@inkeep/impulse-compute 0.0.0-stage → 0.1.0
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/README.md +137 -2
- package/dist/impulse-compute.mjs +1092 -0
- package/dist/internal/launch.js +34 -0
- package/package.json +33 -3
- package/team-mac/host-claim.sh +23 -0
- package/team-mac/host-hold-check.sh +23 -0
- package/team-mac/host-hold-read.sh +17 -0
- package/team-mac/host-hold.sh +88 -0
- package/team-mac/host-prepare.sh +158 -0
- package/team-mac/vm-list.sh +38 -0
- package/team-mac/vm-start.sh +257 -0
- package/team-mac/vm-stop.sh +137 -0
- package/team-mac/vz-start-probe.swift +60 -0
|
@@ -0,0 +1,1092 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// openteammate bundle: {"schema":"openteammate.bundle/provenance@1","source":{"repository":"inkeep/openteammate","commit":"2f737208eb7a3982339959d6bbe78984d9f36185","path":"scripts/offload","tree":"c9494d1cbcdb1e04cca246de09710f7fe38bc9e6","entry":"../../packages/compute/src/main.ts"},"lockfile":{"path":"scripts/offload/pnpm-lock.yaml","sha256":"46fbe6f0274a27c4c2805c68fd50bbc8e9463d1f32b7747945653f766b4ab1e9"},"sources":[{"path":"packages/compute","tree":"860bbdcbe76c884c38c57b77633c6f38f34058a4","lockfile":{"path":"pnpm-lock.yaml","sha256":"9371fec4c0c348519b54cec998038c25b48a9467cd1eeb6bb41e14d9af545e35"}},{"path":"scripts/offload","tree":"c9494d1cbcdb1e04cca246de09710f7fe38bc9e6","lockfile":{"path":"scripts/offload/pnpm-lock.yaml","sha256":"46fbe6f0274a27c4c2805c68fd50bbc8e9463d1f32b7747945653f766b4ab1e9"}},{"path":"scripts/linux-desktop","tree":"43984c3c24e0b737f896c6470b0520e8fd017b7a","lockfile":{"path":"scripts/linux-desktop/pnpm-lock.yaml","sha256":"d9a154dd8aa1710f518cb0feee15f1a087105766f4dfb620a24ce2e678bd6e30"}}],"bundler":{"name":"rolldown","version":"1.2.11"},"format":"esm","platform":"node"}
|
|
3
|
+
import"node:module";import*as e from"node:path";import t,{basename as n,delimiter as r,dirname as i,isAbsolute as a,join as o,resolve as s}from"node:path";import*as c from"node:crypto";import l,{createHash as u,randomUUID as d}from"node:crypto";import{link as f,lstat as p,mkdir as m,readFile as h,rename as g,stat as _,unlink as v,writeFile as y}from"node:fs/promises";import*as ee from"node:zlib";import{crc32 as b,inflateSync as te}from"node:zlib";import*as ne from"node:util";import*as re from"node:stream";import ie,{PassThrough as ae,finished as oe}from"node:stream";import*as se from"node:assert";import*as ce from"node:buffer";import*as x from"node:fs";import le,{accessSync as S,chmodSync as ue,closeSync as de,constants as C,existsSync as fe,mkdirSync as pe,mkdtempSync as w,openSync as me,readFileSync as he,renameSync as T,rmSync as ge,writeFileSync as _e}from"node:fs";import ve from"node:process";import*as ye from"node:os";import be,{constants as xe,tmpdir as Se}from"node:os";import Ce from"node:tty";import*as we from"node:url";import Te,{fileURLToPath as Ee}from"node:url";import*as De from"node:child_process";import{execFile as eee,spawn as Oe}from"node:child_process";import"node:string_decoder";import*as ke from"node:readline";var Ae=Object.create,je=Object.defineProperty,Me=Object.getOwnPropertyDescriptor,tee=Object.getOwnPropertyNames,Ne=Object.getPrototypeOf,Pe=Object.prototype.hasOwnProperty,Fe=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),Ie=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=tee(t),a=0,o=i.length,s;a<o;a++)s=i[a],!Pe.call(e,s)&&s!==n&&je(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=Me(t,s))||r.enumerable});return e},Le=(e,t,n)=>(n=e==null?{}:Ae(Ne(e)),Ie(t||!e||!e.__esModule||!Pe.call(e,`default`)?je(n,`default`,{value:e,enumerable:!0}):n,e)),Re=`0.1.0`;const ze=(e,t)=>{switch(t.length){case 0:return e;case 1:return t[0](e);case 2:return t[1](t[0](e));case 3:return t[2](t[1](t[0](e)));case 4:return t[3](t[2](t[1](t[0](e))));case 5:return t[4](t[3](t[2](t[1](t[0](e)))));case 6:return t[5](t[4](t[3](t[2](t[1](t[0](e))))));case 7:return t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))));case 8:return t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e))))))));case 9:return t[8](t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))))));default:{let n=e;for(let e=0,r=t.length;e<r;e++)n=t[e](n);return n}}},Be={pipe(){return ze(this,arguments)}},Ve=function(){function e(){}return e.prototype=Be,e}(),E=function(e,t){if(typeof e==`function`)return function(){return e(arguments)?t.apply(this,arguments):e=>t(e,...arguments)};switch(e){case 0:case 1:throw RangeError(`Invalid arity ${e}`);case 2:return function(e,n){return arguments.length>=2?t(e,n):function(n){return t(n,e)}};case 3:return function(e,n,r){return arguments.length>=3?t(e,n,r):function(r){return t(r,e,n)}};default:return function(){if(arguments.length>=e)return t.apply(this,arguments);let n=arguments;return function(e){return t(e,...n)}}}},He=e=>e,Ue=e=>()=>e,We=Ue(!0),Ge=Ue(!1),Ke=Ue(void 0),qe=Ke;function Je(e){let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let i=e(n);return t.set(n,i),i}}function Ye(e){let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let i=e(n);return t.set(n,i),i!==n&&t.set(i,i),i}}const Xe=e=>{let t=new Set(Reflect.ownKeys(e));if(e.constructor===Object)return t;e instanceof Error&&t.delete(`stack`);let n=Object.getPrototypeOf(e),r=n;for(;r!==null&&r!==Object.prototype;){let e=Reflect.ownKeys(r);for(let n=0;n<e.length;n++)t.add(e[n]);r=Object.getPrototypeOf(r)}return t.has(`constructor`)&&typeof e.constructor==`function`&&n===e.constructor.prototype&&t.delete(`constructor`),t},Ze=new WeakSet,Qe=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),$e=e=>e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer,et=e=>{try{return new Uint8Array(e)}catch{return}};let tt=0;const nt=()=>{tt++};function rt(e){return typeof e==`string`}function it(e){return typeof e==`number`}function nee(e){return typeof e==`boolean`}function ree(e){return typeof e==`symbol`}function at(e){return rt(e)||it(e)||ree(e)}function ot(e){return typeof e==`function`}function st(e){return e!=null}function ct(e){return!0}function lt(e){return typeof e==`object`&&!!e||ot(e)}const ut=E(2,(e,t)=>lt(e)&&t in e),dt=E(2,(e,t)=>ut(e,`_tag`)&&e._tag===t),ft=`~effect/Hash`,pt=e=>{switch(typeof e){case`number`:return bt(e);case`bigint`:return xt(e.toString(10));case`string`:return xt(e);case`function`:case`object`:if(e===null)break;if(e instanceof Date)return Number.isNaN(e.getTime())?xt(`Invalid Date`):xt(e.toISOString());if(e instanceof RegExp)return xt(e.toString());{if(Ze.has(e))return mt(e);let t=Ot.get(e);if(t!==void 0)return t;if(kt.has(e))return nt(),xt(`[Circular]`);kt.add(e);let n=tt,r;try{if(vt(e))r=e[ft]();else if(typeof e==`function`)r=mt(e);else if($e(e)){let t=et(e);r=t===void 0?mt(e):Tt(t)}else r=e instanceof DataView?Tt(Qe(e)):Array.isArray(e)||ArrayBuffer.isView(e)?Tt(e):e instanceof Map?iee(e):e instanceof Set?aee(e):Ct(e)}finally{kt.delete(e)}return n===tt&&Ot.set(e,r),r}}return _t(ht(xt(String(e))))},mt=e=>(Dt.has(e)||Dt.set(e,_t(Math.random()*4294967296|0)),Dt.get(e)),ht=e=>(e^=e>>>16,e=Math.imul(e,2246822507),e^=e>>>13,e=Math.imul(e,3266489909),e^e>>>16),gt=E(2,(e,t)=>ht(Math.imul(e,2654435761)+Math.imul(t,2246822507))),_t=e=>e&3221225471|e>>>1&1073741824,vt=e=>ut(e,`~effect/Hash`)&&typeof e[`~effect/Hash`]==`function`,yt=new DataView(new ArrayBuffer(8)),bt=e=>{let t=e|0;return t===e?_t(t):(yt.setFloat64(0,e===e?e:NaN),_t(gt(yt.getInt32(0),yt.getInt32(4))))},xt=e=>{let t=5381,n=e.length;for(;n;)t=t*33^e.charCodeAt(--n);return _t(t)},St=(e,t)=>{let n=12289;for(let r of t)n^=gt(pt(r),pt(e[r]));return _t(n)},Ct=e=>St(e,Xe(e)),wt=(e,t)=>n=>{let r=e;for(let e of n)r^=t(e);return _t(r)},Tt=e=>{let t=6151;for(let n of e)t=gt(t,pt(n));return _t(t)},iee=wt(xt(`Map`),([e,t])=>gt(pt(e),pt(t))),Et=xt(`Set`),aee=wt(Et,e=>gt(Et,pt(e))),Dt=new WeakMap,Ot=new WeakMap,kt=new WeakSet,At=`~effect/Equal`;function jt(){return arguments.length===1?e=>Mt(e,arguments[0]):Mt(arguments[0],arguments[1])}function Mt(e,t){if(e===t)return!0;if(e==null||t==null)return!1;let n=typeof e;return n===typeof t?n===`number`&&e!==e&&t!==t?!0:n!==`object`&&n!==`function`||Ze.has(e)||Ze.has(t)?!1:Nt(e,t):!1}function Nt(e,t){let n=Ft.length;for(let r=n;r-->0;)if(Ft[r]===e&&It[r]===t)return!0;if(n)return Pt(e,t);let r=Lt.get(e);r||Lt.set(e,r=new WeakMap);let i=r.get(t);return i===void 0&&r.set(t,i=Pt(e,t)),i}function Pt(e,t){Ft.push(e),It.push(t);try{return oee(e,t)}finally{Ft.pop(),It.pop()}}const Ft=[],It=[],Lt=new WeakMap;function oee(e,t){if(pt(e)!==pt(t))return!1;if(e instanceof Date){if(!(t instanceof Date))return!1;let n=e.getTime(),r=t.getTime();return n===r||Number.isNaN(n)&&Number.isNaN(r)}if(e instanceof RegExp)return t instanceof RegExp&&e.toString()===t.toString();let n=Ut(e);if(n!==Ut(t)||typeof e==`function`&&!n)return!1;if(n)return e[At](t);if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:see(e,t);if($e(e)){if(!$e(t)||e instanceof ArrayBuffer!=t instanceof ArrayBuffer)return!1;let n=et(e),r=et(t);return n!==void 0&&r!==void 0&&Rt(n,r)}if(ArrayBuffer.isView(e)){let n=e instanceof DataView;return!ArrayBuffer.isView(t)||e.byteLength!==t.byteLength||n!==t instanceof DataView?!1:n?Rt(Qe(e),Qe(t)):Rt(e,t)}return e instanceof Map?!(t instanceof Map)||e.size!==t.size?!1:Bt(e,t,Vt,Ht):e instanceof Set?!(t instanceof Set)||e.size!==t.size?!1:Bt(e,t,pt,Mt):zt(e,t)}function see(e,t){for(let n=0;n<e.length;n++)if(!Mt(e[n],t[n]))return!1;return!0}function Rt(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function zt(e,t){let n=Xe(e),r=Xe(t);if(n.size!==r.size)return!1;for(let i of n)if(!r.has(i)||!Mt(e[i],t[i]))return!1;return!0}function Bt(e,t,n,r){let i=new Map,a=0;for(let e of t){let t=n(e),r=i.get(t);r?r.push(e):i.set(t,[e]),a++}outer:for(let t of e){let e=i.get(n(t));if(e){for(let n=0;n<e.length;n++)if(r(t,e[n])){e[n]=e[e.length-1],e.pop(),a--;continue outer}}return!1}return a===0}const Vt=e=>pt(e[0]),Ht=(e,t)=>Mt(e[0],t[0])&&Mt(e[1],t[1]),Ut=e=>ut(e,`~effect/Equal`)&&typeof e[`~effect/Equal`]==`function`,Wt=Symbol.for(`~effect/Redactable`),Gt=e=>ut(e,Wt);function Kt(e){return Gt(e)?qt(e):e}function qt(e){return e[Wt](globalThis[`~effect/Fiber/currentFiber`]?.context??cee)}const Jt=`~effect/Fiber/currentFiber`,Yt=new Map,cee={"~effect/Context":{},base:Yt,depth:0,mapUnsafe:Yt,pipe(){return ze(this,arguments)}};function Xt(e,t){let n=t?.space??0,r=new WeakSet,i=n?typeof n==`number`?` `.repeat(n):n:``,a=e=>i.repeat(e),o=(e,t)=>{let n=e?.constructor;return n&&n!==Object.prototype.constructor&&n.name?`${n.name}(${t})`:t},s=e=>{try{return Reflect.ownKeys(e)}catch{return[`[ownKeys threw]`]}};function c(e,t=0){try{return l(e,t)}catch{return(typeof e==`object`&&e||typeof e==`function`)&&r.delete(e),`[inspection threw]`}}function l(e,n=0){if(typeof e==`string`)return JSON.stringify(e);if(typeof e==`number`||e==null||typeof e==`boolean`||typeof e==`symbol`)return String(e);if(typeof e==`bigint`)return String(e)+`n`;if(typeof e==`object`||typeof e==`function`){if(r.has(e))return lee;r.add(e);let l;if(Wt in e)l=c(qt(e),n);else if(Array.isArray(e))l=!i||e.length<=1?`[${e.map(e=>c(e,n)).join(`,`)}]`:`[\n${a(n+1)}${e.map(e=>c(e,n+1)).join(`,
|
|
4
|
+
`+a(n+1))}\n${a(n)}]`;else if(e instanceof Date)l=dee(e);else if(!t?.ignoreToString&&ut(e,`toString`)&&typeof e.toString==`function`&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString){let t=fee(e);l=e instanceof Error&&e.cause!==void 0?`${t} (cause: ${c(e.cause,n)})`:t}else if(Symbol.iterator in e)l=`${e.constructor.name}(${c(Array.from(e),n)})`;else{let t=s(e);if(!i||t.length<=1){let r=`{${t.map(t=>`${Zt(t)}:${c(Qt(e,t),n)}`).join(`,`)}}`;l=o(e,r)}else{let r=`{\n${t.map(t=>`${a(n+1)}${Zt(t)}: ${c(Qt(e,t),n+1)}`).join(`,
|
|
5
|
+
`)}\n${a(n)}}`;l=o(e,r)}}return r.delete(e),l}return String(e)}return c(e,0)}const lee=`[Circular]`;function Zt(e){return typeof e==`string`?JSON.stringify(e):String(e)}function uee(e){return e.map(e=>`[${Zt(e)}]`).join(``)}function dee(e){try{return e.toISOString()}catch{return`Invalid Date`}}function fee(e){try{let t=e.toString();return typeof t==`string`?t:String(t)}catch{return`[toString threw]`}}function Qt(e,t){try{return e[t]}catch{return`[property access threw]`}}function $t(e,t){let n=[],r=new WeakMap;return JSON.stringify(e,function(e,t){let i=Object.getOwnPropertyDescriptor(r.get(this)??this,e)?.value,a=ut(i,Wt)?Kt(i):Kt(t);if(typeof a==`bigint`)return Xt(a);if(typeof a!=`object`||!a)return a;let o=a instanceof Error&&!ut(a,`toJSON`)?{...a,name:a.name,message:a.message}:a;for(;n.length>0&&n[n.length-1]!==this;)n.pop();if(n.includes(a))return;if(n.push(a),o!==a&&n.push(o),!pee(o)||tn(o))return o;let s=en(o);return r.set(s,o),n.push(s),s},t?.space)??`null`}function pee(e){for(let t of Object.getOwnPropertyNames(e))if(Object.getOwnPropertyDescriptor(e,t)?.get!==void 0)return!0;return!1}function en(e){let t=Array.isArray(e)?[]:{},n=Array.isArray(e)?Array.from({length:e.length},(e,t)=>String(t)):Object.keys(e);for(let r of n)Object.defineProperty(t,r,{enumerable:!0,get:()=>{let t=Reflect.get(e,r);return Object.getOwnPropertyDescriptor(e,r)?.get===void 0?t:Kt(t)}});return t}function tn(e){for(let t of[Number.prototype.valueOf,Boolean.prototype.valueOf,String.prototype.valueOf])try{return Reflect.apply(t,e,[]),!0}catch{}return!1}const nn=Symbol.for(`nodejs.util.inspect.custom`),rn=e=>{try{return e=Kt(e),ut(e,`toJSON`)&&ot(e.toJSON)&&e.toJSON.length===0?e.toJSON():Array.isArray(e)?e.map(rn):e}catch{return`[toJSON threw]`}},an=(e,t=2)=>{if(typeof e==`string`)return e;try{return typeof e==`object`?$t(e,{space:t}):Xt(e,{space:t})}catch{return String(e)}},on={toJSON(){return rn(this)},[nn](){return this.toJSON()},toString(){return Xt(this.toJSON())}},sn=(()=>{let e=Object.getOwnPropertyDescriptor(Error,`stackTraceLimit`);return e===void 0?Object.isExtensible(Error):Object.hasOwn(e,`writable`)?e.writable===!0:e.set!==void 0})(),cn=()=>Error.stackTraceLimit,ln=e=>{sn&&(Error.stackTraceLimit=e)};var un=class{constructor(e){this.value=e,this.done=!1}next(e){return this.done?(this.value=e,this):(this.done=!0,{value:this.value,done:!1})}};const dn=(()=>{let e=`~effect/Utils/internal`,t={[e]:e=>e()},n={[e]:e=>{try{return e()}finally{}}},r=cn();if(r===0)return n[e];ln(2);let i=t[e](()=>Error());return ln(r),i.stack?.includes(e)===!0?t[e]:n[e]})();function fn(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}):e[t]=n}function pn(e,t){if(!Object.hasOwn(t,`__proto__`)){Object.assign(e,t);return}for(let n of Reflect.ownKeys(t))Object.prototype.propertyIsEnumerable.call(t,n)&&fn(e,n,t[n])}const mn=`~effect/Effect`,hn=`~effect/Exit`,gn={_A:He,_E:He,_R:He},_n=`${mn}/identifier`,D=`${mn}/args`,vn=`${mn}/evaluate`,yn=`${mn}/successCont`,bn=`${mn}/failureCont`,xn=`${mn}/ensureCont`,Sn=Symbol.for(`effect/Effect/Yield`),Cn={pipe(){return ze(this,arguments)},toJSON(){return{...this}},toString(){return Xt(this.toJSON(),{ignoreToString:!0,space:2})},[nn](){return this.toJSON()}},wn={[mn]:gn,...Cn,[Symbol.iterator](){return new un(this)},toJSON(){return{_id:`Effect`,op:this[_n],...D in this?{args:this[D]}:void 0}}},Tn=e=>ut(e,mn),En=e=>ut(e,hn),Dn=`~effect/Cause`,On=`~effect/Cause/Reason`,kn=e=>ut(e,Dn);var An=class{constructor(e){this[Dn]=Dn,this.reasons=e}pipe(){return ze(this,arguments)}toJSON(){return{_id:`Cause`,reasons:this.reasons.map(e=>e.toJSON())}}toString(){return`Cause(${Xt(this.reasons)})`}[nn](){return this.toJSON()}[At](e){return kn(e)&&this.reasons.length===e.reasons.length&&this.reasons.every((t,n)=>jt(t,e.reasons[n]))}[ft](){return Tt(this.reasons)}};const jn=new WeakMap;var Mn=class{[On];annotations;_tag;constructor(e,t,n){if(this[On]=On,this._tag=e,t!==Nn&&typeof n==`object`&&n&&t.size>0){let e=jn.get(n);e&&(t=new Map([...e,...t])),jn.set(n,t)}this.annotations=t}annotate(e,t){if(e.mapUnsafe.size===0)return this;let n=new Map(this.annotations);if(e.mapUnsafe.forEach((e,r)=>{t?.overwrite!==!0&&n.has(r)||n.set(r,e)}),t?.overwrite!==!0&&n.size===this.annotations.size)return this;let r=Object.assign(Object.create(Object.getPrototypeOf(this)),this);return r.annotations=n,r}pipe(){return ze(this,arguments)}toString(){return Xt(this)}[nn](){return this.toString()}};const Nn=new Map;var Pn=class extends Mn{constructor(e,t=Nn){super(`Fail`,t,e),this.error=e}toString(){return`Fail(${Xt(this.error)})`}toJSON(){return{_tag:`Fail`,error:this.error}}[At](e){return Hn(e)&&jt(this.error,e.error)&&jt(this.annotations,e.annotations)}[ft](){return gt(xt(this._tag))(gt(pt(this.error))(pt(this.annotations)))}};const Fn=e=>new An(e),In=(e,t)=>{let n=new Map,r=[];for(let i of e.concat(t)){let e=pt(i),t=n.get(e);if(t===void 0)n.set(e,[i]);else if(t.some(e=>jt(e,i)))continue;else t.push(i);r.push(i)}return r},Ln=E(2,(e,t)=>{if(e.reasons.length===0)return t;if(t.reasons.length===0)return e;let n=new An(In(e.reasons,t.reasons));return jt(e,n)?e:n}),Rn=(e,t)=>{let n=e.reasons.slice();for(let e of t.reasons)Wn(e)&&!n.some(t=>Wn(t)&&t.fiberId===e.fiberId&&t.annotations===e.annotations)&&n.push(e);return n.length===e.reasons.length?e:new An(n)},mee=new An([]),hee=e=>new An([new Pn(e)]);var zn=class extends Mn{constructor(e,t=Nn){super(`Die`,t,e),this.defect=e}toString(){return`Die(${Xt(this.defect)})`}toJSON(){return{_tag:`Die`,defect:this.defect}}[At](e){return Un(e)&&jt(this.defect,e.defect)&&jt(this.annotations,e.annotations)}[ft](){return gt(xt(this._tag))(gt(pt(this.defect))(pt(this.annotations)))}};const Bn=e=>new An([new zn(e)]),Vn=E(e=>kn(e[0]),(e,t,n)=>t.mapUnsafe.size===0?e:new An(e.reasons.map(e=>e.annotate(t,n)))),Hn=e=>e._tag===`Fail`,Un=e=>e._tag===`Die`,Wn=e=>e._tag===`Interrupt`;function Gn(e){return er(`Effect.evaluate: Not implemented`)}const Kn=e=>({...wn,[_n]:e.op,[vn]:e[vn]??Gn,[yn]:e[yn],[bn]:e[bn],[xn]:e[xn]}),qn=e=>{let t=Kn(e),n=function(e){this[D]=e};return n.prototype=t,function(e){return new n(e)}},Jn=e=>{let t={[hn]:hn,_tag:e.op,get[e.prop](){return this[D]},...Kn(e),toString(){return`${e.op}(${Xt(this[D])})`},toJSON(){return{_id:`Exit`,_tag:e.op,[e.prop]:this[D]}},[At](e){return En(e)&&e._tag===this._tag&&jt(this[D],e[D])},[ft](){return gt(xt(e.op),pt(this[D]))}},n=function(e){this[D]=e};return n.prototype=t,function(e){return new n(e)}},Yn=Jn({op:`Success`,prop:`value`,[vn](e){let t=e.getCont(yn);return t?t[yn](this[D],e,this):e.yieldWith(this)}}),Xn={key:`effect/Cause/StackTrace`},Zn={key:`effect/Cause/InterruptorStackTrace`},Qn=Jn({op:`Failure`,prop:`cause`,[vn](e){let t=this[D],n=!1;e.cache.stackFrame&&(t=Vn(t,{mapUnsafe:new Map([[Xn.key,e.cache.stackFrame]])}),n=!0);let r=e.getCont(bn),i=e._interruptedCause;if(i&&e.interruptible){let a=!1;for(;r&&e.interruptible;)a||=_n in r,r=e.getCont(bn);a&&(t=Fn(t.reasons.filter(e=>e._tag!==`Fail`))),t=Rn(t,i),n=!0}return r?r[bn](t,e,n?void 0:this):e.yieldWith(n?Qn(t):this)}}),$n=e=>Qn(hee(e)),er=e=>Qn(Bn(e)),tr=qn({op:`WithFiber`,[vn](e){return this[D](e)}}),gee=function(){class e extends globalThis.Error{}let t=Kn({op:`YieldableError`,[vn](){return $n(this)}});return delete t.toString,Object.assign(e.prototype,t),e}(),nr=function(){let e=Symbol.for(`effect/Data/Error/plainArgs`);return class extends gee{constructor(t){super(t?.message,t?.cause?{cause:t.cause}:void 0),t&&(pn(this,t),Object.defineProperty(this,e,{value:t,enumerable:!1}))}toJSON(){return{...this[e],...this}}}}(),rr=e=>{class t extends nr{_tag=e}return t.prototype.name=e,t},ir=e=>ut(e,`~effect/Cause/Done`),ar=e=>Kn({op:e.label,[vn]:e.evaluate}),or=`~effect/Option`,sr={[or]:{_A:e=>e},...Cn,[Symbol.iterator](){return new un(this)}},cr=Object.defineProperty(Object.assign(Object.create(sr),{_tag:`Some`,_op:`Some`,[At](e){return dr(e)&&pr(e)&&jt(this.value,e.value)},[ft](){return gt(pt(this._tag))(pt(this.value))},toString(){return`some(${Xt(this.value)})`},toJSON(){return{_id:`Option`,_tag:this._tag,value:rn(this.value)}}}),"valueOrUndefined",{get(){return this.value}}),lr=pt(`None`),ur=Object.assign(Object.create(sr),{_tag:`None`,_op:`None`,valueOrUndefined:void 0,[At](e){return dr(e)&&fr(e)},[ft](){return lr},toString(){return`none()`},toJSON(){return{_id:`Option`,_tag:this._tag}}}),dr=e=>ut(e,or),fr=e=>e._tag===`None`,pr=e=>e._tag===`Some`,mr=Object.create(ur),hr=function(e){this.value=e};hr.prototype=cr;const gr=e=>new hr(e),_r=`~effect/Result`,vr={[_r]:{_A:e=>e,_E:e=>e},...Cn,[Symbol.iterator](){return new un(this)}},yr=Object.assign(Object.create(vr),{_tag:`Success`,_op:`Success`,[At](e){return xr(e)&&Cr(e)&&jt(this.success,e.success)},[ft](){return gt(pt(this._tag))(pt(this.success))},toString(){return`success(${Xt(this.success)})`},toJSON(){return{_id:`Result`,_tag:this._tag,value:rn(this.success)}}}),br=Object.assign(Object.create(vr),{_tag:`Failure`,_op:`Failure`,[At](e){return xr(e)&&Sr(e)&&jt(this.failure,e.failure)},[ft](){return gt(pt(this._tag))(pt(this.failure))},toString(){return`failure(${Xt(this.failure)})`},toJSON(){return{_id:`Result`,_tag:this._tag,failure:rn(this.failure)}}}),xr=e=>ut(e,_r),Sr=e=>e._tag===`Failure`,Cr=e=>e._tag===`Success`,wr=function(e){this.failure=e};wr.prototype=br;const Tr=e=>new wr(e),Er=function(e){this.success=e};Er.prototype=yr;const Dr=e=>new Er(e);function Or(e){return(t,n)=>t===n?0:e(t,n)}const kr=Or((e,t)=>e<t?-1:1),Ar=Or((e,t)=>globalThis.Number.isNaN(e)&&globalThis.Number.isNaN(t)?0:globalThis.Number.isNaN(e)?-1:globalThis.Number.isNaN(t)?1:e<t?-1:1),jr=E(2,(e,t)=>Or((n,r)=>e(t(n),t(r)))),Mr=e=>E(2,(t,n)=>e(t,n)===1),Nr=()=>mr,Pr=gr,Fr=fr,Ir=`~effect/Context/Service`,Lr=function(){function e(){}let t=e;Object.setPrototypeOf(t,Rr);let n=(e,n)=>(t.key=e,n?.defaultValue&&(t[Br]=Br,t.defaultValue=n.defaultValue),n?.make&&(t.make=n.make),n?.fiberCached&&zr.add(e),t);return arguments.length>0?n(arguments[0],arguments[1]):n},Rr={[Ir]:Ir,...ar({label:`Service`,evaluate(e){return Yn(ii(e.context,this))}}),toJSON(){return{_id:`Service`,key:this.key}},of(e){return e},context(e){return ti(this,e)},use(e){return tr(t=>e(ii(t.context,this)))},useSync(e){return tr(t=>Yn(e(ii(t.context,this))))}},zr=new Set,Br=`~effect/Context/Reference`,Vr=`~effect/Context`,Hr=(e,t,n,r,i)=>{let a=Object.create(Yr);return a.cacheRoot=e??a,a.base=t,a.overlay=n,a.depth=r,a._flat=void 0,a.baseHits=0,a.maxDepth=i,a},Ur=(e,t)=>{t&&(Ur(e,t.parent),e.set(t.key,t.value))},Wr=e=>{if(e._flat)return e._flat;if(!e.overlay)return e._flat=e.base;let t=new Map(e.base);return Ur(t,e.overlay),e._flat=t},Gr=(e,t)=>{let n=new Map(e.mapUnsafe);return t(n),Hr(void 0,n,void 0,0,e.maxDepth)},Kr=Symbol(),qr=(e,t)=>{let n=e;for(let e=n.overlay;e;e=e.parent)if(e.key===t)return e.value;let r=n.base.get(t);return r===void 0&&!n.base.has(t)?Kr:(n.overlay&&++n.baseHits>=n.base.size&&n.baseHits>=8&&(n.base=Wr(n),n.overlay=void 0,n.depth=0),r)},Jr=(e,t)=>{let n=t?.maxDepth;return Hr(void 0,e,void 0,0,Number.isInteger(n)&&n>=0?n:8)},Yr={get mapUnsafe(){return Wr(this)},...Cn,[Vr]:{_Services:e=>e},toJSON(){return{_id:`Context`,services:Array.from(this.mapUnsafe).map(([e,t])=>({key:e,value:t}))}},[At](e){if(!Zr(e))return!1;let t=this.mapUnsafe,n=e.mapUnsafe;if(t.size!==n.size)return!1;for(let[e,r]of t)if(!n.has(e)||!jt(r,n.get(e)))return!1;return!0},[ft](){return bt(this.mapUnsafe.size)}},Xr=(e,t)=>e.cacheRoot===t.cacheRoot,Zr=e=>ut(e,Vr),Qr=e=>!!e[Br],$r=()=>ei,ei=Jr(new Map),ti=(e,t)=>Jr(new Map([[e.key,t]])),ni=E(3,(e,t,n)=>_ee(e,t.key,n)),_ee=(e,t,n)=>{let r=e,i=zr.has(t)?void 0:r.cacheRoot;if(r.depth>=r.maxDepth){let e=new Map(r._flat??r.base);return r._flat||Ur(e,r.overlay),e.set(t,n),Hr(i,e,void 0,0,r.maxDepth)}return Hr(i,r.base,{key:t,value:n,parent:r.overlay},r.depth+1,r.maxDepth)},vee=E(2,(e,t)=>ri(e,t.key)),ri=(e,t)=>{let n=qr(e,t);return n===Kr?void 0:n},ii=E(2,(e,t)=>{let n=qr(e,t.key);if(n===Kr){if(Qr(t))return yee(t);throw bee(t)}return n}),ai=`~effect/Context/defaultValue`,yee=e=>ai in e?e[ai]:e[ai]=e.defaultValue(),bee=e=>{let t=Error(`Service not found${e.key?`: ${String(e.key)}`:``}`);if(t.stack){let e=t.stack.split(`
|
|
6
|
+
`);e.splice(1,3),t.stack=e.join(`
|
|
7
|
+
`)}return t},xee=E(2,(e,t)=>e.mapUnsafe.size===0?t:t.mapUnsafe.size===0?e:Gr(e,e=>t.mapUnsafe.forEach((t,n)=>e.set(n,t)))),See=(...e)=>{let t=new Map;for(let n=0;n<e.length;n++)e[n].mapUnsafe.forEach((e,n)=>{t.set(n,e)});return Jr(t)},oi=Lr,si=e=>e.length>0,ci=Dr,li=Tr,ui=Sr,di=globalThis.Array,Cee=e=>di.isArray(e)?e:di.from(e),fi=E(2,(e,t)=>[...e,t]);di.isArray;const wee=si,Tee=si,pi=()=>[],Eee=E(2,(e,t)=>e.map(t)),mi=`~effect/Duration`,hi=BigInt(0),gi=BigInt(1),Dee=BigInt(2),_i=BigInt(10),vi=BigInt(1e3),yi=BigInt(1e6),bi=BigInt(1e9),xi=BigInt(6e10),Si=BigInt(36e11),Ci=BigInt(864e11),wi=BigInt(6048e11),Ti=e=>BigInt(Math.sign(e)*Math.round(Math.abs(e))),Ei=e=>Number.isInteger(e)?BigInt(e)*yi:Ti(e*1e6),Di=e=>Vi(Number.isFinite(e)?Ti(e):e),Oi=(e,t)=>{let n=Number(e);if(Number.isFinite(n))return n/t;let r=BigInt(t);return Number(e/r)+Number(e%r)/t},ki=(e,t)=>{let n=e.indexOf(`.`);if(n===-1)return BigInt(e)*t;let r=e[0]===`-`,i=e.slice(n+1),a=_i**BigInt(i.length),o=(BigInt(e.slice(+!!r,n))*a+BigInt(i))*t;return Ai(r?-o:o,a)},Ai=(e,t)=>{let n=e<hi?-e:e,r=n/t+(n%t*Dee>=t?gi:hi);return e<hi?-r:r},ji=(e,t)=>{let n=Number(e)*t;if(!Number.isFinite(n))return Vi(n);let r=ki(e,BigInt(t)*yi);return Vi(Number.isInteger(n)&&BigInt(n)*yi===r?n:r)},Mi=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,Ni=e=>{switch(typeof e){case`number`:return qi(e);case`bigint`:return Ki(e);case`string`:{if(e===`Infinity`)return Wi;if(e===`-Infinity`)return Gi;let t=Mi.exec(e);if(!t)break;let[n,r,i]=t;if(i===`nano`||i===`nanos`)return Ki(ki(r,gi));if(i===`micro`||i===`micros`)return Ki(ki(r,vi));switch(i){case`milli`:case`millis`:return ji(r,1);case`second`:case`seconds`:return ji(r,1e3);case`minute`:case`minutes`:return ji(r,6e4);case`hour`:case`hours`:return ji(r,36e5);case`day`:case`days`:return ji(r,864e5);case`week`:case`weeks`:return ji(r,6048e5)}break}case`object`:{if(e===null)break;if(mi in e)return e;if(Array.isArray(e)){if(e.length!==2||!e.every(it))return Ii(e);if(Number.isNaN(e[0])||Number.isNaN(e[1]))return Ui;if(e[0]===-1/0||e[1]===-1/0)return Gi;if(e[0]===1/0||e[1]===1/0)return Wi;let t=e[0]*1e9+e[1];return Number.isFinite(t)&&Number.isInteger(e[0])&&Number.isInteger(e[1])?Vi(BigInt(e[0])*bi+BigInt(e[1])):Di(t)}let t=e,n=0;if(t.weeks&&(n+=t.weeks*6048e5),t.days&&(n+=t.days*864e5),t.hours&&(n+=t.hours*36e5),t.minutes&&(n+=t.minutes*6e4),t.seconds&&(n+=t.seconds*1e3),t.milliseconds&&(n+=t.milliseconds),!t.microseconds&&!t.nanoseconds){if(!Number.isFinite(n))return Vi(n);let e=Fi(t);return e===void 0||BigInt(n)*yi===e?Vi(n):Vi(e)}let r=n*1e6+(t.microseconds??0)*1e3+(t.nanoseconds??0),i=Number.isFinite(r)?Fi(t):void 0;return i===void 0?Di(r):Vi(i)}}return Ii(e)},Pi=e=>!e||Number.isInteger(e),Fi=e=>{if(!Pi(e.weeks)||!Pi(e.days)||!Pi(e.hours)||!Pi(e.minutes)||!Pi(e.seconds)||!Pi(e.milliseconds)||!Pi(e.microseconds)||!Pi(e.nanoseconds))return;let t=hi;return e.weeks&&(t+=BigInt(e.weeks)*wi),e.days&&(t+=BigInt(e.days)*Ci),e.hours&&(t+=BigInt(e.hours)*Si),e.minutes&&(t+=BigInt(e.minutes)*xi),e.seconds&&(t+=BigInt(e.seconds)*bi),e.milliseconds&&(t+=BigInt(e.milliseconds)*yi),e.microseconds&&(t+=BigInt(e.microseconds)*vi),e.nanoseconds&&(t+=BigInt(e.nanoseconds)),t},Ii=e=>{throw Error(`Invalid Input: ${e}`)},Li={_tag:`Millis`,millis:0},Ri={_tag:`Infinity`},zi={_tag:`NegativeInfinity`},Bi={[mi]:mi,[ft](){switch(this.value._tag){case`Millis`:return pt(Ei(this.value.millis));case`Nanos`:return pt(this.value.nanos);default:return Ct(this.value)}},[At](e){return Hi(e)&&$i(this,e)},toString(){switch(this.value._tag){case`Infinity`:return`Infinity`;case`NegativeInfinity`:return`-Infinity`;case`Nanos`:return`${this.value.nanos} nanos`;case`Millis`:return`${this.value.millis} millis`}},toJSON(){switch(this.value._tag){case`Millis`:return{_id:`Duration`,_tag:`Millis`,millis:this.value.millis};case`Nanos`:return{_id:`Duration`,_tag:`Nanos`,nanos:String(this.value.nanos)};case`Infinity`:return{_id:`Duration`,_tag:`Infinity`};case`NegativeInfinity`:return{_id:`Duration`,_tag:`NegativeInfinity`}}},[nn](){return this.toJSON()},pipe(){return ze(this,arguments)}},Vi=e=>{let t=Object.create(Bi);return t.value=typeof e==`number`?isNaN(e)||e===0||Object.is(e,-0)?Li:Number.isFinite(e)?Number.isInteger(e)?{_tag:`Millis`,millis:e}:{_tag:`Nanos`,nanos:Ei(e)}:e>0?Ri:zi:e===hi?Li:{_tag:`Nanos`,nanos:e},t},Hi=e=>ut(e,mi),Ui=Vi(0),Wi=Vi(1/0),Gi=Vi(-1/0),Ki=e=>Vi(e),qi=e=>Vi(e),Ji=e=>Xi(Ni(e),{onMillis:He,onNanos:e=>Oi(e,1e6),onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0}),Yi=e=>{let t=Ni(e);switch(t.value._tag){case`Infinity`:case`NegativeInfinity`:throw Error(`Cannot convert infinite duration to nanos`);case`Nanos`:return t.value.nanos;case`Millis`:return Ei(t.value.millis)}},Xi=E(2,(e,t)=>{switch(e.value._tag){case`Millis`:return t.onMillis(e.value.millis);case`Nanos`:return t.onNanos(e.value.nanos);case`Infinity`:return t.onInfinity();case`NegativeInfinity`:return(t.onNegativeInfinity??t.onInfinity)()}}),Zi=E(3,(e,t,n)=>e.value._tag===`Infinity`||e.value._tag===`NegativeInfinity`||t.value._tag===`Infinity`||t.value._tag===`NegativeInfinity`?n.onInfinity(e,t):e.value._tag===`Millis`?t.value._tag===`Millis`?n.onMillis(e.value.millis,t.value.millis):n.onNanos(Yi(e),t.value.nanos):n.onNanos(e.value.nanos,Yi(t))),Qi=(e,t)=>Zi(e,t,{onMillis:(e,t)=>e===t,onNanos:(e,t)=>e===t,onInfinity:(e,t)=>e.value._tag===t.value._tag}),$i=E(2,(e,t)=>Qi(e,t)),ea=oi(`effect/Scheduler`,{fiberCached:!0,defaultValue:()=>new aa}),ta=e=>{let t=!1;return Promise.resolve().then(()=>{t||e()}),()=>{t=!0}},na=`setImmediate`in globalThis?e=>{let t=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(t)}:e=>{let t=setTimeout(e,0);return()=>clearTimeout(t)},ra=e=>{try{return na(e)}catch{return ta(e)}};var ia=class{buckets=[];scheduleTask(e,t){let n=this.buckets,r=n.length,i,a=0;for(;a<r&&!(n[a][0]>t);a++)i=n[a];i&&i[0]===t?i[1].push(e):a===r?n.push([t,[e]]):n.splice(a,0,[t,[e]])}drain(){let e=this.buckets;return this.buckets=[],e}},aa=class{executionMode;setImmediate;constructor(e=`async`,t){this.executionMode=e,this.setImmediate=t??(e===`sync`?ta:ra)}shouldYield(e){return e.currentOpCount>=e.cache.maxOpsBeforeYield}makeDispatcher(){return new oa(this.setImmediate)}},oa=class{tasks=new ia;running=void 0;setImmediate;constructor(e=ra){this.setImmediate=e}scheduleTask(e,t){this.tasks.scheduleTask(e,t),this.running===void 0&&(this.running=this.setImmediate(this.afterScheduled))}afterScheduled=()=>{this.running=void 0,this.runTasks()};runTasks(){let e=this.tasks.drain();for(let t=0;t<e.length;t++){let n=e[t][1];for(let e=0;e<n.length;e++)n[e]()}}flush(){for(;this.tasks.buckets.length>0;)this.running!==void 0&&(this.running(),this.running=void 0),this.runTasks()}};const sa=oi(`effect/Scheduler/MaxOpsBeforeYield`,{fiberCached:!0,defaultValue:()=>2048}),ca=oi(`effect/Scheduler/PreventSchedulerYield`,{fiberCached:!0,defaultValue:()=>!1}),la=rr,ua=oi(`effect/References/CurrentStackFrame`,{fiberCached:!0,defaultValue:Ke}),da=oi(`effect/References/TracerEnabled`,{fiberCached:!0,defaultValue:We}),fa=oi(`effect/References/CurrentLogAnnotations`,{defaultValue:()=>({})}),pa=oi(`effect/References/CurrentLogLevel`,{fiberCached:!0,defaultValue:()=>`Info`}),ma=oi(`effect/References/MinimumLogLevel`,{fiberCached:!0,defaultValue:()=>`Info`}),ha=oi(`effect/References/UnhandledLogLevel`,{defaultValue:()=>`Error`}),ga=oi(`effect/References/CurrentLogSpans`,{defaultValue:()=>[]});var _a=class extends Mn{constructor(e,t=Nn){super(`Interrupt`,t,`Interrupted`),this.fiberId=e}toString(){return`Interrupt(${this.fiberId})`}toJSON(){return{_tag:`Interrupt`,fiberId:this.fiberId}}[At](e){return Wn(e)&&this.fiberId===e.fiberId&&this.annotations===e.annotations}[ft](){return xt(`${this._tag}:${this.fiberId}`)}};const va=e=>new An([new _a(e)]),ya=e=>e.reasons.some(Hn),ba=e=>{for(let t=0;t<e.reasons.length;t++){let n=e.reasons[t];if(n._tag===`Fail`)return ci(n.error)}return li(e)},xa=e=>e.reasons.some(Un),Sa=e=>xa(e)&&ya(e)?Fn(e.reasons.map(e=>e._tag===`Fail`&&!ir(e.error)?new zn(e.error,e.annotations):e)):e,Ca=e=>xa(e)?li(Sa(e)):ba(e),wa=e=>e.reasons.some(Wn),Ta=e=>e.reasons.length>0&&e.reasons.every(Wn),Ea=E(2,(e,t)=>{let n=!1,r=e.reasons.map(e=>Hn(e)?(n=!0,new Pn(t(e.error),e.annotations)):e);return n?Fn(r):e}),Da=e=>{let t;for(let n of e.reasons){if(n._tag===`Fail`)return n.error;n._tag===`Die`&&(t??=n)}return t===void 0?e.reasons.length>0?new globalThis.Error(`All fibers interrupted without error`):new globalThis.Error(`Empty cause`):t.defect},Oa=(e,t)=>{let n=[],r=[];if(e.reasons.length===0)return n;let i=cn();i!==0&&ln(1);try{for(let i of e.reasons){if(i._tag===`Interrupt`){r.push(i);continue}n.push(ka(i._tag===`Die`?i.defect:i.error,i.annotations,t))}if(n.length===0){let e=Error(`The fiber was interrupted by:`);e.name=`InterruptCause`,e.stack=Pa(e,r);let i=new globalThis.Error(`All fibers interrupted without error`,{cause:e});i.name=`InterruptError`,i.stack=`${i.name}: ${i.message}`,n.push(ka(i,r[0].annotations,t))}}finally{i!==0&&ln(i)}return n},ka=(e,t,n,r=new Set)=>{let i=typeof e,a;if(e&&i===`object`){r.add(e);let i=e.cause;if(a=new globalThis.Error(Aa(e),{cause:i!==void 0&&!r.has(i)?ka(i,void 0,void 0,r):void 0}),typeof e.name==`string`&&(a.name=e.name),typeof e.stack==`string`)a.stack=Ma(e.stack,a,t);else{let e=`${a.name}: ${a.message}`;a.stack=t?Na(e,t):e}n?.includeCauseInStack&&(a.stack=La(a));for(let t of Object.keys(e))t in a||(a[t]=e[t])}else{a=new globalThis.Error(e?i===`string`?e:$t(e):`Unknown error: ${e}`);let n=`${a.name}: ${a.message}`;a.stack=t?Na(n,t):n}return a},Aa=e=>{if(typeof e.message==`string`)return e.message;if(typeof e.toString==`function`&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString)try{return e.toString()}catch{}return $t(e)},ja=/\((.*)\)/g,Ma=(e,t,n)=>{let r=`${t.name}: ${t.message}`,i=(e.startsWith(r)?e.slice(r.length):e).split(`
|
|
8
|
+
`),a=[r];for(let e=1;e<i.length&&!/Generator\.next|~effect\/(?:Effect|Utils)/.test(i[e]);e++)a.push(i[e]);return n?Na(a.join(`
|
|
9
|
+
`),n):a.join(`
|
|
10
|
+
`)},Na=(e,t)=>{let n=t?.get(Xn.key);return n&&(e=`${e}\n${Fa(n)}`),e},Pa=(e,t)=>{let n=[`${e.name}: ${e.message}`];for(let e of t){let t=e.fiberId===void 0?`unknown`:`#${e.fiberId}`,r=e.annotations.get(Zn.key);n.push(` at fiber (${t})`),r&&n.push(Fa(r))}return n.join(`
|
|
11
|
+
`)},Fa=e=>{let t=[],n=e,r=0;for(;n&&r<10;){let e=n.stack();if(e){let r=e.matchAll(ja),i=!1;for(let[,e]of r)i=!0,t.push(` at ${n.name} (${e})`);i||t.push(` at ${n.name} (${e.replace(/^at /,``)})`)}else t.push(` at ${n.name}`);n=n.parent,r++}return t.join(`
|
|
12
|
+
`)},Ia=e=>Oa(e).map(La).join(`
|
|
13
|
+
`),La=e=>e.cause?`${e.stack} {\n${Ra(e.cause,` `)}\n}`:e.stack,Ra=(e,t)=>{let n=e.stack.split(`
|
|
14
|
+
`),r=`${t}[cause]: ${n[0]}`;for(let e=1,i=n.length;e<i;e++)r+=`\n${t}${n[e]}`;return e.cause&&(r+=` {\n${Ra(e.cause,`${t} `)}\n${t}}`),r},za={_A:He,_E:He},Ba={id:0},Va=(()=>{try{return globalThis.process?.getBuiltinModule?.(`node:async_hooks`)?.AsyncResource}catch{return}})(),Ha=()=>Va===void 0?void 0:new Va(`effect/Fiber`),Ua=()=>globalThis[Jt];var Wa=class{constructor(e,t=!0){this.setContext(e),this.id=++Ba.id,this.currentOpCount=0,this.interruptible=t,this._stack=[],this._observers=void 0,this._exit=void 0,this._children=void 0,this._interruptedCause=void 0,this._yielded=void 0,this._running=!1,this._deferredInterrupt=!1,this._parent=void 0,this._asyncContext=void 0,this.cache.runtimeMetrics?.recordFiberStart(this.context)}get"~effect/Fiber"(){return za}get currentDispatcher(){return this._dispatcher??=this.cache.scheduler.makeDispatcher()}getRef(e){return ii(this.context,e)}addObserver(e){return this._exit?(e(this._exit),qe):(this._observers===void 0?this._observers=[e]:this._observers.push(e),()=>this.removeObserver(e))}removeObserver(e){if(this._exit||this._observers===void 0)return;let t=this._observers.indexOf(e);t>=0&&this._observers.splice(t,1)}interruptUnsafe(e,t){if(this._exit)return;let n=va(e);this.cache.stackFrame&&(n=Vn(n,ti(Xn,this.cache.stackFrame))),t&&(n=Vn(n,t)),this._interruptedCause=this._interruptedCause?Rn(this._interruptedCause,n):n,this.interruptible&&(this._running?this._deferredInterrupt=!0:this.evaluate($a(this._interruptedCause)))}pollUnsafe(){return this._exit}evaluate(e){if(this._exit)return;if(this._asyncContext!==void 0){let t=this._asyncContext;this._asyncContext=void 0;try{return t.runInAsyncScope(this.evaluate,this,e)}finally{t.emitDestroy()}}else if(this._yielded!==void 0){let e=this._yielded;this._yielded=void 0,e()}let t=this.runLoop(e);if(t===Sn){this._asyncContext=Ha();return}let n=Ja.interruptChildren&&Ja.interruptChildren(this);if(n!==void 0)return this.evaluate(jo(n,()=>t));if(this._exit=t,this.cache.runtimeMetrics?.recordFiberEnd(this.context,this._exit),this._parent&&=(this._parent._children?.delete(this),void 0),this._observers!==void 0){let e=this._observers;this._observers=void 0;for(let n=0;n<e.length;n++)e[n](t)}this._stack.length=0,this._children=void 0,this.context=$r();let r=this.cache;(r.span!==void 0||r.stackFrame!==void 0)&&(this.cache={...r,span:void 0,stackFrame:void 0})}runLoop(e){let t=globalThis[Jt];globalThis[Jt]=this;let n=this._running;this._running=!0;let r=!1,i=e;this.currentOpCount=0;try{for(;;)try{this._deferredInterrupt&&(this._deferredInterrupt=!1,i=$a(this._interruptedCause)),this.currentOpCount++;let e=this.cache;if(!r&&!e.preventYield&&e.scheduler.shouldYield(this)){r=!0;let e=i;i=jo(ro,()=>e)}if(i=e.tracerContext?e.tracerContext(i,this):i[vn](this),i===Sn){let e=this._yielded;if(hn in e)return this._deferredInterrupt=!1,this._yielded=void 0,e;if(this._deferredInterrupt){this._yielded=void 0,e();continue}return Sn}}catch(e){if(!ut(i,vn))return er(`Fiber.runLoop: Not a valid effect: ${String(i)}`);i=er(e)}}finally{this._running=n,globalThis[Jt]=t}}getCont(e){if(this._deferredInterrupt)return this._deferredInterrupt=!1,Ka;for(;;){let t=this._stack.pop();if(!t)return;let n=t[xn];if(n!==void 0){let r=n.call(t,this);if(r)return r[e]=r,r}if(t[e])return t}}succeedWith(e){if(!(++this.currentOpCount&qa-1))return Yn(e);let t=this.getCont(yn);return t?t[yn](e,this):this.yieldWith(Yn(e))}yieldWith(e){return this._yielded=e,Sn}children(){return this._children??=new Set}pipe(){return ze(this,arguments)}setContext(e){let t=this.context;if(this.context=e,t!==void 0&&Xr(t,e))return;let n=e.cacheRoot,r=n._fiberCache??=Ga(e);this.cache?.scheduler!==r.scheduler&&(this._dispatcher=void 0),this.cache=r}get currentSpanLocal(){let e=this.cache.span;return e?._tag===`Span`?e:void 0}};const Ga=e=>{let t=ri(e,`effect/Tracer`);return{scheduler:ii(e,ea),tracer:t,tracerContext:t?t.context:void 0,tracerEnabled:ii(e,da),span:ri(e,`effect/Tracer/ParentSpan`),logLevel:ii(e,pa),minimumLogLevel:ii(e,ma),stackFrame:ii(e,ua),runtimeMetrics:ri(e,`effect/Metric/FiberRuntimeMetrics`),maxOpsBeforeYield:ii(e,sa),preventYield:ii(e,ca)}},Ka={[yn](e,t){return $a(t._interruptedCause)},[bn](e,t){return $a(t._interruptedCause)}},qa=32,Ja={interruptChildren:void 0},Ya=e=>{if(!e.cache.stackFrame)return;let t=new Map;return t.set(Zn.key,e.cache.stackFrame),Jr(t)},Xa=e=>po(t=>{let n=e[Symbol.iterator](),r=[],i;function a(){let e=n.next();for(;!e.done;){if(e.value._exit){r.push(e.value._exit),e=n.next();continue}i=e.value.addObserver(e=>{r.push(e),a()});return}t(Qa(r))}return a(),to(()=>i?.())}),Za=e=>tr(t=>{let n=Ya(t),r=pi();for(let i of e)i.interruptUnsafe(t.id,n),r.push(i);return Ao(Xa(r))}),Qa=Yn,$a=Qn,eo=$n,to=qn({op:`Sync`,[vn](e){let t=this[D],n=t(),r=e.getCont(yn);return r?r[yn](n,e):e.yieldWith(Yn(n))}}),no=qn({op:`Suspend`,[vn](e){let t=this[D];return t()}}),ro=qn({op:`Yield`,[vn](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate(Fo)},this[D]??0),e.yieldWith(()=>{t=!0})}})(0),io=e=>no(()=>$a(e())),ao=e=>er(e),oo=Qa(void 0),so=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new Zs(e,`An error occurred in Effect.try`):e.catch;return no(()=>{try{return Qa(t())}catch(e){return eo(n(e))}})},co=e=>uo(function(t,n){e(n).then(e=>t(Qa(e)),e=>t(ao(e)))},e.length!==0),lo=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new Zs(e,`An error occurred in Effect.tryPromise`):e.catch;return uo(function(e,r){let i=e=>no(()=>{try{return eo(dn(()=>n(e)))}catch(e){return ao(e)}});try{t(r).then(t=>e(Qa(t)),t=>e(i(t)))}catch(t){e(i(t))}},t.length!==0)},uo=function(){let e=Kn({op:`Async`,[vn](e){let t=!1,n=!1,r=this.withSignal?new AbortController:void 0,i=this.register.call(e.cache.scheduler,r=>{t||(t=!0,n?e.evaluate(r):n=r)},r?.signal);return n===!1?(n=!0,e.yieldWith(()=>{t=!0}),r===void 0&&i===void 0||e._stack.push(fo(()=>(t=!0,r?.abort(),i??Fo))),Sn):n}}),t=function(e,t){this.register=e,this.withSignal=t};return t.prototype=e,function(e,n){return new t(e,n)}}(),fo=qn({op:`AsyncFinalizer`,[xn](e){e.interruptible&&(e.interruptible=!1,e._stack.push(bs))},[bn](e,t){return wa(e)?jo(ns(Qn(e),this[D]()),()=>$a(e)):$a(e)}}),po=e=>uo(e,e.length>=2),mo=po(qe),ho=(...e)=>{if(e.length===1){let t=e[0];return no(()=>xo(t()))}let[t,n]=e;return no(()=>xo(n.call(t.self)))},go=(e,t)=>typeof e==`function`?e:t.shift().bind(e.self),_o=(e,...t)=>{let n=go(e,t),r=t.length===0?function(){return no(()=>xo(n.apply(this,arguments)))}:function(){let e=no(()=>xo(n.apply(this,arguments)));for(let n=0;n<t.length;n++)e=t[n](e,...arguments);return e};return vo(n.length,r)},vo=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),yo=(e,...t)=>{let n=go(e,t);return vo(n.length,t.length===0?function(){return bo(()=>n.apply(this,arguments))}:function(){let e=bo(()=>n.apply(this,arguments));for(let n of t)e=n(e,...arguments);return e})},bo=e=>{try{let t=e(),n;for(;;){let r=t.next(n);if(r.done)return Qa(r.value);let i=r.value;if(i&&i._tag===`Success`){n=i.value;continue}if(i&&i._tag===`Failure`)return r.value;{let n=!0;return no(()=>n?(n=!1,jo(r.value,e=>xo(t,e))):no(()=>xo(e())))}}}catch(e){return ao(e)}},xo=function(){let e=Kn({op:`Iterator`,[yn](e,t){let n=this.iterator;for(;;){let r=n.next(e);if(r.done)return Qa(r.value);if(!Mo(r.value))return t._stack.push(this),r.value;if(r.value._tag===`Failure`)return r.value;e=r.value.value}},[vn](e){return this[yn](this.initial,e)}}),t=function(e,t){this.iterator=e,this.initial=t};return t.prototype=e,function(e,n){return new t(e,n)}}(),So=E(2,(e,t)=>new To(e,Eo,Qa(t))),Co=function(e){return e._stack.push(this),this[D]},wo=Kn({op:`OnSuccess`,[vn]:Co}),To=function(e,t,n){this[D]=e,this[yn]=t,this.payload=n};To.prototype=wo;const Eo=function(){return this.payload},Do=function(e,t){return t.succeedWith(this.payload)},Oo=(()=>{let e=cn();if(e===0)return!1;let t=`~effect/Effect/stackProbe`,n={[t]:function(){return Error()}};ln(1);let r=n[t]();return ln(e),r.stack?.includes(`[as `+t+`]`)===!0})(),Oee=function(e,t){let n=this.payload;return t.succeedWith(Oo?n(e):dn(()=>n(e)))},ko=function(e){let t=this.payload;return t(e)},kee=function(e){let t=this.payload;return new To(t(e),Do,e)},Aee=function(e){return new To(this.payload,Do,e)},jee=e=>No(e,Pr),Mee=E(2,(e,t)=>new To(e,Tn(t)?Eo:ko,t)),Nee=E(2,(e,t)=>new To(e,Tn(t)?Aee:kee,t)),Ao=e=>new To(e,Eo,Fo),Pee=(e,t)=>tr(n=>{let r=new Set;return hs(n,()=>r.size===0?void 0:Za(r)),po(i=>{let a=!1,o=0;for(let s of e){if(a)break;let e=o++,c=Ps(n,s,!0,!0,!1);r.add(c),c.addObserver(o=>{r.delete(c);let s=!a;a=!0,i(o),s&&t?.onWinner&&t.onWinner({fiber:c,index:e,parentFiber:n})})}})}),Fee=E(e=>Tn(e[1]),(e,t,n)=>Pee([e,t],n)),jo=E(2,(e,t)=>new To(e,ko,t)),Mo=e=>e[hn]!==void 0,Iee=E(2,(e,t)=>Mo(e)?e._tag===`Success`?t(e.value):e:jo(e,t)),No=E(2,(e,t)=>new To(e,Oee,t)),Lee=E(2,(e,t)=>Mo(e)?Ree(e,t):No(e,t)),Po=e=>e._tag===`Success`,Fo=Yn(void 0),Ree=E(2,(e,t)=>e._tag===`Success`?Yn(t(e.value)):e),zee=e=>{let t=[];for(let n of e)n._tag===`Failure`&&t.push(...n.cause.reasons);return t.length===0?Fo:Qn(Fn(t))},Bee=e=>e,Io=E(2,(e,t)=>tr(n=>{let r=n.context,i=t(r);return r===i?e:(n.setContext(i),hs(n,()=>{n.setContext(r)}),e)})),Vee=e=>tr(t=>e(t.context)),Lo=E(2,(e,t)=>Mo(e)?e:Io(e,xee(t))),Ro=function(){return arguments.length===1?E(2,(e,t)=>zo(e,arguments[0],t)):E(3,(e,t,n)=>zo(e,t,n)).apply(this,arguments)},zo=(e,t,n)=>Io(e,ni(t,n)),Bo=E(2,(e,t)=>new Vo(e,t.length===1?t:e=>t(e))),Hee=Kn({op:`OnFailure`,[vn]:Co}),Vo=function(e,t){this[D]=e,this[bn]=t};Vo.prototype=Hee;const Uee=E(3,(e,t,n)=>Bo(e,e=>{let r=t(e);return ui(r)?$a(r.failure):n(r.success,e)})),Wee=E(2,(e,t)=>Uee(e,Ca,e=>t(e))),Gee=E(2,(e,t)=>Bo(e,e=>Mee(t(e),$a(e)))),Kee=E(e=>Tn(e[0]),(e,t,n,r)=>Bo(e,e=>{let i=Ca(e);return ui(i)?$a(i.failure):t(i.success)?n(i.success):r?r(i.success):$a(e)})),qee=E(e=>Tn(e[0]),(e,t,n,r)=>{let i=Array.isArray(t)?e=>ut(e,`_tag`)&&t.includes(e._tag):dt(t);return Kee(e,i,n,r)}),Jee=E(2,(e,t)=>Bo(e,e=>$a(Ea(e,t)))),Yee=E(2,(e,t)=>Wee(e,e=>to(()=>t(e)))),Xee=e=>e===`Unhandled`?(...e)=>tr(t=>{let n=t.getRef(ha);return n===void 0?oo:oc(n)(...e)}):oc(e===!0?void 0:e),Zee=E(e=>Tn(e[0]),(e,t)=>{if(!t?.log)return Wo(e,{onFailure:e=>oo,onSuccess:e=>oo});let n=Xee(t.log);return Ho(e,{onFailure(e){let r=Ca(e);return ui(r)?$a(r.failure):t.message===void 0?n(e):n(t.message,e)},onSuccess:e=>oo})}),Qee=e=>Ko(e,{onFailure:li,onSuccess:ci}),Ho=E(2,(e,t)=>new Uo(e,t.onSuccess.length===1?t.onSuccess:e=>t.onSuccess(e),t.onFailure.length===1?t.onFailure:e=>t.onFailure(e))),$ee=Kn({op:`OnSuccessAndFailure`,[vn]:Co}),Uo=function(e,t,n){this[D]=e,this[yn]=t,this[bn]=n};Uo.prototype=$ee;const ete=function(e,t){let n=this.payload;return t.succeedWith(Oo?n.onSuccess(e):dn(()=>n.onSuccess(e)))},tte=((e,t)=>{let n=Kn({op:e,[vn]:Co,[yn]:ete,[bn]:t}),r=function(e,t){this[D]=e,this.payload=t};return r.prototype=n,r})(`Match`,function(e,t){let n=Ca(e);if(ui(n))return $a(n.failure);let r=this.payload;return t.succeedWith(Oo?r.onFailure(n.success):dn(()=>r.onFailure(n.success)))}),Wo=E(2,(e,t)=>Ho(e,{onFailure:e=>{let n=Ca(e);return ui(n)?$a(n.failure):t.onFailure(n.success)},onSuccess:t.onSuccess})),Go=E(2,(e,t)=>new tte(e,t)),Ko=E(2,(e,t)=>{if(Mo(e)){if(e._tag===`Success`)return Yn(t.onSuccess(e.value));let n=Ca(e.cause);return ui(n)?Qn(n.failure):Yn(t.onFailure(n.success))}return Go(e,t)}),qo=e=>Mo(e)?Yn(e):nte(e),nte=qn({op:`Exit`,[vn](e){return e._stack.push(this),this[D]},[yn](e,t,n){return t.succeedWith(n??Yn(e))},[bn](e,t,n){return t.succeedWith(n??Qn(e))}}),Jo=E(2,(e,t)=>jo(Yo(e,t.duration),e=>Fr(e)?t.orElse():Qa(e.value))),Yo=E(2,(e,t)=>Fee(jee(e),So(Gs(t),Nr()))),Xo=`~effect/Scope`,Zo=`~effect/Scope/Closeable`,Qo=Lr(`effect/Scope`),$o=(e,t)=>tr(n=>(Cs(n),es(e,t)??oo)),es=(e,t)=>{let n=e.state;if(n._tag===`Closed`||(e.state={_tag:`Closed`,exit:t},e.parent!==void 0&&rte(e.parent,e),n._tag===`Empty`))return;if(n.finalizer!==void 0)return ts(n.finalizer,t);let r=n.finalizers;return r.size===1?ts(r.values().next().value,t):rs(e,r,t)},ts=(e,t)=>{try{return e(t)}catch(e){return er(e)}},ns=(e,t)=>Po(e)?t:Bo(t,t=>$a(Sa(Ln(e.cause,t)))),rs=_o(function*(e,t,n){let r=[],i=[],a=Array.from(t),o=Ua();for(let t=a.length-1;t>=0;t--){let[s,c]=a[t];e.strategy===`sequential`?r.push(yield*qo(ts(c,n))):s!==o&&i.push(Ps(o,ts(c,n),!0,!0,`inherit`))}return i.length>0&&(r=yield*Xa(i)),yield*zee(r)}),is=(e,t)=>{let n=cs(t,e);return e.state._tag===`Closed`?(n.state=e.state,n):(os(e,n,e=>$o(n,e)),n)},as=(e,t)=>no(()=>e.state._tag===`Closed`?t(e.state.exit):(os(e,{},t),oo)),os=(e,t,n)=>{if(e.state._tag===`Empty`)e.state={_tag:`Open`,finalizerKey:t,finalizer:n,finalizers:void 0};else if(e.state._tag===`Open`){let r=e.state;r.finalizer===void 0?r.finalizers.set(t,n):(r.finalizers=new Map([[r.finalizerKey,r.finalizer]]),r.finalizerKey=void 0,r.finalizer=void 0,r.finalizers.set(t,n))}},rte=(e,t)=>{if(e.state._tag!==`Open`)return;let n=e.state;n.finalizerKey===t?e.state=ls:n.finalizers!==void 0&&(n.finalizers.delete(t),n.finalizers.size===0&&(e.state=ls))},ss=e=>cs(e,void 0),cs=(e=`sequential`,t)=>({[Zo]:Zo,[Xo]:Xo,strategy:e,parent:t,state:ls}),ls={_tag:`Empty`},ite=Qo,ate=Ro(Qo),us=e=>tr(t=>{let n=t.context,r=ss();return t.setContext(ni(t.context,Qo,r)),hs(t,e=>(t.setContext(n),es(r,e))),e}),ds=e=>no(()=>{let t=ss();return gs(e(t),e=>no(()=>es(t,e)??oo))}),fs=(e,t,n)=>Vee(r=>Ts(i=>jo(ite,a=>Nee(n?.interruptible?i(e):e,e=>as(a,n=>Lo(t(e,n),r)))))),ps=function(){let e=Kn({op:`OnExit`,[vn](e){return e._stack.push(this),this.effect},[xn](e){e.interruptible&&this.interruptible!==!0&&(e._stack.push(bs),e.interruptible=!1)},[yn](e,t,n){n??=Yn(e);let r;try{r=this.onExit(n)}catch(e){r=er(e)}return r?jo(r,e=>n):n},[bn](e,t,n){n??=Qn(e);let r;try{r=this.onExit(n)}catch(e){r=er(e)}return r?jo(ns(n,r),e=>n):n}}),t=function(e,t,n){this.effect=e,this.onExit=t,this.interruptible=n};return t.prototype=e,t}(),ms=(e,t,n)=>new ps(e,t,n),hs=(e,t)=>{e._stack.push(new ps(void 0,t,void 0))},gs=E(2,ms),_s=E(2,(e,t)=>gs(e,e=>t)),vs=e=>tr(t=>t.interruptible?(t.interruptible=!1,t._stack.push(bs),e):e),ys=qn({op:`SetInterruptible`,[xn](e){if(e.interruptible=this[D],e._interruptedCause&&e.interruptible)return()=>$a(e._interruptedCause)}}),bs=ys(!0),xs=ys(!1),Ss=e=>{if(e.interruptible=!0,e._stack.push(xs),e._interruptedCause)return $a(e._interruptedCause)},Cs=e=>{let t=e;t.interruptible&&(t.interruptible=!1,t._stack.push(bs))},ws=e=>tr(t=>t.interruptible?e:Ss(t)??e),Ts=e=>tr(t=>t.interruptible?(t.interruptible=!1,t._stack.push(bs),e(ws)):e(He)),Es=qn({op:`While`,[yn](e,t){return this[D].step(e),this[D].while()?(t._stack.push(this),this[D].body()):Fo},[vn](e){return this[D].while()?(e._stack.push(this),this[D].body()):Fo}}),Ds=E(e=>typeof e[1]==`function`,(e,t,n)=>no(()=>{let r=ks(n?.concurrency);if(r===1)return Os(e,t,n);let i=Cee(e),a=i.length;if(a===0)return n?.discard?oo:Qa([]);let o=n?.discard?void 0:Array(a),s=Ns({f:t,out:o},i,{concurrency:r});return s?So(s,o):Qa(o)})),Os=(e,t,n)=>no(()=>{let r=n?.discard?void 0:[],i=e[Symbol.iterator](),a=i.next(),o=0;return So(Es({while:()=>!a.done,body:()=>t(a.value,o++),step:e=>{r&&r.push(e),a=i.next()}}),r)}),ks=e=>e===`unbounded`?1/0:Math.max(1,e??1),As=()=>e=>{let t=e.onItem,n=e.step,r=(e,t,r,a,o)=>jo(qo(o),o=>n(e,t[r],o,r)??i(e,t,r+1,a)??oo),i=(e,i,a=0,o=i.length)=>{for(;a<o;a++){let s=i[a],c=t(e,s,a);if(!Mo(c))return r(e,i,a,o,c);let l=n(e,s,c,a);if(l)return l._tag===`Failure`?l:void 0}};return i},js=e=>{let t=e.onItem,n=e.step;return(e,r,i)=>{let a=0,o=i.end??r.length,s=i.concurrency,c=!1,l,u,d,f,p,m=e=>{let t=er(e);return f=t,c=!0,u&&u.size>0?jo(vs(Za(Array.from(u))),()=>f??t):t},h=()=>{let i=!1;for(;!f&&a<o;a++){let o=r[a],g=p??t(e,o,a);if(Mo(g)){if(f=n(e,o,g,a),f)break}else if(l){p=void 0;let t=Ps(l,g,!0,!0,`inherit`);if(t._exit){if(f=n(e,o,t._exit,a),f)break;continue}u.add(t);let r=a;if(t.addObserver(a=>{u.delete(t);try{if(f){if(a._tag===`Failure`){let e=a.cause.reasons.filter(e=>e._tag!==`Interrupt`);if(e.length>0){let t=Fn(e);f=Qn(f._tag===`Failure`?Sa(Ln(f.cause,t)):t)}}}else{let t=n(e,o,a,r);t&&(f=t,h())}if(i){let e=h();e&&d(e)}else c&&u.size===0&&d(f??oo)}catch(e){d(m(e))}}),u.size<s)continue;i=!0,a++;return}else return po(e=>{l=Ua(),u=new Set,p=g,d=e;let t;try{t=h()}catch(t){return e(m(t))}return t?e(t):no(()=>(f??=Fo,jo(u?Za(u):oo,()=>f?._tag===`Failure`?f:oo)))})}if(c=!0,f){if(u&&u.size>0){let e=Ya(l);u.forEach(t=>t.interruptUnsafe(l.id,e));return}if(d||f._tag===`Failure`)return f}else if(d){if(u)u.size===0&&d(oo);else return Fo}};return h()}},Ms=()=>e=>js(e),Ns=js({onItem(e,t,n){return e.f(t,n)},step(e,t,n,r){if(n._tag===`Failure`)return n;e.out&&(e.out[r]=n.value)}}),Ps=(e,t,n=!1,r=!1,i=!1)=>{let a=e,o=i===`inherit`?a.interruptible:!i,s=new Wa(a.context,o);return r||(a.children().add(s),s._parent=a),n?s.evaluate(t):(s._asyncContext=Ha(),a.currentDispatcher.scheduleTask(()=>s.evaluate(t),0)),s},Fs=e=>(t,n)=>{let r=new Wa(n?.scheduler?ni(e,ea,n.scheduler):e,n?.uninterruptible!==!0);if(r.evaluate(t),r._exit)return r;if(n?.signal){if(n.signal.aborted)r.interruptUnsafe();else{let e=()=>r.interruptUnsafe();n.signal.addEventListener(`abort`,e,{once:!0}),r.addObserver(()=>n.signal.removeEventListener(`abort`,e))}}return n?.onFiberStart&&n.onFiberStart(r),r},Is=Fs($r()),Ls=(e=>{let t=Fs(e);return e=>{if(Mo(e))return e;let n=new aa(`sync`),r=t(e,{scheduler:n});return r._dispatcher?.flush(),r._exit??er(new Ys(r))}})($r()),Rs=oi(`effect/Clock`,{defaultValue:()=>new Bs}),zs=2**31-1;var Bs=class{currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=to(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return Us()}currentTimeNanos=to(()=>this.currentTimeNanosUnsafe());monotonicTimeNanosUnsafe(){return Hs()}monotonicTimeNanos=to(()=>this.monotonicTimeNanosUnsafe());sleep(e){return this.sleepMillis(Ji(e))}sleepMillis(e){return e<=0?ro:Number.isFinite(e)?po(t=>{let n=e>zs?this.sleepMillis(e-zs):oo,r=setTimeout(()=>t(n),Math.min(e,zs));return to(()=>clearTimeout(r))}):mo}};const Vs=BigInt(1e6),Hs=function(){let e=globalThis.process?.hrtime;if(typeof e?.bigint==`function`)return()=>e.bigint();if(typeof performance<`u`&&typeof performance.now==`function`)return()=>BigInt(Math.round(performance.now()*1e6));let t=BigInt(0);return()=>{let e=BigInt(Date.now())*Vs;return e>t&&(t=e),t}}(),Us=function(){let e=BigInt(1e9),t;return()=>{let n=Hs(),r=BigInt(Date.now())*Vs;if(t===void 0)t=r-n;else{let i=t+n;(r>i?r-i:i-r)>e&&(t=r-n)}return t+n}}(),Ws=e=>tr(t=>e(t.getRef(Rs))),Gs=e=>Ws(t=>t.sleep(Ni(e))),Ks=Ws(e=>e.currentTimeMillis),qs=Ws(e=>e.currentTimeNanos),Js=`~effect/Cause/AsyncFiberError`;var Ys=class extends rr(`AsyncFiberError`){[Js]=Js;constructor(e){super({message:`An asynchronous Effect was executed with Effect.runSync`,fiber:e})}};const Xs=`~effect/Cause/UnknownError`;var Zs=class extends rr(`UnknownError`){[Xs]=Xs;constructor(e,t){super({message:t,cause:e})}};const Qs=oi(`effect/Console`,{defaultValue:()=>globalThis.console}),$s=Mr(jr(Ar,e=>{switch(e){case`All`:return-(2**53-1);case`Fatal`:return 5e4;case`Error`:return 4e4;case`Warn`:return 3e4;case`Info`:return 2e4;case`Debug`:return 1e4;case`Trace`:return 0;case`None`:return 2**53-1}})),ec=oi(`effect/Logger/CurrentLoggers`,{defaultValue:()=>new Set([ote,ste])}),tc=oi(`effect/Logger/LogToStderr`,{defaultValue:Ge}),nc={"~effect/Logger":{_Message:He,_Output:He},pipe(){return ze(this,arguments)}},rc=e=>{let t=Object.create(nc);return t.log=e,t},ic=e=>e.replace(/[\s="]/g,`_`),ac=(e,t)=>`${ic(e[0])}=${t-e[1]}ms`,oc=e=>(...t)=>{let n;for(let e=0,r=t.length;e<r;e++){let r=t[e];kn(r)&&(n?t.splice(e,1):t=t.slice(0,e).concat(t.slice(e+1)),n=n?Fn(n.reasons.concat(r.reasons)):r,e--)}return n===void 0&&(n=mee),tr(r=>{let i=e??r.cache.logLevel;if($s(r.cache.minimumLogLevel,i))return oo;let a=r.getRef(Rs),o=r.getRef(ec);if(o.size>0){let e=new Date(a.currentTimeMillisUnsafe());for(let a of o)a.log({cause:n,fiber:r,date:e,logLevel:i,message:t})}return oo})},sc={bold:`1`,red:`31`,green:`32`,yellow:`33`,blue:`34`,cyan:`36`,white:`37`,gray:`90`,black:`30`,bgBrightRed:`101`};sc.gray,sc.blue,sc.green,sc.yellow,sc.red,sc.bgBrightRed,sc.black;const cc=e=>`${e.getHours().toString().padStart(2,`0`)}:${e.getMinutes().toString().padStart(2,`0`)}:${e.getSeconds().toString().padStart(2,`0`)}.${e.getMilliseconds().toString().padStart(3,`0`)}`,ote=rc(({cause:e,date:t,fiber:n,logLevel:r,message:i})=>{let a=Array.isArray(i)?i.slice():[i];e.reasons.length>0&&a.push(Ia(e));let o=t.getTime(),s=n.getRef(ga),c=``;for(let e of s)c+=` ${ac(e,o)}`;let l=n.getRef(fa);Object.keys(l).length>0&&a.push(l);let u=n.getRef(Qs);(n.getRef(tc)?u.error:u.log)(`[${cc(t)}] ${r.toUpperCase()} (#${n.id})${c}:`,...a)}),ste=rc(({cause:e,fiber:t,logLevel:n,message:r})=>{let i=t.getRef(Rs),a=t.getRef(fa),o=t.cache.span;if(o===void 0||o._tag===`ExternalSpan`||o.status._tag===`Ended`)return;let s={};for(let[e,t]of Object.entries(a))fn(s,e,t);s[`effect.fiberId`]=t.id,s[`effect.logLevel`]=n.toUpperCase(),e.reasons.length>0&&(s[`effect.cause`]=Ia(e)),o.event(an(Array.isArray(r)&&r.length===1?r[0]:r),i.currentTimeNanosUnsafe(),s)}),cte=Hn,lte=Bn,lc=Ta,uc=Ea,dc=Da,ute=Ia,dte=Yn,fc=Qn,pc=$n,mc=Fo,hc=Po,fte={"~effect/Deferred":{_A:He,_E:He},pipe(){return ze(this,arguments)}},gc=function(){this.resumes=void 0,this.effect=void 0};gc.prototype=fte;const pte=()=>new gc,mte=e=>po(t=>e.effect?t(e.effect):(e.resumes??=[],e.resumes.push(t),to(()=>{let n=e.resumes;if(n===void 0)return;let r=n.indexOf(t);r>=0&&n.splice(r,1)}))),hte=(e,t)=>{if(e.effect)return!1;if(e.effect=t,e.resumes){let n=e.resumes;e.resumes=void 0;for(let e=0;e<n.length;e++)n[e](t)}return!0},gte=ss,_te=ate,_c=is,vc=$o,yc=`~effect/Layer/MemoMap`,vte=(e,t)=>{let n={observers:0,deferred:pte(),scope:gte(),finalizer:r=>no(()=>--n.observers>0?oo:(e.map.delete(t),vc(n.scope,r)))};return n},bc=(e,t)=>t.state._tag!==`Closed`&&(e.observers++,os(t,{},e.finalizer),!0),yte={"~effect/Layer":{_ROut:He,_E:He,_RIn:He},pipe(){return ze(this,arguments)}},xc=e=>{let t=Object.create(yte);return t.build=e,t},Sc=e=>xc((t,n)=>{let r=_c(n);return gs(e(t,r),e=>e._tag===`Failure`?vc(r,e):oo)}),Cc=e=>{let t=Sc((n,r)=>n.getOrElseMemoize(t,r,e));return t};var wc=class{get[yc](){return yc}parent;constructor(e){this.parent=e}map=new Map;get(e,t){let n=this.map.get(e);return n?(bc(n,t),n.deferred.effect??mte(n.deferred)):this.parent?.get(e,t)}getOrElseMemoize(e,t,n){return no(()=>{let r;return ms(no(()=>{let i=this.get(e,t);if(i)return i;let a=vte(this,e);return bc(a,t)?(r=a.deferred,this.map.set(e,a),n(this,a.scope)):n(this,t)}),e=>{r&&hte(r,e)})})}};const Tc=()=>new wc,Ec=e=>new wc(e);var Dc=class e extends Lr()(`effect/Layer/CurrentMemoMap`){static forkOrCreate(t){let n=vee(t,e);return n?Ec(n):Tc()}};const Oc=E(3,(e,t,n)=>Ro(No(no(()=>e.build(t,n)),ni(Dc,t)),Dc,t)),kc=E(2,(e,t)=>tr(n=>Oc(e,Dc.forkOrCreate(n.context),t))),Ac=function(){return arguments.length===1?e=>jc(ti(arguments[0],e)):jc(ti(arguments[0],arguments[1]))},jc=e=>xc(Ue(Qa(e))),Mc=function(){return arguments.length===1?e=>Nc(arguments[0],e):Nc(arguments[0],arguments[1])},Nc=(e,t)=>Pc(No(t,t=>ti(e,t))),Pc=e=>Cc((t,n)=>_te(e,n)),Fc=(e,t,n)=>{let r=_c(n,`parallel`);return Ds(e,e=>e.build(t,_c(r,`sequential`)),{concurrency:e.length}).pipe(No(e=>See(...e)))},Ic=(...e)=>Cc((t,n)=>Fc(e,t,n)),Lc=Ks,Rc=qs,zc=`~effect/DateTime`,Bc=`~effect/DateTime/TimeZone`,Vc={[zc]:zc,pipe(){return ze(this,arguments)},[nn](){return this.toString()},toJSON(){return Xc(this).toJSON()}},Hc={...Vc,_tag:`Utc`,[ft](){return bt(this.epochMilliseconds)},[At](e){return Yc(e)&&e._tag===`Utc`&&this.epochMilliseconds===e.epochMilliseconds},toString(){return`DateTime.Utc(${Xc(this).toJSON()})`}},Uc={...Vc,_tag:`Zoned`,[ft](){return gt(bt(this.epochMilliseconds))(pt(this.zone))},[At](e){return Yc(e)&&e._tag===`Zoned`&&this.epochMilliseconds===e.epochMilliseconds&&jt(this.zone,e.zone)},toString(){return`DateTime.Zoned(${rl(this)})`}},Wc={[Bc]:Bc,[nn](){return this.toString()}};({...Wc}),{...Wc};const Gc={value:void 0,enumerable:!1,writable:!0},Kc=new WeakMap,qc=(e,t)=>({get(){return Object.isExtensible(this)?void 0:Kc.get(this)?.[e]},set(n){if(Object.isExtensible(this)){for(let e of t)Object.defineProperty(this,e,Gc);this[e]=n}else{let t=Kc.get(this);t===void 0&&(t={},Kc.set(this,t)),t[e]=n}}}),Jc=[`partsUtc`,`adjustedEpochMilliseconds`,`partsAdjusted`];Object.defineProperty(Hc,"partsUtc",qc(`partsUtc`,[`partsUtc`])),Object.defineProperties(Uc,{partsUtc:qc(`partsUtc`,Jc),adjustedEpochMilliseconds:qc(`adjustedEpochMilliseconds`,Jc),partsAdjusted:qc(`partsAdjusted`,Jc)});const Yc=e=>ut(e,zc),Xc=e=>new Date(e.epochMilliseconds),Zc=e=>{if(e._tag===`Utc`)return new Date(e.epochMilliseconds);if(e.zone._tag===`Offset`)return new Date(e.epochMilliseconds+e.zone.offset);if(e.adjustedEpochMilliseconds!==void 0)return new Date(e.adjustedEpochMilliseconds);let t=!1,n=e.zone.format.formatToParts(e.epochMilliseconds).filter(e=>e.type===`era`?(t=e.value===`BC`,!1):e.type!==`literal`),r=Number(n[2].value),i=new Date(0);return i.setUTCFullYear(t?1-r:r,Number(n[0].value)-1,Number(n[1].value)),i.setUTCHours(Number(n[3].value),Number(n[4].value),Number(n[5].value),n[6]?.type===`fractionalSecond`?Number(n[6].value):(e.epochMilliseconds%1e3+1e3)%1e3),e.adjustedEpochMilliseconds=i.getTime(),i},Qc=e=>Zc(e).getTime()-tl(e),$c=e=>{let t=Math.abs(e),n=Math.floor(t/36e5),r=Math.round(t%36e5/6e4);return r===60&&(n+=1,r=0),`${e<0?`-`:`+`}${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}`},el=e=>$c(Qc(e)),tl=e=>e.epochMilliseconds,nl=e=>{let t=Zc(e);return e._tag===`Utc`?t.toISOString():`${t.toISOString().slice(0,-1)}${el(e)}`},rl=e=>e.zone._tag===`Offset`?nl(e):`${nl(e)}[${e.zone.id}]`,il=(e,t,n)=>ds(r=>jo(n?.local?Oc(t,Tc(),r):kc(t,r),t=>Lo(e,t))),al=E(e=>Tn(e[0]),(e,t,n)=>Zr(t)?Lo(e,t):il(e,Array.isArray(t)?Ic(...t):t,n)),ol=Tn,sl=co,cl=lo,ll=Qa,ul=no,dl=to,fl=oo,pl=po,O=ho,k=eo,ml=io,hl=ao,gl=so,_l=tr,vl=jo,yl=Qee,bl=qo,xl=No,Sl=Ao,Cl=qee,wl=Bo,Tl=Jee,El=Gee,Dl=Zee,Ol=Yee,kl=Jo,Al=Gs,jl=al,Ml=Bee,Nl=us,Pl=fs,Fl=_s,Il=Is,Ll=Ls,Rl=oc(`Error`),zl=Lee,Bl=Iee,Vl=yo,Hl=(e,t)=>hc(e)?t(0):lc(e.cause)?t(130):t(Wl(dc(e.cause))),Ul=e=>E(e=>ol(e[0]),(t,n)=>{let r=n?.disableErrorReporting===!0?t:El(t,e=>lc(e)?fl:Gl(dc(e))?Rl(e):fl),i=n?.teardown??Hl;Il(_l(t=>{try{let e=globalThis.setInterval(qe,2147483647);t.addObserver(()=>{clearInterval(e)})}catch{}return e({fiber:t,teardown:i}),r}))}),Wl=e=>{if(typeof e==`object`&&e&&`~effect/Runtime/errorExitCode`in e){let t=e[`~effect/Runtime/errorExitCode`];if(typeof t==`number`)return t}return 1},Gl=e=>{if(typeof e==`object`&&e&&`~effect/Runtime/errorReported`in e){let t=e[`~effect/Runtime/errorReported`];if(typeof t==`boolean`)return t}return!0},Kl=Ul(({fiber:e,teardown:t})=>{let n=!1;e.addObserver(e=>{process.removeListener(`SIGINT`,r),process.removeListener(`SIGTERM`,r),t(e,e=>{(n||e!==0)&&process.exit(e)})});function r(){n=!0,e.interruptUnsafe(e.id)}process.on(`SIGINT`,r),process.on(`SIGTERM`,r)}),ql=`~effect/BigDecimal`,Jl={[ql]:ql,[ft](){let e=nu(this);return gt(xt(String(e.value)),bt(e.scale))},[At](e){return Yl(e)&&su(this,e)===0},toString(){return`BigDecimal(${lu(this)})`},toJSON(){return{_id:`BigDecimal`,value:String(this.value),scale:this.scale}},[nn](){return this.toJSON()},pipe(){return ze(this,arguments)}},Yl=e=>ut(e,ql),Xl=(e,t)=>{if(!Number.isSafeInteger(t))throw RangeError(`Scale must be a safe integer, got ${t}`);let n=Object.create(Jl);return n.value=e,n.scale=t,n},Zl=(e,t)=>{let n=Xl(e,t);return n.normalized=n,n},Ql=BigInt(0),$l=BigInt(1),eu=BigInt(10),tu=Zl(Ql,0),nu=e=>{if(e.normalized===void 0){if(e.value===Ql)e.normalized=tu;else{let t=`${e.value}`,n=ru(t);e.normalized=Zl(BigInt(t.slice(0,t.length-n)),e.scale-n)}}return e.normalized},ru=e=>{let t=e.length;for(;e[t-1]===`0`;)t--;return e.length-t},iu=[$l],au=(e,t)=>e===t?0:e<t?-1:1,ou=(e,t)=>{let n=`${e.value<Ql?-e.value:e.value}`,r=`${t.value<Ql?-t.value:t.value}`,i=BigInt(n.length-r.length)-BigInt(e.scale)+BigInt(t.scale);if(i!==Ql)return i<Ql?-1:1;let a=Math.max(n.length,r.length);return kr(n.padEnd(a,`0`),r.padEnd(a,`0`))},su=(e,t)=>{if(e.scale===t.scale)return au(e.value,t.value);let n=cu(e),r=cu(t);if(n!==r)return n<r?-1:1;if(n===0)return 0;let i=e.scale-t.scale,a=Math.abs(i);if(a>100)return n===-1?ou(t,e):ou(e,t);let o=iu[a]??=eu**BigInt(a);return i>0?au(e.value,t.value*o):au(e.value*o,t.value)},cu=e=>e.value===Ql?0:e.value<Ql?-1:1,lu=e=>{let t=nu(e);if(Math.abs(t.scale)>=16)return uu(t);let n=t.value<Ql,r=`${n?-t.value:t.value}`,i=t.scale>0?r.padStart(t.scale+1,`0`):r.padEnd(r.length-t.scale,`0`),a=i.length-t.scale,o=t.scale>0?`${i.slice(0,a)}.${i.slice(a)}`:i;return n?`-${o}`:o},uu=e=>{if(du(e))return`0e+0`;let t=nu(e),n=`${t.value}`,r=t.value<Ql?2:1,i=n.slice(0,r),a=n.slice(r),o=a.length-t.scale;return`${i}${a===``?``:`.${a}`}e${o>=0?`+`:``}${o}`},du=e=>e.value===Ql,fu=new Uint8Array(123).fill(255);for(let e=0;e<64;e++)fu[`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`.charCodeAt(e)]=e;fu[61]=0,{...on},{...on},{...Cn},on.toString,on[nn],{...Cn};function pu(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}const mu=`~sentinels`,hu=`~constructor`,gu=Je(e=>{let t=pu(e)?.identifier;return typeof t==`string`?t:e.getExpected(gu)}),_u=Symbol(),vu=dte,yu=vu(_u),bu=vu(_u),xu=e=>e===_u?Nr():Pr(e),Su=e=>e._tag===`None`?yu:vu(e.value),Cu=`~effect/SchemaIssue/Issue`;function wu(e){return ut(e,Cu)&&e[Cu]===Cu}function Tu(e){return Object.hasOwn(e,`input`)}var Eu=class{[Cu]=Cu;constructor(e,t){t?.reportInput===!0&&e!==_u&&(this.input=e)}};const Du=class extends Eu{_tag=`Filter`;filter;issue;constructor(e,t,n,r){super(n,r),this.filter=e,this.issue=t}},Ou=class extends Eu{_tag=`Encoding`;ast;issue;constructor(e,t,n,r){super(n,r),this.ast=e,this.issue=t}},ku=class extends Eu{_tag=`Pointer`;path;issue;constructor(e,t){super(),this.path=e,this.issue=t}},Au=class extends Eu{_tag=`MissingKey`;annotations;constructor(e){super(),this.annotations=e}},ju=class extends Eu{_tag=`UnexpectedKey`;ast;constructor(e,t,n){super(t,n),this.ast=e}},Mu=class extends Eu{_tag=`Composite`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},Nu=class extends Eu{_tag=`InvalidType`;ast;constructor(e,t,n){super(t,n),this.ast=e}},Pu=class extends Eu{_tag=`InvalidValue`;annotations;constructor(e,t,n){super(t,n),this.annotations=e}},Fu=class extends Eu{_tag=`AnyOf`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},Iu=class extends Eu{_tag=`OneOf`;ast;successes;constructor(e,t,n,r){super(n,r),this.ast=e,this.successes=t}};function Lu(e,t,n){if(wu(e))return e;if(typeof e==`string`)return new Pu({message:e},t,n);let r=typeof e.issue==`string`?new Pu({message:e.issue},t,n):e.issue;return new ku(e.path,r)}function Ru(e,t,n){if(e!==void 0)return typeof e==`boolean`?e?void 0:new Pu(void 0,t,n):Lu(e,t,n)}function zu(e,t,n,r){return Array.isArray(t)?Tee(t)?t.length===1?Lu(t[0],n,r):new Mu(e,Eee(t,e=>Lu(e,n,r)),n,r):void 0:Ru(t,n,r)}const Bu=e=>{let t=Xu(e);if(t!==void 0)return t;switch(e._tag){case`InvalidType`:return Wu(gu(e.ast),e);case`InvalidValue`:{let t=Uu(e);if(t!==void 0)return Wu(t,e);let n=Hu(e);return n===void 0?`Expected a valid value`:`Invalid data ${n}`}case`MissingKey`:return`Missing key`;case`UnexpectedKey`:{let t=Hu(e);return t===void 0?`Expected no excess property`:`Unexpected key with value ${t}`}case`Forbidden`:return`Forbidden operation`;case`OneOf`:{let t=Hu(e);return t===void 0?`Expected exactly one member to match`:`Expected exactly one member to match the input ${t}`}}},Vu=e=>Xu(e)??Xu(e.issue);function Hu(e){return Tu(e)?Xt(e.input):void 0}function Uu(e){let t=e.annotations?.expected;return typeof t==`string`?t:void 0}function Wu(e,t){let n=Hu(t);return n===void 0?`Expected ${e}`:`Expected ${e}, got ${n}`}function Gu(e,t){let n=t(e);if(n!==void 0||e.issue._tag!==`InvalidValue`)return n;let r=Uu(e.issue);return r===void 0?Wu(Ku(e.filter),e):Wu(r,e.issue)}function Ku(e){let t=e.annotations?.expected;if(typeof t==`string`)return t;switch(e._tag){case`Filter`:return`<filter>`;case`FilterGroup`:return e.checks.map(e=>Ku(e)).join(` & `)}}function qu(){return e=>Yu(e,``)}const Ju=qu();function Yu(e,t,n){let r;switch(e._tag){case`Filter`:return Yu(e.issue,t,n??Gu(e,Vu));case`Encoding`:return Yu(e.issue,t,n);case`Pointer`:return Yu(e.issue,t+uee(e.path),n);case`Composite`:case`AnyOf`:if(e._tag===`Composite`||e.issues.length>0)return e.issues.map(e=>Yu(e,t,n)).join(`
|
|
15
|
+
`);r=n??Xu(e)??Wu(gu(e.ast),e);break;default:r=n??Bu(e)}return t?`${r}\n at ${t}`:r}function Xu(e){if(e._tag===`Pointer`||e._tag===`Composite`)return;if(e._tag===`Encoding`)return Xu(e.issue);let t=(e._tag===`Filter`?e.filter.annotations:`annotations`in e?e.annotations:e.ast.annotations)?.[e._tag===`MissingKey`?`messageMissingKey`:e._tag===`UnexpectedKey`?`messageUnexpectedKey`:`message`];if(typeof t==`string`)return t}function Zu(e){let t;for(let n of e.reasons){if(!cte(n)||!wu(n.error))return;t??=n.error}return t}function Qu(e,t){let n=Zu(e);if(n===void 0)throw Error(t,{cause:e});return n}const $u=e=>Object.assign(Object.create(Be),e),ed=$u({_tag:`Passthrough`});function td(){return ed}function nd(e){return $u({_tag:`Transform`,transform:e})}function rd(e){return $u({_tag:`TransformEffect`,transform:e})}function id(){return nd(globalThis.String)}function ad(){return nd(globalThis.Number)}function od(e){return rd((t,n)=>gl({try:()=>JSON.parse(t,e?.reviver),catch:()=>new Pu({expected:`a valid JSON string`},t,n)}))}function sd(e){return rd((t,n)=>gl({try:()=>{let n=JSON.stringify(t,e?.replacer,e?.space);if(n===void 0)throw TypeError(`Value cannot be represented as JSON`);return n},catch:()=>new Pu({expected:`a JSON-serializable value`},t,n)}))}const cd=Symbol.for(`~effect/Schema/content`);function ld(e,t){return Object.defineProperty(e,cd,{value:t}),e}const ud=class extends Ve{_tag=`Middleware`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new ud(this.encode,this.decode)}},dd=`~effect/SchemaTransformation/Transformation`,fd=class extends Ve{[dd]=dd;_tag=`Transformation`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new fd(this.encode,this.decode)}};function pd(e){return ut(e,dd)&&e[dd]===dd}const md=e=>pd(e)?e:new fd(e.decode,e.encode),hd=new fd(td(),td());function gd(){return hd}const _d=new fd(ad(),id());function bte(e){return new fd(od(e??{}),ld(sd(e),{mediaType:`application/json`,preserveSchema:e?.reviver===void 0&&e?.replacer===void 0}))}function vd(e){return t=>t._tag===e}const yd=vd(`Declaration`),xte=vd(`Never`),bd=vd(`Literal`),xd=vd(`UniqueSymbol`),Ste=vd(`Arrays`),Cte=vd(`Objects`),Sd=vd(`Suspend`),Cd=class{to;transformation;constructor(e,t){this.to=e,this.transformation=t}},wd={},Td=class{isOptional;isMutable;constructorDefault;annotations;constructor(e,t,n=void 0,r=void 0){this.isOptional=e,this.isMutable=t,this.constructorDefault=n,this.annotations=r}},Ed=`~effect/Schema`;var Dd=class{[Ed]=Ed;annotations;checks;encoding;context;constructor(e=void 0,t=void 0,n=void 0,r=void 0){this.annotations=e,this.checks=t,this.encoding=n,this.context=r}toString(){return`<${this._tag}>`}};const Od=class extends Dd{_tag=`Declaration`;typeParameters;run;encodingChecks;encodingRun;constructor(e,t,n,r,i,a,o,s){super(n,r,i,a),this.typeParameters=e,this.run=t,this.encodingChecks=o,this.encodingRun=s}getParser(){let e;return(t,n)=>{if(t===_u)return yu;e??=this.run(this.typeParameters);try{return e(t,this,n)}catch(e){return hl(e)}}}_rebuild(e,t,n,r,i){let a=Ff(this.typeParameters,e);return a===this.typeParameters&&t===this.checks&&n===this.encodingChecks&&r===this.run&&i===this.encodingRun?this:new Od(a,r,this.annotations,t,void 0,this.context,n,i)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks,this.run,this.encodingRun)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks,this.encodingRun??this.run,this.run)}getExpected(){let e=this.annotations?.expected;return typeof e==`string`?e:`<Declaration>`}},kd=new class extends Dd{_tag=`Null`;getParser(){return Qf(this,null)}getExpected(){return`null`}},wte=class extends Dd{_tag=`Undefined`;getParser(){return Qf(this,void 0)}toCodecJson(){return wf(this,[Tte])}getExpected(){return`undefined`}},Tte=new Cd(kd,new fd(nd(()=>void 0),nd(()=>null))),Ad=new wte,jd=new class extends Dd{_tag=`Unknown`;getParser(){return $f(this,ct)}getExpected(){return`unknown`}},Md=class extends Dd{_tag=`Literal`;literal;constructor(e,t,n,r,i){if(super(t,n,r,i),typeof e==`number`&&!globalThis.Number.isFinite(e))throw Error(`A numeric literal must be finite, got ${Xt(e)}`);this.literal=e}getParser(){return Qf(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal==`bigint`?Nd(this):this}toCodecStringTree(){return typeof this.literal==`string`?this:Nd(this)}getExpected(){return typeof this.literal==`string`?JSON.stringify(this.literal):globalThis.String(this.literal)}};function Nd(e){let t=globalThis.String(e.literal);return wf(e,[new Cd(new Md(t),new fd(nd(()=>e.literal),nd(()=>t)))])}const Pd=new class extends Dd{_tag=`String`;getParser(){return $f(this,rt)}matchPart(e,t){let n=this.checks;return n&&!t.disableChecks&&sp(n,e,void 0,this,t)?void 0:e}getExpected(){return`string`}},Ete=class extends Dd{_tag=`Number`;getParser(){return $f(this,it)}matchKey(e,t){return this._match(np,e,t)}matchPart(e,t){return this._match(tp,e,t)}_match(e,t,n){if(!e.test(t))return;let r=globalThis.Number(t);return n.disableChecks||!this.checks?r:sp(this.checks,r,void 0,this,n)?void 0:r}toCodecJson(){return this.checks&&(Fd(this.checks,`effect/schema/isFinite`)||Fd(this.checks,`effect/schema/isInt`))?this:wf(this,[yf])}toCodecStringTree(){return this.toCodecJson()===this?wf(this,[ap]):wf(this,[op])}getExpected(){return`number`}};function Fd(e,t){return e.some(e=>e.annotations?.representation?.id===t||e._tag===`FilterGroup`&&Fd(e.checks,t))}const Id=new Ete,Dte=new class extends Dd{_tag=`Boolean`;getParser(){return $f(this,nee)}getExpected(){return`boolean`}},Ld=class extends Dd{_tag=`Arrays`;isMutable;elements;rest;encodingChecks;constructor(e,t,n,r,i,a,o,s){super(r,i,a,o),this.isMutable=e,this.elements=t,this.rest=n,this.encodingChecks=s;let c=!1;for(let e=0;e<t.length;e++)if(Wf(t[e]))c=!0;else if(c)throw Error(`A required element cannot follow an optional element. ts(1257)`);if(c&&n.length>1)throw Error(`A required element cannot follow an optional element. ts(1257)`);for(let e=1;e<n.length;e++)if(Wf(n[e]))throw Error(`An optional element cannot follow a rest element. ts(1266)`)}getParser(e,t=e){let n=this,r,i,a=n.elements.length,o=Math.max(0,n.rest.length-1);function s(e,t){return t<a?r[t]:t>=e?i[t-e+1]:i[0]}let c=e=>{let{input:t,len:r,options:i}=e;if(n.rest.length===0&&r>a)for(let o=a;o<r;o++){let r=new ju(n,t[o],i),a=new ku([o],r);if(i.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return k(new Mu(n,[a],t,i))}return e.issues?k(new Mu(n,e.issues,t,i)):vu(e.output)},l=(e,t)=>{let r=e.length,i={ast:n,getParser:s,input:e,len:r,tailThreshold:Math.max(a,r-o),output:[],issues:void 0,options:t},u=n.rest.length===0?a:Math.max(r,a+o),d=t.concurrency===void 0?1:ks(t.concurrency),f=d===1?kte(i,e,0,u):Ate(i,e,{concurrency:d,end:u});if(!f)return c(i);if(Mo(f))return Bl(f,()=>c(i));let p=!0;return ul(()=>p?(p=!1,vl(f,()=>c(i))):l(e,t))};return(e,a)=>{if(e===_u)return yu;try{return Array.isArray(e)?(r||(r=n.elements.map(e=>({ast:e,parser:t(e)})),i=n.rest.map(e=>({ast:e,parser:t(e)}))),l(e,a)):k(new Nu(n,e,a))}catch(e){return hl(e)}}}_rebuild(e,t,n){let r=Ff(this.elements,e),i=Ff(this.rest,e);return r===this.elements&&i===this.rest&&t===this.checks&&n===this.encodingChecks?this:new Ld(this.isMutable,r,i,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}getExpected(){return`array`}};function Ote(e,t,n,r){if(n._tag===`Failure`)return zd(e,e.ast,r,n);let i=n===bu?t:n[D];if(i!==_u)e.output[r]=i;else{let t=e.getParser(e.tailThreshold,r);if(Wf(t.ast))return;let n=new ku([r],new Au(t.ast.context?.annotations));if(e.options.errors===`all`)e.issues?e.issues.push(n):e.issues=[n];else return pc(new Mu(e.ast,[n],e.input,e.options))}}const Rd={onItem(e,t,n){let r=n<e.len?t:_u;return e.getParser(e.tailThreshold,n).parser(r,e.options)},step:Ote},kte=As()(Rd),Ate=Ms()(Rd),zd=(e,t,n,r)=>{if(r.cause.reasons.length===0)return r;let i=Zu(r.cause);if(i===void 0)return fc(uc(r.cause,r=>new Mu(t,[new ku([n],r)],e.input,e.options)));let a=new ku([n],i);if(e.options.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return pc(new Mu(t,[a],e.input,e.options))},Bd=`[+-]?(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?:[Ee][+-]?\\d+)?`;function Vd(e,t,n=wd){let r,i;function a(t){switch(t._tag){case`String`:case`TemplateLiteral`:return(r??=Object.keys(e)).filter(e=>t.matchPart(e,n)!==void 0);case`Number`:return(r??=Object.keys(e)).filter(e=>t.matchKey(e,n)!==void 0);case`Symbol`:return(i??=Object.getOwnPropertySymbols(e)).filter(r=>Object.prototype.propertyIsEnumerable.call(e,r)&&t.matchKey(r,n)!==void 0);case`Union`:return[...new Set(t.types.flatMap(a))];default:return[]}}return a(ep(Yf(t)))}const Hd=class{name;type;constructor(e,t){this.name=e,this.type=t}};function Ud(e){switch(e._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return e.types.every(Ud);default:return!1}}function Wd(e){let t=Ef(e);switch(t._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return t.types.every(Wd);default:return!1}}function jte(e){return Ud(e)&&Wd(e)}const Gd=class{parameter;type;constructor(e,t){if(!jte(e))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,Wf(t)||t.encoding!==void 0&&Wf(Yf(t)))throw Error("Cannot use `Schema.optionalKey` or `Schema.optional` with index signatures. Index signatures already allow keys to be absent; use `Schema.UndefinedOr` to allow `undefined` values.")}},Kd=class extends Dd{_tag=`Objects`;propertySignatures;indexSignatures;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.propertySignatures=e,this.indexSignatures=t,this.encodingChecks=o}getParser(e,t=e){let n=this,r=n.propertySignatures.length,i=n.indexSignatures.length;if(!r&&!i)return $f(n,st);let a,o,s=()=>(a||(a=n.propertySignatures.map(e=>({parser:t(e.type),name:e.name,type:e.type})),o=i?n.indexSignatures.map(n=>({is:n,parserKey:e(ep(n.parameter)),parserValue:t(n.type)})):void 0),a),c=()=>{let e=new Set(n.propertySignatures.map(e=>typeof e.name==`number`?globalThis.String(e.name):e.name)),t=(t,i,a,o,s)=>{if(s._tag===`Failure`)return zd(t,n,i,s)??mc;let c=s===bu?o:s[D];if(a!==_u&&c!==_u){if(r&&(e.has(i)||e.has(typeof a==`number`?globalThis.String(a):a)))return mc;fn(t.out,a,c)}return mc},c=(e,r,i,a)=>{if(!a){let t=i.parserKey(r,e.options);if(!Mo(t))return vl(bl(t),t=>c(e,r,i,t));a=t}if(a._tag===`Failure`)return zd(e,n,r,a)??mc;let o=a===bu?r:a[D],s=e.input[r],l=i.parserValue(s,e.options);return Mo(l)?t(e,r,o,s,l):vl(bl(l),n=>t(e,r,o,s,n))},l=(e,n,r)=>{let i=e.input[n],a=r.parserValue(i,e.options);return Mo(a)?t(e,n,n,i,a):vl(bl(a),r=>t(e,n,n,i,r))},u=i?Ms()({onItem:(e,[t,n])=>n.is.parameter===Pd?l(e,t,n):c(e,t,n),step:(e,t,n)=>n._tag===`Failure`?n:void 0}):void 0;return Vl(function*(t,d){if(t===_u)return _u;if(typeof t!=`object`||!t||Array.isArray(t))return yield*k(new Nu(n,t,d));s();let f=t,p={},m={ast:n,input:f,out:p,issues:void 0,options:d},h=d.errors===`all`,g=d.onExcessProperty===`error`,_=d.concurrency===void 0?1:ks(d.concurrency),v=i&&g?n.indexSignatures.map(e=>Vd(f,e.parameter,d)):void 0;if(g){let r=v?new Set(e):e;if(v)for(let e of v)for(let t of e)r.add(t);let i=Reflect.ownKeys(f);for(let e=0;e<i.length;e++){let a=i[e];if(!r.has(a)&&Object.prototype.propertyIsEnumerable.call(f,a)){let e=new ju(n,f[a],d),r=new ku([a],e);if(h){m.issues?m.issues.push(r):m.issues=[r];continue}return yield*k(new Mu(n,[r],t,d))}}}if(r){let e=_===1?Yd(m,a):Mte(m,a,{concurrency:_});e&&(yield*e)}if(i&&_===1)for(let e=0;e<i;e++){let t=o[e],n=t.is.parameter===Pd?l:c,r=v?.[e]??(t.is.parameter===Pd?Object.keys(f):Vd(f,t.is.parameter,d));for(let e=0;e<r.length;e++){let i=n(m,r[e],t);if(!Mo(i))yield*i;else if(i._tag===`Failure`)return yield*i}}else if(u){let e=pi();for(let t=0;t<i;t++){let n=o[t],r=v?.[t]??(n.is.parameter===Pd?Object.keys(f):Vd(f,n.is.parameter,d));for(let t=0;t<r.length;t++)e.push([r[t],n])}let t=u(m,e,{concurrency:_});t&&(yield*t)}return m.issues?yield*k(new Mu(n,m.issues,t,d)):p})};if(i)return c();let l,u=(e,t,n)=>{let r=a[t];return vl(bl(n),n=>{let i={...e,out:{...e.out}},o=qd(i,r,n);if(o)return o;let s=()=>vu(i.out),c=Yd(i,a.slice(t+1));return c?Bl(c,s):s()})};return(e,t)=>{if(e===_u)return yu;if(t.errors===`all`||t.onExcessProperty!==void 0||t.concurrency!==void 0&&ks(t.concurrency)!==1)return(l??=c())(e,t);if(typeof e!=`object`||!e||Array.isArray(e))return k(new Nu(n,e,t));let r=s(),i=e,a={},o={ast:n,input:i,out:a,issues:void 0,options:t};try{for(let e=0;e<r.length;e++){let n=r[e],s=n.name,c=sf(i,s),l=c?i[s]:_u,d=n.parser(l,t);if(!Mo(d))return u(o,e,d);if(d===bu){c&&fn(a,s,l);continue}let f=qd(o,n,d);if(f)return f}}catch(e){return hl(e)}return vu(a)}}_rebuild(e,t,n,r){let i=Ff(this.propertySignatures,t=>{let n=e(t.type);return n===t.type?t:new Hd(t.name,n)}),a=Ff(this.indexSignatures,n=>{let r=t(n.parameter),i=e(n.type);return r===n.parameter&&i===n.type?n:new Gd(r,i)});return i===this.propertySignatures&&a===this.indexSignatures&&n===this.checks&&r===this.encodingChecks?this:new Kd(i,a,this.annotations,n,void 0,this.context,r)}flip(e){return this._rebuild(e,e,this.encodingChecks,this.checks)}recur(e,t=e){return this._rebuild(e,t,this.checks,this.encodingChecks)}getExpected(){return this.propertySignatures.length===0&&this.indexSignatures.length===0?`object | array`:`object`}};function qd(e,t,n){if(n._tag===`Failure`)return zd(e,e.ast,t.name,n);if(n===bu)return;let r=n[D];if(r!==_u){fn(e.out,t.name,r);return}if(delete e.out[t.name],!Wf(t.type)){let n=new ku([t.name],new Au(t.type.context?.annotations));if(e.options.errors===`all`){e.issues?e.issues.push(n):e.issues=[n];return}return pc(new Mu(e.ast,[n],e.input,e.options))}}const Jd={onItem(e,t){if(!sf(e.input,t.name))return t.parser(_u,e.options);let n=e.input[t.name];return fn(e.out,t.name,n),t.parser(n,e.options)},step:qd},Yd=As()(Jd),Mte=Ms()(Jd);function Xd(e,t){return e?t?[...e,...t]:e:t}function Zd(e,t,n){return new Kd(Reflect.ownKeys(e).map(t=>new Hd(t,e[t].ast)),[],n,t)}function Nte(e){return e.ast}function Qd(e,t=void 0){return new Ld(!1,e.map(e=>e.ast),[],void 0,t)}function $d(e,t,n){return new cf(e.map(Nte),t,void 0,n)}const ef=Ye(e=>{for(;;){if(Sd(e))return jd;let t=e.encoding;if(!t)return e.recur?.(ef,He)??e;if(t.some(e=>e.transformation._tag===`Middleware`&&e.transformation.decode!==He))return jd;e=t[t.length-1].to}});function tf(e){switch(e._tag){case`Null`:return[`null`];case`Undefined`:return[`undefined`];case`String`:case`TemplateLiteral`:return[`string`];case`Number`:return[`number`];case`Boolean`:return[`boolean`];case`Symbol`:case`UniqueSymbol`:return[`symbol`];case`BigInt`:return[`bigint`];case`Arrays`:return[`array`];case`ObjectKeyword`:return[`object`,`array`,`function`];case`Objects`:return e.propertySignatures.length||e.indexSignatures.length?[`object`]:[`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`];case`Enum`:return Array.from(new Set(e.enums.map(([,e])=>typeof e)));case`Literal`:return[typeof e.literal];case`Union`:return Array.from(new Set(e.types.flatMap(tf)));default:return[`null`,`undefined`,`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`]}}function nf(e){switch(e._tag){default:return[];case`Declaration`:{let t=e.annotations?.[mu];return Array.isArray(t)?t:[]}case`Objects`:return e.propertySignatures.flatMap(e=>{let t=e.type;if(!Wf(t)){if(bd(t))return[{key:e.name,literal:t.literal}];if(xd(t))return[{key:e.name,literal:t.symbol}]}return[]});case`Arrays`:return e.elements.flatMap((e,t)=>{if(!Wf(e)){if(bd(e))return[{key:t,literal:e.literal}];if(xd(e))return[{key:t,literal:e.symbol}]}return[]});case`Union`:{if(e.types.length===0)return[];let t=e.types.map(e=>nf(ef(e)));return t[0].filter(e=>t.every(t=>t.some(t=>t.key===e.key&&t.literal===e.literal)))}case`Suspend`:return nf(e.thunk())}}const rf=new WeakMap,af=Object.freeze([]),of=e=>e===null?`null`:Array.isArray(e)?`array`:typeof e,sf=(e,t)=>t===`__proto__`?Object.hasOwn(e,t):t in e;function Pte(e){let t=rf.get(e);if(t)return t;let n,r=0,i,a,o=!0,s=[];for(let t=0;t<e.length;t++){let c=e[t],l=ef(c);if(xte(l))continue;if(bd(l)||xd(l)){a??=new Map;let e=bd(l)?l.literal:l.symbol;s[t]=e;let n=a.get(e);n||a.set(e,n=[]),n.push(t)}else o=!1;let u=nf(l);if(u.length){n??=new Map,r++;for(let{key:e,literal:r}of u){let i=n.get(e);i||n.set(e,i=[new Map,new Set]),i[1].add(t);let a=i[0].get(r);a||i[0].set(r,a=new Set),a.add(t)}}else{i??={};let e=tf(l);for(let n of e)(i[n]??=[]).push(t)}}let c={},l=e=>c[e]??=Object.freeze(i?.[e]??af);if(o&&a)a.forEach(Object.freeze),t=e=>a.get(e)??af;else if(n?.size===1&&!i){let[r,[i]]=n.entries().next().value,a=new Map;for(let[e,t]of i)a.set(e,Object.freeze(Array.from(t)));let o=Object.freeze(e.map((e,t)=>t));t=(e,t)=>{if(lt(e)){let n=sf(e,r)?e[r]:void 0;if(n!==void 0)return a.get(n)??af;if(t)return o}return af}}else if(n){let e;for(let t of n)(!e||t[1][0].size>e[1][0].size)&&t[1][1].size===r&&(e=t);t=(t,r)=>{let a=of(t);if(!lt(t))return l(a);let o=new Set(i?.[a]),s;if(e){let[n,[i]]=e,c=sf(t,n),u=c?t[n]:void 0;if(c&&(!r||u!==void 0)){let e=i.get(u);if(!e)return l(a);for(let t of e)o.add(t);s=n}}if(s===void 0)for(let[e,[i,a]]of n){let n=sf(t,e),s=n?t[e]:void 0;if(n&&(!r||s!==void 0)){let e=i.get(s);if(e)for(let t of e)o.add(t)}else if(r)for(let e of a)o.add(e)}for(let[e,[i,a]]of n){if(e===s)continue;let n=sf(t,e),c=n?t[e]:void 0;if(n&&(!r||c!==void 0)){let e=i.get(c);for(let t of o)a.has(t)&&!e?.has(t)&&o.delete(t)}}return Array.from(o).sort((e,t)=>e-t)}}else t=e=>{let t=l(of(e));return a?t.filter(t=>s[t]===void 0||s[t]===e):t};return rf.set(e,t),t}const cf=class extends Dd{_tag=`Union`;types;options;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.types=e,this.options=t,this.encodingChecks=o}getParser(e,t){let n=this,r=t!==void 0,i=[],a=t=>i[t]??=e(n.types[t]),o;return(e,t)=>{if(e===_u)return yu;let i=(o??=Pte(n.types))(e,r);if(i.length===0)return k(new Fu(n,[],e,t));if(i.length===1){let r=a(i[0])(e,t);return r._tag===`Success`?r:Mo(r)?lf(n,r.cause,e,t):Fte(n,r,e,t)}return uf(n,a,i,e,t)}}_rebuild(e,t,n){let r=Ff(this.types,e);return r===this.types&&t===this.checks&&n===this.encodingChecks?this:new cf(r,this.options,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}matchPart(e,t){for(let n of this.types){let r=n.matchPart(e,t);if(r!==void 0)return r}}getExpected(e){let t=this.annotations?.expected;if(typeof t==`string`)return t;if(this.types.length===0)return`never`;let n=this.types.map(t=>{let n=Yf(t);switch(n._tag){case`Arrays`:{let t=n.elements.filter(bd);if(t.length>0)return`${pf(n.isMutable)}[ ${t.map(t=>e(t)+mf(t.context?.isOptional)).join(`, `)}, ... ]`;break}case`Objects`:{let t=n.propertySignatures.filter(e=>bd(e.type));if(t.length>0)return`{ ${t.map(t=>`${pf(t.type.context?.isMutable)}${Zt(t.name)}${mf(t.type.context?.isOptional)}: ${e(t.type)}`).join(`, `)}, ... }`;break}}return e(n)});return Array.from(new Set(n)).join(` | `)}};function lf(e,t,n,r){let i=Zu(t);return i?pc(new Fu(e,[i],n,r)):fc(t)}function Fte(e,t,n,r){return wl(t,t=>lf(e,t,n,r))}function uf(e,t,n,r,i){let a={ast:e,parser:t,input:r,out:void 0,successes:e.options?.mode===`oneOf`?[]:void 0,issues:void 0,options:i},o=Ite(a,n);if(!o)return a.out?a.out:k(new Fu(e,a.issues??[],r,i));if(Mo(o))return df(o,a);let s=!0;return ul(()=>s?(s=!1,df(o,a)):uf(e,t,n,r,i))}function df(e,t){return Bl(e,e=>t.out===bu?ll(t.input):t.out?t.out:k(new Fu(t.ast,t.issues??[],t.input,t.options)))}const Ite=As()({onItem(e,t){return e.parser(t)(e.input,e.options)},step(e,t,n){if(n._tag===`Failure`){let t=Zu(n.cause);if(t===void 0)return n;e.issues?e.issues.push(t):e.issues=[t]}else{if(e.out&&e.successes)return e.successes.push(e.ast.types[t]),pc(new Iu(e.ast,e.successes,e.input,e.options));if(e.out=n,e.successes)e.successes.push(e.ast.types[t]);else return mc}}}),ff=new cf([new Md(`Infinity`),new Md(`-Infinity`),new Md(`NaN`)]);function pf(e){return e?``:`readonly `}function mf(e){return e?`?`:``}const hf=class extends Ve{_tag=`Filter`;run;annotations;aborted;constructor(e,t=void 0,n=!1){super(),this.run=e,this.annotations=t,this.aborted=n}annotate(e){return new hf(this.run,{...this.annotations,...e},this.aborted)}abort(){return new hf(this.run,this.annotations,!0)}and(e,t){return new gf([this,e],t)}},gf=class extends Ve{_tag=`FilterGroup`;checks;annotations;constructor(e,t=void 0){super(),this.checks=e,this.annotations=t}annotate(e){return new gf(this.checks,{...this.annotations,...e})}and(e,t){return new gf([this,e],t)}};function _f(e,t,n=!1){return new hf((t,n,r)=>zu(n,e(t,n,r),t,r),t,n)}function vf(e){return _f(e=>globalThis.Number.isFinite(e),{expected:`a finite number`,representation:{id:`effect/schema/isFinite`,payload:null},toJsonSchema:()=>({type:`number`}),toCode:()=>({runtime:`Schema.isFinite()`}),arbitraryConstraint:{number:`finite`},...e})}const yf=new Cd(new cf([kf(Id,[vf()]),ff]),new fd(ad(),nd(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function bf(e,t){let n=new globalThis.RegExp(e),r={source:n.source,flags:n.flags};return _f(e=>(n.lastIndex=0,n.test(e)),{expected:`a string matching the RegExp ${r.source}`,representation:{id:`effect/schema/isPattern`,payload:r},toJsonSchema:()=>[{},!0],arbitraryConstraint:{patterns:[r]},...t})}const xf=new WeakMap;function Sf(e,t){let n=Object.assign(Object.create(Object.getPrototypeOf(e)),e,t);return Reflect.ownKeys(t).every(e=>e===`context`||e===`encoding`)&&xf.set(n,Cf(e)),n}function Cf(e){let t=xf.get(e);if(t!==void 0)return t;if(e.encoding===void 0)return e;let n=Object.assign(Object.create(Object.getPrototypeOf(e)),e,{encoding:void 0});return xf.set(e,n),n}function wf(e,t){return e.encoding===t?e:Sf(e,{encoding:t})}function Tf(e,t){if(e.context===t)return e;let n=Cf(e);return n.context===t&&n.encoding===e.encoding?n:Sf(e,{context:t})}function Ef(e){return e.encoding?Ef(e.encoding[e.encoding.length-1].to):e}function Df(e,t){if(e.checks){let n=e.checks[e.checks.length-1];return Of(e,fi(e.checks.slice(0,-1),n.annotate(t)))}return Sf(e,{annotations:{...e.annotations,...t}})}function Of(e,t){if(e._tag===`Suspend`&&t)throw Error(`Cannot add checks to Suspend`);return e.checks===t?e:Sf(e,{checks:t})}function kf(e,t){return Of(e,Xd(e.checks,t))}function Af(e,t){let n=t(e.to);return n===e.to?e:new Cd(n,e.transformation)}function jf(e,t){let n=e,r=n[n.length-1],i=Af(r,t);return i===r?e:fi(e.slice(0,e.length-1),i)}function Mf(e){return t=>t.encoding?wf(t,jf(t.encoding,e)):t}function Nf(e,t){function n(r){if(r.encoding){let e=r.encoding[r.encoding.length-1];return t?.stopAt?.(e)?r:wf(r,jf(r.encoding,n))}return e(r)}return Ye(n)}function Pf(e,t,n){let r=new Cd(e,t);return wf(n,n.encoding?[...n.encoding,r]:[r])}function Ff(e,t){let n;for(let r=0;r<e.length;r++){let i=e[r],a=t(i);if(n)n[r]=a;else if(a!==i){n=Array(e.length);for(let t=0;t<r;t++)n[t]=e[t];n[r]=a}}return n??e}function If(e,t){return Tf(e,e.context?new Td(e.context.isOptional,e.context.isMutable,e.context.constructorDefault,{...e.context.annotations,...t}):new Td(!1,!1,void 0,t))}const Lf=Ye(e=>{let t=e.context?e.context.isOptional===!1?new Td(!0,e.context.isMutable,e.context.constructorDefault,e.context.annotations):e.context:new Td(!0,!1);return Rf(Tf(e,t))}),Rf=Mf(Lf),zf=Je(e=>Lf(new cf([e,Ad])));function Bf(e,t){return Tf(e,e.context?new Td(e.context.isOptional,e.context.isMutable,t,e.context.annotations):new Td(!1,!1,t))}function Vf(e,t,n){return Pf(e,n,t)}function Hf(e){let t=[],n=[];function r(e){t.includes(e)||t.push(e)}function i(e){switch(e._tag){case`Literal`:at(e.literal)&&r(e.literal);return;case`UniqueSymbol`:r(e.symbol);return;case`Enum`:for(let[,t]of e.enums)r(t);return;case`Never`:return;case`Union`:for(let t=0;t<e.types.length;t++)i(e.types[t]);return;default:n.push(e)}}return i(e),{literals:t,parameters:n}}function Uf(e,t){let{literals:n,parameters:r}=Hf(e);return new Kd(n.map(e=>new Hd(e,t)),r.map(e=>new Gd(e,t)))}function Wf(e){return e.context?.isOptional??!1}function Gf(e){return e.annotations?.[`~structural`]===!0||e._tag===`FilterGroup`&&e.checks.every(Gf)}function Kf(e){function t(e){return Gf(e)?[e]:e._tag===`FilterGroup`?e.checks.flatMap(t):[]}let n=e.flatMap(t);return wee(n)?n:void 0}function qf(e){let t=!0;function n(e){return t=t&&!e.encoding&&!Sd(e),t&&`recur`in e&&e.recur(n),e}return`recur`in e&&e.recur(n),t}const Jf=Ye(e=>{let t=Cf(e);if(t!==e){let n=Jf(t);return n===t&&e.encoding===void 0?e:Tf(n,e.context)}let n=`recur`in e?e.recur(Jf):e;if(`encodingChecks`in n&&n.encodingChecks){let t=qf(e)?n.encodingChecks:Ste(n)||Cte(n)||yd(n)&&n.typeParameters.length>0?Kf(n.encodingChecks):void 0;return Sf(n,{encodingChecks:void 0,checks:Xd(n.checks,t)})}return n}),Yf=Ye(e=>Jf(Zf(e)));function Xf(e,t){let n=t,r=n.length,i=n[r-1],a=[new Cd(Zf(wf(e,void 0)),n[0].transformation.flip())];for(let e=1;e<r;e++)a.unshift(new Cd(Zf(n[e-1].to),n[e].transformation.flip()));let o=Zf(i.to);return o.encoding?wf(o,[...o.encoding,...a]):wf(o,a)}const Zf=Je(e=>{if(e.encoding)return Xf(e,e.encoding);let t=Cf(e);if(t!==e){let n=Zf(t);return n===t?e:Tf(n,e.context)}return`flip`in e?e.flip(Zf):`recur`in e?e.recur(Zf):e});function Qf(e,t){let n=t===0?bu:vu(t);return(r,i)=>r===_u?yu:r===t?n:k(new Nu(e,r,i))}function $f(e,t){return(n,r)=>n===_u?yu:t(n)?bu:k(new Nu(e,n,r))}const ep=Nf(e=>{switch(e._tag){default:return e;case`Number`:return e.toCodecStringTree();case`Union`:return e.recur(ep)}}),tp=new globalThis.RegExp(`^${Bd}$`),np=new globalThis.RegExp(`^(?:${Bd}|Infinity|-Infinity|NaN)$`);function rp(e){return bf(tp,{expected:`a string representing a finite number`,representation:{id:`effect/schema/isStringFinite`,payload:null},toJsonSchema:()=>({pattern:tp.source}),...e})}const ip=kf(Pd,[rp()]),ap=new Cd(ip,_d),op=new Cd(new cf([ip,ff]),_d);function sp(e,t,n,r,i){for(let a=0;a<e.length;a++){let o=e[a];if(o._tag===`FilterGroup`){if(n=sp(o.checks,t,n,r,i),n&&(i.errors!==`all`||n[n.length-1].filter.aborted))return n}else{let e=o.run(t,r,i);if(e){let r=new Du(o,e,t,i);if(n?n.push(r):n=[r],i.errors!==`all`||o.aborted)return n}}}return n}function cp(e){if(!yd(e))return;let t=e.annotations?.[hu];return ot(t)?t(e.typeParameters):void 0}const lp=(e,t,n)=>e===bu?n(t):Bl(e,n);function up(e){let t=dp(e);return(e,n,r)=>{try{return t(e,n,r)}catch(e){return hl(e)}}}function dp(e){if(e._tag===`Middleware`)return(t,n,r)=>{let i=t===bu?e.decode(vu(xu(n)),r):e.decode(zl(t,xu),r);return fp(i)};let t=e.decode;switch(t._tag){case`Passthrough`:return(e,t)=>e===bu?vu(t):e;case`Transform`:{let e=e=>e===_u?yu:vu(t.transform(e));return(t,n)=>lp(t,n,e)}case`TransformOptional`:{let e=e=>Su(t.transform(xu(e)));return(t,n)=>lp(t,n,e)}case`TransformEffect`:return(e,n,r)=>lp(e,n,e=>e===_u?yu:t.transform(e,r));case`TransformOptionalEffect`:return(e,n,r)=>lp(e,n,e=>fp(t.transform(xu(e),r)))}}const fp=e=>Bl(e,Su),pp=(e,t,n,r)=>wl(r,r=>ml(()=>uc(r,r=>new Ou(e,r,t,n))));function mp(e,t){let n=up(e.link.transformation),r;return(i,a)=>{if(i===_u)return yu;if(e.isConstructed(i))return bu;let o=(r??=t(e.link.to))(i,a);return n(o,i,a)}}function hp(e,t){let n=e.context.constructorDefault;return(r,i)=>{if(r!==_u&&r!==void 0)return t(r,i);let a=n;if(Mo(a)&&a._tag===`Success`){let e=t(a[D],i);return e===bu?a:e}return Bl(pp(e,r,i,a),e=>{let n=t(e,i);return n===bu?vu(e):n})}}function gp(e,t){let n=t(e);return e.context?.constructorDefault===void 0?n:hp(e,n)}function _p(e,t,n,r,i){if(e._tag===`Declaration`)for(let n of e.typeParameters)t(n);let a=n?cp(e):void 0,o=a?mp(a,t):r??e.getParser(t,n),s=e.checks,c=e.encoding,l=c?.map(e=>up(e.transformation)),u=e.encodingChecks;if(!c&&!s&&!u)return o;let d,f=(t,n)=>{let r=o(t,n);try{if(u&&!n.disableChecks){if(Mo(r)){if(r._tag===`Success`){let i=r===bu?t:r[D];if(t!==_u&&i!==_u){let i=sp(u,t,void 0,e,n);i&&(r=k(new Mu(e,i,t,n)))}}}else r=vl(r,r=>{if(t!==_u&&r!==_u){let r=sp(u,t,void 0,e,n);if(r)return k(new Mu(e,r,t,n))}return ll(r)})}if(s&&!n.disableChecks){if(Mo(r)){if(r._tag===`Success`){let i=r===bu?t:r[D];if(i===_u)return r;let a=sp(s,i,void 0,e,n);a&&(r=k(new Mu(e,a,i,n)))}}else r=vl(r,t=>{if(t!==_u){let r=sp(s,t,void 0,e,n);if(r)return k(new Mu(e,r,t,n))}return ll(t)})}return r}catch(e){return hl(e)}},p=i===void 0?f:i(f);return c?(n,r)=>{let i=d??=c.map(e=>t(e.to)),a=n,o=i[i.length-1](n,r);for(let e=c.length-1;e>=0;e--)if(o=l[e](o,a,r),e!==0){let t=i[e-1];o._tag===`Success`?(a=o[D],o=t(a,r)):o=Bl(o,e=>{let n=t(e,r);return n===bu?vu(e):n})}if(o._tag===`Success`){let e=o[D],t=p(e,r);return t===bu?o:t}return o=pp(e,n,r,o),Bl(o,e=>{let t=p(e,r);return t===bu?vu(e):t})}:p}const vp=Symbol(),yp=new WeakMap,bp=e=>wp(e).parser,xp=e=>wp(e).makeEffect,Sp=e=>gp(e,xp);var Cp=class{ast;constructor(e){this.ast=e}get decodeEffect(){return this.cachedDecodeEffect??=_p(this.ast,bp)}get parser(){return this.decodeEffect}get makeEffect(){return this.cachedMakeEffect??=_p(this.ast,xp,Sp)}};function wp(e){let t=yp.get(e);if(t!==void 0)return t;let n=new Cp(e);return yp.set(e,n),n}function Tp(e){let t=e.ast,n;return(e,r)=>(n??=Np(Vp,Jf(t)))(e,r?.disableChecks?r?.parseOptions?{...r.parseOptions,disableChecks:!0}:{disableChecks:!0}:r?.parseOptions)}function Ep(e){let t=Tp(e);return(e,n)=>{let r=Ll(t(e,n));return hc(r)?Pr(r.value):(Qu(r.cause,`Option adapter can only return none for schema issues`),Nr())}}function Dp(e){return Lp(Jf(e.ast))}function Op(e,t){let n=jp(e.ast);return t===void 0?n:(e,r)=>n(e,kp(t,r))}const kp=(e,t)=>t?{...e,...t}:e,Ap=e=>e===_u?k(new Pu):ll(e);function jp(e){return Np(Bp,e)}function Mp(e,t){return e===bu?ll(t):Mo(e)?e[D]===_u?Ap(_u):e:Bl(e,Ap)}function Np(e,t){let n;return(r,i)=>{let a=(n??=e(t))(r,i??wd);return a===bu?ll(r):Mo(a)?a[D]===_u?Ap(_u):a:Bl(a,Ap)}}function Pp(e,t){let n=Ll(e);if(hc(n))return n.value;let r=Qu(n.cause,t);throw Error(`Schema validation failed`,{cause:r})}const Fp=`Constructor adapter can only throw schema issues`;function Ip(e){throw Error(Fp,{cause:lte(e)})}function Lp(e){let t;return(n,r)=>Rp(t??=wp(e),n,r)}function Rp(e,t,n){let r=n?.disableChecks?n.parseOptions?{...n.parseOptions,disableChecks:!0}:{disableChecks:!0}:n?.parseOptions??wd,i=e.make;if(i!==void 0&&t!==_u){let e;try{e=i(t,r)}catch(e){Ip(e)}if(e!==vp&&e!==_u)return e}return Pp(Mp(e.makeEffect(t,r),t),Fp)}function zp(e,t,n,r){let i=wp(e),a=cp(e);if(a===void 0||i.make!==void 0||i.compiledMakeEffect!==void 0)return Rp(i,t,n);if(a.isConstructed(t))return t;let o=Rp((i.resolve??wp)(a.link.to),t,n);try{return r(o)}catch(e){Ip(e)}}const Bp=e=>wp(e).parser,Vp=e=>wp(e).makeEffect,Hp=`~effect/Schema/Schema`,Up=Symbol(),Wp={[Hp]:Hp,get make(){let e=Dp(this);return Object.defineProperty(this,"make",{value:e,enumerable:!0}),e},get makeEffect(){let e=Tp(this);return Object.defineProperty(this,"makeEffect",{value:e,enumerable:!0}),e},get makeOption(){let e=Ep(this);return Object.defineProperty(this,"makeOption",{value:e,enumerable:!0}),e},pipe(){return ze(this,arguments)},annotate(e){return this.rebuild(Df(this.ast,e))},annotateKey(e){return this.rebuild(If(this.ast,e))},check(...e){return this.rebuild(kf(this.ast,e))},rebuild(e){return Gp(e,this[Up])}};function Gp(e,t){function n(){}let r=Object.setPrototypeOf(n,Wp);return t&&(Object.hasOwn(t,`name`)||Object.hasOwn(t,`length`)||Object.hasOwn(t,`__proto__`))?Object.defineProperties(r,Object.getOwnPropertyDescriptors({...t})):Object.assign(r,t),r[Up]=t,r.ast=e,r}const Kp=e=>e,qp=`~effect/Schema/SchemaError`;({...on}),{...on},{...on},{...on},{...on},{...on},{...on},{...on};const Jp=Hp;var Yp=class extends la(`SchemaError`){[qp]=qp;constructor(e){let t=cn();ln(0);try{super({issue:e})}finally{ln(t)}}get message(){return Ju(this.issue)}toJSON(){return{_tag:this._tag,message:this.message}}[nn](){return this.toJSON()}toString(){return`SchemaError(${this.message})`}};function Xp(e){return Mo(e)?Zp(e):wl(e,e=>ml(()=>uc(e,e=>new Yp(e))))}function Zp(e){return hc(e)?e:fc(uc(e.cause,e=>new Yp(e)))}function Qp(e,t){let n=Op(e,t);return(e,t)=>Xp(n(e,t))}const $p=Gp;function em(e){return ut(e,Jp)&&e[Jp]===Jp}const tm=Kp(e=>{let t=vm(e);return $p(zf(e.ast),{schema:t})});function nm(e){let t=$p(new Md(e),{literal:e,transform(n){return t.pipe(ym(nm(n),{decode:nd(()=>n),encode:nd(()=>e)}))}});return t}const rm=$p(jd),im=$p(kd),am=$p(Ad),A=$p(Pd),om=$p(Id),sm=$p(Dte);function cm(e,t){return $p(e,{fields:t,mapFields(e,t){let n=e(this.fields);return cm(Zd(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function lm(e){return cm(Zd(e,void 0),e)}function um(e,t){return $p(Uf(e.ast,t.ast),{key:e,value:t})}function dm(e,t){return $p(e,{elements:t,mapElements(e,t){let n=e(this.elements);return dm(Qd(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function fm(e){return dm(Qd(e),e)}const pm=Kp(e=>$p(new Ld(!1,[],[e.ast]),{value:e}));function mm(e,t){return $p(e,{members:t,mapMembers(e,t){let n=e(this.members);return mm($d(n,this.ast.options,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function hm(e,t){return mm($d(e,t,void 0),e)}function gm(e){let t=e.map(nm);return $p($d(t,void 0,void 0),{literals:e,members:t,mapMembers(e){return hm(e(this.members))},pick(e){return gm(e)},transform(e){return hm(t.map((t,n)=>t.transform(e[n])))}})}const _m=Kp(e=>hm([e,im])),vm=Kp(e=>hm([e,am]));function ym(e,t){return n=>$p(Vf(n.ast,e.ast,t?md(t):gd()),{from:n,to:e})}function bm(e){return t=>$p(Bf(t.ast,e),{schema:t})}function xm(e){return nm(e).pipe(bm(ll(e)))}function Sm(e,t){return lm({_tag:xm(e),...t})}globalThis.RegExp,globalThis.URL;const Cm=A.annotate({expected:`a string that will be decoded as JSON`});function wm(e,t){return Cm.pipe(ym(e,bte(t)))}globalThis.File,globalThis.URLSearchParams,globalThis.Uint8Array;const Tm=globalThis.Symbol.for(`immer-draftable`),Em={};function Dm(e,t,n,r,i){let a=jm(n,t,r),o=Am(t),s=class extends e{constructor(...[e,t]){let r=t?.[`~payload`],i=r?.token===Em?r.value:n.make(e??{},t);super(i,{...t,disableChecks:!0,"~payload":{token:Em,value:i}})}static[Jp]=Jp;get[o](){return o}static[Tm]=!0;static identifier=t;static fields=n.fields;static get ast(){return a(this).ast}static pipe(){return ze(this,arguments)}static rebuild(e){return a(this).rebuild(e)}static make(e,t){return zp(Jf(a(this).ast),e??{},t,e=>Om(this,e))}static makeOption(e,t){return Ep(a(this))(e??{},t)}static makeEffect(e,t){return a(this).makeEffect(e??{},t)}static annotate(e){return this.rebuild(Df(this.ast,e))}static annotateKey(e){return this.rebuild(If(this.ast,e))}static check(...e){return this.rebuild(kf(this.ast,e))}static extend(e){return(t,r)=>{let a=Mm(t)?t:lm(t),o={...n.fields,...a.fields},s=Zd(o,n.ast.checks,{identifier:e});return Dm(this,e,cm(kf(s,a.ast.checks),o),r,i)}}static mapFields(e,t){return n.mapFields(e,t)}};return i!==void 0&&Object.assign(s.prototype,i(t)),s}function Om(e,t){return new e(t,{"~payload":{token:Em,value:t}})}function km(e){return new fd(nd(t=>Om(e,t)),td())}function Am(e){return`~effect/Schema/Class/${e}`}function jm(e,t,n){let r;return i=>{if(r!==void 0)return r;let a=Am(t),o=e=>e instanceof i||ut(e,a),s=km(i);return r=ym($p(new Od([e.ast],()=>(e,t,n)=>o(e)?ll(e):k(new Nu(t,e,n)),{identifier:t,[hu]:([e])=>({isConstructed:o,link:new Cd(e,s)}),toCodec:([e])=>new Cd(e.ast,s),toEquivalence:([e])=>e,toFormatter:([e])=>t=>`${i.identifier}(${e(t)})`,[mu]:nf(e.ast),...n})),s)(e)}}function Mm(e){return em(e)}const Nm=e=>(t,n)=>{let r=Mm(t)?t:lm(t);return Dm(nr,e,r,n,e=>({name:e}))},Pm=e=>(t,n,r)=>{let i=Mm(n)?n.mapFields(e=>({_tag:xm(t),...e}),{unsafePreserveChecks:!0}):Sm(t,n);return Nm(e??t)(i,r)};var Fm=class extends Pm()(`GuestError`,{operation:A,detail:A,timedOut:tm(sm),notStarted:tm(sm)}){get message(){return`guest ${this.operation}: ${this.detail}`}},Im=class extends Lr()(`use-cloud-vms/linux-desktop/Guest`){};const Lm=String.raw`
|
|
16
|
+
for pid in "$@"; do
|
|
17
|
+
case $pid in ''|*[!0-9]*) printf '%s invalid\n' "$pid"; continue;; esac
|
|
18
|
+
if [ "$pid" -le 1 ]; then printf '%s invalid\n' "$pid"; continue; fi
|
|
19
|
+
if [ -r /proc/sys/kernel/random/boot_id ]; then
|
|
20
|
+
boot=$(cat /proc/sys/kernel/random/boot_id) || exit 3
|
|
21
|
+
if line=$(cat "/proc/$pid/stat" 2>/dev/null); then
|
|
22
|
+
rest=$(printf '%s\n' "$line" | sed 's/^.*) //')
|
|
23
|
+
set -- $rest
|
|
24
|
+
state=$1; ppid=$2; shift 19
|
|
25
|
+
printf '%s linux %s %s %s %s\n' "$pid" "$boot" "$state" "$ppid" "$1"
|
|
26
|
+
else
|
|
27
|
+
printf '%s absent\n' "$pid"
|
|
28
|
+
fi
|
|
29
|
+
else
|
|
30
|
+
if out=$(LC_ALL=C ps -o stat= -o ppid= -o lstart= -p "$pid" 2>/dev/null) && [ -n "$out" ]; then
|
|
31
|
+
set -- $out
|
|
32
|
+
state=$1; ppid=$2; shift 2
|
|
33
|
+
printf '%s ps - %s %s %s\n' "$pid" "$state" "$ppid" "$*"
|
|
34
|
+
else
|
|
35
|
+
printf '%s absent\n' "$pid"
|
|
36
|
+
fi
|
|
37
|
+
fi
|
|
38
|
+
done
|
|
39
|
+
`,Rm=String.raw`
|
|
40
|
+
pid=$1; want=$2; sig=$3
|
|
41
|
+
case $pid in ''|*[!0-9]*) echo invalid; exit 0;; esac
|
|
42
|
+
if [ "$pid" -le 1 ]; then echo invalid; exit 0; fi
|
|
43
|
+
if [ -r /proc/sys/kernel/random/boot_id ]; then
|
|
44
|
+
boot=$(cat /proc/sys/kernel/random/boot_id) || exit 3
|
|
45
|
+
line=$(cat "/proc/$pid/stat" 2>/dev/null) || { echo gone; exit 0; }
|
|
46
|
+
rest=$(printf '%s\n' "$line" | sed 's/^.*) //')
|
|
47
|
+
set -- $rest
|
|
48
|
+
state=$1; shift 19; have="$boot $1"
|
|
49
|
+
else
|
|
50
|
+
out=$(LC_ALL=C ps -o stat= -o ppid= -o lstart= -p "$pid" 2>/dev/null)
|
|
51
|
+
[ -n "$out" ] || { echo gone; exit 0; }
|
|
52
|
+
set -- $out
|
|
53
|
+
state=$1; shift 2; have="- $*"
|
|
54
|
+
fi
|
|
55
|
+
case $state in Z*) echo gone; exit 0;; esac
|
|
56
|
+
[ "$have" = "$want" ] || { echo changed; exit 0; }
|
|
57
|
+
if kill -s "$sig" "$pid" 2>/dev/null; then echo sent; else echo gone; fi
|
|
58
|
+
`,zm=String.raw`
|
|
59
|
+
pid=$1; n=0
|
|
60
|
+
while [ "$pid" -gt 1 ] 2>/dev/null && [ "$n" -lt 64 ]; do
|
|
61
|
+
printf '%s\n' "$pid"
|
|
62
|
+
if [ -r "/proc/$pid/stat" ]; then
|
|
63
|
+
line=$(cat "/proc/$pid/stat" 2>/dev/null) || exit 0
|
|
64
|
+
rest=$(printf '%s\n' "$line" | sed 's/^.*) //')
|
|
65
|
+
set -- $rest
|
|
66
|
+
pid=$2
|
|
67
|
+
else
|
|
68
|
+
pid=$(LC_ALL=C ps -o ppid= -p "$pid" 2>/dev/null | tr -d ' ')
|
|
69
|
+
[ -n "$pid" ] || exit 0
|
|
70
|
+
fi
|
|
71
|
+
n=$((n + 1))
|
|
72
|
+
done
|
|
73
|
+
`,Bm=String.raw`
|
|
74
|
+
for path in "$@"; do
|
|
75
|
+
if [ -e "$path" ] || [ -L "$path" ]; then printf 'present\n'; else printf 'absent\n'; fi
|
|
76
|
+
done
|
|
77
|
+
`,Vm=String.raw`
|
|
78
|
+
dir=$1; shift
|
|
79
|
+
for name in "$@"; do
|
|
80
|
+
resolved=$(readlink -f -- "$dir/$name" 2>/dev/null) || { printf 'missing %s\n' "$name"; exit 3; }
|
|
81
|
+
if [ -f "$resolved" ] && [ -x "$resolved" ]; then
|
|
82
|
+
printf 'tool %s %s\n' "$name" "$resolved"
|
|
83
|
+
else
|
|
84
|
+
printf 'missing %s\n' "$name"; exit 3
|
|
85
|
+
fi
|
|
86
|
+
done
|
|
87
|
+
`,Hm=String.raw`
|
|
88
|
+
lock=$1
|
|
89
|
+
content=$(head -c 64 -- "$lock") || exit 3
|
|
90
|
+
owner=$(LC_ALL=C ls -ln -- "$lock" | awk '{print $3}')
|
|
91
|
+
printf '%s\n%s\n' "$owner" "$content"
|
|
92
|
+
`,Um=String.raw`
|
|
93
|
+
pid=$1; shift
|
|
94
|
+
[ -r "/proc/$pid/environ" ] || exit 0
|
|
95
|
+
tr '\000' '\n' < "/proc/$pid/environ" | while IFS= read -r line; do
|
|
96
|
+
for key in "$@"; do
|
|
97
|
+
case $line in "$key"=*) printf '%s\n' "$line";; esac
|
|
98
|
+
done
|
|
99
|
+
done
|
|
100
|
+
`,Wm=(e,t)=>[`sh`,`-c`,e,`sh`,...t],Gm=(e,t)=>t.exitCode===0&&!t.timedOut?ll(t):k(new Fm({operation:e,detail:t.timedOut?`timed out`:`exit ${t.exitCode}: ${t.stderr.trim()||t.stdout.trim()}`,...t.timedOut?{timedOut:!0}:{}})),Km=(e,t,n,r)=>vl(Ml(Im),i=>vl(i.run(Wm(t,n),{timeoutMs:r}),t=>Gm(e,t))),qm=e=>`${e.boot} ${e.start}`,Jm=(e,t)=>vl(Km(`identity`,Lm,e.map(String),t),t=>{let n=t.stdout.split(`
|
|
101
|
+
`).filter(e=>e.length>0);if(n.length!==e.length)return k(new Fm({operation:`identity`,detail:`expected ${e.length} records`}));let r=[];for(let[t,i]of n.entries()){let n=i.split(` `),a=e[t]??0;if(n[0]!==String(a))return k(new Fm({operation:`identity`,detail:`record for ${n[0]}`}));if(n[1]===`absent`)r.push({kind:`absent`});else if(n[1]===`invalid`)r.push({kind:`invalid`});else if((n[1]===`linux`||n[1]===`ps`)&&n.length>=6){let e=n[2]??``,t=n[3]??``,i=Number(n[4]),o={pid:a,start:n.slice(5).join(` `),boot:e};r.push(t.startsWith(`Z`)?{kind:`zombie`,identity:o}:{kind:`running`,identity:o,ppid:i})}else return k(new Fm({operation:`identity`,detail:`unreadable record ${i}`}))}return ll(r)}),Ym=(e,t,n)=>vl(Km(`signal`,Rm,[String(e.pid),qm(e),t],n),e=>{let t=e.stdout.trim();return t===`sent`||t===`gone`||t===`changed`||t===`invalid`?ll(t):k(new Fm({operation:`signal`,detail:`unreadable outcome ${t}`}))}),Xm=(e,t)=>xl(Km(`ancestry`,zm,[String(e)],t),e=>e.stdout.split(`
|
|
102
|
+
`).filter(e=>/^\d+$/u.test(e)).map(Number)),Zm=(e,t)=>vl(Km(`paths`,Bm,e,t),t=>{let n=t.stdout.split(`
|
|
103
|
+
`).filter(e=>e.length>0);return n.length===e.length&&n.every(e=>e===`present`||e===`absent`)?ll(n.map(e=>e===`present`)):k(new Fm({operation:`paths`,detail:`unreadable path states`}))}),Qm=(e,t,n)=>vl(Ml(Im),r=>vl(r.run(Wm(Vm,[e,...t]),{timeoutMs:n}),e=>{let n=e.stdout.split(`
|
|
104
|
+
`).filter(e=>e.length>0),r=n.find(e=>e.startsWith(`missing `));if(e.exitCode===3&&r!==void 0)return ll({kind:`missing`,name:r.slice(8)});if(e.exitCode!==0||e.timedOut)return k(new Fm({operation:`tools`,detail:`exit ${e.exitCode}`}));let i={};for(let e of n){let[,t,...n]=e.split(` `);t!==void 0&&(i[t]=n.join(` `))}return t.every(e=>i[e]!==void 0)?ll({kind:`resolved`,tools:i}):k(new Fm({operation:`tools`,detail:`incomplete tool list`}))})),$m=(e,t)=>xl(Km(`lock`,Hm,[e],t),e=>{let[t=``,...n]=e.stdout.split(`
|
|
105
|
+
`);return{ownerUid:t,content:n.join(`
|
|
106
|
+
`)}}),eh=(e,t,n)=>xl(Km(`environ`,Um,[String(e),...t],n),e=>{let t={};for(let n of e.stdout.split(`
|
|
107
|
+
`)){let e=n.indexOf(`=`);e>0&&(t[n.slice(0,e)]=n.slice(e+1))}return t}),th=e=>xl(Km(`uid`,`id -u`,[],e),e=>e.stdout.trim()),nh=(e,t,n)=>Sl(Km(`mkdir`,t?`mkdir -p -- "$1" && chmod 700 "$1"`:`mkdir -m 700 -- "$1"`,[e],n)),rh=(e,t)=>Sl(Km(`rm`,`rm -f -- "$1"`,[e],t)),ih=lm({path:A,bytes:om,sha256:A});var ah=class extends Pm()(`Unavailable`,{reason:A,nativeExit:tm(om),deadline:tm(sm),retire:tm(sm),log:tm(ih)}){};const j=(e,t)=>k(new ah(t===void 0?{reason:e}:{reason:e,nativeExit:t})),oh=e=>new ah({reason:e.reason,retire:!0,...e.nativeExit===void 0?{}:{nativeExit:e.nativeExit},...e.deadline===void 0?{}:{deadline:e.deadline}}),sh=lm({pid:om,start:A,boot:A});lm({id:A,pid:om,title:A,x:om,y:om,width:om,height:om,gtk_frame_extents:fm([om,om,om,om]),net_frame_extents:fm([om,om,om,om])});const ch={argv:pm(A),home:A,log:A,launched_at:A},lh={...ch,identity:sh,phase:gm([`running`,`closed`,`ended`,`terminated`,`unresolved`]),ended:tm(rm)},uh=lm(lh),dh=hm([lm({...lh,previous:tm(pm(uh))}),lm({...ch,pid:_m(om),phase:nm(`unidentified`),reason:A,previous:tm(pm(uh))})]),fh={dir:A,log:A},ph=lm({...fh,phase:nm(`ready`),address:A,processes:lm({holder:sh,bus:sh,daemon:sh}),ready_at:A}),mh=lm({pid:_m(om),reason:A}),hh=hm([ph,lm({...fh,phase:gm([`starting`,`stopping`,`stopped`,`failed`]),address:tm(A),processes:um(A,sh),unidentified:tm(um(A,mh)),reason:tm(A),ended:tm(rm)})]),gh=Qp(wm(lm({schema:nm(`use-cloud-vms/linux-desktop/session@1`),run_id:A,guest:A,kind:gm([`owned`,`adopted`]),phase:gm([`starting`,`ready`,`stopping`,`stopped`,`released`,`failed`]),display:A,dimensions:fm([om,om]),geometry:A,x11_dir:A,guest_dir:A,tools:um(A,A),probe_timeout_s:om,ready_timeout_s:om,shutdown_timeout_s:om,lock_owner_uid:A,children:um(A,sh),x_server:tm(sh),window_manager:tm(sh),xfce:tm(sh),connection:um(A,A),apps:um(A,dh),keyring:tm(hh),observed:tm(rm),ready_at:tm(A),reason:tm(A),ended:tm(rm),guest_retirement_required:sm}))),_h=e=>o(e,`session.json`),vh=e=>sl(async()=>{try{return await p(e),!0}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return!1;throw e}}),yh=e=>cl({try:async()=>{await m(e,{mode:448}),await m(o(e,`probes`),{mode:448})},catch:e=>new ah({reason:`could not create the state directory: ${String(e)}`})}),bh=(e,t)=>cl({try:async()=>{let r=o(i(e),`.${n(e)}.${d()}`);try{await y(r,`${JSON.stringify(t,null,2)}\n`,{flag:`wx`,mode:384}),await g(r,e)}finally{await v(r).catch(()=>void 0)}},catch:t=>new ah({reason:`could not write ${e}: ${String(t)}`})}),xh=(e,t)=>cl({try:async()=>{let r=o(i(e),`.${n(e)}.${d()}`);await y(r,t,{flag:`wx`,mode:384});try{await f(r,e)}finally{await v(r)}},catch:t=>new ah({reason:`could not publish ${e}: ${String(t)}`})}),Sh=(e,t)=>xh(e,new TextEncoder().encode(`${JSON.stringify(t,null,2)}\n`)),Ch=e=>vl(cl({try:()=>h(_h(e),`utf8`),catch:e=>new ah({reason:`no readable session record: ${String(e)}`})}),e=>gh(e).pipe(Tl(()=>new ah({reason:`session record is not a linux-desktop session`})))),wh=(e,t)=>bh(_h(e),t),Th=xl(Lc,e=>new Date(e).toISOString()),Eh=xl(Rc,e=>Number(e/1000000n)),Dh=e=>xl(Eh,t=>({endMs:t+e*1e3})),Oh=(e,t)=>vl(Eh,n=>{let r=e.endMs-n;return r<=0?k(new ah({reason:`operation deadline exhausted`,deadline:!0})):ll(Math.min(t*1e3,r))}),kh=e=>t=>Cl(t,`Unavailable`,t=>k(t.deadline===!0?new ah({reason:e,deadline:!0}):t)),Ah=[`dbus-daemon`,`gnome-keyring-daemon`,`dbus-send`],jh=String.raw`
|
|
108
|
+
dir=$1; run=$2; bus_tool=$3; daemon_tool=$4
|
|
109
|
+
umask 077
|
|
110
|
+
bus=
|
|
111
|
+
daemon=
|
|
112
|
+
finish() {
|
|
113
|
+
for pid in $daemon $bus; do kill -TERM "$pid" 2>/dev/null; done
|
|
114
|
+
wait
|
|
115
|
+
exit "$1"
|
|
116
|
+
}
|
|
117
|
+
trap 'finish 143' TERM INT HUP
|
|
118
|
+
services=$XDG_DATA_HOME/dbus-1/services
|
|
119
|
+
mkdir -p -- "$HOME" "$XDG_CONFIG_HOME" "$XDG_CACHE_HOME" "$services" "$XDG_RUNTIME_DIR" "$dir/control" || exit 70
|
|
120
|
+
for name in ${[`org.freedesktop.secrets`,`org.gnome.keyring`,`org.freedesktop.impl.portal.Secret`,`org.gnome.keyring.SystemPrompter`,`org.gnome.keyring.PrivatePrompter`].join(` `)}; do
|
|
121
|
+
printf '[D-BUS Service]\nName=%s\nExec=/bin/false\n' "$name" > "$services/$name.service" || exit 70
|
|
122
|
+
done
|
|
123
|
+
mkfifo "$dir/bus.fifo" || exit 70
|
|
124
|
+
"$bus_tool" --session --nofork --print-address=3 3> "$dir/bus.fifo" &
|
|
125
|
+
bus=$!
|
|
126
|
+
head -n 1 < "$dir/bus.fifo" > "$dir/bus.address" &
|
|
127
|
+
wait $!
|
|
128
|
+
IFS= read -r address < "$dir/bus.address" || address=
|
|
129
|
+
[ -n "$address" ] || finish 70
|
|
130
|
+
DBUS_SESSION_BUS_ADDRESS=$address
|
|
131
|
+
export DBUS_SESSION_BUS_ADDRESS
|
|
132
|
+
head -c 32 /dev/urandom | base64 | "$daemon_tool" --foreground --components=secrets --control-directory "$dir/control" --unlock &
|
|
133
|
+
daemon=$!
|
|
134
|
+
tmp="$dir/.connection.$$"
|
|
135
|
+
{
|
|
136
|
+
printf 'RUN_ID=%s\n' "$run"
|
|
137
|
+
printf 'HOLDER=%s\n' "$$"
|
|
138
|
+
printf 'BUS=%s\n' "$bus"
|
|
139
|
+
printf 'DAEMON=%s\n' "$daemon"
|
|
140
|
+
printf 'ADDRESS=%s\n' "$address"
|
|
141
|
+
} > "$tmp" && mv -f "$tmp" "$dir/connection" || finish 70
|
|
142
|
+
wait "$daemon"
|
|
143
|
+
printf '%s\n' "$?" > "$dir/daemon.exit"
|
|
144
|
+
daemon=
|
|
145
|
+
kill -TERM "$bus" 2>/dev/null
|
|
146
|
+
wait "$bus"
|
|
147
|
+
exit 0
|
|
148
|
+
`,Mh=String.raw`
|
|
149
|
+
send=$1; daemon=$2; reply_ms=$3; mode=$4
|
|
150
|
+
last() { awk 'NF { v = $NF } END { print v }'; }
|
|
151
|
+
call() { "$send" --session --print-reply=literal --reply-timeout="$reply_ms" "$@" 2>&1; }
|
|
152
|
+
report() {
|
|
153
|
+
if [ "$3" -eq 0 ]; then
|
|
154
|
+
printf '%s %s\n' "$1" "$(printf '%s\n' "$2" | last)"
|
|
155
|
+
else
|
|
156
|
+
error=$(printf '%s\n' "$2" | sed -n 's/^Error \([^:]*\):.*$/\1/p' | head -n 1)
|
|
157
|
+
[ -n "$error" ] || error=unreachable
|
|
158
|
+
printf '%s !%s\n' "$1" "$error"
|
|
159
|
+
fi
|
|
160
|
+
}
|
|
161
|
+
out=$(call --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.GetConnectionUnixProcessID string:org.freedesktop.DBus)
|
|
162
|
+
report bus "$out" $?
|
|
163
|
+
out=$(call --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.GetNameOwner string:org.freedesktop.secrets)
|
|
164
|
+
rc=$?; report owner "$out" $rc; [ "$rc" -eq 0 ] || exit 0
|
|
165
|
+
name=$(printf '%s\n' "$out" | last)
|
|
166
|
+
out=$(call --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.GetConnectionUnixProcessID "string:$name")
|
|
167
|
+
rc=$?; report owner_pid "$out" $rc; [ "$rc" -eq 0 ] || exit 0
|
|
168
|
+
[ "$(printf '%s\n' "$out" | last)" = "$daemon" ] || exit 0
|
|
169
|
+
for alias in default login; do
|
|
170
|
+
out=$(call --dest=org.freedesktop.secrets /org/freedesktop/secrets org.freedesktop.Secret.Service.ReadAlias "string:$alias")
|
|
171
|
+
report "alias_$alias" "$out" $?
|
|
172
|
+
done
|
|
173
|
+
out=$(call --dest=org.freedesktop.secrets /org/freedesktop/secrets/collection/login org.freedesktop.DBus.Properties.Get string:org.freedesktop.Secret.Collection string:Locked)
|
|
174
|
+
report locked "$out" $?
|
|
175
|
+
if [ "$mode" = start ]; then
|
|
176
|
+
out=$(call --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.StartServiceByName string:org.gnome.keyring.SystemPrompter uint32:0)
|
|
177
|
+
report prompter "$out" $?
|
|
178
|
+
fi
|
|
179
|
+
`,Nh=e=>e===void 0||e.startsWith(`!`)?void 0:e,Ph=(e,t,n)=>{let r=Nh(e.bus);if(r===void 0)return{kind:`pending`,reason:`the keyring bus did not answer (${e.bus??`no reply`})`};if(r!==String(t.bus.pid))return{kind:`wrong`,reason:`the keyring bus address answers as process ${r}, not the bus the holder started (${t.bus.pid})`};let i=Nh(e.owner_pid);if(Nh(e.owner)===void 0||i===void 0)return{kind:`pending`,reason:`no process owns org.freedesktop.secrets on the keyring bus`};if(i!==String(t.daemon.pid))return{kind:`wrong`,reason:`org.freedesktop.secrets on the keyring bus is owned by process ${i}, not the keyring daemon ${t.daemon.pid}`};for(let t of[`default`,`login`])if(e[`alias_${t}`]!==`/org/freedesktop/secrets/collection/login`)return{kind:`pending`,reason:`the ${t} alias does not name the login collection`};return e.locked===`false`?n===`start`&&e.prompter!==`!org.freedesktop.DBus.Error.Spawn.ChildExited`?{kind:`wrong`,reason:`the keyring bus could start an unlock prompter (${e.prompter??`no reply`}): its service masks are not in effect`}:{kind:`ready`}:{kind:`pending`,reason:`the login collection is not unlocked`}},Fh=(e,t,n,r,i,a)=>O(function*(){let o=yield*Im,s=yield*Oh(r,e.probe_timeout_s),c=yield*o.run(Wm(Mh,[e.tools[`dbus-send`]??``,String(n.pid),String(Math.max(1,Math.floor(s/2))),a]),{timeoutMs:s,env:{DBUS_SESSION_BUS_ADDRESS:t,LC_ALL:`C`},unsetEnv:i}).pipe(Tl(Bh(`keyring check could not run`)));if(c.timedOut||c.exitCode!==0)return yield*j(`keyring check failed (exit ${c.exitCode})`);let l={};for(let e of c.stdout.split(`
|
|
180
|
+
`)){let t=e.indexOf(` `);t>0&&(l[e.slice(0,t)]=e.slice(t+1))}return l}),Ih=e=>({dir:o(e,`keyring`),log:o(e,`logs`,`keyring.log`)}),Lh=(e,t)=>{let n=o(t,`home`);return{...e.DISPLAY===void 0?{}:{DISPLAY:e.DISPLAY},...e.XAUTHORITY===void 0?{}:{XAUTHORITY:e.XAUTHORITY},HOME:n,XDG_CONFIG_HOME:o(n,`.config`),XDG_CACHE_HOME:o(n,`.cache`),XDG_DATA_HOME:o(n,`.local/share`),XDG_RUNTIME_DIR:o(t,`runtime`)}},Rh=e=>{let t={};for(let n of e.split(`
|
|
181
|
+
`)){let e=n.indexOf(`=`);e>0&&(t[n.slice(0,e)]=n.slice(e+1))}return t},zh=e=>{let t=Number(e);return Number.isInteger(t)&&t>1?t:void 0},Bh=e=>t=>new ah({reason:`${e}: ${t.message}`}),Vh=(e,t,n)=>vl(Oh(t,n),t=>Jm(e,t).pipe(Tl(Bh(`keyring process identity read failed`)))),Hh=e=>O(function*(){let t=yield*Im,{stateDir:n,deadline:r,session:i}=e,{dir:a,log:o}=Ih(i.guest_dir),s=(e,t)=>({...i,keyring:{phase:`starting`,dir:a,log:o,processes:e,...t===void 0?{}:{unidentified:{holder:t}}}});yield*nh(a,!1,yield*Oh(r,i.probe_timeout_s)).pipe(Tl(Bh(`keyring directory setup failed`))),yield*wh(n,s({},{pid:null,reason:`its start was requested, but no process id was recorded`}));let c=yield*yl(t.start([`/bin/sh`,`-c`,jh,`sh`,a,i.run_id,i.tools[`dbus-daemon`]??``,i.tools[`gnome-keyring-daemon`]??``],{env:e.env,unsetEnv:e.unsetEnv,cwd:a,logPath:o}));if(c._tag===`Failure`){if(c.failure.notStarted===!0)return yield*wh(n,s({})).pipe(Dl),yield*j(`keyring holder could not start: ${c.failure.message}`);let e=`its start may have run, but returned no process id: ${c.failure.message}`;return yield*wh(n,s({},{pid:null,reason:e})).pipe(Dl),yield*k(new ah({reason:`keyring holder: ${e}; it cannot be signalled, so the guest must be retired`,retire:!0}))}return yield*Uh(e,s,c.success).pipe(Tl(oh))}),Uh=(e,t,n)=>O(function*(){let r=yield*Im,{stateDir:i,deadline:a,session:s}=e,c=s.probe_timeout_s,{dir:l,log:u}=Ih(s.guest_dir);yield*wh(i,t({},{pid:n,reason:`its identity was not read yet`})).pipe(Dl);let d=yield*yl(Vh([n],a,c));if(d._tag===`Failure`){let e=d.failure.reason;return yield*wh(i,t({},{pid:n,reason:e})).pipe(Dl),yield*j(`keyring holder started as process ${n}, but its identity could not be read (${e}); it cannot be signalled, so the guest must be retired`)}let[f]=d.success;if(f?.kind!==`running`)return yield*wh(i,t({})).pipe(Dl),yield*j(`keyring holder exited at once; see its log ${u}`);let p=f.identity;yield*wh(i,t({holder:p}));let m;for(;m===void 0;){let e=yield*yl(r.readFile(o(l,`connection`),yield*Oh(a,c)));if(e._tag===`Success`){m=Rh(new TextDecoder().decode(e.success));break}let t=a.endMs-(yield*Eh);if(t<=0)return yield*j(`keyring session did not become ready`);yield*Al(Math.min(50,t))}let h=zh(m.BUS),g=zh(m.DAEMON),_=m.ADDRESS??``;if(h===void 0||g===void 0||_.length===0)return yield*j(`keyring connection data is incomplete`);let[v,y]=yield*Vh([h,g],a,c);if(v?.kind!==`running`||y?.kind!==`running`)return yield*j(`keyring bus or daemon is not running; see its log ${u}`);let ee={holder:p,bus:v.identity,daemon:y.identity};if(yield*wh(i,{...s,keyring:{phase:`starting`,dir:l,log:u,address:_,processes:ee}}),v.ppid!==p.pid||y.ppid!==p.pid)return yield*j(`keyring bus or daemon is not a child of the keyring holder`);for(;;){let t=yield*yl(Fh(s,_,ee.daemon,a,e.unsetEnv,`start`)),n=t._tag===`Success`?Ph(t.success,ee,`start`):{kind:`pending`,reason:t.failure.reason};if(n.kind===`ready`)break;if(n.kind===`wrong`)return yield*j(n.reason);let r=a.endMs-(yield*Eh);if(r<=0)return yield*j(`keyring session did not become ready: ${n.reason}`);yield*Al(Math.min(50,r))}let b={phase:`ready`,dir:l,log:u,address:_,processes:ee,ready_at:yield*Th};return{...s,keyring:b}}),Wh=[`daemon`,`bus`,`holder`],Gh=(e,t,n,r)=>O(function*(){let i=Wh.map(e=>[e,t.processes[e]]),a=yield*Vh(i.map(([,e])=>e.pid),n,e.probe_timeout_s);for(let[e,[t,n]]of i.entries()){let r=a[e];if(r?.kind!==`running`||qm(r.identity)!==qm(n))return yield*j(`keyring ${t} (process ${n.pid}) is no longer running; the keyring session has ended`)}let o=yield*Fh(e,t.address,t.processes.daemon,n,r,`check`),s=Ph(o,t.processes,`check`);if(s.kind!==`ready`)return yield*j(s.reason)}),Kh=e=>{if(e===void 0)return[];let t=e.processes;return Wh.flatMap(e=>{let n=t[e];return n===void 0?[]:[[`keyring:${e}`,n]]})},qh=e=>Object.fromEntries(Object.entries(e===void 0||e.phase===`ready`?{}:e.unidentified??{}).map(([e,t])=>[`keyring:${e}`,{outcome:`unresolved`,reason:t.pid===null?`${t.reason}; no signal sent`:`process ${t.pid} was never identified; no signal sent`}])),Jh=(e,t)=>{let n=Object.fromEntries(Object.entries(t).filter(([e])=>e.startsWith(`keyring:`))),r=Object.values(n).some(e=>e.outcome===`unresolved`);return{...e,phase:r?`stopping`:`stopped`,ended:n}},Yh=(e,t,n)=>({...Jh(e,t),phase:`failed`,reason:n}),Xh=e=>({address:e.address,processes:e.processes}),Zh=[`Xvfb`,`dbus-run-session`,`startxfce4`,`xdpyinfo`,`wmctrl`,`xprop`,`scrot`,`xwininfo`],Qh=[`xdpyinfo`,`wmctrl`,`xprop`,`scrot`,`xwininfo`],$h=[`DISPLAY`,`HOME`,`XDG_CONFIG_HOME`,`XDG_CACHE_HOME`,`XDG_DATA_HOME`,`XDG_RUNTIME_DIR`,`XDG_CURRENT_DESKTOP`,`XDG_SESSION_TYPE`,`DBUS_SESSION_BUS_ADDRESS`],eg=[...$h,`DBUS_SESSION_BUS_PID`,`SESSION_MANAGER`,`XAUTHORITY`,`WAYLAND_DISPLAY`,`XDG_SESSION_ID`,`DESKTOP_SESSION`],tg=[`DBUS_SESSION_BUS_ADDRESS`,`XDG_RUNTIME_DIR`,`XAUTHORITY`],ng=String.raw`
|
|
182
|
+
dir=$1; run=$2; xfce=$3
|
|
183
|
+
umask 077
|
|
184
|
+
tmp="$dir/.connection.$$"
|
|
185
|
+
{
|
|
186
|
+
printf 'RUN_ID=%s\n' "$run"
|
|
187
|
+
printf 'PID=%s\n' "$$"
|
|
188
|
+
for key in DISPLAY HOME XDG_CONFIG_HOME XDG_CACHE_HOME XDG_DATA_HOME XDG_RUNTIME_DIR XDG_CURRENT_DESKTOP XDG_SESSION_TYPE DBUS_SESSION_BUS_ADDRESS; do
|
|
189
|
+
value=$(printenv "$key" || true)
|
|
190
|
+
printf '%s=%s\n' "$key" "$value"
|
|
191
|
+
done
|
|
192
|
+
} > "$tmp" && mv -f "$tmp" "$dir/connection" || exit 70
|
|
193
|
+
exec "$xfce"
|
|
194
|
+
`,rg=(e,t)=>{let n=t.slice(1);return{lock:o(e,`.X${n}-lock`),socket:o(e,`.X11-unix`,`X${n}`)}},ig=e=>({home:o(e,`home`),runtime:o(e,`runtime`),logs:o(e,`logs`),captures:o(e,`captures`),connection:o(e,`connection`)}),ag=e=>{if(e.kind===`adopted`)return{...e.connection};let t=ig(e.guest_dir);return{DISPLAY:e.display,HOME:t.home,XDG_CONFIG_HOME:o(t.home,`.config`),XDG_CACHE_HOME:o(t.home,`.cache`),XDG_DATA_HOME:o(t.home,`.local/share`),XDG_RUNTIME_DIR:t.runtime,XDG_CURRENT_DESKTOP:`XFCE`,XDG_SESSION_TYPE:`x11`,DESKTOP_SESSION:`xfce`}},og=e=>e.kind===`owned`?ig(e.guest_dir).home:e.guest_dir,sg=(e,t,n,r,i,a,s=t.probe_timeout_s)=>O(function*(){let c=yield*Im,l=yield*Oh(i,s),u=l<s*1e3,d=t.tools[n];if(d===void 0)return yield*j(`no resolved tool named ${n}`);let f=yield*c.run([d,...r],{timeoutMs:l,env:{...a,LC_ALL:`C`},unsetEnv:eg,cwd:og(t)}).pipe(Tl(e=>new ah({reason:`${n} read could not run: ${e.message}`}))),p=o(e,`probes`,`${n}.json`),m=yield*Th;return f.timedOut?(yield*bh(p,{timed_out:!0,timeout_seconds:l/1e3,observed_at:m}),yield*k(new ah({reason:`${n} read timed out; see private probes/${n}.json`,...u?{deadline:!0}:{}}))):(yield*bh(p,{native_exit:f.exitCode,stdout:f.stdout,stderr:f.stderr,observed_at:m}),f.exitCode===0?f.stdout:yield*j(`${n} read failed; see private probes/${n}.json`,f.exitCode))}),cg=e=>t=>new ah({reason:`${e}: ${t.message}`}),lg=(e,t,n=!1)=>Jm(e,t).pipe(Tl(e=>new ah({reason:`process identity read failed: ${e.message}`,...n&&e.timedOut===!0?{deadline:!0}:{}}))),ug=(e,t,n)=>vl(Oh(t,n),t=>lg(e,t,t<n*1e3)),dg=(e,t)=>e?.kind===`running`&&qm(e.identity)===qm(t),fg=(e,t)=>O(function*(){let n=Object.entries(e.children),r=[];e.xfce!==void 0&&r.push([`xfce`,e.xfce]),e.x_server!==void 0&&r.push([`X server`,e.x_server]);let i=[...n,...r];if(i.length===0)return;for(let[e,t]of i)if(!Number.isInteger(t.pid)||t.pid<=1)return yield*j(`${e} has a reserved or malformed recorded process identity`);let a=yield*ug(i.map(([,e])=>e.pid),t,e.probe_timeout_s);for(let[e,[t,n]]of i.entries())if(!dg(a[e],n))return yield*j(`${t} launch identity changed`)}),pg=(e,t,n)=>O(function*(){let{lock:r}=rg(e.x11_dir,e.display),i=yield*$m(r,yield*Oh(t,e.probe_timeout_s)).pipe(Tl(cg(`display lock read failed`)));if(!/^\s*\d+\s*$/u.test(i.content)||Number(i.content.trim())!==n)return yield*j(`display lock does not identify the held X server`);if(i.ownerUid!==e.lock_owner_uid)return yield*j(`display lock belongs to another user`)}),mg=e=>{let t={};for(let n of e.split(`
|
|
195
|
+
`)){let e=n.indexOf(`=`);e>0&&(t[n.slice(0,e)]=n.slice(e+1))}return t},hg=(e,t)=>O(function*(){let n=yield*(yield*Im).readFile(ig(e.guest_dir).connection,yield*Oh(t,e.probe_timeout_s)).pipe(Tl(cg(`session connection data is not readable yet`))),r=mg(new TextDecoder().decode(n));if(r.RUN_ID!==e.run_id)return yield*j(`connection belongs to another launch`);let i=Number(r.PID);if(!Number.isInteger(i)||i<=1)return yield*j(`connection names no XFCE process`);let a=ag(e);for(let e of $h){if(r[e]===void 0)return yield*j(`session connection data is incomplete`);if(e!==`DBUS_SESSION_BUS_ADDRESS`&&r[e]!==a[e])return yield*j(`session connection data changed`)}return(r.DBUS_SESSION_BUS_ADDRESS??``).startsWith(`unix:`)?{pid:i,bus:r.DBUS_SESSION_BUS_ADDRESS??``}:yield*j(`dbus-run-session did not provide a local bus`)}),gg=e=>({...ag(e),...e.kind===`owned`&&e.connection.DBUS_SESSION_BUS_ADDRESS!==void 0?{DBUS_SESSION_BUS_ADDRESS:e.connection.DBUS_SESSION_BUS_ADDRESS}:{}}),_g=e=>{let t=/dimensions:\s+(\d+)x(\d+)\s+pixels/u.exec(e);return t?[Number(t[1]),Number(t[2])]:void 0},vg=(e,t,n)=>O(function*(){let r=t,i=()=>Oh(n,r.probe_timeout_s);yield*fg(r,n);let a=r.kind===`owned`?r.children.xvfb?.pid:r.x_server?.pid;if(a===void 0)return yield*j(`session records no X server`);yield*pg(r,n,a);let o=r.kind===`adopted`||r.children.session!==void 0;if(r.kind===`owned`&&o){let e=yield*hg(r,n);if(r.xfce===void 0){let[t]=yield*ug([e.pid],n,r.probe_timeout_s);if(t?.kind!==`running`)return yield*j(`XFCE launch identity changed`);r={...r,xfce:t.identity,connection:{...r.connection,DBUS_SESSION_BUS_ADDRESS:e.bus}}}else if(e.pid!==r.xfce.pid)return yield*j(`XFCE launch identity changed`)}let s=gg(r),c=yield*sg(e,r,`xdpyinfo`,[],n,s),l=_g(c);if(l===void 0||l[0]!==r.dimensions[0]||l[1]!==r.dimensions[1])return yield*j(`X display dimensions do not match the requested geometry`);if(!o)return{observation:{dimensions:r.dimensions},session:r};let u=yield*sg(e,r,`xprop`,[`-root`,`_NET_SUPPORTING_WM_CHECK`],n,s),d=/window id # (0x[0-9a-fA-F]+)\s*$/u.exec(u);if(d?.[1]===void 0||Number.parseInt(d[1],16)===0)return yield*j(`X root has no supporting window manager`);let f=d[1],p=yield*sg(e,r,`xprop`,[`-id`,f,`_NET_SUPPORTING_WM_CHECK`,`_NET_WM_PID`],n,s),m=/_NET_SUPPORTING_WM_CHECK\(WINDOW\): window id # (0x[0-9a-fA-F]+)/u.exec(p),h=/_NET_WM_PID\(CARDINAL\)\s*=\s*(\d+)/u.exec(p);if(m?.[1]===void 0||Number.parseInt(m[1],16)!==Number.parseInt(f,16)||h?.[1]===void 0||Number(h[1])<=1)return yield*j(`window manager support window is stale or incomplete`);let g=yield*sg(e,r,`wmctrl`,[`-m`],n,s),_=/^Name:\s*(.+)$/mu.exec(g),v=/^PID:\s*(\d+)\s*$/mu.exec(g);if(_?.[1]?.trim()!==`Xfwm4`||v?.[1]===void 0||Number(v[1])!==Number(h[1]))return yield*j(`wmctrl does not identify the same Xfwm4 window manager`);let[y]=yield*ug([Number(h[1])],n,r.probe_timeout_s);if(y?.kind!==`running`)return yield*j(`window manager process is not running`);if(r.kind===`owned`){let e=r.children.session?.pid,t=yield*Xm(y.identity.pid,yield*i()).pipe(Tl(cg(`window manager ancestry read failed`)));if(e===void 0||!t.includes(e))return yield*j(`window manager does not descend from the held XFCE launch`)}else if(r.window_manager!==void 0&&qm(r.window_manager)!==qm(y.identity))return yield*j(`window manager identity changed`);return yield*fg(r,n),yield*pg(r,n,a),r.keyring?.phase===`ready`&&(yield*Gh(r,r.keyring,n,eg)),{observation:{dimensions:r.dimensions,window_manager:{name:`Xfwm4`,window:f,identity:y.identity}},session:r}}),yg=(e,t,n,r)=>O(function*(){let i=`no completed readiness observation`;for(;;){let a=Object.entries(t.children);if(a.length>0){let e=yield*ug(a.map(([,e])=>e.pid),n,t.probe_timeout_s);for(let[t,[n,r]]of a.entries())if(!dg(e[t],r))return yield*j(`${n} exited before or during readiness`)}let o=yield*yl(vg(e,t,n));if(o._tag===`Success`)return o.success;i=o.failure.reason;let s=yield*Eh,c=n.endMs-s;if(c<=0)return yield*j(`readiness expired after ${r}s: ${i}`);yield*Al(Math.min(100,c))}}),bg=(e,t)=>e===void 0||e.kind===`absent`||e.kind===`zombie`||e.kind===`running`&&qm(e.identity)!==qm(t),xg=(e,t,n)=>Nl(O(function*(){let r=yield*Im,i={},a=yield*Dh(t),o={endMs:a.endMs-t*1e3/2},s=new Map;for(let[n,i]of e){let e=yield*yl(r.watchExit(i.pid,t*1e3));e._tag===`Success`&&s.set(n,e.success)}let c=new Map(e),l=new Map,u=new Set,d=e=>O(function*(){for(let[t,r]of c){let o=yield*Ym(r,e,Math.min(n*1e3,Math.max(1,a.endMs-(yield*Eh)))).pipe(Ol(()=>`error`));o===`sent`?l.set(t,e):o===`gone`?(c.delete(t),i[t]={outcome:`ended`,by:l.get(t)??`already`}):o===`changed`?(c.delete(t),u.add(t),i[t]={outcome:`ended`,by:l.get(t)??`already`,reason:`its process id now names another process, which was sent no signal`}):(c.delete(t),i[t]={outcome:`unresolved`,reason:o===`invalid`?`reserved or malformed process identity; no signal sent`:`the identity-checked signal could not be sent`})}}),f=e=>O(function*(){for(;;){if(c.size===0)return;let t=[...c],r=yield*lg(t.map(([,e])=>e.pid),Math.min(n*1e3,Math.max(1,a.endMs-(yield*Eh)))).pipe(Ol(()=>[]));for(let[e,[n,a]]of t.entries())r.length===t.length&&bg(r[e],a)&&(c.delete(n),i[n]={outcome:`ended`,by:l.get(n)??`already`});if(c.size===0||(yield*Eh)>=e.endMs)return;yield*Al(100)}});yield*d(`TERM`),yield*f(o),c.size>0&&(yield*d(`KILL`),yield*f(a));for(let[e]of c)i[e]={outcome:`unresolved`,reason:`still running after the shutdown budget`};for(let[e,t]of Object.entries(i)){let n=s.get(e);if(t.outcome===`ended`&&n!==void 0&&!u.has(e)){let r=yield*yl(kl(n,{duration:2e3,orElse:()=>ll(void 0)}));i[e]={...t,exit_code:r._tag===`Success`?r.success??null:null}}else t.outcome===`ended`&&(i[e]={...t,exit_code:null})}return i})),Sg=(e,t)=>O(function*(){if(yield*vh(e.stateDir))return yield*j(`fresh-only launch refuses existing path: ${e.stateDir}`);let n=yield*Zm(e.guestPaths,t).pipe(Tl(cg(`path check failed`))),r=e.guestPaths.find((e,t)=>n[t]===!0);if(r!==void 0)return yield*j(`fresh-only launch refuses existing path: ${r}`)}),Cg=(e,t,n)=>O(function*(){let r=yield*Qm(e,t,n).pipe(Tl(cg(`tool check failed`)));return r.kind===`missing`?yield*j(`tool directory contains a missing or non-executable prerequisite: ${r.name}`):r.tools}),wg=(e,t,n,r,i,a)=>O(function*(){let o=yield*(yield*Im).start(t,{env:n,unsetEnv:eg,cwd:r,logPath:i}).pipe(Tl(cg(`${e} could not start`))),[s]=yield*lg([o],a);return s?.kind===`running`?s.identity:yield*j(`${e} exited before or during readiness`)}),Tg=e=>O(function*(){let t=yield*Im,n=e.probeTimeout*1e3,r=ig(e.guestDir),i=rg(e.x11Dir,e.display);yield*Sg({stateDir:e.stateDir,guestPaths:[e.guestDir,i.lock,i.socket]},n);let a=yield*Cg(e.toolDir,e.keyring?[...Zh,...Ah]:Zh,n),[s,c]=e.geometry.split(`x`).map(Number);yield*yh(e.stateDir);for(let[t,i]of[[e.guestDir,!0],[r.home,!1],[r.runtime,!1],[r.logs,!1],[r.captures,!1]])yield*nh(t,i,n).pipe(Tl(cg(`guest directory setup failed`)));let l=yield*th(n).pipe(Tl(cg(`uid read failed`))),u={schema:`use-cloud-vms/linux-desktop/session@1`,run_id:d().replaceAll(`-`,``),guest:t.name,kind:`owned`,phase:`starting`,display:e.display,dimensions:[s??0,c??0],geometry:e.geometry,x11_dir:e.x11Dir,guest_dir:e.guestDir,tools:a,probe_timeout_s:e.probeTimeout,ready_timeout_s:e.readyTimeout,shutdown_timeout_s:e.shutdownTimeout,lock_owner_uid:l,children:{},connection:{},apps:{},guest_retirement_required:!0};yield*wh(e.stateDir,u);let f=yield*Dh(e.readyTimeout),p=ag(u),m=O(function*(){let t=yield*wg(`xvfb`,[a.Xvfb??``,e.display,`-screen`,`0`,e.geometry,`-nolisten`,`tcp`,`-ac`,`+extension`,`RANDR`],p,r.home,o(r.logs,`xvfb.log`),n);u={...u,children:{xvfb:t}},yield*wh(e.stateDir,u),yield*yg(e.stateDir,u,f,e.readyTimeout);let i=yield*wg(`session`,[a[`dbus-run-session`]??``,`--`,`/bin/sh`,`-c`,ng,`sh`,e.guestDir,u.run_id,a.startxfce4??``],p,r.home,o(r.logs,`xfce.log`),n);u={...u,children:{...u.children,session:i}},yield*wh(e.stateDir,u);let s=yield*yg(e.stateDir,u,f,e.readyTimeout);return u=s.session,e.keyring&&(u=yield*Hh({stateDir:e.stateDir,session:u,deadline:f,env:Lh(gg(u),Ih(u.guest_dir).dir),unsetEnv:eg})),u={...u,phase:`ready`,observed:s.observation,ready_at:yield*Th},yield*wh(e.stateDir,u),s.observation}),h=yield*yl(m);if(h._tag===`Success`)return{status:`ready`,state_dir:e.stateDir,run_id:u.run_id,guest:u.guest,observed:h.success,...u.keyring?.phase===`ready`?{keyring:Xh(u.keyring)}:{}};let g=e.keyring?yield*yl(Ch(e.stateDir)):void 0,_=g?._tag===`Success`&&g.success.run_id===u.run_id?g.success.keyring:u.keyring,v=Object.entries(u.children),y={...yield*xg([...Kh(_),...v.toReversed()],e.shutdownTimeout,e.probeTimeout),...qh(_)};return u={...u,..._===void 0?{}:{keyring:Yh(_,y,h.failure.reason)},phase:`failed`,reason:h.failure.reason,ended:{direct_children:y,at:yield*Th}},yield*wh(e.stateDir,u).pipe(Dl),yield*k(h.failure)}),Eg=(e,t,n,r)=>O(function*(){let i=yield*yl(Hh({stateDir:e,session:t,deadline:n,env:Lh(gg(t),Ih(t.guest_dir).dir),unsetEnv:eg}).pipe(vl(e=>r(e).pipe(Tl(oh)))));if(i._tag===`Success`)return i.success;let a=yield*yl(Ch(e)),o=a._tag===`Success`?a.success.keyring:void 0,s={...yield*xg(Kh(o),t.shutdown_timeout_s,t.probe_timeout_s),...qh(o)};return o!==void 0&&a._tag===`Success`&&(yield*wh(e,{...a.success,phase:`failed`,reason:i.failure.reason,keyring:Yh(o,s,i.failure.reason)}).pipe(Dl)),yield*k(i.failure)}),Dg=e=>O(function*(){let t=yield*Im,n=e.probeTimeout*1e3,r=ig(e.guestDir);yield*Sg({stateDir:e.stateDir,guestPaths:[e.guestDir]},n);let i=yield*Cg(e.toolDir,e.keyring?[...Qh,...Ah]:Qh,n),[a,o]=e.geometry.split(`x`).map(Number),s=yield*Dh(Math.max(e.probeTimeout*8,1)),{lock:c}=rg(e.x11Dir,e.display),l=yield*$m(c,yield*Oh(s,e.probeTimeout)).pipe(Tl(cg(`display lock read failed`)));if(!/^\s*\d+\s*$/u.test(l.content))return yield*j(`display lock does not name an X server`);let[u]=yield*lg([Number(l.content.trim())],yield*Oh(s,e.probeTimeout));if(u?.kind!==`running`)return yield*j(`display lock names no running X server`);yield*yh(e.stateDir);for(let[t,i]of[[e.guestDir,!0],[r.logs,!1],[r.captures,!1]])yield*nh(t,i,n).pipe(Tl(cg(`guest directory setup failed`)));let f={schema:`use-cloud-vms/linux-desktop/session@1`,run_id:d().replaceAll(`-`,``),guest:t.name,kind:`adopted`,phase:`starting`,display:e.display,dimensions:[a??0,o??0],geometry:e.geometry,x11_dir:e.x11Dir,guest_dir:e.guestDir,tools:i,probe_timeout_s:e.probeTimeout,ready_timeout_s:e.probeTimeout,shutdown_timeout_s:e.probeTimeout*2,lock_owner_uid:l.ownerUid,children:{},x_server:u.identity,connection:{DISPLAY:e.display},apps:{},guest_retirement_required:e.keyring};yield*wh(e.stateDir,f);let p=yield*vg(e.stateDir,f,s),m=p.observation.window_manager;if(m===void 0)return yield*j(`adopted display has no window manager`);let h=yield*eh(m.identity.pid,tg,yield*Oh(s,e.probeTimeout)).pipe(Tl(cg(`window manager environment read failed`)));f={...f,window_manager:m.identity,connection:{...h,DISPLAY:e.display},observed:p.observation};let g=t=>O(function*(){let n={...t,phase:`ready`,ready_at:yield*Th};return yield*wh(e.stateDir,n),n});return f=e.keyring?yield*Eg(e.stateDir,f,s,g):yield*g(f),{status:`ready`,state_dir:e.stateDir,run_id:f.run_id,guest:f.guest,observed:p.observation,connection_keys:Object.keys(f.connection).toSorted(),...f.keyring?.phase===`ready`?{keyring:Xh(f.keyring)}:{}}}),Og=(e,t)=>O(function*(){let n=yield*Dh(t),r=yield*Ch(e);if(r.phase!==`ready`)return yield*j(`session is not in its ready phase`);let i={...r,probe_timeout_s:Math.min(r.probe_timeout_s,t)},a=yield*vg(e,i,n),o=yield*Ch(e);return o.phase!==`ready`||o.run_id!==r.run_id?yield*j(`session changed while readiness was inspected`):{session:r,observation:a.observation,deadline:n}}),kg=(e,t)=>O(function*(){let n=yield*Ch(e);if(n.phase===`stopped`||n.phase===`released`)return{status:n.phase,already:!0,run_id:n.run_id};let r=[],i=t=>wh(e,t).pipe(Cl(`Unavailable`,e=>dl(()=>void r.push(e.reason))));n={...n,phase:`stopping`},yield*i(n);let a=Object.entries(n.apps).flatMap(([e,t])=>t.phase===`running`||t.phase===`unresolved`?[[`app:${e}`,t.identity]]:[]),o=n.kind===`owned`?Object.entries(n.children).toReversed():[],s={...yield*xg([...a,...Kh(n.keyring),...o],t,n.probe_timeout_s),...qh(n.keyring)},c={...n.apps};for(let[e,t]of Object.entries(n.apps)){let n=s[`app:${e}`];t.phase===`unidentified`?s[`app:${e}`]={outcome:`unresolved`,reason:t.pid===null?`${t.reason}; no signal sent`:`process ${t.pid} was never identified; no signal sent`}:n!==void 0&&(c[e]={...t,phase:n.outcome===`ended`?`terminated`:`unresolved`,ended:n})}let l=Object.values(s).some(e=>e.outcome===`unresolved`),u=n.kind===`owned`?`stopped`:`released`;return n={...n,apps:c,...n.keyring===void 0?{}:{keyring:Jh(n.keyring,s)},phase:l?`stopping`:u,ended:{direct_children:s,at:yield*Th}},yield*i(n),{status:n.phase,run_id:n.run_id,direct_children:s,guest_retirement_required:n.guest_retirement_required||l,state_write_errors:r,failed:l||r.length>0}}),Ag=e=>e.split(`
|
|
196
|
+
`).map(e=>/^(0x[0-9a-fA-F]+)\s+(-?\d+)\s+(\d+)\s+(\S+)\s?(.*)$/u.exec(e)).filter(e=>e!==null).map(e=>({id:e[1]??``,pid:Number(e[3]),title:e[5]??``})),jg=(e,t)=>{let n=RegExp(`^\\s*${t}:\\s*(-?\\d+)\\s*$`,`mu`).exec(e);return n?.[1]===void 0?void 0:Number(n[1])},Mg=(e,t)=>{let n=RegExp(`^${t}\\(CARDINAL\\) = (\\d+), (\\d+), (\\d+), (\\d+)$`,`mu`).exec(e);return n===null?RegExp(`^${t}:\\s+not found\\.$`,`mu`).test(e)?[0,0,0,0]:void 0:[Number(n[1]),Number(n[2]),Number(n[3]),Number(n[4])]},Ng=(e,t,n,r)=>O(function*(){if(!/^0x[0-9a-fA-F]+$/u.test(n))return yield*j(`window id ${n} is not an X window id`);let i=yield*sg(e,t,`xwininfo`,[`-id`,n],r,gg(t)),a=jg(i,`Absolute upper-left X`),o=jg(i,`Absolute upper-left Y`),s=jg(i,`Width`),c=jg(i,`Height`);if(a===void 0||o===void 0||s===void 0||c===void 0)return yield*j(`xwininfo did not report the window's geometry`);let l=yield*sg(e,t,`xprop`,[`-id`,n,`_GTK_FRAME_EXTENTS`,`_NET_FRAME_EXTENTS`],r,gg(t)),u=Mg(l,`_GTK_FRAME_EXTENTS`);if(u===void 0)return yield*j(`xprop reported an unreadable _GTK_FRAME_EXTENTS`);let d=Mg(l,`_NET_FRAME_EXTENTS`);if(d===void 0)return yield*j(`xprop reported an unreadable _NET_FRAME_EXTENTS`);let[f,p,m,h]=u,[g,_,v,y]=d;return{x:a+f-g,y:o+m-v,width:s-f-p+g+_,height:c-m-h+v+y,viewable:/Map State:\s*IsViewable/u.test(i),gtk_frame_extents:u,net_frame_extents:d}}),Pg=/^_NET_CLIENT_LIST_STACKING\(WINDOW\): window id # (.*)$/mu,Fg=(e,t,n)=>O(function*(){let r=yield*sg(e,t,`xprop`,[`-root`,`_NET_CLIENT_LIST_STACKING`],n,gg(t)),i=Pg.exec(r)?.[1]?.split(`,`).map(e=>e.trim());return i===void 0||!i.every(e=>/^0x[0-9a-fA-F]+$/u.test(e))?yield*j(`xprop reported an unreadable _NET_CLIENT_LIST_STACKING`):i}),Ig=(e,t)=>e.x<t.x+t.width&&t.x<e.x+e.width&&e.y<t.y+t.height&&t.y<e.y+e.height,Lg=(e,t,n,r,i)=>O(function*(){let a=yield*Fg(e,t,i),o=a.findIndex(e=>Number.parseInt(e,16)===Number.parseInt(n,16));if(o<0)return yield*j(`window ${n} is not in the window manager's stacking order`);let s=[];for(let n of a.slice(o+1)){let a=yield*Ng(e,t,n,i);a.viewable&&Ig(a,r)&&s.push(n)}return s}),Rg=(e,t,n,r)=>O(function*(){let i=yield*sg(e,t,`wmctrl`,[`-lp`],r,gg(t)),a=Ag(i).filter(e=>n===void 0||e.pid===n),o=[];for(let n of a){let i=yield*Ng(e,t,n.id,r);o.push({...n,x:i.x,y:i.y,width:i.width,height:i.height,gtk_frame_extents:i.gtk_frame_extents,net_frame_extents:i.net_frame_extents})}return o}),zg=/^[a-z0-9][a-z0-9-]{0,62}$/u,Bg=(e,t)=>{let n=e.connection.XDG_RUNTIME_DIR??gg(e).XDG_RUNTIME_DIR;return{...gg(e),...e.keyring?.phase===`ready`?{DBUS_SESSION_BUS_ADDRESS:e.keyring.address}:{},HOME:t,XDG_CONFIG_HOME:o(t,`.config`),XDG_CACHE_HOME:o(t,`.cache`),XDG_DATA_HOME:o(t,`.local/share`),XDG_RUNTIME_DIR:n??o(t,`.runtime`)}},Vg=(e,t,n,r)=>O(function*(){let i=n=>o(e.guest_dir,`logs`,n<=1?`app-${t}.log`:`app-${t}-${n}.log`);for(let t=n;;t+=1){let[n]=yield*Zm([i(t)],yield*Oh(r,e.probe_timeout_s)).pipe(Tl(e=>new ah({reason:`log path check failed: ${e.message}`})));if(n===!1)return i(t)}}),Hg=(e,t,n)=>O(function*(){let r=yield*Ch(e),i=Object.fromEntries(Object.entries(r.apps).filter(([e])=>e!==t));yield*wh(e,{...r,apps:n===void 0?i:{...i,[t]:n}})}),Ug=(e,t,n)=>O(function*(){let r=yield*Ch(e),i=r.apps[t];if(i===void 0)return yield*j(`no app named ${t}`);if(i.phase===`unidentified`)return yield*j(`app ${t} was never identified`);yield*wh(e,{...r,apps:{...r.apps,[t]:n(i)}})}),Wg=(e,t,n,r,i,a=`app ${n} is no longer running`)=>O(function*(){let[o]=yield*ug([r.identity.pid],i,t.probe_timeout_s);if(o?.kind!==`running`||qm(o.identity)!==qm(r.identity))return yield*Ug(e,n,e=>({...e,phase:`ended`})),yield*j(a)}),Gg=(e,t,n)=>new ah({reason:`app ${e} started as process ${t}, but ${n}; it cannot be signalled, so the guest must be retired`,retire:!0}),Kg=(e,t,n,r,i,a)=>O(function*(){let o=yield*yl(Hg(e,n,{...i,pid:r,phase:`unidentified`,reason:`its identity was not read yet`})),s=yield*yl(lg([r],t.probe_timeout_s*1e3));if(s._tag===`Failure`)return o._tag===`Failure`?yield*k(Gg(n,r,`it could not be recorded (${o.failure.reason}) and its identity could not be read (${s.failure.reason})`)):(yield*Hg(e,n,{...i,pid:r,phase:`unidentified`,reason:s.failure.reason}).pipe(Dl),yield*k(Gg(n,r,`its identity could not be read (${s.failure.reason})`)));let[c]=s.success;if(c?.kind!==`running`)return yield*Hg(e,n,a).pipe(Dl),yield*j(`app exited at once; see its log ${i.log}`);let l=yield*yl(Hg(e,n,{...i,identity:c.identity,phase:`running`}));return l._tag===`Success`?c.identity:(yield*xg([[`app:${n}`,c.identity]],t.shutdown_timeout_s,t.probe_timeout_s))[`app:${n}`]?.outcome===`ended`?(yield*Hg(e,n,a).pipe(Dl),yield*j(`app ${n} started as process ${r} was ended because its record could not be written: ${l.failure.reason}`)):yield*k(Gg(n,r,`its record could not be written (${l.failure.reason}) and it could not be ended`))}),qg=(e,t,n,r,i)=>O(function*(){if(r.notStarted===!0)return yield*Hg(e,t,i).pipe(Dl),yield*j(`app could not start: ${r.message}`);let a=`its start may have run, but returned no process id: ${r.message}`;return yield*Hg(e,t,{...n,pid:null,phase:`unidentified`,reason:a}).pipe(Dl),yield*k(new ah({reason:`app ${t}: ${a}; it cannot be signalled, so the guest must be retired`,retire:!0}))}),Jg=e=>O(function*(){if(!zg.test(e.name))return yield*j(`app name must be lowercase letters, digits and hyphens`);if(!a(e.home))return yield*j(`app home must be an absolute guest path`);if(e.argv.length===0)return yield*j(`app launch needs a command after --`);let t=yield*Ch(e.stateDir),{session:n,deadline:r}=yield*Og(e.stateDir,t.ready_timeout_s);if(n.apps[e.name]!==void 0)return yield*j(`an app named ${e.name} was already launched`);let i=yield*Oh(r,n.probe_timeout_s),[s]=yield*Zm([e.home],i).pipe(Tl(e=>new ah({reason:`path check failed: ${e.message}`})));if(s===!0)return yield*j(`fresh-only launch refuses existing path: ${e.home}`);for(let t of[e.home,o(e.home,`.config`),o(e.home,`.cache`),o(e.home,`.local`),o(e.home,`.local/share`)])yield*nh(t,t===e.home,i).pipe(Tl(e=>new ah({reason:`app home setup failed: ${e.message}`})));n.connection.XDG_RUNTIME_DIR===void 0&&n.kind===`adopted`&&(yield*nh(o(e.home,`.runtime`),!1,i).pipe(Tl(e=>new ah({reason:`app home setup failed: ${e.message}`}))));let c={argv:[...e.argv],home:e.home,log:yield*Vg(n,e.name,1,r),launched_at:yield*Th};return yield*Yg(e.stateDir,n,e.name,c,e.timeout,void 0)}),Yg=(e,t,n,r,i,a)=>O(function*(){let o=yield*Im;yield*Hg(e,n,{...r,pid:null,phase:`unidentified`,reason:`its start was requested, but no process id was recorded`}).pipe(Tl(e=>new ah({reason:`app ${n} was not started, because it could not be recorded first: ${e.reason}`})));let s=yield*Eh,c=yield*yl(o.start(r.argv,{env:Bg(t,r.home),unsetEnv:eg,cwd:r.home,logPath:r.log}));if(c._tag===`Failure`)return yield*qg(e,n,r,c.failure,a);let l=yield*Kg(e,t,n,c.success,r,a),u={...r,identity:l,phase:`running`},d=yield*Dh(i);return yield*O(function*(){for(;;){let a=yield*Rg(e,t,l.pid,d);if(yield*Wg(e,t,n,u,d,`app exited before it showed a window; see its log ${r.log}`),a.length>0)return{status:`launched`,app:n,identity:l,home:r.home,log:r.log,windows:a,launch_to_window_ms:(yield*Eh)-s};let o=d.endMs-(yield*Eh);if(o<=0)return yield*j(`app showed no window within ${i}s`);yield*Al(Math.min(250,o))}}).pipe(kh(`app showed no window within ${i}s`))}),Xg=e=>O(function*(){let t=yield*Ch(e.stateDir),{session:n,deadline:r}=yield*Og(e.stateDir,t.ready_timeout_s),i=n.apps[e.name];if(i===void 0)return yield*j(`no app named ${e.name}`);if(i.phase===`running`)return yield*j(`app ${e.name} is running`);if(i.phase===`unidentified`||i.phase===`unresolved`)return yield*j(`app ${e.name} is ${i.phase}, so it may still be running; it cannot be relaunched`);let{previous:a=[],...o}=i,s={argv:i.argv,home:i.home,log:yield*Vg(n,e.name,a.length+2,r),launched_at:yield*Th,previous:[...a,o]};return yield*Yg(e.stateDir,n,e.name,s,e.timeout,i)}),Zg=(e,t)=>O(function*(){let n=e.apps[t];return n===void 0?yield*j(`no app named ${t}`):n.phase===`running`?n:yield*j(`app ${t} is ${n.phase}`)}),Qg=(e,t,n)=>O(function*(){let{session:r,deadline:i}=yield*Og(e,n),a=yield*Zg(r,t),o=yield*Rg(e,r,a.identity.pid,i);return yield*Wg(e,r,t,a,i),{status:`windows`,app:t,identity:a.identity,windows:o}}),$g=(e,t,n)=>Nl(O(function*(){let r=yield*Im,i=yield*Ch(e),{session:a,deadline:o}=yield*Og(e,i.ready_timeout_s),s=yield*Zg(a,t),c=yield*Rg(e,a,s.identity.pid,o);if(yield*Wg(e,a,t,s,o),c.length===0)return yield*j(`app ${t} has no window to close`);let l=yield*yl(r.watchExit(s.identity.pid,n*1e3)),u=yield*Eh,d=yield*Th;for(let t of c)yield*sg(e,a,`wmctrl`,[`-i`,`-c`,t.id],o,gg(a));let f=yield*Dh(n);for(;;){let e=f.endMs-(yield*Eh);if(e<=0)return yield*j(`app ${t} was asked to close and is still running after ${n}s`);let r=yield*yl(lg([s.identity.pid],Math.min(a.probe_timeout_s*1e3,e)));if(r._tag===`Failure`)return yield*j(`app ${t} was asked to close, but whether it ended could not be read: ${r.failure.reason}`);let[i]=r.success;if(i===void 0||i.kind===`absent`||i.kind===`zombie`||i.kind===`running`&&qm(i.identity)!==qm(s.identity))break;yield*Al(Math.max(0,Math.min(100,f.endMs-(yield*Eh))))}let p=yield*Eh,m=l._tag===`Success`?yield*l.success.pipe(kl({duration:2e3,orElse:()=>ll(void 0)}),Ol(()=>void 0)):void 0,h=yield*Rg(e,a,s.identity.pid,yield*Dh(a.ready_timeout_s)),g={outcome:`closed`,windows_closed:c.map(e=>e.id),windows_left:h.map(e=>e.id),exit_code:m??null,close_requested_at:d,close_to_exit_ms:p-u};return yield*Ug(e,t,e=>({...e,phase:`closed`,ended:g})),h.length>0?yield*j(`app ${t} ended but windows with its process id remain`):{status:`closed`,app:t,identity:s.identity,...g}})),e_=(e,t,n={})=>{let r={},i=0;for(;i<e.length;){let a=e[i]??``;if(a===`--`)return n.allowRest===!0?t_(r,t,e.slice(i+1)):{ok:!1,reason:`unexpected --`};let o=t[a];if(!a.startsWith(`--`)||o===void 0)return{ok:!1,reason:`unrecognized argument ${JSON.stringify(a)}`};if(r[a]!==void 0)return{ok:!1,reason:`${a} given more than once`};let s=e.slice(i+1,i+1+o.arity);if(s.length<o.arity||s.some(e=>e===`--`))return{ok:!1,reason:`${a} needs ${o.arity} value${o.arity===1?``:`s`}`};r[a]=s,i+=1+o.arity}return n.allowRest===!0?{ok:!1,reason:`missing -- before the command`}:t_(r,t,[])},t_=(e,t,n)=>{for(let[n,r]of Object.entries(t))if(r.required===!0&&e[n]===void 0)return{ok:!1,reason:`${n} is required`};return{ok:!0,values:e,rest:n}},n_=e=>/^[+-]?\d+$/u.test(e)&&Number.isSafeInteger(Number(e))?Number(e):void 0;var r_=Fe(((e,t)=>{t.exports=ne.default})),i_=Fe(((e,t)=>{t.exports=re.default})),a_=Fe(((e,t)=>{t.exports=ee.default})),o_=Fe(((e,t)=>{let n=r_(),r=i_(),i=t.exports=function(){r.call(this),this._buffers=[],this._buffered=0,this._reads=[],this._paused=!1,this._encoding=`utf8`,this.writable=!0};n.inherits(i,r),i.prototype.read=function(e,t){this._reads.push({length:Math.abs(e),allowLess:e<0,func:t}),process.nextTick(function(){this._process(),this._paused&&this._reads&&this._reads.length>0&&(this._paused=!1,this.emit(`drain`))}.bind(this))},i.prototype.write=function(e,t){if(!this.writable)return this.emit(`error`,Error(`Stream not writable`)),!1;let n;return n=Buffer.isBuffer(e)?e:Buffer.from(e,t||this._encoding),this._buffers.push(n),this._buffered+=n.length,this._process(),this._reads&&this._reads.length===0&&(this._paused=!0),this.writable&&!this._paused},i.prototype.end=function(e,t){e&&this.write(e,t),this.writable=!1,this._buffers&&(this._buffers.length===0?this._end():(this._buffers.push(null),this._process()))},i.prototype.destroySoon=i.prototype.end,i.prototype._end=function(){this._reads.length>0&&this.emit(`error`,Error(`Unexpected end of input`)),this.destroy()},i.prototype.destroy=function(){this._buffers&&(this.writable=!1,this._reads=null,this._buffers=null,this.emit(`close`))},i.prototype._processReadAllowingLess=function(e){this._reads.shift();let t=this._buffers[0];t.length>e.length?(this._buffered-=e.length,this._buffers[0]=t.slice(e.length),e.func.call(this,t.slice(0,e.length))):(this._buffered-=t.length,this._buffers.shift(),e.func.call(this,t))},i.prototype._processRead=function(e){this._reads.shift();let t=0,n=0,r=Buffer.alloc(e.length);for(;t<e.length;){let i=this._buffers[n++],a=Math.min(i.length,e.length-t);i.copy(r,t,0,a),t+=a,a!==i.length&&(this._buffers[--n]=i.slice(a))}n>0&&this._buffers.splice(0,n),this._buffered-=e.length,e.func.call(this,r)},i.prototype._process=function(){try{for(;this._buffered>0&&this._reads&&this._reads.length>0;){let e=this._reads[0];if(e.allowLess)this._processReadAllowingLess(e);else if(this._buffered>=e.length)this._processRead(e);else break}this._buffers&&!this.writable&&this._end()}catch(e){this.emit(`error`,e)}}})),s_=Fe((e=>{let t=[{x:[0],y:[0]},{x:[4],y:[0]},{x:[0,4],y:[4]},{x:[2,6],y:[0,4]},{x:[0,2,4,6],y:[2,6]},{x:[1,3,5,7],y:[0,2,4,6]},{x:[0,1,2,3,4,5,6,7],y:[1,3,5,7]}];e.getImagePasses=function(e,n){let r=[],i=e%8,a=n%8,o=(e-i)/8,s=(n-a)/8;for(let e=0;e<t.length;e++){let n=t[e],c=o*n.x.length,l=s*n.y.length;for(let e=0;e<n.x.length&&n.x[e]<i;e++)c++;for(let e=0;e<n.y.length&&n.y[e]<a;e++)l++;c>0&&l>0&&r.push({width:c,height:l,index:e})}return r},e.getInterlaceIterator=function(e){return function(n,r,i){let a=n%t[i].x.length,o=(n-a)/t[i].x.length*8+t[i].x[a],s=r%t[i].y.length,c=(r-s)/t[i].y.length*8+t[i].y[s];return o*4+c*e*4}}})),c_=Fe(((e,t)=>{t.exports=function(e,t,n){let r=e+t-n,i=Math.abs(r-e),a=Math.abs(r-t),o=Math.abs(r-n);return i<=a&&i<=o?e:a<=o?t:n}})),l_=Fe(((e,t)=>{let n=s_(),r=c_();function i(e,t,n){let r=e*t;return n!==8&&(r=Math.ceil(r/(8/n))),r}let a=t.exports=function(e,t){let r=e.width,a=e.height,o=e.interlace,s=e.bpp,c=e.depth;if(this.read=t.read,this.write=t.write,this.complete=t.complete,this._imageIndex=0,this._images=[],o){let e=n.getImagePasses(r,a);for(let t=0;t<e.length;t++)this._images.push({byteWidth:i(e[t].width,s,c),height:e[t].height,lineIndex:0})}else this._images.push({byteWidth:i(r,s,c),height:a,lineIndex:0});this._xComparison=c===8?s:c===16?s*2:1};a.prototype.start=function(){this.read(this._images[this._imageIndex].byteWidth+1,this._reverseFilterLine.bind(this))},a.prototype._unFilterType1=function(e,t,n){let r=this._xComparison,i=r-1;for(let a=0;a<n;a++){let n=e[1+a],o=a>i?t[a-r]:0;t[a]=n+o}},a.prototype._unFilterType2=function(e,t,n){let r=this._lastLine;for(let i=0;i<n;i++){let n=e[1+i],a=r?r[i]:0;t[i]=n+a}},a.prototype._unFilterType3=function(e,t,n){let r=this._xComparison,i=r-1,a=this._lastLine;for(let o=0;o<n;o++){let n=e[1+o],s=a?a[o]:0,c=o>i?t[o-r]:0,l=Math.floor((c+s)/2);t[o]=n+l}},a.prototype._unFilterType4=function(e,t,n){let i=this._xComparison,a=i-1,o=this._lastLine;for(let s=0;s<n;s++){let n=e[1+s],c=o?o[s]:0,l=s>a?t[s-i]:0,u=s>a&&o?o[s-i]:0,d=r(l,c,u);t[s]=n+d}},a.prototype._reverseFilterLine=function(e){let t=e[0],n,r=this._images[this._imageIndex],i=r.byteWidth;if(t===0)n=e.slice(1,i+1);else switch(n=Buffer.alloc(i),t){case 1:this._unFilterType1(e,n,i);break;case 2:this._unFilterType2(e,n,i);break;case 3:this._unFilterType3(e,n,i);break;case 4:this._unFilterType4(e,n,i);break;default:throw Error(`Unrecognised filter type - `+t)}this.write(n),r.lineIndex++,r.lineIndex>=r.height?(this._lastLine=null,this._imageIndex++,r=this._images[this._imageIndex]):this._lastLine=n,r?this.read(r.byteWidth+1,this._reverseFilterLine.bind(this)):(this._lastLine=null,this.complete())}})),u_=Fe(((e,t)=>{let n=r_(),r=o_(),i=l_(),a=t.exports=function(e){r.call(this);let t=[],n=this;this._filter=new i(e,{read:this.read.bind(this),write:function(e){t.push(e)},complete:function(){n.emit(`complete`,Buffer.concat(t))}}),this._filter.start()};n.inherits(a,r)})),d_=Fe(((e,t)=>{t.exports={PNG_SIGNATURE:[137,80,78,71,13,10,26,10],TYPE_IHDR:1229472850,TYPE_IEND:1229278788,TYPE_IDAT:1229209940,TYPE_PLTE:1347179589,TYPE_tRNS:1951551059,TYPE_gAMA:1732332865,COLORTYPE_GRAYSCALE:0,COLORTYPE_PALETTE:1,COLORTYPE_COLOR:2,COLORTYPE_ALPHA:4,COLORTYPE_PALETTE_COLOR:3,COLORTYPE_COLOR_ALPHA:6,COLORTYPE_TO_BPP_MAP:{0:1,2:3,3:1,4:2,6:4},GAMMA_DIVISION:1e5}})),f_=Fe(((e,t)=>{let n=[];(function(){for(let e=0;e<256;e++){let t=e;for(let e=0;e<8;e++)t&1?t=3988292384^t>>>1:t>>>=1;n[e]=t}})();let r=t.exports=function(){this._crc=-1};r.prototype.write=function(e){for(let t=0;t<e.length;t++)this._crc=n[(this._crc^e[t])&255]^this._crc>>>8;return!0},r.prototype.crc32=function(){return this._crc^-1},r.crc32=function(e){let t=-1;for(let r=0;r<e.length;r++)t=n[(t^e[r])&255]^t>>>8;return t^-1}})),p_=Fe(((e,t)=>{let n=d_(),r=f_(),i=t.exports=function(e,t){this._options=e,e.checkCRC=e.checkCRC!==!1,this._hasIHDR=!1,this._hasIEND=!1,this._emittedHeadersFinished=!1,this._palette=[],this._colorType=0,this._chunks={},this._chunks[n.TYPE_IHDR]=this._handleIHDR.bind(this),this._chunks[n.TYPE_IEND]=this._handleIEND.bind(this),this._chunks[n.TYPE_IDAT]=this._handleIDAT.bind(this),this._chunks[n.TYPE_PLTE]=this._handlePLTE.bind(this),this._chunks[n.TYPE_tRNS]=this._handleTRNS.bind(this),this._chunks[n.TYPE_gAMA]=this._handleGAMA.bind(this),this.read=t.read,this.error=t.error,this.metadata=t.metadata,this.gamma=t.gamma,this.transColor=t.transColor,this.palette=t.palette,this.parsed=t.parsed,this.inflateData=t.inflateData,this.finished=t.finished,this.simpleTransparency=t.simpleTransparency,this.headersFinished=t.headersFinished||function(){}};i.prototype.start=function(){this.read(n.PNG_SIGNATURE.length,this._parseSignature.bind(this))},i.prototype._parseSignature=function(e){let t=n.PNG_SIGNATURE;for(let n=0;n<t.length;n++)if(e[n]!==t[n]){this.error(Error(`Invalid file signature`));return}this.read(8,this._parseChunkBegin.bind(this))},i.prototype._parseChunkBegin=function(e){let t=e.readUInt32BE(0),i=e.readUInt32BE(4),a=``;for(let t=4;t<8;t++)a+=String.fromCharCode(e[t]);let o=!!(e[4]&32);if(!this._hasIHDR&&i!==n.TYPE_IHDR){this.error(Error(`Expected IHDR on beggining`));return}if(this._crc=new r,this._crc.write(Buffer.from(a)),this._chunks[i])return this._chunks[i](t);if(!o){this.error(Error(`Unsupported critical chunk type `+a));return}this.read(t+4,this._skipChunk.bind(this))},i.prototype._skipChunk=function(){this.read(8,this._parseChunkBegin.bind(this))},i.prototype._handleChunkEnd=function(){this.read(4,this._parseChunkEnd.bind(this))},i.prototype._parseChunkEnd=function(e){let t=e.readInt32BE(0),n=this._crc.crc32();if(this._options.checkCRC&&n!==t){this.error(Error(`Crc error - `+t+` - `+n));return}this._hasIEND||this.read(8,this._parseChunkBegin.bind(this))},i.prototype._handleIHDR=function(e){this.read(e,this._parseIHDR.bind(this))},i.prototype._parseIHDR=function(e){this._crc.write(e);let t=e.readUInt32BE(0),r=e.readUInt32BE(4),i=e[8],a=e[9],o=e[10],s=e[11],c=e[12];if(i!==8&&i!==4&&i!==2&&i!==1&&i!==16){this.error(Error(`Unsupported bit depth `+i));return}if(!(a in n.COLORTYPE_TO_BPP_MAP)){this.error(Error(`Unsupported color type`));return}if(o!==0){this.error(Error(`Unsupported compression method`));return}if(s!==0){this.error(Error(`Unsupported filter method`));return}if(c!==0&&c!==1){this.error(Error(`Unsupported interlace method`));return}this._colorType=a;let l=n.COLORTYPE_TO_BPP_MAP[this._colorType];this._hasIHDR=!0,this.metadata({width:t,height:r,depth:i,interlace:!!c,palette:!!(a&n.COLORTYPE_PALETTE),color:!!(a&n.COLORTYPE_COLOR),alpha:!!(a&n.COLORTYPE_ALPHA),bpp:l,colorType:a}),this._handleChunkEnd()},i.prototype._handlePLTE=function(e){this.read(e,this._parsePLTE.bind(this))},i.prototype._parsePLTE=function(e){this._crc.write(e);let t=Math.floor(e.length/3);for(let n=0;n<t;n++)this._palette.push([e[n*3],e[n*3+1],e[n*3+2],255]);this.palette(this._palette),this._handleChunkEnd()},i.prototype._handleTRNS=function(e){this.simpleTransparency(),this.read(e,this._parseTRNS.bind(this))},i.prototype._parseTRNS=function(e){if(this._crc.write(e),this._colorType===n.COLORTYPE_PALETTE_COLOR){if(this._palette.length===0){this.error(Error(`Transparency chunk must be after palette`));return}if(e.length>this._palette.length){this.error(Error(`More transparent colors than palette size`));return}for(let t=0;t<e.length;t++)this._palette[t][3]=e[t];this.palette(this._palette)}this._colorType===n.COLORTYPE_GRAYSCALE&&this.transColor([e.readUInt16BE(0)]),this._colorType===n.COLORTYPE_COLOR&&this.transColor([e.readUInt16BE(0),e.readUInt16BE(2),e.readUInt16BE(4)]),this._handleChunkEnd()},i.prototype._handleGAMA=function(e){this.read(e,this._parseGAMA.bind(this))},i.prototype._parseGAMA=function(e){this._crc.write(e),this.gamma(e.readUInt32BE(0)/n.GAMMA_DIVISION),this._handleChunkEnd()},i.prototype._handleIDAT=function(e){this._emittedHeadersFinished||(this._emittedHeadersFinished=!0,this.headersFinished()),this.read(-e,this._parseIDAT.bind(this,e))},i.prototype._parseIDAT=function(e,t){if(this._crc.write(t),this._colorType===n.COLORTYPE_PALETTE_COLOR&&this._palette.length===0)throw Error(`Expected palette not found`);this.inflateData(t);let r=e-t.length;r>0?this._handleIDAT(r):this._handleChunkEnd()},i.prototype._handleIEND=function(e){this.read(e,this._parseIEND.bind(this))},i.prototype._parseIEND=function(e){this._crc.write(e),this._hasIEND=!0,this._handleChunkEnd(),this.finished&&this.finished()}})),m_=Fe((e=>{let t=s_(),n=[function(){},function(e,t,n,r){if(r===t.length)throw Error(`Ran out of data`);let i=t[r];e[n]=i,e[n+1]=i,e[n+2]=i,e[n+3]=255},function(e,t,n,r){if(r+1>=t.length)throw Error(`Ran out of data`);let i=t[r];e[n]=i,e[n+1]=i,e[n+2]=i,e[n+3]=t[r+1]},function(e,t,n,r){if(r+2>=t.length)throw Error(`Ran out of data`);e[n]=t[r],e[n+1]=t[r+1],e[n+2]=t[r+2],e[n+3]=255},function(e,t,n,r){if(r+3>=t.length)throw Error(`Ran out of data`);e[n]=t[r],e[n+1]=t[r+1],e[n+2]=t[r+2],e[n+3]=t[r+3]}],r=[function(){},function(e,t,n,r){let i=t[0];e[n]=i,e[n+1]=i,e[n+2]=i,e[n+3]=r},function(e,t,n){let r=t[0];e[n]=r,e[n+1]=r,e[n+2]=r,e[n+3]=t[1]},function(e,t,n,r){e[n]=t[0],e[n+1]=t[1],e[n+2]=t[2],e[n+3]=r},function(e,t,n){e[n]=t[0],e[n+1]=t[1],e[n+2]=t[2],e[n+3]=t[3]}];function i(e,t){let n=[],r=0;function i(){if(r===e.length)throw Error(`Ran out of data`);let i=e[r];r++;let a,o,s,c,l,u,d,f;switch(t){default:throw Error(`unrecognised depth`);case 16:d=e[r],r++,n.push((i<<8)+d);break;case 4:d=i&15,f=i>>4,n.push(f,d);break;case 2:l=i&3,u=i>>2&3,d=i>>4&3,f=i>>6&3,n.push(f,d,u,l);break;case 1:a=i&1,o=i>>1&1,s=i>>2&1,c=i>>3&1,l=i>>4&1,u=i>>5&1,d=i>>6&1,f=i>>7&1,n.push(f,d,u,l,c,s,o,a)}}return{get:function(e){for(;n.length<e;)i();let t=n.slice(0,e);return n=n.slice(e),t},resetAfterLine:function(){n.length=0},end:function(){if(r!==e.length)throw Error(`extra data found`)}}}function a(e,t,r,i,a,o){let s=e.width,c=e.height,l=e.index;for(let e=0;e<c;e++)for(let c=0;c<s;c++){let s=r(c,e,l);n[i](t,a,s,o),o+=i}return o}function o(e,t,n,i,a,o){let s=e.width,c=e.height,l=e.index;for(let e=0;e<c;e++){for(let c=0;c<s;c++){let s=a.get(i),u=n(c,e,l);r[i](t,s,u,o)}a.resetAfterLine()}}e.dataToBitMap=function(e,n){let r=n.width,s=n.height,c=n.depth,l=n.bpp,u=n.interlace,d;c!==8&&(d=i(e,c));let f;f=c<=8?Buffer.alloc(r*s*4):new Uint16Array(r*s*4);let p=2**c-1,m=0,h,g;if(u)h=t.getImagePasses(r,s),g=t.getInterlaceIterator(r,s);else{let e=0;g=function(){let t=e;return e+=4,t},h=[{width:r,height:s}]}for(let t=0;t<h.length;t++)c===8?m=a(h[t],f,g,l,e,m):o(h[t],f,g,l,d,p);if(c===8){if(m!==e.length)throw Error(`extra data found`)}else d.end();return f}})),h_=Fe(((e,t)=>{function n(e,t,n,r,i){let a=0;for(let o=0;o<r;o++)for(let r=0;r<n;r++){let n=i[e[a]];if(!n)throw Error(`index `+e[a]+` not in palette`);for(let e=0;e<4;e++)t[a+e]=n[e];a+=4}}function r(e,t,n,r,i){let a=0;for(let o=0;o<r;o++)for(let r=0;r<n;r++){let n=!1;if(i.length===1?i[0]===e[a]&&(n=!0):i[0]===e[a]&&i[1]===e[a+1]&&i[2]===e[a+2]&&(n=!0),n)for(let e=0;e<4;e++)t[a+e]=0;a+=4}}function i(e,t,n,r,i){let a=2**i-1,o=0;for(let i=0;i<r;i++)for(let r=0;r<n;r++){for(let n=0;n<4;n++)t[o+n]=Math.floor(e[o+n]*255/a+.5);o+=4}}t.exports=function(e,t,a=!1){let o=t.depth,s=t.width,c=t.height,l=t.colorType,u=t.transColor,d=t.palette,f=e;return l===3?n(e,f,s,c,d):(u&&r(e,f,s,c,u),o!==8&&!a&&(o===16&&(f=Buffer.alloc(s*c*4)),i(e,f,s,c,o))),f}})),g_=Fe(((e,t)=>{let n=r_(),r=a_(),i=o_(),a=u_(),o=p_(),s=m_(),c=h_(),l=t.exports=function(e){i.call(this),this._parser=new o(e,{read:this.read.bind(this),error:this._handleError.bind(this),metadata:this._handleMetaData.bind(this),gamma:this.emit.bind(this,`gamma`),palette:this._handlePalette.bind(this),transColor:this._handleTransColor.bind(this),finished:this._finished.bind(this),inflateData:this._inflateData.bind(this),simpleTransparency:this._simpleTransparency.bind(this),headersFinished:this._headersFinished.bind(this)}),this._options=e,this.writable=!0,this._parser.start()};n.inherits(l,i),l.prototype._handleError=function(e){this.emit(`error`,e),this.writable=!1,this.destroy(),this._inflate&&this._inflate.destroy&&this._inflate.destroy(),this._filter&&(this._filter.destroy(),this._filter.on(`error`,function(){})),this.errord=!0},l.prototype._inflateData=function(e){if(!this._inflate){if(this._bitmapInfo.interlace)this._inflate=r.createInflate(),this._inflate.on(`error`,this.emit.bind(this,`error`)),this._filter.on(`complete`,this._complete.bind(this)),this._inflate.pipe(this._filter);else{let e=((this._bitmapInfo.width*this._bitmapInfo.bpp*this._bitmapInfo.depth+7>>3)+1)*this._bitmapInfo.height,t=Math.max(e,r.Z_MIN_CHUNK);this._inflate=r.createInflate({chunkSize:t});let n=e,i=this.emit.bind(this,`error`);this._inflate.on(`error`,function(e){n&&i(e)}),this._filter.on(`complete`,this._complete.bind(this));let a=this._filter.write.bind(this._filter);this._inflate.on(`data`,function(e){n&&(e.length>n&&(e=e.slice(0,n)),n-=e.length,a(e))}),this._inflate.on(`end`,this._filter.end.bind(this._filter))}}this._inflate.write(e)},l.prototype._handleMetaData=function(e){this._metaData=e,this._bitmapInfo=Object.create(e),this._filter=new a(this._bitmapInfo)},l.prototype._handleTransColor=function(e){this._bitmapInfo.transColor=e},l.prototype._handlePalette=function(e){this._bitmapInfo.palette=e},l.prototype._simpleTransparency=function(){this._metaData.alpha=!0},l.prototype._headersFinished=function(){this.emit(`metadata`,this._metaData)},l.prototype._finished=function(){this.errord||(this._inflate?this._inflate.end():this.emit(`error`,`No Inflate block`))},l.prototype._complete=function(e){if(this.errord)return;let t;try{let n=s.dataToBitMap(e,this._bitmapInfo);t=c(n,this._bitmapInfo,this._options.skipRescale),n=null}catch(e){this._handleError(e);return}this.emit(`parsed`,t)}})),__=Fe(((e,t)=>{let n=d_();t.exports=function(e,t,r,i){let a=[n.COLORTYPE_COLOR_ALPHA,n.COLORTYPE_ALPHA].indexOf(i.colorType)!==-1;if(i.colorType===i.inputColorType){let t=(function(){let e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),new Int16Array(e)[0]!==256})();if(i.bitDepth===8||i.bitDepth===16&&t)return e}let o=i.bitDepth===16?new Uint16Array(e.buffer):e,s=255,c=n.COLORTYPE_TO_BPP_MAP[i.inputColorType];c===4&&!i.inputHasAlpha&&(c=3);let l=n.COLORTYPE_TO_BPP_MAP[i.colorType];i.bitDepth===16&&(s=65535,l*=2);let u=Buffer.alloc(t*r*l),d=0,f=0,p=i.bgColor||{};p.red===void 0&&(p.red=s),p.green===void 0&&(p.green=s),p.blue===void 0&&(p.blue=s);function m(){let e,t,r,c=s;switch(i.inputColorType){case n.COLORTYPE_COLOR_ALPHA:c=o[d+3],e=o[d],t=o[d+1],r=o[d+2];break;case n.COLORTYPE_COLOR:e=o[d],t=o[d+1],r=o[d+2];break;case n.COLORTYPE_ALPHA:c=o[d+1],e=o[d],t=e,r=e;break;case n.COLORTYPE_GRAYSCALE:e=o[d],t=e,r=e;break;default:throw Error(`input color type:`+i.inputColorType+` is not supported at present`)}return i.inputHasAlpha&&(a||(c/=s,e=Math.min(Math.max(Math.round((1-c)*p.red+c*e),0),s),t=Math.min(Math.max(Math.round((1-c)*p.green+c*t),0),s),r=Math.min(Math.max(Math.round((1-c)*p.blue+c*r),0),s))),{red:e,green:t,blue:r,alpha:c}}for(let e=0;e<r;e++)for(let e=0;e<t;e++){let e=m(o,d);switch(i.colorType){case n.COLORTYPE_COLOR_ALPHA:case n.COLORTYPE_COLOR:i.bitDepth===8?(u[f]=e.red,u[f+1]=e.green,u[f+2]=e.blue,a&&(u[f+3]=e.alpha)):(u.writeUInt16BE(e.red,f),u.writeUInt16BE(e.green,f+2),u.writeUInt16BE(e.blue,f+4),a&&u.writeUInt16BE(e.alpha,f+6));break;case n.COLORTYPE_ALPHA:case n.COLORTYPE_GRAYSCALE:{let t=(e.red+e.green+e.blue)/3;i.bitDepth===8?(u[f]=t,a&&(u[f+1]=e.alpha)):(u.writeUInt16BE(t,f),a&&u.writeUInt16BE(e.alpha,f+2));break}default:throw Error(`unrecognised color Type `+i.colorType)}d+=c,f+=l}return u}})),v_=Fe(((e,t)=>{let n=c_();function r(e,t,n,r,i){for(let a=0;a<n;a++)r[i+a]=e[t+a]}function i(e,t,n){let r=0,i=t+n;for(let n=t;n<i;n++)r+=Math.abs(e[n]);return r}function a(e,t,n,r,i,a){for(let o=0;o<n;o++){let n=o>=a?e[t+o-a]:0,s=e[t+o]-n;r[i+o]=s}}function o(e,t,n,r){let i=0;for(let a=0;a<n;a++){let n=a>=r?e[t+a-r]:0,o=e[t+a]-n;i+=Math.abs(o)}return i}function s(e,t,n,r,i){for(let a=0;a<n;a++){let o=t>0?e[t+a-n]:0,s=e[t+a]-o;r[i+a]=s}}function c(e,t,n){let r=0,i=t+n;for(let a=t;a<i;a++){let i=t>0?e[a-n]:0,o=e[a]-i;r+=Math.abs(o)}return r}function l(e,t,n,r,i,a){for(let o=0;o<n;o++){let s=o>=a?e[t+o-a]:0,c=t>0?e[t+o-n]:0,l=e[t+o]-(s+c>>1);r[i+o]=l}}function u(e,t,n,r){let i=0;for(let a=0;a<n;a++){let o=a>=r?e[t+a-r]:0,s=t>0?e[t+a-n]:0,c=e[t+a]-(o+s>>1);i+=Math.abs(c)}return i}function d(e,t,r,i,a,o){for(let s=0;s<r;s++){let c=s>=o?e[t+s-o]:0,l=t>0?e[t+s-r]:0,u=t>0&&s>=o?e[t+s-(r+o)]:0,d=e[t+s]-n(c,l,u);i[a+s]=d}}function f(e,t,r,i){let a=0;for(let o=0;o<r;o++){let s=o>=i?e[t+o-i]:0,c=t>0?e[t+o-r]:0,l=t>0&&o>=i?e[t+o-(r+i)]:0,u=e[t+o]-n(s,c,l);a+=Math.abs(u)}return a}let p={0:r,1:a,2:s,3:l,4:d},m={0:i,1:o,2:c,3:u,4:f};t.exports=function(e,t,n,r,i){let a;if(!(`filterType`in r)||r.filterType===-1)a=[0,1,2,3,4];else if(typeof r.filterType==`number`)a=[r.filterType];else throw Error(`unrecognised filter types`);r.bitDepth===16&&(i*=2);let o=t*i,s=0,c=0,l=Buffer.alloc((o+1)*n),u=a[0];for(let t=0;t<n;t++){if(a.length>1){let t=1/0;for(let n=0;n<a.length;n++){let r=m[a[n]](e,c,o,i);r<t&&(u=a[n],t=r)}}l[s]=u,s++,p[u](e,c,o,l,s,i),s+=o,c+=o}return l}})),y_=Fe(((e,t)=>{let n=d_(),r=f_(),i=__(),a=v_(),o=a_(),s=t.exports=function(e){if(this._options=e,e.deflateChunkSize=e.deflateChunkSize||32768,e.deflateLevel=e.deflateLevel==null?9:e.deflateLevel,e.deflateStrategy=e.deflateStrategy==null?3:e.deflateStrategy,e.inputHasAlpha=e.inputHasAlpha==null||e.inputHasAlpha,e.deflateFactory=e.deflateFactory||o.createDeflate,e.bitDepth=e.bitDepth||8,e.colorType=typeof e.colorType==`number`?e.colorType:n.COLORTYPE_COLOR_ALPHA,e.inputColorType=typeof e.inputColorType==`number`?e.inputColorType:n.COLORTYPE_COLOR_ALPHA,[n.COLORTYPE_GRAYSCALE,n.COLORTYPE_COLOR,n.COLORTYPE_COLOR_ALPHA,n.COLORTYPE_ALPHA].indexOf(e.colorType)===-1)throw Error(`option color type:`+e.colorType+` is not supported at present`);if([n.COLORTYPE_GRAYSCALE,n.COLORTYPE_COLOR,n.COLORTYPE_COLOR_ALPHA,n.COLORTYPE_ALPHA].indexOf(e.inputColorType)===-1)throw Error(`option input color type:`+e.inputColorType+` is not supported at present`);if(e.bitDepth!==8&&e.bitDepth!==16)throw Error(`option bit depth:`+e.bitDepth+` is not supported at present`)};s.prototype.getDeflateOptions=function(){return{chunkSize:this._options.deflateChunkSize,level:this._options.deflateLevel,strategy:this._options.deflateStrategy}},s.prototype.createDeflate=function(){return this._options.deflateFactory(this.getDeflateOptions())},s.prototype.filterData=function(e,t,r){let o=i(e,t,r,this._options),s=n.COLORTYPE_TO_BPP_MAP[this._options.colorType];return a(o,t,r,this._options,s)},s.prototype._packChunk=function(e,t){let n=t?t.length:0,i=Buffer.alloc(n+12);return i.writeUInt32BE(n,0),i.writeUInt32BE(e,4),t&&t.copy(i,8),i.writeInt32BE(r.crc32(i.slice(4,i.length-4)),i.length-4),i},s.prototype.packGAMA=function(e){let t=Buffer.alloc(4);return t.writeUInt32BE(Math.floor(e*n.GAMMA_DIVISION),0),this._packChunk(n.TYPE_gAMA,t)},s.prototype.packIHDR=function(e,t){let r=Buffer.alloc(13);return r.writeUInt32BE(e,0),r.writeUInt32BE(t,4),r[8]=this._options.bitDepth,r[9]=this._options.colorType,r[10]=0,r[11]=0,r[12]=0,this._packChunk(n.TYPE_IHDR,r)},s.prototype.packIDAT=function(e){return this._packChunk(n.TYPE_IDAT,e)},s.prototype.packIEND=function(){return this._packChunk(n.TYPE_IEND,null)}})),b_=Fe(((e,t)=>{let n=r_(),r=i_(),i=d_(),a=y_(),o=t.exports=function(e){r.call(this);let t=e||{};this._packer=new a(t),this._deflate=this._packer.createDeflate(),this.readable=!0};n.inherits(o,r),o.prototype.pack=function(e,t,n,r){this.emit(`data`,Buffer.from(i.PNG_SIGNATURE)),this.emit(`data`,this._packer.packIHDR(t,n)),r&&this.emit(`data`,this._packer.packGAMA(r));let a=this._packer.filterData(e,t,n);this._deflate.on(`error`,this.emit.bind(this,`error`)),this._deflate.on(`data`,function(e){this.emit(`data`,this._packer.packIDAT(e))}.bind(this)),this._deflate.on(`end`,function(){this.emit(`data`,this._packer.packIEND()),this.emit(`end`)}.bind(this)),this._deflate.end(a)}})),x_=Fe(((e,t)=>{t.exports=se.default})),S_=Fe(((e,t)=>{t.exports=ce.default})),C_=Fe(((e,t)=>{let n=x_().ok,r=a_(),i=r_(),a=S_().kMaxLength;function o(e){if(!(this instanceof o))return new o(e);e&&e.chunkSize<r.Z_MIN_CHUNK&&(e.chunkSize=r.Z_MIN_CHUNK),r.Inflate.call(this,e),this._offset=this._offset===void 0?this._outOffset:this._offset,this._buffer=this._buffer||this._outBuffer,e&&e.maxLength!=null&&(this._maxLength=e.maxLength)}function s(e){return new o(e)}function c(e,t){t&&process.nextTick(t),e._handle&&=(e._handle.close(),null)}o.prototype._processChunk=function(e,t,i){if(typeof i==`function`)return r.Inflate._processChunk.call(this,e,t,i);let o=this,s=e&&e.length,l=this._chunkSize-this._offset,u=this._maxLength,d=0,f=[],p=0,m;this.on(`error`,function(e){m=e});function h(e,t){if(o._hadError)return;let r=l-t;if(n(r>=0,`have should not go down`),r>0){let e=o._buffer.slice(o._offset,o._offset+r);if(o._offset+=r,e.length>u&&(e=e.slice(0,u)),f.push(e),p+=e.length,u-=e.length,u===0)return!1}return(t===0||o._offset>=o._chunkSize)&&(l=o._chunkSize,o._offset=0,o._buffer=Buffer.allocUnsafe(o._chunkSize)),t===0&&(d+=s-e,s=e,!0)}n(this._handle,`zlib binding closed`);let g;do g=this._handle.writeSync(t,e,d,s,this._buffer,this._offset,l),g||=this._writeState;while(!this._hadError&&h(g[0],g[1]));if(this._hadError)throw m;if(p>=a)throw c(this),RangeError(`Cannot create final Buffer. It would be larger than 0x`+a.toString(16)+` bytes`);let _=Buffer.concat(f,p);return c(this),_},i.inherits(o,r.Inflate);function l(e,t){if(typeof t==`string`&&(t=Buffer.from(t)),!(t instanceof Buffer))throw TypeError(`Not a string or buffer`);let n=e._finishFlushFlag;return n??=r.Z_FINISH,e._processChunk(t,n)}function u(e,t){return l(new o(t),e)}t.exports=e=u,e.Inflate=o,e.createInflate=s,e.inflateSync=u})),w_=Fe(((e,t)=>{let n=t.exports=function(e){this._buffer=e,this._reads=[]};n.prototype.read=function(e,t){this._reads.push({length:Math.abs(e),allowLess:e<0,func:t})},n.prototype.process=function(){for(;this._reads.length>0&&this._buffer.length;){let e=this._reads[0];if(this._buffer.length&&(this._buffer.length>=e.length||e.allowLess)){this._reads.shift();let t=this._buffer;this._buffer=t.slice(e.length),e.func.call(this,t.slice(0,e.length))}else break}if(this._reads.length>0)throw Error(`There are some read requests waitng on finished stream`);if(this._buffer.length>0)throw Error(`unrecognised content at end of stream`)}})),T_=Fe((e=>{let t=w_(),n=l_();e.process=function(e,r){let i=[],a=new t(e);return new n(r,{read:a.read.bind(a),write:function(e){i.push(e)},complete:function(){}}).start(),a.process(),Buffer.concat(i)}})),E_=Fe(((e,t)=>{let n=!0,r=a_(),i=C_();r.deflateSync||(n=!1);let a=w_(),o=T_(),s=p_(),c=m_(),l=h_();t.exports=function(e,t){if(!n)throw Error(`To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0`);let u;function d(e){u=e}let f;function p(e){f=e}function m(e){f.transColor=e}function h(e){f.palette=e}function g(){f.alpha=!0}let _;function v(e){_=e}let y=[];function ee(e){y.push(e)}let b=new a(e);if(new s(t,{read:b.read.bind(b),error:d,metadata:p,gamma:v,palette:h,transColor:m,inflateData:ee,simpleTransparency:g}).start(),b.process(),u)throw u;let te=Buffer.concat(y);y.length=0;let ne;if(f.interlace)ne=r.inflateSync(te);else{let e=((f.width*f.bpp*f.depth+7>>3)+1)*f.height;ne=i(te,{chunkSize:e,maxLength:e})}if(te=null,!ne||!ne.length)throw Error(`bad png - invalid inflate data response`);let re=o.process(ne,f);te=null;let ie=c.dataToBitMap(re,f);re=null;let ae=l(ie,f,t.skipRescale);return f.data=ae,f.gamma=_||0,f}})),D_=Fe(((e,t)=>{let n=!0,r=a_();r.deflateSync||(n=!1);let i=d_(),a=y_();t.exports=function(e,t){if(!n)throw Error(`To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0`);let o=new a(t||{}),s=[];s.push(Buffer.from(i.PNG_SIGNATURE)),s.push(o.packIHDR(e.width,e.height)),e.gamma&&s.push(o.packGAMA(e.gamma));let c=o.filterData(e.data,e.width,e.height),l=r.deflateSync(c,o.getDeflateOptions());if(c=null,!l||!l.length)throw Error(`bad png - invalid compressed data response`);return s.push(o.packIDAT(l)),s.push(o.packIEND()),Buffer.concat(s)}})),O_=Fe((e=>{let t=E_(),n=D_();e.read=function(e,n){return t(e,n||{})},e.write=function(e,t){return n(e,t)}})),k_=Fe((e=>{let t=r_(),n=i_(),r=g_(),i=b_(),a=O_(),o=e.PNG=function(e){n.call(this),e||={},this.width=e.width|0,this.height=e.height|0,this.data=this.width>0&&this.height>0?Buffer.alloc(4*this.width*this.height):null,e.fill&&this.data&&this.data.fill(0),this.gamma=0,this.readable=this.writable=!0,this._parser=new r(e),this._parser.on(`error`,this.emit.bind(this,`error`)),this._parser.on(`close`,this._handleClose.bind(this)),this._parser.on(`metadata`,this._metadata.bind(this)),this._parser.on(`gamma`,this._gamma.bind(this)),this._parser.on(`parsed`,function(e){this.data=e,this.emit(`parsed`,e)}.bind(this)),this._packer=new i(e),this._packer.on(`data`,this.emit.bind(this,`data`)),this._packer.on(`end`,this.emit.bind(this,`end`)),this._parser.on(`close`,this._handleClose.bind(this)),this._packer.on(`error`,this.emit.bind(this,`error`))};t.inherits(o,n),o.sync=a,o.prototype.pack=function(){return!this.data||!this.data.length?(this.emit(`error`,`No data provided`),this):(process.nextTick(function(){this._packer.pack(this.data,this.width,this.height,this.gamma)}.bind(this)),this)},o.prototype.parse=function(e,t){if(t){let e,n;e=function(e){this.removeListener(`error`,n),this.data=e,t(null,this)}.bind(this),n=function(n){this.removeListener(`parsed`,e),t(n,null)}.bind(this),this.once(`parsed`,e),this.once(`error`,n)}return this.end(e),this},o.prototype.write=function(e){return this._parser.write(e),!0},o.prototype.end=function(e){this._parser.end(e)},o.prototype._metadata=function(e){this.width=e.width,this.height=e.height,this.emit(`metadata`,e)},o.prototype._gamma=function(e){this.gamma=e},o.prototype._handleClose=function(){!this._parser.writable&&!this._packer.readable&&this.emit(`close`)},o.bitblt=function(e,t,n,r,i,a,o,s){if(n|=0,r|=0,i|=0,a|=0,o|=0,s|=0,n>e.width||r>e.height||n+i>e.width||r+a>e.height)throw Error(`bitblt reading outside image`);if(o>t.width||s>t.height||o+i>t.width||s+a>t.height)throw Error(`bitblt writing outside image`);for(let c=0;c<a;c++)e.data.copy(t.data,(s+c)*t.width+o<<2,(r+c)*e.width+n<<2,(r+c)*e.width+n+i<<2)},o.prototype.bitblt=function(e,t,n,r,i,a,s){return o.bitblt(this,e,t,n,r,i,a,s),this},o.adjustGamma=function(e){if(e.gamma){for(let t=0;t<e.height;t++)for(let n=0;n<e.width;n++){let r=e.width*t+n<<2;for(let t=0;t<3;t++){let n=e.data[r+t]/255;n**=1/2.2/e.gamma,e.data[r+t]=Math.round(n*255)}}e.gamma=0}},o.prototype.adjustGamma=function(){o.adjustGamma(this)}}))();const A_=Uint8Array.of(137,80,78,71,13,10,26,10),j_=(e,t)=>{switch(e){case 0:return t===16?`I;16`:`L`;case 2:return`RGB`;case 3:return`P`;case 4:return`LA`;case 6:return`RGBA`;default:return`color-type-${e}`}},M_=(e,t)=>(e[t]??0)*16777216+((e[t+1]??0)<<16)+((e[t+2]??0)<<8)+(e[t+3]??0)>>>0,N_=(e,t)=>String.fromCharCode(...e.subarray(t,t+4)),P_=e=>e>=65&&e<=90||e>=97&&e<=122,F_=[[0,0,8,8],[4,0,8,8],[0,4,4,8],[2,0,4,4],[0,2,2,4],[1,0,2,2],[0,1,1,2]],I_=(e,t)=>{let n=(e,n)=>n>0?e*(1+n*t):0;return e.interlace===0?n(e.height,e.width):F_.reduce((t,[r,i,a,o])=>t+n(Math.ceil(Math.max(0,e.height-i)/o),Math.ceil(Math.max(0,e.width-r)/a)),0)},L_=(e,t)=>{try{return te(Buffer.concat(e),{maxOutputLength:t+1}).length===t}catch{return!1}},R_=e=>{if(e.length<A_.length||A_.some((t,n)=>e[n]!==t))return{ok:!1,reason:`invalid_png`};let t=A_.length,n,r=!1,i=!1,a=!1,o=!1,s=!1,c=[];for(;t<e.length;){if(s||e.length-t<12)return{ok:!1,reason:`invalid_png`,...n?{header:n}:{}};let l=M_(e,t),u=t+4,d=N_(e,u),f=e.subarray(u,u+4);if(l>2147483647||!f.every(P_))return{ok:!1,reason:`invalid_png`,...n?{header:n}:{}};let p=u+4+l;if(p+4>e.length)return{ok:!1,reason:`invalid_png`,...n?{header:n}:{}};let m=M_(e,p);if(b(e.subarray(u,p))>>>0!==m)return{ok:!1,reason:`invalid_png`,...n?{header:n}:{}};let h=e.subarray(u+4,p);if(n===void 0){if(d!==`IHDR`||l!==13)return{ok:!1,reason:`invalid_png`};if(n={width:M_(h,0),height:M_(h,4),bitDepth:h[8]??0,colorType:h[9]??0,interlace:h[12]??0,mode:j_(h[9]??0,h[8]??0)},n.width===0||n.height===0||h[10]!==0||h[11]!==0||n.interlace!==0&&n.interlace!==1)return{ok:!1,reason:`invalid_png`,header:n}}else if(d===`IHDR`)return{ok:!1,reason:`invalid_png`,header:n};else if(d===`IDAT`){if(a)return{ok:!1,reason:`invalid_png`,header:n};r=!0,c.push(h)}else if(d===`PLTE`){if(r||i||l===0||l%3!=0||l>768)return{ok:!1,reason:`invalid_png`,header:n};i=!0}else if(r&&(a=!0),d===`acTL`)o=!0;else if(d===`IEND`){if(l!==0||!r)return{ok:!1,reason:`invalid_png`,header:n};s=!0}else if((f[0]??0)<=90)return{ok:!1,reason:`invalid_png`,header:n};t=p+4}return!s||n===void 0?{ok:!1,reason:`invalid_png`,...n?{header:n}:{}}:o?{ok:!1,reason:`multiple_frames`,header:n}:n.bitDepth!==8||n.colorType!==2&&n.colorType!==6?{ok:!1,reason:`unsupported_sample_format`,header:n}:L_(c,I_(n,n.colorType===6?4:3))?{ok:!0,header:n}:{ok:!1,reason:`invalid_png`,header:n}},z_=e=>{let t=k_.PNG.sync.read(Buffer.from(e.buffer,e.byteOffset,e.byteLength),{checkCRC:!0});return{width:t.width,height:t.height,data:new Uint8Array(t.data)}},B_=e=>{let t=new k_.PNG({width:e.width,height:e.height});return t.data=Buffer.from(e.data),new Uint8Array(k_.PNG.sync.write(t,{colorType:6,inputHasAlpha:!0}))},V_=(e,t)=>{let n=t.right-t.left,r=t.bottom-t.top,i=new Uint8Array(n*r*4);for(let a=0;a<r;a++){let r=((t.top+a)*e.width+t.left)*4;i.set(e.data.subarray(r,r+n*4),a*n*4)}return{width:n,height:r,data:i}},H_=(e,t)=>{let n=new Set;for(let r=0;r<e.data.length&&(n.add(((e.data[r]??0)<<24)+((e.data[r+1]??0)<<16)+((e.data[r+2]??0)<<8)+(e.data[r+3]??0)),!(n.size>=t));r+=4);return n.size},U_=e=>{if(!(e instanceof Error))return{name:void 0,code:void 0,errno:void 0};let t=`code`in e&&typeof e.code==`string`?e.code:void 0,n=`errno`in e&&typeof e.errno==`number`?e.errno:void 0;return{name:e.name,code:t,errno:n}};var W_=class extends Error{reason;subject;errorType;errno;constructor(e,t,n){super(e),this.reason=e,this.subject=t;let r=U_(n);this.errorType=n===void 0?void 0:r.code??r.name,this.errno=r.errno}};const G_=e=>u(`sha256`).update(e).digest(`hex`),K_=async(e,t,n)=>{n.path=e;let r;try{if(!(await _(e)).isFile())throw new W_(`missing_or_non_file`,t);r=await h(e)}catch(e){if(e instanceof W_)throw e;let{code:n}=U_(e);throw n===`ENOENT`||n===`ENOTDIR`?new W_(`missing_or_non_file`,t,e):new W_(`unreadable_file`,t,e)}n.file_bytes=r.length,n.file_sha256=G_(r);let i=R_(r);if(i.header!==void 0||i.ok){let e=(i.ok,i.header);e!==void 0&&(n.width=e.width,n.height=e.height,n.mode=e.mode,n.bit_depth=e.bitDepth)}if(!i.ok)throw new W_(i.reason,t);let a;try{a=z_(r)}catch{throw new W_(`invalid_png`,t)}return n.rgba_sha256=G_(a.data),a},q_=(e,t,n,r,i)=>{let[a=0,o=0,s=0,c=0]=t;if(!(a>=0&&a<s&&o>=0&&o<c))throw new W_(`invalid_content_box`);if(s>r||c>i)throw new W_(`content_box_out_of_bounds`);if(n.some(e=>e<0))throw new W_(`invalid_min_margins`);let[l=0,u=0,d=0,f=0]=e,p={top:n[0]??0,right:n[1]??0,bottom:n[2]??0,left:n[3]??0},m={top:o-u,right:d-s,bottom:f-c,left:a-l};return{source:`caller_supplied`,box:[...t],minimum_margins:p,observed_margins:m,content_contained:Object.values(m).every(e=>e>=0),margins_satisfied:m.top>=p.top&&m.right>=p.right&&m.bottom>=p.bottom&&m.left>=p.left}},J_={"--raw":{arity:1,required:!0},"--crop":{arity:1,required:!0},"--box":{arity:4,required:!0},"--content-box":{arity:4},"--min-margins":{arity:4}},Y_=e=>{if(e===void 0)return;let t=e.map(n_);if(t.some(e=>e===void 0))throw new W_(`invalid_arguments`);return t.filter(e=>e!==void 0)},X_=e=>sl(async()=>{let t={status:`uncheckable`,reason:null,box:null,comparison_mode:`RGBA8`,decoder:`pngjs@7.0.0`,raw:{},crop:{},expected:{},dimensions_equal:null,pixels_equal:null},n={},r={};t.raw=n,t.crop=r;try{let i=e_(e,J_);if(!i.ok)throw new W_(`invalid_arguments`);let a=Y_(i.values[`--box`])??[],o=Y_(i.values[`--content-box`]),s=Y_(i.values[`--min-margins`]);if(t.box=[...a],o===void 0!=(s===void 0))throw new W_(`incomplete_content_bounds_arguments`);let[c=0,l=0,u=0,d=0]=a;if(!(c>=0&&c<u&&l>=0&&l<d))throw new W_(`invalid_box`);let f=await K_(i.values[`--raw`]?.[0]??``,`raw`,n);if(u>f.width||d>f.height)throw new W_(`box_out_of_bounds`);let p;o!==void 0&&s!==void 0&&(p=q_(a,o,s,f.width,f.height),t.content_bounds=p);let m=await K_(i.values[`--crop`]?.[0]??``,`crop`,r),h=V_(f,{left:c,top:l,right:u,bottom:d});t.expected={width:h.width,height:h.height,rgba_sha256:G_(h.data)};let g=m.width===h.width&&m.height===h.height;if(t.dimensions_equal=g,!g)return{report:{...t,status:`mismatch`,reason:`dimensions_differ`},exitCode:1};let _=Buffer.compare(Buffer.from(m.data),Buffer.from(h.data))===0;return t.pixels_equal=_,_?p!==void 0&&p.content_contained!==!0?{report:{...t,status:`mismatch`,reason:`content_cut`},exitCode:1}:p!==void 0&&p.margins_satisfied!==!0?{report:{...t,status:`mismatch`,reason:`content_margins_insufficient`},exitCode:1}:{report:{...t,status:`exact`,reason:`pixels_equal`},exitCode:0}:{report:{...t,status:`mismatch`,reason:`pixels_differ`},exitCode:1}}catch(e){if(!(e instanceof W_))throw e;let n={...t,reason:e.reason};return e.subject!==void 0&&(n.subject=e.subject),e.errorType!==void 0&&(n.error_type=e.errorType),e.errno!==void 0&&(n.errno=e.errno),{report:n,exitCode:2}}}),Z_=e=>JSON.stringify(Q_(e)),Q_=e=>{if(Array.isArray(e))return e.map(Q_);if(typeof e==`object`&&e){let t=Object.entries(e).toSorted(([e],[t])=>e<t?-1:1);return Object.fromEntries(t.map(([e,t])=>[e,Q_(t)]))}return e},$_=e=>u(`sha256`).update(e).digest(`hex`),ev=e=>O(function*(){let t=yield*sl(async()=>{try{return(await p(i(e))).isDirectory()}catch{return!1}});if(!a(e)||!e.toLowerCase().endsWith(`.png`)||!t||(yield*vh(e))||(yield*vh(`${e}.json`)))return yield*j(`capture requires a fresh absolute .png path with an existing parent`)}),tv=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height&&e.viewable===t.viewable,nv=e=>O(function*(){if(yield*ev(e.output),e.window!==void 0&&(yield*ev(e.window.output),e.window.output===e.output))return yield*j(`window output must differ from the raw output`);let t=yield*Im,{session:n,observation:r,deadline:i}=yield*Og(e.stateDir,e.timeout),a=(t,r)=>O(function*(){let a=yield*Lg(e.stateDir,n,t,r,i);if(a.length>0)return yield*j(`window is covered by ${a.join(`, `)}`)}),s=e.window===void 0?void 0:yield*Ng(e.stateDir,n,e.window.id,i);e.window!==void 0&&s!==void 0&&(yield*a(e.window.id,s));let c=o(n.guest_dir,`captures`,`${d()}.png`),l=yield*Th,u=yield*Eh,f=yield*Fl(O(function*(){return yield*sg(e.stateDir,n,`scrot`,[c],i,gg(n),e.timeout).pipe(Cl(`Unavailable`,e=>k(new ah({reason:e.reason.replace(/^scrot read/u,`scrot`),...e.nativeExit===void 0?{}:{nativeExit:e.nativeExit}})))),yield*t.readFile(c,yield*Oh(i,e.timeout)).pipe(Tl(e=>new ah({reason:`capture could not be read back: ${e.message}`})))}),rh(c,n.probe_timeout_s*1e3).pipe(Dl)),p=R_(f);if(!p.ok&&p.reason===`invalid_png`)return yield*j(`scrot did not produce a PNG screen capture`);let m=(p.ok,p.header);if(m===void 0||m.width!==r.dimensions[0]||m.height!==r.dimensions[1])return yield*j(`raw capture dimensions differ from the inspected display`);let h=yield*Og(e.stateDir,Math.max(.001,(i.endMs-(yield*Eh))/1e3));if(h.session.run_id!==n.run_id||JSON.stringify(h.observation)!==JSON.stringify(r))return yield*j(`session or window manager changed during capture`);let g;if(e.window!==void 0&&s!==void 0){if(g=yield*Ng(e.stateDir,n,e.window.id,i),!tv(s,g))return yield*j(`window moved or changed during capture`);yield*a(e.window.id,g)}let _={run_id:n.run_id,output:e.output,bytes:f.length,sha256:$_(f),dimensions:[m.width,m.height],capture_started_at:l,capture_completed_at:yield*Th,capture_ms:(yield*Eh)-u,window_manager:h.observation.window_manager??null,transformations:[]},v=g===void 0?void 0:{left:g.x,top:g.y,right:g.x+g.width,bottom:g.y+g.height};if(g!==void 0&&v!==void 0){if(!g.viewable)return yield*j(`window is not viewable`);if(v.left<0||v.top<0||v.right>m.width||v.bottom>m.height||v.left>=v.right||v.top>=v.bottom)return yield*j(`window is not entirely on the screen`);if(!p.ok)return yield*j(`raw capture is not an 8-bit RGB or RGBA PNG: ${p.reason}`)}if(yield*xh(e.output,f),yield*Sh(`${e.output}.json`,_),e.window===void 0||v===void 0||!p.ok)return _;let y=V_(z_(f),v),ee=B_(y);yield*xh(e.window.output,ee);let b=yield*X_([`--raw`,e.output,`--crop`,e.window.output,`--box`,String(v.left),String(v.top),String(v.right),String(v.bottom)]),te={run_id:n.run_id,window:e.window.id,raw:e.output,output:e.window.output,box:[v.left,v.top,v.right,v.bottom],bytes:ee.length,sha256:$_(ee),distinct_colors:H_(y,4096),exact_crop:b.report};return yield*Sh(`${e.window.output}.json`,te),b.exitCode===0?{..._,window:te}:yield*j(`window crop did not verify as an exact crop of the raw capture`)}),rv=/\{[^{}]+\}/g,iv=()=>typeof process==`object`&&Number.parseInt(process?.versions?.node?.substring(0,2))>=18&&process.versions.undici;function av(){return Math.random().toString(36).slice(2,11)}function ov(e){let{baseUrl:t=``,Request:n=globalThis.Request,fetch:r=globalThis.fetch,querySerializer:i,bodySerializer:a,pathSerializer:o,headers:s,requestInitExt:c=void 0,...l}={...e};c=iv()?c:void 0,t=hv(t);let u=[];async function d(e,d){let{baseUrl:f,fetch:p=r,Request:m=n,headers:h,params:g={},parseAs:_=`json`,querySerializer:v,bodySerializer:y=a??fv,pathSerializer:ee,body:b,middleware:te=[],...ne}=d||{},re=t;f&&(re=hv(f)??t);let ie=typeof i==`function`?i:uv(i);v&&(ie=typeof v==`function`?v:uv({...typeof i==`object`?i:{},...v}));let ae=ee||o||dv,oe=b===void 0?void 0:y(b,mv(s,h,g.header)),se=mv(oe===void 0||oe instanceof FormData?{}:{"Content-Type":`application/json`},s,h,g.header),ce=[...u,...te],x={redirect:`follow`,...l,...ne,body:oe,headers:se},le,S,ue=new m(pv(e,{baseUrl:re,params:g,querySerializer:ie,pathSerializer:ae}),x),de;for(let e in ne)e in ue||(ue[e]=ne[e]);if(ce.length){le=av(),S=Object.freeze({baseUrl:re,fetch:p,parseAs:_,querySerializer:ie,bodySerializer:y,pathSerializer:ae});for(let t of ce)if(t&&typeof t==`object`&&typeof t.onRequest==`function`){let n=await t.onRequest({request:ue,schemaPath:e,params:g,options:S,id:le});if(n){if(n instanceof m)ue=n;else if(n instanceof Response){de=n;break}else throw Error(`onRequest: must return new Request() or Response() when modifying the request`)}}}if(!de){try{de=await p(ue,c)}catch(t){let n=t;if(ce.length)for(let t=ce.length-1;t>=0;t--){let r=ce[t];if(r&&typeof r==`object`&&typeof r.onError==`function`){let t=await r.onError({request:ue,error:n,schemaPath:e,params:g,options:S,id:le});if(t){if(t instanceof Response){n=void 0,de=t;break}if(t instanceof Error){n=t;continue}throw Error(`onError: must return new Response() or instance of Error`)}}}if(n)throw n}if(ce.length)for(let t=ce.length-1;t>=0;t--){let n=ce[t];if(n&&typeof n==`object`&&typeof n.onResponse==`function`){let t=await n.onResponse({request:ue,response:de,schemaPath:e,params:g,options:S,id:le});if(t){if(!(t instanceof Response))throw Error(`onResponse: must return new Response() when modifying the response`);de=t}}}}let C=de.headers.get(`Content-Length`);if(de.status===204||ue.method===`HEAD`||C===`0`&&!de.headers.get(`Transfer-Encoding`)?.includes(`chunked`))return de.ok?{data:void 0,response:de}:{error:void 0,response:de};if(de.ok)return{data:await(async()=>{if(_===`stream`)return de.body;if(_===`json`&&!C){let e=await de.text();return e?JSON.parse(e):void 0}return await de[_]()})(),response:de};let fe=await de.text();try{fe=JSON.parse(fe)}catch{}return{error:fe,response:de}}return{request(e,t,n){return d(t,{...n,method:e.toUpperCase()})},GET(e,t){return d(e,{...t,method:`GET`})},PUT(e,t){return d(e,{...t,method:`PUT`})},POST(e,t){return d(e,{...t,method:`POST`})},DELETE(e,t){return d(e,{...t,method:`DELETE`})},OPTIONS(e,t){return d(e,{...t,method:`OPTIONS`})},HEAD(e,t){return d(e,{...t,method:`HEAD`})},PATCH(e,t){return d(e,{...t,method:`PATCH`})},TRACE(e,t){return d(e,{...t,method:`TRACE`})},use(...e){for(let t of e)if(t){if(typeof t!=`object`||!(`onRequest`in t||`onResponse`in t||`onError`in t))throw Error("Middleware must be an object with one of `onRequest()`, `onResponse() or `onError()`");u.push(t)}},eject(...e){for(let t of e){let e=u.indexOf(t);e!==-1&&u.splice(e,1)}}}}function sv(e,t,n){if(t==null)return``;if(typeof t==`object`)throw Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${e}=${n?.allowReserved===!0?t:encodeURIComponent(t)}`}function cv(e,t,n){if(!t||typeof t!=`object`)return``;let r=[],i={simple:`,`,label:`.`,matrix:`;`}[n.style]||`&`;if(n.style!==`deepObject`&&n.explode===!1){for(let e in t)r.push(e,n.allowReserved===!0?t[e]:encodeURIComponent(t[e]));let i=r.join(`,`);switch(n.style){case`form`:return`${e}=${i}`;case`label`:return`.${i}`;case`matrix`:return`;${e}=${i}`;default:return i}}for(let i in t){let a=n.style===`deepObject`?`${e}[${i}]`:i;r.push(sv(a,t[i],n))}let a=r.join(i);return n.style===`label`||n.style===`matrix`?`${i}${a}`:a}function lv(e,t,n){if(!Array.isArray(t))return``;if(n.explode===!1){let r={form:`,`,spaceDelimited:`%20`,pipeDelimited:`|`}[n.style]||`,`,i=(n.allowReserved===!0?t:t.map(e=>encodeURIComponent(e))).join(r);switch(n.style){case`simple`:return i;case`label`:return`.${i}`;case`matrix`:return`;${e}=${i}`;default:return`${e}=${i}`}}let r={simple:`,`,label:`.`,matrix:`;`}[n.style]||`&`,i=[];for(let r of t)n.style===`simple`||n.style===`label`?i.push(n.allowReserved===!0?r:encodeURIComponent(r)):i.push(sv(e,r,n));return n.style===`label`||n.style===`matrix`?`${r}${i.join(r)}`:i.join(r)}function uv(e){return function(t){let n=[];if(t&&typeof t==`object`)for(let r in t){let i=t[r];if(i!=null){if(Array.isArray(i)){if(i.length===0)continue;n.push(lv(r,i,{style:`form`,explode:!0,...e?.array,allowReserved:e?.allowReserved||!1}));continue}if(typeof i==`object`){n.push(cv(r,i,{style:`deepObject`,explode:!0,...e?.object,allowReserved:e?.allowReserved||!1}));continue}n.push(sv(r,i,e))}}return n.join(`&`)}}function dv(e,t){let n=e;for(let r of e.match(rv)??[]){let e=r.substring(1,r.length-1),i=!1,a=`simple`;if(e.endsWith(`*`)&&(i=!0,e=e.substring(0,e.length-1)),e.startsWith(`.`)?(a=`label`,e=e.substring(1)):e.startsWith(`;`)&&(a=`matrix`,e=e.substring(1)),!t||t[e]===void 0||t[e]===null)continue;let o=t[e];if(Array.isArray(o)){n=n.replace(r,lv(e,o,{style:a,explode:i}));continue}if(typeof o==`object`){n=n.replace(r,cv(e,o,{style:a,explode:i}));continue}if(a===`matrix`){n=n.replace(r,`;${sv(e,o)}`);continue}n=n.replace(r,a===`label`?`.${encodeURIComponent(o)}`:encodeURIComponent(o))}return n}function fv(e,t){return e instanceof FormData?e:t&&(t.get instanceof Function?t.get(`Content-Type`)??t.get(`content-type`):t[`Content-Type`]??t[`content-type`])===`application/x-www-form-urlencoded`?new URLSearchParams(e).toString():JSON.stringify(e)}function pv(e,t){let n=`${t.baseUrl}${e}`;t.params?.path&&(n=t.pathSerializer(n,t.params.path));let r=t.querySerializer(t.params.query??{});return r.startsWith(`?`)&&(r=r.substring(1)),r&&(n+=`?${r}`),n}function mv(...e){let t=new Headers;for(let n of e){if(!n||typeof n!=`object`)continue;let e=n instanceof Headers?n.entries():Object.entries(n);for(let[n,r]of e)if(r===null)t.delete(n);else if(Array.isArray(r))for(let e of r)t.append(n,e);else r!==void 0&&t.set(n,r)}return t}function hv(e){return e.endsWith(`/`)?e.substring(0,e.length-1):e}var gv=Fe(((e,t)=>{(function(){var n={function:!0,object:!0},r=n[typeof window]&&window||this,i=n[typeof e]&&e,a=n[typeof t]&&t&&!t.nodeType&&t,o=i&&a&&typeof global==`object`&&global;o&&(o.global===o||o.window===o||o.self===o)&&(r=o);var s=2**53-1,c=/\bOpera/,l=Object.prototype,u=l.hasOwnProperty,d=l.toString;function f(e){return e=String(e),e.charAt(0).toUpperCase()+e.slice(1)}function p(e,t,n){var r={"10.0":`10`,"6.4":`10 Technical Preview`,"6.3":`8.1`,"6.2":`8`,"6.1":`Server 2008 R2 / 7`,"6.0":`Server 2008 / Vista`,"5.2":`Server 2003 / XP 64-bit`,"5.1":`XP`,"5.01":`2000 SP1`,"5.0":`2000`,"4.0":`NT`,"4.90":`ME`};return t&&n&&/^Win/i.test(e)&&!/^Windows Phone /i.test(e)&&(r=r[/[\d.]+$/.exec(e)])&&(e=`Windows `+r),e=String(e),t&&n&&(e=e.replace(RegExp(t,`i`),n)),e=h(e.replace(/ ce$/i,` CE`).replace(/\bhpw/i,`web`).replace(/\bMacintosh\b/,`Mac OS`).replace(/_PowerPC\b/i,` OS`).replace(/\b(OS X) [^ \d]+/i,`$1`).replace(/\bMac (OS X)\b/,`$1`).replace(/\/(\d)/,` $1`).replace(/_/g,`.`).replace(/(?: BePC|[ .]*fc[ \d.]+)$/i,``).replace(/\bx86\.64\b/gi,`x86_64`).replace(/\b(Windows Phone) OS\b/,`$1`).replace(/\b(Chrome OS \w+) [\d.]+\b/,`$1`).split(` on `)[0]),e}function m(e,t){var n=-1,r=e?e.length:0;if(typeof r==`number`&&r>-1&&r<=s)for(;++n<r;)t(e[n],n,e);else g(e,t)}function h(e){return e=b(e),/^(?:webOS|i(?:OS|P))/.test(e)?e:f(e)}function g(e,t){for(var n in e)u.call(e,n)&&t(e[n],n,e)}function _(e){return e==null?f(e):d.call(e).slice(8,-1)}function v(e,t){var n=e==null?`number`:typeof e[t];return!/^(?:boolean|number|string|undefined)$/.test(n)&&(n!=`object`||!!e[t])}function y(e){return String(e).replace(/([ -])(?!$)/g,`$1?`)}function ee(e,t){var n=null;return m(e,function(r,i){n=t(n,r,i,e)}),n}function b(e){return String(e).replace(/^ +| +$/g,``)}function te(e){var t=r,n=e&&typeof e==`object`&&_(e)!=`String`;n&&(t=e,e=null);var i=t.navigator||{},a=i.userAgent||``;e||=a;var o=n?!!i.likeChrome:/\bChrome\b/.test(e)&&!/internal|\n/i.test(d.toString()),s=`Object`,l=n?s:`ScriptBridgingProxyObject`,u=n?s:`Environment`,f=n&&t.java?`JavaPackage`:_(t.java),m=n?s:`RuntimeObject`,ne=/\bJava/.test(f)&&t.java,re=ne&&_(t.environment)==u,ie=ne?`a`:`α`,ae=ne?`b`:`β`,oe=t.document||{},se=t.operamini||t.opera,ce=c.test(ce=n&&se?se[`[[Class]]`]:_(se))?ce:se=null,x,le=e,S=[],ue=null,de=e==a,C=de&&se&&typeof se.version==`function`&&se.version(),fe,pe=ge([{label:`EdgeHTML`,pattern:`Edge`},`Trident`,{label:`WebKit`,pattern:`AppleWebKit`},`iCab`,`Presto`,`NetFront`,`Tasman`,`KHTML`,`Gecko`]),w=ve([`Adobe AIR`,`Arora`,`Avant Browser`,`Breach`,`Camino`,`Electron`,`Epiphany`,`Fennec`,`Flock`,`Galeon`,`GreenBrowser`,`iCab`,`Iceweasel`,`K-Meleon`,`Konqueror`,`Lunascape`,`Maxthon`,{label:`Microsoft Edge`,pattern:`(?:Edge|Edg|EdgA|EdgiOS)`},`Midori`,`Nook Browser`,`PaleMoon`,`PhantomJS`,`Raven`,`Rekonq`,`RockMelt`,{label:`Samsung Internet`,pattern:`SamsungBrowser`},`SeaMonkey`,{label:`Silk`,pattern:`(?:Cloud9|Silk-Accelerated)`},`Sleipnir`,`SlimBrowser`,{label:`SRWare Iron`,pattern:`Iron`},`Sunrise`,`Swiftfox`,`Vivaldi`,`Waterfox`,`WebPositive`,{label:`Yandex Browser`,pattern:`YaBrowser`},{label:`UC Browser`,pattern:`UCBrowser`},`Opera Mini`,{label:`Opera Mini`,pattern:`OPiOS`},`Opera`,{label:`Opera`,pattern:`OPR`},`Chromium`,`Chrome`,{label:`Chrome`,pattern:`(?:HeadlessChrome)`},{label:`Chrome Mobile`,pattern:`(?:CriOS|CrMo)`},{label:`Firefox`,pattern:`(?:Firefox|Minefield)`},{label:`Firefox for iOS`,pattern:`FxiOS`},{label:`IE`,pattern:`IEMobile`},{label:`IE`,pattern:`MSIE`},`Safari`]),me=be([{label:`BlackBerry`,pattern:`BB10`},`BlackBerry`,{label:`Galaxy S`,pattern:`GT-I9000`},{label:`Galaxy S2`,pattern:`GT-I9100`},{label:`Galaxy S3`,pattern:`GT-I9300`},{label:`Galaxy S4`,pattern:`GT-I9500`},{label:`Galaxy S5`,pattern:`SM-G900`},{label:`Galaxy S6`,pattern:`SM-G920`},{label:`Galaxy S6 Edge`,pattern:`SM-G925`},{label:`Galaxy S7`,pattern:`SM-G930`},{label:`Galaxy S7 Edge`,pattern:`SM-G935`},`Google TV`,`Lumia`,`iPad`,`iPod`,`iPhone`,`Kindle`,{label:`Kindle Fire`,pattern:`(?:Cloud9|Silk-Accelerated)`},`Nexus`,`Nook`,`PlayBook`,`PlayStation Vita`,`PlayStation`,`TouchPad`,`Transformer`,{label:`Wii U`,pattern:`WiiU`},`Wii`,`Xbox One`,{label:`Xbox 360`,pattern:`Xbox`},`Xoom`]),he=_e({Apple:{iPad:1,iPhone:1,iPod:1},Alcatel:{},Archos:{},Amazon:{Kindle:1,"Kindle Fire":1},Asus:{Transformer:1},"Barnes & Noble":{Nook:1},BlackBerry:{PlayBook:1},Google:{"Google TV":1,Nexus:1},HP:{TouchPad:1},HTC:{},Huawei:{},Lenovo:{},LG:{},Microsoft:{Xbox:1,"Xbox One":1},Motorola:{Xoom:1},Nintendo:{"Wii U":1,Wii:1},Nokia:{Lumia:1},Oppo:{},Samsung:{"Galaxy S":1,"Galaxy S2":1,"Galaxy S3":1,"Galaxy S4":1},Sony:{PlayStation:1,"PlayStation Vita":1},Xiaomi:{Mi:1,Redmi:1}}),T=ye([`Windows Phone`,`KaiOS`,`Android`,`CentOS`,{label:`Chrome OS`,pattern:`CrOS`},`Debian`,{label:`DragonFly BSD`,pattern:`DragonFly`},`Fedora`,`FreeBSD`,`Gentoo`,`Haiku`,`Kubuntu`,`Linux Mint`,`OpenBSD`,`Red Hat`,`SuSE`,`Ubuntu`,`Xubuntu`,`Cygwin`,`Symbian OS`,`hpwOS`,`webOS `,`webOS`,`Tablet OS`,`Tizen`,`Linux`,`Mac OS X`,`Macintosh`,`Mac`,`Windows 98;`,`Windows `]);function ge(t){return ee(t,function(t,n){return t||RegExp(`\\b`+(n.pattern||y(n))+`\\b`,`i`).exec(e)&&(n.label||n)})}function _e(t){return ee(t,function(t,n,r){return t||(n[me]||n[/^[a-z]+(?: +[a-z]+\b)*/i.exec(me)]||RegExp(`\\b`+y(r)+`(?:\\b|\\w*\\d)`,`i`).exec(e))&&r})}function ve(t){return ee(t,function(t,n){return t||RegExp(`\\b`+(n.pattern||y(n))+`\\b`,`i`).exec(e)&&(n.label||n)})}function ye(t){return ee(t,function(t,n){var r=n.pattern||y(n);return!t&&(t=RegExp(`\\b`+r+`(?:/[\\d.]+|[ \\w.]*)`,`i`).exec(e))&&(t=p(t,r,n.label||n)),t})}function be(t){return ee(t,function(t,n){var r=n.pattern||y(n);return!t&&(t=RegExp(`\\b`+r+` *\\d+[.\\w_]*`,`i`).exec(e)||RegExp(`\\b`+r+` *\\w+-[\\w]*`,`i`).exec(e)||RegExp(`\\b`+r+`(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)`,`i`).exec(e))&&((t=String(n.label&&!RegExp(r,`i`).test(n.label)?n.label:t).split(`/`))[1]&&!/[\d.]+/.test(t[0])&&(t[0]+=` `+t[1]),n=n.label||n,t=h(t[0].replace(RegExp(r,`i`),n).replace(RegExp(`; *(?:`+n+`[_-])?`,`i`),` `).replace(RegExp(`(`+n+`)[-_.]?(\\w)`,`i`),`$1 $2`))),t})}function xe(t){return ee(t,function(t,n){return t||(RegExp(n+`(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)`,`i`).exec(e)||0)[1]||null})}function Se(){return this.description||``}if(pe&&=[pe],/\bAndroid\b/.test(T)&&!me&&(x=/\bAndroid[^;]*;(.*?)(?:Build|\) AppleWebKit)\b/i.exec(e))&&(me=b(x[1]).replace(/^[a-z]{2}-[a-z]{2};\s*/i,``)||null),he&&!me?me=be([he]):he&&me&&(me=me.replace(RegExp(`^(`+y(he)+`)[-_.\\s]`,`i`),he+` `).replace(RegExp(`^(`+y(he)+`)[-_.]?(\\w)`,`i`),he+` $2`)),(x=/\bGoogle TV\b/.exec(me))&&(me=x[0]),/\bSimulator\b/i.test(e)&&(me=(me?me+` `:``)+`Simulator`),w==`Opera Mini`&&/\bOPiOS\b/.test(e)&&S.push(`running in Turbo/Uncompressed mode`),w==`IE`&&/\blike iPhone OS\b/.test(e)?(x=te(e.replace(/like iPhone OS/,``)),he=x.manufacturer,me=x.product):/^iP/.test(me)?(w||=`Safari`,T=`iOS`+((x=/ OS ([\d_]+)/i.exec(e))?` `+x[1].replace(/_/g,`.`):``)):w==`Konqueror`&&/^Linux\b/i.test(T)?T=`Kubuntu`:he&&he!=`Google`&&(/Chrome/.test(w)&&!/\bMobile Safari\b/i.test(e)||/\bVita\b/.test(me))||/\bAndroid\b/.test(T)&&/^Chrome/.test(w)&&/\bVersion\//i.test(e)?(w=`Android Browser`,T=/\bAndroid\b/.test(T)?T:`Android`):w==`Silk`?(/\bMobi/i.test(e)||(T=`Android`,S.unshift(`desktop mode`)),/Accelerated *= *true/i.test(e)&&S.unshift(`accelerated`)):w==`UC Browser`&&/\bUCWEB\b/.test(e)?S.push(`speed mode`):w==`PaleMoon`&&(x=/\bFirefox\/([\d.]+)\b/.exec(e))?S.push(`identifying as Firefox `+x[1]):w==`Firefox`&&(x=/\b(Mobile|Tablet|TV)\b/i.exec(e))?(T||=`Firefox OS`,me||=x[1]):!w||(x=!/\bMinefield\b/i.test(e)&&/\b(?:Firefox|Safari)\b/.exec(w))?(w&&!me&&/[\/,]|^[^(]+?\)/.test(e.slice(e.indexOf(x+`/`)+8))&&(w=null),(x=me||he||T)&&(me||he||/\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(T))&&(w=/[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(T)?T:x)+` Browser`)):w==`Electron`&&(x=(/\bChrome\/([\d.]+)\b/.exec(e)||0)[1])&&S.push(`Chromium `+x),C||=xe([`(?:Cloud9|CriOS|CrMo|Edge|Edg|EdgA|EdgiOS|FxiOS|HeadlessChrome|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$)|UCBrowser|YaBrowser)`,`Version`,y(w),`(?:Firefox|Minefield|NetFront)`]),(x=pe==`iCab`&&parseFloat(C)>3&&`WebKit`||/\bOpera\b/.test(w)&&(/\bOPR\b/.test(e)?`Blink`:`Presto`)||/\b(?:Midori|Nook|Safari)\b/i.test(e)&&!/^(?:Trident|EdgeHTML)$/.test(pe)&&`WebKit`||!pe&&/\bMSIE\b/i.test(e)&&(T==`Mac OS`?`Tasman`:`Trident`)||pe==`WebKit`&&/\bPlayStation\b(?! Vita\b)/i.test(w)&&`NetFront`)&&(pe=[x]),w==`IE`&&(x=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(e)||0)[1])?(w+=` Mobile`,T=`Windows Phone `+(/\+$/.test(x)?x:x+`.x`),S.unshift(`desktop mode`)):/\bWPDesktop\b/i.test(e)?(w=`IE Mobile`,T=`Windows Phone 8.x`,S.unshift(`desktop mode`),C||=(/\brv:([\d.]+)/.exec(e)||0)[1]):w!=`IE`&&pe==`Trident`&&(x=/\brv:([\d.]+)/.exec(e))&&(w&&S.push(`identifying as `+w+(C?` `+C:``)),w=`IE`,C=x[1]),de){if(v(t,`global`)){if(ne&&(x=ne.lang.System,le=x.getProperty(`os.arch`),T||=x.getProperty(`os.name`)+` `+x.getProperty(`os.version`)),re){try{C=(()=>{throw Error(`impulse-compute loads no package at run time`)})().version.join(`.`),w=`RingoJS`}catch{(x=t.system)&&x.global.system==t.system&&(w=`Narwhal`,T||=x[0].os||null)}w||=`Rhino`}else typeof t.process==`object`&&!t.process.browser&&(x=t.process)&&(typeof x.versions==`object`&&(typeof x.versions.electron==`string`?(S.push(`Node `+x.versions.node),w=`Electron`,C=x.versions.electron):typeof x.versions.nw==`string`&&(S.push(`Chromium `+C,`Node `+x.versions.node),w=`NW.js`,C=x.versions.nw)),w||(w=`Node.js`,le=x.arch,T=x.platform,C=/[\d.]+/.exec(x.version),C=C?C[0]:null))}else _(x=t.runtime)==l?(w=`Adobe AIR`,T=x.flash.system.Capabilities.os):_(x=t.phantom)==m?(w=`PhantomJS`,C=(x=x.version||null)&&x.major+`.`+x.minor+`.`+x.patch):typeof oe.documentMode==`number`&&(x=/\bTrident\/(\d+)/i.exec(e))?(C=[C,oe.documentMode],(x=+x[1]+4)!=C[1]&&(S.push(`IE `+C[1]+` mode`),pe&&(pe[1]=``),C[1]=x),C=w==`IE`?String(C[1].toFixed(1)):C[0]):typeof oe.documentMode==`number`&&/^(?:Chrome|Firefox)\b/.test(w)&&(S.push(`masking as `+w+` `+C),w=`IE`,C=`11.0`,pe=[`Trident`],T=`Windows`);T&&=h(T)}if(C&&(x=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(C)||/(?:alpha|beta)(?: ?\d)?/i.exec(e+`;`+(de&&i.appMinorVersion))||/\bMinefield\b/i.test(e)&&`a`)&&(ue=/b/i.test(x)?`beta`:`alpha`,C=C.replace(RegExp(x+`\\+?$`),``)+(ue==`beta`?ae:ie)+(/\d+\+?/.exec(x)||``)),w==`Fennec`||w==`Firefox`&&/\b(?:Android|Firefox OS|KaiOS)\b/.test(T))w=`Firefox Mobile`;else if(w==`Maxthon`&&C)C=C.replace(/\.[\d.]+/,`.x`);else if(/\bXbox\b/i.test(me))me==`Xbox 360`&&(T=null),me==`Xbox 360`&&/\bIEMobile\b/.test(e)&&S.unshift(`mobile mode`);else if((/^(?:Chrome|IE|Opera)$/.test(w)||w&&!me&&!/Browser|Mobi/.test(w))&&(T==`Windows CE`||/Mobi/i.test(e)))w+=` Mobile`;else if(w==`IE`&&de)try{t.external===null&&S.unshift(`platform preview`)}catch{S.unshift(`embedded`)}else(/\bBlackBerry\b/.test(me)||/\bBB10\b/.test(e))&&(x=(RegExp(me.replace(/ +/g,` *`)+`/([.\\d]+)`,`i`).exec(e)||0)[1]||C)?(x=[x,/BB10/.test(e)],T=(x[1]?(me=null,he=`BlackBerry`):`Device Software`)+` `+x[0],C=null):this!=g&&me!=`Wii`&&(de&&se||/Opera/.test(w)&&/\b(?:MSIE|Firefox)\b/i.test(e)||w==`Firefox`&&/\bOS X (?:\d+\.){2,}/.test(T)||w==`IE`&&(T&&!/^Win/.test(T)&&C>5.5||/\bWindows XP\b/.test(T)&&C>8||C==8&&!/\bTrident\b/.test(e)))&&!c.test(x=te.call(g,e.replace(c,``)+`;`))&&x.name&&(x=`ing as `+x.name+((x=x.version)?` `+x:``),c.test(w)?(/\bIE\b/.test(x)&&T==`Mac OS`&&(T=null),x=`identify`+x):(x=`mask`+x,w=ce?h(ce.replace(/([a-z])([A-Z])/g,`$1 $2`)):`Opera`,/\bIE\b/.test(x)&&(T=null),de||(C=null)),pe=[`Presto`],S.push(x));(x=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(e)||0)[1])&&(x=[parseFloat(x.replace(/\.(\d)$/,`.0$1`)),x],w==`Safari`&&x[1].slice(-1)==`+`?(w=`WebKit Nightly`,ue=`alpha`,C=x[1].slice(0,-1)):(C==x[1]||C==(x[2]=(/\bSafari\/([\d.]+\+?)/i.exec(e)||0)[1]))&&(C=null),x[1]=(/\b(?:Headless)?Chrome\/([\d.]+)/i.exec(e)||0)[1],x[0]==537.36&&x[2]==537.36&&parseFloat(x[1])>=28&&pe==`WebKit`&&(pe=[`Blink`]),!de||!o&&!x[1]?(pe&&(pe[1]=`like Safari`),x=(x=x[0],x<400?1:x<500?2:x<526?3:x<533?4:x<534?`4+`:x<535?5:x<537?6:x<538?7:x<601?8:x<602?9:x<604?10:x<606?11:x<608?12:`12`)):(pe&&(pe[1]=`like Chrome`),x=x[1]||(x=x[0],x<530?1:x<532?2:x<532.05?3:x<533?4:x<534.03?5:x<534.07?6:x<534.1?7:x<534.13?8:x<534.16?9:x<534.24?10:x<534.3?11:x<535.01?12:x<535.02?`13+`:x<535.07?15:x<535.11?16:x<535.19?17:x<536.05?18:x<536.1?19:x<537.01?20:x<537.11?`21+`:x<537.13?23:x<537.18?24:x<537.24?25:x<537.36?26:pe==`Blink`?`28`:`27`)),pe&&(pe[1]+=` `+(x+=typeof x==`number`?`.x`:/[.+]/.test(x)?``:`+`)),w==`Safari`&&(!C||parseInt(C)>45)?C=x:w==`Chrome`&&/\bHeadlessChrome/i.test(e)&&S.unshift(`headless`)),w==`Opera`&&(x=/\bzbov|zvav$/.exec(T))?(w+=` `,S.unshift(`desktop mode`),x==`zvav`?(w+=`Mini`,C=null):w+=`Mobile`,T=T.replace(RegExp(` *`+x+`$`),``)):w==`Safari`&&/\bChrome\b/.exec(pe&&pe[1])?(S.unshift(`desktop mode`),w=`Chrome Mobile`,C=null,/\bOS X\b/.test(T)?(he=`Apple`,T=`iOS 4.3+`):T=null):/\bSRWare Iron\b/.test(w)&&!C&&(C=xe(`Chrome`)),C&&C.indexOf(x=/[\d.]+$/.exec(T))==0&&e.indexOf(`/`+x+`-`)>-1&&(T=b(T.replace(x,``))),T&&T.indexOf(w)!=-1&&!RegExp(w+` OS`).test(T)&&(T=T.replace(RegExp(` *`+y(w)+` *`),``)),pe&&!/\b(?:Avant|Nook)\b/.test(w)&&(/Browser|Lunascape|Maxthon/.test(w)||w!=`Safari`&&/^iOS/.test(T)&&/\bSafari\b/.test(pe[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|SRWare Iron|Vivaldi|Web)/.test(w)&&pe[1])&&(x=pe[pe.length-1])&&S.push(x),S.length&&(S=[`(`+S.join(`; `)+`)`]),he&&me&&me.indexOf(he)<0&&S.push(`on `+he),me&&S.push((/^on /.test(S[S.length-1])?``:`on `)+me),T&&=(x=/ ([\d.+]+)$/.exec(T),fe=x&&T.charAt(T.length-x[0].length-1)==`/`,{architecture:32,family:x&&!fe?T.replace(x[0],``):T,version:x?x[1]:null,toString:function(){var e=this.version;return this.family+(e&&!fe?` `+e:``)+(this.architecture==64?` 64-bit`:``)}}),(x=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(le))&&!/\bi686\b/i.test(le)?(T&&(T.architecture=64,T.family=T.family.replace(RegExp(` *`+x),``)),w&&(/\bWOW64\b/i.test(e)||de&&/\w(?:86|32)$/.test(i.cpuClass||i.platform)&&!/\bWin64; x64\b/i.test(e))&&S.unshift(`32-bit`)):T&&/^OS X/.test(T.family)&&w==`Chrome`&&parseFloat(C)>=39&&(T.architecture=64),e||=null;var Ce={};return Ce.description=e,Ce.layout=pe&&pe[0],Ce.manufacturer=he,Ce.name=w,Ce.prerelease=ue,Ce.product=me,Ce.ua=e,Ce.version=w&&C,Ce.os=T||{architecture:null,family:null,version:null,toString:function(){return`null`}},Ce.parse=te,Ce.toString=Se,Ce.version&&S.unshift(C),Ce.name&&S.unshift(w),T&&w&&(T!=String(T).split(` `)[0]||T!=w.split(` `)[0]&&!me)&&S.push(me?`(`+T+`)`:`on `+T),S.length&&(Ce.description=S.join(` `)),Ce}var ne=te();typeof define==`function`&&typeof define.amd==`object`&&define.amd?(r.platform=ne,define(function(){return ne})):i&&a?g(ne,function(e,t){i[t]=e}):r.platform=ne}).call(e)}));const _v=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,vv=e=>{if(typeof e!=`string`)throw TypeError(`Invalid argument expected string`);let t=e.match(_v);if(!t)throw Error(`Invalid argument not valid semver ('${e}' received)`);return t.shift(),t},yv=e=>e===`*`||e===`x`||e===`X`,bv=e=>{let t=parseInt(e,10);return isNaN(t)?e:t},xv=(e,t)=>typeof e==typeof t?[e,t]:[String(e),String(t)],Sv=(e,t)=>{if(yv(e)||yv(t))return 0;let[n,r]=xv(bv(e),bv(t));return n>r?1:n<r?-1:0},Cv=(e,t)=>{for(let n=0;n<Math.max(e.length,t.length);n++){let r=Sv(e[n]||`0`,t[n]||`0`);if(r!==0)return r}return 0},wv=(e,t)=>{let n=vv(e),r=vv(t),i=n.pop(),a=r.pop(),o=Cv(n,r);return o===0?i&&a?Cv(i.split(`.`),a.split(`.`)):i||a?i?-1:1:0:o};var M;(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`})(M||={});function Tv(e,t){return typeof e==`object`&&e&&`$typeName`in e&&typeof e.$typeName==`string`?t===void 0||t.typeName===e.$typeName:!1}var N;(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`})(N||={});function Ev(){let e=this.buf,t=this.pos,n=0,r=0;for(let i=0;i<28;i+=7){let a=e[t++];if(n|=(a&127)<<i,!(a&128)){this.pos=t,this.assertBounds(),this.varint64Lo=n,this.varint64Hi=r;return}}let i=e[t++];if(n|=(i&15)<<28,r=(i&112)>>4,!(i&128)){this.pos=t,this.assertBounds(),this.varint64Lo=n,this.varint64Hi=r;return}for(let i=3;i<=31;i+=7){let a=e[t++];if(r|=(a&127)<<i,!(a&128)){this.pos=t,this.assertBounds(),this.varint64Lo=n,this.varint64Hi=r;return}}throw Error(`invalid varint`)}const Dv=4294967296;function Ov(e){let t=e[0]===`-`;t&&(e=e.slice(1));let n=1e6,r=0,i=0;function a(t,a){let o=Number(e.slice(t,a));i*=n,r=r*n+o,r>=Dv&&(i+=r/Dv|0,r%=Dv)}return a(-24,-18),a(-18,-12),a(-12,-6),a(-6),t?Nv(r,i):Mv(r,i)}function kv(e,t){let n=Mv(e,t),r=n.hi&2147483648;r&&(n=Nv(n.lo,n.hi));let i=Av(n.lo,n.hi);return r?`-`+i:i}function Av(e,t){if({lo:e,hi:t}=jv(e,t),t<=2097151)return String(Dv*t+e);let n=e&16777215,r=(e>>>24|t<<8)&16777215,i=t>>16&65535,a=n+r*6777216+i*6710656,o=r+i*8147497,s=i*2,c=1e7;return a>=c&&(o+=Math.floor(a/c),a%=c),o>=c&&(s+=Math.floor(o/c),o%=c),s.toString()+Pv(o)+Pv(a)}function jv(e,t){return{lo:e>>>0,hi:t>>>0}}function Mv(e,t){return{lo:e|0,hi:t|0}}function Nv(e,t){return t=~t,e?e=~e+1:t+=1,Mv(e,t)}const Pv=e=>{let t=String(e);return`0000000`.slice(t.length)+t};function Fv(e,t){if(e>>>0<128){t.push(e);return}if(e>=0){for(;e>127;)t.push(e&127|128),e>>>=7;t.push(e)}else{for(let n=0;n<9;n++)t.push(e&127|128),e>>=7;t.push(1)}}function Iv(){let e=this.buf[this.pos++];if(!(e&128))return this.assertBounds(),e;let t=e&127;if(e=this.buf[this.pos++],t|=(e&127)<<7,!(e&128)||(e=this.buf[this.pos++],t|=(e&127)<<14,!(e&128))||(e=this.buf[this.pos++],t|=(e&127)<<21,!(e&128)))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(e&15)<<28;for(let t=5;e&128&&t<10;t++)e=this.buf[this.pos++];if(e&128)throw Error(`invalid varint`);return this.assertBounds(),t>>>0}const Lv=Rv();function Rv(){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`&&(globalThis.Deno||globalThis.Bun||typeof process!=`object`||typeof process.env!=`object`||process.env.BUF_BIGINT_DISABLE!==`1`)){let t=BigInt(`-9223372036854775808`),n=BigInt(`9223372036854775807`),r=BigInt(`0`),i=BigInt(`18446744073709551615`);return{zero:BigInt(0),supported:!0,parse(e){let r=typeof e==`bigint`?e:BigInt(e);if(r>n||r<t)throw Error(`invalid int64: ${e}`);return r},uParse(e){let t=typeof e==`bigint`?e:BigInt(e);if(t>i||t<r)throw Error(`invalid uint64: ${e}`);return t},enc(t){return e.setBigInt64(0,this.parse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},uEnc(t){return e.setBigInt64(0,this.uParse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},dec(t,n){return e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigInt64(0,!0)},uDec(t,n){return e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigUint64(0,!0)}}}return{zero:`0`,supported:!1,parse(e){return typeof e!=`string`&&(e=e.toString()),zv(e),e},uParse(e){return typeof e!=`string`&&(e=e.toString()),Bv(e),e},enc(e){return typeof e!=`string`&&(e=e.toString()),zv(e),Ov(e)},uEnc(e){return typeof e!=`string`&&(e=e.toString()),Bv(e),Ov(e)},dec(e,t){return kv(e,t)},uDec(e,t){return Av(e,t)}}}function zv(e){if(!/^-?[0-9]+$/.test(e))throw Error(`invalid int64: `+e)}function Bv(e){if(!/^[0-9]+$/.test(e))throw Error(`invalid uint64: `+e)}function Vv(e,t){switch(e){case N.STRING:return``;case N.BOOL:return!1;case N.DOUBLE:case N.FLOAT:return 0;case N.INT64:case N.UINT64:case N.SFIXED64:case N.FIXED64:case N.SINT64:return t?`0`:Lv.zero;case N.BYTES:return new Uint8Array;default:return 0}}function Hv(e,t){switch(e){case N.BOOL:return t===!1;case N.STRING:return t===``;case N.BYTES:return t instanceof Uint8Array&&!t.byteLength;case N.DOUBLE:case N.FLOAT:return Object.is(t,0);default:return t==0}}const Uv=Symbol.for(`reflect unsafe local`);function Wv(e,t){let n=e[t.localName].case;return n===void 0?n:t.fields.find(e=>e.localName===n)}function Gv(e,t){let n=t.localName;if(t.oneof)return e[t.oneof.localName].case===n;if(t.presence!=2)return e[n]!==void 0&&Object.prototype.hasOwnProperty.call(e,n);switch(t.fieldKind){case`list`:return e[n].length>0;case`map`:return Object.keys(e[n]).length>0;case`scalar`:return!Hv(t.scalar,e[n]);case`enum`:return e[n]!==t.enum.values[0].number}throw Error(`message field with implicit presence`)}function Kv(e,t){return Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==void 0}function qv(e,t){if(t.oneof){let n=e[t.oneof.localName];return n.case===t.localName?n.value:void 0}return e[t.localName]}function Jv(e,t,n){t.oneof?e[t.oneof.localName]={case:t.localName,value:n}:e[t.localName]=n}function Yv(e,t,n){t===`__proto__`?Object.defineProperty(e,"__proto__",{value:n,writable:!0,enumerable:!0,configurable:!0}):e[t]=n}function Xv(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function Zv(e,t){let n=t.localName;if(t.oneof){let r=t.oneof.localName;e[r].case===n&&(e[r]={case:void 0})}else if(t.presence!=2)delete e[n];else switch(t.fieldKind){case`map`:e[n]={};break;case`list`:e[n]=[];break;case`enum`:e[n]=t.enum.values[0].number;break;case`scalar`:e[n]=Vv(t.scalar,t.longAsString)}}function Qv(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $v(e,t){if(Qv(e)&&Uv in e&&`add`in e&&`field`in e&&typeof e.field==`function`){if(t!==void 0){let n=t,r=e.field();return n.listKind==r.listKind&&n.scalar===r.scalar&&n.message?.typeName===r.message?.typeName&&n.enum?.typeName===r.enum?.typeName}return!0}return!1}function ey(e,t){if(Qv(e)&&Uv in e&&`has`in e&&`field`in e&&typeof e.field==`function`){if(t!==void 0){let n=t,r=e.field();return n.mapKey===r.mapKey&&n.mapKind==r.mapKind&&n.scalar===r.scalar&&n.message?.typeName===r.message?.typeName&&n.enum?.typeName===r.enum?.typeName}return!0}return!1}function ty(e,t){return Qv(e)&&Uv in e&&`desc`in e&&Qv(e.desc)&&e.desc.kind===`message`&&(t===void 0||e.desc.typeName==t.typeName)}function ny(e){return oy(e.$typeName)}function ry(e){let t=e.fields[0];return oy(e.typeName)&&t!==void 0&&t.fieldKind==`scalar`&&t.name==`value`&&t.number==1}function iy(e){switch(e.typeName){case`google.protobuf.Any`:case`google.protobuf.Timestamp`:case`google.protobuf.Duration`:case`google.protobuf.FieldMask`:case`google.protobuf.Struct`:case`google.protobuf.Value`:case`google.protobuf.ListValue`:return!0;default:return ry(e)}}const ay=new Set([`google.protobuf.DoubleValue`,`google.protobuf.FloatValue`,`google.protobuf.Int64Value`,`google.protobuf.UInt64Value`,`google.protobuf.Int32Value`,`google.protobuf.UInt32Value`,`google.protobuf.BoolValue`,`google.protobuf.StringValue`,`google.protobuf.BytesValue`]);function oy(e){return ay.has(e)}function sy(e,t){return Tv(t,e)?t:ly(e)(t)}const cy=new WeakMap;function ly(e){let t=cy.get(e);return t===void 0&&(t=uy(e),cy.set(e,t)),t}function uy(e){let t=e.typeName,{properties:n,prototype:r}=dy(e);return e=>{let i;r===void 0?i={$typeName:t}:(i=Object.create(r),i.$typeName=t);for(let t=0;t<n.length;t++){let r=n[t],a=r.name,o=e?.[a];switch(r.kind){case 0:o==null?r.constant!==void 0&&(i[a]=r.constant):i[a]=r.convert===void 0?o:r.convert(o);break;case 1:i[a]=r.convert!==void 0&&Array.isArray(o)?o.map(r.convert):o??[];break;case 2:if(r.convert===void 0||!Qv(o))i[a]=o??{};else{let e={},t=Object.keys(o);for(let n=0;n<t.length;n++)Yv(e,t[n],r.convert(o[t[n]]));i[a]=e}break;case 3:{let e=o;if(e?.case!=null){let t=r.convert.get(e.case);if(t!==void 0){i[a]={case:e.case,value:t(e.value)};break}}i[a]={case:void 0};break}}}return i}}function dy(e){let t=[],n={},r=hy(e);for(let i of e.members){let e=i.localName;if(i.kind==`oneof`){t.push({name:e,kind:3,constant:void 0,convert:fy(i)});continue}switch(i.fieldKind){case`message`:t.push({name:e,kind:0,constant:void 0,convert:py(i)});break;case`list`:t.push({name:e,kind:1,constant:void 0,convert:i.listKind==`message`?py(i)??(e=>e):i.scalar==N.BYTES?my:void 0});break;case`map`:t.push({name:e,kind:2,constant:void 0,convert:i.mapKind==`message`?py(i)??(e=>e):i.scalar==N.BYTES?my:void 0});break;default:{let a=gy(i);t.push({name:e,kind:0,constant:i.presence==2?a:void 0,convert:i.fieldKind==`scalar`&&i.scalar==N.BYTES?my:void 0}),r&&(n[e]=a);break}}}return{properties:t,prototype:r?n:void 0}}function fy(e){let t=new Map;for(let n of e.fields){let e;n.fieldKind==`message`?e=py(n):n.fieldKind==`scalar`&&n.scalar==N.BYTES&&(e=my),t.set(n.localName,e??(e=>e))}return t}function py(e){if(e.fieldKind==`message`&&!e.oneof&&ry(e.message))return e.message.fields[0].scalar==N.BYTES?my:void 0;if(e.message.typeName==`google.protobuf.Struct`&&e.parent.typeName!==`google.protobuf.Value`)return;let t=e.message,n;return e=>!Qv(e)||Tv(e,t)?e:(n??=ly(t),n(e))}function my(e){return Array.isArray(e)?new Uint8Array(e):e}function hy(e){switch(e.file.edition){case 999:return!1;case 998:return!0;default:return e.fields.some(e=>e.presence!=2&&e.fieldKind!=`message`&&!e.oneof)}}function gy(e){let t=e.getDefaultValue();return t===void 0?e.fieldKind==`scalar`?Vv(e.scalar,e.longAsString):e.enum.values[0].number:e.fieldKind==`scalar`&&e.longAsString?t.toString():t}const _y=[`FieldValueInvalidError`,`FieldListRangeError`,`ForeignFieldError`];var vy=class extends Error{constructor(e,t,n=`FieldValueInvalidError`){super(t),this.name=n,this.field=()=>e}};function yy(e){return e instanceof Error&&_y.includes(e.name)&&`field`in e&&typeof e.field==`function`}let by;function xy(e){by=Object.assign(Object.assign({},e),{encodeUtf8Into:e.encodeUtf8Into??Cy(e.encodeUtf8.bind(e))})}function Sy(){if(!by){let e=globalThis;if(!e.TextEncoder||!e.TextDecoder)throw Error(`encoding API missing: install TextEncoder and TextDecoder on globalThis`);let t=new e.TextEncoder,n=new e.TextDecoder(`utf-8`,{ignoreBOM:!0}),r,i={encodeUtf8(e){return t.encode(e)},decodeUtf8(t,i){return i?(r||=new e.TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0}),r.decode(t)):n.decode(t)},checkUtf8(e){try{return!0}catch{return!1}}};t.encodeInto&&(i.encodeUtf8Into=t.encodeInto.bind(t));let a=String.prototype.isWellFormed;a&&(i.checkUtf8=e=>a.call(e)),xy(i)}return by}function Cy(e){return(t,n)=>{let r=e(t);return n.set(r),{written:r.byteLength}}}var wy;(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`})(wy||={});var Ty=class{constructor(e){this.stackPos=[],this.encodeUtf8Into=e?Cy(e):Sy().encodeUtf8Into,this.buffer=Dy,this.viewCache=Rte,this.pos=0}ensureCapacity(e){let t=this.pos+e;if(t>this.buffer.length){let e=this.buffer.length||Lte;for(;e<t;)e*=2;let n=new Uint8Array(e);this.pos>0&&n.set(this.buffer),this.buffer=n}}view(){let e=this.buffer,t=this.viewCache;if(t.byteLength===e.byteLength)return t;let n=new DataView(e.buffer);return this.viewCache=n,n}finish(){let e=this.buffer.slice(0,this.pos);return this.pos=0,this.stackPos=[],e}fork(){return this.stackPos.push(this.pos),this.ensureCapacity(Ey),this.buffer[this.pos++]=0,this}join(){let e=this.stackPos.pop();if(e===void 0)throw Error(`invalid state, fork stack empty`);let t=this.pos-e-Ey,n=Oy(t);return n>Ey&&(this.ensureCapacity(n-Ey),this.buffer.copyWithin(e+n,e+Ey,this.pos)),this.pos=e,this.uint32(t),this.pos+=t,this}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.ensureCapacity(e.length),this.buffer.set(e,this.pos),this.pos+=e.length,this}uint32(e){if(jy(e),this.ensureCapacity(5),e<128)return this.buffer[this.pos++]=e,this;for(;e>127;)this.buffer[this.pos++]=e&127|128,e>>>=7;return this.buffer[this.pos++]=e,this}int32(e){if(Ay(e),e>=0)return this.uint32(e);this.ensureCapacity(10);for(let t=0;t<9;t++)this.buffer[this.pos++]=e&127|128,e>>=7;return this.buffer[this.pos++]=1,this}bool(e){return this.ensureCapacity(1),this.buffer[this.pos++]=+!!e,this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){typeof e!=`string`&&(e=String(e));let t=e.length;if(t<=zte){this.ensureCapacity(t+1);let n=this.buffer,r=this.pos;n[r++]=t;let i=0;for(;i<t;i++){let t=e.charCodeAt(i);if(t>127)break;n[r++]=t}if(i==t)return this.pos=r,this}this.ensureCapacity(t*3+5);let n=Oy(t),r=this.buffer,i=this.pos,{written:a}=this.encodeUtf8Into(e,r.subarray(i+n)),o=Oy(a);return o!=n&&r.copyWithin(i+o,i+n,i+n+a),this.uint32(a),this.pos+=a,this}float(e){return Bte(e),this.ensureCapacity(4),this.view().setFloat32(this.pos,e,!0),this.pos+=4,this}double(e){return this.ensureCapacity(8),this.view().setFloat64(this.pos,e,!0),this.pos+=8,this}fixed32(e){return jy(e),this.ensureCapacity(4),this.view().setUint32(this.pos,e,!0),this.pos+=4,this}sfixed32(e){return Ay(e),this.ensureCapacity(4),this.view().setInt32(this.pos,e,!0),this.pos+=4,this}sint32(e){return Ay(e),this.uint32((e<<1^e>>31)>>>0)}sfixed64(e){let t=Lv.enc(e);this.ensureCapacity(8);let n=this.view();return n.setInt32(this.pos,t.lo,!0),n.setInt32(this.pos+4,t.hi,!0),this.pos+=8,this}fixed64(e){let t=Lv.uEnc(e);this.ensureCapacity(8);let n=this.view();return n.setInt32(this.pos,t.lo,!0),n.setInt32(this.pos+4,t.hi,!0),this.pos+=8,this}int64(e){let t=Lv.enc(e);return this.writeVarint64(t.lo,t.hi)}sint64(e){let t=Lv.enc(e),n=t.hi>>31,r=t.lo<<1^n,i=(t.hi<<1|t.lo>>>31)^n;return this.writeVarint64(r,i)}uint64(e){let t=Lv.uEnc(e);return this.writeVarint64(t.lo,t.hi)}writeVarint64(e,t){this.ensureCapacity(10);let n=this.buffer,r=this.pos;for(let i=0;i<28;i+=7){let a=e>>>i,o=!(!(a>>>7)&&t==0);if(n[r++]=(o?a|128:a)&255,!o)return this.pos=r,this}let i=e>>>28&15|(t&7)<<4,a=!!(t>>3);if(n[r++]=(a?i|128:i)&255,!a)return this.pos=r,this;for(let e=3;e<31;e+=7){let i=t>>>e,a=!!(i>>>7);if(n[r++]=(a?i|128:i)&255,!a)return this.pos=r,this}return n[r++]=t>>>31&1,this.pos=r,this}};const Lte=128,Ey=1,Dy=new Uint8Array,Rte=new DataView(Dy.buffer),zte=32;function Oy(e){return e<128?1:e<16384?2:e<2097152?3:e<268435456?4:5}var ky=class{constructor(e,t=Sy().decodeUtf8){this.decodeUtf8=t,this.varint64Lo=0,this.varint64Hi=0,this.varint64=Ev,this.uint32=Iv,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength)}tag(){let e=this.pos,t=this.uint32(),n=this.pos-e;if(n>5||n==5&&this.buf[this.pos-1]>15)throw Error(`illegal tag: varint overflows uint32`);let r=t>>>3,i=t&7;if(r<=0||i>5)throw Error(`illegal tag: field no `+r+` wire type `+i);return[r,i]}skip(e,t,n=100){let r=this.pos;switch(e){case wy.Varint:for(;this.buf[this.pos++]&128;);break;case wy.Bit64:this.pos+=4;case wy.Bit32:this.pos+=4;break;case wy.LengthDelimited:let r=this.uint32();this.pos+=r;break;case wy.StartGroup:if(n<=0)throw Error(`maximum recursion depth reached`);for(;;){let[e,r]=this.tag();if(r===wy.EndGroup){if(t!==void 0&&e!==t)throw Error(`invalid end group tag`);break}this.skip(r,e,n-1)}break;default:throw Error(`cant skip wire type `+e)}return this.assertBounds(),this.buf.subarray(r,this.pos)}assertBounds(){if(this.pos>this.len)throw RangeError(`premature EOF`)}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return this.varint64(),Lv.dec(this.varint64Lo,this.varint64Hi)}uint64(){return this.varint64(),Lv.uDec(this.varint64Lo,this.varint64Hi)}sint64(){this.varint64();let e=this.varint64Lo,t=this.varint64Hi,n=-(e&1);return e=(e>>>1|(t&1)<<31)^n,t=t>>>1^n,Lv.dec(e,t)}bool(){let e=this.buf[this.pos];return e<128?(this.pos++,e!==0):(this.varint64(),this.varint64Lo!==0||this.varint64Hi!==0)}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return Lv.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return Lv.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 e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(e){let t=this.uint32(),n=this.pos;this.pos+=t,this.assertBounds();let r=this.buf;if(t<=32){let i=Array(t);for(let a=0;a<t;a++){let t=r[n+a];if(t>127)return this.decodeUtf8(r.subarray(n,this.pos),e);i[a]=t}return String.fromCharCode.apply(String,i)}return this.decodeUtf8(r.subarray(n,this.pos),e)}};function Ay(e){if(typeof e==`string`)e=Number(e);else if(typeof e!=`number`)throw Error(`invalid int32: `+typeof e);if(!Number.isInteger(e)||e>2147483647||e<-2147483648)throw Error(`invalid int32: `+e)}function jy(e){if(typeof e==`string`)e=Number(e);else if(typeof e!=`number`)throw Error(`invalid uint32: `+typeof e);if(!Number.isInteger(e)||e>4294967295||e<0)throw Error(`invalid uint32: `+e)}function Bte(e){if(typeof e==`string`){let t=e;if(e=Number(e),Number.isNaN(e)&&t!==`NaN`)throw Error(`invalid float32: `+t)}else if(typeof e!=`number`)throw Error(`invalid float32: `+typeof e);if(!Number.isFinite(Math.fround(e))&&Number.isFinite(e))throw Error(`invalid float32: `+e)}function My(e,t){let n=e.fieldKind==`list`?$v(t,e):e.fieldKind==`map`?ey(t,e):Py(e,t);if(n===!0)return;let r;switch(e.fieldKind){case`list`:r=`expected ${zy(e)}, got ${Ly(t)}`;break;case`map`:r=`expected ${By(e)}, got ${Ly(t)}`;break;default:r=Iy(e,t,n)}return new vy(e,r)}function Ny(e,t,n){let r=Py(e,n);if(r!==!0)return new vy(e,`list item #${t+1}: ${Iy(e,n,r)}`)}function Vte(e,t,n){let r=Fy(e.mapKey)(t);if(r!==!0)return new vy(e,`invalid map key: ${Iy({scalar:e.mapKey},t,r)}`);let i=Py(e,n);if(i!==!0)return new vy(e,`map entry ${Ly(t)}: ${Iy(e,n,i)}`)}function Py(e,t){return e.scalar===void 0?e.enum===void 0?ty(t,e.message):e.enum.open?Fy(N.INT32)(t):e.enum.values.some(e=>e.number===t):Fy(e.scalar)(t)}function Fy(e){switch(e){case N.DOUBLE:return e=>typeof e==`number`;case N.FLOAT:return e=>typeof e==`number`?!Number.isFinite(Math.fround(e))&&Number.isFinite(e)?`${e.toFixed()} out of range`:!0:!1;case N.INT32:case N.SFIXED32:case N.SINT32:return e=>typeof e!=`number`||!Number.isInteger(e)?!1:e>2147483647||e<-2147483648?`${e.toFixed()} out of range`:!0;case N.FIXED32:case N.UINT32:return e=>typeof e!=`number`||!Number.isInteger(e)?!1:e>4294967295||e<0?`${e.toFixed()} out of range`:!0;case N.BOOL:return e=>typeof e==`boolean`;case N.STRING:return e=>typeof e==`string`?Sy().checkUtf8(e)||`invalid UTF8`:!1;case N.BYTES:return e=>e instanceof Uint8Array;case N.INT64:case N.SFIXED64:case N.SINT64:return e=>{if(typeof e==`bigint`||typeof e==`number`||typeof e==`string`&&e.length>0)try{return Lv.parse(e),!0}catch{return`${e} out of range`}return!1};case N.FIXED64:case N.UINT64:return e=>{if(typeof e==`bigint`||typeof e==`number`||typeof e==`string`&&e.length>0)try{return Lv.uParse(e),!0}catch{return`${e} out of range`}return!1}}}function Iy(e,t,n){return n=typeof n==`string`?`: ${n}`:`, got ${Ly(t)}`,e.scalar===void 0?e.enum===void 0?`expected ${Ry(e.message)}`+n:`expected ${e.enum.toString()}`+n:`expected ${Hte(e.scalar)}`+n}function Ly(e){switch(typeof e){case`object`:return e===null?`null`:e instanceof Uint8Array?`Uint8Array(${e.length})`:Array.isArray(e)?`Array(${e.length})`:$v(e)?zy(e.field()):ey(e)?By(e.field()):ty(e)?Ry(e.desc):Tv(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 Ry(e){return`ReflectMessage (${e.typeName})`}function zy(e){switch(e.listKind){case`message`:return`ReflectList (${e.message.toString()})`;case`enum`:return`ReflectList (${e.enum.toString()})`;case`scalar`:return`ReflectList (${N[e.scalar]})`}}function By(e){switch(e.mapKind){case`message`:return`ReflectMap (${N[e.mapKey]}, ${e.message.toString()})`;case`enum`:return`ReflectMap (${N[e.mapKey]}, ${e.enum.toString()})`;case`scalar`:return`ReflectMap (${N[e.mapKey]}, ${N[e.scalar]})`}}function Hte(e){switch(e){case N.STRING:return`string`;case N.BOOL:return`boolean`;case N.INT64:case N.SINT64:case N.SFIXED64:return`bigint (int64)`;case N.UINT64:case N.FIXED64:return`bigint (uint64)`;case N.BYTES:return`Uint8Array`;case N.DOUBLE:return`number (float64)`;case N.FLOAT:return`number (float32)`;case N.FIXED32:case N.UINT32:return`number (uint32)`;case N.INT32:case N.SFIXED32:case N.SINT32:return`number (int32)`}}function Vy(e){if(Ute(e))return{toMessage:e=>Hy(e),toLocal:e=>Uy(e)};if(e.fieldKind==`message`&&!e.oneof&&ry(e.message)){let t=e.message,n=t.fields[0].localName;return{toMessage:e=>{let r=sy(t);return e!==void 0&&(r[n]=e),r},toLocal:e=>e[n]}}let t=e.message;return{toMessage:e=>e===void 0?sy(t):e,toLocal:e=>e}}function Ute(e){return e.message.typeName==`google.protobuf.Struct`&&e.parent.typeName!=`google.protobuf.Value`}function Hy(e){let t={$typeName:`google.protobuf.Struct`,fields:{}};if(Qv(e))for(let n of Object.keys(e))Yv(t.fields,n,Gy(e[n]));return t}function Uy(e){let t={};for(let n of Object.keys(e.fields))Yv(t,n,Wy(e.fields[n]));return t}function Wy(e){switch(e.kind.case){case`structValue`:return Uy(e.kind.value);case`listValue`:return e.kind.value.values.map(Wy);case`nullValue`:case void 0:return null;default:return e.kind.value}}function Gy(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 n={$typeName:`google.protobuf.ListValue`,values:[]};if(Array.isArray(e))for(let t of e)n.values.push(Gy(t));t.kind={case:`listValue`,value:n}}else t.kind={case:`structValue`,value:Hy(e)}}return t}function Wte(e,t,n=!0){return new qy(e,t,n)}const Ky=new WeakMap;var qy=class{get sortedFields(){let e=Ky.get(this.desc);if(e)return e;let t=this.desc.fields.concat().sort((e,t)=>e.number-t.number);return Ky.set(this.desc,t),t}constructor(e,t,n=!0){this.lists=new Map,this.maps=new Map,this.check=n,this.desc=e,this.message=this[Uv]=t??sy(e),this.fields=e.fields,this.oneofs=e.oneofs,this.members=e.members}findNumber(e){return this._fieldsByNumber||=new Map(this.desc.fields.map(e=>[e.number,e])),this._fieldsByNumber.get(e)}oneofCase(e){return Jy(this.message,e),Wv(this.message,e)}isSet(e){return Jy(this.message,e),Gv(this.message,e)}clear(e){Jy(this.message,e),Zv(this.message,e)}get(e){Jy(this.message,e);let t=qv(this.message,e);switch(e.fieldKind){case`list`:let n=this.lists.get(e);return(!n||n[Uv]!==t)&&this.lists.set(e,n=new Gte(e,t,this.check)),n;case`map`:let r=this.maps.get(e);return(!r||r[Uv]!==t)&&this.maps.set(e,r=new Kte(e,t,this.check)),r;case`message`:return Xy(e,t,this.check);case`scalar`:return t===void 0?Vv(e.scalar,!1):nb(e,t);case`enum`:return t??e.enum.values[0].number}}set(e,t){if(Jy(this.message,e),this.check){let n=My(e,t);if(n)throw n}let n;n=e.fieldKind==`message`?Yy(e,t):ey(t)||$v(t)?t[Uv]:rb(e,t),Jv(this.message,e,n)}getUnknown(){return this.message.$unknown}setUnknown(e){this.message.$unknown=e}};function Jy(e,t){if(t.parent.typeName!==e.$typeName)throw new vy(t,`cannot use ${t.toString()} with message ${e.$typeName}`,`ForeignFieldError`)}var Gte=class{field(){return this._field}get size(){return this._arr.length}constructor(e,t,n){this._field=e,this._arr=this[Uv]=t,this.check=n}get(e){let t=this._arr[e];return t===void 0?void 0:Qy(this._field,t,this.check)}set(e,t){if(e<0||e>=this._arr.length)throw new vy(this._field,`list item #${e+1}: out of range`);if(this.check){let n=Ny(this._field,e,t);if(n)throw n}this._arr[e]=Zy(this._field,t)}add(e){if(this.check){let t=Ny(this._field,this._arr.length,e);if(t)throw t}this._arr.push(Zy(this._field,e))}clear(){this._arr.splice(0,this._arr.length)}[Symbol.iterator](){return this.values()}keys(){return this._arr.keys()}*values(){for(let e of this._arr)yield Qy(this._field,e,this.check)}*entries(){for(let e=0;e<this._arr.length;e++)yield[e,Qy(this._field,this._arr[e],this.check)]}},Kte=class{constructor(e,t,n=!0){this.obj=this[Uv]=t??{},this.check=n,this._field=e}field(){return this._field}set(e,t){if(this.check){let n=Vte(this._field,e,t);if(n)throw n}return Yv(this.obj,eb(e),qte(this._field,t)),this}delete(e){let t=eb(e),n=Object.prototype.hasOwnProperty.call(this.obj,t);return n&&delete this.obj[t],n}clear(){for(let e of Object.keys(this.obj))delete this.obj[e]}get(e){let t=Xv(this.obj,eb(e));return t!==void 0&&(t=$y(this._field,t,this.check)),t}has(e){return Object.prototype.hasOwnProperty.call(this.obj,eb(e))}*keys(){for(let e of Object.keys(this.obj))yield tb(e,this._field.mapKey)}*entries(){for(let e of Object.entries(this.obj))yield[tb(e[0],this._field.mapKey),$y(this._field,e[1],this.check)]}[Symbol.iterator](){return this.entries()}get size(){return Object.keys(this.obj).length}*values(){for(let e of Object.values(this.obj))yield $y(this._field,e,this.check)}forEach(e,t){for(let n of this.entries())e.call(t,n[1],n[0],this)}};function Yy(e,t){return ty(t)?ny(t.message)&&!e.oneof&&e.fieldKind==`message`?t.message.value:t.desc.typeName==`google.protobuf.Struct`&&e.parent.typeName!=`google.protobuf.Value`?Uy(t.message):t.message:t}function Xy(e,t,n){return t!==void 0&&(ry(e.message)&&!e.oneof&&e.fieldKind==`message`?t={$typeName:e.message.typeName,value:nb(e.message.fields[0],t)}:e.message.typeName==`google.protobuf.Struct`&&e.parent.typeName!=`google.protobuf.Value`&&Qv(t)&&(t=Hy(t))),new qy(e.message,t,n)}function Zy(e,t){return e.listKind==`message`?Yy(e,t):rb(e,t)}function Qy(e,t,n){return e.listKind==`message`?Xy(e,t,n):nb(e,t)}function qte(e,t){return e.mapKind==`message`?Yy(e,t):rb(e,t)}function $y(e,t,n){return e.mapKind==`message`?Xy(e,t,n):t}function eb(e){return typeof e==`string`||typeof e==`number`?e:String(e)}function tb(e,t){switch(t){case N.STRING:return e;case N.INT32:case N.FIXED32:case N.UINT32:case N.SFIXED32:case N.SINT32:{let t=Number.parseInt(e);if(Number.isFinite(t))return t;break}case N.BOOL:switch(e){case`true`:return!0;case`false`:return!1}break;case N.UINT64:case N.FIXED64:try{return Lv.uParse(e)}catch{}break;default:try{return Lv.parse(e)}catch{}}return e}function nb(e,t){switch(e.scalar){case N.INT64:case N.SFIXED64:case N.SINT64:`longAsString`in e&&e.longAsString&&typeof t==`string`&&(t=Lv.parse(t));break;case N.FIXED64:case N.UINT64:`longAsString`in e&&e.longAsString&&typeof t==`string`&&(t=Lv.uParse(t))}return t}function rb(e,t){switch(e.scalar){case N.INT64:case N.SFIXED64:case N.SINT64:`longAsString`in e&&e.longAsString?t=String(t):(typeof t==`string`||typeof t==`number`)&&(t=Lv.parse(t));break;case N.FIXED64:case N.UINT64:`longAsString`in e&&e.longAsString?t=String(t):(typeof t==`string`||typeof t==`number`)&&(t=Lv.uParse(t))}return t}const ib=Uint8Array.prototype.setFromBase64;function ab(e){let t=e.length,n=t-(t+3>>2);!(t&3)&&e[t-1]==`=`&&(n-=e[t-2]==`=`?2:1);let r=new Uint8Array(n),i=-1;if(ib)try{let n=ib.call(r,e);n.read==t&&(i=n.written)}catch{}return i<0&&(i=Jte(r,e)),i==n?r:r.subarray(0,i)}function Jte(e,t){let n=Xte(),r=0,i=0,a,o=0;for(let s=0;s<t.length;s++){if(a=n[t.charCodeAt(s)],a===void 0)switch(t[s]){case`=`:i=0;case`
|
|
197
|
+
`:case`\r`:case` `:case` `:continue;default:throw Error(`invalid base64 string`)}switch(i){case 0:o=a,i=1;break;case 1:e[r++]=o<<2|(a&48)>>4,o=a,i=2;break;case 2:e[r++]=(o&15)<<4|(a&60)>>2,o=a,i=3;break;case 3:e[r++]=(o&3)<<6|a,i=0}}if(i==1)throw Error(`invalid base64 string`);return r}const ob=Uint8Array.prototype.toBase64,Yte={std:{alphabet:`base64`,omitPadding:!1},std_raw:{alphabet:`base64`,omitPadding:!0},url:{alphabet:`base64url`,omitPadding:!0}};function sb(e,t=`std`){if(ob)return ob.call(e,Yte[t]);let n=db(t),r=t==`std`,i=``,a=0,o,s=0;for(let t=0;t<e.length;t++)switch(o=e[t],a){case 0:i+=n[o>>2],s=(o&3)<<4,a=1;break;case 1:i+=n[s|o>>4],s=(o&15)<<2,a=2;break;case 2:i+=n[s|o>>6],i+=n[o&63],a=0}return a&&(i+=n[s],r&&(i+=`=`,a==1&&(i+=`=`))),i}let cb,lb,ub;function db(e){return cb||(cb=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`.split(``),lb=cb.slice(0,-2).concat(`-`,`_`)),e==`url`?lb:cb}function Xte(){if(!ub){ub=[];let e=db(`std`);for(let t=0;t<e.length;t++)ub[e[t].charCodeAt(0)]=t;ub[45]=e.indexOf(`+`),ub[95]=e.indexOf(`/`)}return ub}function fb(e){let t=!1,n=[];for(let r=0;r<e.length;r++){let i=e.charAt(r);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`:n.push(i),t=!1;break;default:t&&(t=!1,i=i.toUpperCase()),n.push(i)}}return n.join(``)}function pb(e){return e.replace(/[A-Z]/g,e=>`_`+e.toLowerCase())}const Zte=new Set([`constructor`,`toString`,`toJSON`,`valueOf`]);function mb(e){return Zte.has(e)?e+`$`:e}function hb(e){for(let t of e.field)Kv(t,`jsonName`)||(t.jsonName=fb(t.name));e.nestedType.forEach(hb)}function Qte(e,t){let n=e.values.find(e=>e.name===t);if(!n)throw Error(`cannot parse ${e} default value: ${t}`);return n.number}function $te(e,t){switch(e){case N.STRING:return t;case N.BYTES:{let n=ene(t);if(n===!1)throw Error(`cannot parse ${N[e]} default value: ${t}`);return n}case N.INT64:case N.SFIXED64:case N.SINT64:return Lv.parse(t);case N.UINT64:case N.FIXED64:return Lv.uParse(t);case N.DOUBLE:case N.FLOAT:switch(t){case`inf`:return 1/0;case`-inf`:return-1/0;case`nan`:return NaN;default:return parseFloat(t)}case N.BOOL:return t===`true`;case N.INT32:case N.UINT32:case N.SINT32:case N.FIXED32:case N.SFIXED32:return parseInt(t,10)}}function ene(e){let t=[],n={tail:e,c:``,next(){return this.tail.length!=0&&(this.c=this.tail[0],this.tail=this.tail.substring(1),!0)},take(e){if(this.tail.length>=e){let t=this.tail.substring(0,e);return this.tail=this.tail.substring(e),t}return!1}};for(;n.next();)switch(n.c){case`\\`:if(n.next())switch(n.c){case`\\`:t.push(n.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 e=n.c,r=n.take(2);if(r===!1)return!1;let i=parseInt(e+r,8);if(Number.isNaN(i))return!1;t.push(i);break}case`x`:{let e=n.c,r=n.take(2);if(r===!1)return!1;let i=parseInt(e+r,16);if(Number.isNaN(i))return!1;t.push(i);break}case`u`:{let e=n.c,r=n.take(4);if(r===!1)return!1;let i=parseInt(e+r,16);if(Number.isNaN(i))return!1;let a=new Uint8Array(4);new DataView(a.buffer).setInt32(0,i,!0),t.push(a[0],a[1],a[2],a[3]);break}case`U`:{let e=n.c,r=n.take(8);if(r===!1)return!1;let i=Lv.uEnc(e+r),a=new Uint8Array(8),o=new DataView(a.buffer);o.setInt32(0,i.lo,!0),o.setInt32(4,i.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(n.c.charCodeAt(0))}return new Uint8Array(t)}function*gb(e){switch(e.kind){case`file`:for(let t of e.messages)yield t,yield*gb(t);yield*e.enums,yield*e.services,yield*e.extensions;break;case`message`:for(let t of e.nestedMessages)yield t,yield*gb(t);yield*e.nestedEnums,yield*e.nestedExtensions}}function _b(e,t){return tne([e,t])}function tne(e,t){let n=nne();if(!e.length)return n;if(`$typeName`in e[0]&&e[0].$typeName==`google.protobuf.FileDescriptorSet`){for(let r of e[0].file)t?.(r),yb(r,n);return n}if(`$typeName`in e[0]){let r=e[0],i=e[1],a=new Set;function o(e){let t=[];for(let r of e.dependency){if(n.getFile(r)!=null||a.has(r))continue;let o=i(r);if(!o)throw Error(`Unable to resolve ${r}, imported by ${e.name}`);`kind`in o?n.addFile(o,!1,!0):(a.add(o.name),t.push(o))}return t.concat(...t.map(o))}for(let e of[r,...o(r)].reverse())t?.(e),yb(e,n)}else for(let t of e)for(let e of t.files)n.addFile(e);return n}function nne(){let e=new Map,t=new Map,n=new Map;return{kind:`registry`,types:e,extendees:t,[Symbol.iterator](){return e.values()},get files(){return n.values()},addFile(e,t,r){if(n.set(e.proto.name,e),!t)for(let t of gb(e))this.add(t);if(r)for(let n of e.dependencies)this.addFile(n,t,r)},add(n){if(n.kind==`extension`){let e=t.get(n.extendee.typeName);e||t.set(n.extendee.typeName,e=new Map),e.set(n.number,n)}e.set(n.typeName,n)},get(t){return e.get(t)},getFile(e){return n.get(e)},getMessage(t){let n=e.get(t);return n?.kind==`message`?n:void 0},getEnum(t){let n=e.get(t);return n?.kind==`enum`?n:void 0},getExtension(t){let n=e.get(t);return n?.kind==`extension`?n:void 0},getExtensionFor(e,n){return t.get(e.typeName)?.get(n)},getService(t){let n=e.get(t);return n?.kind==`service`?n:void 0}}}const vb={998:{fieldPresence:1,enumType:2,repeatedFieldEncoding:2,utf8Validation:3,messageEncoding:1,jsonFormat:2,enforceNamingStyle:2,defaultSymbolVisibility:1,enforceProtoLimits:1},999:{fieldPresence:2,enumType:1,repeatedFieldEncoding:1,utf8Validation:2,messageEncoding:1,jsonFormat:1,enforceNamingStyle:2,defaultSymbolVisibility:1,enforceProtoLimits:1},1e3:{fieldPresence:1,enumType:1,repeatedFieldEncoding:1,utf8Validation:2,messageEncoding:1,jsonFormat:1,enforceNamingStyle:2,defaultSymbolVisibility:1,enforceProtoLimits:1},1001:{fieldPresence:1,enumType:1,repeatedFieldEncoding:1,utf8Validation:2,messageEncoding:1,jsonFormat:1,enforceNamingStyle:1,defaultSymbolVisibility:2,enforceProtoLimits:1},1002:{fieldPresence:1,enumType:1,repeatedFieldEncoding:1,utf8Validation:2,messageEncoding:1,jsonFormat:1,enforceNamingStyle:3,defaultSymbolVisibility:4,enforceProtoLimits:2}};function yb(e,t){let n={kind:`file`,proto:e,deprecated:e.options?.deprecated??!1,edition:one(e),name:e.name.replace(/\.proto$/,``),dependencies:sne(e,t),enums:[],messages:[],extensions:[],services:[],toString(){return`file ${e.name}`}},r=new Map,i={get(e){return r.get(e)},add(e){kb(e.proto.options?.mapEntry===!0),r.set(e.typeName,e)}};for(let r of e.enumType)Sb(r,n,void 0,t);for(let r of e.messageType)Cb(r,n,void 0,t,i);for(let r of e.service)rne(r,n,t);bb(n,t);for(let e of r.values())xb(e,t,i);for(let e of n.messages)xb(e,t,i),bb(e,t);t.addFile(n,!0)}function bb(e,t){switch(e.kind){case`file`:for(let n of e.proto.extension){let r=wb(n,e,t);e.extensions.push(r),t.add(r)}break;case`message`:for(let n of e.proto.extension){let r=wb(n,e,t);e.nestedExtensions.push(r),t.add(r)}for(let n of e.nestedMessages)bb(n,t)}}function xb(e,t,n){let r=e.proto.oneofDecl.map(t=>ane(t,e)),i=new Set;for(let a of e.proto.field){let o=dne(a,r),s=wb(a,e,t,o,n);e.fields.push(s),e.field[s.localName]=s,o===void 0?e.members.push(s):(o.fields.push(s),i.has(o)||(i.add(o),e.members.push(o)))}for(let t of r.filter(e=>i.has(e)))e.oneofs.push(t);for(let r of e.nestedMessages)xb(r,t,n)}function Sb(e,t,n,r){var i,a;let o=cne(e.name,e.value),s={kind:`enum`,proto:e,deprecated:e.options?.deprecated??!1,file:t,parent:n,open:!0,name:e.name,typeName:Tb(e,n,t),value:{},values:[],sharedPrefix:o,toString(){return`enum ${this.typeName}`}};s.open=hne(s),r.add(s);for(let t of e.value){let e=t.name,n={kind:`enum_value`,proto:t,deprecated:t.options?.deprecated??!1,parent:s,name:e,localName:mb(o==null?e:e.substring(o.length)),number:t.number,jsonName:lne(t)??e,toString(){return`enum value ${s.typeName}.${e}`}};s.values.push(n),(i=s.value)[a=t.number]??(i[a]=n)}(n?.nestedEnums??t.enums).push(s)}function Cb(e,t,n,r,i){let a={kind:`message`,proto:e,deprecated:e.options?.deprecated??!1,file:t,parent:n,name:e.name,typeName:Tb(e,n,t),fields:[],field:{},oneofs:[],members:[],nestedEnums:[],nestedMessages:[],nestedExtensions:[],toString(){return`message ${this.typeName}`}};e.options?.mapEntry===!0?i.add(a):((n?.nestedMessages??t.messages).push(a),r.add(a));for(let n of e.enumType)Sb(n,t,a,r);for(let n of e.nestedType)Cb(n,t,a,r,i)}function rne(e,t,n){let r={kind:`service`,proto:e,deprecated:e.options?.deprecated??!1,file:t,name:e.name,typeName:Tb(e,void 0,t),methods:[],method:{},toString(){return`service ${this.typeName}`}};t.services.push(r),n.add(r);for(let t of e.method){let e=ine(t,r,n);r.methods.push(e),r.method[e.localName]=e}}function ine(e,t,n){let r;r=e.clientStreaming&&e.serverStreaming?`bidi_streaming`:e.clientStreaming?`client_streaming`:e.serverStreaming?`server_streaming`:`unary`;let i=n.getMessage(Eb(e.inputType)),a=n.getMessage(Eb(e.outputType));kb(i,`invalid MethodDescriptorProto: input_type ${e.inputType} not found`),kb(a,`invalid MethodDescriptorProto: output_type ${e.inputType} not found`);let o=e.name;return{kind:`rpc`,proto:e,deprecated:e.options?.deprecated??!1,parent:t,name:o,localName:mb(o.length?mb(o[0].toLowerCase()+o.substring(1)):o),methodKind:r,input:i,output:a,idempotency:e.options?.idempotencyLevel??0,toString(){return`rpc ${t.typeName}.${o}`}}}function ane(e,t){return{kind:`oneof`,proto:e,deprecated:!1,parent:t,fields:[],name:e.name,localName:mb(fb(e.name)),toString(){return`oneof ${t.typeName}.${this.name}`}}}function wb(e,t,n,r,i){let a=i===void 0,o={kind:`field`,proto:e,deprecated:e.options?.deprecated??!1,name:e.name,number:e.number,scalar:void 0,message:void 0,enum:void 0,presence:fne(e,r,a,t),utf8Validation:gne(e,t),listKind:void 0,mapKind:void 0,mapKey:void 0,delimitedEncoding:void 0,packed:void 0,longAsString:!1,getDefaultValue:void 0},s;if(a){let r=t.kind==`file`?t:t.file,i=t.kind==`file`?void 0:t,a=Tb(e,i,r);o.kind=`extension`,o.file=r,o.parent=i,o.oneof=void 0,o.typeName=a,o.jsonName=`[${a}]`,s=()=>`extension ${a}`;let c=n.getMessage(Eb(e.extendee));kb(c,`invalid FieldDescriptorProto: extendee ${e.extendee} not found`),o.extendee=c}else{let n=t;kb(n.kind==`message`),o.parent=n,o.oneof=r,o.localName=r?fb(e.name):mb(fb(e.name)),o.jsonName=e.jsonName,s=()=>`field ${n.typeName}.${e.name}`}Object.defineProperty(o,"toString",{value:s,writable:!0,enumerable:!0,configurable:!0});let c=e.label,l=e.type,u=e.options?.jstype;if(c===3){let r=l==11?i?.get(Eb(e.typeName)):void 0;if(r){o.fieldKind=`map`;let{key:e,value:t}=mne(r);return o.mapKey=e.scalar,o.mapKind=t.fieldKind,o.message=t.message,o.delimitedEncoding=!1,o.enum=t.enum,o.scalar=t.scalar,o}switch(o.fieldKind=`list`,l){case 11:case 10:o.listKind=`message`,o.message=n.getMessage(Eb(e.typeName)),kb(o.message),o.delimitedEncoding=Db(e,t);break;case 14:o.listKind=`enum`,o.enum=n.getEnum(Eb(e.typeName)),kb(o.enum);break;default:o.listKind=`scalar`,o.scalar=l,o.longAsString=u==1}return o.packed=pne(e,t),o}switch(l){case 11:case 10:o.fieldKind=`message`,o.message=n.getMessage(Eb(e.typeName)),kb(o.message,`invalid FieldDescriptorProto: type_name ${e.typeName} not found`),o.delimitedEncoding=Db(e,t),o.getDefaultValue=()=>void 0;break;case 14:{let t=n.getEnum(Eb(e.typeName));kb(t!==void 0,`invalid FieldDescriptorProto: type_name ${e.typeName} not found`),o.fieldKind=`enum`,o.enum=n.getEnum(Eb(e.typeName)),o.getDefaultValue=()=>Kv(e,`defaultValue`)?Qte(t,e.defaultValue):void 0;break}default:o.fieldKind=`scalar`,o.scalar=l,o.longAsString=u==1,o.getDefaultValue=()=>Kv(e,`defaultValue`)?$te(l,e.defaultValue):void 0}return o}function one(e){switch(e.syntax){case``:case`proto2`:return 998;case`proto3`:return 999;case`editions`:if(e.edition===9999)return 1002;if(e.edition in vb)return e.edition;throw Error(`${e.name}: unsupported edition`);default:throw Error(`${e.name}: unsupported syntax "${e.syntax}"`)}}function sne(e,t){return e.dependency.map(n=>{let r=t.getFile(n);if(!r)throw Error(`Cannot find ${n}, imported by ${e.name}`);return r})}function cne(e,t){let n=une(e)+`_`;for(let e of t){if(!e.name.toLowerCase().startsWith(n))return;let t=e.name.substring(n.length);if(t.length==0||/^\d/.test(t))return}return n}function lne(e){let t;for(let n of e.options?.$unknown??[]){if(n.no!==998||n.wireType!==wy.LengthDelimited)continue;let e=new ky(new ky(n.data).bytes());for(;e.pos<e.len;){let[n,r]=e.tag();n===1&&r===wy.LengthDelimited?t=e.string():e.skip(r,n)}}return t}function une(e){return(e.substring(0,1)+e.substring(1).replace(/[A-Z]/g,e=>`_`+e)).toLowerCase()}function Tb(e,t,n){let r;return r=t?`${t.typeName}.${e.name}`:n.proto.package.length>0?`${n.proto.package}.${e.name}`:`${e.name}`,r}function Eb(e){return e.startsWith(`.`)?e.substring(1):e}function dne(e,t){if(!Kv(e,`oneofIndex`)||e.proto3Optional)return;let n=t[e.oneofIndex];return kb(n,`invalid FieldDescriptorProto: oneof #${e.oneofIndex} for field #${e.number} not found`),n}function fne(e,t,n,r){if(e.label==2)return 3;if(e.label==3)return 2;if(t||e.proto3Optional||n)return 1;let i=Ob(`fieldPresence`,{proto:e,parent:r});return i==2&&(e.type==11||e.type==10)?1:i}function pne(e,t){if(e.label!=3)return!1;switch(e.type){case 9:case 12:case 10:case 11:return!1}let n=e.options;return n&&Kv(n,`packed`)?n.packed:Ob(`repeatedFieldEncoding`,{proto:e,parent:t})==1}function mne(e){let t=e.fields.find(e=>e.number===1),n=e.fields.find(e=>e.number===2);return kb(t&&t.fieldKind==`scalar`&&t.scalar!=N.BYTES&&t.scalar!=N.FLOAT&&t.scalar!=N.DOUBLE&&n&&n.fieldKind!=`list`&&n.fieldKind!=`map`),{key:t,value:n}}function hne(e){return Ob(`enumType`,{proto:e.proto,parent:e.parent??e.file})==1}function Db(e,t){return e.type==10||Ob(`messageEncoding`,{proto:e,parent:t})==2}function gne(e,t){return Ob(`utf8Validation`,{proto:e,parent:t})==2}function Ob(e,t){let n=t.proto.options?.features;if(n){let t=n[e];if(t!=0)return t}if(`kind`in t){if(t.kind==`message`)return Ob(e,t.parent??t.file);let n=vb[t.edition];if(!n)throw Error(`feature default for edition ${t.edition} not found`);return n[e]}return Ob(e,t.parent)}function kb(e,t){if(!e)throw Error(t)}function _ne(e){let t=vne(e);return t.messageType.forEach(hb),_b(t,()=>void 0).getFile(t.name)}function vne(e){return Object.assign(Object.create({syntax:``,edition:0}),Object.assign(Object.assign({$typeName:`google.protobuf.FileDescriptorProto`,dependency:[],publicDependency:[],weakDependency:[],optionDependency:[],service:[],extension:[]},e),{messageType:e.messageType.map(Ab),enumType:e.enumType.map(jb)}))}function Ab(e){return Object.assign(Object.create({visibility:0}),{$typeName:`google.protobuf.DescriptorProto`,name:e.name,field:e.field?.map(yne)??[],extension:[],nestedType:e.nestedType?.map(Ab)??[],enumType:e.enumType?.map(jb)??[],extensionRange:e.extensionRange?.map(e=>Object.assign({$typeName:`google.protobuf.DescriptorProto.ExtensionRange`},e))??[],oneofDecl:[],reservedRange:[],reservedName:[]})}function yne(e){return Object.assign(Object.create({label:1,typeName:``,extendee:``,defaultValue:``,oneofIndex:0,jsonName:``,proto3Optional:!1}),Object.assign(Object.assign({$typeName:`google.protobuf.FieldDescriptorProto`},e),{options:e.options?bne(e.options):void 0}))}function bne(e){return Object.assign(Object.create({ctype:0,packed:!1,jstype:0,lazy:!1,unverifiedLazy:!1,deprecated:!1,weak:!1,debugRedact:!1,retention:0}),Object.assign(Object.assign({$typeName:`google.protobuf.FieldOptions`},e),{targets:e.targets??[],editionDefaults:e.editionDefaults?.map(e=>Object.assign({$typeName:`google.protobuf.FieldOptions.EditionDefault`},e))??[],uninterpretedOption:[]}))}function jb(e){return Object.assign(Object.create({visibility:0}),{$typeName:`google.protobuf.EnumDescriptorProto`,name:e.name,reservedName:[],reservedRange:[],value:e.value.map(e=>Object.assign({$typeName:`google.protobuf.EnumValueDescriptorProto`},e))})}function Mb(e,t,...n){return n.reduce((e,t)=>e.nestedMessages[t],e.messages[t])}const xne=Mb(_ne({name:`google/protobuf/descriptor.proto`,package:`google.protobuf`,messageType:[{name:`FileDescriptorSet`,field:[{name:`file`,number:1,type:11,label:3,typeName:`.google.protobuf.FileDescriptorProto`}],extensionRange:[{start:536e6,end:536000001}]},{name:`FileDescriptorProto`,field:[{name:`name`,number:1,type:9,label:1},{name:`package`,number:2,type:9,label:1},{name:`dependency`,number:3,type:9,label:3},{name:`public_dependency`,number:10,type:5,label:3},{name:`weak_dependency`,number:11,type:5,label:3},{name:`option_dependency`,number:15,type:9,label:3},{name:`message_type`,number:4,type:11,label:3,typeName:`.google.protobuf.DescriptorProto`},{name:`enum_type`,number:5,type:11,label:3,typeName:`.google.protobuf.EnumDescriptorProto`},{name:`service`,number:6,type:11,label:3,typeName:`.google.protobuf.ServiceDescriptorProto`},{name:`extension`,number:7,type:11,label:3,typeName:`.google.protobuf.FieldDescriptorProto`},{name:`options`,number:8,type:11,label:1,typeName:`.google.protobuf.FileOptions`},{name:`source_code_info`,number:9,type:11,label:1,typeName:`.google.protobuf.SourceCodeInfo`},{name:`syntax`,number:12,type:9,label:1},{name:`edition`,number:14,type:14,label:1,typeName:`.google.protobuf.Edition`}]},{name:`DescriptorProto`,field:[{name:`name`,number:1,type:9,label:1},{name:`field`,number:2,type:11,label:3,typeName:`.google.protobuf.FieldDescriptorProto`},{name:`extension`,number:6,type:11,label:3,typeName:`.google.protobuf.FieldDescriptorProto`},{name:`nested_type`,number:3,type:11,label:3,typeName:`.google.protobuf.DescriptorProto`},{name:`enum_type`,number:4,type:11,label:3,typeName:`.google.protobuf.EnumDescriptorProto`},{name:`extension_range`,number:5,type:11,label:3,typeName:`.google.protobuf.DescriptorProto.ExtensionRange`},{name:`oneof_decl`,number:8,type:11,label:3,typeName:`.google.protobuf.OneofDescriptorProto`},{name:`options`,number:7,type:11,label:1,typeName:`.google.protobuf.MessageOptions`},{name:`reserved_range`,number:9,type:11,label:3,typeName:`.google.protobuf.DescriptorProto.ReservedRange`},{name:`reserved_name`,number:10,type:9,label:3},{name:`visibility`,number:11,type:14,label:1,typeName:`.google.protobuf.SymbolVisibility`}],nestedType:[{name:`ExtensionRange`,field:[{name:`start`,number:1,type:5,label:1},{name:`end`,number:2,type:5,label:1},{name:`options`,number:3,type:11,label:1,typeName:`.google.protobuf.ExtensionRangeOptions`}]},{name:`ReservedRange`,field:[{name:`start`,number:1,type:5,label:1},{name:`end`,number:2,type:5,label:1}]}]},{name:`ExtensionRangeOptions`,field:[{name:`uninterpreted_option`,number:999,type:11,label:3,typeName:`.google.protobuf.UninterpretedOption`},{name:`declaration`,number:2,type:11,label:3,typeName:`.google.protobuf.ExtensionRangeOptions.Declaration`,options:{retention:2}},{name:`features`,number:50,type:11,label:1,typeName:`.google.protobuf.FeatureSet`},{name:`verification`,number:3,type:14,label:1,typeName:`.google.protobuf.ExtensionRangeOptions.VerificationState`,defaultValue:`UNVERIFIED`,options:{retention:2}}],nestedType:[{name:`Declaration`,field:[{name:`number`,number:1,type:5,label:1},{name:`full_name`,number:2,type:9,label:1},{name:`type`,number:3,type:9,label:1},{name:`reserved`,number:5,type:8,label:1},{name:`repeated`,number:6,type:8,label:1}]}],enumType:[{name:`VerificationState`,value:[{name:`DECLARATION`,number:0},{name:`UNVERIFIED`,number:1}]}],extensionRange:[{start:990,end:999},{start:1e3,end:536870912}]},{name:`FieldDescriptorProto`,field:[{name:`name`,number:1,type:9,label:1},{name:`number`,number:3,type:5,label:1},{name:`label`,number:4,type:14,label:1,typeName:`.google.protobuf.FieldDescriptorProto.Label`},{name:`type`,number:5,type:14,label:1,typeName:`.google.protobuf.FieldDescriptorProto.Type`},{name:`type_name`,number:6,type:9,label:1},{name:`extendee`,number:2,type:9,label:1},{name:`default_value`,number:7,type:9,label:1},{name:`oneof_index`,number:9,type:5,label:1},{name:`json_name`,number:10,type:9,label:1},{name:`options`,number:8,type:11,label:1,typeName:`.google.protobuf.FieldOptions`},{name:`proto3_optional`,number:17,type:8,label:1}],enumType:[{name:`Type`,value:[{name:`TYPE_DOUBLE`,number:1},{name:`TYPE_FLOAT`,number:2},{name:`TYPE_INT64`,number:3},{name:`TYPE_UINT64`,number:4},{name:`TYPE_INT32`,number:5},{name:`TYPE_FIXED64`,number:6},{name:`TYPE_FIXED32`,number:7},{name:`TYPE_BOOL`,number:8},{name:`TYPE_STRING`,number:9},{name:`TYPE_GROUP`,number:10},{name:`TYPE_MESSAGE`,number:11},{name:`TYPE_BYTES`,number:12},{name:`TYPE_UINT32`,number:13},{name:`TYPE_ENUM`,number:14},{name:`TYPE_SFIXED32`,number:15},{name:`TYPE_SFIXED64`,number:16},{name:`TYPE_SINT32`,number:17},{name:`TYPE_SINT64`,number:18}]},{name:`Label`,value:[{name:`LABEL_OPTIONAL`,number:1},{name:`LABEL_REPEATED`,number:3},{name:`LABEL_REQUIRED`,number:2}]}]},{name:`OneofDescriptorProto`,field:[{name:`name`,number:1,type:9,label:1},{name:`options`,number:2,type:11,label:1,typeName:`.google.protobuf.OneofOptions`}]},{name:`EnumDescriptorProto`,field:[{name:`name`,number:1,type:9,label:1},{name:`value`,number:2,type:11,label:3,typeName:`.google.protobuf.EnumValueDescriptorProto`},{name:`options`,number:3,type:11,label:1,typeName:`.google.protobuf.EnumOptions`},{name:`reserved_range`,number:4,type:11,label:3,typeName:`.google.protobuf.EnumDescriptorProto.EnumReservedRange`},{name:`reserved_name`,number:5,type:9,label:3},{name:`visibility`,number:6,type:14,label:1,typeName:`.google.protobuf.SymbolVisibility`}],nestedType:[{name:`EnumReservedRange`,field:[{name:`start`,number:1,type:5,label:1},{name:`end`,number:2,type:5,label:1}]}]},{name:`EnumValueDescriptorProto`,field:[{name:`name`,number:1,type:9,label:1},{name:`number`,number:2,type:5,label:1},{name:`options`,number:3,type:11,label:1,typeName:`.google.protobuf.EnumValueOptions`}]},{name:`ServiceDescriptorProto`,field:[{name:`name`,number:1,type:9,label:1},{name:`method`,number:2,type:11,label:3,typeName:`.google.protobuf.MethodDescriptorProto`},{name:`options`,number:3,type:11,label:1,typeName:`.google.protobuf.ServiceOptions`}]},{name:`MethodDescriptorProto`,field:[{name:`name`,number:1,type:9,label:1},{name:`input_type`,number:2,type:9,label:1},{name:`output_type`,number:3,type:9,label:1},{name:`options`,number:4,type:11,label:1,typeName:`.google.protobuf.MethodOptions`},{name:`client_streaming`,number:5,type:8,label:1,defaultValue:`false`},{name:`server_streaming`,number:6,type:8,label:1,defaultValue:`false`}]},{name:`FileOptions`,field:[{name:`java_package`,number:1,type:9,label:1},{name:`java_outer_classname`,number:8,type:9,label:1},{name:`java_multiple_files`,number:10,type:8,label:1,defaultValue:`false`,options:{}},{name:`java_generate_equals_and_hash`,number:20,type:8,label:1,options:{deprecated:!0}},{name:`java_string_check_utf8`,number:27,type:8,label:1,defaultValue:`false`},{name:`optimize_for`,number:9,type:14,label:1,typeName:`.google.protobuf.FileOptions.OptimizeMode`,defaultValue:`SPEED`},{name:`go_package`,number:11,type:9,label:1},{name:`cc_generic_services`,number:16,type:8,label:1,defaultValue:`false`},{name:`java_generic_services`,number:17,type:8,label:1,defaultValue:`false`},{name:`py_generic_services`,number:18,type:8,label:1,defaultValue:`false`},{name:`deprecated`,number:23,type:8,label:1,defaultValue:`false`},{name:`cc_enable_arenas`,number:31,type:8,label:1,defaultValue:`true`,options:{}},{name:`objc_class_prefix`,number:36,type:9,label:1},{name:`csharp_namespace`,number:37,type:9,label:1},{name:`swift_prefix`,number:39,type:9,label:1},{name:`php_class_prefix`,number:40,type:9,label:1},{name:`php_namespace`,number:41,type:9,label:1},{name:`php_metadata_namespace`,number:44,type:9,label:1},{name:`ruby_package`,number:45,type:9,label:1},{name:`features`,number:50,type:11,label:1,typeName:`.google.protobuf.FeatureSet`},{name:`uninterpreted_option`,number:999,type:11,label:3,typeName:`.google.protobuf.UninterpretedOption`}],enumType:[{name:`OptimizeMode`,value:[{name:`SPEED`,number:1},{name:`CODE_SIZE`,number:2},{name:`LITE_RUNTIME`,number:3}]}],extensionRange:[{start:990,end:999},{start:1e3,end:536870912}]},{name:`MessageOptions`,field:[{name:`message_set_wire_format`,number:1,type:8,label:1,defaultValue:`false`},{name:`no_standard_descriptor_accessor`,number:2,type:8,label:1,defaultValue:`false`},{name:`deprecated`,number:3,type:8,label:1,defaultValue:`false`},{name:`map_entry`,number:7,type:8,label:1},{name:`deprecated_legacy_json_field_conflicts`,number:11,type:8,label:1,options:{deprecated:!0}},{name:`features`,number:12,type:11,label:1,typeName:`.google.protobuf.FeatureSet`},{name:`uninterpreted_option`,number:999,type:11,label:3,typeName:`.google.protobuf.UninterpretedOption`}],extensionRange:[{start:990,end:999},{start:1e3,end:536870912}]},{name:`FieldOptions`,field:[{name:`ctype`,number:1,type:14,label:1,typeName:`.google.protobuf.FieldOptions.CType`,defaultValue:`STRING`},{name:`packed`,number:2,type:8,label:1},{name:`jstype`,number:6,type:14,label:1,typeName:`.google.protobuf.FieldOptions.JSType`,defaultValue:`JS_NORMAL`},{name:`lazy`,number:5,type:8,label:1,defaultValue:`false`},{name:`unverified_lazy`,number:15,type:8,label:1,defaultValue:`false`},{name:`deprecated`,number:3,type:8,label:1,defaultValue:`false`},{name:`weak`,number:10,type:8,label:1,defaultValue:`false`,options:{deprecated:!0}},{name:`debug_redact`,number:16,type:8,label:1,defaultValue:`false`},{name:`retention`,number:17,type:14,label:1,typeName:`.google.protobuf.FieldOptions.OptionRetention`},{name:`targets`,number:19,type:14,label:3,typeName:`.google.protobuf.FieldOptions.OptionTargetType`},{name:`edition_defaults`,number:20,type:11,label:3,typeName:`.google.protobuf.FieldOptions.EditionDefault`},{name:`features`,number:21,type:11,label:1,typeName:`.google.protobuf.FeatureSet`},{name:`feature_support`,number:22,type:11,label:1,typeName:`.google.protobuf.FieldOptions.FeatureSupport`},{name:`uninterpreted_option`,number:999,type:11,label:3,typeName:`.google.protobuf.UninterpretedOption`}],nestedType:[{name:`EditionDefault`,field:[{name:`edition`,number:3,type:14,label:1,typeName:`.google.protobuf.Edition`},{name:`value`,number:2,type:9,label:1}]},{name:`FeatureSupport`,field:[{name:`edition_introduced`,number:1,type:14,label:1,typeName:`.google.protobuf.Edition`},{name:`edition_deprecated`,number:2,type:14,label:1,typeName:`.google.protobuf.Edition`},{name:`deprecation_warning`,number:3,type:9,label:1},{name:`edition_removed`,number:4,type:14,label:1,typeName:`.google.protobuf.Edition`},{name:`removal_error`,number:5,type:9,label:1}]}],enumType:[{name:`CType`,value:[{name:`STRING`,number:0},{name:`CORD`,number:1},{name:`STRING_PIECE`,number:2}]},{name:`JSType`,value:[{name:`JS_NORMAL`,number:0},{name:`JS_STRING`,number:1},{name:`JS_NUMBER`,number:2}]},{name:`OptionRetention`,value:[{name:`RETENTION_UNKNOWN`,number:0},{name:`RETENTION_RUNTIME`,number:1},{name:`RETENTION_SOURCE`,number:2}]},{name:`OptionTargetType`,value:[{name:`TARGET_TYPE_UNKNOWN`,number:0},{name:`TARGET_TYPE_FILE`,number:1},{name:`TARGET_TYPE_EXTENSION_RANGE`,number:2},{name:`TARGET_TYPE_MESSAGE`,number:3},{name:`TARGET_TYPE_FIELD`,number:4},{name:`TARGET_TYPE_ONEOF`,number:5},{name:`TARGET_TYPE_ENUM`,number:6},{name:`TARGET_TYPE_ENUM_ENTRY`,number:7},{name:`TARGET_TYPE_SERVICE`,number:8},{name:`TARGET_TYPE_METHOD`,number:9}]}],extensionRange:[{start:990,end:999},{start:1e3,end:536870912}]},{name:`OneofOptions`,field:[{name:`features`,number:1,type:11,label:1,typeName:`.google.protobuf.FeatureSet`},{name:`uninterpreted_option`,number:999,type:11,label:3,typeName:`.google.protobuf.UninterpretedOption`}],extensionRange:[{start:990,end:999},{start:1e3,end:536870912}]},{name:`EnumOptions`,field:[{name:`allow_alias`,number:2,type:8,label:1},{name:`deprecated`,number:3,type:8,label:1,defaultValue:`false`},{name:`deprecated_legacy_json_field_conflicts`,number:6,type:8,label:1,options:{deprecated:!0}},{name:`features`,number:7,type:11,label:1,typeName:`.google.protobuf.FeatureSet`},{name:`uninterpreted_option`,number:999,type:11,label:3,typeName:`.google.protobuf.UninterpretedOption`}],extensionRange:[{start:990,end:999},{start:1e3,end:536870912}]},{name:`EnumValueOptions`,field:[{name:`deprecated`,number:1,type:8,label:1,defaultValue:`false`},{name:`features`,number:2,type:11,label:1,typeName:`.google.protobuf.FeatureSet`},{name:`debug_redact`,number:3,type:8,label:1,defaultValue:`false`},{name:`feature_support`,number:4,type:11,label:1,typeName:`.google.protobuf.FieldOptions.FeatureSupport`},{name:`uninterpreted_option`,number:999,type:11,label:3,typeName:`.google.protobuf.UninterpretedOption`}],extensionRange:[{start:990,end:999},{start:1e3,end:536870912}]},{name:`ServiceOptions`,field:[{name:`features`,number:34,type:11,label:1,typeName:`.google.protobuf.FeatureSet`},{name:`deprecated`,number:33,type:8,label:1,defaultValue:`false`},{name:`uninterpreted_option`,number:999,type:11,label:3,typeName:`.google.protobuf.UninterpretedOption`}],extensionRange:[{start:990,end:999},{start:1e3,end:536870912}]},{name:`MethodOptions`,field:[{name:`deprecated`,number:33,type:8,label:1,defaultValue:`false`},{name:`idempotency_level`,number:34,type:14,label:1,typeName:`.google.protobuf.MethodOptions.IdempotencyLevel`,defaultValue:`IDEMPOTENCY_UNKNOWN`},{name:`features`,number:35,type:11,label:1,typeName:`.google.protobuf.FeatureSet`},{name:`uninterpreted_option`,number:999,type:11,label:3,typeName:`.google.protobuf.UninterpretedOption`}],enumType:[{name:`IdempotencyLevel`,value:[{name:`IDEMPOTENCY_UNKNOWN`,number:0},{name:`NO_SIDE_EFFECTS`,number:1},{name:`IDEMPOTENT`,number:2}]}],extensionRange:[{start:990,end:999},{start:1e3,end:536870912}]},{name:`UninterpretedOption`,field:[{name:`name`,number:2,type:11,label:3,typeName:`.google.protobuf.UninterpretedOption.NamePart`},{name:`identifier_value`,number:3,type:9,label:1},{name:`positive_int_value`,number:4,type:4,label:1},{name:`negative_int_value`,number:5,type:3,label:1},{name:`double_value`,number:6,type:1,label:1},{name:`string_value`,number:7,type:12,label:1},{name:`aggregate_value`,number:8,type:9,label:1}],nestedType:[{name:`NamePart`,field:[{name:`name_part`,number:1,type:9,label:2},{name:`is_extension`,number:2,type:8,label:2}]}]},{name:`FeatureSet`,field:[{name:`field_presence`,number:1,type:14,label:1,typeName:`.google.protobuf.FeatureSet.FieldPresence`,options:{retention:1,targets:[4,1],editionDefaults:[{value:`EXPLICIT`,edition:900},{value:`IMPLICIT`,edition:999},{value:`EXPLICIT`,edition:1e3}]}},{name:`enum_type`,number:2,type:14,label:1,typeName:`.google.protobuf.FeatureSet.EnumType`,options:{retention:1,targets:[6,1],editionDefaults:[{value:`CLOSED`,edition:900},{value:`OPEN`,edition:999}]}},{name:`repeated_field_encoding`,number:3,type:14,label:1,typeName:`.google.protobuf.FeatureSet.RepeatedFieldEncoding`,options:{retention:1,targets:[4,1],editionDefaults:[{value:`EXPANDED`,edition:900},{value:`PACKED`,edition:999}]}},{name:`utf8_validation`,number:4,type:14,label:1,typeName:`.google.protobuf.FeatureSet.Utf8Validation`,options:{retention:1,targets:[4,1],editionDefaults:[{value:`NONE`,edition:900},{value:`VERIFY`,edition:999}]}},{name:`message_encoding`,number:5,type:14,label:1,typeName:`.google.protobuf.FeatureSet.MessageEncoding`,options:{retention:1,targets:[4,1],editionDefaults:[{value:`LENGTH_PREFIXED`,edition:900}]}},{name:`json_format`,number:6,type:14,label:1,typeName:`.google.protobuf.FeatureSet.JsonFormat`,options:{retention:1,targets:[3,6,1],editionDefaults:[{value:`LEGACY_BEST_EFFORT`,edition:900},{value:`ALLOW`,edition:999}]}},{name:`enforce_naming_style`,number:7,type:14,label:1,typeName:`.google.protobuf.FeatureSet.EnforceNamingStyle`,options:{retention:2,targets:[1,2,3,4,5,6,7,8,9],editionDefaults:[{value:`STYLE_LEGACY`,edition:900},{value:`STYLE2024`,edition:1001},{value:`STYLE2026`,edition:1002}]}},{name:`default_symbol_visibility`,number:8,type:14,label:1,typeName:`.google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility`,options:{retention:2,targets:[1],editionDefaults:[{value:`EXPORT_ALL`,edition:900},{value:`EXPORT_TOP_LEVEL`,edition:1001},{value:`STRICT`,edition:1002}]}},{name:`enforce_proto_limits`,number:9,type:14,label:1,typeName:`.google.protobuf.FeatureSet.ProtoLimitsFeature.EnforceProtoLimits`,options:{retention:2,targets:[6,3,4,5],editionDefaults:[{value:`LEGACY_NO_EXPLICIT_LIMITS`,edition:900},{value:`PROTO_LIMITS2026`,edition:1002}]}}],nestedType:[{name:`VisibilityFeature`,enumType:[{name:`DefaultSymbolVisibility`,value:[{name:`DEFAULT_SYMBOL_VISIBILITY_UNKNOWN`,number:0},{name:`EXPORT_ALL`,number:1},{name:`EXPORT_TOP_LEVEL`,number:2},{name:`LOCAL_ALL`,number:3},{name:`STRICT`,number:4}]}]},{name:`ProtoLimitsFeature`,enumType:[{name:`EnforceProtoLimits`,value:[{name:`PROTO_LIMITS_UNKNOWN`,number:0},{name:`LEGACY_NO_EXPLICIT_LIMITS`,number:1},{name:`PROTO_LIMITS2026`,number:2}]}]}],enumType:[{name:`FieldPresence`,value:[{name:`FIELD_PRESENCE_UNKNOWN`,number:0},{name:`EXPLICIT`,number:1},{name:`IMPLICIT`,number:2},{name:`LEGACY_REQUIRED`,number:3}]},{name:`EnumType`,value:[{name:`ENUM_TYPE_UNKNOWN`,number:0},{name:`OPEN`,number:1},{name:`CLOSED`,number:2}]},{name:`RepeatedFieldEncoding`,value:[{name:`REPEATED_FIELD_ENCODING_UNKNOWN`,number:0},{name:`PACKED`,number:1},{name:`EXPANDED`,number:2}]},{name:`Utf8Validation`,value:[{name:`UTF8_VALIDATION_UNKNOWN`,number:0},{name:`VERIFY`,number:2},{name:`NONE`,number:3}]},{name:`MessageEncoding`,value:[{name:`MESSAGE_ENCODING_UNKNOWN`,number:0},{name:`LENGTH_PREFIXED`,number:1},{name:`DELIMITED`,number:2}]},{name:`JsonFormat`,value:[{name:`JSON_FORMAT_UNKNOWN`,number:0},{name:`ALLOW`,number:1},{name:`LEGACY_BEST_EFFORT`,number:2}]},{name:`EnforceNamingStyle`,value:[{name:`ENFORCE_NAMING_STYLE_UNKNOWN`,number:0},{name:`STYLE2024`,number:1},{name:`STYLE_LEGACY`,number:2},{name:`STYLE2026`,number:3}]}],extensionRange:[{start:1e3,end:9995},{start:9995,end:1e4},{start:1e4,end:10001}]},{name:`FeatureSetDefaults`,field:[{name:`defaults`,number:1,type:11,label:3,typeName:`.google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault`},{name:`minimum_edition`,number:4,type:14,label:1,typeName:`.google.protobuf.Edition`},{name:`maximum_edition`,number:5,type:14,label:1,typeName:`.google.protobuf.Edition`}],nestedType:[{name:`FeatureSetEditionDefault`,field:[{name:`edition`,number:3,type:14,label:1,typeName:`.google.protobuf.Edition`},{name:`overridable_features`,number:4,type:11,label:1,typeName:`.google.protobuf.FeatureSet`},{name:`fixed_features`,number:5,type:11,label:1,typeName:`.google.protobuf.FeatureSet`}]}]},{name:`SourceCodeInfo`,field:[{name:`location`,number:1,type:11,label:3,typeName:`.google.protobuf.SourceCodeInfo.Location`}],nestedType:[{name:`Location`,field:[{name:`path`,number:1,type:5,label:3,options:{packed:!0}},{name:`span`,number:2,type:5,label:3,options:{packed:!0}},{name:`leading_comments`,number:3,type:9,label:1},{name:`trailing_comments`,number:4,type:9,label:1},{name:`leading_detached_comments`,number:6,type:9,label:3}]}],extensionRange:[{start:536e6,end:536000001}]},{name:`GeneratedCodeInfo`,field:[{name:`annotation`,number:1,type:11,label:3,typeName:`.google.protobuf.GeneratedCodeInfo.Annotation`}],nestedType:[{name:`Annotation`,field:[{name:`path`,number:1,type:5,label:3,options:{packed:!0}},{name:`source_file`,number:2,type:9,label:1},{name:`begin`,number:3,type:5,label:1},{name:`end`,number:4,type:5,label:1},{name:`semantic`,number:5,type:14,label:1,typeName:`.google.protobuf.GeneratedCodeInfo.Annotation.Semantic`}],enumType:[{name:`Semantic`,value:[{name:`NONE`,number:0},{name:`SET`,number:1},{name:`ALIAS`,number:2}]}]}]}],enumType:[{name:`Edition`,value:[{name:`EDITION_UNKNOWN`,number:0},{name:`EDITION_LEGACY`,number:900},{name:`EDITION_PROTO2`,number:998},{name:`EDITION_PROTO3`,number:999},{name:`EDITION_2023`,number:1e3},{name:`EDITION_2024`,number:1001},{name:`EDITION_2026`,number:1002},{name:`EDITION_UNSTABLE`,number:9999},{name:`EDITION_1_TEST_ONLY`,number:1},{name:`EDITION_2_TEST_ONLY`,number:2},{name:`EDITION_99997_TEST_ONLY`,number:99997},{name:`EDITION_99998_TEST_ONLY`,number:99998},{name:`EDITION_99999_TEST_ONLY`,number:99999},{name:`EDITION_MAX`,number:2147483647}]},{name:`SymbolVisibility`,value:[{name:`VISIBILITY_UNSET`,number:0},{name:`VISIBILITY_LOCAL`,number:1},{name:`VISIBILITY_EXPORT`,number:2}]}]}),1);var Sne;(function(e){e[e.DECLARATION=0]=`DECLARATION`,e[e.UNVERIFIED=1]=`UNVERIFIED`})(Sne||={});var Cne;(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.GROUP=10]=`GROUP`,e[e.MESSAGE=11]=`MESSAGE`,e[e.BYTES=12]=`BYTES`,e[e.UINT32=13]=`UINT32`,e[e.ENUM=14]=`ENUM`,e[e.SFIXED32=15]=`SFIXED32`,e[e.SFIXED64=16]=`SFIXED64`,e[e.SINT32=17]=`SINT32`,e[e.SINT64=18]=`SINT64`})(Cne||={});var wne;(function(e){e[e.OPTIONAL=1]=`OPTIONAL`,e[e.REPEATED=3]=`REPEATED`,e[e.REQUIRED=2]=`REQUIRED`})(wne||={});var Tne;(function(e){e[e.SPEED=1]=`SPEED`,e[e.CODE_SIZE=2]=`CODE_SIZE`,e[e.LITE_RUNTIME=3]=`LITE_RUNTIME`})(Tne||={});var Ene;(function(e){e[e.STRING=0]=`STRING`,e[e.CORD=1]=`CORD`,e[e.STRING_PIECE=2]=`STRING_PIECE`})(Ene||={});var Dne;(function(e){e[e.JS_NORMAL=0]=`JS_NORMAL`,e[e.JS_STRING=1]=`JS_STRING`,e[e.JS_NUMBER=2]=`JS_NUMBER`})(Dne||={});var One;(function(e){e[e.RETENTION_UNKNOWN=0]=`RETENTION_UNKNOWN`,e[e.RETENTION_RUNTIME=1]=`RETENTION_RUNTIME`,e[e.RETENTION_SOURCE=2]=`RETENTION_SOURCE`})(One||={});var kne;(function(e){e[e.TARGET_TYPE_UNKNOWN=0]=`TARGET_TYPE_UNKNOWN`,e[e.TARGET_TYPE_FILE=1]=`TARGET_TYPE_FILE`,e[e.TARGET_TYPE_EXTENSION_RANGE=2]=`TARGET_TYPE_EXTENSION_RANGE`,e[e.TARGET_TYPE_MESSAGE=3]=`TARGET_TYPE_MESSAGE`,e[e.TARGET_TYPE_FIELD=4]=`TARGET_TYPE_FIELD`,e[e.TARGET_TYPE_ONEOF=5]=`TARGET_TYPE_ONEOF`,e[e.TARGET_TYPE_ENUM=6]=`TARGET_TYPE_ENUM`,e[e.TARGET_TYPE_ENUM_ENTRY=7]=`TARGET_TYPE_ENUM_ENTRY`,e[e.TARGET_TYPE_SERVICE=8]=`TARGET_TYPE_SERVICE`,e[e.TARGET_TYPE_METHOD=9]=`TARGET_TYPE_METHOD`})(kne||={});var Nb;(function(e){e[e.IDEMPOTENCY_UNKNOWN=0]=`IDEMPOTENCY_UNKNOWN`,e[e.NO_SIDE_EFFECTS=1]=`NO_SIDE_EFFECTS`,e[e.IDEMPOTENT=2]=`IDEMPOTENT`})(Nb||={});var Ane;(function(e){e[e.DEFAULT_SYMBOL_VISIBILITY_UNKNOWN=0]=`DEFAULT_SYMBOL_VISIBILITY_UNKNOWN`,e[e.EXPORT_ALL=1]=`EXPORT_ALL`,e[e.EXPORT_TOP_LEVEL=2]=`EXPORT_TOP_LEVEL`,e[e.LOCAL_ALL=3]=`LOCAL_ALL`,e[e.STRICT=4]=`STRICT`})(Ane||={});var jne;(function(e){e[e.PROTO_LIMITS_UNKNOWN=0]=`PROTO_LIMITS_UNKNOWN`,e[e.LEGACY_NO_EXPLICIT_LIMITS=1]=`LEGACY_NO_EXPLICIT_LIMITS`,e[e.PROTO_LIMITS2026=2]=`PROTO_LIMITS2026`})(jne||={});var Mne;(function(e){e[e.FIELD_PRESENCE_UNKNOWN=0]=`FIELD_PRESENCE_UNKNOWN`,e[e.EXPLICIT=1]=`EXPLICIT`,e[e.IMPLICIT=2]=`IMPLICIT`,e[e.LEGACY_REQUIRED=3]=`LEGACY_REQUIRED`})(Mne||={});var Nne;(function(e){e[e.ENUM_TYPE_UNKNOWN=0]=`ENUM_TYPE_UNKNOWN`,e[e.OPEN=1]=`OPEN`,e[e.CLOSED=2]=`CLOSED`})(Nne||={});var Pne;(function(e){e[e.REPEATED_FIELD_ENCODING_UNKNOWN=0]=`REPEATED_FIELD_ENCODING_UNKNOWN`,e[e.PACKED=1]=`PACKED`,e[e.EXPANDED=2]=`EXPANDED`})(Pne||={});var Fne;(function(e){e[e.UTF8_VALIDATION_UNKNOWN=0]=`UTF8_VALIDATION_UNKNOWN`,e[e.VERIFY=2]=`VERIFY`,e[e.NONE=3]=`NONE`})(Fne||={});var Ine;(function(e){e[e.MESSAGE_ENCODING_UNKNOWN=0]=`MESSAGE_ENCODING_UNKNOWN`,e[e.LENGTH_PREFIXED=1]=`LENGTH_PREFIXED`,e[e.DELIMITED=2]=`DELIMITED`})(Ine||={});var Lne;(function(e){e[e.JSON_FORMAT_UNKNOWN=0]=`JSON_FORMAT_UNKNOWN`,e[e.ALLOW=1]=`ALLOW`,e[e.LEGACY_BEST_EFFORT=2]=`LEGACY_BEST_EFFORT`})(Lne||={});var Rne;(function(e){e[e.ENFORCE_NAMING_STYLE_UNKNOWN=0]=`ENFORCE_NAMING_STYLE_UNKNOWN`,e[e.STYLE2024=1]=`STYLE2024`,e[e.STYLE_LEGACY=2]=`STYLE_LEGACY`,e[e.STYLE2026=3]=`STYLE2026`})(Rne||={});var zne;(function(e){e[e.NONE=0]=`NONE`,e[e.SET=1]=`SET`,e[e.ALIAS=2]=`ALIAS`})(zne||={});var Bne;(function(e){e[e.EDITION_UNKNOWN=0]=`EDITION_UNKNOWN`,e[e.EDITION_LEGACY=900]=`EDITION_LEGACY`,e[e.EDITION_PROTO2=998]=`EDITION_PROTO2`,e[e.EDITION_PROTO3=999]=`EDITION_PROTO3`,e[e.EDITION_2023=1e3]=`EDITION_2023`,e[e.EDITION_2024=1001]=`EDITION_2024`,e[e.EDITION_2026=1002]=`EDITION_2026`,e[e.EDITION_UNSTABLE=9999]=`EDITION_UNSTABLE`,e[e.EDITION_1_TEST_ONLY=1]=`EDITION_1_TEST_ONLY`,e[e.EDITION_2_TEST_ONLY=2]=`EDITION_2_TEST_ONLY`,e[e.EDITION_99997_TEST_ONLY=99997]=`EDITION_99997_TEST_ONLY`,e[e.EDITION_99998_TEST_ONLY=99998]=`EDITION_99998_TEST_ONLY`,e[e.EDITION_99999_TEST_ONLY=99999]=`EDITION_99999_TEST_ONLY`,e[e.EDITION_MAX=2147483647]=`EDITION_MAX`})(Bne||={});var Vne;(function(e){e[e.VISIBILITY_UNSET=0]=`VISIBILITY_UNSET`,e[e.VISIBILITY_LOCAL=1]=`VISIBILITY_LOCAL`,e[e.VISIBILITY_EXPORT=2]=`VISIBILITY_EXPORT`})(Vne||={});function Pb(e){return Object.assign(Object.assign({readUnknownFields:!0,recursionLimit:100},e),{depth:0})}function Fb(e,t,n){let r=sy(e);return Lb(e).read(r,new ky(t),Pb(n),t.byteLength),r}const Ib=new WeakMap;function Lb(e){let t=Ib.get(e);return t===void 0&&(t=Hne(e)),t}function Hne(e){let t=String(e),n=new Map,r={read:Une(t,n),readGroup:Wne(t,n)};Ib.set(e,r);for(let t of e.fields)n.set(t.number,Rb(t));return r}function Une(e,t){return(n,r,i,a)=>{if(++i.depth>i.recursionLimit)throw Error(`cannot decode ${e} from binary: maximum recursion depth of ${i.recursionLimit} reached`);let o=r.pos+a,s=n.$unknown??[];for(;r.pos<o;){let[e,a]=r.tag(),o=t.get(e);if(o===void 0){let t=r.skip(a,e,i.recursionLimit-i.depth);i.readUnknownFields&&s.push({no:e,wireType:a,data:t});continue}o(n,r,i,a)}s.length>0&&(n.$unknown=s),i.depth--}}function Wne(e,t){return(n,r,i,a)=>{if(++i.depth>i.recursionLimit)throw Error(`cannot decode ${e} from binary: maximum recursion depth of ${i.recursionLimit} reached`);let o,s,c=n.$unknown??[];for(;r.pos<r.len&&([o,s]=r.tag(),s!=wy.EndGroup);){let e=t.get(o);if(e===void 0){let e=r.skip(s,o,i.recursionLimit-i.depth);i.readUnknownFields&&c.push({no:o,wireType:s,data:e});continue}e(n,r,i,s)}if(s!=wy.EndGroup||o!==a)throw Error(`invalid end group tag`);c.length>0&&(n.$unknown=c),i.depth--}}function Gne(e,t,n,r,i){Rb(n)(e[Uv],t,i,r)}function Rb(e){switch(e.fieldKind){case`scalar`:return Kne(e);case`enum`:return qne(e);case`message`:return Jne(e);case`list`:return Yne(e);case`map`:return Xne(e)}}function Kne(e){let t=Bb(e.scalar,e.utf8Validation,e.longAsString),n=e.localName;if(e.oneof){let r=e.oneof.localName;return(e,i)=>{e[r]={case:n,value:t(i)}}}return(e,r)=>{e[n]=t(r)}}function qne(e){let t=e.localName,n=e.oneof?.localName;if(e.enum.open)return n===void 0?(e,n)=>{e[t]=n.int32()}:(e,r)=>{e[n]={case:t,value:r.int32()}};let r=e.enum.values,i=e.number;return(e,a,o,s)=>{let c=a.int32();if(r.some(e=>e.number===c))n===void 0?e[t]=c:e[n]={case:t,value:c};else if(o.readUnknownFields){let t=[];Fv(c,t);let n=e.$unknown??[];n.push({no:i,wireType:s,data:new Uint8Array(t)}),e.$unknown=n}}}function Jne(e){let t=e.localName,{toMessage:n,toLocal:r}=Vy(e),i=zb(e);if(e.oneof){let a=e.oneof.localName;return(e,o,s)=>{let c=e[a],l=n(c.case===t?c.value:void 0);i(l,o,s),e[a]={case:t,value:r(l)}}}return(e,a,o)=>{let s=n(e[t]);i(s,a,o),e[t]=r(s)}}function zb(e){let t=Lb(e.message);if(e.delimitedEncoding){let n=e.number;return(e,r,i)=>t.readGroup(e,r,i,n)}return(e,n,r)=>t.read(e,n,r,n.uint32())}function Yne(e){let t=e.localName;if(e.listKind==`message`){let{toMessage:n,toLocal:r}=Vy(e),i=zb(e);return(e,a,o)=>{let s=n(void 0);i(s,a,o),e[t].push(r(s))}}let n=e.listKind==`enum`?N.INT32:e.scalar,r=e.listKind==`scalar`&&e.longAsString,i=Bb(n,e.utf8Validation,r),a=n!=N.STRING&&n!=N.BYTES;return(e,n,r,o)=>{let s=e[t];if(o==wy.LengthDelimited&&a){let e=n.uint32()+n.pos;for(;n.pos<e;)s.push(i(n))}else s.push(i(n))}}function Xne(e){let t=e.localName,n=Bb(e.mapKey,e.utf8Validation,!1),r=Vv(e.mapKey,!1),i,a;switch(e.mapKind){case`scalar`:{let t=e.scalar,n=Bb(t,e.utf8Validation,!1);if(i=e=>n(e),t==N.BYTES)a=()=>new Uint8Array;else{let e=Vv(t,!1);a=()=>e}break}case`enum`:{let t=e.enum.values[0].number;i=e=>e.int32(),a=()=>t;break}case`message`:{let{toMessage:t,toLocal:n}=Vy(e),r=Lb(e.message).read;i=(e,i,a)=>{let o=t(a);return r(o,e,i,e.uint32()),n(o)},a=()=>n(t(void 0));break}}return(e,o,s)=>{let c=e[t],l,u,d=o.uint32(),f=o.pos+d;for(;o.pos<f;){let[e,t]=o.tag();switch(e){case 1:l=n(o);break;case 2:u=i(o,s,u);break;default:o.skip(t,e,s.recursionLimit-s.depth)}}l===void 0&&(l=r),u===void 0&&(u=a()),Yv(c,l,u)}}function Bb(e,t,n){switch(e){case N.STRING:return e=>e.string(t);case N.BOOL:return e=>e.bool();case N.DOUBLE:return e=>e.double();case N.FLOAT:return e=>e.float();case N.INT32:return e=>e.int32();case N.INT64:return n?e=>String(e.int64()):e=>e.int64();case N.UINT64:return n?e=>String(e.uint64()):e=>e.uint64();case N.FIXED64:return n?e=>String(e.fixed64()):e=>e.fixed64();case N.BYTES:return e=>e.bytes();case N.FIXED32:return e=>e.fixed32();case N.SFIXED32:return e=>e.sfixed32();case N.SFIXED64:return n?e=>String(e.sfixed64()):e=>e.sfixed64();case N.SINT64:return n?e=>String(e.sint64()):e=>e.sint64();case N.UINT32:return e=>e.uint32();case N.SINT32:return e=>e.sint32()}}function Vb(e,t){let n=Fb(xne,ab(e));return n.messageType.forEach(hb),n.dependency=t?.map(e=>e.proto.name)??[],_b(n,e=>t?.find(t=>t.proto.name===e)).getFile(n.name)}const Zne=Vb(`Ch9nb29nbGUvcHJvdG9idWYvdGltZXN0YW1wLnByb3RvEg9nb29nbGUucHJvdG9idWYiKwoJVGltZXN0YW1wEg8KB3NlY29uZHMYASABKAMSDQoFbmFub3MYAiABKAVChQEKE2NvbS5nb29nbGUucHJvdG9idWZCDlRpbWVzdGFtcFByb3RvUAFaMmdvb2dsZS5nb2xhbmcub3JnL3Byb3RvYnVmL3R5cGVzL2tub3duL3RpbWVzdGFtcHBi+AEBogIDR1BCqgIeR29vZ2xlLlByb3RvYnVmLldlbGxLbm93blR5cGVzYgZwcm90bzM`),Qne=Mb(Vb(`Chlnb29nbGUvcHJvdG9idWYvYW55LnByb3RvEg9nb29nbGUucHJvdG9idWYiJgoDQW55EhAKCHR5cGVfdXJsGAEgASgJEg0KBXZhbHVlGAIgASgMQnYKE2NvbS5nb29nbGUucHJvdG9idWZCCEFueVByb3RvUAFaLGdvb2dsZS5nb2xhbmcub3JnL3Byb3RvYnVmL3R5cGVzL2tub3duL2FueXBiogIDR1BCqgIeR29vZ2xlLlByb3RvYnVmLldlbGxLbm93blR5cGVzYgZwcm90bzM`),0),Hb={writeUnknownFields:!0};function $ne(e){return e?Object.assign(Object.assign({},Hb),e):Hb}function Ub(e,t,n){let r=new Ty;return Gb(e)(r,$ne(n),t),r.finish()}const Wb=new WeakMap;function Gb(e){let t=Wb.get(e);return t===void 0&&(t=ere(e)),t}function ere(e){let t=e.typeName,n=e.fields.concat().sort((e,t)=>e.number-t.number),r=n[0],i=[],a=(e,n,a)=>{if(a.$typeName!==t&&r!==void 0)throw new vy(r,`cannot use ${r} with message ${a.$typeName}`,`ForeignFieldError`);for(let t=0;t<i.length;t++)i[t](e,n,a);let o=a.$unknown;if(o!==void 0&&n.writeUnknownFields)for(let t=0;t<o.length;t++){let{no:n,wireType:r,data:i}=o[t];e.tag(n,r).raw(i)}};Wb.set(e,a);for(let e of n)i.push(Kb(e));return a}function Kb(e){switch(e.fieldKind){case`message`:case`scalar`:case`enum`:return tre(e);case`list`:return Jb(e);case`map`:return Yb(e)}}function tre(e){let t=qb(e),n=e.localName;if(e.oneof){let r=e.oneof.localName;return(e,i,a)=>{let o=a[r];o.case===n&&t(e,i,o.value)}}if(e.presence!=2){let r=e.presence==3?`cannot encode ${e} to binary: required field not set`:void 0;return(e,i,a)=>{let o=a[n];if(o!==void 0&&Object.prototype.hasOwnProperty.call(a,n))t(e,i,o);else if(r!==void 0)throw Error(r)}}if(e.fieldKind==`enum`){let r=e.enum.values[0].number;return(e,i,a)=>{let o=a[n];o!==r&&t(e,i,o)}}switch(e.scalar){case N.BOOL:return(e,r,i)=>{let a=i[n];a!==!1&&t(e,r,a)};case N.STRING:return(e,r,i)=>{let a=i[n];a!==``&&t(e,r,a)};case N.BYTES:return(e,r,i)=>{let a=i[n];(!(a instanceof Uint8Array)||a.byteLength>0)&&t(e,r,a)};case N.DOUBLE:case N.FLOAT:return(e,r,i)=>{let a=i[n];Object.is(a,0)||t(e,r,a)};default:return(e,r,i)=>{let a=i[n];a!=0&&t(e,r,a)}}}function qb(e){switch(e.fieldKind){case`message`:{let{toMessage:t}=Vy(e),n=$b(e);return(e,r,i)=>{n(e,r,t(i))}}case`scalar`:case`enum`:{let t=e.fieldKind==`enum`?N.INT32:e.scalar,n=e.number,r=ex(t),i=Qb(t,e.parent.typeName,e.name);return(e,t,a)=>{e.tag(n,r),i(e,a)}}}}function Jb(e){let t=e.localName,n=e.number;switch(e.listKind){case`message`:{let{toMessage:n}=Vy(e),r=$b(e);return(e,i,a)=>{let o=a[t];for(let t=0;t<o.length;t++)r(e,i,n(o[t]))}}case`scalar`:case`enum`:{let r=e.listKind==`enum`?N.INT32:e.scalar,i=Qb(r,e.parent.typeName,e.name);if(e.packed)return(e,r,a)=>{let o=a[t];if(o.length!=0){e.tag(n,wy.LengthDelimited).fork();for(let t=0;t<o.length;t++)i(e,o[t]);e.join()}};let a=ex(r);return(e,r,o)=>{let s=o[t];for(let t=0;t<s.length;t++)e.tag(n,a),i(e,s[t])}}}}function Yb(e){let t=e.localName,n=e.number,r=Xb(e);if(e.mapKind==`message`){let{toMessage:i}=Vy(e),a=Gb(e.message);return(e,o,s)=>{let c=s[t],l=Object.keys(c);for(let t=0;t<l.length;t++){let s=l[t];e.tag(n,wy.LengthDelimited).fork(),r(e,s),e.tag(2,wy.LengthDelimited).fork(),a(e,o,i(c[s])),e.join(),e.join()}}}let i=e.mapKind==`enum`?N.INT32:e.scalar,a=ex(i),o=Qb(i,e.parent.typeName,e.name);return(e,i,s)=>{let c=s[t],l=Object.keys(c);for(let t=0;t<l.length;t++){let i=l[t];e.tag(n,wy.LengthDelimited).fork(),r(e,i),e.tag(2,a),o(e,c[i]),e.join()}}}function Xb(e){let t=ex(e.mapKey),n=Qb(e.mapKey,e.parent.typeName,e.name),r=Zb(e.mapKey);return(e,i)=>{e.tag(1,t),n(e,r(i))}}function Zb(e){switch(e){case N.STRING:return e=>e;case N.BOOL:return e=>e===`true`||e!==`false`&&e;case N.UINT64:case N.FIXED64:return e=>{try{return Lv.uParse(e)}catch{return e}};case N.INT64:case N.SFIXED64:case N.SINT64:return e=>{try{return Lv.parse(e)}catch{return e}};default:return e=>{let t=Number.parseInt(e);return Number.isFinite(t)?t:e}}}function Qb(e,t,n){let r=nre(e);return(e,i)=>{try{r(e,i)}catch(e){throw e instanceof Error?Error(`cannot encode field ${t}.${n} to binary: ${e.message}`):e}}}function nre(e){switch(e){case N.STRING:return(e,t)=>e.string(t);case N.BOOL:return(e,t)=>e.bool(t);case N.DOUBLE:return(e,t)=>e.double(t);case N.FLOAT:return(e,t)=>e.float(t);case N.INT32:return(e,t)=>e.int32(t);case N.INT64:return(e,t)=>e.int64(t);case N.UINT64:return(e,t)=>e.uint64(t);case N.FIXED64:return(e,t)=>e.fixed64(t);case N.BYTES:return(e,t)=>e.bytes(t);case N.FIXED32:return(e,t)=>e.fixed32(t);case N.SFIXED32:return(e,t)=>e.sfixed32(t);case N.SFIXED64:return(e,t)=>e.sfixed64(t);case N.SINT64:return(e,t)=>e.sint64(t);case N.UINT32:return(e,t)=>e.uint32(t);case N.SINT32:return(e,t)=>e.sint32(t)}}function rre(e,t,n,r){Kb(r)(e,t,n[Uv])}function $b(e){let t=e.number,n=Gb(e.message);return e.delimitedEncoding?(e,r,i)=>{e.tag(t,wy.StartGroup),n(e,r,i),e.tag(t,wy.EndGroup)}:(e,r,i)=>{e.tag(t,wy.LengthDelimited).fork(),n(e,r,i),e.join()}}function ex(e){switch(e){case N.BYTES:case N.STRING:return wy.LengthDelimited;case N.DOUBLE:case N.FIXED64:case N.SFIXED64:return wy.Bit64;case N.FIXED32:case N.SFIXED32:case N.FLOAT:return wy.Bit32;default:return wy.Varint}}function tx(e,t,n){let r=!1;return n||(n=sy(Qne),r=!0),n.value=Ub(e,t),n.typeUrl=ix(t.$typeName),r?n:void 0}function nx(e,t){return e.typeUrl!==``&&(typeof t==`string`?t:t.typeName)===ax(e.typeUrl)}function rx(e,t){if(e.typeUrl===``)return;let n=t.kind==`message`?t:t.getMessage(ax(e.typeUrl));if(n&&nx(e,n))return Fb(n,e.value)}function ix(e){return`type.googleapis.com/${e}`}function ax(e){let t=e.lastIndexOf(`/`),n=t>=0?e.substring(t+1):e;if(!n.length)throw Error(`invalid type url: ${e}`);return n}const ox=Vb(`Chxnb29nbGUvcHJvdG9idWYvc3RydWN0LnByb3RvEg9nb29nbGUucHJvdG9idWYihAEKBlN0cnVjdBIzCgZmaWVsZHMYASADKAsyIy5nb29nbGUucHJvdG9idWYuU3RydWN0LkZpZWxkc0VudHJ5GkUKC0ZpZWxkc0VudHJ5EgsKA2tleRgBIAEoCRIlCgV2YWx1ZRgCIAEoCzIWLmdvb2dsZS5wcm90b2J1Zi5WYWx1ZToCOAEi6gEKBVZhbHVlEjAKCm51bGxfdmFsdWUYASABKA4yGi5nb29nbGUucHJvdG9idWYuTnVsbFZhbHVlSAASFgoMbnVtYmVyX3ZhbHVlGAIgASgBSAASFgoMc3RyaW5nX3ZhbHVlGAMgASgJSAASFAoKYm9vbF92YWx1ZRgEIAEoCEgAEi8KDHN0cnVjdF92YWx1ZRgFIAEoCzIXLmdvb2dsZS5wcm90b2J1Zi5TdHJ1Y3RIABIwCgpsaXN0X3ZhbHVlGAYgASgLMhouZ29vZ2xlLnByb3RvYnVmLkxpc3RWYWx1ZUgAQgYKBGtpbmQiMwoJTGlzdFZhbHVlEiYKBnZhbHVlcxgBIAMoCzIWLmdvb2dsZS5wcm90b2J1Zi5WYWx1ZSobCglOdWxsVmFsdWUSDgoKTlVMTF9WQUxVRRAAQn8KE2NvbS5nb29nbGUucHJvdG9idWZCC1N0cnVjdFByb3RvUAFaL2dvb2dsZS5nb2xhbmcub3JnL3Byb3RvYnVmL3R5cGVzL2tub3duL3N0cnVjdHBi+AEBogIDR1BCqgIeR29vZ2xlLlByb3RvYnVmLldlbGxLbm93blR5cGVzYgZwcm90bzM`),sx=Mb(ox,0),cx=Mb(ox,1),lx=Mb(ox,2);var ux;(function(e){e[e.NULL_VALUE=0]=`NULL_VALUE`})(ux||={});function dx(e,t,n){hx(t,e);let r=px(e.$unknown,t),[i,a,o]=mx(t),s=Pb(n);for(let e of r)Gne(i,new ky(e.data),a,e.wireType,s);return o()}function fx(e,t,n){hx(t,e);let r=(e.$unknown??[]).filter(e=>e.no!==t.number),[i,a]=mx(t,n),o=new Ty;rre(o,{writeUnknownFields:!0},i,a);let s=new ky(o.finish());for(;s.pos<s.len;){let[e,t]=s.tag(),n=s.skip(t,e);r.push({no:e,wireType:t,data:n})}e.$unknown=r}function px(e,t){if(e===void 0)return[];if(t.fieldKind===`enum`||t.fieldKind===`scalar`){for(let n=e.length-1;n>=0;--n)if(e[n].no==t.number)return[e[n]];return[]}return e.filter(e=>e.no===t.number)}function mx(e,t){let n=e.typeName,r=Object.assign(Object.assign({},e),{kind:`field`,parent:e.extendee,localName:n}),i=Object.assign(Object.assign({},e.extendee),{fields:[r],members:[r],oneofs:[]}),a=sy(i,t===void 0?void 0:{[n]:t});return[Wte(i,a),r,()=>{let t=a[n];if(t===void 0){let t=e.message;return ry(t)?Vv(t.fields[0].scalar,t.fields[0].longAsString):sy(t)}return t}]}function hx(e,t){if(e.extendee.typeName!=t.$typeName)throw Error(`extension ${e.typeName} can only be applied to message ${e.extendee.typeName}`)}const gx=Date.parse(`0001-01-01T00:00:00Z`),_x=Date.parse(`9999-12-31T23:59:59Z`),vx={alwaysEmitImplicit:!1,enumAsInteger:!1,useProtoFieldName:!1};function ire(e){return e?Object.assign(Object.assign({},vx),e):vx}function yx(e,t,n){return xx(e)(ire(n),t)}function are(e,t,n){let r=yx(e,t,n);return JSON.stringify(r,null,n?.prettySpaces??0)}const bx=new WeakMap;function xx(e){let t=bx.get(e);return t===void 0&&(t=ore(e)),t}function ore(e){let t=e.typeName,n=Cx(e);if(n!==void 0){let r=e.fields[0],i=(e,i)=>{if(i.$typeName!==t&&r!==void 0)throw new vy(r,`cannot use ${r} with message ${i.$typeName}`,`ForeignFieldError`);return n(e,i)};return bx.set(e,i),i}let r=e.fields.concat().sort((e,t)=>e.number-t.number),i=r[0],a=[],o=(n,r)=>{if(r.$typeName!==t&&i!==void 0)throw new vy(i,`cannot use ${i} with message ${r.$typeName}`,`ForeignFieldError`);let o={};for(let e=0;e<a.length;e++)a[e](n,r,o);return n.registry&&Lx(o,n,n.registry,r,e),o};bx.set(e,o);for(let e of r){let t=wx(e);a.push(e.jsonName===`__proto__`||e.name===`__proto__`?Sx(t):t)}return o}function Sx(e){return(t,n,r)=>{let i=Object.create(null);e(t,n,i);for(let e of Object.keys(i))Yv(r,e,i[e])}}function Cx(e){if(e.typeName.startsWith(`google.protobuf.`))switch(e.typeName){case`google.protobuf.Any`:return(e,t)=>Rx(t,e);case`google.protobuf.Timestamp`:return(e,t)=>Wx(t);case`google.protobuf.Duration`:return(e,t)=>zx(t);case`google.protobuf.FieldMask`:return(e,t)=>Bx(t);case`google.protobuf.Struct`:return(e,t)=>Vx(t);case`google.protobuf.Value`:return(e,t)=>Hx(t);case`google.protobuf.ListValue`:return(e,t)=>Ux(t);default:if(ry(e)){let t=e.fields[0],n=t.localName,r=Vv(t.scalar,!1),i=Fx(t);return(e,t)=>{let a=t[n];return i(e,a===void 0?r:a)}}return}}function wx(e){switch(e.fieldKind){case`scalar`:case`enum`:case`message`:return Tx(e);case`list`:case`map`:{let t=e.fieldKind==`list`?kx(e):jx(e),n=e.name,r=e.jsonName,i=e.localName;return(e,a,o)=>{let s=t(e,a[i]);s!==void 0&&(o[e.useProtoFieldName?n:r]=s)}}}}function Tx(e){let t=Dx(e),n=e.name,r=e.jsonName,i=e.localName;if(e.oneof){let a=e.oneof.localName;return(e,o,s)=>{let c=o[a];c.case===i&&(s[e.useProtoFieldName?n:r]=t(e,c.value))}}if(e.presence!=2){let a=e.presence==3?`cannot encode ${e} to JSON: required field not set`:void 0;return(e,o,s)=>{let c=o[i];if(c!==void 0&&Object.prototype.hasOwnProperty.call(o,i))s[e.useProtoFieldName?n:r]=t(e,c);else if(a!==void 0)throw Error(a)}}if(e.fieldKind==`enum`){let a=e.enum.values[0].number;return(e,o,s)=>{let c=o[i];(c!==a||e.alwaysEmitImplicit)&&(s[e.useProtoFieldName?n:r]=t(e,c))}}switch(e.scalar){case N.BOOL:return(e,a,o)=>{let s=a[i];(s!==!1||e.alwaysEmitImplicit)&&(o[e.useProtoFieldName?n:r]=t(e,s))};case N.STRING:return(e,a,o)=>{let s=a[i];(s!==``||e.alwaysEmitImplicit)&&(o[e.useProtoFieldName?n:r]=t(e,s))};case N.BYTES:return(e,a,o)=>{let s=a[i];(!(s instanceof Uint8Array)||s.byteLength>0||e.alwaysEmitImplicit)&&(o[e.useProtoFieldName?n:r]=t(e,s))};case N.DOUBLE:case N.FLOAT:return(e,a,o)=>{let s=a[i];(!Object.is(s,0)||e.alwaysEmitImplicit)&&(o[e.useProtoFieldName?n:r]=t(e,s))};default:return(e,a,o)=>{let s=a[i];(s!=0||e.alwaysEmitImplicit)&&(o[e.useProtoFieldName?n:r]=t(e,s))}}}function Ex(e){switch(e.fieldKind){case`scalar`:case`enum`:case`message`:return Dx(e);case`list`:return kx(e);case`map`:return jx(e)}}function Dx(e){switch(e.fieldKind){case`scalar`:return Fx(e);case`enum`:return Nx(e);case`message`:return Ox(e)}}function Ox(e){let{toMessage:t}=Vy(e),n=xx(e.message);return(e,r)=>n(e,t(r))}function kx(e){let t=Ax(e);return(e,n)=>{let r=n;if(r.length==0&&!e.alwaysEmitImplicit)return;let i=[];for(let n=0;n<r.length;n++)i.push(t(e,r[n]));return i}}function Ax(e){switch(e.listKind){case`scalar`:return Fx(e);case`enum`:return Nx(e);case`message`:return Ox(e)}}function jx(e){let t=Mx(e);return(e,n)=>{let r=n,i=Object.keys(r);if(i.length==0&&!e.alwaysEmitImplicit)return;let a={};for(let n=0;n<i.length;n++){let o=i[n];Yv(a,o,t(e,r[o]))}return a}}function Mx(e){switch(e.mapKind){case`scalar`:return Fx(e);case`enum`:return Nx(e);case`message`:return Ox(e)}}function Nx(e){let t=e.enum;return t.typeName==`google.protobuf.NullValue`?(e,n)=>{if(typeof n!=`number`)throw Px(t,n);return null}:(e,n)=>{if(typeof n!=`number`)throw Px(t,n);return e.enumAsInteger?n:t.value[n]?.jsonName??n}}function Px(e,t){return Error(`cannot encode ${e} to JSON: expected number, got ${Ly(t)}`)}function Fx(e){switch(e.scalar){case N.INT32:case N.SFIXED32:case N.SINT32:case N.FIXED32:case N.UINT32:return(t,n)=>{if(typeof n!=`number`)throw Ix(e,n);return n};case N.FLOAT:case N.DOUBLE:return(t,n)=>{if(typeof n!=`number`)throw Ix(e,n);return Number.isNaN(n)?`NaN`:n===1/0?`Infinity`:n===-1/0?`-Infinity`:n};case N.STRING:return(t,n)=>{if(typeof n!=`string`)throw Ix(e,n);return n};case N.BOOL:return(t,n)=>{if(typeof n!=`boolean`)throw Ix(e,n);return n};case N.UINT64:case N.FIXED64:case N.INT64:case N.SFIXED64:case N.SINT64:return(t,n)=>{if(typeof n==`bigint`||typeof n==`string`||typeof n==`number`&&Number.isInteger(n))return n.toString();throw Ix(e,n)};case N.BYTES:return(t,n)=>{if(n instanceof Uint8Array)return sb(n);throw Ix(e,n)}}}function Ix(e,t){return Error(`cannot encode ${e} to JSON: ${My(e,t)?.message}`)}function Lx(e,t,n,r,i){let a=r.$unknown;if(a===void 0)return;let o=new Set;for(let s=0;s<a.length;s++){let{no:c}=a[s];if(!o.has(c)){o.add(c);let a=n.getExtensionFor(i,c);if(!a)continue;let[s,l]=mx(a,dx(r,a)),u=s[Uv],d=Ex(l)(t,u[l.localName]);d!==void 0&&(e[a.jsonName]=d)}}}function Rx(e,t){if(e.typeUrl===``)return{};let{registry:n}=t,r,i;if(n&&(r=rx(e,n),r&&(i=n.getMessage(r.$typeName))),!i||!r)throw Error(`cannot encode message ${e.$typeName} to JSON: "${e.typeUrl}" is not in the type registry`);let a=iy(i)?{value:xx(i)(t,r)}:xx(i)(t,r);return a[`@type`]=e.typeUrl,a}function zx(e){let t=Number(e.seconds),n=e.nanos;if(t>315576e6||t<-315576e6)throw Error(`cannot encode message ${e.$typeName} to JSON: value out of range`);if(t>0&&n<0||t<0&&n>0)throw Error(`cannot encode message ${e.$typeName} to JSON: nanos sign must match seconds sign`);let r=e.seconds.toString();if(n!==0){let e=Math.abs(n).toString();e=`0`.repeat(9-e.length)+e,e.substring(3)===`000000`?e=e.substring(0,3):e.substring(6)===`000`&&(e=e.substring(0,6)),r+=`.`+e,n<0&&t==0&&(r=`-`+r)}return r+`s`}function Bx(e){return e.paths.map(t=>{if(pb(fb(t))!==t)throw Error(`cannot encode message ${e.$typeName} to JSON: lowerCamelCase of path name "${t}" is irreversible`);return fb(t)}).join(`,`)}function Vx(e){let t={},n=Object.keys(e.fields);for(let r=0;r<n.length;r++){let i=n[r];Yv(t,i,Hx(e.fields[i]))}return t}function Hx(e){switch(e.kind.case){case`nullValue`:return null;case`numberValue`:if(!Number.isFinite(e.kind.value))throw Error(`${e.$typeName} cannot be NaN or Infinity`);return e.kind.value;case`boolValue`:return e.kind.value;case`stringValue`:return e.kind.value;case`structValue`:return Vx(e.kind.value);case`listValue`:return Ux(e.kind.value);default:throw Error(`${e.$typeName} must have a value`)}}function Ux(e){return e.values.map(Hx)}function Wx(e){let t=Number(e.seconds)*1e3;if(t<gx||t>_x)throw Error(`cannot encode message ${e.$typeName} to JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive`);if(e.nanos<0)throw Error(`cannot encode message ${e.$typeName} to JSON: nanos must not be negative`);if(e.nanos>999999999)throw Error(`cannot encode message ${e.$typeName} to JSON: nanos must not be greater than 999999999`);let n=`Z`;if(e.nanos>0){let t=(e.nanos+1e9).toString().substring(1);n=t.substring(3)===`000000`?`.`+t.substring(0,3)+`Z`:t.substring(6)===`000`?`.`+t.substring(0,6)+`Z`:`.`+t+`Z`}return new Date(t).toISOString().replace(`.000Z`,n)}function Gx(e){return Object.assign(Object.assign({ignoreUnknownFields:!1,recursionLimit:100},e),{depth:0})}function Kx(e,t,n){return qx(e,hS(t,e.typeName),n)}function qx(e,t,n){let r=sy(e);return Jx(e,r,t,n),r}function Jx(e,t,n,r){try{Xx(e)(t,n,Gx(r))}catch(e){throw yy(e)?Error(`cannot decode ${e.field()} from JSON: ${e.message}`,{cause:e}):e}}const Yx=new WeakMap;function Xx(e){let t=Yx.get(e);return t===void 0&&(t=Zx(e)),t}function Zx(e){let t=String(e),n=Qx(e);if(n!==void 0){let r=(e,r,i)=>{if(++i.depth>i.recursionLimit)throw Error(`cannot decode ${t} from JSON: maximum recursion depth of ${i.recursionLimit} reached`);n(e,r,i),i.depth--};return Yx.set(e,r),r}let r=e.typeName,i=new Map,a=(e,n,a)=>{if(++a.depth>a.recursionLimit)throw Error(`cannot decode ${t} from JSON: maximum recursion depth of ${a.recursionLimit} reached`);if(n==null||Array.isArray(n)||typeof n!=`object`)throw Error(`cannot decode ${t} from JSON: ${Ly(n)}`);let o=new Map,s=new Set,c=Object.keys(n);for(let l=0;l<c.length;l++){let u=c[l],d=n[u],f=i.get(u);if(f!==void 0){let t=f.field;if(s.has(t))throw new vy(t,`set multiple times`);if(s.add(t),f.oneofScalarNullSkip&&d===null)continue;if(f.oneof){let e=o.get(f.oneof);if(e!==void 0)throw new vy(f.oneof,`oneof set multiple times by ${e.name} and ${t.name}`);o.set(f.oneof,t)}f.read(e,d,a)}else{let n=u.startsWith(`[`)&&u.endsWith(`]`)?a.registry?.getExtension(u.substring(1,u.length-1)):void 0;if(n?.extendee.typeName==r){let[t,r,i]=mx(n);$x(r)(t[Uv],d,a),fx(e,n,i())}if(n===void 0&&!a.ignoreUnknownFields)throw Error(`cannot decode ${t} from JSON: key "${u}" is unknown`)}}a.depth--};Yx.set(e,a);for(let t of e.fields){let e={read:$x(t),field:t,oneof:t.oneof,oneofScalarNullSkip:t.oneof!==void 0&&t.fieldKind==`scalar`};i.set(t.name,e).set(t.jsonName,e)}return a}function Qx(e){if(e.typeName.startsWith(`google.protobuf.`))switch(e.typeName){case`google.protobuf.Any`:return(e,t,n)=>_S(e,t,n);case`google.protobuf.Timestamp`:return(e,t)=>vS(e,t);case`google.protobuf.Duration`:return(e,t)=>sre(e,t);case`google.protobuf.FieldMask`:return(e,t)=>cre(e,t);case`google.protobuf.Struct`:return(e,t,n)=>yS(e,t,n);case`google.protobuf.Value`:return(e,t,n)=>bS(e,t,n);case`google.protobuf.ListValue`:return(e,t,n)=>xS(e,t,n);default:if(ry(e)){let t=e.fields[0],n=t.localName,r=t.scalar,i=t.longAsString,a=uS(t);return(e,t)=>{t===null?e[n]=Vv(r,i):e[n]=a(t)}}return}}function $x(e){switch(e.fieldKind){case`scalar`:return eS(e);case`enum`:return nS(e);case`message`:return rS(e);case`list`:return iS(e);case`map`:return oS(e)}}function eS(e){let t=uS(e),n=e.localName;if(e.oneof){let r=e.oneof.localName;return(e,i)=>{e[r]={case:n,value:t(i)}}}let r=tS(e);return(e,i)=>{i===null?r(e):e[n]=t(i)}}function tS(e){let t=e.localName;if(e.presence!=2)return e=>{delete e[t]};if(e.fieldKind==`enum`){let n=e.enum.values[0].number;return e=>{e[t]=n}}let n=e.scalar,r=e.longAsString;return e=>{e[t]=Vv(n,r)}}function nS(e){let t=cS(e.enum),n=lS(e.enum),r=e.localName,i=e.enum.typeName!=`google.protobuf.NullValue`;if(e.oneof){let a=e.oneof.localName;return(o,s,c)=>{if(s===null&&i){o[a].case===r&&(o[a]={case:void 0});return}let l=t(s,c.ignoreUnknownFields);if(l===sS)return;let u=n(l);if(u!==!0)throw new vy(e,Iy(e,l,u));o[a]={case:r,value:l}}}let a=tS(e);return(o,s,c)=>{if(s===null&&i){a(o);return}let l=t(s,c.ignoreUnknownFields);if(l===sS)return;let u=n(l);if(u!==!0)throw new vy(e,Iy(e,l,u));o[r]=l}}function rS(e){let t=e.localName,{toMessage:n,toLocal:r}=Vy(e),i=Xx(e.message),a=e.message.typeName!=`google.protobuf.Value`;if(e.oneof){let o=e.oneof.localName;return(e,s,c)=>{let l=e[o];if(s===null&&a){l.case===t&&(e[o]={case:void 0});return}let u=n(l.case===t?l.value:void 0);i(u,s,c),e[o]={case:t,value:r(u)}}}return(e,o,s)=>{if(o===null&&a){delete e[t];return}let c=n(e[t]);i(c,o,s),e[t]=r(c)}}function iS(e){let t=e.localName,n=aS(e);return(r,i,a)=>{if(i===null)return;if(!Array.isArray(i))throw new vy(e,`expected Array, got `+Ly(i));let o=r[t];for(let e=0;e<i.length;e++){let t=n(i[e],a,o.length);t!==sS&&o.push(t)}}}function aS(e){switch(e.listKind){case`scalar`:{let t=dS(e),n=Fy(e.scalar),r=fS(e);return(i,a,o)=>{if(i===null)throw new vy(e,`list item must not be null`);let s=t(i),c=n(s);if(c!==!0)throw new vy(e,`list item #${o+1}: ${Iy(e,s,c)}`);return r(s)}}case`enum`:{let t=cS(e.enum),n=lS(e.enum),r=e.enum.typeName!=`google.protobuf.NullValue`;return(i,a,o)=>{if(i===null&&r)throw new vy(e,`list item must not be null`);let s=t(i,a.ignoreUnknownFields);if(s===sS)return s;let c=n(s);if(c!==!0)throw new vy(e,`list item #${o+1}: ${Iy(e,s,c)}`);return s}}case`message`:{let{toMessage:t,toLocal:n}=Vy(e),r=Xx(e.message),i=e.message.typeName!=`google.protobuf.Value`;return(a,o)=>{if(a===null&&i)throw new vy(e,`list item must not be null`);let s=t(void 0);return r(s,a,o),n(s)}}}}function oS(e){let t=e.localName,n=e.mapKey,r=pS(n),i=Fy(n),a,o,s=e=>e,c=!0;switch(e.mapKind){case`scalar`:a=dS(e),o=Fy(e.scalar),s=fS(e);break;case`enum`:{let t=cS(e.enum);a=(e,n)=>t(e,n.ignoreUnknownFields),o=lS(e.enum),c=e.enum.typeName!=`google.protobuf.NullValue`;break}case`message`:{let{toMessage:t,toLocal:n}=Vy(e),r=Xx(e.message);c=e.message.typeName!=`google.protobuf.Value`,a=(e,i)=>{let a=t(void 0);return r(a,e,i),n(a)};break}}return(l,u,d)=>{if(u===null)return;if(typeof u!=`object`||Array.isArray(u))throw new vy(e,`expected object, got `+Ly(u));let f=l[t],p=new Set,m=Object.keys(u);for(let t=0;t<m.length;t++){let l=m[t],h=u[l],g=r(l);if(p.has(g))throw new vy(e,`duplicate map key "${l}"`);if(p.add(g),h===null&&c)throw new vy(e,`map value must not be null`);let _=a(h,d);if(_===sS)continue;let v=i(g);if(v!==!0)throw new vy(e,`invalid map key: ${Iy({scalar:n},g,v)}`);if(o!==void 0){let t=o(_);if(t!==!0)throw new vy(e,`map entry ${Ly(g)}: ${Iy(e,_,t)}`)}Yv(f,g,s(_))}}}const sS=Symbol();function cS(e){let t=e.values[0].number,n=new Map;for(let t of e.values)n.set(t.jsonName,t.number);for(let t of e.values)n.set(t.name,t.number);return(r,i)=>{if(r===null)return t;switch(typeof r){case`number`:if(Number.isInteger(r))return r;break;case`string`:{let e=n.get(r);if(e!==void 0)return e;if(i)return sS;break}}throw Error(`cannot decode ${e} from JSON: ${Ly(r)}`)}}function lS(e){if(e.open)return Fy(N.INT32);let t=e.values;return e=>t.some(t=>t.number===e)}function uS(e){let t=dS(e),n=Fy(e.scalar),r=fS(e);return i=>{let a=t(i),o=n(a);if(o!==!0)throw new vy(e,Iy(e,a,o));return r(a)}}function dS(e){switch(e.scalar){case N.DOUBLE:case N.FLOAT:return t=>{if(t===`NaN`)return NaN;if(t===`Infinity`)return 1/0;if(t===`-Infinity`)return-1/0;if(typeof t==`number`){if(Number.isNaN(t))throw new vy(e,`unexpected NaN number`);if(!Number.isFinite(t))throw new vy(e,`unexpected infinite number`);return t}if(typeof t==`string`){if(t===``||t.trim().length!==t.length)return t;let e=Number(t);return Number.isFinite(e)?e:t}return t};case N.INT32:case N.FIXED32:case N.SFIXED32:case N.SINT32:case N.UINT32:return mS;case N.BYTES:return t=>{if(typeof t==`string`){if(t===``)return new Uint8Array;try{return ab(t)}catch(t){throw new vy(e,t instanceof Error?t.message:String(t))}}return t};default:return e=>e}}function fS(e){let t=e.fieldKind!==`map`&&e.longAsString;switch(e.scalar){case N.INT64:case N.SFIXED64:case N.SINT64:return t?e=>String(e):e=>typeof e==`string`||typeof e==`number`?Lv.parse(e):e;case N.FIXED64:case N.UINT64:return t?e=>String(e):e=>typeof e==`string`||typeof e==`number`?Lv.uParse(e):e;default:return e=>e}}function pS(e){switch(e){case N.BOOL:return e=>{switch(e){case`true`:return!0;case`false`:return!1}return e};case N.INT32:case N.FIXED32:case N.UINT32:case N.SFIXED32:case N.SINT32:return mS;case N.INT64:case N.SINT64:case N.SFIXED64:case N.UINT64:case N.FIXED64:return e=>/^-?0+$/.test(e)?`0`:e.replace(/^(-?)0+(?=\d)/,`$1`);default:return e=>e}}function mS(e){if(typeof e==`string`){if(e===``||e.trim().length!==e.length)return e;let t=Number(e);return Number.isNaN(t)?e:t}return e}function hS(e,t){let n;try{n=JSON.parse(e)}catch(e){let n=e instanceof Error?e.message:String(e);throw Error(`cannot decode message ${t} from JSON: ${n}`,{cause:e})}return gS(e,t),n}function gS(e,t){let n=[],r=!1,i=0;for(;i<e.length;)switch(e[i]){case`{`:n.push(new Set),r=!0,i++;break;case`[`:n.push(null),r=!1,i++;break;case`}`:case`]`:n.pop(),r=!1,i++;break;case`,`:r=n[n.length-1]!=null,i++;break;case`:`:r=!1,i++;break;case`"`:{let a=i++,o=!1;for(;i<e.length;){if(e[i]==`\\`){o=!0,i+=2;continue}if(e[i]==`"`)break;i++}let s=i++,c=n[n.length-1];if(r&&c){let n=o?JSON.parse(e.substring(a,s+1)):e.substring(a+1,s);if(c.has(n))throw Error(`cannot decode message ${t} from JSON: duplicate object key "${n}"`);c.add(n)}r=!1;break}default:i++}}function _S(e,t,n){if(t===null||Array.isArray(t)||typeof t!=`object`)throw Error(`cannot decode message ${e.$typeName} from JSON: expected object but got ${Ly(t)}`);if(Object.keys(t).length==0)return;let r=t[`@type`];if(typeof r!=`string`||r==``)throw Error(`cannot decode message ${e.$typeName} from JSON: "@type" is empty`);let i=r.includes(`/`)?r.substring(r.lastIndexOf(`/`)+1):r;if(!i.length)throw Error(`cannot decode message ${e.$typeName} from JSON: "@type" is invalid`);let a=n.registry?.getMessage(i);if(!a)throw Error(`cannot decode message ${e.$typeName} from JSON: ${r} is not in the type registry`);let o=sy(a);if(iy(a)&&Object.prototype.hasOwnProperty.call(t,`value`))Xx(a)(o,t.value,n);else{let e={};for(let n of Object.keys(t))n!==`@type`&&Yv(e,n,t[n]);Xx(a)(o,e,n)}tx(a,o,e)}function vS(e,t){if(typeof t!=`string`)throw Error(`cannot decode message ${e.$typeName} from JSON: ${Ly(t)}`);let n=t.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:\.([0-9]{1,9}))?(?:Z|([+-][0-9][0-9]:[0-9][0-9]))$/);if(!n)throw Error(`cannot decode message ${e.$typeName} from JSON: invalid RFC 3339 string`);let r=Date.parse(n[1]+`-`+n[2]+`-`+n[3]+`T`+n[4]+`:`+n[5]+`:`+n[6]+(n[8]?n[8]:`Z`));if(Number.isNaN(r))throw Error(`cannot decode message ${e.$typeName} from JSON: invalid RFC 3339 string`);if(r<gx||r>_x)throw Error(`cannot decode message ${e.$typeName} from JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive`);e.seconds=Lv.parse(r/1e3),e.nanos=0,n[7]&&(e.nanos=parseInt(`1`+n[7]+`0`.repeat(9-n[7].length))-1e9)}function sre(e,t){if(typeof t!=`string`)throw Error(`cannot decode message ${e.$typeName} from JSON: ${Ly(t)}`);let n=t.match(/^(-?[0-9]+)(?:\.([0-9]+))?s/);if(n===null)throw Error(`cannot decode message ${e.$typeName} from JSON: ${Ly(t)}`);let r=Number(n[1]);if(r>315576e6||r<-315576e6)throw Error(`cannot decode message ${e.$typeName} from JSON: ${Ly(t)}`);if(e.seconds=Lv.parse(r),typeof n[2]!=`string`)return;let i=n[2]+`0`.repeat(9-n[2].length);e.nanos=parseInt(i),(r<0||Object.is(r,-0))&&(e.nanos=-e.nanos)}function cre(e,t){if(typeof t!=`string`)throw Error(`cannot decode message ${e.$typeName} from JSON: ${Ly(t)}`);t!==``&&(e.paths=t.split(`,`).map(t=>{if(t.includes(`_`))throw Error(`cannot decode message ${e.$typeName} from JSON: path names must be lowerCamelCase`);return pb(t)}))}function yS(e,t,n){if(typeof t!=`object`||!t||Array.isArray(t))throw Error(`cannot decode message ${e.$typeName} from JSON ${Ly(t)}`);let r=Object.keys(t);for(let i=0;i<r.length;i++){let a=r[i],o=sy(cx);bS(o,t[a],n),Yv(e.fields,a,o)}}function bS(e,t,n){if(++n.depth>n.recursionLimit)throw Error(`cannot decode ${e.$typeName} from JSON: maximum recursion depth of ${n.recursionLimit} reached`);switch(typeof t){case`number`:e.kind={case:`numberValue`,value:t};break;case`string`:e.kind={case:`stringValue`,value:t};break;case`boolean`:e.kind={case:`boolValue`,value:t};break;case`object`:if(t===null)e.kind={case:`nullValue`,value:ux.NULL_VALUE};else if(Array.isArray(t)){let r=sy(lx);xS(r,t,n),e.kind={case:`listValue`,value:r}}else{let r=sy(sx);yS(r,t,n),e.kind={case:`structValue`,value:r}}break;default:throw Error(`cannot decode message ${e.$typeName} from JSON ${Ly(t)}`)}return n.depth--,e}function xS(e,t,n){if(!Array.isArray(t))throw Error(`cannot decode message ${e.$typeName} from JSON ${Ly(t)}`);for(let r=0;r<t.length;r++){let i=sy(cx);bS(i,t[r],n),e.values.push(i)}}function SS(e){let t=M[e];return typeof t==`string`?t[0].toLowerCase()+t.substring(1).replace(/[A-Z]/g,e=>`_`+e.toLowerCase()):e.toString()}let CS;function wS(e){if(!CS){CS={};for(let e of Object.values(M))typeof e!=`string`&&(CS[SS(e)]=e)}return CS[e]}var TS=class e extends Error{constructor(e,t=M.Unknown,n,r,i){super(lre(e,t)),this.name=`ConnectError`,this.isWireError=!1,Object.setPrototypeOf(this,new.target.prototype),this.rawMessage=e,this.code=t,this.metadata=new Headers(n??{}),this.details=r??[],this.cause=i}static from(t,n=M.Unknown){return t instanceof e?t:t instanceof Error?t.name==`AbortError`||t.name==`TimeoutError`?new e(t.message,M.Canceled):new e(t.message,n,void 0,void 0,t):new e(String(t),n,void 0,void 0,t)}static[Symbol.hasInstance](t){return t instanceof Error?Object.getPrototypeOf(t)===e.prototype||t.name===`ConnectError`&&`code`in t&&typeof t.code==`number`&&`metadata`in t&&`details`in t&&Array.isArray(t.details)&&`rawMessage`in t&&typeof t.rawMessage==`string`&&`cause`in t:!1}findDetails(e){let t=e.kind===`message`?{getMessage:t=>t===e.typeName?e:void 0}:e,n=[];for(let e of this.details){if(`desc`in e){t.getMessage(e.desc.typeName)&&n.push(sy(e.desc,e.value));continue}let r=t.getMessage(e.type);if(r)try{n.push(Fb(r,e.value))}catch{}}return n}};function lre(e,t){return e.length?`[${SS(t)}] ${e}`:`[${SS(t)}]`}function ES(...e){let t=new Headers;for(let n of e)n.forEach((e,n)=>{t.append(n,e)});return t}function ure(e,t){let n={};for(let r of e.methods){let e=t(r);e!=null&&(n[r.localName]=e)}return n}function dre(e,t){if(t>e)throw new TS(`message size ${t} is larger than configured writeMaxBytes ${e}`,M.ResourceExhausted)}function DS(e,t,n=!1){if(t>e){let r=`message size is larger than configured readMaxBytes ${e}`;throw n&&(r=`message size ${t} is larger than configured readMaxBytes ${e}`),new TS(r,M.ResourceExhausted)}}function OS(e){return new fre(e)}var fre=class{constructor(e){this.readMaxBytes=e,this.header=new Uint8Array(5),this.headerView=new DataView(this.header.buffer),this.buf=[]}get byteLength(){return this.buf.reduce((e,t)=>e+t.byteLength,0)}decode(e){this.buf.push(e);let t=[];for(;;){let e=this.pop();if(!e)break;t.push(e)}return t}pop(){if(!(!this.env&&(this.env=this.head(),!this.env))&&this.cons(this.env.data)){let e=this.env;return this.env=void 0,e}}head(){if(!this.cons(this.header))return;let e=this.headerView.getUint8(0),t=this.headerView.getUint32(1);return DS(this.readMaxBytes,t,!0),{flags:e,data:new Uint8Array(t)}}cons(e){let t=e.byteLength;if(this.byteLength<t)return!1;let n=0;for(;n<t;){let r=this.buf.shift();r.byteLength>t-n?(e.set(r.subarray(0,t-n),n),this.buf.unshift(r.subarray(t-n)),n+=t-n):(e.set(r,n),n+=r.byteLength)}return!0}};function pre(e){let t,n=OS(4294967295);return new ReadableStream({start(){t=e.getReader()},async pull(e){let r=!1;for(;!r;){let i=await t.read();if(i.done)n.byteLength>0&&e.error(new TS(`protocol error: incomplete envelope`,M.InvalidArgument)),e.close();else for(let t of n.decode(i.value))e.enqueue(t),r=!0}}})}async function mre(e,t,n){let{flags:r,data:i}=e;if((r&1)==1)throw new TS(`invalid envelope, already compressed`,M.Internal);return t&&i.byteLength>=n&&(i=await t.compress(i),r|=1),{data:i,flags:r}}async function hre(e,t,n){let{flags:r,data:i}=e;if((r&1)==1){if(!t)throw new TS(`received compressed envelope, but do not know how to decompress`,M.Internal);i=await t.decompress(i,n),r^=1}return{data:i,flags:r}}function kS(e,t){let n=new Uint8Array(t.length+5);n.set(t,5);let r=new DataView(n.buffer,n.byteOffset,n.byteLength);return r.setUint8(0,e),r.setUint32(1,t.length),n}var AS=function(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof __values==`function`?__values(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}},jS=function(e){return this instanceof jS?(this.v=e,this):new jS(e)},MS=function(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof jS?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}},NS=function(e){var t={},n;return r(`next`),r(`throw`,function(e){throw e}),r(`return`),t[Symbol.iterator]=function(){return this},t;function r(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:jS(e[r](t)),done:!1}:i?i(t):t}:i}};function PS(e,...t){let[n,r,i]=FS(t),a=e,o;return i?.propagateDownStreamError===!0&&(a=o=qS(a)),a=LS(a,...n,{propagateDownStreamError:!1}),r(a).catch(e=>o?o.abort(e).then(()=>Promise.reject(e)):Promise.reject(e))}function FS(e){let t;return typeof e[e.length-1]!=`function`&&(t=e.pop()),[e,e.pop(),t]}function IS(e,t){return async n=>await GS(n,e,t)}function LS(e,...t){return MS(this,arguments,function*(){var n;let[r,i]=RS(t),a,o=e[Symbol.asyncIterator](),s={[Symbol.asyncIterator](){return o}};i?.propagateDownStreamError===!0&&(s=a=qS(s));for(let e of r)s=e(s);let c=s[Symbol.asyncIterator]();try{for(;;){let e=yield jS(c.next());if(e.done===!0)break;if(!a){yield yield jS(e.value);continue}try{yield yield jS(e.value)}catch(e){throw yield jS(a.abort(e)),e}}}finally{i?.propagateDownStreamError===!0&&((n=o.return)==null||n.call(o).catch(()=>{}))}})}function RS(e){let t;return typeof e[e.length-1]!=`function`&&(t=e.pop()),[e,t]}function zS(e,t,n){return t===void 0||n===void 0?function(t){return MS(this,arguments,function*(){var n,r,i,a;try{for(var o=!0,s=AS(t),c;c=yield jS(s.next()),n=c.done,!n;o=!0){a=c.value,o=!1;let t=a;yield yield jS({flags:0,data:e.serialize(t)})}}catch(e){r={error:e}}finally{try{!o&&!n&&(i=s.return)&&(yield jS(i.call(s)))}finally{if(r)throw r.error}}})}:function(r){return MS(this,arguments,function*(){var i,a,o,s;try{for(var c=!0,l=AS(r),u;u=yield jS(l.next()),i=u.done,!i;c=!0){s=u.value,c=!1;let r=s,i,a=0;r.end?(a|=t,i=n.serialize(r.value)):i=e.serialize(r.value),yield yield jS({flags:a,data:i})}}catch(e){a={error:e}}finally{try{!c&&!i&&(o=l.return)&&(yield jS(o.call(l)))}finally{if(a)throw a.error}}})}}function BS(e,t,n){return n&&t!==void 0?function(r){return MS(this,arguments,function*(){var i,a,o,s;try{for(var c=!0,l=AS(r),u;u=yield jS(l.next()),i=u.done,!i;c=!0){s=u.value,c=!1;let{flags:r,data:i}=s;(r&t)===t?yield yield jS({value:n.parse(i),end:!0}):yield yield jS({value:e.parse(i),end:!1})}}catch(e){a={error:e}}finally{try{!c&&!i&&(o=l.return)&&(yield jS(o.call(l)))}finally{if(a)throw a.error}}})}:function(r){return MS(this,arguments,function*(){var i,a,o,s;try{for(var c=!0,l=AS(r),u;u=yield jS(l.next()),i=u.done,!i;c=!0){s=u.value,c=!1;let{flags:r,data:i}=s;if(t!==void 0&&(r&t)===t){if(n===null)throw new TS(`unexpected end flag`,M.InvalidArgument);continue}yield yield jS(e.parse(i))}}catch(e){a={error:e}}finally{try{!c&&!i&&(o=l.return)&&(yield jS(o.call(l)))}finally{if(a)throw a.error}}})}}function VS(e,t){return function(n){return MS(this,arguments,function*(){var r,i,a,o;try{for(var s=!0,c=AS(n),l;l=yield jS(c.next()),r=l.done,!r;s=!0)o=l.value,s=!1,yield yield jS(yield jS(mre(o,e,t)))}catch(e){i={error:e}}finally{try{!s&&!r&&(a=c.return)&&(yield jS(a.call(c)))}finally{if(i)throw i.error}}})}}function HS(e,t){return function(n){return MS(this,arguments,function*(){var r,i,a,o;try{for(var s=!0,c=AS(n),l;l=yield jS(c.next()),r=l.done,!r;s=!0)o=l.value,s=!1,yield yield jS(yield jS(hre(o,e,t)))}catch(e){i={error:e}}finally{try{!s&&!r&&(a=c.return)&&(yield jS(a.call(c)))}finally{if(i)throw i.error}}})}}function US(){return function(e){return MS(this,arguments,function*(){var t,n,r,i;try{for(var a=!0,o=AS(e),s;s=yield jS(o.next()),t=s.done,!t;a=!0){i=s.value,a=!1;let{flags:e,data:t}=i;yield yield jS(kS(e,t))}}catch(e){n={error:e}}finally{try{!a&&!t&&(r=o.return)&&(yield jS(r.call(o)))}finally{if(n)throw n.error}}})}}function WS(e){return function(t){return MS(this,arguments,function*(){var n,r,i,a;let o=OS(e);try{for(var s=!0,c=AS(t),l;l=yield jS(c.next()),n=l.done,!n;s=!0){a=l.value,s=!1;let e=a;for(let t of o.decode(e))yield yield jS(t)}}catch(e){r={error:e}}finally{try{!s&&!n&&(i=c.return)&&(yield jS(i.call(c)))}finally{if(r)throw r.error}}if(o.byteLength>0)throw new TS(`protocol error: incomplete envelope`,M.InvalidArgument)})}}async function GS(e,t,n){var r,i,a,o,s,c,l,u;let[d,f]=KS(n);if(d){f>t&&DS(t,f,!0);let n=new Uint8Array(f),s=0;try{for(var p=!0,m=AS(e),h;h=await m.next(),r=h.done,!r;p=!0){o=h.value,p=!1;let e=o;if(s+e.byteLength>f)throw new TS(`protocol error: promised ${f} bytes, received ${s+e.byteLength}`,M.InvalidArgument);n.set(e,s),s+=e.byteLength}}catch(e){i={error:e}}finally{try{!p&&!r&&(a=m.return)&&await a.call(m)}finally{if(i)throw i.error}}if(s<f)throw new TS(`protocol error: promised ${f} bytes, received ${s}`,M.InvalidArgument);return n}let g=[],_=0;try{for(var v=!0,y=AS(e),ee;ee=await y.next(),s=ee.done,!s;v=!0){u=ee.value,v=!1;let e=u;_+=e.byteLength,DS(t,_),g.push(e)}}catch(e){c={error:e}}finally{try{!v&&!s&&(l=y.return)&&await l.call(y)}finally{if(c)throw c.error}}let b=new Uint8Array(_),te=0;for(let e=g.shift();e;e=g.shift())b.set(e,te),te+=e.byteLength;return b}function KS(e){if(e==null)return[!1,0];let t=typeof e==`string`?parseInt(e,10):e;return!Number.isSafeInteger(t)||t<0?[!1,t]:[!0,t]}function qS(e){let t=e[Symbol.asyncIterator]();if(t.throw===void 0)throw Error(`AsyncIterable does not implement throw`);let n=t,r,i,a={next(){return i=n.next().finally(()=>{i=void 0}),i},throw(e){return n.throw(e)}};t.return!==void 0&&(a=Object.assign(Object.assign({},a),{return(e){return n.return(e)}}));let o=!1;return{abort(e){if(r)return r.state;let t=()=>n.throw(e).then(e=>e.done===!0?`completed`:`caught`,()=>`rethrown`);return i?(r={reason:e,state:i.then(t,t)},r.state):(r={reason:e,state:t()},r.state)},[Symbol.asyncIterator](){if(o)throw Error(`AsyncIterable cannot be re-used`);return o=!0,a}}}function JS(e){return MS(this,arguments,function*(){yield jS(yield*NS(AS(e)))})}var YS=function(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof __values==`function`?__values(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}},XS=function(e){return this instanceof XS?(this.v=e,this):new XS(e)},ZS=function(e){var t={},n;return r(`next`),r(`throw`,function(e){throw e}),r(`return`),t[Symbol.iterator]=function(){return this},t;function r(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:XS(e[r](t)),done:!1}:i?i(t):t}:i}},QS=function(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof XS?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}};function $S(e,t){return ure(e,e=>{switch(e.methodKind){case`unary`:return eC(t,e);case`server_streaming`:return tC(t,e);case`client_streaming`:return nC(t,e);case`bidi_streaming`:return rC(t,e);default:return null}})}function eC(e,t){return async(n,r)=>{var i,a;let o=await e.unary(t,r?.signal,r?.timeoutMs,r?.headers,n,r?.contextValues);return(i=r?.onHeader)==null||i.call(r,o.header),(a=r?.onTrailer)==null||a.call(r,o.trailer),o.message}}function tC(e,t){return(n,r)=>iC(e.stream(t,r?.signal,r?.timeoutMs,r?.headers,JS([n]),r?.contextValues),r)}function nC(e,t){return async(n,r)=>{var i,a,o,s,c,l;let u=await e.stream(t,r?.signal,r?.timeoutMs,r?.headers,n,r?.contextValues);(c=r?.onHeader)==null||c.call(r,u.header);let d,f=0;try{for(var p=!0,m=YS(u.message),h;h=await m.next(),i=h.done,!i;p=!0)s=h.value,p=!1,d=s,f++}catch(e){a={error:e}}finally{try{!p&&!i&&(o=m.return)&&await o.call(m)}finally{if(a)throw a.error}}if(!d)throw new TS(`protocol error: missing response message`,M.Unimplemented);if(f>1)throw new TS(`protocol error: received extra messages for client streaming method`,M.Unimplemented);return(l=r?.onTrailer)==null||l.call(r,u.trailer),d}}function rC(e,t){return(n,r)=>iC(e.stream(t,r?.signal,r?.timeoutMs,r?.headers,n,r?.contextValues),r)}function iC(e,t){return(function(){return QS(this,arguments,function*(){var n,r;let i=yield XS(e);(n=t?.onHeader)==null||n.call(t,i.header),yield XS(yield*ZS(YS(i.message))),(r=t?.onTrailer)==null||r.call(t,i.trailer)})})()}function aC(...e){let t=new AbortController,n=e.filter(e=>e!==void 0).concat(t.signal);for(let e of n){if(e.aborted){r.apply(e);break}e.addEventListener(`abort`,r)}function r(){t.signal.aborted||t.abort(sC(this));for(let e of n)e.removeEventListener(`abort`,r)}return t}function oC(e){let t=new AbortController,n=()=>{t.abort(new TS(`the operation timed out`,M.DeadlineExceeded))},r;return e!==void 0&&(e<=0?n():r=setTimeout(n,e)),{signal:t.signal,cleanup:()=>clearTimeout(r)}}function sC(e){if(!e.aborted)return;if(e.reason!==void 0)return e.reason;let t=Error(`This operation was aborted`);return t.name=`AbortError`,t}function cC(){return{get(e){return e.id in this?this[e.id]:e.defaultValue},set(e,t){return this[e.id]=t,this},delete(e){return delete this[e.id],this}}}function lC(e,t,...n){if(n.length>0)throw Error();return e.services[t]}const uC=`Content-Type`,dC=`Content-Length`,fC=`Content-Encoding`,pC=`Connect-Content-Encoding`,mC=`Accept-Encoding`,hC=`Connect-Accept-Encoding`,gC=`Connect-Timeout-Ms`,_C=`Connect-Protocol-Version`,vC=`User-Agent`,yC=new Set([uC,dC,fC,`Host`,vC,`Trailer`,`Date`,mC,`Trailer-`,pC,hC,gC,_C,`Grpc-Encoding`,`Grpc-Accept-Encoding`,`Grpc-Timeout`,`Grpc-Status`,`Grpc-Message`,`Grpc-Status-Details-Bin`].map(e=>e.toLowerCase()));function bC(e,t){t.forEach((t,n)=>{yC.has(n.toLowerCase())||e.append(n,t)})}function xC(e,t){return e.toString().replace(/\/?$/,`/${t.parent.typeName}/${t.name}`)}function SC(e,t){return sy(e,t)}function CC(e,t){function n(t){return t.done===!0?t:{done:t.done,value:SC(e,t.value)}}return{[Symbol.asyncIterator](){let e=t[Symbol.asyncIterator](),r={next:()=>e.next().then(n)};return e.throw!==void 0&&(r.throw=t=>e.throw(t).then(n)),e.return!==void 0&&(r.return=t=>e.return(t).then(n)),r}}}function wC(e,t){if(!t)return e;for(let n of t.concat().reverse())e=n(e);return e}function TC(e){let t=Object.assign({},e);return t.ignoreUnknownFields??=!0,t}function EC(e,t,n,r){let i=OC(kC(e.input,t),r),a=OC(AC(e.input,n),r),o=OC(kC(e.output,t),r),s=OC(AC(e.output,n),r);return{getI(e){return e?i:a},getO(e){return e?o:s}}}function DC(e,t,n,r){let i=t?kC(e.input,r):AC(e.input,n);return{parse:(t?kC(e.output,r):AC(e.output,n)).parse,serialize:i.serialize}}function OC(e,t){return{serialize(n){let r=e.serialize(n);return dre(t.writeMaxBytes,r.byteLength),r},parse(n){return DS(t.readMaxBytes,n.byteLength,!0),e.parse(n)}}}function kC(e,t){return{parse(n){try{return Fb(e,n,t)}catch(e){throw new TS(`parse binary: ${e instanceof Error?e.message:String(e)}`,M.Internal)}},serialize(n){try{return Ub(e,n,t)}catch(e){throw new TS(`serialize binary: ${e instanceof Error?e.message:String(e)}`,M.Internal)}}}}function AC(e,t){let n=t?.textEncoder??new TextEncoder,r=t?.textDecoder??new TextDecoder,i=TC(t);return{parse(t){try{return Kx(e,r.decode(t),i)}catch(e){throw TS.from(e,M.InvalidArgument)}},serialize(t){try{let r=are(e,t,i);return n.encode(r)}catch(e){throw TS.from(e,M.Internal)}}}}const jC=/^application\/(connect\+)?(?:(json)(?:; ?charset=utf-?8)?|(proto))$/i;function MC(e){let t=e?.match(jC);if(t)return{stream:!!t[1],binary:!!t[3]}}var NC=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};function PC(e,t,n){if(t&&new Headers(t).forEach((e,t)=>n.metadata.append(t,e)),typeof e!=`object`||!e||Array.isArray(e))throw n;let r=n.code;`code`in e&&typeof e.code==`string`&&(r=wS(e.code)??r);let i=e.message;if(i!=null&&typeof i!=`string`)throw n;let a=new TS(i??``,r,t);if(a.isWireError=!0,`details`in e&&Array.isArray(e.details))for(let t of e.details){if(typeof t!=`object`||!t||Array.isArray(t)||typeof t.type!=`string`||typeof t.value!=`string`)throw n;try{a.details.push({type:t.type,value:ab(t.value),debug:t.debug})}catch{throw n}}return a}function FC(e,t,n){let r;try{r=JSON.parse(new TextDecoder().decode(e))}catch{throw n}return PC(r,t,n)}function IC(e,t){let n={code:SS(e.code)};return e.rawMessage.length>0&&(n.message=e.rawMessage),e.details.length>0&&(n.details=e.details.map(e=>{if(`desc`in e){let n=sy(e.desc,e.value),r={type:e.desc.typeName,value:Ub(e.desc,n)};try{r.debug=yx(e.desc,n,t)}catch{}return r}return e}).map(e=>{var{value:t}=e,n=NC(e,[`value`]);return Object.assign(Object.assign({},n),{value:sb(t,`std_raw`)})})),n}function LC(e){let t=new TS(`invalid end stream`,M.Unknown),n;try{n=JSON.parse(typeof e==`string`?e:new TextDecoder().decode(e))}catch{throw t}if(typeof n!=`object`||!n||Array.isArray(n))throw t;let r=new Headers;if(`metadata`in n){if(typeof n.metadata!=`object`||n.metadata==null||Array.isArray(n.metadata))throw t;for(let[e,i]of Object.entries(n.metadata)){if(!Array.isArray(i)||i.some(e=>typeof e!=`string`))throw t;for(let t of i)r.append(e,t)}}return{metadata:r,error:`error`in n&&n.error!=null?PC(n.error,r,t):void 0}}function RC(e,t,n){let r={};t!==void 0&&(r.error=IC(t,n),t.isWireError||bC(e,t.metadata));let i=!1,a={};return e.forEach((e,t)=>{i=!0,a[t]=[e]}),i&&(r.metadata=a),r}function zC(e){let t=new TextEncoder;return{serialize(n){try{let r=RC(n.metadata,n.error,e),i=JSON.stringify(r);return t.encode(i)}catch(e){throw new TS(`failed to serialize EndStreamResponse: ${e instanceof Error?e.message:String(e)}`,M.Internal)}},parse(e){try{return LC(e)}catch(e){throw new TS(`failed to parse EndStreamResponse: ${e instanceof Error?e.message:String(e)}`,M.InvalidArgument)}}}}function BC(e){switch(e){case 400:return M.Internal;case 401:return M.Unauthenticated;case 403:return M.PermissionDenied;case 404:return M.Unimplemented;case 429:return M.Unavailable;case 502:return M.Unavailable;case 503:return M.Unavailable;case 504:return M.Unavailable;default:return M.Unknown}}function VC(e){let t=new Headers,n=new Headers;return e.forEach((e,r)=>{r.toLowerCase().startsWith(`trailer-`)?n.append(r.substring(8),e):t.append(r,e)}),[t,n]}function HC(e,t,n,r,i){let a=new Headers(r??{});return n!==void 0&&a.set(gC,`${n}`),a.set(uC,e==`unary`?t?`application/proto`:`application/json`:t?`application/connect+proto`:`application/connect+json`),a.set(_C,`1`),!a.has(`User-Agent`)&&i&&a.set(vC,`connect-es/2.3.0`),a}function UC(e,t,n,r,i,a,o){let s=HC(e,t,n,r,o);if(a!=null){let t=e==`unary`?fC:pC;s.set(t,a.name)}if(i.length>0){let t=e==`unary`?mC:hC;s.set(t,i.map(e=>e.name).join(`,`))}return s}function WC(e,t,n,r){let i=r.get(uC),a=MC(i);if(n!==200){let t=new TS(`HTTP ${n}`,BC(n),r);if(e==`unary`&&a&&!a.binary)return{isUnaryError:!0,unaryError:t};throw t}let o={binary:t,stream:e!==`unary`};if(a?.binary!==o.binary||a.stream!==o.stream)throw new TS(`unsupported content type ${i}`,a===void 0?M.Unknown:M.Internal,r);return{isUnaryError:!1}}function GC(e,t,n,r,i){let a,o=i.get(e==`unary`?fC:pC);if(o!=null&&o.toLowerCase()!==`identity`&&(a=t.find(e=>e.name===o),!a))throw new TS(`unsupported response encoding "${o}"`,M.Internal,i);return Object.assign({compression:a},WC(e,n,r,i))}function KC(e,t){return t?sb(e,`url`):encodeURIComponent(new TextDecoder().decode(e))}function qC(e,t,n){let r=`?connect=v1`,i=``,a=e.header.get(fC);a!==null&&a!==`identity`&&(i=`&compression=`+encodeURIComponent(a),n=!0),n&&(r+=`&base64=1`),r+=i;let o=e.header.get(uC);o?.indexOf(`application/`)===0&&(r+=`&encoding=`+encodeURIComponent(o.slice(12))),r+=`&message=`+KC(t,n);let s=e.url+r,c=new Headers(e.header);for(let e of[_C,uC,dC,fC,mC])c.delete(e);return Object.assign(Object.assign({},e),{requestMethod:`GET`,url:s,header:c})}function JC(e){let t=wC(e.next,e.interceptors),[n,r,i]=XC(e);return t(Object.assign(Object.assign({},e.req),{message:SC(e.req.method.input,e.req.message),signal:n})).then(e=>(i(),e),r)}function YC(e){let[t,n,r]=XC(e),i=!1,a=new Promise(e=>{t.aborted?e():t.addEventListener(`abort`,()=>e())});return a.then(()=>{var n,r;let a=e.req.message[Symbol.asyncIterator]();if(!i){let e=TS.from(sC(t),M.Canceled);(n=a.throw)==null||n.call(a,e).catch(()=>{})}(r=a.return)==null||r.call(a).catch(()=>{})}),wC(async r=>{let o=await e.next(r),s=o.message[Symbol.asyncIterator]();return a.then(()=>s.return?.call(s).catch(()=>{})),Object.assign(Object.assign({},o),{message:{[Symbol.asyncIterator]:()=>({next:async()=>{let e=t.aborted?void 0:await Promise.race([s.next(),a]);return e===void 0?i?{done:!0,value:void 0}:n(sC(t)):e}})}})},e.interceptors)(Object.assign(Object.assign({},e.req),{message:CC(e.req.method.input,e.req.message),signal:t})).then(e=>{let o=e.message[Symbol.asyncIterator](),s=a.then(async()=>{try{for(;(await o.next()).done!==!0;);}catch{}});return Object.assign(Object.assign({},e),{message:{[Symbol.asyncIterator]:()=>({async next(){if(t.aborted)return await s,i?{done:!0,value:void 0}:n(sC(t));try{let e=await o.next();return e.done===!0&&(i=!0,r()),e}catch(e){return n(e)}},async return(e){return t.aborted||(i=!0,r()),await s,{done:!0,value:e}},async throw(e){if(i)throw TS.from(e);try{return await n(e)}finally{await s}}})}})},n)}function XC(e){let{signal:t,cleanup:n}=oC(e.timeoutMs),r=aC(e.signal,t);return[r.signal,function(e){let t=r.signal.aborted?TS.from(sC(r.signal),M.Canceled):TS.from(e);return r.abort(t),n(),Promise.reject(t)},function(){n(),r.abort()}]}var ZC=function(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof __values==`function`?__values(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}},QC=function(e){return this instanceof QC?(this.v=e,this):new QC(e)},$C=function(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof QC?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}};function ew(e){return{async unary(t,n,r,i,a,o){let s=EC(t,e.binaryOptions,e.jsonOptions,e);return r=r===void 0?e.defaultTimeoutMs:r<=0?void 0:r,await JC({interceptors:e.interceptors,signal:n,timeoutMs:r,req:{stream:!1,service:t.parent,method:t,requestMethod:`POST`,url:xC(e.baseUrl,t),header:UC(t.methodKind,e.useBinaryFormat,r,i,e.acceptCompression,e.sendCompression,!0),contextValues:o??cC(),message:a},next:async n=>{let r=s.getI(e.useBinaryFormat).serialize(n.message);e.sendCompression&&r.byteLength>e.compressMinBytes?(r=await e.sendCompression.compress(r),n.header.set(fC,e.sendCompression.name)):n.header.delete(fC);let i=e.useHttpGet===!0&&t.idempotency===Nb.NO_SIDE_EFFECTS,a;i?n=qC(n,r,e.useBinaryFormat):a=JS([r]);let o=await e.httpClient({url:n.url,method:n.requestMethod,header:n.header,signal:n.signal,body:a}),{compression:c,isUnaryError:l,unaryError:u}=GC(t.methodKind,e.acceptCompression,e.useBinaryFormat,o.status,o.header),[d,f]=VC(o.header),p=await PS(o.body,IS(e.readMaxBytes,o.header.get(dC)),{propagateDownStreamError:!1});if(c&&(p=await c.decompress(p,e.readMaxBytes)),l)throw FC(p,ES(d,f),u);return{stream:!1,service:t.parent,method:t,header:d,message:s.getO(e.useBinaryFormat).parse(p),trailer:f}}})},async stream(t,n,r,i,a,o){let s=EC(t,e.binaryOptions,e.jsonOptions,e),c=zC(e.jsonOptions);return r=r===void 0?e.defaultTimeoutMs:r<=0?void 0:r,YC({interceptors:e.interceptors,signal:n,timeoutMs:r,req:{stream:!0,service:t.parent,method:t,requestMethod:`POST`,url:xC(e.baseUrl,t),header:UC(t.methodKind,e.useBinaryFormat,r,i,e.acceptCompression,e.sendCompression,!0),contextValues:o??cC(),message:a},next:async n=>{let r=await e.httpClient({url:n.url,method:`POST`,header:n.header,signal:n.signal,body:LS(n.message,zS(s.getI(e.useBinaryFormat)),VS(e.sendCompression,e.compressMinBytes),US(),{propagateDownStreamError:!0})}),{compression:i}=GC(t.methodKind,e.acceptCompression,e.useBinaryFormat,r.status,r.header),a=Object.assign(Object.assign({},n),{header:r.header,trailer:new Headers,message:LS(r.body,WS(e.readMaxBytes),HS(i??null,e.readMaxBytes),BS(s.getO(e.useBinaryFormat),2,c),function(e){return $C(this,arguments,function*(){var t,n,i,o;let s=!1;try{for(var c=!0,l=ZC(e),u;u=yield QC(l.next()),t=u.done,!t;c=!0){o=u.value,c=!1;let e=o;if(e.end){if(s)throw new TS(`protocol error: received extra EndStreamResponse`,M.InvalidArgument);if(s=!0,e.value.error){let t=e.value.error;throw r.header.forEach((e,n)=>{t.metadata.append(n,e)}),t}e.value.metadata.forEach((e,t)=>a.trailer.set(t,e));continue}if(s)throw new TS(`protocol error: received extra message after EndStreamResponse`,M.InvalidArgument);yield yield QC(e.value)}}catch(e){n={error:e}}finally{try{!c&&!t&&(i=l.return)&&(yield QC(i.call(l)))}finally{if(n)throw n.error}}if(!s)throw new TS(`protocol error: missing EndStreamResponse`,M.InvalidArgument)})},{propagateDownStreamError:!0})});return a}})}}}function tw(){try{new Headers}catch{throw Error(`connect-web requires the fetch API. Are you running on an old version of Node.js?`)}}var nw=function(e){return this instanceof nw?(this.v=e,this):new nw(e)},rw=function(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof nw?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}};const iw={redirect:`error`};function aw(e){tw();let t=e.useBinaryFormat??!1;return{async unary(n,r,i,a,o,s){let{serialize:c,parse:l}=DC(n,t,e.jsonOptions,e.binaryOptions);return i=i===void 0?e.defaultTimeoutMs:i<=0?void 0:i,await JC({interceptors:e.interceptors,signal:r,timeoutMs:i,req:{stream:!1,service:n.parent,method:n,requestMethod:`POST`,url:xC(e.baseUrl,n),header:HC(n.methodKind,t,i,a,!1),contextValues:s??cC(),message:o},next:async r=>{let i=e.useHttpGet===!0&&n.idempotency===Nb.NO_SIDE_EFFECTS,a=null;i?r=qC(r,c(r.message),t):a=c(r.message);let o=await(e.fetch??globalThis.fetch)(r.url,Object.assign(Object.assign({},iw),{method:r.requestMethod,headers:r.header,signal:r.signal,body:a})),{isUnaryError:s,unaryError:u}=WC(n.methodKind,t,o.status,o.headers);if(s)throw PC(await o.json(),ES(...VC(o.headers)),u);let[d,f]=VC(o.headers);return{stream:!1,service:n.parent,method:n,header:d,message:t?l(new Uint8Array(await o.arrayBuffer())):qx(n.output,await o.json(),TC(e.jsonOptions)),trailer:f}}})},async stream(n,r,i,a,o,s){let{serialize:c,parse:l}=DC(n,t,e.jsonOptions,e.binaryOptions);function u(e,t,n,r){return rw(this,arguments,function*(){let r=pre(e).getReader(),i=!1;for(;;){let e=yield nw(r.read());if(e.done)break;let{flags:a,data:o}=e.value;if((a&1)==1)throw new TS(`protocol error: received unsupported compressed output`,M.Internal);if((a&2)==2){i=!0;let e=LC(o);if(e.error){let t=e.error;throw n.forEach((e,n)=>{t.metadata.append(n,e)}),t}e.metadata.forEach((e,n)=>t.set(n,e));continue}yield yield nw(l(o))}if(!i)throw`missing EndStreamResponse`})}async function d(e){if(n.methodKind!=`server_streaming`)throw`The fetch API does not support streaming request bodies`;let t=await e[Symbol.asyncIterator]().next();if(t.done==1)throw`missing request message`;return kS(0,c(t.value))}return i=i===void 0?e.defaultTimeoutMs:i<=0?void 0:i,await YC({interceptors:e.interceptors,timeoutMs:i,signal:r,req:{stream:!0,service:n.parent,method:n,requestMethod:`POST`,url:xC(e.baseUrl,n),header:HC(n.methodKind,t,i,a,!1),contextValues:s??cC(),message:o},next:async r=>{let i=await(e.fetch??globalThis.fetch)(r.url,Object.assign(Object.assign({},iw),{method:r.requestMethod,headers:r.header,signal:r.signal,body:await d(r.message)}));if(WC(n.methodKind,t,i.status,i.headers),i.body===null)throw`missing response body`;let a=new Headers;return Object.assign(Object.assign({},r),{header:i.headers,trailer:a,message:u(i.body,a,i.headers,r.signal)})}})}}}var ow=Le(gv(),1);const sw=(e=0)=>t=>`\u001B[${t+e}m`,cw=(e=0)=>t=>`\u001B[${38+e};5;${t}m`,lw=(e=0)=>(t,n,r)=>`\u001B[${38+e};2;${t};${n};${r}m`,uw={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(uw.modifier);const dw=Object.keys(uw.color),fw=Object.keys(uw.bgColor);[...dw,...fw];function pw(){let e=new Map;for(let[t,n]of Object.entries(uw)){for(let[t,r]of Object.entries(n))uw[t]={open:`\u001B[${r[0]}m`,close:`\u001B[${r[1]}m`},n[t]=uw[t],e.set(r[0],r[1]);Object.defineProperty(uw,t,{value:n,enumerable:!1})}return Object.defineProperty(uw,"codes",{value:e,enumerable:!1}),uw.color.close=`\x1B[39m`,uw.bgColor.close=`\x1B[49m`,uw.color.ansi=sw(),uw.color.ansi256=cw(),uw.color.ansi16m=lw(),uw.bgColor.ansi=sw(10),uw.bgColor.ansi256=cw(10),uw.bgColor.ansi16m=lw(10),Object.defineProperties(uw,{rgbToAnsi256:{value(e,t,n){return e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5)},enumerable:!1},hexToRgb:{value(e){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(e=>e+e).join(``));let r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:e=>uw.rgbToAnsi256(...uw.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,r;if(e>=232)t=((e-232)*10+8)/255,n=t,r=t;else{e-=16;let i=e%36;t=Math.floor(e/36)/5,n=Math.floor(i/6)/5,r=i%6/5}let i=Math.max(t,n,r)*2;if(i===0)return 30;let a=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return i===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>uw.ansi256ToAnsi(uw.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>uw.ansi256ToAnsi(uw.hexToAnsi256(e)),enumerable:!1}}),uw}const mw=pw();function hw(e,t=globalThis.Deno?globalThis.Deno.args:ve.argv){let n=e.startsWith(`-`)?``:e.length===1?`-`:`--`,r=t.indexOf(n+e),i=t.indexOf(`--`);return r!==-1&&(i===-1||r<i)}const{env:gw}=ve;let _w;hw(`no-color`)||hw(`no-colors`)||hw(`color=false`)||hw(`color=never`)?_w=0:(hw(`color`)||hw(`colors`)||hw(`color=true`)||hw(`color=always`))&&(_w=1);function vw(){if(`FORCE_COLOR`in gw)return gw.FORCE_COLOR===`true`?1:gw.FORCE_COLOR===`false`?0:gw.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(gw.FORCE_COLOR,10),3)}function yw(e){return e!==0&&{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function bw(e,{streamIsTTY:t,sniffFlags:n=!0}={}){let r=vw();r!==void 0&&(_w=r);let i=n?_w:r;if(i===0)return 0;if(n){if(hw(`color=16m`)||hw(`color=full`)||hw(`color=truecolor`))return 3;if(hw(`color=256`))return 2}if(`TF_BUILD`in gw&&`AGENT_NAME`in gw)return 1;if(e&&!t&&i===void 0)return 0;let a=i||0;if(gw.TERM===`dumb`)return a;if(ve.platform===`win32`){let e=be.release().split(`.`);return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if(`CI`in gw)return[`GITHUB_ACTIONS`,`GITEA_ACTIONS`,`CIRCLECI`].some(e=>e in gw)?3:[`TRAVIS`,`APPVEYOR`,`GITLAB_CI`,`BUILDKITE`,`DRONE`].some(e=>e in gw)||gw.CI_NAME===`codeship`?1:a;if(`TEAMCITY_VERSION`in gw)return+!!/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(gw.TEAMCITY_VERSION);if(gw.COLORTERM===`truecolor`||gw.TERM===`xterm-kitty`||gw.TERM===`xterm-ghostty`||gw.TERM===`wezterm`)return 3;if(`TERM_PROGRAM`in gw){let e=Number.parseInt((gw.TERM_PROGRAM_VERSION||``).split(`.`)[0],10);switch(gw.TERM_PROGRAM){case`iTerm.app`:return e>=3?3:2;case`Apple_Terminal`:return 2}}return/-256(color)?$/i.test(gw.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(gw.TERM)||`COLORTERM`in gw?1:a}function xw(e,t={}){return yw(bw(e,{streamIsTTY:e&&e.isTTY,...t}))}const Sw={stdout:xw({isTTY:Ce.isatty(1)}),stderr:xw({isTTY:Ce.isatty(2)})};function Cw(e,t,n){let r=e.indexOf(t);if(r===-1)return e;let i=t.length,a=0,o=``;do o+=e.slice(a,r)+t+n,a=r+i,r=e.indexOf(t,a);while(r!==-1);return o+=e.slice(a),o}function ww(e,t,n,r){let i=0,a=``;do{let o=e[r-1]===`\r`;a+=e.slice(i,o?r-1:r)+t+(o?`\r
|
|
198
|
+
`:`
|
|
199
|
+
`)+n,i=r+1,r=e.indexOf(`
|
|
200
|
+
`,i)}while(r!==-1);return a+=e.slice(i),a}const{stdout:Tw,stderr:Ew}=Sw,Dw=Symbol(`GENERATOR`),Ow=Symbol(`STYLER`),kw=Symbol(`IS_EMPTY`),Aw=[`ansi`,`ansi`,`ansi256`,`ansi16m`],jw=Object.create(null),Mw=(e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw Error("The `level` option should be an integer from 0 to 3");let n=Tw?Tw.level:0;e.level=t.level===void 0?n:t.level},Nw=e=>{let t=(...e)=>e.join(` `);return Mw(t,e),Object.setPrototypeOf(t,Pw.prototype),t};function Pw(e){return Nw(e)}Object.setPrototypeOf(Pw.prototype,Function.prototype);for(let[e,t]of Object.entries(mw))jw[e]={get(){let n=Rw(this,Lw(t.open,t.close,this[Ow]),this[kw]);return Object.defineProperty(this,e,{value:n}),n}};jw.visible={get(){let e=Rw(this,this[Ow],!0);return Object.defineProperty(this,"visible",{value:e}),e}};const Fw=(e,t,n,...r)=>e===`rgb`?t===`ansi16m`?mw[n].ansi16m(...r):t===`ansi256`?mw[n].ansi256(mw.rgbToAnsi256(...r)):mw[n].ansi(mw.rgbToAnsi(...r)):e===`hex`?Fw(`rgb`,t,n,...mw.hexToRgb(...r)):mw[n][e](...r);for(let e of[`rgb`,`hex`,`ansi256`]){jw[e]={get(){let{level:t}=this;return function(...n){let r=Lw(Fw(e,Aw[t],`color`,...n),mw.color.close,this[Ow]);return Rw(this,r,this[kw])}}};let t=`bg`+e[0].toUpperCase()+e.slice(1);jw[t]={get(){let{level:t}=this;return function(...n){let r=Lw(Fw(e,Aw[t],`bgColor`,...n),mw.bgColor.close,this[Ow]);return Rw(this,r,this[kw])}}}}const Iw=Object.defineProperties(()=>{},{...jw,level:{enumerable:!0,get(){return this[Dw].level},set(e){this[Dw].level=e}}}),Lw=(e,t,n)=>{let r,i;return n===void 0?(r=e,i=t):(r=n.openAll+e,i=t+n.closeAll),{open:e,close:t,openAll:r,closeAll:i,parent:n}},Rw=(e,t,n)=>{let r=(...e)=>zw(r,e.length===1?``+e[0]:e.join(` `));return Object.setPrototypeOf(r,Iw),r[Dw]=e,r[Ow]=t,r[kw]=n,r},zw=(e,t)=>{if(e.level<=0||!t)return e[kw]?``:t;let n=e[Ow];if(n===void 0)return t;let{openAll:r,closeAll:i}=n;if(t.includes(`\x1B`))for(;n!==void 0;)t=Cw(t,n.close,n.open),n=n.parent;let a=t.indexOf(`
|
|
201
|
+
`);return a!==-1&&(t=ww(t,i,r,a)),r+t+i};Object.defineProperties(Pw.prototype,jw);const Bw=Pw();Pw({level:Ew?Ew.level:0});function Vw(e){"@babel/helpers - typeof";return Vw=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Vw(e)}function Hw(e,t){if(Vw(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(Vw(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Uw(e){var t=Hw(e,`string`);return Vw(t)==`symbol`?t:t+``}function Ww(e,t,n){return(t=Uw(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Gw(e){return RegExp(`^[\\t\\n\\v\\f\\r \\u0085\\u00a0\\p{Z}]$`,`u`).test(e)}function Kw(e){return RegExp(`^\\p{L}$`,`u`).test(e)}function qw(e){return RegExp(`^\\p{Nd}$`,`u`).test(e)}function Jw(e){return`@*#?-$!0`.includes(e)}var Yw=class{constructor(e){Ww(this,`chars`,void 0),Ww(this,`pos`,0),this.chars=Array.from(e)}peek(){return this.pos<this.chars.length?this.chars[this.pos]:null}next(){return this.pos<this.chars.length?this.chars[this.pos++]:null}},Xw=class{constructor(){Ww(this,`words`,[]),Ww(this,`buf`,``),Ww(this,`inWord`,!1)}addChar(e){Gw(e)&&this.inWord?this.buf.length!==0&&(this.words.push(this.buf),this.buf=``,this.inWord=!1):Gw(e)||this.addRawChar(e)}addRawChar(e){this.buf+=e,this.inWord=!0}addString(e){for(let t of e)this.addChar(t)}addRawString(e){this.buf+=e,this.inWord=!0}getWords(){return this.buf.length>0&&(this.words.push(this.buf),this.buf=``,this.inWord=!1),this.words}},Zw=class{constructor(e,t={}){Ww(this,`escapeToken`,void 0),Ww(this,`rawQuotes`,void 0),Ww(this,`rawEscapes`,void 0),Ww(this,`skipProcessQuotes`,void 0),Ww(this,`env`,void 0),Ww(this,`skipUnsetEnv`,void 0),this.escapeToken=e,this.rawQuotes=t.rawQuotes??!1,this.rawEscapes=t.rawEscapes??!1,this.skipProcessQuotes=t.skipProcessQuotes??!1,this.env=t.env??new Map,this.skipUnsetEnv=t.skipUnsetEnv??!0}processWord(e){return this.process(e).result}processWords(e){return this.process(e).words}process(e){let t=new Qw(new Yw(e),this.escapeToken,this.rawQuotes,this.rawEscapes,this.skipProcessQuotes,this.env,this.skipUnsetEnv);try{return t.processStopOn(null,this.rawEscapes)}catch(t){let n=t instanceof Error?t.message:String(t);throw Error(`failed to process ${JSON.stringify(e)}: ${n}`)}}},Qw=class{constructor(e,t,n,r,i,a,o){this.scanner=e,this.escapeToken=t,this.rawQuotes=n,this.rawEscapes=r,this.skipProcessQuotes=i,this.env=a,this.skipUnsetEnv=o}processStopOn(e,t){let n=``,r=new Xw,i=this.rawEscapes;this.rawEscapes=t;try{for(;this.scanner.peek()!==null;){let t=this.scanner.peek();if(e!==null&&t===e)return this.scanner.next(),{result:n,words:r.getWords()};let i=this.specialHandler(t);if(i){let e=i();n+=e,t===`$`?r.addString(e):r.addRawString(e);continue}if(t=this.scanner.next(),t===this.escapeToken){this.rawEscapes&&(r.addRawChar(t),n+=t);let e=this.scanner.next();if(e===null)break;t=e,r.addRawChar(t)}else r.addChar(t);n+=t}}finally{this.rawEscapes=i}if(e!==null)throw Error(`unexpected end of statement while looking for matching ${e}`);return{result:n,words:r.getWords()}}specialHandler(e){switch(e){case`$`:return()=>this.processDollar();case`<`:return()=>this.processPossibleHeredoc();case`'`:return this.skipProcessQuotes?void 0:()=>this.processSingleQuote();case`"`:return this.skipProcessQuotes?void 0:()=>this.processDoubleQuote();default:return}}processSingleQuote(){let e=``,t=this.scanner.next();for(this.rawQuotes&&(e+=t);;){let n=this.scanner.next();if(n===null)throw Error(`unexpected end of statement while looking for matching single-quote`);if(t=n,t===`'`)return this.rawQuotes&&(e+=t),e;e+=t}}processDoubleQuote(){let e=``,t=this.scanner.next();for(this.rawQuotes&&(e+=t);;){let t=this.scanner.peek();if(t===null)throw Error(`unexpected end of statement while looking for matching double-quote`);if(t===`"`){let t=this.scanner.next();return this.rawQuotes&&(e+=t),e}if(t===`$`){e+=this.processDollar();continue}let n=this.scanner.next();if(n===this.escapeToken){this.rawEscapes&&(e+=n);let t=this.scanner.peek();if(t===null)continue;(t===`"`||t===`$`||t===this.escapeToken)&&(n=this.scanner.next())}e+=n}}processDollar(){if(this.scanner.next(),this.scanner.peek()!==`{`){let e=this.processName();if(e===``)return`$`;let t=this.env.get(e);return t===void 0&&this.skipUnsetEnv?`$`+e:t??``}this.scanner.next();let e=this.scanner.peek();if(e===null)throw Error(`syntax error: missing '}'`);if(e===`{`||e===`}`||e===`:`)throw Error(`syntax error: bad substitution`);let t=this.processName(),n=this.scanner.next();if(n===null)throw Error(`syntax error: missing '}'`);let r=n,i=this.env.get(t);if(n===`}`)return i===void 0&&this.skipUnsetEnv?"${"+t+`}`:i??``;let a=!1;if(n===`:`){a=!0;let e=this.scanner.next();if(e===null)throw Error(`syntax error: missing '}'`);n=e,r+=n}if(!a){if(n===`/`)return this.processDollarReplace(t);if(!`+-?#%`.includes(n))throw Error(`unsupported modifier (${r}) in substitution`)}let o=n===`#`||n===`%`;if(a&&o)throw Error(`unsupported modifier (${r}) in substitution`);let s=this.processStopOnOrMissingBrace(`}`,o);if(i===void 0&&this.skipUnsetEnv)return"${"+t+r+s+`}`;let c=i===void 0||a&&i===``;switch(n){case`-`:return c?s:i;case`+`:return c?``:s;case`?`:if(i===void 0)throw Error(`${t}: ${s||`is not allowed to be unset`}`);if(c)throw Error(`${t}: ${s||`is not allowed to be empty`}`);return i;case`#`:case`%`:{let e=s.startsWith(n),t=e?s.slice(1):s;return n===`%`?rT(t,i??``,e):eT(t,i??``,e)}default:throw Error(`unsupported modifier (${r}) in substitution`)}}processDollarReplace(e){let t=`/`;this.scanner.peek()===`/`&&(this.scanner.next(),t=`//`);let n;try{n=this.processStopOn(`/`,!0).result}catch(e){throw this.scanner.peek()===null?Error("syntax error: missing '/' in ${}"):e}let r=this.processStopOnOrMissingBrace(`}`,!0),i=this.env.get(e);if(i===void 0&&this.skipUnsetEnv)return"${"+e+t+n+`/`+r+`}`;let a=$w(n,!0,!1,t===`//`);return(i??``).replace(a,()=>r)}processStopOnOrMissingBrace(e,t){try{return this.processStopOn(e,t).result}catch(e){throw this.scanner.peek()===null?Error(`syntax error: missing '}'`):e}}processName(){let e=``;for(;;){let t=this.scanner.peek();if(t===null)break;if(e.length===0&&qw(t)){let e=``;for(;;){let t=this.scanner.peek();if(t===null||!qw(t))break;e+=this.scanner.next()}return e}if(e.length===0&&Jw(t))return this.scanner.next();if(!Kw(t)&&!qw(t)&&t!==`_`)break;e+=this.scanner.next()}return e}processPossibleHeredoc(){if(this.scanner.next(),this.scanner.peek()!==`<`)return`<`;this.scanner.next();let e=``;for(;;){let t=this.scanner.peek();if(t!==` `&&t!==`\r`&&t!==` `)break;e+=this.scanner.next()}return`<<`+e}};function $w(e,t,n,r=!1){let i=Array.from(e),a=n?`^`:``,o=t?`.*`:`.*?`;for(let t=0;t<i.length;t++){let n=i[t];if(n===`*`){a+=o;continue}if(n===`?`){a+=`.`;continue}if(n===`\\`){let r=i[t+1];if(r===`}`||r===`/`)continue;if(t++,r!==`*`&&r!==`?`&&r!==`\\`)throw Error(`invalid pattern (${e}) in substitution: invalid escape '\\${r??``}'`);n=r}`[]{}.+()|^$*?\\`.includes(n)&&(a+=`\\`),a+=n}return new RegExp(a,r?`gu`:`u`)}function eT(e,t,n){return t.replace($w(e,n,!0),``)}function tT(e){let t=Array.from(e),n=[];for(let e=0;e<t.length;e++)t[e]===`\\`&&e+1<t.length?(n.unshift(t[e],t[e+1]),e++):n.unshift(t[e]);return n.join(``)}function nT(e){return Array.from(e).reverse().join(``)}function rT(e,t,n){return nT(eT(tT(e),nT(t),n))}var iT=class extends Error{constructor(e,t){super(t===void 0?`Dockerfile parse error: ${e}`:`Dockerfile parse error on line ${t}: ${e}`),this.line=t,this.name=`DockerfileSyntaxError`}};function aT(e,t){try{return t()}catch(t){throw t instanceof iT?t:new iT(t instanceof Error?t.message:String(t),e)}}const oT=/[\t\v\f\r ]+/,sT=/^#\s*([a-zA-Z][a-zA-Z0-9]*)\s*=\s*(.+?)\s*$/,cT=new Set([`syntax`,`escape`,`check`]),lT=new Set([`ADD`,`COPY`,`RUN`]);function uT(e){let t=e.length;for(;t>0&&(e[t-1]===`
|
|
202
|
+
`||e[t-1]===`\r`);)t--;return e.slice(0,t)}function dT(e){return e.replace(RegExp(`^[\\t\\n\\v\\f\\r \\u0085\\u00a0\\p{Z}]+`,`u`),``)}function fT(e){return dT(e).startsWith(`#`)}function pT(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function mT(e){return e.match(/[^\n]*\n|[^\n]+$/g)??[]}var hT=class{constructor(){Ww(this,`escapeToken`,`\\`),Ww(this,`continuation`,this.buildContinuationRegex(`\\`)),Ww(this,`done`,!1),Ww(this,`seen`,new Set)}possibleParserDirective(e){if(this.done)return!1;let t=sT.exec(e);if(!t)return this.done=!0,!1;let n=t[1].toLowerCase();if(!cT.has(n))return this.done=!0,!1;if(this.seen.has(n))throw Error(`only one ${n} parser directive can be used`);return this.seen.add(n),n===`escape`&&this.setEscapeToken(t[2]),!0}trimContinuation(e){return this.continuation.test(e)?{line:e.replace(this.continuation,`$1`),isEndOfLine:!1}:{line:e,isEndOfLine:!0}}setEscapeToken(e){if(e!=="`"&&e!==`\\`)throw Error(`invalid escape token '${e}' does not match \` or \\`);this.escapeToken=e,this.continuation=this.buildContinuationRegex(e)}buildContinuationRegex(e){let t=pT(e);return RegExp(`([^${t}])${t}[ \\t]*$|^${t}[ \\t]*$`)}};function gT(e){return{args:e===``?[]:[e],json:!1}}function _T(){return{args:[],json:!1}}function vT(e){return e===``?{args:[],json:!1}:{args:e.split(oT),json:!1}}var yT=class extends Error{},bT=class extends Error{};function xT(e){if(e=dT(e),!e.startsWith(`[`))throw new yT;let t;try{t=JSON.parse(e)}catch{throw new yT}if(!Array.isArray(t))throw new yT;for(let e of t)if(typeof e!=`string`)throw new bT(`Only strings are supported in JSON arrays`);return t}function ST(e){if(e===``)return{args:[],json:!1};try{return{args:xT(e),json:!0}}catch(t){if(t instanceof bT)throw t;return{args:[e],json:!1}}}function gre(e){let t=Array.from(e),n=0;for(;n<t.length&&!Gw(t[n]);)n++;let r=n;for(;r<t.length&&Gw(t[r]);)r++;if(n===0)return{args:[],json:!1};let{args:i,json:a}=ST(t.slice(r).join(``));return{args:[t.slice(0,n).join(``),...i],json:a}}function _re(e){try{return{args:xT(e),json:!0}}catch(t){if(t instanceof bT)throw t;return vT(e)}}function CT(e,t){let n=Array.from(e),r=[],i=`spaces`,a=``,o=!1,s=``;for(let e=0;e<=n.length;e++){let c=n[e];if(i===`spaces`){if(e===n.length)break;if(Gw(c))continue;i=`word`}if(e===n.length){(o||s.length>0)&&r.push(s);break}if(i===`word`){if(Gw(c)){i=`spaces`,(o||s.length>0)&&r.push(s),s=``,o=!1;continue}if((c===`'`||c===`"`)&&(a=c,o=!0,i=`quote`),c===t){if(e+1===n.length)continue;s+=c,e++,s+=n[e];continue}s+=c;continue}if(c===a&&(i=`word`),c===t&&a!==`'`){if(e+1===n.length){i=`word`;continue}s+=c,e++,s+=n[e];continue}s+=c}return r}function wT(e,t){try{return{args:xT(e),json:!0}}catch(n){if(n instanceof bT)throw n;return{args:CT(e,t),json:!1}}}function vre(e,t){return{args:CT(e,t),json:!1}}function TT(e){return(t,n)=>{let r=CT(t,n);if(r.length===0)return{args:[],json:!1};if(!r[0].includes(`=`)){let n=oT.exec(t);if(!n)throw Error(`${e} must have two arguments`);return{args:[t.slice(0,n.index),t.slice(n.index+n[0].length),``],json:!1}}let i=[];for(let e of r){if(!e.includes(`=`))throw Error(`Syntax error - can't find = in "${e}". Must be of the form: name=value`);let t=e.indexOf(`=`);i.push(e.slice(0,t),e.slice(t+1),`=`)}return{args:i,json:!1}}}const yre={ADD:wT,ARG:vre,CMD:ST,COPY:wT,ENTRYPOINT:ST,ENV:TT(`ENV`),EXPOSE:vT,FROM:vT,HEALTHCHECK:gre,LABEL:TT(`LABEL`),MAINTAINER:gT,ONBUILD:_T,RUN:ST,SHELL:ST,STOPSIGNAL:gT,USER:gT,VOLUME:_re,WORKDIR:gT};function bre(e,t){let n=Array.from(e),r=[],i=`spaces`,a=``,o=!1,s=``;for(let e=0;e<=n.length;e++){let c=n[e];if(i===`spaces`){if(e===n.length)break;if(Gw(c))continue;if(c!==`-`||e+1===n.length||n[e+1]!==`-`)return{rest:n.slice(e).join(``),flags:r};i=`word`}if(e===n.length){s!==`--`&&(o||s.length>0)&&r.push(s);break}if(i===`word`){if(Gw(c)){if(i=`spaces`,s===`--`)return{rest:n.slice(e).join(``),flags:r};(o||s.length>0)&&r.push(s),s=``,o=!1;continue}if(c===`'`||c===`"`){a=c,o=!0,i=`quote`;continue}if(c===t){if(e+1===n.length)continue;e++,s+=n[e];continue}s+=c;continue}if(c===a){i=`word`;continue}if(c===t){if(e+1===n.length){i=`word`;continue}e++,s+=n[e];continue}s+=c}return{rest:``,flags:r}}function xre(e,t){let n=e.trim(),r=oT.exec(n);if(!r)return{command:n,flags:[],rest:``};let i=n.slice(0,r.index),{rest:a,flags:o}=bre(n.slice(r.index+r[0].length),t);return{command:i,flags:o,rest:a.trim()}}function Sre(e){let t=0;for(;t<e.length&&e[t]>=`0`&&e[t]<=`9`;)t++;if(!e.startsWith(`<<`,t))return;let n=e.slice(0,t);t+=2;let r=e[t]===`-`;for(r&&t++;t<e.length&&`
|
|
203
|
+
\f\r `.includes(e[t]);)t++;let i=e.slice(t);if(!i.includes(`<`))return{fileDescriptor:n,chomp:r,rest:i}}function ET(e){let t=Sre(e);if(!t)return;let n=t.fileDescriptor===``?0:parseInt(t.fileDescriptor,10),{chomp:r,rest:i}=t;if(i.length===0)return;let a=new Zw(`\\`).processWords(i);if(a.length!==1)return;let o=new Zw(`\\`,{rawQuotes:!0}).processWords(i);if(o.length!==a.length)throw Error(`internal lexing of heredoc produced inconsistent results: ${i}`);let s=e=>(e.match(/'/g)??[]).length+(e.match(/"/g)??[]).length,c=s(a[0])===s(o[0]);return{name:a[0],content:``,chomp:r,expand:c,fileDescriptor:n}}function Cre(e){let t;try{t=new Zw(`\\`,{rawQuotes:!0,rawEscapes:!0}).processWords(e)}catch{return[]}let n=[];for(let e of t){let t=ET(e);t&&n.push(t)}return n}function DT(e){return e.replace(/^\t+/gm,``)}function wre(e){let t=new hT,n=mT(e.replace(/^\uFEFF/,``)),r=[],i=[],a=0,o=0,s=(e,n)=>{let r=uT(e);return n&&(r=dT(r)),aT(a+1,()=>t.possibleParserDirective(r)),fT(r)?``:r};for(;o<n.length;){let e=n[o++],c=s(e,!0);a++;let l=a,u=t.trimContinuation(c);c=u.line;let d=u.isEndOfLine;if(d&&c.length===0)continue;let f=!1;for(;!d&&o<n.length;){let e=n[o++],r=s(e,!1);if(a++,fT(e))continue;if(dT(uT(e)).length===0){f=!0;continue}let i=t.trimContinuation(r);d=i.isEndOfLine,c+=i.line}f&&i.push({message:`Empty continuation line found in: ${c}`,line:a});let{command:p,flags:m,rest:h}=xre(c,t.escapeToken),g=p.toUpperCase(),_=yre[g];if(!_)throw new iT(`unknown instruction: ${p}`,l);let v=aT(l,()=>_(h,t.escapeToken)),y={name:g,original:c,flags:m,args:v.args,json:v.json,heredocs:[],startLine:l,endLine:a};if(lT.has(g)&&!v.json&&c.includes(`<<`)){let e=aT(l,()=>Cre(c));for(let t of e){let e=!1;for(;o<n.length;){let r=n[o++];a++;let i=uT(r);if(t.chomp&&(i=i.replace(/^\t+/,``)),i===t.name){e=!0;break}t.content+=r}if(!e)throw new iT(`unterminated heredoc`,l);y.heredocs.push(t)}y.endLine=a}r.push(y)}return{instructions:r,escapeToken:t.escapeToken,warnings:i}}const Tre=new Set([`.`,`+`,`(`,`)`,`|`,`{`,`}`,`$`,`^`]),Ere=/[*?[\\]/;function Dre(e){return e.replace(/[.*+?^${}()|[\]\\/]/g,`\\$&`)}const Ore=new Set(`dDsSwWfnrtv`),OT={a:`\\x07`,b:`\\x08`},kT={x:2,u:4,U:8},kre=new Set(`^$\\.*+?()[]{}|/-`);function Are(e,t){let n=``,r=0;for(;r<e.length;){let i=e[r++];if(i!==`\\`)n+=i;else if(!t||r>=e.length)n+=`\\\\`;else{let t=e[r++];if(Ore.has(t))n+=`\\`+t;else if(t in OT)n+=OT[t];else if(t in kT){let i=kT[t],a=e.slice(r,r+i);if(a.length<i||!/^[0-9a-fA-F]+$/.test(a))throw Error(`incomplete escape \\${t}${a}`);let o=parseInt(a,16);if(o>1114111)throw Error(`bad escape \\${t}${a}`);n+=`\\u{${o.toString(16)}}`,r+=i}else if(/[0-7]/.test(t)){let i=t;for(;i.length<3&&/[0-7]/.test(e[r]??``);)i+=e[r++];let a=parseInt(i,8);if(a>255)throw Error(`octal escape value \\${i} outside of range 0-0o377`);n+=`\\u{${a.toString(16)}}`}else if(/[A-Za-z0-9]/.test(t))throw Error(`bad escape \\${t}`);else n+=kre.has(t)?`\\`+t:t}}return n}function jre(e){let t=e.startsWith(`/`),n=[];for(let r of e.split(`/`))if(r!==``&&r!==`.`){if(r===`..`){n.length>0&&n[n.length-1]!==`..`?n.pop():t||n.push(`..`);continue}n.push(r)}let r=(t?`/`:``)+n.join(`/`);return r===``?`.`:r}const AT=`syntax error in pattern`;function jT(e,t,n){let r=e.length;if(t>=r||e[t]===`-`||e[t]===`]`||e[t]===`\\`&&n&&(t++,t>=r)||(t+=e.codePointAt(t)>65535?2:1,t>=r))throw Error(AT);return t}function Mre(e,t){let n=e.length,r=0;for(;r<n;){let i=e[r++];if(i===`\\`&&t){if(r>=n)throw Error(AT);r++}else if(i===`[`){e[r]===`^`&&r++;let n=0;for(;!(n>0&&e[r]===`]`);)r=jT(e,r,t),e[r]===`-`&&(r=jT(e,r+1,t)),n++;r++}}}function Nre(e,t){Mre(e,t);let n=`^`,r=`exact`,i=e.length,a=0;for(;a<i;){let o=a===0,s=e[a++];if(s===`*`)e[a]===`*`?(a++,e[a]===`/`&&a++,a>=i?(n+=`.*`,r=r===`exact`?`prefix`:`regex`):(n+=`(.*/)?`,r=`regex`),o&&(r=`suffix`)):(n+=`[^/]*`,r=`regex`);else if(s===`?`)n+=`[^/]`,r=`regex`;else if(s===`[`){let o=a;for(e[o]===`^`&&o++;o<i&&e[o]!==`]`;)e[o]===`\\`&&t&&o++,o++;n+=`[`+Are(e.slice(a,Math.min(o,i)),t)+(o<i?`]`:``),a=o+1,r=`regex`}else s===`]`?(n+=`\\]`,r=`regex`):Tre.has(s)?n+=`\\`+s:s===`\\`&&t?a<i?(n+=Dre(e[a++]),r=`regex`):n+=`\\\\`:n+=s}switch(r){case`exact`:return t=>t===e;case`prefix`:{let t=e.slice(0,-2);return e=>e.startsWith(t)}case`suffix`:{let t=e.slice(2);return e=>e.endsWith(t)||t[0]===`/`&&e===t.slice(1)}case`regex`:{let e=RegExp(n+`$`,`u`);return t=>e.test(t)}}}var Pre=class{constructor(e,t={}){Ww(this,`compiled`,[]),Ww(this,`backslashIsSeparator`,void 0),Ww(this,`patterns`,[]);let n=t.backslashIsSeparator??!1;this.backslashIsSeparator=n;for(let t of e){if(t.startsWith(`#`))continue;let e=t.trim();if(!e)continue;let r=e.startsWith(`!`);if(r&&(e=e.slice(1).trim(),!e))throw Error(`Invalid ignore pattern '${t}': illegal exclusion pattern`);n&&(e=e.replace(/\\/g,`/`)),e=jre(e),e.length>1&&e.startsWith(`/`)&&(e=e.slice(1));let i;try{i=Nre(e,!n)}catch(e){throw Error(`Invalid ignore pattern '${t}': ${e.message}`)}this.compiled.push({exclusion:r,dirs:e.split(`/`),match:i}),this.patterns.push((r?`!`:``)+e)}}toSlash(e){return this.backslashIsSeparator?e.replace(/\\/g,`/`):e}matches(e){let t=this.toSlash(e).split(`/`),n=[],r=!1;for(let e=1;e<=t.length;e++){let i=t.slice(0,e).join(`/`);r=!1,n=this.compiled.map((e,t)=>{let a=n[t]??!1;if(!a){if(e.exclusion!==r)return!1;a=e.match(i)}return a&&(r=!e.exclusion),a})}return r}mayMatchUnder(e){let t=this.toSlash(e).split(`/`);return this.compiled.some(e=>e.exclusion&&Fre(e,t))}};function Fre(e,t){for(let n=0;n<t.length;n++){if(n>=e.dirs.length)return!1;let r=e.dirs[n];if(r.includes(`**`))return!0;if(!Ere.test(r)&&r!==t[n])return!1}return e.dirs.length>t.length}var MT=`2.63.0`;function NT(e){"@babel/helpers - typeof";return NT=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},NT(e)}function Ire(e,t){if(NT(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(NT(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Lre(e){var t=Ire(e,`string`);return NT(t)==`symbol`?t:t+``}function P(e,t,n){return(t=Lre(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function PT(e){return e.includes(`was not found`)}function FT(e){return e.includes(`port is not open`)}function IT(e){return PT(e)?new HT(`${e}: The sandbox was killed or reached its timeout. You can modify the sandbox timeout by passing 'timeoutMs' when starting the sandbox or calling '.setTimeout' on the sandbox with the desired timeout.`):FT(e)?new UT(`${e}: The sandbox is running but envd inside it could not be reached (e.g. its network is down). Check the sandbox state with 'Sandbox.getInfo()'.`):new UT(`${e}: The sandbox could not be reached and its state is unknown — it may have been killed or reached its timeout, or the connection to it was lost. Check the sandbox state with 'Sandbox.getInfo()'.`)}var LT=class extends Error{constructor(e){super(e),P(this,`statusCode`,void 0),this.name=`SandboxError`}},RT=class extends LT{constructor(e){super(e),this.name=`TimeoutError`}},F=class extends LT{constructor(e,t){super(e),this.name=`InvalidArgumentError`,t&&(this.stack=t)}},Rre=class extends LT{constructor(e){super(e),this.name=`NotEnoughSpaceError`}},zT=class extends LT{constructor(e){super(e),this.name=`NotFoundError`}},BT=class extends zT{constructor(e){super(e),this.name=`FileNotFoundError`}},VT=class extends zT{constructor(e){super(e),this.name=`SandboxNotFoundError`}},HT=class extends RT{constructor(e,t){super(e),this.name=`SandboxNotRunningError`,t?.cause!==void 0&&(this.cause=t.cause)}},UT=class extends RT{constructor(e,t){super(e),this.name=`SandboxUnreachableError`,t?.cause!==void 0&&(this.cause=t.cause)}},WT=class extends Error{constructor(e){super(e),this.name=`AuthenticationError`}},GT=class extends WT{constructor(e){super(e),this.name=`GitAuthError`}},KT=class extends LT{constructor(e){super(e),this.name=`GitUpstreamError`}},qT=class extends LT{constructor(e,t){super(e),this.name=`TemplateError`,t&&(this.stack=t)}},JT=class extends LT{constructor(e){super(e),this.name=`RateLimitError`,this.statusCode=429}},zre=class extends Error{constructor(e){super(e),P(this,`statusCode`,503),this.name=`ServiceBusyError`}},YT=class extends LT{constructor(e){super(e),this.name=`GuestUnresponsiveError`,this.statusCode=409}};P(YT,`code`,`sandbox_snapshot_guest_agent_unresponsive`);var XT=class extends Error{constructor(e,t){super(e),this.name=`BuildError`,t&&(this.stack=t)}},ZT=class extends XT{constructor(e,t){super(e,t),this.name=`FileUploadError`}};function QT(e){return typeof e==`object`&&!!e}function Bre(e){return Object.prototype.toString.call(e).slice(8,-1)}function Vre(e){return e instanceof Request||QT(e)&&typeof e.url==`string`&&typeof e.method==`string`&&typeof e.clone==`function`}function Hre(e){if(e instanceof Blob)return!0;if(!QT(e))return!1;let t=Bre(e);return(t===`Blob`||t===`File`)&&typeof e.arrayBuffer==`function`}function $T(e){return e instanceof ReadableStream||QT(e)&&typeof e.getReader==`function`&&typeof e.tee==`function`&&typeof e.cancel==`function`}function eE(e){return QT(e)&&typeof e[Symbol.asyncIterator]==`function`}function Ure(){var e;return globalThis.Bun?{runtime:`bun`,version:globalThis.Bun.version}:globalThis.Deno?{runtime:`deno`,version:globalThis.Deno.version.deno}:typeof EdgeRuntime==`string`?{runtime:`vercel-edge`,version:`unknown`}:globalThis.navigator?.userAgent===`Cloudflare-Workers`?{runtime:`cloudflare-worker`,version:`unknown`}:((e=globalThis.process)==null||(e=e.release)==null?void 0:e.name)===`node`?{runtime:`node`,version:ow.default.version||`unknown`}:typeof window<`u`?{runtime:`browser`,version:ow.default.version||`unknown`}:{runtime:`unknown`,version:`unknown`}}const{runtime:tE,version:Wre}=Ure();async function Gre(e){let t=new TextEncoder().encode(e),n=await crypto.subtle.digest(`SHA-256`,t),r=new Uint8Array(n);return btoa(String.fromCharCode(...r))}function nE(e){return Math.ceil(e/1e3)}async function rE(e){if(tE===`browser`)throw Error(`Browser runtime is not supported for dynamic import`);return await Promise.reject(Error(`impulse-compute loads no package at run time`))}function Kre({onlyFirst:e=!1}={}){return RegExp(`(?:\\u001B[\\]PX^_][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]`,e?void 0:`g`)}function qre(e){return e.replace(Kre(),``)}function iE(){try{var e;let t=(e=new Blob).stream?.call(e);if(t)return t.constructor}catch{}return ReadableStream}function aE(e){let t=iE();if(e instanceof t)return e;let n=e.getReader();return new t({async pull(e){let{done:t,value:r}=await n.read();if(t){e.close();return}e.enqueue(r)},cancel(e){return n.cancel(e)}})}function oE(e){return e instanceof iE()||Symbol.asyncIterator in e?e:aE(e)}function sE(e){return $T(e)||eE(e)}function cE(e){if(e instanceof Uint8Array||ArrayBuffer.isView(e)&&Object.prototype.toString.call(e)===`[object Uint8Array]`)return new Uint8Array(e);throw new F(`AsyncIterable upload data must yield Uint8Array chunks, got ${e===null?`null`:typeof e==`object`?e.constructor?.name??`object`:typeof e}`)}function lE(e,t){let n=e[Symbol.asyncIterator]();return new(iE())({async pull(e){let{done:r,value:i}=await n.next();if(r){e.close();return}let a;try{a=cE(i)}catch(e){throw await n.return?.call(n).catch(()=>{}),t(e),e}e.enqueue(a)},async cancel(e){await n.return?.call(n,e)}})}async function uE(e){return e instanceof Blob?e:Hre(e)?new Blob([await e.arrayBuffer()],{type:e.type}):new Blob([e])}const dE=/[^\w@%+=:,./-]/;function fE(e){return e===``?`''`:dE.test(e)?`'`+e.replace(/'/g,`'"'"'`)+`'`:e}function pE(){let e=!1,t=iE(),n=new Request(`https://e2b.invalid`,{body:new t,method:`POST`,get duplex(){return e=!0,`half`}}).headers.has(`Content-Type`);return e&&!n}async function mE(e,t){if(sE(e)){if(tE===`browser`&&!pE())throw new F("This browser can't stream request bodies, and stream data is never buffered. Pass the data as a `Blob` instead, e.g. `await new Response(stream).blob()`.");let n,r=eE(e)&&!$T(e)?lE(e,e=>{n=e}):t||tE===`browser`?aE(e):oE(e);return{body:t?r.pipeThrough(new CompressionStream(`gzip`)):r,streamed:!0,sourceError:()=>n}}let n=()=>void 0;if(t){let t=(await uE(e)).stream().pipeThrough(new CompressionStream(`gzip`));return tE===`browser`?{body:await new Response(t).blob(),streamed:!1,sourceError:n}:{body:t,streamed:!0,sourceError:n}}return{body:await uE(e),streamed:!1,sourceError:n}}const hE={browser:typeof window<`u`&&ow.default.name||`unknown`,lang:`js`,lang_version:Wre,package_version:MT,publisher:`e2b`,sdk_runtime:tE,system:ow.default.os?.family||`unknown`};function gE(e){return tE===`deno`?Deno.env.get(e):typeof process>`u`?``:process.env[e]}function _E(e,t){let n=gE(e);if(!n)return t;let r=Number.parseInt(n,10);if(!Number.isFinite(r))throw Error(`Invalid ${e}=${JSON.stringify(n)}: expected an integer.`);return r}function vE(e,t){let n=_E(e,t);if(n<1)throw Error(`Invalid ${e}=${n}: expected a positive integer.`);return n}const yE=new Set([429,502,503,504]),bE=new Set([`ECONNREFUSED`,`ENOTFOUND`,`EAI_AGAIN`,`EHOSTUNREACH`,`ENETUNREACH`,`ENETDOWN`,`EHOSTDOWN`,`UND_ERR_CONNECT_TIMEOUT`,`ConnectionRefused`]),xE=new Set([`connect`,`getaddrinfo`]),SE=/client error \(Connect\)/,CE=/^(Failed to fetch|Load failed|NetworkError when attempting to fetch resource\.?)$/;function wE(e){if(!Number.isInteger(e)||e<0)throw new F(`Invalid retries=${e}: expected a non-negative integer.`);return e}const TE=/^[a-z0-9-]{1,255}$/;function EE(e){if(e!==void 0){if(e.length<1||e.length>255)throw new F(`Invalid idempotencyKey: expected 1-255 characters, got ${e.length}.`);if(!TE.test(e))throw new F(`Invalid idempotencyKey: only lowercase letters, digits and hyphens are allowed.`);return e}}function DE(e){if(!e)return;let t=e.trim();if(!/^\d+$/.test(t))return;let n=Number(t);return Number.isSafeInteger(n)&&n<=2147483?n:void 0}function OE(e,t=0){if(!(e instanceof Error)||t>4)return!1;let{code:n,syscall:r}=e;return typeof n==`string`&&bE.has(n)||typeof r==`string`&&xE.has(r)||SE.test(e.message)?!0:e instanceof AggregateError?e.errors.some(e=>OE(e,t+1)):OE(e.cause,t+1)}function kE(e){return OE(e)?!0:e instanceof Error&&CE.test(e.message)}function AE(e){return e instanceof DOMException?!1:OE(e)}function jE(e,t){return t.aborted?Promise.reject(t.reason):new Promise((n,r)=>{let i=()=>{clearTimeout(a),r(t.reason)},a=setTimeout(()=>{t.removeEventListener(`abort`,i),n()},e);t.addEventListener(`abort`,i,{once:!0})})}function ME(e,t){let n=Math.min(100*2**e,1e4);return Math.floor(n*(.5+t()*.5))}function NE(e,t,n){let r=e.headers.get(`Should-Retry`);if(!(r===null?yE.has(e.status):r.trim().toLowerCase()===`true`))return;let i=DE(e.headers.get(`Retry-After`));return i===void 0?ME(t,n):i*1e3}function PE(e,t,n,r={}){let i=r.monotonic??(()=>performance.now()),a=r.sleep??jE,o=r.random??Math.random;return(async(r,s)=>{if(t===0||$T(s?.body))return e(r,s);let c=r instanceof Request&&s===void 0?r:new Request(r,s),l=i()+(n||6e4);for(let n=0;;n++){var u;let r;try{r=await e(n===t?c:c.clone())}catch(e){if(n===t||c.signal.aborted||!AE(e))throw e;let r=ME(n,o);if(i()+r>=l)throw e;await a(r,c.signal);continue}if(n===t)return r;let s=NE(r,n,o);if(s===void 0||i()+s>=l)return r;(u=r.body)==null||u.cancel().catch(()=>{}),await a(s,c.signal)}})}function FE(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function I(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?FE(Object(n),!0).forEach(function(t){P(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):FE(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}const IE=[`e2b.app`,`e2b.dev`,`e2b.pro`,`e2b-staging.dev`,`e2b-tango.dev`,`e2b-juliett.dev`,`foxtrot-2.e2b.dev`],LE=`Keepalive-Ping-Interval`;function RE(e){let t=`httpVersion`;if(e===void 0&&(t=`E2B_HTTP_VERSION`,e=gE(`E2B_HTTP_VERSION`)||`2`),e!==`1.1`&&e!==`2`)throw new F(`${t} must be '1.1' or '2', got '${e}'`);return e}function zE(e,t){let n=e?AbortSignal.timeout(e):void 0;return n&&t?AbortSignal.any([n,t]):n??t}function BE(e,t){let n=new AbortController,r=()=>HE(n,t?.reason);t&&(t.aborted?HE(n,t.reason):t.addEventListener(`abort`,r,{once:!0}));let i=e?setTimeout(()=>HE(n,new DOMException(`Request handshake timed out after ${e}ms`,`TimeoutError`)),e):void 0,a=()=>{i&&=(clearTimeout(i),void 0)},o=!1;return{controller:n,clearStartTimeout:a,cleanup:()=>{o||(o=!0,t?.removeEventListener(`abort`,r),a(),n.abort())}}}function VE(e,t,n){let r,i=()=>{r&&=(clearTimeout(r),void 0)};return{arm:()=>{t&&(i(),r=setTimeout(()=>HE(e,new DOMException(`${n} idle for ${t}ms`,`TimeoutError`)),t))},clear:i}}function HE(e,t){e.signal.aborted||(e.__e2bAbortReason=t,e.abort(t))}function UE(e,{clearStartTimeout:t,cleanup:n,controller:r,idleTimeoutMs:i}){if(t(),!e)return n(),new Blob([]).stream();let a=e.getReader(),o=VE(r,i,`Stream`),s=!1,c=()=>{s||(s=!0,o.clear(),n())};return new ReadableStream({async pull(e){o.arm();try{let{done:t,value:n}=await a.read();o.clear(),t?(c(),e.close()):e.enqueue(n)}catch(t){c(),e.error(t)}},async cancel(e){try{await a.cancel(e)}finally{c()}}})}var WE=class e{static buildUserAgent(){let t=[`${e.sdkUserAgentPrefix}${MT}`];return e.integration&&t.push(e.integration),t.join(` `)}static applyUserAgent(t){let n=t[`User-Agent`];(n===void 0||n.startsWith(e.sdkUserAgentPrefix))&&(t[`User-Agent`]=e.buildUserAgent())}static setIntegration(t){e.integration=t}constructor(t){P(this,`debug`,void 0),P(this,`domain`,void 0),P(this,`apiUrl`,void 0),P(this,`sandboxUrl`,void 0),P(this,`logger`,void 0),P(this,`requestTimeoutMs`,void 0),P(this,`retries`,void 0),P(this,`apiKey`,void 0),P(this,`validateApiKey`,void 0),P(this,`headers`,void 0),P(this,`proxy`,void 0),P(this,`httpVersion`,void 0),this.apiKey=t?.apiKey||e.apiKey,this.validateApiKey=t?.validateApiKey,this.debug=t?.debug??e.debug,this.domain=t?.domain||e.domain,this.requestTimeoutMs=t?.requestTimeoutMs??6e4,this.retries=wE(t?.retries??3),this.logger=t?.logger,this.headers=I(I({},t?.headers??{}),t?.apiHeaders??{}),e.applyUserAgent(this.headers),this.proxy=t?.proxy,this.httpVersion=RE(t?.httpVersion),this.apiUrl=t?.apiUrl||e.apiUrl||(this.debug?`http://localhost:3000`:`https://api.${this.domain}`),this.sandboxUrl=t?.sandboxUrl||e.sandboxUrl}static mergeOpts(e,t){if(!e)return t;let n=I({},e);for(let[e,r]of Object.entries(t??{}))r!==void 0&&Object.defineProperty(n,e,{value:r,enumerable:!0,writable:!0,configurable:!0});return n}static get domain(){return gE(`E2B_DOMAIN`)||`e2b.app`}static get apiUrl(){return gE(`E2B_API_URL`)}static get sandboxUrl(){return gE(`E2B_SANDBOX_URL`)}static get debug(){return(gE(`E2B_DEBUG`)||`false`).toLowerCase()===`true`}static get apiKey(){return gE(`E2B_API_KEY`)}getSignal(e,t){return zE(e??this.requestTimeoutMs,t)}getSandboxUrl(e,t){if(this.sandboxUrl)return this.sandboxUrl;if(this.debug)return`http://${this.getHost(e,t.envdPort,t.sandboxDomain)}`;let n=t.sandboxDomain??this.domain;return tE!==`browser`&&IE.includes(n)?`https://sandbox.${n}`:`https://${this.getHost(e,t.envdPort,n)}`}getSandboxDirectUrl(e,t){return this.sandboxUrl?this.sandboxUrl:this.debug?`http://${this.getHost(e,t.envdPort,t.sandboxDomain)}`:`https://${this.getHost(e,t.envdPort,t.sandboxDomain)}`}getHost(e,t,n){return this.debug?`localhost:${t}`:`${t}-${e}.${n??this.domain}`}};P(WE,`envdPort`,49983),P(WE,`integration`,void 0),P(WE,`sdkUserAgentPrefix`,`e2b-js-sdk/`);var GE=class{static resolveOpts(e){return WE.mergeOpts(this.boundOpts,e)}};P(GE,`boundOpts`,void 0);const KE=`user`,qE=/NGHTTP2_(ENHANCE_YOUR_CALM|INTERNAL_ERROR)\b/;function JE(e){if(!(e instanceof Error)||!(e.cause instanceof Error))return!1;let t=e.cause;return t.code===`ERR_HTTP2_STREAM_ERROR`&&qE.test(t.message)}async function YE(e=(()=>{var e;return(e=globalThis.process)==null||(e=e.versions)==null?void 0:e.node})()){if(!(!e||wv(e,`22.19.0`)<0))try{return await rE(`undici`)}catch{return}}function XE(){return((e,t)=>globalThis.fetch(e,t))}function ZE(e,t){if(e!==`node`)return XE();let n;return(async(e,r)=>{let i=n??=t(),a;try{a=await i}catch(e){throw n===i&&(n=void 0),e}return a(e,r)})}async function QE(e){let t=await(e.loadUndici??YE)();if(!t)return XE();let{Agent:n,ProxyAgent:r,fetch:i}=t,a={allowH2:(e.httpVersion??`2`)===`2`,connections:e.connections},o=()=>e.proxy?new r(I(I({uri:e.proxy},a),{},{proxyTunnel:!0})):new n(a),s=i,c=o();return(async(e,t)=>{let n=$E(e,t),r=c;try{return await s(n.input,I(I({},n.init),{},{dispatcher:r}))}catch(e){throw r===c&&JE(e)&&(c=o(),r.close().catch(()=>{})),e}})}function $E(e,t){if(!Vre(e))return{input:e,init:t};let n=I({body:$T(e.body)?oE(e.body):e.body,cache:e.cache,credentials:e.credentials,headers:e.headers,integrity:e.integrity,keepalive:e.keepalive,method:e.method,mode:e.mode,redirect:e.redirect,referrer:e.referrer,referrerPolicy:e.referrerPolicy,signal:e.signal},t);return n.body&&(n.duplex=`half`),{input:e.url,init:n}}const eD=new Map;function tD({proxy:e,httpVersion:t=`2`}={}){let n=`${t}:${e??``}`,r=eD.get(n);if(r)return r;let i=nD(tE,{proxy:e,httpVersion:t});return eD.set(n,i),i}function nD(e=tE,t={}){return ZE(e,()=>QE({connections:t.connectionLimit??rD(),proxy:t.proxy,httpVersion:t.httpVersion,loadUndici:t.loadUndici}))}function rD(){return vE(`E2B_API_CONNECTIONS`,100)}function iD(e){var t,n,r,i=2;for(typeof Symbol<`u`&&(n=Symbol.asyncIterator,r=Symbol.iterator);i--;){if(n&&(t=e[n])!=null)return t.call(e);if(r&&(t=e[r])!=null)return new aD(t.call(e));n=`@@asyncIterator`,r=`@@iterator`}throw TypeError(`Object is not async iterable`)}function aD(e){function t(e){if(Object(e)!==e)return Promise.reject(TypeError(e+` is not an object.`));var t=e.done;return Promise.resolve(e.value).then(function(e){return{value:e,done:t}})}return aD=function(e){this.s=e,this.n=e.next},aD.prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var n=this.s.return;return n===void 0?Promise.resolve({value:e,done:!0}):t(n.apply(this.s,arguments))},throw:function(e){var n=this.s.return;return n===void 0?Promise.reject(e):t(n.apply(this.s,arguments))}},new aD(e)}function oD(e,t){this.v=e,this.k=t}function sD(e){return new oD(e,0)}function cD(e){return function(){return new lD(e.apply(this,arguments))}}function lD(e){var t,n;function r(t,n){try{var a=e[t](n),o=a.value,s=o instanceof oD;Promise.resolve(s?o.v:o).then(function(n){if(s){var c=t===`return`?`return`:`next`;if(!o.k||n.done)return r(c,n);n=e[c](n).value}i(a.done?`return`:`normal`,n)},function(e){r(`throw`,e)})}catch(e){i(`throw`,e)}}function i(e,i){switch(e){case`return`:t.resolve({value:i,done:!0});break;case`throw`:t.reject(i);break;default:t.resolve({value:i,done:!1})}(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,i){return new Promise(function(a,o){var s={key:e,arg:i,resolve:a,reject:o,next:null};n?n=n.next=s:(t=n=s,r(e,i))})},typeof e.return!=`function`&&(this.return=void 0)}lD.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},lD.prototype.next=function(e){return this._invoke(`next`,e)},lD.prototype.throw=function(e){return this._invoke(`throw`,e)},lD.prototype.return=function(e){return this._invoke(`return`,e)};function uD(e){return JSON.parse(JSON.stringify(e,(e,t)=>typeof t==`bigint`?t.toString():t))}function dD(e){function t(e){return n.apply(this,arguments)}function n(){return n=cD(function*(t){var n=!1,r=!1,i;try{for(var a=iD(t),o;n=!(o=yield sD(a.next())).done;n=!1){let t=o.value;var s;(s=e.debug)==null||s.call(e,`Response stream:`,uD(t)),yield t}}catch(e){r=!0,i=e}finally{try{n&&a.return!=null&&(yield sD(a.return()))}finally{if(r)throw i}}}),n.apply(this,arguments)}return n=>async r=>{var i;(i=e.info)==null||i.call(e,`Request: POST ${r.url}`);let a=await n(r);if(a.stream)return I(I({},a),{},{message:t(a.message)});var o;return(o=e.info)==null||o.call(e,`Response:`,uD(a.message)),a}}function fD(e){return{async onRequest({request:t}){var n;return(n=e.info)==null||n.call(e,`Request ${t.method} ${t.url}`),t},async onResponse({response:t}){if(t.status>=400){var n;(n=e.error)==null||n.call(e,`Response:`,t.status,t.statusText)}else{var r;(r=e.info)==null||r.call(e,`Response:`,t.status,t.statusText)}return t}}}function pD(e,t,n=LT,r){if(e===401){let e=`Unauthorized, please check your credentials.`;return new WT(t?`${e} - ${t}`:e)}if(e===429){let e=`Rate limit exceeded, please try again later`;return new JT(t?`${e} - ${t}`:e)}if(e===503){let e=`Service temporarily unavailable, please retry`;return new zre(t?`${e} - ${t}`:e)}let i=new n(`${e}: ${t}`,r);return i instanceof LT&&(i.statusCode=e),i}function mD(e,t=LT,n){if(e.response.ok)return;let r=e.response.status;return e.error?.error_code===YT.code?new YT(`${e.error.message}. Resume the sandbox with \`onResume: 'reboot'\`.`):r===401||r===429||r===503?pD(r,e.error?.message??e.error,t,n):pD(r,e.error?.message||e.error||e.response.statusText,t,n)}var hD=class{constructor(e,t={}){if(P(this,`api`,void 0),(t.requireApiKey??!0)&&!e.apiKey)throw new WT("API key is required, please visit the API Keys tab at https://e2b.dev/dashboard?tab=keys 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_...' })");this.api=ov({baseUrl:e.apiUrl,fetch:PE(tD(e),e.retries,e.requestTimeoutMs),headers:I(I(I({},hE),e.apiKey&&{"X-API-KEY":e.apiKey}),e.headers),querySerializer:{array:{style:`form`,explode:!1}}}),e.logger&&this.api.use(fD(e.logger))}};async function gD({path:e,operation:t,user:n,expirationInSeconds:r,envdAccessToken:i}){if(!i)throw Error(`Access token is not set and signature cannot be generated!`);let a=r==null?null:Math.floor(Date.now()/1e3)+r,o;return n??=``,o=a===null?`${e}:${t}:${n}:${i}`:`${e}:${t}:${n}:${i}:${a.toString()}`,{signature:`v1_`+(await Gre(o)).replace(/=+$/,``),expiration:a}}const _D=new Map,vD=new Map,yD=new Map;function bD(e=tE,t={}){return ZE(e,()=>QE({connections:t.connectionLimit??10,proxy:t.proxy,httpVersion:t.httpVersion,loadUndici:t.loadUndici}))}function xD(e,t){return`${t}:${e??``}`}function SD({proxy:e,httpVersion:t=`2`}={}){let n=xD(e,t),r=_D.get(n);if(r)return r;let i=bD(tE,{proxy:e,httpVersion:t});return _D.set(n,i),i}function CD({proxy:e,httpVersion:t=`2`}={}){let n=xD(e,t),r=vD.get(n);if(r)return r;let i=bD(tE,{connectionLimit:wD(),proxy:e,httpVersion:t});return vD.set(n,i),i}function wD(){return vE(`E2B_ENVD_RPC_CONNECTIONS`,200)}function TD({proxy:e}={}){let t=xD(e,`1.1`),n=yD.get(t);if(n)return n;let r=bD(tE,{connectionLimit:ED(),proxy:e,httpVersion:`1.1`});return yD.set(t,r),r}function ED(){return vE(`E2B_ENVD_UPLOAD_CONNECTIONS`,50)}const DD=`99.99.99`,OD=`0.5.7`,kD=Vb(`ChVwcm9jZXNzL3Byb2Nlc3MucHJvdG8SB3Byb2Nlc3MiSgoDUFRZEh8KBHNpemUYASABKAsyES5wcm9jZXNzLlBUWS5TaXplGiIKBFNpemUSDAoEY29scxgBIAEoDRIMCgRyb3dzGAIgASgNIqEBCg1Qcm9jZXNzQ29uZmlnEgsKA2NtZBgBIAEoCRIMCgRhcmdzGAIgAygJEi4KBGVudnMYAyADKAsyIC5wcm9jZXNzLlByb2Nlc3NDb25maWcuRW52c0VudHJ5EhAKA2N3ZBgEIAEoCUgAiAEBGisKCUVudnNFbnRyeRILCgNrZXkYASABKAkSDQoFdmFsdWUYAiABKAk6AjgBQgYKBF9jd2QiDQoLTGlzdFJlcXVlc3QiXAoLUHJvY2Vzc0luZm8SJgoGY29uZmlnGAEgASgLMhYucHJvY2Vzcy5Qcm9jZXNzQ29uZmlnEgsKA3BpZBgCIAEoDRIQCgN0YWcYAyABKAlIAIgBAUIGCgRfdGFnIjcKDExpc3RSZXNwb25zZRInCglwcm9jZXNzZXMYASADKAsyFC5wcm9jZXNzLlByb2Nlc3NJbmZvIpcBCgxTdGFydFJlcXVlc3QSJwoHcHJvY2VzcxgBIAEoCzIWLnByb2Nlc3MuUHJvY2Vzc0NvbmZpZxIeCgNwdHkYAiABKAsyDC5wcm9jZXNzLlBUWUgAiAEBEhAKA3RhZxgDIAEoCUgBiAEBEhIKBXN0ZGluGAQgASgISAKIAQFCBgoEX3B0eUIGCgRfdGFnQggKBl9zdGRpbiJiCg1VcGRhdGVSZXF1ZXN0EikKB3Byb2Nlc3MYASABKAsyGC5wcm9jZXNzLlByb2Nlc3NTZWxlY3RvchIeCgNwdHkYAiABKAsyDC5wcm9jZXNzLlBUWUgAiAEBQgYKBF9wdHkiEAoOVXBkYXRlUmVzcG9uc2UirwMKDFByb2Nlc3NFdmVudBIxCgVzdGFydBgBIAEoCzIgLnByb2Nlc3MuUHJvY2Vzc0V2ZW50LlN0YXJ0RXZlbnRIABIvCgRkYXRhGAIgASgLMh8ucHJvY2Vzcy5Qcm9jZXNzRXZlbnQuRGF0YUV2ZW50SAASLQoDZW5kGAMgASgLMh4ucHJvY2Vzcy5Qcm9jZXNzRXZlbnQuRW5kRXZlbnRIABI0CglrZWVwYWxpdmUYBCABKAsyHy5wcm9jZXNzLlByb2Nlc3NFdmVudC5LZWVwQWxpdmVIABoZCgpTdGFydEV2ZW50EgsKA3BpZBgBIAEoDRpICglEYXRhRXZlbnQSEAoGc3Rkb3V0GAEgASgMSAASEAoGc3RkZXJyGAIgASgMSAASDQoDcHR5GAMgASgMSABCCAoGb3V0cHV0GlsKCEVuZEV2ZW50EhEKCWV4aXRfY29kZRgBIAEoERIOCgZleGl0ZWQYAiABKAgSDgoGc3RhdHVzGAMgASgJEhIKBWVycm9yGAQgASgJSACIAQFCCAoGX2Vycm9yGgsKCUtlZXBBbGl2ZUIHCgVldmVudCI1Cg1TdGFydFJlc3BvbnNlEiQKBWV2ZW50GAEgASgLMhUucHJvY2Vzcy5Qcm9jZXNzRXZlbnQiNwoPQ29ubmVjdFJlc3BvbnNlEiQKBWV2ZW50GAEgASgLMhUucHJvY2Vzcy5Qcm9jZXNzRXZlbnQiYwoQU2VuZElucHV0UmVxdWVzdBIpCgdwcm9jZXNzGAEgASgLMhgucHJvY2Vzcy5Qcm9jZXNzU2VsZWN0b3ISJAoFaW5wdXQYAiABKAsyFS5wcm9jZXNzLlByb2Nlc3NJbnB1dCITChFTZW5kSW5wdXRSZXNwb25zZSI3CgxQcm9jZXNzSW5wdXQSDwoFc3RkaW4YASABKAxIABINCgNwdHkYAiABKAxIAEIHCgVpbnB1dCLCAgoSU3RyZWFtSW5wdXRSZXF1ZXN0EjcKBXN0YXJ0GAEgASgLMiYucHJvY2Vzcy5TdHJlYW1JbnB1dFJlcXVlc3QuU3RhcnRFdmVudEgAEjUKBGRhdGEYAiABKAsyJS5wcm9jZXNzLlN0cmVhbUlucHV0UmVxdWVzdC5EYXRhRXZlbnRIABI6CglrZWVwYWxpdmUYAyABKAsyJS5wcm9jZXNzLlN0cmVhbUlucHV0UmVxdWVzdC5LZWVwQWxpdmVIABo3CgpTdGFydEV2ZW50EikKB3Byb2Nlc3MYASABKAsyGC5wcm9jZXNzLlByb2Nlc3NTZWxlY3RvchoxCglEYXRhRXZlbnQSJAoFaW5wdXQYAiABKAsyFS5wcm9jZXNzLlByb2Nlc3NJbnB1dBoLCglLZWVwQWxpdmVCBwoFZXZlbnQiFQoTU3RyZWFtSW5wdXRSZXNwb25zZSJfChFTZW5kU2lnbmFsUmVxdWVzdBIpCgdwcm9jZXNzGAEgASgLMhgucHJvY2Vzcy5Qcm9jZXNzU2VsZWN0b3ISHwoGc2lnbmFsGAIgASgOMg8ucHJvY2Vzcy5TaWduYWwiFAoSU2VuZFNpZ25hbFJlc3BvbnNlIj4KEUNsb3NlU3RkaW5SZXF1ZXN0EikKB3Byb2Nlc3MYASABKAsyGC5wcm9jZXNzLlByb2Nlc3NTZWxlY3RvciIUChJDbG9zZVN0ZGluUmVzcG9uc2UiOwoOQ29ubmVjdFJlcXVlc3QSKQoHcHJvY2VzcxgBIAEoCzIYLnByb2Nlc3MuUHJvY2Vzc1NlbGVjdG9yIjsKD1Byb2Nlc3NTZWxlY3RvchINCgNwaWQYASABKA1IABINCgN0YWcYAiABKAlIAEIKCghzZWxlY3RvcipICgZTaWduYWwSFgoSU0lHTkFMX1VOU1BFQ0lGSUVEEAASEgoOU0lHTkFMX1NJR1RFUk0QDxISCg5TSUdOQUxfU0lHS0lMTBAJMpEECgdQcm9jZXNzEjMKBExpc3QSFC5wcm9jZXNzLkxpc3RSZXF1ZXN0GhUucHJvY2Vzcy5MaXN0UmVzcG9uc2USPgoHQ29ubmVjdBIXLnByb2Nlc3MuQ29ubmVjdFJlcXVlc3QaGC5wcm9jZXNzLkNvbm5lY3RSZXNwb25zZTABEjgKBVN0YXJ0EhUucHJvY2Vzcy5TdGFydFJlcXVlc3QaFi5wcm9jZXNzLlN0YXJ0UmVzcG9uc2UwARI5CgZVcGRhdGUSFi5wcm9jZXNzLlVwZGF0ZVJlcXVlc3QaFy5wcm9jZXNzLlVwZGF0ZVJlc3BvbnNlEkoKC1N0cmVhbUlucHV0EhsucHJvY2Vzcy5TdHJlYW1JbnB1dFJlcXVlc3QaHC5wcm9jZXNzLlN0cmVhbUlucHV0UmVzcG9uc2UoARJCCglTZW5kSW5wdXQSGS5wcm9jZXNzLlNlbmRJbnB1dFJlcXVlc3QaGi5wcm9jZXNzLlNlbmRJbnB1dFJlc3BvbnNlEkUKClNlbmRTaWduYWwSGi5wcm9jZXNzLlNlbmRTaWduYWxSZXF1ZXN0GhsucHJvY2Vzcy5TZW5kU2lnbmFsUmVzcG9uc2USRQoKQ2xvc2VTdGRpbhIaLnByb2Nlc3MuQ2xvc2VTdGRpblJlcXVlc3QaGy5wcm9jZXNzLkNsb3NlU3RkaW5SZXNwb25zZUJXCgtjb20ucHJvY2Vzc0IMUHJvY2Vzc1Byb3RvUAGiAgNQWFiqAgdQcm9jZXNzygIHUHJvY2Vzc+ICE1Byb2Nlc3NcR1BCTWV0YWRhdGHqAgdQcm9jZXNzYgZwcm90bzM`),AD=Mb(kD,14),jD=lC(kD,0),MD=[`terminated`,`The socket connection was closed unexpectedly`,`error reading a body from connection`,`Network connection lost`,`network error`];function ND(e){return e?MD.some(t=>e.includes(t)):!1}function PD(e){return e instanceof TS&&e.code===M.Unknown&&ND(e.rawMessage)}function FD(e){return PD(e)?!0:e instanceof TS&&e.code===M.Unknown&&kE(e.cause)}function ID(e){return e instanceof TS&&e.code===M.Unavailable&&!PT(e.rawMessage)&&!FT(e.rawMessage)}function LD(e,t){if(t instanceof UT)return t.cause=e,t;let n=t instanceof Error?t.message:String(t);return new UT(`${e.message}: The sandbox could not be reached and its health probe failed too (${n}). It was not confirmed to be stopped — this is likely a network issue or envd inside the sandbox not being up yet; check the sandbox state with 'Sandbox.getInfo()'.`,{cause:e})}async function RD(e,t){let n;try{n=await t()}catch(t){return LD(e,t)}if(n===!1)return new HT(`${e.message}: The sandbox was killed or reached its end of life while the request was in flight.`,{cause:e})}const zD={[M.InvalidArgument]:e=>new F(e),[M.Unauthenticated]:e=>new WT(e),[M.NotFound]:e=>new zT(e),[M.ResourceExhausted]:e=>new JT(`${e}: Rate limit exceeded, please try again later.`),[M.Unavailable]:IT,[M.Canceled]:e=>new RT(`${e}: This error is likely due to exceeding 'requestTimeoutMs'. You can pass the request timeout value as an option when making the request.`),[M.DeadlineExceeded]:e=>new RT(`${e}: This error is likely due to exceeding 'timeoutMs' — the total time a long running request (like command execution or directory watch) can be active. It can be modified by passing 'timeoutMs' when making the request. Use '0' to disable the timeout.`)};function BD(e,t){return e instanceof TS?t&&e.code in t?t[e.code](e.message):e.code in zD?zD[e.code](e.message):new LT(`${e.code}: ${e.message}`):e}async function VD(e,t,n){if(t&&(FD(e)||ID(e))){let n=await RD(e,t);if(n)return n}return BD(e,n)}async function HD(e,t,n,r){try{return await e.sendSignal({process:{selector:{case:`pid`,value:t}},signal:9},{signal:n}),!0}catch(e){if(e instanceof TS&&e.code===M.NotFound)return!1;throw await VD(e,r)}}function UD(e){switch(tE){case`deno`:return btoa(e);case`node`:return Buffer.from(e).toString(`base64`);case`bun`:return Buffer.from(e).toString(`base64`);default:return btoa(e)}}function WD(e,t){return t==null&&wv(e,`0.4.0`)<0&&(t=KE),t?{Authorization:`Basic ${UD(`${t}:`)}`}:{}}async function GD(e){if(e.status!==502)return e;let t=``;try{t=await e.text()}catch{}try{let n=JSON.parse(t);if(typeof n?.code==`string`&&wS(n.code)!==void 0)return new Response(t,{status:e.status,statusText:e.statusText,headers:e.headers});typeof n?.message==`string`&&(t=n.message)}catch{}throw new TS(t||`HTTP ${e.status}`,M.Unavailable)}const KD={400:e=>new F(e),401:e=>new WT(e),404:e=>new zT(e),429:e=>new JT(`${e}: The requests are being rate limited.`),502:IT,507:e=>new Rre(e)};async function qD(e){let t=await e.api.GET(`/health`,{signal:AbortSignal.timeout(5e3)});if(t.response.status===502){let e=IT(await XD(t));if(e instanceof HT)return!1;throw e}if(t.response.ok)return!0}function JD(e){return e instanceof Error&&(ND(e.message)||kE(e))}async function YD(e,t){if(t&&JD(e)){let n=await RD(e,t);if(n)return n}return e}async function XD(e){let t=(typeof e.error==`string`?e.error:e.error?.message)??``;if(!t&&!e.response.bodyUsed)try{t=await e.response.text()}catch{}return t||e.response.statusText}async function ZD(e,t){if(e.response.ok)return;let n=await XD(e);return t&&e.response.status in t?t[e.response.status]?.call(t,n):e.response.status in KD?KD[e.response.status]?.call(KD,n):new LT(`${e.response.status}: ${n}`)}async function QD(e){let t=(await e[Symbol.asyncIterator]().next()).value;if(t.event?.event.case!==`start`)throw Error(`Expected start event`);return t.event.event.value.pid}async function $D(e){let t=(await e[Symbol.asyncIterator]().next()).value;if(t.event?.case!==`start`)throw Error(`Expected start event`);return t.event.value}var eO=class{constructor(e,t){P(this,`api`,void 0),P(this,`version`,void 0),this.api=ov({baseUrl:e.apiUrl,fetch:e?.fetch,headers:I(I({},e?.headers),e.envdAccessToken&&{"X-Access-Token":e.envdAccessToken})}),this.version=t.version,e.logger&&this.api.use(fD(e.logger))}};const tO=lC(Vb(`ChtmaWxlc3lzdGVtL2ZpbGVzeXN0ZW0ucHJvdG8SCmZpbGVzeXN0ZW0iMgoLTW92ZVJlcXVlc3QSDgoGc291cmNlGAEgASgJEhMKC2Rlc3RpbmF0aW9uGAIgASgJIjQKDE1vdmVSZXNwb25zZRIkCgVlbnRyeRgBIAEoCzIVLmZpbGVzeXN0ZW0uRW50cnlJbmZvIh4KDk1ha2VEaXJSZXF1ZXN0EgwKBHBhdGgYASABKAkiNwoPTWFrZURpclJlc3BvbnNlEiQKBWVudHJ5GAEgASgLMhUuZmlsZXN5c3RlbS5FbnRyeUluZm8iHQoNUmVtb3ZlUmVxdWVzdBIMCgRwYXRoGAEgASgJIhAKDlJlbW92ZVJlc3BvbnNlIhsKC1N0YXRSZXF1ZXN0EgwKBHBhdGgYASABKAkiNAoMU3RhdFJlc3BvbnNlEiQKBWVudHJ5GAEgASgLMhUuZmlsZXN5c3RlbS5FbnRyeUluZm8i+QIKCUVudHJ5SW5mbxIMCgRuYW1lGAEgASgJEiIKBHR5cGUYAiABKA4yFC5maWxlc3lzdGVtLkZpbGVUeXBlEgwKBHBhdGgYAyABKAkSDAoEc2l6ZRgEIAEoAxIMCgRtb2RlGAUgASgNEhMKC3Blcm1pc3Npb25zGAYgASgJEg0KBW93bmVyGAcgASgJEg0KBWdyb3VwGAggASgJEjEKDW1vZGlmaWVkX3RpbWUYCSABKAsyGi5nb29nbGUucHJvdG9idWYuVGltZXN0YW1wEhsKDnN5bWxpbmtfdGFyZ2V0GAogASgJSACIAQESNQoIbWV0YWRhdGEYCyADKAsyIy5maWxlc3lzdGVtLkVudHJ5SW5mby5NZXRhZGF0YUVudHJ5EhIKCmlzX3N5bWxpbmsYDCABKAgaLwoNTWV0YWRhdGFFbnRyeRILCgNrZXkYASABKAkSDQoFdmFsdWUYAiABKAk6AjgBQhEKD19zeW1saW5rX3RhcmdldCItCg5MaXN0RGlyUmVxdWVzdBIMCgRwYXRoGAEgASgJEg0KBWRlcHRoGAIgASgNIjkKD0xpc3REaXJSZXNwb25zZRImCgdlbnRyaWVzGAEgAygLMhUuZmlsZXN5c3RlbS5FbnRyeUluZm8iZwoPV2F0Y2hEaXJSZXF1ZXN0EgwKBHBhdGgYASABKAkSEQoJcmVjdXJzaXZlGAIgASgIEhUKDWluY2x1ZGVfZW50cnkYAyABKAgSHAoUYWxsb3dfbmV0d29ya19tb3VudHMYBCABKAgieQoPRmlsZXN5c3RlbUV2ZW50EgwKBG5hbWUYASABKAkSIwoEdHlwZRgCIAEoDjIVLmZpbGVzeXN0ZW0uRXZlbnRUeXBlEikKBWVudHJ5GAMgASgLMhUuZmlsZXN5c3RlbS5FbnRyeUluZm9IAIgBAUIICgZfZW50cnki4AEKEFdhdGNoRGlyUmVzcG9uc2USOAoFc3RhcnQYASABKAsyJy5maWxlc3lzdGVtLldhdGNoRGlyUmVzcG9uc2UuU3RhcnRFdmVudEgAEjEKCmZpbGVzeXN0ZW0YAiABKAsyGy5maWxlc3lzdGVtLkZpbGVzeXN0ZW1FdmVudEgAEjsKCWtlZXBhbGl2ZRgDIAEoCzImLmZpbGVzeXN0ZW0uV2F0Y2hEaXJSZXNwb25zZS5LZWVwQWxpdmVIABoMCgpTdGFydEV2ZW50GgsKCUtlZXBBbGl2ZUIHCgVldmVudCJsChRDcmVhdGVXYXRjaGVyUmVxdWVzdBIMCgRwYXRoGAEgASgJEhEKCXJlY3Vyc2l2ZRgCIAEoCBIVCg1pbmNsdWRlX2VudHJ5GAMgASgIEhwKFGFsbG93X25ldHdvcmtfbW91bnRzGAQgASgIIisKFUNyZWF0ZVdhdGNoZXJSZXNwb25zZRISCgp3YXRjaGVyX2lkGAEgASgJIi0KF0dldFdhdGNoZXJFdmVudHNSZXF1ZXN0EhIKCndhdGNoZXJfaWQYASABKAkiRwoYR2V0V2F0Y2hlckV2ZW50c1Jlc3BvbnNlEisKBmV2ZW50cxgBIAMoCzIbLmZpbGVzeXN0ZW0uRmlsZXN5c3RlbUV2ZW50IioKFFJlbW92ZVdhdGNoZXJSZXF1ZXN0EhIKCndhdGNoZXJfaWQYASABKAkiFwoVUmVtb3ZlV2F0Y2hlclJlc3BvbnNlKmkKCEZpbGVUeXBlEhkKFUZJTEVfVFlQRV9VTlNQRUNJRklFRBAAEhIKDkZJTEVfVFlQRV9GSUxFEAESFwoTRklMRV9UWVBFX0RJUkVDVE9SWRACEhUKEUZJTEVfVFlQRV9TWU1MSU5LEAMqmAEKCUV2ZW50VHlwZRIaChZFVkVOVF9UWVBFX1VOU1BFQ0lGSUVEEAASFQoRRVZFTlRfVFlQRV9DUkVBVEUQARIUChBFVkVOVF9UWVBFX1dSSVRFEAISFQoRRVZFTlRfVFlQRV9SRU1PVkUQAxIVChFFVkVOVF9UWVBFX1JFTkFNRRAEEhQKEEVWRU5UX1RZUEVfQ0hNT0QQBTKfBQoKRmlsZXN5c3RlbRI5CgRTdGF0EhcuZmlsZXN5c3RlbS5TdGF0UmVxdWVzdBoYLmZpbGVzeXN0ZW0uU3RhdFJlc3BvbnNlEkIKB01ha2VEaXISGi5maWxlc3lzdGVtLk1ha2VEaXJSZXF1ZXN0GhsuZmlsZXN5c3RlbS5NYWtlRGlyUmVzcG9uc2USOQoETW92ZRIXLmZpbGVzeXN0ZW0uTW92ZVJlcXVlc3QaGC5maWxlc3lzdGVtLk1vdmVSZXNwb25zZRJCCgdMaXN0RGlyEhouZmlsZXN5c3RlbS5MaXN0RGlyUmVxdWVzdBobLmZpbGVzeXN0ZW0uTGlzdERpclJlc3BvbnNlEj8KBlJlbW92ZRIZLmZpbGVzeXN0ZW0uUmVtb3ZlUmVxdWVzdBoaLmZpbGVzeXN0ZW0uUmVtb3ZlUmVzcG9uc2USRwoIV2F0Y2hEaXISGy5maWxlc3lzdGVtLldhdGNoRGlyUmVxdWVzdBocLmZpbGVzeXN0ZW0uV2F0Y2hEaXJSZXNwb25zZTABElQKDUNyZWF0ZVdhdGNoZXISIC5maWxlc3lzdGVtLkNyZWF0ZVdhdGNoZXJSZXF1ZXN0GiEuZmlsZXN5c3RlbS5DcmVhdGVXYXRjaGVyUmVzcG9uc2USXQoQR2V0V2F0Y2hlckV2ZW50cxIjLmZpbGVzeXN0ZW0uR2V0V2F0Y2hlckV2ZW50c1JlcXVlc3QaJC5maWxlc3lzdGVtLkdldFdhdGNoZXJFdmVudHNSZXNwb25zZRJUCg1SZW1vdmVXYXRjaGVyEiAuZmlsZXN5c3RlbS5SZW1vdmVXYXRjaGVyUmVxdWVzdBohLmZpbGVzeXN0ZW0uUmVtb3ZlV2F0Y2hlclJlc3BvbnNlQmkKDmNvbS5maWxlc3lzdGVtQg9GaWxlc3lzdGVtUHJvdG9QAaICA0ZYWKoCCkZpbGVzeXN0ZW3KAgpGaWxlc3lzdGVt4gIWRmlsZXN5c3RlbVxHUEJNZXRhZGF0YeoCCkZpbGVzeXN0ZW1iBnByb3RvMw`,[Zne]),0);function nO(e){switch(e){case 5:return`chmod`;case 1:return`create`;case 3:return`remove`;case 4:return`rename`;case 2:return`write`}}var rO=class{constructor(e,t,n,r,i){this.handleStop=e,this.events=t,this.onEvent=n,this.onExit=r,this.checkHealth=i,P(this,`stopped`,!1),this.handleEvents()}async stop(){var e=this;e.stopped=!0,e.handleStop()}iterateEvents(){var e=this;return cD(function*(){try{var t=!1,n=!1,r;try{for(var i=iD(e.events),a;t=!(a=yield sD(i.next())).done;t=!1){let e=a.value;e.event.case===`filesystem`&&(yield e.event)}}catch(e){n=!0,r=e}finally{try{t&&i.return!=null&&(yield sD(i.return()))}finally{if(n)throw r}}}catch(t){if(e.stopped)return;throw yield sD(VD(t,e.checkHealth))}})()}async handleEvents(){var e=this;let t;try{var n=!1,r=!1,i;try{for(var a=iD(e.iterateEvents()),o;n=!(o=await a.next()).done;n=!1){let t=o.value;{let n=nO(t.value.type);if(n===void 0)continue;await e.onEvent?.call(e,{name:t.value.name,type:n,entry:t.value.entry?hO(t.value.entry):void 0})}}}catch(e){r=!0,i=e}finally{try{n&&a.return!=null&&await a.return()}finally{if(r)throw i}}}catch(e){t=e}try{t?await e.onExit?.call(e,t):await e.onExit?.call(e)}catch{}finally{e.handleStop()}}};const iO={404:e=>new BT(e)},aO={[M.NotFound]:e=>new BT(e)};async function oO(e,t){return VD(e,t,aO)}function sO(e){return ZD(e,iO)}function cO(e){switch(e){case 2:return`dir`;case 1:return`file`;case 3:return`symlink`}}function lO(e){if(e)return new Date(Number(e.seconds)*1e3+Math.floor(e.nanos/1e6))}function uO(e){if(e)return Object.keys(e).length===0?void 0:e}const dO=/^[A-Za-z0-9!#$%&'*+\-.^_`|~]+$/,fO=/^[\x20-\x7e]*$/;function pO(e){if(e)for(let[t,n]of Object.entries(e)){if(!dO.test(t))throw new F(`Invalid metadata key ${JSON.stringify(t)}: keys must be non-empty and use only HTTP token characters (letters, digits and !#$%&'*+-.^_\`|~).`);if(!fO.test(n))throw new F(`Invalid metadata value for key ${JSON.stringify(t)}: values must be printable US-ASCII.`)}}function mO(e){if(!e)return{};let t={};for(let[n,r]of Object.entries(e))t[`X-Metadata-${n}`]=r;return t}function hO(e){return{name:e.name,type:e.isSymlink?`symlink`:cO(e.type),path:e.path,size:Number(e.size),mode:e.mode,permissions:e.permissions,owner:e.owner,group:e.group,modifiedTime:lO(e.modifiedTime),symlinkTarget:e.symlinkTarget,metadata:uO(e.metadata)}}var gO=class{constructor(e,t,n){this.envdApi=t,this.connectionConfig=n,P(this,`rpc`,void 0),P(this,`defaultWatchTimeout`,6e4),P(this,`defaultWatchRecursive`,!1),P(this,`checkHealth`,void 0),P(this,`uploadFetch`,void 0);let r=TD({proxy:n.proxy});this.uploadFetch=e=>r(e),this.rpc=$S(tO,e),this.checkHealth=()=>qD(this.envdApi)}async read(e,t){var n=this;let r=t?.format??`text`,i=t?.user;i==null&&wv(n.envdApi.version,`0.4.0`)<0&&(i=KE);let a={};if(t?.gzip&&(a[`Accept-Encoding`]=`gzip`),r===`stream`){let r=t?.requestTimeoutMs??n.connectionConfig.requestTimeoutMs,{controller:o,clearStartTimeout:s,cleanup:c}=BE(r,t?.signal);try{let l=await n.envdApi.api.GET(`/files`,{params:{query:{path:e,username:i}},parseAs:`stream`,signal:o.signal,headers:a}).catch(async e=>{throw await YD(e,n.checkHealth)}),u=await sO(l);if(u)throw l.response.body&&!l.response.bodyUsed&&await l.response.body.cancel().catch(()=>{}),c(),u;return UE(l.data,{clearStartTimeout:s,cleanup:c,controller:o,idleTimeoutMs:t?.streamIdleTimeoutMs??r})}catch(e){throw c(),e}}let o=await n.envdApi.api.GET(`/files`,{params:{query:{path:e,username:i}},parseAs:r===`bytes`?`arrayBuffer`:r,signal:n.connectionConfig.getSignal(t?.requestTimeoutMs,t?.signal),headers:a}).catch(async e=>{throw await YD(e,n.checkHealth)}),s=await sO(o);if(s)throw s;return o.response.headers.get(`content-length`)===`0`?r===`bytes`?new Uint8Array:r===`blob`?new Blob([]):``:r===`bytes`?new Uint8Array(o.data):o.data}async write(e,t,n){var r=this;if(typeof e!=`string`&&!Array.isArray(e))throw Error(`Path or files are required`);if(typeof e==`string`&&Array.isArray(t))throw Error(`Cannot specify both path and array of files. You have to specify either path and data for a single file or an array for multiple files.`);let{path:i,writeOpts:a,writeFiles:o}=typeof e==`string`?{path:e,writeOpts:n,writeFiles:[{data:t}]}:{path:void 0,writeOpts:t,writeFiles:e};if(o.length===0)return[];let s=a?.user;s==null&&wv(r.envdApi.version,`0.4.0`)<0&&(s=KE);let c=a?.gzip===!0;if(c&&a?.useOctetStream===!1)throw new F("`gzip` requires the octet-stream upload and can't be combined with `useOctetStream: false`.");let l=wv(r.envdApi.version,OD)>=0,u=o.some(e=>sE(e.data)),d=((a?.useOctetStream??u)||c)&&l;if(u&&!d)throw l?new F("Stream data (`ReadableStream` / `AsyncIterable`) is only uploaded with octet-stream; `useOctetStream: false` is not supported for it."):new qT(`Uploading stream data requires envd ${OD} or later.`);let f=a?.metadata;if(pO(f),f&&Object.keys(f).length>0&&wv(r.envdApi.version,`0.6.2`)<0)throw new qT(`File metadata requires envd 0.6.2 or later.`);let p=mO(f),m=[];if(d){let e=I({"Content-Type":`application/octet-stream`},p);c&&(e[`Content-Encoding`]=`gzip`);let t=await Promise.all(o.map(async t=>{let n=i??t.path,{body:o,streamed:l,sourceError:u}=await mE(t.data,c),d=l?a?.signal:r.connectionConfig.getSignal(a?.requestTimeoutMs,a?.signal),f=await r.envdApi.api.POST(`/files`,I({params:{query:{path:n,username:s}},bodySerializer:()=>o,headers:e,signal:d,body:{},fetch:r.uploadFetch},l&&{duplex:`half`})).catch(async e=>{throw u()||await YD(e,r.checkHealth)}),p=await sO(f);if(p)throw p;let m=f.data;if(!m||m.length===0)throw Error(`Expected to receive information about written file`);for(let e of m)e.metadata=uO(e.metadata);return m}));for(let e of t)m.push(...e)}else{let e=new FormData;for(let t of o)e.append(`file`,await uE(t.data),t.path??i);let t=await r.envdApi.api.POST(`/files`,{params:{query:{path:i,username:s}},bodySerializer:()=>e,headers:p,signal:r.connectionConfig.getSignal(a?.requestTimeoutMs,a?.signal),body:{},fetch:r.uploadFetch}).catch(async e=>{throw await YD(e,r.checkHealth)}),n=await sO(t);if(n)throw n;let c=t.data;if(!c||c.length===0)throw Error(`Expected to receive information about written file`);for(let e of c)e.metadata=uO(e.metadata);m.push(...c)}return m.length===1&&i?m[0]:m}async writeFiles(e,t){return this.write(e,t)}async list(e,t){var n=this;if(typeof t?.depth==`number`&&t.depth<1)throw new F(`depth should be at least one`);try{let r=await n.rpc.listDir({path:e,depth:t?.depth??1},{headers:WD(n.envdApi.version,t?.user),signal:n.connectionConfig.getSignal(t?.requestTimeoutMs,t?.signal)}),i=[];for(let e of r.entries)cO(e.type)&&i.push(hO(e));return i}catch(e){throw await oO(e,n.checkHealth)}}async makeDir(e,t){var n=this;try{return await n.rpc.makeDir({path:e},{headers:WD(n.envdApi.version,t?.user),signal:n.connectionConfig.getSignal(t?.requestTimeoutMs,t?.signal)}),!0}catch(e){if(e instanceof TS&&e.code===M.AlreadyExists)return!1;throw await oO(e,n.checkHealth)}}async rename(e,t,n){var r=this;try{let i=(await r.rpc.move({source:e,destination:t},{headers:WD(r.envdApi.version,n?.user),signal:r.connectionConfig.getSignal(n?.requestTimeoutMs,n?.signal)})).entry;if(!i)throw Error(`Expected to receive information about moved object`);return hO(i)}catch(e){throw await oO(e,r.checkHealth)}}async remove(e,t){var n=this;try{await n.rpc.remove({path:e},{headers:WD(n.envdApi.version,t?.user),signal:n.connectionConfig.getSignal(t?.requestTimeoutMs,t?.signal)})}catch(e){throw await oO(e,n.checkHealth)}}async exists(e,t){var n=this;try{return await n.rpc.stat({path:e},{headers:WD(n.envdApi.version,t?.user),signal:n.connectionConfig.getSignal(t?.requestTimeoutMs,t?.signal)}),!0}catch(e){if(e instanceof TS&&e.code===M.NotFound)return!1;throw await oO(e,n.checkHealth)}}async getInfo(e,t){var n=this;try{let r=await n.rpc.stat({path:e},{headers:WD(n.envdApi.version,t?.user),signal:n.connectionConfig.getSignal(t?.requestTimeoutMs,t?.signal)});if(!r.entry)throw Error(`Expected to receive information about the file or directory`);return hO(r.entry)}catch(e){throw await oO(e,n.checkHealth)}}async watchDir(e,t,n){var r=this;if(n?.recursive&&r.envdApi.version&&wv(r.envdApi.version,`0.1.4`)<0)throw new qT(`You need to update the template to use recursive watching.`);if(n?.includeEntry&&r.envdApi.version&&wv(r.envdApi.version,`0.6.3`)<0)throw new qT(`You need to update the template to include entry info in watch events.`);if(n?.allowNetworkMounts&&r.envdApi.version&&wv(r.envdApi.version,`0.6.4`)<0)throw new qT(`You need to update the template to watch directories on network mounts.`);let{controller:i,clearStartTimeout:a,cleanup:o}=BE(n?.requestTimeoutMs??r.connectionConfig.requestTimeoutMs,n?.signal),s=r.rpc.watchDir({path:e,recursive:n?.recursive??r.defaultWatchRecursive,includeEntry:n?.includeEntry??!1,allowNetworkMounts:n?.allowNetworkMounts??!1},{headers:I(I({},WD(r.envdApi.version,n?.user)),{},{[LE]:`50`}),signal:i.signal,timeoutMs:n?.timeoutMs??r.defaultWatchTimeout});try{return await $D(s),a(),new rO(o,s,t,n?.onExit,r.checkHealth)}catch(e){throw o(),await oO(e,r.checkHealth)}}};function _O(e){var t={},n=!1;function r(t,r){return n=!0,r=new Promise(function(n){n(e[t](r))}),{done:!1,value:new oD(r,1)}}return t[typeof Symbol<`u`&&Symbol.iterator||`@@iterator`]=function(){return this},t.next=function(e){return n?(n=!1,e):r(`next`,e)},typeof e.throw==`function`&&(t.throw=function(e){if(n)throw n=!1,e;return r(`throw`,e)}),typeof e.return==`function`&&(t.return=function(e){return n?(n=!1,e):r(`return`,e)}),t}var vO=class extends LT{constructor(e){super(e.error),this.result=e,this.name=`CommandExitError`}get exitCode(){return this.result.exitCode}get error(){return this.result.error}get stdout(){return this.result.stdout}get stderr(){return this.result.stderr}},yO=class{constructor(e,t,n,r,i,a,o,s,c,l,u=!0){this.pid=e,this.handleDisconnect=t,this.handleKill=n,this.events=r,this.onStdout=i,this.onStderr=a,this.onPty=o,this.handleSendStdin=s,this.handleCloseStdin=c,this.checkHealth=l,P(this,`_stdout`,void 0),P(this,`_stderr`,void 0),P(this,`stdoutDecoder`,new TextDecoder),P(this,`stderrDecoder`,new TextDecoder),P(this,`result`,void 0),P(this,`iterationError`,void 0),P(this,`disconnected`,!1),P(this,`_wait`,void 0),u&&(this._stdout=``,this._stderr=``),this._wait=this.handleEvents()}get exitCode(){return this.result?.exitCode}get error(){return this.result?.error}get stderr(){return this._stderr}get stdout(){return this._stdout}async wait(){var e=this;if(await e._wait,e.iterationError)throw e.iterationError;if(!e.result)throw new LT(`Process exited without a result`);if(e.result.exitCode!==0)throw new vO(e.result);return e.result}async disconnect(){var e=this;e.disconnected=!0,e.handleDisconnect()}async kill(){return await this.handleKill()}async sendStdin(e,t){var n=this;if(!n.handleSendStdin)throw new LT(`Sending stdin is not supported for this command handle.`);await n.handleSendStdin(e,t)}async closeStdin(e){var t=this;if(!t.handleCloseStdin)throw new LT(`Closing stdin is not supported for this command handle.`);await t.handleCloseStdin(e)}appendStdout(e){this._stdout!==void 0&&(this._stdout+=e)}appendStderr(e){this._stderr!==void 0&&(this._stderr+=e)}*flushDecoders(){let e=this.stdoutDecoder.decode();e&&(this.appendStdout(e),yield[e,null,null]);let t=this.stderrDecoder.decode();t&&(this.appendStderr(t),yield[null,t,null])}iterateEvents(){var e=this;return cD(function*(){try{var t=!1,n=!1,r;try{for(var i=iD(e.events),a;t=!(a=yield sD(i.next())).done;t=!1){let t=a.value;{var o;let n=t==null||(o=t.event)==null?void 0:o.event,r;switch(n?.case){case`data`:switch(n.value.output.case){case`stdout`:r=e.stdoutDecoder.decode(n.value.output.value,{stream:!0}),r&&(e.appendStdout(r),yield[r,null,null]);break;case`stderr`:r=e.stderrDecoder.decode(n.value.output.value,{stream:!0}),r&&(e.appendStderr(r),yield[null,r,null]);break;case`pty`:yield[null,null,n.value.output.value]}break;case`end`:{let t=[...e.flushDecoders()];e.result={exitCode:n.value.exitCode,error:n.value.error,stdout:e.stdout,stderr:e.stderr};for(let e of t)yield e;break}}}}}catch(e){n=!0,r=e}finally{try{t&&i.return!=null&&(yield sD(i.return()))}finally{if(n)throw r}}}catch(t){throw yield*_O(iD(e.flushDecoders())),t}e.result===void 0&&(yield*_O(iD(e.flushDecoders())))})()}async handleEvents(){var e=this;try{var t=!1,n=!1,r;try{for(var i=iD(e.iterateEvents()),a;t=!(a=await i.next()).done;t=!1){let[t,n,r]=a.value;if(e.disconnected)break;t===null?n===null?r&&await e.onPty?.call(e,r):await e.onStderr?.call(e,n):await e.onStdout?.call(e,t)}}catch(e){n=!0,r=e}finally{try{t&&i.return!=null&&await i.return()}finally{if(n)throw r}}}catch(t){e.iterationError=await VD(t,e.checkHealth)}finally{e.handleDisconnect()}}};const bO=Symbol(`close`);var xO=class{constructor(e,t,n,r,i,a=5e4){var o=this;this.rpc=e,this.pid=t,this.inputKind=n,this.checkHealth=i,P(this,`queue`,[]),P(this,`completion`,void 0),P(this,`keepaliveIntervalMs`,void 0),P(this,`wake`,void 0),P(this,`closing`,!1),P(this,`stopped`,!1),P(this,`failure`,void 0),P(this,`closePromise`,void 0),this.keepaliveIntervalMs=a,this.completion=this.rpc.streamInput(this.requests(),{signal:r.signal,timeoutMs:r.timeoutMs??6e4}).then(()=>{this.stopped=!0,this.notify()}).catch(async e=>{throw o.failure=await VD(e,o.checkHealth),o.stopped=!0,o.notify(),o.failure}),this.completion.catch(()=>void 0)}async send(e){var t=this;if(t.failure)throw t.failure;if(t.closing||t.stopped)throw new LT("Cannot send input after the input handle is closed. Open a new one with `sandbox.commands.streamInput(pid)` or `sandbox.pty.streamInput(pid)`.");t.queue.push(e instanceof Uint8Array?e.slice():e),t.notify()}close(){return this.closePromise?this.closePromise:(this.closing=!0,this.queue.push(bO),this.notify(),this.closePromise=this.completion,this.closePromise)}notify(){var e;(e=this.wake)==null||e.call(this)}waitForInput(){return new Promise(e=>{let t=!1,n=setTimeout(()=>{t=!0,this.wake=void 0,e(!1)},this.keepaliveIntervalMs);this.wake=()=>{t||(t=!0,clearTimeout(n),this.wake=void 0,e(!0))}})}requests(){var e=this;return cD(function*(){for(yield sy(AD,{event:{case:`start`,value:{process:{selector:{case:`pid`,value:e.pid}}}}});!e.stopped;){if(e.queue.length>0){let t=e.queue.shift();if(t===bO)return;let n=typeof t==`string`?new TextEncoder().encode(t):t;yield sy(AD,{event:{case:`data`,value:{input:{input:{case:e.inputKind,value:n}}}}});continue}!(yield sD(e.waitForInput()))&&!e.stopped&&e.queue.length===0&&(yield sy(AD,{event:{case:`keepalive`,value:{}}}))}})()}},SO=class{constructor(e,t,n){P(this,`opts`,void 0),P(this,`limit`,void 0),P(this,`_hasNext`,void 0),P(this,`_nextToken`,void 0),this.opts=e,this.limit=t,this._hasNext=!0,this._nextToken=n}get hasNext(){return this._hasNext}get nextToken(){return this._nextToken}updatePagination(e){this._nextToken=e.headers.get(`x-next-token`)||void 0,this._hasNext=!!this._nextToken}};function CO(e,t,n){if(!t&&!n)return e;if(!t||!n)throw new F(`Both username and password are required when using Git credentials.`);let r;try{r=new URL(e)}catch{throw new F(`Invalid Git URL: ${e}`)}if(r.protocol!==`http:`&&r.protocol!==`https:`)throw new F(`Only http(s) Git URLs support username/password credentials.`);return r.username=t,r.password=n,r.toString()}function wO(e){let t;try{t=new URL(e)}catch{return e}return t.protocol!==`http:`&&t.protocol!==`https:`||!t.username&&!t.password?e:(t.username=``,t.password=``,t.toString())}function TO(e){let t;try{t=new URL(e)}catch{return}let n=t.pathname.replace(/\/+$/,``).split(`/`).pop();if(n)return n.endsWith(`.git`)?n.slice(0,-4):n}function EO(e,t){let n=[`git`];return t&&n.push(`-C`,t),n.push(...e),n.map(e=>fE(e)).join(` `)}function DO(e,t){let{remote:n,branch:r,setUpstream:i}=t,a=[`push`],o=e??n;return i&&o&&a.push(`--set-upstream`),o&&a.push(o),r&&a.push(r),a}function OO(e){if(!e)return{ahead:0,behind:0};let t=0,n=0;if(e.includes(`ahead`))try{t=Number.parseInt(e.split(`ahead`)[1].split(`,`)[0].trim(),10)}catch{t=0}if(e.includes(`behind`))try{n=Number.parseInt(e.split(`behind`)[1].split(`,`)[0].trim(),10)}catch{n=0}return{ahead:t,behind:n}}function kO(e){return e.startsWith(`HEAD (detached at `)?e.replace(`HEAD (detached at `,``).replace(/\)$/,``):e.replace(`HEAD (no branch)`,`HEAD`).replace(`No commits yet on `,``).replace(`Initial commit on `,``)}function AO(e,t){let n=new Set([e,t]);return n.has(`U`)?`conflict`:n.has(`R`)?`renamed`:n.has(`C`)?`copied`:n.has(`D`)?`deleted`:n.has(`A`)?`added`:n.has(`M`)?`modified`:n.has(`T`)?`typechange`:n.has(`?`)?`untracked`:`unknown`}function jO(e){let t=e.split(`
|
|
204
|
+
`).map(e=>e.replace(/\r$/,``)).filter(e=>e.trim().length>0),n,r,i=0,a=0,o=!1,s=[];if(t.length===0)return{currentBranch:n,upstream:r,ahead:i,behind:a,detached:o,fileStatus:s,isClean:!0,hasChanges:!1,hasStaged:!1,hasUntracked:!1,hasConflicts:!1,totalCount:0,stagedCount:0,unstagedCount:0,untrackedCount:0,conflictCount:0};let c=t[0];if(c.startsWith(`## `)){let e=c.slice(3),t=e.indexOf(` [`),s=t===-1?e:e.slice(0,t),l=t===-1?void 0:e.slice(t+2,-1),u=kO(s),d=s;if(d.startsWith(`HEAD (detached at `)||d.includes(`detached`)||u.startsWith(`HEAD`))o=!0;else if(u.includes(`...`)){let[e,t]=u.split(`...`);n=e||void 0,r=t||void 0}else n=u||void 0;let f=OO(l);i=f.ahead,a=f.behind}for(let e of t.slice(1)){if(e.startsWith(`?? `)){let t=e.slice(3);s.push({name:t,status:`untracked`,indexStatus:`?`,workingTreeStatus:`?`,staged:!1});continue}if(e.length<3)continue;let t=e[0],n=e[1],r=e.slice(3),i,a=r;if(r.includes(` -> `)){let e=r.split(` -> `);i=e[0],a=e.slice(1).join(` -> `)}s.push(I({name:a,status:AO(t,n),indexStatus:t,workingTreeStatus:n,staged:t!==` `&&t!==`?`},i?{renamedFrom:i}:{}))}let l=s.length,u=s.filter(e=>e.staged).length,d=s.filter(e=>e.status===`untracked`).length,f=s.filter(e=>e.status===`conflict`).length,p=l-u;return{currentBranch:n,upstream:r,ahead:i,behind:a,detached:o,fileStatus:s,isClean:l===0,hasChanges:l>0,hasStaged:u>0,hasUntracked:d>0,hasConflicts:f>0,totalCount:l,stagedCount:u,unstagedCount:p,untrackedCount:d,conflictCount:f}}function MO(e){let t=[],n,r=e.split(`
|
|
205
|
+
`).map(e=>e.trim()).filter(e=>e.length>0);for(let e of r){let r=e.split(` `),i=r[0];t.push(i),r.length>1&&r[1]===`*`&&(n=i)}return{branches:t,currentBranch:n}}function NO(e){if(!(e instanceof vO))return!1;let t=`${e.stderr}\n${e.stdout}`.toLowerCase();return[`authentication failed`,`terminal prompts disabled`,`could not read username`,`invalid username or password`,`access denied`,`permission denied`,`not authorized`].some(e=>t.includes(e))}function PO(e){if(e!==`global`&&e!==`local`&&e!==`system`)throw new F(`Git config scope must be one of: global, local, system.`);return`--${e}`}function FO(e){if(!(e instanceof vO))return!1;let t=`${e.stderr}\n${e.stdout}`.toLowerCase();return[`has no upstream branch`,`no upstream branch`,`no upstream configured`,`no tracking information for the current branch`,`no tracking information`,`set the remote as upstream`,`set the upstream branch`,`please specify which branch you want to merge with`].some(e=>t.includes(e))}function IO(e,t){return t?`Git ${e} requires a password/token for private repositories.`:`Git ${e} requires credentials for private repositories.`}function LO(e){return e===`push`?`Git push failed because no upstream branch is configured. Set upstream once with { setUpstream: true } (and optional remote/branch), or pass remote and branch explicitly.`:`Git pull failed because no upstream branch is configured. Pass remote and branch explicitly, or set upstream once (push with { setUpstream: true } or run: git branch --set-upstream-to=origin/<branch> <branch>).`}function RO(e,t){if(e===`local`){if(!t)throw new F(`A repository path is required when using scope "local".`);return t}}function zO(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}function BO(e,t){if(e==null)return{};var n,r,i=zO(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.includes(n)||{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}const VO=[`username`,`password`,`branch`,`depth`,`path`,`dangerouslyStoreCredentials`],HO=[`bare`,`initialBranch`],UO=[`fetch`,`overwrite`],WO=[`force`],GO=[`files`,`all`],KO=[`authorName`,`authorEmail`,`allowEmpty`],qO=[`mode`,`target`,`paths`],JO=[`paths`,`staged`,`worktree`,`source`],YO=[`remote`,`branch`,`setUpstream`,`username`,`password`],XO=[`remote`,`branch`,`username`,`password`],ZO=[`username`,`password`,`host`,`protocol`],QO=[`envs`],$O=[`envs`],ek={GIT_TERMINAL_PROMPT:`0`};var tk=class{constructor(e){this.commands=e}async clone(e,t){var n=this;let r=t??{},{username:i,password:a,branch:o,depth:s,path:c,dangerouslyStoreCredentials:l}=r,u=BO(r,VO);if(a&&!i)throw new F(`Username is required when using a password or token for git clone.`);let d=async(t,r)=>{let i=t&&r?CO(e,t,r):e,a=wO(i),d=!l&&a!==i,f=d?c??TO(e):c;if(d&&!f)throw new F(`A destination path is required when using credentials without storing them.`);let p=[`clone`,i];o&&p.push(`--branch`,o,`--single-branch`),s&&p.push(`--depth`,s.toString()),f&&p.push(f);let m=await n.runGit(p,void 0,u);return d&&await n.runGit([`remote`,`set-url`,`origin`,a],f,u),m};try{return await d(i,a)}catch(e){throw NO(e)?new GT(IO(`clone`,!!i&&!a)):e}}async init(e,t){var n=this;let r=t??{},{bare:i,initialBranch:a}=r,o=BO(r,HO),s=[`init`];return a&&s.push(`--initial-branch`,a),i&&s.push(`--bare`),s.push(e),n.runGit(s,void 0,o)}async remoteAdd(e,t,n,r){var i=this;if(!t||!n)throw new F(`Both remote name and URL are required to add a git remote.`);let a=r??{},{fetch:o,overwrite:s}=a,c=BO(a,UO),l=[`remote`,`add`];if(o&&l.push(`-f`),l.push(t,n),!s)return i.runGit(l,e,c);let u=`${EO(l,e)} || ${EO([`remote`,`set-url`,t,n],e)}`;if(o){let n=EO([`fetch`,t],e);u=`(${u}) && ${n}`}return i.runShell(u,c)}async remoteGet(e,t,n){var r=this;if(!t)throw new F(`Remote name is required.`);let i=`${EO([`remote`,`get-url`,t],e)} || true`,a=(await r.runShell(i,n)).stdout.trim();return a.length>0?a:void 0}async status(e,t){return jO((await this.runGit([`status`,`--porcelain=1`,`-b`],e,t)).stdout)}async branches(e,t){return MO((await this.runGit([`branch`,`--format=%(refname:short) %(HEAD)`],e,t)).stdout)}async createBranch(e,t,n){return this.runGit([`checkout`,`-b`,t],e,n)}async checkoutBranch(e,t,n){return this.runGit([`checkout`,t],e,n)}async deleteBranch(e,t,n){var r=this;let i=n??{},{force:a}=i,o=BO(i,WO),s=[`branch`,a?`-D`:`-d`,t];return r.runGit(s,e,o)}async add(e,t){var n=this;let r=t??{},{files:i,all:a=!0}=r,o=BO(r,GO),s=[`add`];return!i||i.length===0?s.push(a?`-A`:`.`):s.push(`--`,...i),n.runGit(s,e,o)}async commit(e,t,n){var r=this;let i=n??{},{authorName:a,authorEmail:o,allowEmpty:s}=i,c=BO(i,KO),l=[`commit`,`-m`,t];s&&l.push(`--allow-empty`);let u=[];return a&&u.push(`-c`,`user.name=${a}`),o&&u.push(`-c`,`user.email=${o}`),r.runGit([...u,...l],e,c)}async reset(e,t){var n=this;let r=t??{},{mode:i,target:a,paths:o}=r,s=BO(r,qO),c=[`soft`,`mixed`,`hard`,`merge`,`keep`];if(i&&!c.includes(i))throw new F(`Reset mode must be one of ${c.join(`, `)}.`);let l=[`reset`];return i&&l.push(`--${i}`),a&&l.push(a),o&&o.length>0&&l.push(`--`,...o),n.runGit(l,e,s)}async restore(e,t){var n=this;let{paths:r,staged:i,worktree:a,source:o}=t,s=BO(t,JO);if(!r||r.length===0)throw new F(`At least one path is required.`);let c=i,l=a;if(i===void 0&&a===void 0?l=!0:i===!0&&a===void 0?l=!1:i===void 0&&a!==void 0&&(c=!1),c===!1&&l===!1)throw new F(`At least one of staged or worktree must be true.`);let u=[`restore`];return l&&u.push(`--worktree`),c&&u.push(`--staged`),o&&u.push(`--source`,o),u.push(`--`,...r),n.runGit(u,e,s)}async push(e,t){var n=this;let r=t??{},{remote:i,branch:a,setUpstream:o=!0,username:s,password:c}=r,l=BO(r,YO);if(c&&!s)throw new F(`Username is required when using a password or token for git push.`);if(s&&c){let t=await n.resolveRemoteName(e,i,l);return n.withRemoteCredentials(e,t,s,c,l,()=>n.runGit(DO(t,{remote:i,branch:a,setUpstream:o}),e,l))}try{return await n.runGit(DO(void 0,{remote:i,branch:a,setUpstream:o}),e,l)}catch(e){throw NO(e)?new GT(IO(`push`,!!s&&!c)):FO(e)?new KT(LO(`push`)):e}}async pull(e,t){var n=this;let r=t??{},{remote:i,branch:a,username:o,password:s}=r,c=BO(r,XO);if(s&&!o)throw new F(`Username is required when using a password or token for git pull.`);if(!i&&!a&&!await n.hasUpstream(e,c))throw new KT(LO(`pull`));let l=e=>{let t=[`pull`],n=e??i;return n&&t.push(n),a&&t.push(a),t};if(o&&s){let t=await n.resolveRemoteName(e,i,c);return n.withRemoteCredentials(e,t,o,s,c,()=>n.runGit(l(t),e,c))}try{return await n.runGit(l(),e,c)}catch(e){throw NO(e)?new GT(IO(`pull`,!!o&&!s)):FO(e)?new KT(LO(`pull`)):e}}async setConfig(e,t,n){var r=this;if(!e)throw new F(`Git config key is required.`);let i=n?.scope??`global`,a=PO(i),o=RO(i,n?.path);return r.runGit([`config`,a,e,t],o,n)}async getConfig(e,t){var n=this;if(!e)throw new F(`Git config key is required.`);let r=t?.scope??`global`,i=PO(r),a=RO(r,t?.path),o=`${EO([`config`,i,`--get`,e],a)} || true`,s=(await n.runShell(o,t)).stdout.trim();return s.length>0?s:void 0}async dangerouslyAuthenticate(e){var t=this;let{username:n,password:r,host:i,protocol:a}=e,o=BO(e,ZO);if(!n||!r)throw new F(`Both username and password are required to authenticate git.`);let s=(i??`github.com`).trim(),c=[`protocol=${(a??`https`).trim()}`,`host=${s}`,`username=${n}`,`password=${r}`,``,``].join(`
|
|
206
|
+
`);await t.runGit([`config`,`--global`,`credential.helper`,`store`],void 0,o);let l=`printf %s ${fE(c)} | ${EO([`credential`,`approve`])}`;return t.runShell(l,o)}async configureUser(e,t,n){var r=this;if(!e||!t)throw new F(`Both name and email are required.`);let i=n?.scope??`global`,a=I(I({},n),{},{scope:i});return await r.setConfig(`user.name`,e,a),r.setConfig(`user.email`,t,a)}async runGit(e,t,n){var r=this;let i=n??{},{envs:a}=i,o=BO(i,QO),s=EO(e,t),c=I(I({},ek),a??{});return r.commands.run(s,I(I({},o),{},{envs:c}))}async runShell(e,t){var n=this;let r=t??{},{envs:i}=r,a=BO(r,$O),o=I(I({},ek),i??{});return n.commands.run(e,I(I({},a),{},{envs:o}))}async getRemoteUrl(e,t,n){let r=(await this.runGit([`remote`,`get-url`,t],e,n)).stdout.trim();if(!r)throw new F(`Remote "${t}" URL not found in repository.`);return r}async resolveRemoteName(e,t,n){var r=this;if(t)return t;let i=(await r.runGit([`remote`],e,n)).stdout.split(`
|
|
207
|
+
`).map(e=>e.trim()).filter(Boolean);if(i.length===1)return i[0];throw new F(`Remote is required when using username/password and the repository has multiple remotes.`)}async withRemoteCredentials(e,t,n,r,i,a){var o=this;let s=await o.getRemoteUrl(e,t,i),c=CO(s,n,r);await o.runGit([`remote`,`set-url`,t,c],e,i);let l,u;try{l=await a()}catch(e){u=e}let d;try{await o.runGit([`remote`,`set-url`,t,s],e,i)}catch(e){d=e}if(u)throw u;if(d)throw d;return l}async hasUpstream(e,t){var n=this;try{return(await n.runGit([`rev-parse`,`--abbrev-ref`,`--symbolic-full-name`,`@{u}`],e,t)).stdout.trim().length>0}catch{return!1}}};function nk(e){let t=e[Symbol.asyncIterator]();return new ReadableStream({async pull(e){try{let{done:n,value:r}=await t.next();n?e.close():e.enqueue(r)}catch(t){e.error(t)}},async cancel(e){await t.return?.call(t,e)}})}function rk(e){return{[Symbol.asyncIterator](){return cD(function*(){if(!e)return;let t=e.getReader();try{for(;;){let{done:e,value:n}=yield sD(t.read());if(e)return;yield n}}finally{t.releaseLock()}})()}}}function ik(e){return async t=>{let n=await e(t.url,{method:t.method,headers:t.header,body:t.body?nk(t.body):void 0,signal:t.signal,duplex:`half`});return{status:n.status,header:n.headers,body:rk(n.body),trailer:new Headers}}}function ak({baseUrl:e,fetch:t,interceptors:n=[]}){return ew({baseUrl:e,httpClient:ik(t),useBinaryFormat:!1,interceptors:n,acceptCompression:[],sendCompression:null,compressMinBytes:1024,readMaxBytes:4294967295,writeMaxBytes:4294967295})}var ok=class{constructor(e,t,n,r){this.transport=e,this.envdApi=t,this.connectionConfig=n,P(this,`rpc`,void 0),P(this,`streamingRpc`,void 0),P(this,`envdVersion`,void 0),P(this,`checkHealth`,void 0),P(this,`defaultPtyConnectionTimeout`,6e4),this.rpc=$S(jD,this.transport),this.streamingRpc=$S(jD,r),this.envdVersion=t.version,this.checkHealth=()=>qD(this.envdApi)}async create(e){var t=this;let n=e?.requestTimeoutMs??t.connectionConfig.requestTimeoutMs,r=I({},e?.envs??{});r.TERM=r.TERM??`xterm-256color`,r.LANG=r.LANG??`C.UTF-8`,r.LC_ALL=r.LC_ALL??`C.UTF-8`;let{controller:i,clearStartTimeout:a,cleanup:o}=BE(n,e?.signal),s=t.rpc.start({process:{cmd:`/bin/bash`,args:[`-i`,`-l`],envs:r,cwd:e?.cwd},pty:{size:{cols:e.cols,rows:e.rows}}},{headers:I(I({},WD(t.envdVersion,e?.user)),{},{[LE]:`50`}),signal:i.signal,timeoutMs:e?.timeoutMs??t.defaultPtyConnectionTimeout});try{let n=await QD(s);return a(),new yO(n,o,()=>t.kill(n),s,void 0,void 0,e.onData,void 0,void 0,t.checkHealth)}catch(e){throw o(),await VD(e,t.checkHealth)}}async connect(e,t){var n=this;let{controller:r,clearStartTimeout:i,cleanup:a}=BE(t?.requestTimeoutMs??n.connectionConfig.requestTimeoutMs,t?.signal),o=n.rpc.connect({process:{selector:{case:`pid`,value:e}}},{signal:r.signal,headers:{[LE]:`50`},timeoutMs:t?.timeoutMs??n.defaultPtyConnectionTimeout});try{let e=await QD(o);return i(),new yO(e,a,()=>n.kill(e),o,void 0,void 0,t?.onData,void 0,void 0,n.checkHealth)}catch(e){throw a(),await VD(e,n.checkHealth)}}async sendInput(e,t,n){var r=this;try{await r.rpc.sendInput({input:{input:{case:`pty`,value:t}},process:{selector:{case:`pid`,value:e}}},{signal:r.connectionConfig.getSignal(n?.requestTimeoutMs,n?.signal)})}catch(e){throw await VD(e,r.checkHealth)}}streamInput(e,t={}){return new xO(this.streamingRpc,e,`pty`,t,this.checkHealth)}async resize(e,t,n){var r=this;try{await r.rpc.update({process:{selector:{case:`pid`,value:e}},pty:{size:t}},{signal:r.connectionConfig.getSignal(n?.requestTimeoutMs,n?.signal)})}catch(e){throw await VD(e,r.checkHealth)}}async kill(e,t){var n=this;return HD(n.rpc,e,n.connectionConfig.getSignal(t?.requestTimeoutMs,t?.signal),n.checkHealth)}},sk=class{constructor(e,t,n,r){this.envdApi=t,this.connectionConfig=n,P(this,`rpc`,void 0),P(this,`streamingRpc`,void 0),P(this,`defaultProcessConnectionTimeout`,6e4),P(this,`envdVersion`,void 0),P(this,`checkHealth`,void 0),this.rpc=$S(jD,e),this.streamingRpc=$S(jD,r),this.envdVersion=t.version,this.checkHealth=()=>qD(this.envdApi)}get supportsStdinClose(){return wv(this.envdVersion,`0.5.2`)>=0}async list(e){var t=this;try{return(await t.rpc.list({},{signal:t.connectionConfig.getSignal(e?.requestTimeoutMs,e?.signal)})).processes.map(e=>I(I({pid:e.pid},e.tag&&{tag:e.tag}),{},{args:e.config.args,envs:e.config.envs,cmd:e.config.cmd},e.config.cwd&&{cwd:e.config.cwd}))}catch(e){throw await VD(e,t.checkHealth)}}async sendStdin(e,t,n){var r=this;try{let i=typeof t==`string`?new TextEncoder().encode(t):t;await r.rpc.sendInput({process:{selector:{case:`pid`,value:e}},input:{input:{case:`stdin`,value:i}}},{signal:r.connectionConfig.getSignal(n?.requestTimeoutMs,n?.signal)})}catch(e){throw await VD(e,r.checkHealth)}}streamInput(e,t={}){return new xO(this.streamingRpc,e,`stdin`,t,this.checkHealth)}async closeStdin(e,t){var n=this;if(!n.supportsStdinClose)throw new LT(`Sandbox envd version ${n.envdVersion} doesn't support closeStdin. Please rebuild your template to pick up the latest sandbox version.`);try{await n.rpc.closeStdin({process:{selector:{case:`pid`,value:e}}},{signal:n.connectionConfig.getSignal(t?.requestTimeoutMs,t?.signal)})}catch(e){throw await VD(e,n.checkHealth)}}async kill(e,t){var n=this;return HD(n.rpc,e,n.connectionConfig.getSignal(t?.requestTimeoutMs,t?.signal),n.checkHealth)}async connect(e,t){var n=this;let{controller:r,clearStartTimeout:i,cleanup:a}=BE(t?.requestTimeoutMs??n.connectionConfig.requestTimeoutMs,t?.signal),o=n.rpc.connect({process:{selector:{case:`pid`,value:e}}},{signal:r.signal,headers:{[LE]:`50`},timeoutMs:t?.timeoutMs??n.defaultProcessConnectionTimeout});return n.createHandle(o,i,a,t)}async run(e,t){let n=await this.start(e,t);return t?.background?n:n.wait()}async start(e,t){var n=this;if(t?.stdin===!1&&wv(n.envdVersion,`0.3.0`)<0)throw new LT(`Sandbox envd version ${n.envdVersion} can't specify stdin, it's always turned on. Please rebuild your template if you need this feature.`);let{controller:r,clearStartTimeout:i,cleanup:a}=BE(t?.requestTimeoutMs??n.connectionConfig.requestTimeoutMs,t?.signal),o=n.rpc.start({process:{cmd:`/bin/bash`,cwd:t?.cwd,envs:t?.envs,args:[`-l`,`-c`,e]},stdin:t?.stdin||!1},{headers:I(I({},WD(n.envdVersion,t?.user)),{},{[LE]:`50`}),signal:r.signal,timeoutMs:t?.timeoutMs??n.defaultProcessConnectionTimeout});return n.createHandle(o,i,a,t)}async createHandle(e,t,n,r){var i=this;try{let a=await QD(e);return t(),new yO(a,n,()=>i.kill(a),e,r?.onStdout,r?.onStderr,void 0,(e,t)=>i.sendStdin(a,e,t),e=>i.closeStdin(a,e),i.checkHealth,r?.retainOutput??!0)}catch(e){throw n(),await VD(e,i.checkHealth)}}};const ck=RegExp(`[{}\\p{Cc}]`,`u`),lk=new Set([`toJSON`,`then`,`toString`,`valueOf`]);function uk(e,t,n){let r=e===`toString`?()=>Object.prototype.toString.call(t()):e===`valueOf`?()=>t():{};return Object.defineProperty(r,Symbol.toPrimitive,{value:n}),Object.defineProperty(r,"toJSON",{value:n,enumerable:!0})}function dk(e){if(e.length===0||ck.test(e))throw new F(`iam token name ${JSON.stringify(e)} is not usable: a token name cannot be empty or contain '{', '}' or control characters, because it is interpolated into the '\${e2b.identity.tokens.<name>}' placeholder the egress proxy resolves.`)}function fk(e){return dk(e),`\${e2b.identity.tokens.${e}}`}function pk(e,{validate:t}){let n={};for(let t of e)n[t]=fk(t);let r=n=>{if(!t)return fk(n);throw new F(`Network transform references iam token '${n}', which is not registered. ${e.length===0?`Pass it to Sandbox.create as iam: { tokens: { '${n}': Secret.iamToken({ audience, tokenType }) } }.`:`Registered tokens: ${e.map(e=>`'${e}'`).join(`, `)}.`}`)},i=new Proxy(n,{get(e,t,n){return typeof t==`string`&&!Object.hasOwn(e,t)?lk.has(t)?uk(t,()=>i,()=>r(t)):r(t):Reflect.get(e,t,n)},has(e,t){return Object.hasOwn(e,t)}});return i}const mk=[`full`,`filesystem`];function hk(e,t,n){if(t!=null&&n!=null)throw new F(`Pass either ${e} or the deprecated keepMemory, not both.`);if(t==null)return n??void 0;if(!mk.includes(t))throw new F(`${e} must be one of: ${mk.join(`, `)} (got ${JSON.stringify(t)}).`);return t===`full`}function gk(e){if(e!==void 0&&(!Number.isInteger(e)||e<1||e>20))throw new F(`count must be an integer between 1 and 20`)}function _k(e){return{sandboxId:e.sandboxID,sandboxDomain:e.domain||void 0,envdVersion:e.envdVersion,envdAccessToken:e.envdAccessToken,trafficAccessToken:e.trafficAccessToken||void 0}}function vk(e,t){if(e!==void 0)return typeof e==`function`?e({allTraffic:`0.0.0.0/0`,rules:t}):e}function yk(e,{validate:t}){return{iam:{tokens:pk(e,{validate:t})}}}function bk(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function xk(e){return e===null?`null`:typeof e==`object`?Array.isArray(e)?`array`:e.constructor?.name??`object`:typeof e}function Sk(e,t){let n={};for(let[r,i]of e)n[r]=i.map(e=>{if(e.transform==null)return{};if(typeof e.transform!=`function`)return{transform:e.transform};let n=e.transform(t);if(typeof n?.then==`function`)throw Promise.resolve(n).catch(()=>{}),new F(`Network transform callback for '${r}' must be synchronous, it returned a promise. Resolve the value before creating the sandbox.`);if(!bk(n))throw new F(`Network transform callback for '${r}' must return a transform object, got ${xk(n)}.`);return{transform:n}});return n}function Ck(e){if(!bk(e)||typeof e.address!=`string`)throw new F(`network egressProxy must be an object with a string 'address' (e.g. 'proxy.example.com:1080').`);let t=e.tls;if(t!=null&&typeof t!=`boolean`&&!bk(t))throw new F(`network egressProxy tls must be a boolean or an object.`);if(bk(t)&&Object.prototype.hasOwnProperty.call(t,`enabled`))throw new F(`network egressProxy tls takes no 'enabled'; pass tls: true or tls: false instead.`);let n=t===!0?{enabled:!0}:typeof t==`object`&&t?I(I({enabled:!0},t.serverName==null?{}:{serverName:t.serverName}),t.caCert==null?{}:{caCert:t.caCert}):void 0;return I(I(I({address:e.address},e.username==null?{}:{username:e.username}),e.password==null?{}:{password:e.password}),n===void 0?{}:{tls:n})}function wk(e,t){let n=e.rules instanceof Map?e.rules:new Map(Object.entries(e.rules??{})),r=vk(e.allowOut,n),i=vk(e.denyOut,n);return I(I(I(I(I({},r===void 0?{}:{allowOut:r}),i===void 0?{}:{denyOut:i}),e.egressProxy==null?{}:{egressProxy:Ck(e.egressProxy)}),e.dnsServers==null?{}:{dnsServers:[...e.dnsServers]}),e.rules===void 0?{}:{rules:Sk(n,t)})}function Tk(e){if(e)return I(I({address:e.address},e.username===void 0?{}:{username:e.username}),e.tls?.enabled===!0?{tls:I({},e.tls.serverName===void 0?{}:{serverName:e.tls.serverName})}:{})}function Ek(e,t){if(e)return I(I(I(I({},wk(e,yk(Object.keys(t?.tokens??{}),{validate:!0}))),e.allowPublicTraffic===void 0?{}:{allowPublicTraffic:e.allowPublicTraffic}),e.maskRequestHost===void 0?{}:{maskRequestHost:e.maskRequestHost}),e.httpsPorts===void 0?{}:{httpsPorts:e.httpsPorts})}function Dk(e){let t={};for(let[n,r]of Object.entries(e?.tokens??{}))if(r){if(typeof r.audience!=`string`||typeof r.tokenType!=`string`)throw new F(`iam token '${n}' must have string 'audience' and 'tokenType' properties.`);dk(n),t[n]={audience:r.audience,tokenType:r.tokenType}}if(Object.keys(t).length!==0)return{tokens:t}}function Ok(e){return I(I({},wk(e,yk([],{validate:!1}))),e.allowInternetAccess===void 0?{}:{allow_internet_access:e.allowInternetAccess})}var kk=class extends GE{constructor(){super()}static async kill(e,t){let n=this.resolveOpts(t),r=new WE(n);if(r.debug)return!0;let i=await new hD(r).api.DELETE(`/sandboxes/{sandboxID}`,{params:{path:{sandboxID:e}},signal:r.getSignal(n?.requestTimeoutMs,n?.signal)});if(i.error?.code===404)return!1;let a=mD(i);if(a)throw a;return!0}static async getInfo(e,t){let n=this.resolveOpts(t),r=new WE(n),i=await new hD(r).api.GET(`/sandboxes/{sandboxID}`,{params:{path:{sandboxID:e}},signal:r.getSignal(n?.requestTimeoutMs,n?.signal)});if(i.error?.code===404)throw new VT(`Sandbox ${e} not found`);let a=mD(i);if(a)throw a;if(!i.data)throw Error(`Sandbox not found`);return I(I({sandboxId:i.data.sandboxID,templateId:i.data.templateID},i.data.alias&&{name:i.data.alias}),{},{metadata:i.data.metadata??{},allowInternetAccess:i.data.allowInternetAccess??void 0,envdVersion:i.data.envdVersion,startedAt:new Date(i.data.startedAt),endAt:new Date(i.data.endAt),state:i.data.state,cpuCount:i.data.cpuCount,memoryMB:i.data.memoryMB,network:i.data.network?I(I({allowOut:i.data.network.allowOut,denyOut:i.data.network.denyOut,rules:i.data.network.rules??void 0,egressProxy:Tk(i.data.network.egressProxy)},i.data.network.dnsServers===void 0?{}:{dnsServers:i.data.network.dnsServers}),{},{allowPublicTraffic:i.data.network.allowPublicTraffic??void 0,maskRequestHost:i.data.network.maskRequestHost,httpsPorts:i.data.network.httpsPorts}):void 0,lifecycle:i.data.lifecycle?{onTimeout:i.data.lifecycle.onTimeout,autoResume:i.data.lifecycle.autoResume}:void 0,sandboxDomain:i.data.domain||void 0,volumeMounts:i.data.volumeMounts??[],envdUnresponsiveAtPause:i.data.envdUnresponsiveAtPause||void 0})}static async getFullInfo(e,t){return await this.getInfo(e,t)}static async getMetrics(e,t){let n=this.resolveOpts(t),r=new WE(n);if(r.debug)return[];let i=new hD(r),a=n?.start?Math.round(n.start.getTime()/1e3):void 0,o=n?.end?Math.round(n.end.getTime()/1e3):void 0,s=await i.api.GET(`/sandboxes/{sandboxID}/metrics`,{params:{path:{sandboxID:e},query:{start:a,end:o}},signal:r.getSignal(n?.requestTimeoutMs,n?.signal)});if(s.error?.code===404)throw new VT(`Sandbox ${e} not found`);let c=mD(s);if(c)throw c;return s.data?.map(e=>({timestamp:new Date(e.timestamp),cpuUsedPct:e.cpuUsedPct,cpuCount:e.cpuCount,memUsed:e.memUsed,memTotal:e.memTotal,memCache:e.memCache,diskUsed:e.diskUsed,diskTotal:e.diskTotal}))??[]}static async setTimeout(e,t,n){let r=this.resolveOpts(n),i=new WE(r),a=await new hD(i).api.POST(`/sandboxes/{sandboxID}/timeout`,{params:{path:{sandboxID:e}},body:{timeout:nE(t)},signal:i.getSignal(r?.requestTimeoutMs,r?.signal)});if(a.error?.code===404)throw new VT(`Sandbox ${e} not found`);let o=mD(a);if(o)throw o}static async updateNetwork(e,t,n){let r=this.resolveOpts(n),i=new WE(r),a=await new hD(i).api.PUT(`/sandboxes/{sandboxID}/network`,{params:{path:{sandboxID:e}},body:Ok(t),signal:i.getSignal(r?.requestTimeoutMs,r?.signal)});if(a.error?.code===404)throw new VT(`Sandbox ${e} not found`);let o=mD(a);if(o)throw o}static async pause(e,t){let n=this.resolveOpts(t),r=hk(`mode`,n?.mode,n?.keepMemory),i=new WE(n),a=await new hD(i).api.POST(`/sandboxes/{sandboxID}/pause`,{params:{path:{sandboxID:e}},body:{memory:r,requireHealthyGuest:n?.strict?!0:void 0},signal:i.getSignal(n?.requestTimeoutMs,n?.signal)});if(a.error?.code===404)throw new VT(`Sandbox ${e} not found`);if(a.error?.code===409)return!1;let o=mD(a);if(o)throw o;return!0}static async betaPause(e,t){return this.pause(e,t)}static async createSnapshot(e,t){let n=this.resolveOpts(t),r=new WE(n),i=await new hD(r).api.POST(`/sandboxes/{sandboxID}/snapshots`,{params:{path:{sandboxID:e}},body:I(I({},n?.name?{name:n.name}:{}),{},{memory:hk(`mode`,n?.mode)}),signal:r.getSignal(n?.requestTimeoutMs,n?.signal)});if(i.error?.code===404)throw new VT(`Sandbox ${e} not found`);let a=mD(i);if(a)throw a;return{snapshotId:i.data.snapshotID,names:i.data.names??[]}}static listSnapshots(e){return new jk(this.resolveOpts(e))}static async deleteSnapshot(e,t){let n=this.resolveOpts(t),r=new WE(n),i=await new hD(r).api.DELETE(`/templates/{templateID}`,{params:{path:{templateID:e}},signal:r.getSignal(n?.requestTimeoutMs,n?.signal)});if(i.error?.code===404)return!1;let a=mD(i);if(a)throw a;return!0}static async createSandbox(e,t,n){var r=this,i,a;let o=EE(n?.idempotencyKey),s=n==null||(i=n.lifecycle)==null?void 0:i.onTimeout,c=s!=null,l=s??`kill`,u=typeof l==`string`?l:l.action,d=[`pause`,`kill`];if(c&&!d.includes(u))throw new F(`${typeof l==`string`?`onTimeout`:`onTimeout.action`} must be one of: ${d.join(`, `)} (got ${JSON.stringify(u)}).`);let f=typeof l==`string`?{}:l,p=`mode`in f||`keepMemory`in f,m=(n==null||(a=n.lifecycle)==null?void 0:a.autoResume)??void 0;if(p&&u!==`pause`)throw new F(`onTimeout.mode is only allowed when action is 'pause'.`);let h=hk(`onTimeout.mode`,f.mode,f.keepMemory);if(m&&u!==`pause`)throw new F(`autoResume can only be true when onTimeout action is 'pause'.`);if(h===!1&&m)throw new F(`autoResume: true is not a valid value with mode: 'filesystem' - a filesystem-only snapshot cannot be auto-resumed by traffic and must be resumed explicitly using Sandbox.connect().`);let g=Dk(n?.iam),_={templateID:e,metadata:n?.metadata,mcp:n?.mcp,envVars:n?.envs,timeout:t===void 0?void 0:nE(t),allow_internet_access:n?.allowInternetAccess,network:Ek(n?.network,g),iam:g,autoPause:c?u===`pause`:void 0,autoPauseMemory:u===`pause`?h:void 0,autoResume:m===void 0?void 0:{enabled:m}};n?.volumeMounts&&(_.volumeMounts=Object.entries(n.volumeMounts).map(([e,t])=>({name:typeof t==`string`?t:t.name,path:e})));let v=r.resolveOpts(n),y=new WE(v),ee=await new hD(y).api.POST(`/v2/sandboxes`,{body:_,params:o===void 0?void 0:{header:{"Idempotency-Key":o}},signal:y.getSignal(v?.requestTimeoutMs,v?.signal)}),b=mD(ee);if(b)throw b;if(wv(ee.data.envdVersion,`0.1.0`)<0)throw await r.kill(ee.data.sandboxID,v),new qT(`You need to update the template to use the new SDK.`);return _k(ee.data)}static async forkSandbox(e,t,n,r){var i=this;gk(n);let a=i.resolveOpts(r),o=new WE(a),s=await new hD(o).api.POST(`/sandboxes/{sandboxID}/fork`,{params:{path:{sandboxID:e}},body:{timeout:t===void 0?void 0:nE(t),count:n},signal:o.getSignal(a?.requestTimeoutMs,a?.signal)});if(s.response.status===404)throw new VT(s.error?.message??`Sandbox ${e} not found`);let c=mD(s);if(c)throw c;return(s.data??[]).map(e=>e.error||!e.sandbox?e.error?e.error.code===404?new zT(`${e.error.code}: ${e.error.message}`):pD(e.error.code,e.error.message):new LT(`Failed to start forked sandbox`):_k(e.sandbox))}static async connectSandbox(e,t){let n=this.resolveOpts(t),r=n?.timeoutMs,i=n?.onResume??void 0,a=[`restore`,`reboot`];if(i!==void 0&&!a.includes(i))throw new F(`onResume must be one of: ${a.join(`, `)} (got ${JSON.stringify(i)}).`);let o=new WE(n),s=await new hD(o).api.POST(`/v2/sandboxes/{sandboxID}/connect`,{params:{path:{sandboxID:e}},body:{timeout:r===void 0?void 0:nE(r),memory:i!==`reboot`&&void 0},signal:o.getSignal(n?.requestTimeoutMs,n?.signal)});if(s.error?.code===404)throw new VT(`Paused sandbox ${e} not found`);let c=mD(s);if(c)throw c;return _k(s.data)}},Ak=class extends SO{constructor(e){super(e,e?.limit,e?.nextToken),P(this,`query`,void 0),P(this,`order`,void 0),this.query=e?.query,this.order=e?.order}async nextItems(e){var t=this,n;if(!t.hasNext)throw Error(`No more items to fetch`);let r;if(t.query?.metadata){let e=Object.fromEntries(Object.entries(t.query.metadata).map(([e,t])=>[encodeURIComponent(e),encodeURIComponent(t)]));r=new URLSearchParams(e).toString()}let i=WE.mergeOpts(t.opts,e),a=new WE(i),o=await new hD(a).api.GET(`/v2/sandboxes`,{params:{query:{metadata:r,state:t.query?.state,startedAfter:(n=t.query)==null||(n=n.startedAfter)==null?void 0:n.toISOString(),template:t.query?.template||void 0,order:t.order,limit:t.limit,nextToken:t.nextToken}},signal:a.getSignal(i?.requestTimeoutMs,i?.signal)}),s=mD(o);if(s)throw s;return t.updatePagination(o.response),(o.data??[]).map(e=>I(I({sandboxId:e.sandboxID,templateId:e.templateID},e.alias&&{name:e.alias}),{},{metadata:e.metadata??{},startedAt:new Date(e.startedAt),endAt:new Date(e.endAt),state:e.state,cpuCount:e.cpuCount,memoryMB:e.memoryMB,envdVersion:e.envdVersion,volumeMounts:e.volumeMounts??[],envdUnresponsiveAtPause:e.envdUnresponsiveAtPause||void 0}))}},jk=class extends SO{constructor(e){super(e,e?.limit,e?.nextToken),P(this,`sandboxId`,void 0),P(this,`name`,void 0),this.sandboxId=e?.sandboxId,this.name=e?.name}async nextItems(e){var t=this;if(!t.hasNext)throw Error(`No more items to fetch`);let n=WE.mergeOpts(t.opts,e),r=new WE(n),i=await new hD(r).api.GET(`/snapshots`,{params:{query:{sandboxID:t.sandboxId,name:t.name,limit:t.limit,nextToken:t.nextToken}},signal:r.getSignal(n?.requestTimeoutMs,n?.signal)}),a=mD(i);if(a)throw a;return t.updatePagination(i.response),(i.data??[]).map(e=>({snapshotId:e.snapshotID,names:e.names??[]}))}},Mk=class extends kk{constructor(e){super(),P(this,`files`,void 0),P(this,`commands`,void 0),P(this,`pty`,void 0),P(this,`git`,void 0),P(this,`sandboxId`,void 0),P(this,`sandboxDomain`,void 0),P(this,`trafficAccessToken`,void 0),P(this,`envdPort`,49983),P(this,`mcpPort`,50005),P(this,`connectionConfig`,void 0),P(this,`envdAccessToken`,void 0),P(this,`envdApiUrl`,void 0),P(this,`envdDirectUrl`,void 0),P(this,`envdApi`,void 0),P(this,`mcpToken`,void 0),this.connectionConfig=new WE(e),this.sandboxId=e.sandboxId,this.sandboxDomain=e.sandboxDomain??this.connectionConfig.domain,this.envdAccessToken=e.envdAccessToken,this.trafficAccessToken=e.trafficAccessToken,this.envdApiUrl=this.connectionConfig.getSandboxUrl(this.sandboxId,{sandboxDomain:this.sandboxDomain,envdPort:this.envdPort}),this.envdDirectUrl=this.connectionConfig.getSandboxDirectUrl(this.sandboxId,{sandboxDomain:this.sandboxDomain,envdPort:this.envdPort});let t={"E2b-Sandbox-Id":this.sandboxId,"E2b-Sandbox-Port":this.envdPort.toString()},n=SD(this.connectionConfig),r=CD(this.connectionConfig),i=e?.logger?[dD(e.logger)]:void 0,a=(e,n)=>{let i=new Headers({"User-Agent":this.connectionConfig.headers?.[`User-Agent`]??``});return new Headers(n?.headers).forEach((e,t)=>i.append(t,e)),new Headers(t).forEach((e,t)=>i.append(t,e)),this.envdAccessToken&&i.append(`X-Access-Token`,this.envdAccessToken),n=I(I({},n??{}),{},{headers:i,redirect:`follow`}),r(e,n).then(GD)},o=aw({baseUrl:this.envdApiUrl,useBinaryFormat:!1,interceptors:i,fetch:a}),s=ak({baseUrl:this.envdApiUrl,fetch:a,interceptors:i});this.envdApi=new eO({apiUrl:this.envdApiUrl,logger:e?.logger,envdAccessToken:this.envdAccessToken,headers:I({"User-Agent":this.connectionConfig.headers?.[`User-Agent`]??``},t),fetch:e=>n(e)},{version:e.envdVersion}),this.files=new gO(o,this.envdApi,this.connectionConfig),this.commands=new sk(o,this.envdApi,this.connectionConfig,s),this.pty=new ok(o,this.envdApi,this.connectionConfig,s),this.git=new tk(this.commands)}static list(e){return new Ak(this.resolveOpts(e))}static async create(e,t){var n=this;let{template:r,sandboxOpts:i}=typeof e==`string`?{template:e,sandboxOpts:t}:{template:e?.template??(e?.mcp?n.defaultMcpTemplate:n.defaultTemplate),sandboxOpts:e},a=n.resolveOpts(i),o=new WE(a);if(o.debug)return new n(I({sandboxId:`debug_sandbox_id`,envdVersion:DD},o));let s=new n(I(I({},await n.createSandbox(r,a?.timeoutMs,a)),o));if(i?.mcp){s.mcpToken=crypto.randomUUID();try{await s.commands.run(`mcp-gateway --config ${fE(JSON.stringify(i.mcp))}`,{user:`root`,envs:{GATEWAY_ACCESS_TOKEN:s.mcpToken??``}})}catch(e){throw await s.kill().catch(()=>void 0),e instanceof vO?new LT(`Failed to start MCP gateway: ${e.stderr}`):e}}return s}static async connect(e,t){var n=this;let r=n.resolveOpts(t),i=new WE(r);if(i.debug)return new n(I({sandboxId:e,envdVersion:DD},i));let a=await n.connectSandbox(e,r);return new n(I({sandboxId:e,sandboxDomain:a.sandboxDomain,envdAccessToken:a.envdAccessToken,trafficAccessToken:a.trafficAccessToken,envdVersion:a.envdVersion},i))}static async fork(e,t){var n=this;let r=n.resolveOpts(t),i=new WE(r);return(await n.forkSandbox(e,r?.timeoutMs,r?.count,r)).map(e=>e instanceof Error?e:new n(I(I({},e),i)))}async connect(e){var t=this;return t.connectionConfig.debug||await kk.connectSandbox(t.sandboxId,t.resolveApiOpts(e)),t}async fork(e){var t=this;return await t.constructor.fork(t.sandboxId,t.resolveApiOpts(e))}getHost(e){return this.connectionConfig.getHost(this.sandboxId,e,this.sandboxDomain)}async isRunning(e){var t=this;let n=t.connectionConfig.getSignal(e?.requestTimeoutMs,e?.signal),r=await t.envdApi.api.GET(`/health`,{signal:n});if(r.response.status==502)return!1;let i=await ZD(r);if(i)throw i;return!0}async setTimeout(e,t){var n=this;n.connectionConfig.debug||await kk.setTimeout(n.sandboxId,e,n.resolveApiOpts(t))}async updateNetwork(e,t){var n=this;await kk.updateNetwork(n.sandboxId,e,n.resolveApiOpts(t))}async kill(e){var t=this;return t.connectionConfig.debug?!0:await kk.kill(t.sandboxId,t.resolveApiOpts(e))}async pause(e){var t=this;return await kk.pause(t.sandboxId,t.resolveApiOpts(e))}async betaPause(e){var t=this;return await kk.betaPause(t.sandboxId,t.resolveApiOpts(e))}async createSnapshot(e){var t=this;return await kk.createSnapshot(t.sandboxId,I(I({},t.resolveApiOpts(e)),{},{name:e?.name,mode:e?.mode}))}listSnapshots(e){return kk.listSnapshots(I(I({},this.resolveApiOpts(e)),{},{sandboxId:this.sandboxId}))}getMcpUrl(){return`https://${this.getHost(this.mcpPort)}/mcp`}async getMcpToken(){var e=this;return e.mcpToken||=await e.files.read(`/etc/mcp-gateway/.token`,{user:`root`}),e.mcpToken}async uploadUrl(e,t){var n=this;t??={};let r=!!n.envdAccessToken;if(!r&&t.useSignatureExpiration!=null)throw new F(`Signature expiration can be used only when sandbox is created as secured.`);let i=t.user;i==null&&wv(n.envdApi.version,`0.4.0`)<0&&(i=KE);let a=e??``,o=n.fileUrl(a,i);if(r){let e=new URL(o),r=await gD({path:a,operation:`write`,user:i,expirationInSeconds:t.useSignatureExpiration,envdAccessToken:n.envdAccessToken});return e.searchParams.set(`signature`,r.signature),r.expiration&&e.searchParams.set(`signature_expiration`,r.expiration.toString()),e.toString()}return o}async downloadUrl(e,t){var n=this;t??={};let r=!!n.envdAccessToken;if(!r&&t.useSignatureExpiration!=null)throw new F(`Signature expiration can be used only when sandbox is created as secured.`);let i=t.user;i==null&&wv(n.envdApi.version,`0.4.0`)<0&&(i=KE);let a=n.fileUrl(e,i);if(r){let r=new URL(a),o=await gD({path:e,operation:`read`,user:i,expirationInSeconds:t.useSignatureExpiration,envdAccessToken:n.envdAccessToken});return r.searchParams.set(`signature`,o.signature),o.expiration&&r.searchParams.set(`signature_expiration`,o.expiration.toString()),r.toString()}return a}async getInfo(e){var t=this;return await kk.getInfo(t.sandboxId,t.resolveApiOpts(e))}async getMetrics(e){var t=this;if(t.connectionConfig.debug)return[];if(t.envdApi.version){if(wv(t.envdApi.version,`0.1.5`)<0)throw new qT(`You need to update the template to use the new SDK.`);if(wv(t.envdApi.version,`0.2.4`)<0){var n,r;(n=t.connectionConfig.logger)==null||(r=n.warn)==null||r.call(n,`Disk metrics are not supported in this version of the sandbox, please rebuild the template to get disk metrics.`)}}return await kk.getMetrics(t.sandboxId,t.resolveApiOpts(e))}resolveApiOpts(e){return WE.mergeOpts(this.connectionConfig,e)}fileUrl(e,t){let n=new URL(`/files`,this.envdDirectUrl);return t&&n.searchParams.set(`username`,t),e&&n.searchParams.set(`path`,e),n.toString()}};P(Mk,`defaultTemplate`,`base`),P(Mk,`defaultMcpTemplate`,`mcp-gateway`);function Nk(e){let t=new WeakMap;return new Proxy(e,{apply(e,t,n){return new e(...n)},get(e,n,r){let i=Reflect.get(e,n,r);if(n===`prototype`||typeof i!=`function`)return i;let a=typeof r==`function`?r:e,o=t.get(a);o||(o=new Map,t.set(a,o));let s=o.get(n);return s||(s=i.bind(a),o.set(n,s)),s}})}var Pk=class{constructor(e,t,n){P(this,`timestamp`,void 0),P(this,`level`,void 0),P(this,`message`,void 0),this.timestamp=e,this.level=t,this.message=qre(n)}toString(){return`[${this.timestamp.toISOString()}] [${this.level}] ${this.message}`}},Fk=class extends Pk{constructor(e,t){super(e,`debug`,t)}},Ik=class extends Pk{constructor(e,t){super(e,`debug`,t)}};Bw.red(`ERROR`),Bw.hex(`#FF4400`)(`WARN `),Bw.hex(`#FF8800`)(`INFO `),Bw.gray(`DEBUG`);const Lk=/(^|@)\S+:\d+/,Rk=/^\s*at .*(\S+:\d+|\(native\))/m,zk=/^(eval@)?(\[native code\])?$/;function Bk(e,t){if(e.stacktrace!==void 0||e[`opera#sourceloc`]!==void 0)return qk(e,t);if(e.stack&&Rk.test(e.stack))return Uk(e,t);if(e.stack)return Gk(e,t);if(t?.allowEmpty)return[];throw Error(`Cannot parse given Error object`)}function Vk(e){if(!e.includes(`:`))return[e,void 0,void 0];let t=/(.+?)(?::(\d+))?(?::(\d+))?$/.exec(e.replace(/[()]/g,``));return[t[1],t[2]||void 0,t[3]||void 0]}function Hk(e,t){return t&&t.slice!=null?Array.isArray(t.slice)?e.slice(t.slice[0],t.slice[1]):e.slice(0,t.slice):e}function Uk(e,t){return Wk(e.stack,t)}function Wk(e,t){return Hk(e.split(`
|
|
208
|
+
`).filter(e=>!!e.match(Rk)),t).map(e=>{e.includes(`(eval `)&&(e=e.replace(/eval code/g,`eval`).replace(/(\(eval at [^()]*)|(,.*$)/g,``));let t=e.replace(/^\s+/,``).replace(/\(eval code/g,`(`).replace(/^.*?\s+/,``),n=t.match(/ (\(.+\)$)/);t=n?t.replace(n[0],``):t;let r=Vk(n?n[1]:t);return{function:n&&t||void 0,file:[`eval`,`<anonymous>`].includes(r[0])?void 0:r[0],line:r[1]?+r[1]:void 0,col:r[2]?+r[2]:void 0,raw:e}})}function Gk(e,t){return Kk(e.stack,t)}function Kk(e,t){return Hk(e.split(`
|
|
209
|
+
`).filter(e=>!e.match(zk)),t).map(e=>{if(e.includes(` > eval`)&&(e=e.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,`:$1`)),!e.includes(`@`)&&!e.includes(`:`))return{function:e};{let t=/(([^\n\r"\u2028\u2029]*".[^\n\r"\u2028\u2029]*"[^\n\r@\u2028\u2029]*(?:@[^\n\r"\u2028\u2029]*"[^\n\r@\u2028\u2029]*)*(?:[\n\r\u2028\u2029][^@]*)?)?[^@]*)@/,n=e.match(t),r=n&&n[1]?n[1]:void 0,i=Vk(e.replace(t,``));return{function:r,file:i[0],line:i[1]?+i[1]:void 0,col:i[2]?+i[2]:void 0,raw:e}}})}function qk(e,t){return!e.stacktrace||e.message.includes(`
|
|
210
|
+
`)&&e.message.split(`
|
|
211
|
+
`).length>e.stacktrace.split(`
|
|
212
|
+
`).length?Jk(e):e.stack?Xk(e,t):Yk(e)}function Jk(e,t){let n=/Line (\d+).*script (?:in )?(\S+)/i,r=e.message.split(`
|
|
213
|
+
`),i=[];for(let e=2,t=r.length;e<t;e+=2){let t=n.exec(r[e]);t&&i.push({file:t[2],line:+t[1],raw:r[e]})}return Hk(i,t)}function Yk(e,t){let n=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i,r=e.stacktrace.split(`
|
|
214
|
+
`),i=[];for(let e=0,t=r.length;e<t;e+=2){let t=n.exec(r[e]);t&&i.push({function:t[3]||void 0,file:t[2],line:t[1]?+t[1]:void 0,raw:r[e]})}return Hk(i,t)}function Xk(e,t){return Hk(e.stack.split(`
|
|
215
|
+
`).filter(e=>!!e.match(Lk)&&!e.match(/^Error created at/)),t).map(e=>{let t=e.split(`@`),n=Vk(t.pop()),r=t.shift()||``,i=r.replace(/<anonymous function(: (\w+))?>/,`$2`).replace(/\([^)]*\)/g,``)||void 0,a;return/\([^)]*\)/.test(r)&&(a=r.replace(/^[^(]+\(([^)]*)\)$/,`$1`)),{function:i,args:a===void 0||a===`[arguments not available]`?void 0:a.split(`,`),file:n[0],line:n[1]?+n[1]:void 0,col:n[2]?+n[2]:void 0,raw:e}})}function Zk(e){return e.map(e=>({functionName:e.function,args:e.args,fileName:e.file,lineNumber:e.line,columnNumber:e.col,source:e.raw}))}function Qk(e,t){return Zk(Bk(e,t))}const $k=[`alias`];function eA(e,n){if(t.isAbsolute(e))throw new qT(`Invalid source path "${e}": absolute paths are not allowed. Use a relative path within the context directory.`,n);let r=t.normalize(e);if(r===`..`||r.startsWith(`..`+t.sep))throw new qT(`Invalid source path "${e}": path escapes the context directory. The path must stay within the context directory.`,n)}function tA(e,t){let n,r;if(typeof e==`string`)n=e,r=t??{};else{let{alias:t}=e,i=BO(e,$k);n=t,r=i}if(!n||n.length===0)throw new qT(`Name must be provided`);return{name:n,buildOptions:r}}function nA(e){let n=t.join(e,`.dockerignore`);return le.existsSync(n)?le.readFileSync(n,`utf-8`).replace(/^\uFEFF/,``).split(`
|
|
216
|
+
`).filter(e=>!e.startsWith(`#`)).map(e=>e.trim()).filter(e=>e):[]}function rA(e){return e.replace(/\\/g,`/`)}function iA(e,n){let r=e.trim(),i=r.startsWith(`!`);if(i&&(r=r.slice(1).trim()),t.isAbsolute(r)){let e=t.relative(n,r);e!==``&&e!==`..`&&!e.startsWith(`..${t.sep}`)&&!t.isAbsolute(e)&&(r=e)}return(i?`!`:``)+r}function aA(e,n){let r=t.resolve(n),i;try{i=new Pre(e.map(e=>iA(e,r)),{backslashIsSeparator:t.sep===`\\`})}catch(e){throw new qT(e.message)}let a=e=>{let t=e.relativePosix();return t!==``&&i.matches(t)};return{ignored:a,childrenIgnored:e=>a(e)&&!i.mayMatchUnder(e.relativePosix())}}async function oA(e,n,r,i=!0){let{glob:a}=await rE(`glob`),o=new Map,s=aA(r,n),c=await a(e,{ignore:s,withFileTypes:!0,dot:!0,cwd:n}),l=e=>{let t=e.relativePosix();return t===``?0:t.split(`/`).length};c.sort((e,t)=>l(e)-l(t));let u=new Set,d=e=>{if(u.has(``))return!0;for(let n=t.posix.dirname(e);n!==`.`&&n!==`/`;n=t.posix.dirname(n))if(u.has(n))return!0;return!1};for(let e of c)d(e.relativePosix())||(e.isDirectory()?(u.add(e.relativePosix()),i&&o.set(e.fullpath(),e),(await a(rA(t.join(e.relative()||`.`,`**/*`)),{ignore:s,withFileTypes:!0,dot:!0,cwd:n})).forEach(e=>o.set(e.fullpath(),e))):o.set(e.fullpath(),e));return Array.from(o.values()).sort((e,t)=>e.fullpath()<t.fullpath()?-1:+(e.fullpath()>t.fullpath()))}function sA(e,t,n){let r=le.openSync(t,`r`);try{let t;for(;(t=le.readSync(r,n,0,n.length,null))>0;)e.update(n.subarray(0,t))}finally{le.closeSync(r)}}async function cA(e,n,r,i,a,o){let s=t.join(r,e),c=l.createHash(`sha256`),u=`COPY ${e} ${n}`;c.update(u);let d=await oA(e,r,i,!0);if(d.length===0){let e=Error(`No files found in ${s}`);throw o&&(e.stack=o),e}let f=e=>{c.update(e.mode.toString()),e.isDirectory()||c.update(e.size.toString())},p=Buffer.allocUnsafe(1048576);for(let e of d){let t=e.relativePosix();if(c.update(t),e.isSymbolicLink()){let t=le.statSync(e.fullpath(),{throwIfNoEntry:!1});if(!(a&&(t?.isFile()||t?.isDirectory()))){f(le.lstatSync(e.fullpath()));let t=le.readlinkSync(e.fullpath());c.update(t);continue}}let n=le.statSync(e.fullpath());f(n),n.isFile()&&sA(c,e.fullpath(),p)}return c.digest(`hex`)}function lA(e){return e.startsWith(`file:`)?Te.fileURLToPath(e):e}function uA(e,n){if(e.startsWith(`node:`)||e===`native`)return!1;try{let r=t.relative(n,t.dirname(lA(e)));return r!==``&&(r.startsWith(`..`)||t.isAbsolute(r))}catch{return!1}}function dA(){let e=Qk(Error(),{allowEmpty:!0}),n=e[0]?.fileName;if(!n)return{frames:e,userFrameIndex:-1};let r=t.dirname(lA(n));return{frames:e,userFrameIndex:e.findIndex(e=>e.fileName!==void 0&&uA(e.fileName,r))}}function fA(){let{frames:e,userFrameIndex:t}=dA();if(t!==-1)return e.slice(t).map(e=>e.source).filter(e=>e!==void 0).join(`
|
|
217
|
+
`)}function pA(){let{frames:e,userFrameIndex:n}=dA(),r=n===-1?void 0:e[n].fileName;if(r)return t.dirname(lA(r))}function mA(e){return e.toString(8).padStart(4,`0`)}async function hA(e,n,r,i,a){let{create:o}=await rE(`tar`),s=(await oA(e,n,r,!0)).map(e=>e.relativePosix()),c=await le.promises.mkdtemp(t.join(be.tmpdir(),`e2b-template-`)),l=t.join(c,`context.tar.gz`),u=()=>le.promises.rm(c,{recursive:!0,force:!0}).catch(()=>{});try{await o({gzip:a,cwd:n,follow:i,noDirRecurse:!0,file:l},s);let{size:e}=await le.promises.stat(l);return{path:l,size:e,cleanup:u}}catch(e){throw await u(),e}}function gA(e,t){return e===`base`?0:e===`finalize`?t-1:Number(e)}function _A(e,n){return typeof n==`string`?le.readFileSync(t.join(e,n),`utf-8`):JSON.stringify(n)}async function vA(e,{name:t,tags:n,cpuCount:r,memoryMB:i,minFreeDiskMb:a},o){let s=await e.api.POST(`/v3/templates`,{body:{name:t,tags:n,cpuCount:r,memoryMB:i,minFreeDiskMb:a},signal:o}),c=mD(s,XT);if(c)throw c;if(!s.data)throw new XT(`Failed to request build`);return s.data}async function yA(e,{templateID:t,filesHash:n},r,i){let a=await e.api.GET(`/templates/{templateID}/files/{hash}`,{params:{path:{templateID:t,hash:n}},signal:i}),o=mD(a,ZT,r);if(o)throw o;if(!a.data)throw new ZT(`Failed to get file upload link`,r);return a.data}async function bA(e,t,n){let{fileName:r,url:i,headers:a,fileContextPath:o,ignorePatterns:s,resolveSymlinks:c,gzip:l}=e,u;try{let e=await hA(r,o,s,c,l);u=e.cleanup;let d=zE(n?.requestTimeoutMs??36e5,n?.signal),f=await xA(i,e.path,e.size,d,a);if(!f.ok)throw new ZT(`Failed to upload file: ${f.statusText}`,t)}catch(e){throw e instanceof ZT?e:new ZT(`Failed to upload file: ${e}`,t)}finally{await u?.()}}async function xA(e,t,n,r,i){return await((await YE())?.fetch??fetch)(e,{method:`PUT`,body:ie.Readable.toWeb(le.createReadStream(t)),headers:I(I({},Object.fromEntries(Object.entries(i??{}).filter(([e])=>e.toLowerCase()!==`content-length`))),{},{"Content-Length":n.toString()}),duplex:`half`,signal:r})}async function SA(e,{templateID:t,buildID:n,template:r},i){let a=mD(await e.api.POST(`/v2/templates/{templateID}/builds/{buildID}`,{params:{path:{templateID:t,buildID:n}},body:r,signal:i}),XT);if(a)throw a}function CA(e){return new Pk(new Date(e.timestamp),e.level,e.message)}function wA(e){if(e)return{message:e.message,step:e.step,logEntries:(e.logEntries??[]).map(CA)}}async function TA(e,{templateID:t,buildID:n,logsOffset:r},i){let a=await e.api.GET(`/templates/{templateID}/builds/{buildID}/status`,{params:{path:{templateID:t,buildID:n},query:{logsOffset:r}},signal:i}),o=mD(a,XT);if(o)throw o;if(!a.data)throw new XT(`Failed to get build status`);return{buildID:a.data.buildID,templateID:a.data.templateID,status:a.data.status,logEntries:a.data.logEntries.map(CA),logs:a.data.logs,reason:wA(a.data.reason)}}async function EA(e,{alias:t},n){let r=await e.api.GET(`/templates/aliases/{alias}`,{params:{path:{alias:t}},signal:n});if(r.response.status===404)return!1;if(r.response.status===403)return!0;let i=mD(r,qT);if(i)throw i;return r.data!==void 0}async function DA(e,{templateID:t,buildID:n,onBuildLogs:r,logsRefreshFrequency:i,stackTraces:a,signal:o,requestTimeoutMs:s}){let c=0,l=`building`,u=async()=>{let i=await TA(e,{templateID:t,buildID:n,logsOffset:c},zE(s,o));return c+=i.logEntries.length,i.logEntries.forEach(e=>r?.(e)),i};for(;l===`building`||l===`waiting`;){o?.throwIfAborted();let e=await u();switch(l=e.status,l){case`ready`:case`error`:{var d;let t=e;for(;t.logEntries.length>0;)o?.throwIfAborted(),t=await u();if(l===`ready`)return;let n;throw e.reason?.step!==void 0&&(n=a[gA(e.reason.step,a.length)]),new XT((e==null||(d=e.reason)==null?void 0:d.message)??`Unknown error`,n)}}await new Promise(e=>setTimeout(e,i))}throw new XT(`Unknown build error occurred.`)}async function OA(e,{targetName:t,tags:n},r){let i=await e.api.POST(`/templates/tags`,{body:{target:t,tags:n},signal:r}),a=mD(i,qT);if(a)throw a;if(!i.data)throw new qT(`Failed to assign tags`);return{buildId:i.data.buildID,tags:i.data.tags}}async function kA(e,{name:t,tags:n},r){let i=mD(await e.api.DELETE(`/templates/tags`,{body:{name:t,tags:n},signal:r}),qT);if(i)throw i}async function AA(e,{templateID:t},n){let r=await e.api.GET(`/templates/{templateID}/tags`,{params:{path:{templateID:t}},signal:n}),i=mD(r,qT);if(i)throw i;if(!r.data)throw new qT(`Failed to get template tags`);return r.data.map(e=>({tag:e.tag,buildId:e.buildID,createdAt:new Date(e.createdAt)}))}var jA=class{constructor(e){P(this,`cmd`,void 0),this.cmd=e}getCmd(){return this.cmd}};function MA(e){return new jA(`[ -f ${fE(e)} ]`)}function NA(e){return new jA(`sleep ${Math.max(1,Math.floor(e/1e3))}`)}const PA={mount:{type:`string`,ignored:!0},network:{type:`string`,ignored:!0},security:{type:`string`,ignored:!0},device:{type:`string`,ignored:!0}},FA={chown:{type:`string`},chmod:{type:`string`},from:{type:`string`},link:{type:`bool`,ignored:!0},exclude:{type:`string`,ignored:!0},parents:{type:`bool`,ignored:!0}},IA=I(I({},FA),{},{"keep-git-dir":{type:`bool`,ignored:!0},checksum:{type:`string`,ignored:!0},unpack:{type:`bool`,ignored:!0}}),LA={platform:{type:`string`,ignored:!0}},RA=new Set([`EXPOSE`,`VOLUME`,`LABEL`,`MAINTAINER`]);function zA(e,t){let n=`E2B_HEREDOC_${e.replace(/[^A-Za-z0-9_]/g,`_`)}`;for(;t.includes(n);)n+=`_`;return n}function BA(e){return e===``||e.endsWith(`
|
|
218
|
+
`)?e:e+`
|
|
219
|
+
`}const VA=RegExp(`\\p{Nd}+|[@*#?\\-$!0]|[\\p{L}\\p{Nd}_]+`,`uy`);function HA(e,t){return e===`\\`||e==="`"||e===`$`||e===t?`\\`+e:e}function UA(e,t){let n=0;function r(e){throw new iT(`syntax error: missing ${e===`/`?"'/' in ${}":`'}'`}`,t)}function i(){VA.lastIndex=n;let t=VA.exec(e);return t?(n+=t[0].length,t[0]):``}function a(){if(e[n]!==`{`){let e=i();return e===``?`\\$`:`$`+e}if(n++,n>=e.length&&r(`}`),e[n]===`{`||e[n]===`}`||e[n]===`:`)throw new iT(`syntax error: bad substitution`,t);let a=i();n>=e.length&&r(`}`);let s=e[n++];if(s===`}`)return`\${${a}}`;if(s===`/`){e[n]===`/`&&(s+=e[n++]);let t=o(`/`,!0);return`\${${a}${s}${t}/${o(`}`,!0)}}`}s===`:`&&(n>=e.length&&r(`}`),s+=e[n++]);let c=s[s.length-1],l=c===`#`||c===`%`;if(!`+-?#%`.includes(c)||s.length===2&&l)throw new iT(`unsupported modifier (${s}) in substitution`,t);return`\${${a}${s}${o(`}`,l)}}`}function o(t,i=!1){let o=``;for(;n<e.length;){let r=e[n++];if(r===t)return o;if(r===`\\`){if(n<e.length){let r=e[n++];o+=i?`\\`+r:HA(r,t)}}else o+=r===`$`?a():r==="`"?"\\`":r}return t!==void 0&&r(t),o}return o()}function WA(e){return e.map(fE).join(` `)}var GA=class{constructor(e,t){this.templateBuilder=e,P(this,`lex`,void 0),P(this,`envLex`,void 0),P(this,`vars`,new Map),P(this,`userChanged`,!1),P(this,`workdirChanged`,!1),P(this,`cmd`,void 0),P(this,`entrypoint`,void 0),this.lex=new Zw(t),this.envLex=new Zw(t,{env:this.vars,skipUnsetEnv:!1})}convert(e){let t=e.filter(e=>e.name===`FROM`);if(t.length>1)throw new iT(`Multi-stage Dockerfiles are not supported`);if(t.length===0)throw new iT(`Dockerfile must contain a FROM instruction`);let n=t[0],r=this.handleFrom(n);this.templateBuilder.setUser(`root`),this.templateBuilder.setWorkdir(`/`);for(let t of e)if(t.name!==`FROM`){if(t.startLine<n.startLine&&t.name!==`ARG`)throw new iT(`${t.name} must be preceded by a FROM instruction`,t.startLine);this.handleInstruction(t)}return this.applyStartCmd(),this.userChanged||this.templateBuilder.setUser(`user`),this.workdirChanged||this.templateBuilder.setWorkdir(`/home/user`),{baseImage:r}}handleInstruction(e){switch(e.name){case`RUN`:this.handleRun(e);break;case`COPY`:this.handleCopy(e,FA);break;case`ADD`:this.handleCopy(e,IA);break;case`WORKDIR`:this.templateBuilder.setWorkdir(this.expandSingle(e)),this.workdirChanged=!0;break;case`USER`:this.templateBuilder.setUser(this.expandSingle(e)),this.userChanged=!0;break;case`ENV`:this.handleEnv(e);break;case`ARG`:this.handleArg(e);break;case`CMD`:this.parseFlags(e,{}),this.cmd={json:e.json,args:e.args};break;case`ENTRYPOINT`:this.parseFlags(e,{}),this.entrypoint={json:e.json,args:e.args};break;default:RA.has(e.name)||console.warn(`Unsupported instruction: ${e.name}`)}}expand(e,t,n=this.lex){try{return n.processWord(t)}catch(t){throw new iT(t instanceof Error?t.message:String(t),e.startLine)}}expandSingle(e){if(this.parseFlags(e,{}),e.args.length!==1)throw new iT(`${e.name} requires exactly one argument`,e.startLine);return this.expand(e,e.args[0])}parseFlags(e,t){let n={};for(let r of e.flags){if(!r.startsWith(`--`))throw new iT(`arg should start with -- : ${r}`,e.startLine);let i=r.slice(2),a=i.indexOf(`=`),o=a===-1?i:i.slice(0,a),s=a===-1?void 0:i.slice(a+1),c=Object.hasOwn(t,o)?t[o]:void 0;if(!c)throw new iT(`unknown flag: ${o}`,e.startLine);if(o in n)throw new iT(`duplicate flag specified: ${o}`,e.startLine);let l;if(c.type===`bool`){if(s===void 0||s===``||s===`true`)l=`true`;else if(s===`false`)l=`false`;else throw new iT(`expecting boolean value for flag ${o}, not: ${s}`,e.startLine)}else{if(s===void 0)throw new iT(`missing a value on flag: ${o}`,e.startLine);l=s}if(c.ignored){console.warn(`Ignoring unsupported ${e.name} flag --${o} (line ${e.startLine})`);continue}n[o]=l}return n}handleFrom(e){this.parseFlags(e,LA);let t=e.args;if((t.length!==3||t[1].toLowerCase()!==`as`)&&t.length!==1)throw new iT(`FROM requires either one or three arguments`,e.startLine);return this.expand(e,t[0])}handleRun(e){this.parseFlags(e,PA);let{args:t,json:n,heredocs:r}=e;if(t.length===0)throw new iT(`RUN requires at least one argument`,e.startLine);let i;i=n?WA(t):r.length>0?this.runWithHeredocs(t[0],r):t[0],this.templateBuilder.runCmd(i)}runWithHeredocs(e,t){let n=e=>e.chomp?DT(e.content):e.content;if(t.length===1&&ET(e.trim())){let e=t[0],r=n(e);if(!r.startsWith(`#!`))return r;let i=fE(`/tmp/${e.name}`),a=zA(e.name,r);return`cat <<'${a}' >${i}\n`+BA(r)+`${a}\nchmod +x ${i} && ${i}\nE2B_EXIT=$?; rm -f ${i}; exit $E2B_EXIT`}let r=e;for(let e of t)r+=`
|
|
220
|
+
`+e.content+e.name;return r}handleCopy(e,t){let n=this.parseFlags(e,t);if(e.args.length<2)throw new iT(`${e.name} requires at least two arguments`,e.startLine);if(n.from!==void 0)throw new iT(`${e.name} --from is not supported (multi-stage builds are not supported)`,e.startLine);let r=n.chown===void 0?void 0:this.expand(e,n.chown),i;if(n.chmod!==void 0){let t=this.expand(e,n.chmod),r=this.expand(e,n.chmod,this.envLex);if(!/^[0-7]{3,4}$/.test(r))throw new iT(`invalid chmod value "${t}"${r===t?``:` (resolves to "${r}")`}, expected an octal mode such as 0755`,e.startLine);i=parseInt(r,8)}let a=e.args[e.args.length-1];if(ET(a))throw new iT(`${e.name} cannot accept a heredoc as a destination`,e.startLine);let o=this.expand(e,a),s=new Map(e.heredocs.map(e=>[e.name,e]));for(let t of e.args.slice(0,-1)){let n=ET(t);if(n){let t=s.get(n.name);if(!t)throw new iT(`missing heredoc content for ${n.name}`,e.startLine);this.copyHeredoc(t,o,r,i,e.startLine);continue}let a=this.expand(e,t);if(e.name===`ADD`&&/^[a-z][a-z0-9+.-]*:\/\//i.test(a))throw new iT(`ADD from a remote URL is not supported: ${a}`,e.startLine);this.templateBuilder.copy(a,o,{user:r,mode:i})}}copyHeredoc(e,t,n,r,i){let a=e.chomp?DT(e.content):e.content;e.expand&&(a=UA(a,i));let o=zA(e.name,a),s=e.expand?o:`'${o}'`,c=`"$E2B_HEREDOC_DEST"`,l=t.endsWith(`/`)?`E2B_HEREDOC_DEST=${fE(t+e.name)}\n`:`E2B_HEREDOC_DEST=${fE(t)}\nif [ -d ${c} ]; then E2B_HEREDOC_DEST=${c}/${fE(e.name)}; fi\n`;l+=`mkdir -p "$(dirname ${c})" && cat <<${s} >${c}\n`+BA(a)+o,n!==void 0&&(l+=`\nchown ${fE(n)} ${c}`),r!==void 0&&(l+=`\nchmod ${r.toString(8)} ${c}`),this.templateBuilder.runCmd(l,{user:`root`})}handleEnv(e){this.parseFlags(e,{});let{args:t}=e;if(t.length===0)throw new iT(`ENV requires at least one argument`,e.startLine);let n={};for(let r=0;r+2<t.length;r+=3){let i=this.expand(e,t[r]);if(i===``)throw new iT(`ENV names can not be blank`,e.startLine);n[i]=this.expand(e,t[r+1]),this.vars.set(i,this.expand(e,t[r+1],this.envLex))}this.templateBuilder.setEnvs(n)}handleArg(e){this.parseFlags(e,{});let{args:t}=e;if(t.length===0)throw new iT(`ARG requires at least one argument`,e.startLine);let n={};for(let r of t){let t=r.indexOf(`=`),i=this.expand(e,t===-1?r:r.slice(0,t));if(i===``)throw new iT(`ARG names can not be blank`,e.startLine);let a=r.slice(t+1);n[i]=t===-1?``:this.expand(e,a),this.vars.set(i,t===-1?``:this.expand(e,a,this.envLex))}this.templateBuilder.setEnvs(n)}applyStartCmd(){let{cmd:e,entrypoint:t}=this,n;if(t){if(t.json){let r=[...t.args];e&&(e.json?r.push(...e.args):e.args.length>0&&r.push(`/bin/sh`,`-c`,e.args[0])),n=r.length>0?WA(r):void 0}else n=t.args.length>0?t.args[0]:void 0}else e&&(n=e.json?e.args.length>0?WA(e.args):void 0:e.args.length>0?e.args[0]:void 0);n!==void 0&&n.trim()!==``&&this.templateBuilder.setStartCmd(n,NA(2e4))}};function KA(e){try{if(le.existsSync(e)&&le.statSync(e).isFile())return le.readFileSync(e,`utf-8`)}catch{}return e}function qA(e,t){let n=wre(KA(e));for(let e of n.warnings)console.warn(`${e.message} (line ${e.line})`);return new GA(t,n.escapeToken).convert(n.instructions)}Nk(class extends GE{constructor(e){super(),P(this,`defaultBaseImage`,`e2bdev/base`),P(this,`baseImage`,this.defaultBaseImage),P(this,`baseTemplate`,void 0),P(this,`registryConfig`,void 0),P(this,`startCmd`,void 0),P(this,`readyCmd`,void 0),P(this,`force`,!1),P(this,`forceNextLayer`,!1),P(this,`instructions`,[]),P(this,`fileContextPath`,void 0),P(this,`fileIgnorePatterns`,[]),P(this,`logsRefreshFrequency`,200),P(this,`stackTraces`,[]),this.fileContextPath=e?.fileContextPath??(tE===`browser`?`.`:pA()??`.`),this.fileIgnorePatterns=e?.fileIgnorePatterns??this.fileIgnorePatterns}static toJSON(e,t=!0){return e.toJSON(t)}static toDockerfile(e){return e.toDockerfile()}static async build(e,t,n){var r=this;let{name:i,buildOptions:a}=tA(t,n),o=r.resolveOpts(a)??{};try{var s,c;(s=o.onBuildLogs)==null||s.call(o,new Fk(new Date,`Build started`));let t=e,n=new WE(o),r=new hD(n),a=await t.build(r,n,i,o);return(c=o.onBuildLogs)==null||c.call(o,new Pk(new Date,`info`,`Waiting for logs...`)),await DA(r,{templateID:a.templateId,buildID:a.buildId,onBuildLogs:o.onBuildLogs,logsRefreshFrequency:t.logsRefreshFrequency,stackTraces:t.stackTraces,signal:o.signal,requestTimeoutMs:n.requestTimeoutMs}),a}finally{var l;(l=o.onBuildLogs)==null||l.call(o,new Ik(new Date,`Build finished`))}}static async buildInBackground(e,t,n){var r=this;let{name:i,buildOptions:a}=tA(t,n),o=r.resolveOpts(a)??{},s=new WE(o),c=new hD(s);return e.build(c,s,i,o)}static async getBuildStatus(e,t){let n=new WE(this.resolveOpts(t));return await TA(new hD(n),{templateID:e.templateId,buildID:e.buildId,logsOffset:t?.logsOffset},n.getSignal(void 0,t?.signal))}static async exists(e,t){return this.aliasExists(e,t)}static async aliasExists(e,t){let n=new WE(this.resolveOpts(t));return EA(new hD(n),{alias:e},n.getSignal(void 0,t?.signal))}static async assignTags(e,t,n){let r=new WE(this.resolveOpts(n));return OA(new hD(r),{targetName:e,tags:Array.isArray(t)?t:[t]},r.getSignal(void 0,n?.signal))}static async removeTags(e,t,n){let r=new WE(this.resolveOpts(n));return kA(new hD(r),{name:e,tags:Array.isArray(t)?t:[t]},r.getSignal(void 0,n?.signal))}static async getTags(e,t){let n=new WE(this.resolveOpts(t));return AA(new hD(n),{templateID:e},n.getSignal(void 0,t?.signal))}fromDebianImage(e=`stable`){return this.fromImage(`debian:${e}`)}fromUbuntuImage(e=`latest`){return this.fromImage(`ubuntu:${e}`)}fromFedoraImage(e=`44`){return this.fromImage(`fedora:${e}`)}fromAlpineImage(e=`3.24`){return this.fromImage(`alpine:${e}`)}fromArchImage(e=`latest`){return this.fromImage(`archlinux:${e}`)}fromPythonImage(e=`3`){return this.fromImage(`python:${e}`)}fromNodeImage(e=`lts`){return this.fromImage(`node:${e}`)}fromBunImage(e=`latest`){return this.fromImage(`oven/bun:${e}`)}fromBaseImage(){return this.fromImage(this.defaultBaseImage)}fromImage(e,t){if(t&&(!t.username||!t.password))throw new F(`Both username and password are required when providing registry credentials`,fA());return this.baseImage=e,this.baseTemplate=void 0,t&&(this.registryConfig={type:`registry`,username:t.username,password:t.password}),this.forceNextLayer&&(this.force=!0),this.collectStackTrace(),this}fromTemplate(e){return this.baseTemplate=e,this.baseImage=void 0,this.forceNextLayer&&(this.force=!0),this.collectStackTrace(),this}fromDockerfile(e){let{baseImage:t}=qA(e,this);return this.baseImage=t,this.baseTemplate=void 0,this.forceNextLayer&&(this.force=!0),this.collectStackTrace(),this}fromAWSRegistry(e,t){return this.baseImage=e,this.baseTemplate=void 0,this.registryConfig={type:`aws`,awsAccessKeyId:t.accessKeyId,awsSecretAccessKey:t.secretAccessKey,awsRegion:t.region},this.forceNextLayer&&(this.force=!0),this.collectStackTrace(),this}fromGCPRegistry(e,t){return this.baseImage=e,this.baseTemplate=void 0,this.registryConfig={type:`gcp`,serviceAccountJson:_A(this.fileContextPath.toString(),t.serviceAccountJSON)},this.forceNextLayer&&(this.force=!0),this.collectStackTrace(),this}copy(e,t,n){if(tE===`browser`)throw Error(`Browser runtime is not supported for copy`);let r=Array.isArray(e)?e:[e],i=fA();for(let e of r){let r=e.toString();eA(r,i);let a=[r,t.toString(),n?.user??``,n?.mode===void 0?``:mA(n.mode)];this.instructions.push({type:`COPY`,args:a,force:n?.forceUpload||this.forceNextLayer,forceUpload:n?.forceUpload,resolveSymlinks:n?.resolveSymlinks,gzip:n?.gzip}),this.collectStackTrace()}return this}copyItems(e){if(tE===`browser`)throw Error(`Browser runtime is not supported for copyItems`);let t=fA();for(let n of e)try{this.copy(n.src,n.dest,{forceUpload:n.forceUpload,user:n.user,mode:n.mode,resolveSymlinks:n.resolveSymlinks,gzip:n.gzip})}catch(e){let n=e;throw n.stack=t,n}return this}remove(e,t){let n=Array.isArray(e)?e:[e],r=[`rm`];return t?.recursive&&r.push(`-r`),t?.force&&r.push(`-f`),r.push(...n.map(e=>fE(e.toString()))),this.runCmd(r.join(` `),{user:t?.user})}rename(e,t,n){let r=[`mv`,fE(e.toString()),fE(t.toString())];return n?.force&&r.push(`-f`),this.runCmd(r.join(` `),{user:n?.user})}makeDir(e,t){let n=Array.isArray(e)?e:[e],r=[`mkdir`,`-p`];return t?.mode!==void 0&&r.push(`-m ${mA(t.mode)}`),r.push(...n.map(e=>fE(e.toString()))),this.runCmd(r.join(` `),{user:t?.user})}makeSymlink(e,t,n){let r=[`ln`,`-s`];return n?.force&&r.push(`-f`),r.push(fE(e.toString()),fE(t.toString())),this.runCmd(r.join(` `),{user:n?.user})}runCmd(e,t){let n=[(Array.isArray(e)?e:[e]).join(` && `)];return t?.user&&n.push(t.user),this.instructions.push({type:`RUN`,args:n,force:this.forceNextLayer}),this.collectStackTrace(),this}setWorkdir(e){return this.instructions.push({type:`WORKDIR`,args:[e.toString()],force:this.forceNextLayer}),this.collectStackTrace(),this}setUser(e){return this.instructions.push({type:`USER`,args:[e],force:this.forceNextLayer}),this.collectStackTrace(),this}pipInstall(e,t){let n=t?.g??!0,r=[`pip`,`install`],i=e?Array.isArray(e)?e:[e]:void 0;return n===!1&&r.push(`--user`),i?r.push(...i):r.push(`.`),this.runCmd(r.join(` `),{user:n?`root`:void 0})}npmInstall(e,t){let n=[`npm`,`install`],r=e?Array.isArray(e)?e:[e]:void 0;return t?.g&&n.push(`-g`),t?.dev&&n.push(`--save-dev`),r&&n.push(...r),this.runCmd(n.join(` `),{user:t?.g?`root`:void 0})}bunInstall(e,t){let n=[`bun`,`install`],r=e?Array.isArray(e)?e:[e]:void 0;return t?.g&&n.push(`-g`),t?.dev&&n.push(`--dev`),r&&n.push(...r),this.runCmd(n.join(` `),{user:t?.g?`root`:void 0})}aptInstall(e,t){let n=Array.isArray(e)?e:[e];return this.runCmd([`apt-get update`,`DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes apt-get install -y ${t?.noInstallRecommends?`--no-install-recommends `:``}${t?.fixMissing?`--fix-missing `:``}${n.join(` `)}`],{user:`root`})}addMcpServer(e){if(this.baseTemplate!==`mcp-gateway`)throw new XT(`MCP servers can only be added to mcp-gateway template`,fA());let t=Array.isArray(e)?e:[e];return this.runCmd(`mcp-gateway pull ${t.join(` `)}`,{user:`root`})}gitClone(e,t,n){let r=[`git`,`clone`,fE(e)];return n?.branch&&(r.push(`--branch ${fE(n.branch)}`),r.push(`--single-branch`)),n?.depth&&r.push(`--depth ${n.depth}`),t&&r.push(fE(t.toString())),this.runCmd(r.join(` `),{user:n?.user})}setStartCmd(e,t){return this.startCmd=e,this.readyCmd=t instanceof jA?t.getCmd():t,this.collectStackTrace(),this}setReadyCmd(e){return this.readyCmd=e instanceof jA?e.getCmd():e,this.collectStackTrace(),this}setEnvs(e){return Object.keys(e).length===0?this:(this.instructions.push({type:`ENV`,args:Object.entries(e).flatMap(([e,t])=>[e,t]),force:this.forceNextLayer}),this.collectStackTrace(),this)}skipCache(){return this.forceNextLayer=!0,this}betaDevContainerPrebuild(e){if(this.baseTemplate!==`devcontainer`)throw new XT(`Devcontainers can only used in the devcontainer template`,fA());return this.runCmd(`devcontainer build --workspace-folder ${fE(e)}`,{user:`root`})}betaSetDevContainerStart(e){if(this.baseTemplate!==`devcontainer`)throw new XT(`Devcontainers can only used in the devcontainer template`,fA());let t=fE(e);return this.setStartCmd(`sudo devcontainer up --workspace-folder ${t} && sudo /prepare-exec.sh ${t} | sudo tee /devcontainer.sh > /dev/null && sudo chmod +x /devcontainer.sh && sudo touch /devcontainer.up`,MA(`/devcontainer.up`))}collectStackTrace(){return this.stackTraces.push(fA()),this}async toJSON(e){var t=this;let n=t.instructions;return e&&(n=await t.instructionsWithHashes()),JSON.stringify(t.serialize(n),void 0,2)}toDockerfile(){if(this.baseTemplate!==void 0)throw Error(`Cannot convert template built from another template to Dockerfile. Templates based on other templates can only be built using the E2B API.`);if(this.baseImage===void 0)throw Error(`No base image specified for template`);let e=`FROM ${this.baseImage}\n`;for(let t of this.instructions){if(t.type===`RUN`){e+=`RUN ${t.args[0]}\n`;continue}if(t.type===`COPY`){e+=`COPY ${t.args[0]} ${t.args[1]}\n`;continue}if(t.type===`ENV`){let n=[];for(let e=0;e<t.args.length;e+=2)n.push(`${t.args[e]}=${t.args[e+1]}`);e+=`ENV ${n.join(` `)}\n`;continue}e+=`${t.type} ${t.args.join(` `)}\n`}return this.startCmd&&(e+=`ENTRYPOINT ${this.startCmd}\n`),e}async build(e,t,n,r){var i=this,a,o,s,c;r.skipCache&&(i.force=!0),(a=r.onBuildLogs)==null||a.call(r,new Pk(new Date,`info`,`Requesting build for template: ${n}${r.tags&&r.tags.length>0?` with tags ${r.tags.join(`, `)}`:``}`));let{templateID:l,buildID:u,tags:d}=await vA(e,{name:n,tags:r.tags,cpuCount:r.cpuCount,memoryMB:r.memoryMB,minFreeDiskMb:r.minFreeDiskMb},t.getSignal(void 0,r.signal));(o=r.onBuildLogs)==null||o.call(r,new Pk(new Date,`info`,`Template created with ID: ${l}, Build ID: ${u}`));let f=await i.instructionsWithHashes(),p=f.map(async(n,a)=>{if(n.type!==`COPY`)return;let o=n.args.length>0?n.args[0]:null,s=n.filesHash??null;if(o===null||s===null)throw Error(`Source path and files hash are required`);let c=n.forceUpload,u;a+1>=0&&a+1<i.stackTraces.length&&(u=i.stackTraces[a+1]);let{present:d,url:f,headers:p}=await yA(e,{templateID:l,filesHash:s},u,t.getSignal(void 0,r.signal));if(c&&f!=null||d===!1&&f!=null){var m;await bA({fileName:o,fileContextPath:i.fileContextPath.toString(),url:f,headers:p,ignorePatterns:[...nA(i.fileContextPath.toString()),...i.fileIgnorePatterns],resolveSymlinks:n.resolveSymlinks??!1,gzip:n.gzip??!0},u,{signal:r.signal,requestTimeoutMs:r.requestTimeoutMs}),(m=r.onBuildLogs)==null||m.call(r,new Pk(new Date,`info`,`Uploaded '${o}'`))}else{var h;(h=r.onBuildLogs)==null||h.call(r,new Pk(new Date,`info`,`Skipping upload of '${o}', already cached`))}});return await Promise.all(p),(s=r.onBuildLogs)==null||s.call(r,new Pk(new Date,`info`,`All file uploads completed`)),(c=r.onBuildLogs)==null||c.call(r,new Pk(new Date,`info`,`Starting building...`)),await SA(e,{templateID:l,buildID:u,template:i.serialize(f)},t.getSignal(void 0,r.signal)),{alias:n,name:n,tags:d,templateId:l,buildId:u}}async instructionsWithHashes(){var e=this;return Promise.all(e.instructions.map(async(t,n)=>{if(t.type!==`COPY`)return t;let r=t.args.length>0?t.args[0]:null,i=t.args.length>1?t.args[1]:null;if(r===null||i===null)throw Error(`Source path and destination path are required`);let a;return n+1>=0&&n+1<e.stackTraces.length&&(a=e.stackTraces[n+1]),I(I({},t),{},{filesHash:await cA(r,i,e.fileContextPath.toString(),[...tE===`browser`?[]:nA(e.fileContextPath.toString()),...e.fileIgnorePatterns],t.resolveSymlinks??!1,a)})}))}serialize(e){let t={startCmd:this.startCmd,readyCmd:this.readyCmd,steps:e,force:this.force};return this.baseImage!==void 0&&(t.fromImage=this.baseImage),this.baseTemplate!==void 0&&(t.fromTemplate=this.baseTemplate),this.registryConfig!==void 0&&(t.fromImageRegistry=this.registryConfig),t}});const JA=3e4,YA=1e3,XA=e=>`'${e.replaceAll(`'`,`'\\''`)}'`,ZA=(e,t)=>(e??[]).flatMap(e=>t?.[e]===void 0?[`-u`,e]:[]),QA=e=>typeof e==`string`?e:``,$A=e=>e instanceof Error?`${e.name}: ${e.message}`:String(e),ej=e=>cl({try:async()=>{let t=await Mk.getInfo(e,{requestTimeoutMs:JA});if(t.state!==`running`)throw Error(`sandbox ${e} is ${t.state}, not running`);if(t.endAt.getTime()-Date.now()<=YA)throw Error(`sandbox ${e} has reached its end`);return Mk.connect(e,{timeoutMs:YA,requestTimeoutMs:JA})},catch:e=>new Fm({operation:`connect`,detail:$A(e)})}),tj=e=>xl(ej(e),t=>Im.of({name:`e2b:${e}`,run:(e,n)=>cl({try:async r=>{let i=Math.max(.001,n.timeoutMs/1e3).toFixed(3),a=[`exec`,`env`,...ZA(n.unsetEnv,n.env),`LC_ALL=C`,`timeout`,`--verbose`,`-k`,`1s`,`${i}s`,...e].map((e,t)=>t<2?e:XA(e)).join(` `);try{let e=await t.commands.run(a,{timeoutMs:n.timeoutMs+5e3,requestTimeoutMs:JA,signal:r,...n.env===void 0?{}:{envs:{...n.env}},...n.cwd===void 0?{}:{cwd:n.cwd}});return{exitCode:e.exitCode,stdout:e.stdout,stderr:e.stderr,timedOut:!1}}catch(e){if(!(e instanceof vO))throw e;let t=QA(e.stderr),n=(e.exitCode===124||e.exitCode===137)&&t.includes(`timeout: sending signal`);return{exitCode:e.exitCode,stdout:QA(e.stdout),stderr:t,timedOut:n}}},catch:t=>new Fm({operation:`run`,detail:`${e[0]??``}: ${$A(t)}`})}),start:(e,n)=>cl({try:async()=>{let r=[`set -C;`,`exec`,`env`,...ZA(n.unsetEnv,n.env).map(XA),...e.map(XA),`>${XA(n.logPath)}`,`2>&1`,`</dev/null`].join(` `),i=await t.commands.run(r,{background:!0,timeoutMs:0,retainOutput:!1,requestTimeoutMs:JA,...n.env===void 0?{}:{envs:{...n.env}},...n.cwd===void 0?{}:{cwd:n.cwd}}),a=i.pid;return await i.disconnect(),a},catch:t=>new Fm({operation:`start`,detail:`${e[0]??``}: ${$A(t)}`})}),readFile:(e,n)=>cl({try:async()=>t.files.read(e,{format:`bytes`,requestTimeoutMs:n}),catch:t=>new Fm({operation:`readFile`,detail:`${e}: ${$A(t)}`})}),watchExit:(e,n)=>Pl(cl({try:async()=>{try{return await t.commands.connect(e,{timeoutMs:0,retainOutput:!1,requestTimeoutMs:JA})}catch(e){if(e instanceof zT)return;throw e}},catch:t=>new Fm({operation:`watchExit`,detail:`${e}: ${$A(t)}`})}),e=>e===void 0?fl:sl(()=>e.disconnect())).pipe(xl(t=>t===void 0?ll(void 0):cl({try:async()=>{try{return(await t.wait()).exitCode}catch(e){if(e instanceof vO)return e.exitCode;throw e}},catch:t=>new Fm({operation:`watchExit`,detail:`${e}: ${$A(t)}`})}).pipe(kl({duration:Math.max(1,n),orElse:()=>ll(void 0)}))))})),nj=e=>Mc(Im,tj(e)),rj=(e,t,n)=>{let r={};for(let[n,i]of Object.entries(e))i!==void 0&&!(t??[]).includes(n)&&(r[n]=i);return{...r,...n}},ij=e=>e?128+xe.signals[e]:1,aj=Ac(Im,Im.of({name:`local`,run:(e,t)=>pl((n,r)=>{let[i,...a]=e;if(i===void 0){n(k(new Fm({operation:`run`,detail:`empty argv`})));return}eee(i,a,{env:rj(process.env,t.unsetEnv,t.env),...t.cwd===void 0?{}:{cwd:t.cwd},timeout:Math.max(1,Math.ceil(t.timeoutMs)),killSignal:`SIGKILL`,maxBuffer:67108864,encoding:`utf8`,signal:r},(e,t,r)=>{if(e===null){n(ll({exitCode:0,stdout:t,stderr:r,timedOut:!1}));return}if(typeof e.code==`string`){n(k(new Fm({operation:`run`,detail:`${i}: ${e.code}`})));return}let a=e.killed===!0,o=typeof e.code==`number`?e.code:ij(e.signal);n(ll({exitCode:o,stdout:t,stderr:r,timedOut:a}))})}),start:(e,t)=>pl(n=>{let[r,...i]=e;if(r===void 0){n(k(new Fm({operation:`start`,detail:`empty argv`,notStarted:!0})));return}let a;try{a=me(t.logPath,`wx`,384)}catch(e){n(k(new Fm({operation:`start`,detail:`log ${String(e)}`,notStarted:!0})));return}let o=Oe(r,i,{detached:!0,stdio:[`ignore`,a,a],env:rj(process.env,t.unsetEnv,t.env),...t.cwd===void 0?{}:{cwd:t.cwd}});de(a),o.once(`error`,e=>{n(k(new Fm({operation:`start`,detail:`${r}: ${e.message}`,notStarted:!0})))}),o.once(`spawn`,()=>{o.unref();let e=o.pid;n(e===void 0?k(new Fm({operation:`start`,detail:`${r}: no pid`})):ll(e))})}),readFile:e=>cl({try:async()=>new Uint8Array(await h(e)),catch:t=>new Fm({operation:`readFile`,detail:`${e}: ${String(t)}`})}),watchExit:()=>ll(ll(void 0))})),oj=[`xvfb`,`xfce4`,`dbus-x11`,`x11-utils`,`xdg-utils`,`xdotool`,`wmctrl`,`scrot`,`fonts-inter`,`fonts-dejavu`,`fonts-liberation`,`libnss3`,`libgbm1`,`libnotify4`,`libsecret-1-0`,`libxss1`,`libxtst6`,`libxkbcommon0`,`libdrm2`],sj={"22.04":[...oj,`libgtk-3-0`,`libasound2`],"24.04":[...oj,`libgtk-3-0t64`,`libasound2t64`]},cj=String.raw`
|
|
221
|
+
receipt=$1; shift
|
|
222
|
+
if [ -e "$receipt" ] || [ -L "$receipt" ]; then
|
|
223
|
+
printf 'fresh-only install refuses an existing receipt directory\n' >&2; exit 64
|
|
224
|
+
fi
|
|
225
|
+
if [ "$(uname -s)" != Linux ] || [ ! -r /etc/os-release ]; then
|
|
226
|
+
printf 'prerequisite package lists target Ubuntu Linux\n' >&2; exit 65
|
|
227
|
+
fi
|
|
228
|
+
. /etc/os-release
|
|
229
|
+
release=$1; shift
|
|
230
|
+
if [ "$ID" != ubuntu ] || [ "$VERSION_ID" != "$release" ]; then
|
|
231
|
+
printf 'this guest is %s %s, not Ubuntu %s\n' "$ID" "$VERSION_ID" "$release" >&2; exit 66
|
|
232
|
+
fi
|
|
233
|
+
set -eu
|
|
234
|
+
umask 077
|
|
235
|
+
mkdir "$receipt"
|
|
236
|
+
log=$receipt/install.log
|
|
237
|
+
step() { printf '== %s %s\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" "$1" >> "$log"; }
|
|
238
|
+
step 'apt-get update'
|
|
239
|
+
sudo -n env DEBIAN_FRONTEND=noninteractive apt-get update -q >> "$log" 2>&1
|
|
240
|
+
step 'apt-get install'
|
|
241
|
+
sudo -n env DEBIAN_FRONTEND=noninteractive apt-get -o DPkg::Lock::Timeout=300 install -y -q "$@" >> "$log" 2>&1
|
|
242
|
+
step 'dpkg-query'
|
|
243
|
+
dpkg-query -W -f='$'"{Package}\t"'$'"{Version}\n" "$@" > "$receipt/packages.tsv.tmp" 2>> "$log"
|
|
244
|
+
mv "$receipt/packages.tsv.tmp" "$receipt/packages.tsv"
|
|
245
|
+
printf 'desktop_prereqs=installed\nos=ubuntu\nversion=%s\n' "$VERSION_ID" > "$receipt/installed.tmp"
|
|
246
|
+
mv "$receipt/installed.tmp" "$receipt/installed"
|
|
247
|
+
step done
|
|
248
|
+
printf 'log %s %s\n' "$(wc -c < "$log" | tr -d ' ')" "$(sha256sum "$log" | cut -d ' ' -f 1)"
|
|
249
|
+
cat "$receipt/packages.tsv"
|
|
250
|
+
`,lj=String.raw`
|
|
251
|
+
log=$1
|
|
252
|
+
if [ -f "$log" ]; then
|
|
253
|
+
printf 'log %s %s\n' "$(wc -c < "$log" | tr -d ' ')" "$(sha256sum "$log" | cut -d ' ' -f 1)"
|
|
254
|
+
tail -n 3 "$log"
|
|
255
|
+
else
|
|
256
|
+
printf 'absent\n'
|
|
257
|
+
fi
|
|
258
|
+
`,uj=new Set([64,65,66]),dj=(e,t)=>{let n=/^log (\d+) ([0-9a-f]{64})$/u.exec(t??``);return n?.[1]===void 0||n[2]===void 0?void 0:{path:e,bytes:Number(n[1]),sha256:n[2]}},fj=e=>e.split(`
|
|
259
|
+
`).filter(e=>e.trim().length>0).slice(-3).join(` | `),pj=(e,t)=>O(function*(){if(!a(e))return yield*j(`receipt directory must be absolute`);let n=yield*Im,r=o(e,`install.log`),[i]=yield*Zm([e],1e4).pipe(Tl(e=>new ah({reason:`path check failed: ${e.message}`})));if(i===!0)return yield*j(`fresh-only install refuses an existing receipt directory`);let s=(yield*n.run([`sh`,`-c`,`sed -n 's/^VERSION_ID="\\{0,1\\}\\([^"]*\\)"\\{0,1\\}$/\\1/p' /etc/os-release`],{timeoutMs:1e4}).pipe(Tl(e=>new ah({reason:`os-release read failed: ${e.message}`})))).stdout.trim(),c=sj[s];if(c===void 0)return yield*j(`prerequisite package lists cover Ubuntu 22.04 and 24.04; this guest reports ${JSON.stringify(s)}`);let l=yield*n.run(Wm(cj,[e,s,...c]),{timeoutMs:t*1e3}).pipe(Tl(e=>new ah({reason:`install could not run: ${e.message}`})));if(l.timedOut||l.exitCode!==0){let e=l.timedOut||!uj.has(l.exitCode)?yield*yl(n.run(Wm(lj,[r]),{timeoutMs:1e4})):void 0,[i,...a]=e?._tag===`Success`?e.success.stdout.split(`
|
|
260
|
+
`):[],o=dj(r,i),s=o===void 0?fj(l.stderr)||`no output; see ${r}`:fj(a.join(`
|
|
261
|
+
`));return yield*k(new ah({reason:l.timedOut?`install did not finish within ${t}s`:`install failed: ${s}`,...l.timedOut?{}:{nativeExit:l.exitCode},...o===void 0?{}:{log:o}}))}let u=l.stdout.split(`
|
|
262
|
+
`),d=dj(r,u.find(e=>e.startsWith(`log `)));return d===void 0?yield*hl(Error(`install reported no log facts`)):{status:`installed`,receipt_dir:e,ubuntu:s,packages:u.map(e=>e.split(` `)).filter(e=>e.length===2).map(([e,t])=>({name:e,version:t})),log:d}}),mj=`usage: impulse-compute linux-desktop <command> [flags]
|
|
263
|
+
|
|
264
|
+
Own or adopt an X11 desktop session in a Linux guest, launch and close apps in it,
|
|
265
|
+
capture raw screens and exact window crops, and verify exact crops. The guest is
|
|
266
|
+
an E2B sandbox (--sandbox <id>, with E2B_API_KEY set) or this machine. Paths named
|
|
267
|
+
--guest-dir, --tool-dir, --home and --receipt-dir are on the guest; --state-dir,
|
|
268
|
+
--output and --window-output are on this machine.
|
|
269
|
+
|
|
270
|
+
Each command prints one JSON object: on stdout when it completes, on stderr when it
|
|
271
|
+
refuses. crop verify prints its report on stdout whatever its verdict. Read the
|
|
272
|
+
JSON's "status" together with the exit code:
|
|
273
|
+
0 done
|
|
274
|
+
1 refused; or crop verify's "mismatch"; or a session stop that could not
|
|
275
|
+
confirm that everything it set out to end has ended (status "stopping",
|
|
276
|
+
on stdout: run the stop again)
|
|
277
|
+
1-255 a refusal caused by a guest tool's failure exits with that tool's exit
|
|
278
|
+
code, which "native_exit" also gives
|
|
279
|
+
2 a usage error, or crop verify's "uncheckable"
|
|
280
|
+
70 a defect in this helper
|
|
281
|
+
"guest_retirement_required": true means retire the guest: something this helper
|
|
282
|
+
started there may still be running and cannot be ended safely.
|
|
283
|
+
|
|
284
|
+
session start --state-dir DIR --guest-dir DIR --tool-dir DIR --display :N
|
|
285
|
+
--geometry WxHxD --ready-timeout S --probe-timeout S
|
|
286
|
+
--shutdown-timeout S [--x11-dir DIR] [--sandbox ID] [--keyring]
|
|
287
|
+
Start a fresh Xvfb display and an XFCE session under its own
|
|
288
|
+
D-Bus session bus, and wait until both are ready.
|
|
289
|
+
session adopt --state-dir DIR --guest-dir DIR --tool-dir DIR --display :N
|
|
290
|
+
--geometry WxH --probe-timeout S [--x11-dir DIR] [--sandbox ID]
|
|
291
|
+
[--keyring]
|
|
292
|
+
Adopt a display that is already running, such as E2B Desktop's :0.
|
|
293
|
+
session inspect --state-dir DIR --timeout S
|
|
294
|
+
session stop --state-dir DIR --timeout S
|
|
295
|
+
End the apps it launched, then a keyring session's daemon, bus and
|
|
296
|
+
holder, then (owned session) its Xvfb and XFCE launches.
|
|
297
|
+
capture --state-dir DIR --output FILE.png --timeout S
|
|
298
|
+
[--window 0xID --window-output FILE.png]
|
|
299
|
+
Capture the raw screen and, with --window, an exact crop of that window's
|
|
300
|
+
visible frame, with the window manager's title bar and borders. A window
|
|
301
|
+
another managed window covers is refused; menus, tooltips and other
|
|
302
|
+
override-redirect windows are not checked.
|
|
303
|
+
app launch --state-dir DIR --name NAME --home DIR --timeout S -- COMMAND [ARGS...]
|
|
304
|
+
app relaunch --state-dir DIR --name NAME --timeout S
|
|
305
|
+
Start an app that has ended again, with the command and home of
|
|
306
|
+
its first launch.
|
|
307
|
+
app windows --state-dir DIR --name NAME --timeout S
|
|
308
|
+
app close --state-dir DIR --name NAME --timeout S
|
|
309
|
+
crop verify --raw RAW.png --crop CROP.png --box L T R B
|
|
310
|
+
[--content-box L T R B --min-margins T R B L]
|
|
311
|
+
prereqs install --receipt-dir DIR --timeout S [--sandbox ID]
|
|
312
|
+
Install Ubuntu 22.04's or 24.04's Xvfb, XFCE, capture, font and
|
|
313
|
+
Electron runtime packages with sudo -n apt-get, recording them in
|
|
314
|
+
DIR, which must not exist yet and whose parent must, and apt-get's
|
|
315
|
+
output and every step's errors in DIR/install.log.
|
|
316
|
+
|
|
317
|
+
--x11-dir is where the X server keeps its .X<n>-lock and .X11-unix socket: /tmp on Linux.
|
|
318
|
+
|
|
319
|
+
--keyring also starts a test keyring for the apps the session launches: a private
|
|
320
|
+
D-Bus session bus whose Secret Service daemon (gnome-keyring-daemon, run with
|
|
321
|
+
dbus-daemon and dbus-send from --tool-dir) holds an unlocked login collection,
|
|
322
|
+
under a password generated in the guest. It lasts until session stop, and the
|
|
323
|
+
session reports guest_retirement_required: true. Any process of the guest's user
|
|
324
|
+
can read that collection, so store only made-up secrets in it.
|
|
325
|
+
`;var hj=class extends Error{reason;constructor(e){super(e),this.reason=e}};const gj=e=>`${JSON.stringify(e)}\n`,_j=(e,t)=>{let n=e[t]?.[0]??``;if(!a(n))throw new hj(`${t}: must be an absolute path`);return s(n)},vj=(e,t,n)=>e[t]===void 0?n:_j(e,t),yj=(e,t)=>{let n=e[t]?.[0]??``,r=/^\s*[+]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?\s*$/u.test(n)?Number(n):NaN;if(!Number.isFinite(r)||r<=0)throw new hj(`${t}: must be finite and greater than zero`);return r},bj=e=>{let t=e[`--display`]?.[0]??``;if(!/^:\d+$/u.test(t))throw new hj(`--display: must be a local display such as :99`);return`:${Number(t.slice(1))}`},xj=(e,t)=>{let n=e[`--geometry`]?.[0]??``;if(!(t?/^[1-9]\d*x[1-9]\d*x[1-9]\d*$/u:/^[1-9]\d*x[1-9]\d*$/u).test(n))throw new hj(`--geometry: must be positive ${t?`WIDTHxHEIGHTxDEPTH`:`WIDTHxHEIGHT`}`);return n},Sj=(e,t,n=!1)=>{let r=e_(e,t,{allowRest:n});if(!r.ok)throw new hj(r.reason);return r},Cj=(e=1)=>({arity:e,required:!0}),wj=(e=1)=>({arity:e}),Tj=e=>e===void 0?aj:nj(e),Ej=e=>xl(Ch(e),e=>e.guest===`local`?aj:nj(e.guest.slice(4))),Dj=(e,t)=>vl(e,e=>t.pipe(jl(e),Cl(`GuestError`,e=>k(new ah({reason:e.message}))))),Oj=(e,t=0)=>({stdout:gj(e),exitCode:t}),kj=e=>{let t=e[`--sandbox`]?.[0];if(t!==void 0&&!/^[a-z0-9]+$/u.test(t))throw new hj(`--sandbox: must be an E2B sandbox id`);return t},Aj={"session start":e=>{let{values:t}=Sj(e,{"--state-dir":Cj(),"--guest-dir":Cj(),"--tool-dir":Cj(),"--display":Cj(),"--geometry":Cj(),"--ready-timeout":Cj(),"--probe-timeout":Cj(),"--shutdown-timeout":Cj(),"--x11-dir":wj(),"--sandbox":wj(),"--keyring":wj(0)}),n={stateDir:_j(t,`--state-dir`),guestDir:_j(t,`--guest-dir`),toolDir:_j(t,`--tool-dir`),x11Dir:vj(t,`--x11-dir`,`/tmp`),display:bj(t),geometry:xj(t,!0),readyTimeout:yj(t,`--ready-timeout`),probeTimeout:yj(t,`--probe-timeout`),shutdownTimeout:yj(t,`--shutdown-timeout`),keyring:t[`--keyring`]!==void 0};return xl(Dj(ll(Tj(kj(t))),Tg(n)),e=>Oj(e))},"session adopt":e=>{let{values:t}=Sj(e,{"--state-dir":Cj(),"--guest-dir":Cj(),"--tool-dir":Cj(),"--display":Cj(),"--geometry":Cj(),"--probe-timeout":Cj(),"--x11-dir":wj(),"--sandbox":wj(),"--keyring":wj(0)}),n={stateDir:_j(t,`--state-dir`),guestDir:_j(t,`--guest-dir`),toolDir:_j(t,`--tool-dir`),x11Dir:vj(t,`--x11-dir`,`/tmp`),display:bj(t),geometry:xj(t,!1),probeTimeout:yj(t,`--probe-timeout`),keyring:t[`--keyring`]!==void 0};return xl(Dj(ll(Tj(kj(t))),Dg(n)),e=>Oj(e))},"session inspect":e=>{let{values:t}=Sj(e,{"--state-dir":Cj(),"--timeout":Cj()}),n=_j(t,`--state-dir`),r=yj(t,`--timeout`);return xl(Dj(Ej(n),Og(n,r)),e=>Oj({status:`ready`,run_id:e.session.run_id,guest:e.session.guest,observed:e.observation,connection:e.session.connection,...e.session.keyring?.phase===`ready`?{keyring:Xh(e.session.keyring)}:{}}))},"session stop":e=>{let{values:t}=Sj(e,{"--state-dir":Cj(),"--timeout":Cj()}),n=_j(t,`--state-dir`),r=yj(t,`--timeout`);return xl(Dj(Ej(n),kg(n,r)),e=>Oj(e,`failed`in e&&e.failed?1:0))},capture:e=>{let{values:t}=Sj(e,{"--state-dir":Cj(),"--output":Cj(),"--timeout":Cj(),"--window":wj(),"--window-output":wj()}),n=_j(t,`--state-dir`),r=_j(t,`--output`),i=yj(t,`--timeout`),a=t[`--window`]?.[0],o=t[`--window-output`]===void 0?void 0:_j(t,`--window-output`);if(a===void 0!=(o===void 0))throw new hj(`--window and --window-output go together`);return xl(Dj(Ej(n),nv({stateDir:n,output:r,timeout:i,...a!==void 0&&o!==void 0?{window:{id:a,output:o}}:{}})),e=>Oj(e))},"app launch":e=>{let{values:t,rest:n}=Sj(e,{"--state-dir":Cj(),"--name":Cj(),"--home":Cj(),"--timeout":Cj()},!0),r=_j(t,`--state-dir`),i={stateDir:r,name:t[`--name`]?.[0]??``,home:_j(t,`--home`),timeout:yj(t,`--timeout`),argv:n};if(n.length===0)throw new hj(`app launch needs a command after --`);return xl(Dj(Ej(r),Jg(i)),e=>Oj(e))},"app relaunch":e=>{let{values:t}=Sj(e,{"--state-dir":Cj(),"--name":Cj(),"--timeout":Cj()}),n=_j(t,`--state-dir`);return xl(Dj(Ej(n),Xg({stateDir:n,name:t[`--name`]?.[0]??``,timeout:yj(t,`--timeout`)})),e=>Oj(e))},"app windows":e=>{let{values:t}=Sj(e,{"--state-dir":Cj(),"--name":Cj(),"--timeout":Cj()}),n=_j(t,`--state-dir`);return xl(Dj(Ej(n),Qg(n,t[`--name`]?.[0]??``,yj(t,`--timeout`))),e=>Oj(e))},"app close":e=>{let{values:t}=Sj(e,{"--state-dir":Cj(),"--name":Cj(),"--timeout":Cj()}),n=_j(t,`--state-dir`);return xl(Dj(Ej(n),$g(n,t[`--name`]?.[0]??``,yj(t,`--timeout`))),e=>Oj(e))},"prereqs install":e=>{let{values:t}=Sj(e,{"--receipt-dir":Cj(),"--timeout":Cj(),"--sandbox":wj()}),n=_j(t,`--receipt-dir`),r=yj(t,`--timeout`);return xl(Dj(ll(Tj(kj(t))),pj(n,r)),e=>Oj(e))}},jj=(e,t)=>{let n=t.nativeExit;return{stderr:gj({status:`unavailable`,reason:t.reason,native_exit:n??null,guest_retirement_required:e===`session start`||t.retire===!0,...t.log===void 0?{}:{log:t.log}}),exitCode:n!==void 0&&n>0&&n<256?n:1}},Mj=e=>{if(e.length===0)return ll({stderr:mj,exitCode:2});if(e[0]===`--help`||e[0]===`-h`||e[0]===`help`)return ll({stdout:mj,exitCode:0});if(e[0]===`crop`&&e[1]===`verify`)return xl(X_(e.slice(2)),e=>({stdout:`${Z_(e.report)}\n`,exitCode:e.exitCode}));let t=e.length>=2&&Aj[`${e[0]} ${e[1]}`]!==void 0?`${e[0]} ${e[1]}`:e[0]??``,n=Aj[t];if(n===void 0)return ll({stderr:gj({status:`usage`,reason:`unknown command ${JSON.stringify(t)}`}),exitCode:2});let r=e.slice(t.split(` `).length);return ul(()=>{try{return n(r)}catch(e){if(e instanceof hj)return ll({stderr:gj({status:`usage`,reason:e.reason}),exitCode:2});throw e}}).pipe(Cl(`Unavailable`,e=>ll(jj(t,e))),wl(e=>ll({stderr:gj({status:`error`,reason:ute(e)}),exitCode:70})))},Nj=e=>Kl(vl(Mj(e),e=>dl(()=>{e.stdout!==void 0&&process.stdout.write(e.stdout),e.stderr!==void 0&&process.stderr.write(e.stderr),process.exitCode=e.exitCode}))),Pj={done:0,failure:1,usage:2,blocked:3,notInstalled:77},Fj=(e,t)=>{switch(t.length){case 0:return e;case 1:return t[0](e);case 2:return t[1](t[0](e));case 3:return t[2](t[1](t[0](e)));case 4:return t[3](t[2](t[1](t[0](e))));case 5:return t[4](t[3](t[2](t[1](t[0](e)))));case 6:return t[5](t[4](t[3](t[2](t[1](t[0](e))))));case 7:return t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))));case 8:return t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e))))))));case 9:return t[8](t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))))));default:{let n=e;for(let e=0,r=t.length;e<r;e++)n=t[e](n);return n}}},Ij={pipe(){return Fj(this,arguments)}},Lj=function(){function e(){}return e.prototype=Ij,e}(),L=function(e,t){if(typeof e==`function`)return function(){return e(arguments)?t.apply(this,arguments):e=>t(e,...arguments)};switch(e){case 0:case 1:throw RangeError(`Invalid arity ${e}`);case 2:return function(e,n){return arguments.length>=2?t(e,n):function(n){return t(n,e)}};case 3:return function(e,n,r){return arguments.length>=3?t(e,n,r):function(r){return t(r,e,n)}};default:return function(){if(arguments.length>=e)return t.apply(this,arguments);let n=arguments;return function(e){return t(e,...n)}}}},R=e=>e,Rj=e=>()=>e,zj=Rj(!0),Bj=Rj(!1),Vj=Rj(void 0),Hj=Vj;function Uj(e,...t){return Fj(e,t)}function Wj(e){let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let i=e(n);return t.set(n,i),i}}function Gj(e){let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let i=e(n);return t.set(n,i),i!==n&&t.set(i,i),i}}const Kj=e=>{let t=new Set(Reflect.ownKeys(e));if(e.constructor===Object)return t;e instanceof Error&&t.delete(`stack`);let n=Object.getPrototypeOf(e),r=n;for(;r!==null&&r!==Object.prototype;){let e=Reflect.ownKeys(r);for(let n=0;n<e.length;n++)t.add(e[n]);r=Object.getPrototypeOf(r)}return t.has(`constructor`)&&typeof e.constructor==`function`&&n===e.constructor.prototype&&t.delete(`constructor`),t},qj=new WeakSet,Jj=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),Yj=e=>e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer,Xj=e=>{try{return new Uint8Array(e)}catch{return}};let Zj=0;const Qj=()=>{Zj++};function $j(e){return typeof e==`string`}function eM(e){return typeof e==`number`}function tM(e){return typeof e==`boolean`}function nM(e){return typeof e==`symbol`}function rM(e){return $j(e)||eM(e)||nM(e)}function iM(e){return typeof e==`function`}function aM(e){return e===void 0}function oM(e){return e!==void 0}function sM(e){return e!==null}function cM(e){return e==null}function lM(e){return e!=null}function uM(e){return!0}function dM(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function fM(e){return typeof e==`object`&&!!e||iM(e)}const z=L(2,(e,t)=>fM(e)&&t in e),pM=L(2,(e,t)=>z(e,`_tag`)&&e._tag===t);function mM(e){return e instanceof Error}function hM(e){return z(e,Symbol.iterator)||$j(e)}const gM=`~effect/Hash`,_M=e=>{switch(typeof e){case`number`:return CM(e);case`bigint`:return wM(e.toString(10));case`string`:return wM(e);case`function`:case`object`:if(e===null)break;if(e instanceof Date)return Number.isNaN(e.getTime())?wM(`Invalid Date`):wM(e.toISOString());if(e instanceof RegExp)return wM(e.toString());{if(qj.has(e))return vM(e);let t=NM.get(e);if(t!==void 0)return t;if(PM.has(e))return Qj(),wM(`[Circular]`);PM.add(e);let n=Zj,r;try{if(`~effect/Hash`in e)r=e[gM]();else if(typeof e==`function`)r=vM(e);else if(Yj(e)){let t=Xj(e);r=t===void 0?vM(e):OM(t)}else r=e instanceof DataView?OM(Jj(e)):Array.isArray(e)||ArrayBuffer.isView(e)?OM(e):e instanceof Map?kM(e):e instanceof Set?jM(e):EM(e)}finally{PM.delete(e)}return n===Zj&&NM.set(e,r),r}}return xM(yM(wM(String(e))))},vM=e=>(MM.has(e)||MM.set(e,xM(Math.random()*4294967296|0)),MM.get(e)),yM=e=>(e^=e>>>16,e=Math.imul(e,2246822507),e^=e>>>13,e=Math.imul(e,3266489909),e^e>>>16),bM=L(2,(e,t)=>yM(Math.imul(e,2654435761)+Math.imul(t,2246822507))),xM=e=>e&3221225471|e>>>1&1073741824,SM=new DataView(new ArrayBuffer(8)),CM=e=>{let t=e|0;return t===e?xM(t):(SM.setFloat64(0,e===e?e:NaN),xM(bM(SM.getInt32(0),SM.getInt32(4))))},wM=e=>{let t=5381,n=e.length;for(;n;)t=t*33^e.charCodeAt(--n);return xM(t)},TM=(e,t)=>{let n=12289;for(let r of t)n^=bM(_M(r),_M(e[r]));return xM(n)},EM=e=>TM(e,Kj(e)),DM=(e,t)=>n=>{let r=e;for(let e of n)r^=t(e);return xM(r)},OM=e=>{let t=6151;for(let n of e)t=bM(t,_M(n));return xM(t)},kM=DM(wM(`Map`),([e,t])=>bM(_M(e),_M(t))),AM=wM(`Set`),jM=DM(AM,e=>bM(AM,_M(e))),MM=new WeakMap,NM=new WeakMap,PM=new WeakSet,FM=`~effect/Equal`;function IM(){return arguments.length===1?e=>LM(e,arguments[0]):LM(arguments[0],arguments[1])}function LM(e,t){if(e===t)return!0;if(e==null||t==null)return!1;let n=typeof e;return n===typeof t?n===`number`&&e!==e&&t!==t?!0:n!==`object`&&n!==`function`||qj.has(e)||qj.has(t)?!1:RM(e,t):!1}function RM(e,t){let n=BM.length;for(let r=n;r-->0;)if(BM[r]===e&&VM[r]===t)return!0;if(n)return zM(e,t);let r=HM.get(e);r||HM.set(e,r=new WeakMap);let i=r.get(t);return i===void 0&&r.set(t,i=zM(e,t)),i}function zM(e,t){BM.push(e),VM.push(t);try{return UM(e,t)}finally{BM.pop(),VM.pop()}}const BM=[],VM=[],HM=new WeakMap;function UM(e,t){if(_M(e)!==_M(t))return!1;if(e instanceof Date){if(!(t instanceof Date))return!1;let n=e.getTime(),r=t.getTime();return n===r||Number.isNaN(n)&&Number.isNaN(r)}if(e instanceof RegExp)return t instanceof RegExp&&e.toString()===t.toString();let n=XM(e);if(n!==XM(t)||typeof e==`function`&&!n)return!1;if(n)return e[FM](t);if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:WM(e,t);if(Yj(e)){if(!Yj(t)||e instanceof ArrayBuffer!=t instanceof ArrayBuffer)return!1;let n=Xj(e),r=Xj(t);return n!==void 0&&r!==void 0&&GM(n,r)}if(ArrayBuffer.isView(e)){let n=e instanceof DataView;return!ArrayBuffer.isView(t)||e.byteLength!==t.byteLength||n!==t instanceof DataView?!1:n?GM(Jj(e),Jj(t)):GM(e,t)}return e instanceof Map?!(t instanceof Map)||e.size!==t.size?!1:qM(e,t,JM,YM):e instanceof Set?!(t instanceof Set)||e.size!==t.size?!1:qM(e,t,_M,LM):KM(e,t)}function WM(e,t){for(let n=0;n<e.length;n++)if(!LM(e[n],t[n]))return!1;return!0}function GM(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function KM(e,t){let n=Kj(e),r=Kj(t);if(n.size!==r.size)return!1;for(let i of n)if(!r.has(i)||!LM(e[i],t[i]))return!1;return!0}function qM(e,t,n,r){let i=new Map,a=0;for(let e of t){let t=n(e),r=i.get(t);r?r.push(e):i.set(t,[e]),a++}outer:for(let t of e){let e=i.get(n(t));if(e){for(let n=0;n<e.length;n++)if(r(t,e[n])){e[n]=e[e.length-1],e.pop(),a--;continue outer}}return!1}return a===0}const JM=e=>_M(e[0]),YM=(e,t)=>LM(e[0],t[0])&&LM(e[1],t[1]),XM=e=>z(e,FM),ZM=Symbol.for(`~effect/Redactable`),QM=e=>z(e,ZM);function $M(e){return QM(e)?eN(e):e}function eN(e){return e[ZM](globalThis[`~effect/Fiber/currentFiber`]?.context??rN)}const tN=`~effect/Fiber/currentFiber`,nN=new Map,rN={"~effect/Context":{},base:nN,depth:0,mapUnsafe:nN,pipe(){return Fj(this,arguments)}};function iN(e,t){let n=t?.space??0,r=new WeakSet,i=n?typeof n==`number`?` `.repeat(n):n:``,a=e=>i.repeat(e),o=(e,t)=>{let n=e?.constructor;return n&&n!==Object.prototype.constructor&&n.name?`${n.name}(${t})`:t},s=e=>{try{return Reflect.ownKeys(e)}catch{return[`[ownKeys threw]`]}};function c(e,t=0){try{return l(e,t)}catch{return(typeof e==`object`&&e||typeof e==`function`)&&r.delete(e),`[inspection threw]`}}function l(e,n=0){if(typeof e==`string`)return JSON.stringify(e);if(typeof e==`number`||e==null||typeof e==`boolean`||typeof e==`symbol`)return String(e);if(typeof e==`bigint`)return String(e)+`n`;if(typeof e==`object`||typeof e==`function`){if(r.has(e))return aN;r.add(e);let l;if(ZM in e)l=c(eN(e),n);else if(Array.isArray(e))l=!i||e.length<=1?`[${e.map(e=>c(e,n)).join(`,`)}]`:`[\n${a(n+1)}${e.map(e=>c(e,n+1)).join(`,
|
|
326
|
+
`+a(n+1))}\n${a(n)}]`;else if(e instanceof Date)l=cN(e);else if(!t?.ignoreToString&&z(e,`toString`)&&typeof e.toString==`function`&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString){let t=lN(e);l=e instanceof Error&&e.cause!==void 0?`${t} (cause: ${c(e.cause,n)})`:t}else if(Symbol.iterator in e)l=`${e.constructor.name}(${c(Array.from(e),n)})`;else{let t=s(e);if(!i||t.length<=1){let r=`{${t.map(t=>`${oN(t)}:${c(uN(e,t),n)}`).join(`,`)}}`;l=o(e,r)}else{let r=`{\n${t.map(t=>`${a(n+1)}${oN(t)}: ${c(uN(e,t),n+1)}`).join(`,
|
|
327
|
+
`)}\n${a(n)}}`;l=o(e,r)}}return r.delete(e),l}return String(e)}return c(e,0)}const aN=`[Circular]`;function oN(e){return typeof e==`string`?JSON.stringify(e):String(e)}function sN(e){return e.map(e=>`[${oN(e)}]`).join(``)}function cN(e){try{return e.toISOString()}catch{return`Invalid Date`}}function lN(e){try{let t=e.toString();return typeof t==`string`?t:String(t)}catch{return`[toString threw]`}}function uN(e,t){try{return e[t]}catch{return`[property access threw]`}}function dN(e,t){let n=[],r=new WeakMap;return JSON.stringify(e,function(e,t){let i=Object.getOwnPropertyDescriptor(r.get(this)??this,e)?.value,a=z(i,ZM)?$M(i):$M(t);if(typeof a==`bigint`)return iN(a);if(typeof a!=`object`||!a)return a;let o=a instanceof Error&&!z(a,`toJSON`)?{...a,name:a.name,message:a.message}:a;for(;n.length>0&&n[n.length-1]!==this;)n.pop();if(n.includes(a))return;if(n.push(a),o!==a&&n.push(o),!fN(o)||mN(o))return o;let s=pN(o);return r.set(s,o),n.push(s),s},t?.space)??`null`}function fN(e){for(let t of Object.getOwnPropertyNames(e))if(Object.getOwnPropertyDescriptor(e,t)?.get!==void 0)return!0;return!1}function pN(e){let t=Array.isArray(e)?[]:{},n=Array.isArray(e)?Array.from({length:e.length},(e,t)=>String(t)):Object.keys(e);for(let r of n)Object.defineProperty(t,r,{enumerable:!0,get:()=>{let t=Reflect.get(e,r);return Object.getOwnPropertyDescriptor(e,r)?.get===void 0?t:$M(t)}});return t}function mN(e){for(let t of[Number.prototype.valueOf,Boolean.prototype.valueOf,String.prototype.valueOf])try{return Reflect.apply(t,e,[]),!0}catch{}return!1}const hN=Symbol.for(`nodejs.util.inspect.custom`),gN=e=>{try{return e=$M(e),z(e,`toJSON`)&&iM(e.toJSON)&&e.toJSON.length===0?e.toJSON():Array.isArray(e)?e.map(gN):e}catch{return`[toJSON threw]`}},_N=(e,t=2)=>{if(typeof e==`string`)return e;try{return typeof e==`object`?dN(e,{space:t}):iN(e,{space:t})}catch{return String(e)}},vN={toJSON(){return gN(this)},[hN](){return this.toJSON()},toString(){return iN(this.toJSON())}},yN=(()=>{let e=Object.getOwnPropertyDescriptor(Error,`stackTraceLimit`);return e===void 0?Object.isExtensible(Error):Object.hasOwn(e,`writable`)?e.writable===!0:e.set!==void 0})(),bN=()=>Error.stackTraceLimit,xN=e=>{yN&&(Error.stackTraceLimit=e)};var SN=class{constructor(e){this.value=e,this.done=!1}next(e){return this.done?(this.value=e,this):(this.done=!0,{value:this.value,done:!1})}};const CN=(()=>{let e=`~effect/Utils/internal`,t={[e]:e=>e()},n={[e]:e=>{try{return e()}finally{}}},r=bN();if(r===0)return n[e];xN(2);let i=t[e](()=>Error());return xN(r),i.stack?.includes(e)===!0?t[e]:n[e]})();function wN(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}):e[t]=n}function TN(e,t){if(!Object.hasOwn(t,`__proto__`)){Object.assign(e,t);return}for(let n of Reflect.ownKeys(t))Object.prototype.propertyIsEnumerable.call(t,n)&&wN(e,n,t[n])}const EN=`~effect/Effect`,DN=`~effect/Exit`,ON={_A:R,_E:R,_R:R},kN=`${EN}/identifier`,B=`${EN}/args`,AN=`${EN}/evaluate`,jN=`${EN}/successCont`,MN=`${EN}/failureCont`,NN=`${EN}/ensureCont`,PN=Symbol.for(`effect/Effect/Yield`),FN={pipe(){return Fj(this,arguments)},toJSON(){return{...this}},toString(){return iN(this.toJSON(),{ignoreToString:!0,space:2})},[hN](){return this.toJSON()}},IN={[EN]:ON,...FN,[Symbol.iterator](){return new SN(this)},toJSON(){return{_id:`Effect`,op:this[kN],...B in this?{args:this[B]}:void 0}}},LN=e=>z(e,EN),RN=e=>z(e,DN),zN=`~effect/Cause`,BN=`~effect/Cause/Reason`,VN=e=>z(e,zN);var HN=class{constructor(e){this[zN]=zN,this.reasons=e}pipe(){return Fj(this,arguments)}toJSON(){return{_id:`Cause`,reasons:this.reasons.map(e=>e.toJSON())}}toString(){return`Cause(${iN(this.reasons)})`}[hN](){return this.toJSON()}[FM](e){return VN(e)&&this.reasons.length===e.reasons.length&&this.reasons.every((t,n)=>IM(t,e.reasons[n]))}[gM](){return OM(this.reasons)}};const UN=new WeakMap;var WN=class{[BN];annotations;_tag;constructor(e,t,n){if(this[BN]=BN,this._tag=e,t!==GN&&typeof n==`object`&&n&&t.size>0){let e=UN.get(n);e&&(t=new Map([...e,...t])),UN.set(n,t)}this.annotations=t}annotate(e,t){if(e.mapUnsafe.size===0)return this;let n=new Map(this.annotations);if(e.mapUnsafe.forEach((e,r)=>{t?.overwrite!==!0&&n.has(r)||n.set(r,e)}),t?.overwrite!==!0&&n.size===this.annotations.size)return this;let r=Object.assign(Object.create(Object.getPrototypeOf(this)),this);return r.annotations=n,r}pipe(){return Fj(this,arguments)}toString(){return iN(this)}[hN](){return this.toString()}};const GN=new Map;var KN=class extends WN{constructor(e,t=GN){super(`Fail`,t,e),this.error=e}toString(){return`Fail(${iN(this.error)})`}toJSON(){return{_tag:`Fail`,error:this.error}}[FM](e){return nP(e)&&IM(this.error,e.error)&&IM(this.annotations,e.annotations)}[gM](){return bM(wM(this._tag))(bM(_M(this.error))(_M(this.annotations)))}};const qN=e=>new HN(e),JN=(e,t)=>{let n=new Map,r=[];for(let i of e.concat(t)){let e=_M(i),t=n.get(e);if(t===void 0)n.set(e,[i]);else if(t.some(e=>IM(e,i)))continue;else t.push(i);r.push(i)}return r},YN=L(2,(e,t)=>{if(e.reasons.length===0)return t;if(t.reasons.length===0)return e;let n=new HN(JN(e.reasons,t.reasons));return IM(e,n)?e:n}),XN=(e,t)=>{let n=e.reasons.slice();for(let e of t.reasons)iP(e)&&!n.some(t=>iP(t)&&t.fiberId===e.fiberId&&t.annotations===e.annotations)&&n.push(e);return n.length===e.reasons.length?e:new HN(n)},ZN=new HN([]),QN=e=>new HN([new KN(e)]);var $N=class extends WN{constructor(e,t=GN){super(`Die`,t,e),this.defect=e}toString(){return`Die(${iN(this.defect)})`}toJSON(){return{_tag:`Die`,defect:this.defect}}[FM](e){return rP(e)&&IM(this.defect,e.defect)&&IM(this.annotations,e.annotations)}[gM](){return bM(wM(this._tag))(bM(_M(this.defect))(_M(this.annotations)))}};const eP=e=>new HN([new $N(e)]),tP=L(e=>VN(e[0]),(e,t,n)=>t.mapUnsafe.size===0?e:new HN(e.reasons.map(e=>e.annotate(t,n)))),nP=e=>e._tag===`Fail`,rP=e=>e._tag===`Die`,iP=e=>e._tag===`Interrupt`;function aP(e){return mP(`Effect.evaluate: Not implemented`)}const oP=e=>({...IN,[kN]:e.op,[AN]:e[AN]??aP,[jN]:e[jN],[MN]:e[MN],[NN]:e[NN]}),sP=e=>{let t=oP(e),n=function(e){this[B]=e};return n.prototype=t,function(e){return new n(e)}},cP=e=>{let t={[DN]:DN,_tag:e.op,get[e.prop](){return this[B]},...oP(e),toString(){return`${e.op}(${iN(this[B])})`},toJSON(){return{_id:`Exit`,_tag:e.op,[e.prop]:this[B]}},[FM](e){return RN(e)&&e._tag===this._tag&&IM(this[B],e[B])},[gM](){return bM(wM(e.op),_M(this[B]))}},n=function(e){this[B]=e};return n.prototype=t,function(e){return new n(e)}},lP=cP({op:`Success`,prop:`value`,[AN](e){let t=e.getCont(jN);return t?t[jN](this[B],e,this):e.yieldWith(this)}}),uP={key:`effect/Cause/StackTrace`},dP={key:`effect/Cause/InterruptorStackTrace`},fP=cP({op:`Failure`,prop:`cause`,[AN](e){let t=this[B],n=!1;e.cache.stackFrame&&(t=tP(t,{mapUnsafe:new Map([[uP.key,e.cache.stackFrame]])}),n=!0);let r=e.getCont(MN),i=e._interruptedCause;if(i&&e.interruptible){let a=!1;for(;r&&e.interruptible;)a||=kN in r,r=e.getCont(MN);a&&(t=qN(t.reasons.filter(e=>e._tag!==`Fail`))),t=XN(t,i),n=!0}return r?r[MN](t,e,n?void 0:this):e.yieldWith(n?fP(t):this)}}),pP=e=>fP(QN(e)),mP=e=>fP(eP(e)),hP=sP({op:`WithFiber`,[AN](e){return this[B](e)}}),gP=function(){class e extends globalThis.Error{}let t=oP({op:`YieldableError`,[AN](){return pP(this)}});return delete t.toString,Object.assign(e.prototype,t),e}(),_P=function(){let e=Symbol.for(`effect/Data/Error/plainArgs`);return class extends gP{constructor(t){super(t?.message,t?.cause?{cause:t.cause}:void 0),t&&(TN(this,t),Object.defineProperty(this,e,{value:t,enumerable:!1}))}toJSON(){return{...this[e],...this}}}}(),vP=e=>{class t extends _P{_tag=e}return t.prototype.name=e,t},yP=`~effect/Cause/Done`,bP=e=>z(e,yP),xP={[yP]:yP,_tag:`Done`,value:void 0},SP=e=>e===void 0?xP:{[yP]:yP,_tag:`Done`,value:e},Jre=pP(xP),Yre=e=>e===void 0?Jre:pP(SP(e)),CP=e=>oP({op:e.label,[AN]:e.evaluate}),wP=e=>(t,n)=>t===n||e(t,n),Xre=(e,t)=>e===t,Zre=()=>Xre;function Qre(e){return wP((t,n)=>{if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(!e(t[r],n[r]))return!1;return!0})}const TP=`~effect/Option`,EP={[TP]:{_A:e=>e},...FN,[Symbol.iterator](){return new SN(this)}},$re=Object.defineProperty(Object.assign(Object.create(EP),{_tag:`Some`,_op:`Some`,[FM](e){return DP(e)&&kP(e)&&IM(this.value,e.value)},[gM](){return bM(_M(this._tag))(_M(this.value))},toString(){return`some(${iN(this.value)})`},toJSON(){return{_id:`Option`,_tag:this._tag,value:gN(this.value)}}}),"valueOrUndefined",{get(){return this.value}}),eie=_M(`None`),tie=Object.assign(Object.create(EP),{_tag:`None`,_op:`None`,valueOrUndefined:void 0,[FM](e){return DP(e)&&OP(e)},[gM](){return eie},toString(){return`none()`},toJSON(){return{_id:`Option`,_tag:this._tag}}}),DP=e=>z(e,TP),OP=e=>e._tag===`None`,kP=e=>e._tag===`Some`,nie=Object.create(tie),AP=function(e){this.value=e};AP.prototype=$re;const rie=e=>new AP(e),jP=`~effect/Result`,MP={[jP]:{_A:e=>e,_E:e=>e},...FN,[Symbol.iterator](){return new SN(this)}},iie=Object.assign(Object.create(MP),{_tag:`Success`,_op:`Success`,[FM](e){return NP(e)&&FP(e)&&IM(this.success,e.success)},[gM](){return bM(_M(this._tag))(_M(this.success))},toString(){return`success(${iN(this.success)})`},toJSON(){return{_id:`Result`,_tag:this._tag,value:gN(this.success)}}}),aie=Object.assign(Object.create(MP),{_tag:`Failure`,_op:`Failure`,[FM](e){return NP(e)&&PP(e)&&IM(this.failure,e.failure)},[gM](){return bM(_M(this._tag))(_M(this.failure))},toString(){return`failure(${iN(this.failure)})`},toJSON(){return{_id:`Result`,_tag:this._tag,failure:gN(this.failure)}}}),NP=e=>z(e,jP),PP=e=>e._tag===`Failure`,FP=e=>e._tag===`Success`,IP=function(e){this.failure=e};IP.prototype=aie;const oie=e=>new IP(e),LP=function(e){this.success=e};LP.prototype=iie;const sie=e=>new LP(e);function RP(e){return(t,n)=>t===n?0:e(t,n)}const zP=RP((e,t)=>e<t?-1:1),BP=RP((e,t)=>globalThis.Number.isNaN(e)&&globalThis.Number.isNaN(t)?0:globalThis.Number.isNaN(e)?-1:globalThis.Number.isNaN(t)?1:e<t?-1:1),cie=L(2,(e,t)=>RP((n,r)=>e(t(n),t(r)))),VP=e=>L(2,(t,n)=>e(t,n)===-1),HP=e=>L(2,(t,n)=>e(t,n)===1),lie=e=>L(2,(t,n)=>e(t,n)!==1),uie=e=>L(2,(t,n)=>e(t,n)!==-1),V=()=>nie,UP=rie,die=DP,WP=OP,GP=kP,KP=L(2,(e,{onNone:t,onSome:n})=>WP(e)?t():n(e.value)),qP=L(2,(e,t)=>WP(e)?t():e.value),fie=L(2,(e,t)=>WP(e)?t():e),JP=e=>e==null?V():UP(e),YP=e=>e===void 0?V():UP(e),XP=qP(Vj),pie=e=>(...t)=>{try{return UP(e(...t))}catch{return V()}},mie=L(2,(e,t)=>WP(e)?V():UP(t(e.value))),ZP=L(2,(e,t)=>WP(e)?V():t(e.value)),hie=L(2,(e,t)=>!WP(e)&&t(e.value)),QP=`~effect/Context/Service`,$P=function(){function e(){}let t=e;Object.setPrototypeOf(t,gie);let n=(e,n)=>(t.key=e,n?.defaultValue&&(t[tF]=tF,t.defaultValue=n.defaultValue),n?.make&&(t.make=n.make),n?.fiberCached&&eF.add(e),t);return arguments.length>0?n(arguments[0],arguments[1]):n},gie={[QP]:QP,...CP({label:`Service`,evaluate(e){return lP(_F(e.context,this))}}),toJSON(){return{_id:`Service`,key:this.key}},of(e){return e},context(e){return fF(this,e)},use(e){return hP(t=>e(_F(t.context,this)))},useSync(e){return hP(t=>lP(e(_F(t.context,this))))}},eF=new Set,tF=`~effect/Context/Reference`,nF=`~effect/Context`,rF=(e,t,n,r)=>{let i=Object.create(vie);return i.cacheRoot=e??i,i.base=t,i.overlay=n,i.depth=r,i._flat=void 0,i.baseHits=0,i},iF=(e,t)=>{t&&(iF(e,t.parent),e.set(t.key,t.value))},aF=e=>{if(e._flat)return e._flat;if(!e.overlay)return e._flat=e.base;let t=new Map(e.base);return iF(t,e.overlay),e._flat=t},_ie=(e,t)=>{let n=new Map(e.mapUnsafe);return t(n),cF(n)},oF=Symbol(),sF=(e,t)=>{let n=e;for(let e=n.overlay;e;e=e.parent)if(e.key===t)return e.value;let r=n.base.get(t);return r===void 0&&!n.base.has(t)?oF:(n.overlay&&++n.baseHits>=n.base.size&&n.baseHits>=8&&(n.base=aF(n),n.overlay=void 0,n.depth=0),r)},cF=e=>rF(void 0,e,void 0,0),vie={get mapUnsafe(){return aF(this)},...FN,[nF]:{_Services:e=>e},toJSON(){return{_id:`Context`,services:Array.from(this.mapUnsafe).map(([e,t])=>({key:e,value:t}))}},[FM](e){if(!lF(e))return!1;let t=this.mapUnsafe,n=e.mapUnsafe;if(t.size!==n.size)return!1;for(let[e,r]of t)if(!n.has(e)||!IM(r,n.get(e)))return!1;return!0},[gM](){return CM(this.mapUnsafe.size)}},yie=(e,t)=>e.cacheRoot===t.cacheRoot,lF=e=>z(e,nF),uF=e=>!!e[tF],dF=()=>bie,bie=cF(new Map),fF=(e,t)=>cF(new Map([[e.key,t]])),pF=L(3,(e,t,n)=>xie(e,t.key,n)),xie=(e,t,n)=>{let r=e,i=eF.has(t)?void 0:r.cacheRoot;if(r.depth>=8){let e=new Map(r._flat??r.base);return r._flat||iF(e,r.overlay),e.set(t,n),rF(i,e,void 0,0)}return rF(i,r.base,{key:t,value:n,parent:r.overlay},r.depth+1)},mF=L(2,(e,t)=>hF(e,t.key)),hF=(e,t)=>{let n=sF(e,t);return n===oF?void 0:n},gF=L(2,(e,t)=>{let n=sF(e,t.key);if(n===oF){if(uF(t))return yF(t);throw Sie(t)}return n}),_F=gF,vF=`~effect/Context/defaultValue`,yF=e=>vF in e?e[vF]:e[vF]=e.defaultValue(),Sie=e=>{let t=Error(`Service not found${e.key?`: ${String(e.key)}`:``}`);if(t.stack){let e=t.stack.split(`
|
|
328
|
+
`);e.splice(1,3),t.stack=e.join(`
|
|
329
|
+
`)}return t},Cie=L(2,(e,t)=>{let n=sF(e,t.key);return n===oF?uF(t)?UP(yF(t)):V():UP(n)}),bF=L(2,(e,t)=>e.mapUnsafe.size===0?t:t.mapUnsafe.size===0?e:_ie(e,e=>t.mapUnsafe.forEach((t,n)=>e.set(n,t)))),wie=(...e)=>{let t=new Map;for(let n=0;n<e.length;n++)e[n].mapUnsafe.forEach((e,n)=>{t.set(n,e)});return cF(t)},xF=$P,SF=e=>e.length>0,CF=e=>e>0?Math.floor(e):0,wF=sie,TF=oie,Tie=e=>{if(iM(e))try{return wF(e())}catch(e){return TF(e)}try{return wF(e.try())}catch(t){return TF(e.catch(t))}},Eie=NP,EF=PP,DF=FP,Die=L(2,(e,t)=>EF(e)?TF(t(e.failure)):e),Oie=L(2,(e,{onFailure:t,onSuccess:n})=>EF(e)?t(e.failure):n(e.success)),kie=L(2,(e,t)=>{let n=0;for(let r of e){let e=t(r,n);if(tM(e)){if(e)return UP(r)}else if(GP(e))return e;n++}return V()}),OF=globalThis.Array,kF=e=>OF.isArray(e)?e:OF.from(e),AF=L(2,(e,{onEmpty:t,onNonEmpty:n})=>MF(e)?n(e):t()),jF=L(2,(e,t)=>[...e,t]);OF.isArray;const Aie=SF,MF=SF,NF=L(2,(e,t)=>{let n=0;for(let r of e){if(t(r,n))return UP(n);n++}return V()}),jie=kie,Mie=L(2,(e,t)=>{let n=kF(e);for(let e=n.length-1;e>=0;e--){let r=n[e],i=t(r,e);if(typeof i==`boolean`){if(i)return UP(r)}else if(GP(i))return i}return V()}),PF=()=>[],FF=e=>[e],IF=L(2,(e,t)=>e.map(t)),LF=L(3,(e,t,n)=>kF(e).reduce((e,t,r)=>n(e,t,r),t)),RF=`~effect/Duration`,zF=BigInt(0),BF=BigInt(1),VF=BigInt(2),Nie=BigInt(10),HF=BigInt(24),UF=BigInt(60),WF=BigInt(1e3),GF=BigInt(1e6),KF=BigInt(1e9),Pie=BigInt(6e10),Fie=BigInt(36e11),Iie=BigInt(864e11),Lie=BigInt(6048e11),qF=e=>BigInt(Math.sign(e)*Math.round(Math.abs(e))),JF=e=>Number.isInteger(e)?BigInt(e)*GF:qF(e*1e6),YF=e=>aI(Number.isFinite(e)?qF(e):e),XF=(e,t)=>{let n=Number(e);if(Number.isFinite(n))return n/t;let r=BigInt(t);return Number(e/r)+Number(e%r)/t},ZF=(e,t)=>{let n=e.indexOf(`.`);if(n===-1)return BigInt(e)*t;let r=e[0]===`-`,i=e.slice(n+1),a=Nie**BigInt(i.length),o=(BigInt(e.slice(+!!r,n))*a+BigInt(i))*t;return QF(r?-o:o,a)},QF=(e,t)=>{let n=e<zF?-e:e,r=n/t+(n%t*VF>=t?BF:zF);return e<zF?-r:r},$F=(e,t)=>{let n=Number(e)*t;if(!Number.isFinite(n))return aI(n);let r=ZF(e,BigInt(t)*GF);return aI(Number.isInteger(n)&&BigInt(n)*GF===r?n:r)},Rie=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,eI=e=>{switch(typeof e){case`number`:return dI(e);case`bigint`:return uI(e);case`string`:{if(e===`Infinity`)return cI;if(e===`-Infinity`)return lI;let t=Rie.exec(e);if(!t)break;let[n,r,i]=t;if(i===`nano`||i===`nanos`)return uI(ZF(r,BF));if(i===`micro`||i===`micros`)return uI(ZF(r,WF));switch(i){case`milli`:case`millis`:return $F(r,1);case`second`:case`seconds`:return $F(r,1e3);case`minute`:case`minutes`:return $F(r,6e4);case`hour`:case`hours`:return $F(r,36e5);case`day`:case`days`:return $F(r,864e5);case`week`:case`weeks`:return $F(r,6048e5)}break}case`object`:{if(e===null)break;if(RF in e)return e;if(Array.isArray(e)){if(e.length!==2||!e.every(eM))return rI(e);if(Number.isNaN(e[0])||Number.isNaN(e[1]))return sI;if(e[0]===-1/0||e[1]===-1/0)return lI;if(e[0]===1/0||e[1]===1/0)return cI;let t=e[0]*1e9+e[1];return Number.isFinite(t)&&Number.isInteger(e[0])&&Number.isInteger(e[1])?aI(BigInt(e[0])*KF+BigInt(e[1])):YF(t)}let t=e,n=0;if(t.weeks&&(n+=t.weeks*6048e5),t.days&&(n+=t.days*864e5),t.hours&&(n+=t.hours*36e5),t.minutes&&(n+=t.minutes*6e4),t.seconds&&(n+=t.seconds*1e3),t.milliseconds&&(n+=t.milliseconds),!t.microseconds&&!t.nanoseconds){if(!Number.isFinite(n))return aI(n);let e=nI(t);return e===void 0||BigInt(n)*GF===e?aI(n):aI(e)}let r=n*1e6+(t.microseconds??0)*1e3+(t.nanoseconds??0),i=Number.isFinite(r)?nI(t):void 0;return i===void 0?YF(r):aI(i)}}return rI(e)},tI=e=>!e||Number.isInteger(e),nI=e=>{if(!tI(e.weeks)||!tI(e.days)||!tI(e.hours)||!tI(e.minutes)||!tI(e.seconds)||!tI(e.milliseconds)||!tI(e.microseconds)||!tI(e.nanoseconds))return;let t=zF;return e.weeks&&(t+=BigInt(e.weeks)*Lie),e.days&&(t+=BigInt(e.days)*Iie),e.hours&&(t+=BigInt(e.hours)*Fie),e.minutes&&(t+=BigInt(e.minutes)*Pie),e.seconds&&(t+=BigInt(e.seconds)*KF),e.milliseconds&&(t+=BigInt(e.milliseconds)*GF),e.microseconds&&(t+=BigInt(e.microseconds)*WF),e.nanoseconds&&(t+=BigInt(e.nanoseconds)),t},rI=e=>{throw Error(`Invalid Input: ${e}`)},zie=pie(eI),iI={_tag:`Millis`,millis:0},Bie={_tag:`Infinity`},Vie={_tag:`NegativeInfinity`},Hie={[RF]:RF,[gM](){switch(this.value._tag){case`Millis`:return _M(JF(this.value.millis));case`Nanos`:return _M(this.value.nanos);default:return EM(this.value)}},[FM](e){return Uie(e)&&vI(this,e)},toString(){switch(this.value._tag){case`Infinity`:return`Infinity`;case`NegativeInfinity`:return`-Infinity`;case`Nanos`:return`${this.value.nanos} nanos`;case`Millis`:return`${this.value.millis} millis`}},toJSON(){switch(this.value._tag){case`Millis`:return{_id:`Duration`,_tag:`Millis`,millis:this.value.millis};case`Nanos`:return{_id:`Duration`,_tag:`Nanos`,nanos:String(this.value.nanos)};case`Infinity`:return{_id:`Duration`,_tag:`Infinity`};case`NegativeInfinity`:return{_id:`Duration`,_tag:`NegativeInfinity`}}},[hN](){return this.toJSON()},pipe(){return Fj(this,arguments)}},aI=e=>{let t=Object.create(Hie);return t.value=typeof e==`number`?isNaN(e)||e===0||Object.is(e,-0)?iI:Number.isFinite(e)?Number.isInteger(e)?{_tag:`Millis`,millis:e}:{_tag:`Nanos`,nanos:JF(e)}:e>0?Bie:Vie:e===zF?iI:{_tag:`Nanos`,nanos:e},t},Uie=e=>z(e,RF),oI=e=>e.value._tag!==`Infinity`&&e.value._tag!==`NegativeInfinity`,Wie=e=>{switch(e.value._tag){case`Millis`:return e.value.millis===0;case`Nanos`:return e.value.nanos===zF;case`Infinity`:case`NegativeInfinity`:return!1}},Gie=e=>{switch(e.value._tag){case`Millis`:return e.value.millis<0;case`Nanos`:return e.value.nanos<zF;case`NegativeInfinity`:return!0;case`Infinity`:return!1}},Kie=e=>{switch(e.value._tag){case`Infinity`:case`NegativeInfinity`:return cI;case`Millis`:return e.value.millis<0?aI(-e.value.millis):e;case`Nanos`:return e.value.nanos<zF?aI(-e.value.nanos):e}},sI=aI(0),cI=aI(1/0),lI=aI(-1/0),uI=e=>aI(e),dI=e=>aI(e),fI=e=>aI(e*1e3),pI=e=>aI(e*6e4),mI=e=>aI(e*36e5),qie=e=>aI(e*864e5),hI=e=>_I(eI(e),{onMillis:R,onNanos:e=>XF(e,1e6),onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0}),Jie=e=>_I(eI(e),{onMillis:e=>e/1e3,onNanos:e=>XF(e,1e9),onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0}),Yie=e=>_I(eI(e),{onMillis:e=>e/6e4,onNanos:e=>XF(e,6e10),onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0}),Xie=e=>_I(eI(e),{onMillis:e=>e/36e5,onNanos:e=>XF(e,36e11),onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0}),gI=e=>{let t=eI(e);switch(t.value._tag){case`Infinity`:case`NegativeInfinity`:throw Error(`Cannot convert infinite duration to nanos`);case`Nanos`:return t.value.nanos;case`Millis`:return JF(t.value.millis)}},_I=L(2,(e,t)=>{switch(e.value._tag){case`Millis`:return t.onMillis(e.value.millis);case`Nanos`:return t.onNanos(e.value.nanos);case`Infinity`:return t.onInfinity();case`NegativeInfinity`:return(t.onNegativeInfinity??t.onInfinity)()}}),Zie=L(3,(e,t,n)=>e.value._tag===`Infinity`||e.value._tag===`NegativeInfinity`||t.value._tag===`Infinity`||t.value._tag===`NegativeInfinity`?n.onInfinity(e,t):e.value._tag===`Millis`?t.value._tag===`Millis`?n.onMillis(e.value.millis,t.value.millis):n.onNanos(gI(e),t.value.nanos):n.onNanos(e.value.nanos,gI(t))),Qie=(e,t)=>Zie(e,t,{onMillis:(e,t)=>e===t,onNanos:(e,t)=>e===t,onInfinity:(e,t)=>e.value._tag===t.value._tag}),$ie=L(2,(e,t)=>_I(e,{onMillis:e=>aI(e*t),onNanos:e=>{if(Number.isInteger(t))return aI(e*BigInt(t));let n=Number(e),r=n*t;if(!Number.isFinite(t)||Number.isSafeInteger(n)&&Math.abs(r)<=2**53-1)return YF(r);let i=t,a=BF;for(;!Number.isInteger(i);)i*=2,a*=VF;return aI(QF(e*BigInt(i),a))},onInfinity:()=>t>0?cI:t<0?lI:sI,onNegativeInfinity:()=>t>0?lI:t<0?cI:sI})),vI=L(2,(e,t)=>Qie(e,t)),yI=e=>{if(e.value._tag===`Infinity`)return{days:1/0,hours:1/0,minutes:1/0,seconds:1/0,millis:1/0,nanos:1/0};if(e.value._tag===`NegativeInfinity`)return{days:-1/0,hours:-1/0,minutes:-1/0,seconds:-1/0,millis:-1/0,nanos:-1/0};let t=gI(e),n=t<zF,r=n?-t:t,i=r/GF,a=i/WF,o=a/UF,s=o/UF,c=s/HF,l=n?-1:1;return{days:l*Number(c),hours:l*Number(s%HF),minutes:l*Number(o%UF),seconds:l*Number(a%UF),millis:l*Number(i%WF),nanos:l*Number(r%GF)}},bI=e=>{if(e.value._tag===`Infinity`)return`Infinity`;if(e.value._tag===`NegativeInfinity`)return`-Infinity`;if(Wie(e))return`0`;if(Gie(e))return`-`+bI(Kie(e));let t=yI(e),n=[];return t.days!==0&&n.push(`${t.days}d`),t.hours!==0&&n.push(`${t.hours}h`),t.minutes!==0&&n.push(`${t.minutes}m`),t.seconds!==0&&n.push(`${t.seconds}s`),t.millis!==0&&n.push(`${t.millis}ms`),t.nanos!==0&&n.push(`${t.nanos}ns`),n.join(` `)},xI=L(2,(e,t)=>n=>{let r=e(n);if(EF(r))return TF(n);let i=t(r.success);return EF(i)?TF(n):i}),SI=xF(`effect/Scheduler`,{fiberCached:!0,defaultValue:()=>new DI}),CI=e=>{let t=!1;return Promise.resolve().then(()=>{t||e()}),()=>{t=!0}},wI=`setImmediate`in globalThis?e=>{let t=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(t)}:e=>{let t=setTimeout(e,0);return()=>clearTimeout(t)},TI=e=>{try{return wI(e)}catch{return CI(e)}};var EI=class{buckets=[];scheduleTask(e,t){let n=this.buckets,r=n.length,i,a=0;for(;a<r&&!(n[a][0]>t);a++)i=n[a];i&&i[0]===t?i[1].push(e):a===r?n.push([t,[e]]):n.splice(a,0,[t,[e]])}drain(){let e=this.buckets;return this.buckets=[],e}},DI=class{executionMode;setImmediate;constructor(e=`async`,t){this.executionMode=e,this.setImmediate=t??(e===`sync`?CI:TI)}shouldYield(e){return e.currentOpCount>=e.cache.maxOpsBeforeYield}makeDispatcher(){return new OI(this.setImmediate)}},OI=class{tasks=new EI;running=void 0;setImmediate;constructor(e=TI){this.setImmediate=e}scheduleTask(e,t){this.tasks.scheduleTask(e,t),this.running===void 0&&(this.running=this.setImmediate(this.afterScheduled))}afterScheduled=()=>{this.running=void 0,this.runTasks()};runTasks(){let e=this.tasks.drain();for(let t=0;t<e.length;t++){let n=e[t][1];for(let e=0;e<n.length;e++)n[e]()}}flush(){for(;this.tasks.buckets.length>0;)this.running!==void 0&&(this.running(),this.running=void 0),this.runTasks()}};const kI=xF(`effect/Scheduler/MaxOpsBeforeYield`,{fiberCached:!0,defaultValue:()=>2048}),AI=xF(`effect/Scheduler/PreventSchedulerYield`,{fiberCached:!0,defaultValue:()=>!1}),jI=()=>new Proxy({},{get(e,t,n){return t===`$is`?pM:t===`$match`?MI:e=>({...e,_tag:t})}});function MI(){if(arguments.length===1){let e=arguments[0];return function(t){return e[t._tag](t)}}let e=arguments[0];return arguments[1][e._tag](e)}const NI=_P,PI=vP,FI=`~effect/encoding/EncodingError`;var II=class extends PI(`EncodingError`){[FI]=FI};const LI=e=>{switch(e){case 16:return BI();case 32:return VI();default:{let t=``;for(let n=e>>>3;n>0;n--)t+=zI();return t}}},H=Uint8Array.from(`0123456789abcdef`,e=>e.charCodeAt(0)),RI=()=>Math.random()*4294967296>>>0,zI=()=>{let e=RI();return String.fromCharCode(H[e>>>28],H[e>>>24&15],H[e>>>20&15],H[e>>>16&15],H[e>>>12&15],H[e>>>8&15],H[e>>>4&15],H[e&15])},BI=()=>{let e=RI(),t=RI();return String.fromCharCode(H[e>>>28],H[e>>>24&15],H[e>>>20&15],H[e>>>16&15],H[e>>>12&15],H[e>>>8&15],H[e>>>4&15],H[e&15],H[t>>>28],H[t>>>24&15],H[t>>>20&15],H[t>>>16&15],H[t>>>12&15],H[t>>>8&15],H[t>>>4&15],H[t&15])},VI=()=>{let e=RI(),t=RI(),n=RI(),r=RI();return String.fromCharCode(H[e>>>28],H[e>>>24&15],H[e>>>20&15],H[e>>>16&15],H[e>>>12&15],H[e>>>8&15],H[e>>>4&15],H[e&15],H[t>>>28],H[t>>>24&15],H[t>>>20&15],H[t>>>16&15],H[t>>>12&15],H[t>>>8&15],H[t>>>4&15],H[t&15],H[n>>>28],H[n>>>24&15],H[n>>>20&15],H[n>>>16&15],H[n>>>12&15],H[n>>>8&15],H[n>>>4&15],H[n&15],H[r>>>28],H[r>>>24&15],H[r>>>20&15],H[r>>>16&15],H[r>>>12&15],H[r>>>8&15],H[r>>>4&15],H[r&15])},HI=`effect/Tracer/ParentSpan`;var UI=class extends $P()(HI,{fiberCached:!0}){};const WI=e=>e,GI=xF(`effect/Tracer/DisablePropagation`,{defaultValue:Bj}),KI=xF(`effect/Tracer/CurrentTraceLevel`,{defaultValue:()=>`Info`}),qI=xF(`effect/Tracer/MinimumTraceLevel`,{defaultValue:()=>`All`}),JI=WI({span:e=>new YI(e)});var YI=class{_tag=`Span`;sampled;name;parent;annotations;links;startTime;kind;status;_traceId=void 0;_spanId=void 0;_attributes=void 0;_events=void 0;constructor(e){this.name=e.name,this.parent=e.parent,this.annotations=e.annotations,this.links=e.links,this.startTime=e.startTime,this.kind=e.kind,this.sampled=e.sampled,this.status={_tag:`Started`,startTime:e.startTime}}get traceId(){return this._traceId??=XP(this.parent)?.traceId??LI(32)}get spanId(){return this._spanId??=LI(16)}get attributes(){return this._attributes??=new Map}get events(){return this._events??=[]}end(e,t){this.status._tag!==`Ended`&&(this.status={_tag:`Ended`,endTime:e,exit:t,startTime:this.status.startTime})}attribute(e,t){this.status._tag!==`Ended`&&this.attributes.set(e,t)}event(e,t,n){this.status._tag!==`Ended`&&this.events.push([e,t,n??{}])}addLinks(e){this.status._tag!==`Ended`&&this.links.push(...e)}};const XI=xF(`effect/References/CurrentStackFrame`,{fiberCached:!0,defaultValue:Vj}),ZI=xF(`effect/References/TracerEnabled`,{fiberCached:!0,defaultValue:zj}),QI=xF(`effect/References/TracerTimingEnabled`,{defaultValue:zj}),$I=xF(`effect/References/TracerSpanAnnotations`,{defaultValue:()=>({})}),eL=xF(`effect/References/TracerSpanLinks`,{defaultValue:()=>[]}),tL=xF(`effect/References/CurrentLogAnnotations`,{defaultValue:()=>({})}),nL=xF(`effect/References/CurrentLogLevel`,{fiberCached:!0,defaultValue:()=>`Info`}),rL=xF(`effect/References/MinimumLogLevel`,{fiberCached:!0,defaultValue:()=>`Info`}),iL=xF(`effect/References/CurrentLogSpans`,{defaultValue:()=>[]}),aL=e=>{if(e?.captureStackTrace===!1||e?.captureStackTrace!==void 0&&typeof e.captureStackTrace!=`boolean`)return e;let t=bN();if(t===0&&e?.captureStackTrace!==!0)return{...e,captureStackTrace:!1};xN(3);let n=Error();return xN(t),{...e,captureStackTrace:oL(()=>n.stack)}},oL=(e=>t=>{let n;return()=>{if(n!==void 0)return n;let r=t();if(!r)return;let i=r.split(`
|
|
330
|
+
`);if(i[e]!==void 0)return n=i[e].trim(),n}})(3);var sL=class extends WN{constructor(e,t=GN){super(`Interrupt`,t,`Interrupted`),this.fiberId=e}toString(){return`Interrupt(${this.fiberId})`}toJSON(){return{_tag:`Interrupt`,fiberId:this.fiberId}}[FM](e){return iP(e)&&this.fiberId===e.fiberId&&this.annotations===e.annotations}[gM](){return wM(`${this._tag}:${this.fiberId}`)}};const cL=e=>new HN([new sL(e)]),lL=e=>e.reasons.some(nP),uL=e=>{for(let t=0;t<e.reasons.length;t++){let n=e.reasons[t];if(n._tag===`Fail`)return wF(n.error)}return TF(e)},dL=e=>e.reasons.some(rP),fL=e=>dL(e)&&lL(e)?qN(e.reasons.map(e=>e._tag===`Fail`&&!bP(e.error)?new $N(e.error,e.annotations):e)):e,pL=e=>dL(e)?TF(fL(e)):uL(e),mL=e=>e.reasons.some(iP),hL=e=>e.reasons.length>0&&e.reasons.every(iP),gL=L(2,(e,t)=>{let n=!1,r=e.reasons.map(e=>nP(e)?(n=!0,new KN(t(e.error),e.annotations)):e);return n?qN(r):e}),_L=e=>{let t;for(let n of e.reasons){if(n._tag===`Fail`)return n.error;n._tag===`Die`&&(t??=n)}return t===void 0?e.reasons.length>0?new globalThis.Error(`All fibers interrupted without error`):new globalThis.Error(`Empty cause`):t.defect},vL=(e,t)=>{let n=[],r=[];if(e.reasons.length===0)return n;let i=bN();i!==0&&xN(1);try{for(let i of e.reasons){if(i._tag===`Interrupt`){r.push(i);continue}n.push(yL(i._tag===`Die`?i.defect:i.error,i.annotations,t))}if(n.length===0){let e=Error(`The fiber was interrupted by:`);e.name=`InterruptCause`,e.stack=wL(e,r);let i=new globalThis.Error(`All fibers interrupted without error`,{cause:e});i.name=`InterruptError`,i.stack=`${i.name}: ${i.message}`,n.push(yL(i,r[0].annotations,t))}}finally{i!==0&&xN(i)}return n},yL=(e,t,n,r=new Set)=>{let i=typeof e,a;if(e&&i===`object`){r.add(e);let i=e.cause;if(a=new globalThis.Error(bL(e),{cause:i!==void 0&&!r.has(i)?yL(i,void 0,void 0,r):void 0}),typeof e.name==`string`&&(a.name=e.name),typeof e.stack==`string`)a.stack=SL(e.stack,a,t);else{let e=`${a.name}: ${a.message}`;a.stack=t?CL(e,t):e}n?.includeCauseInStack&&(a.stack=DL(a));for(let t of Object.keys(e))t in a||(a[t]=e[t])}else{a=new globalThis.Error(e?i===`string`?e:dN(e):`Unknown error: ${e}`);let n=`${a.name}: ${a.message}`;a.stack=t?CL(n,t):n}return a},bL=e=>{if(typeof e.message==`string`)return e.message;if(typeof e.toString==`function`&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString)try{return e.toString()}catch{}return dN(e)},xL=/\((.*)\)/g,SL=(e,t,n)=>{let r=`${t.name}: ${t.message}`,i=(e.startsWith(r)?e.slice(r.length):e).split(`
|
|
331
|
+
`),a=[r];for(let e=1;e<i.length&&!/Generator\.next|~effect\/(?:Effect|Utils)/.test(i[e]);e++)a.push(i[e]);return n?CL(a.join(`
|
|
332
|
+
`),n):a.join(`
|
|
333
|
+
`)},CL=(e,t)=>{let n=t?.get(uP.key);return n&&(e=`${e}\n${TL(n)}`),e},wL=(e,t)=>{let n=[`${e.name}: ${e.message}`];for(let e of t){let t=e.fiberId===void 0?`unknown`:`#${e.fiberId}`,r=e.annotations.get(dP.key);n.push(` at fiber (${t})`),r&&n.push(TL(r))}return n.join(`
|
|
334
|
+
`)},TL=e=>{let t=[],n=e,r=0;for(;n&&r<10;){let e=n.stack();if(e){let r=e.matchAll(xL),i=!1;for(let[,e]of r)i=!0,t.push(` at ${n.name} (${e})`);i||t.push(` at ${n.name} (${e.replace(/^at /,``)})`)}else t.push(` at ${n.name}`);n=n.parent,r++}return t.join(`
|
|
335
|
+
`)},EL=e=>vL(e).map(DL).join(`
|
|
336
|
+
`),DL=e=>e.cause?`${e.stack} {\n${OL(e.cause,` `)}\n}`:e.stack,OL=(e,t)=>{let n=e.stack.split(`
|
|
337
|
+
`),r=`${t}[cause]: ${n[0]}`;for(let e=1,i=n.length;e<i;e++)r+=`\n${t}${n[e]}`;return e.cause&&(r+=` {\n${OL(e.cause,`${t} `)}\n${t}}`),r},kL=`~effect/Fiber`,AL={_A:R,_E:R},jL={id:0},ML=(()=>{try{return globalThis.process?.getBuiltinModule?.(`node:async_hooks`)?.AsyncResource}catch{return}})(),NL=()=>ML===void 0?void 0:new ML(`effect/Fiber`),PL=()=>globalThis[tN];var FL=class{constructor(e,t=!0){this.setContext(e),this.id=++jL.id,this.currentOpCount=0,this.interruptible=t,this._stack=[],this._observers=void 0,this._exit=void 0,this._children=void 0,this._interruptedCause=void 0,this._yielded=void 0,this._running=!1,this._deferredInterrupt=!1,this._parent=void 0,this._asyncContext=void 0,this.cache.runtimeMetrics?.recordFiberStart(this.context)}get[kL](){return AL}get currentDispatcher(){return this._dispatcher??=this.cache.scheduler.makeDispatcher()}getRef(e){return _F(this.context,e)}addObserver(e){return this._exit?(e(this._exit),Hj):(this._observers===void 0?this._observers=[e]:this._observers.push(e),()=>this.removeObserver(e))}removeObserver(e){if(this._exit||this._observers===void 0)return;let t=this._observers.indexOf(e);t>=0&&this._observers.splice(t,1)}interruptUnsafe(e,t){if(this._exit)return;let n=cL(e);this.cache.stackFrame&&(n=tP(n,fF(uP,this.cache.stackFrame))),t&&(n=tP(n,t)),this._interruptedCause=this._interruptedCause?XN(this._interruptedCause,n):n,this.interruptible&&(this._running?this._deferredInterrupt=!0:this.evaluate(qL(this._interruptedCause)))}pollUnsafe(){return this._exit}evaluate(e){if(this._exit)return;if(this._asyncContext!==void 0){let t=this._asyncContext;this._asyncContext=void 0;try{return t.runInAsyncScope(this.evaluate,this,e)}finally{t.emitDestroy()}}else if(this._yielded!==void 0){let e=this._yielded;this._yielded=void 0,e()}let t=this.runLoop(e);if(t===PN){this._asyncContext=NL();return}let n=zL.interruptChildren&&zL.interruptChildren(this);if(n!==void 0)return this.evaluate(NR(n,()=>t));if(this._exit=t,this.cache.runtimeMetrics?.recordFiberEnd(this.context,this._exit),this._parent&&=(this._parent._children?.delete(this),void 0),this._observers!==void 0){let e=this._observers;this._observers=void 0;for(let n=0;n<e.length;n++)e[n](t)}this._stack.length=0,this._children=void 0,this.context=dF()}runLoop(e){let t=globalThis[tN];globalThis[tN]=this;let n=this._running;this._running=!0;let r=!1,i=e;this.currentOpCount=0;try{for(;;)try{this._deferredInterrupt&&(this._deferredInterrupt=!1,i=qL(this._interruptedCause)),this.currentOpCount++;let e=this.cache;if(!r&&!e.preventYield&&e.scheduler.shouldYield(this)){r=!0;let e=i;i=NR(QL,()=>e)}if(i=e.tracerContext?e.tracerContext(i,this):i[AN](this),i===PN){let e=this._yielded;if(DN in e)return this._deferredInterrupt=!1,this._yielded=void 0,e;if(this._deferredInterrupt){this._yielded=void 0,e();continue}return PN}}catch(e){if(!z(i,AN))return mP(`Fiber.runLoop: Not a valid effect: ${String(i)}`);i=mP(e)}}finally{this._running=n,globalThis[tN]=t}}getCont(e){if(this._deferredInterrupt)return this._deferredInterrupt=!1,LL;for(;;){let t=this._stack.pop();if(!t)return;let n=t[NN];if(n!==void 0){let r=n.call(t,this);if(r)return r[e]=r,r}if(t[e])return t}}succeedWith(e){if(!(++this.currentOpCount&RL-1))return lP(e);let t=this.getCont(jN);return t?t[jN](e,this):this.yieldWith(lP(e))}yieldWith(e){return this._yielded=e,PN}children(){return this._children??=new Set}pipe(){return Fj(this,arguments)}setContext(e){let t=this.context;if(this.context=e,t!==void 0&&yie(t,e))return;let n=e.cacheRoot,r=n._fiberCache??=IL(e);this.cache?.scheduler!==r.scheduler&&(this._dispatcher=void 0),this.cache=r}get currentSpanLocal(){let e=this.cache.span;return e?._tag===`Span`?e:void 0}};const IL=e=>{let t=hF(e,`effect/Tracer`);return{scheduler:_F(e,SI),tracer:t,tracerContext:t?t.context:void 0,tracerEnabled:_F(e,ZI),span:hF(e,HI),logLevel:_F(e,nL),minimumLogLevel:_F(e,rL),stackFrame:_F(e,XI),runtimeMetrics:hF(e,`effect/Metric/FiberRuntimeMetrics`),maxOpsBeforeYield:_F(e,kI),preventYield:_F(e,AI)}},LL={[jN](e,t){return qL(t._interruptedCause)},[MN](e,t){return qL(t._interruptedCause)}},RL=32,zL={interruptChildren:void 0},BL=e=>{if(!e.cache.stackFrame)return;let t=new Map;return t.set(dP.key,e.cache.stackFrame),cF(t)},VL=e=>{let t=e;return t._exit?U(t._exit):cR(n=>t._exit?n(U(t._exit)):YL(e.addObserver(e=>n(U(e)))))},HL=e=>cR(t=>{let n=e[Symbol.iterator](),r=[],i;function a(){let e=n.next();for(;!e.done;){if(e.value._exit){r.push(e.value._exit),e=n.next();continue}i=e.value.addObserver(e=>{r.push(e),a()});return}t(U(r))}return a(),YL(()=>i?.())}),UL=e=>{let t=e;return t._exit?t._exit:cR(n=>t._exit?n(t._exit):YL(e.addObserver(n)))},WL=e=>hP(t=>GL(e,t.id)),GL=L(e=>z(e[0],kL),(e,t,n)=>hP(r=>{let i=BL(r);return i=i&&n?bF(i,n):i??n,e.interruptUnsafe(t,i),AR(VL(e))})),KL=e=>hP(t=>{let n=BL(t),r=PF();for(let i of e)i.interruptUnsafe(t.id,n),r.push(i);return AR(HL(r))}),U=lP,qL=fP,JL=pP,YL=sP({op:`Sync`,[AN](e){let t=this[B],n=t(),r=e.getCont(jN);return r?r[jN](n,e):e.yieldWith(lP(n))}}),XL=sP({op:`Suspend`,[AN](e){let t=this[B];return t()}}),ZL=Oie({onFailure:JL,onSuccess:U}),QL=sP({op:`Yield`,[AN](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate(KR)},this[B]??0),e.yieldWith(()=>{t=!0})}})(0),$L=U(V()),eR=e=>XL(()=>qL(e())),tR=e=>mP(e),nR=e=>XL(()=>JL(e())),rR=U(void 0),iR=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new SV(e,`An error occurred in Effect.try`):e.catch;return XL(()=>{try{return U(t())}catch(e){return JL(n(e))}})},aR=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new SV(e,`An error occurred in Effect.tryPromise`):e.catch;return oR(function(e,r){let i=e=>XL(()=>{try{return JL(CN(()=>n(e)))}catch(e){return tR(e)}});try{t(r).then(t=>e(U(t)),t=>e(i(t)))}catch(t){e(i(t))}},t.length!==0)},oR=function(){let e=oP({op:`Async`,[AN](e){let t=!1,n=!1,r=this.withSignal?new AbortController:void 0,i=this.register.call(e.cache.scheduler,r=>{t||(t=!0,n?e.evaluate(r):n=r)},r?.signal);return n===!1?(n=!0,e.yieldWith(()=>{t=!0}),r===void 0&&i===void 0||e._stack.push(sR(()=>(t=!0,r?.abort(),i??KR))),PN):n}}),t=function(e,t){this.register=e,this.withSignal=t};return t.prototype=e,function(e,n){return new t(e,n)}}(),sR=sP({op:`AsyncFinalizer`,[NN](e){e.interruptible&&(e.interruptible=!1,e._stack.push(bB))},[MN](e,t){return mL(e)?NR(Uz(fP(e),this[B]()),()=>qL(e)):qL(e)}}),cR=e=>oR(e,e.length>=2),lR=cR(Hj),uR=(...e)=>{if(e.length===1){let t=e[0];return XL(()=>hR(t()))}let[t,n]=e;return XL(()=>hR(n.call(t.self)))},dR=(e,...t)=>{let n=t.length===0?function(){return XL(()=>hR(e.apply(this,arguments)))}:function(){let n=XL(()=>hR(e.apply(this,arguments)));for(let e=0;e<t.length;e++)n=t[e](n,...arguments);return n};return fR(e.length,n)},fR=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),pR=(e,...t)=>fR(e.length,t.length===0?function(){return mR(()=>e.apply(this,arguments))}:function(){let n=mR(()=>e.apply(this,arguments));for(let e of t)n=e(n,...arguments);return n}),mR=e=>{try{let t=e(),n;for(;;){let r=t.next(n);if(r.done)return U(r.value);let i=r.value;if(i&&i._tag===`Success`){n=i.value;continue}if(i&&i._tag===`Failure`)return r.value;{let n=!0;return XL(()=>n?(n=!1,NR(r.value,e=>hR(t,e))):XL(()=>hR(e())))}}}catch(e){return tR(e)}},hR=function(){let e=oP({op:`Iterator`,[jN](e,t){let n=this.iterator;for(;;){let r=n.next(e);if(r.done)return U(r.value);if(!PR(r.value))return t._stack.push(this),r.value;if(r.value._tag===`Failure`)return r.value;e=r.value.value}},[AN](e){return this[jN](this.initial,e)}}),t=function(e,t){this.iterator=e,this.initial=t};return t.prototype=e,function(e,n){return new t(e,n)}}(),gR=L(2,(e,t)=>new yR(e,bR,U(t))),_R=function(e){return e._stack.push(this),this[B]},vR=oP({op:`OnSuccess`,[AN]:_R}),yR=function(e,t,n){this[B]=e,this[jN]=t,this.payload=n};yR.prototype=vR;const bR=function(){return this.payload},xR=function(e,t){return t.succeedWith(this.payload)},SR=(()=>{let e=bN();if(e===0)return!1;let t=`~effect/Effect/stackProbe`,n={[t]:function(){return Error()}};xN(1);let r=n[t]();return xN(e),r.stack?.includes(`[as `+t+`]`)===!0})(),CR=function(e,t){let n=this.payload;return t.succeedWith(SR?n(e):CN(()=>n(e)))},wR=function(e){let t=this.payload;return t(e)},TR=function(e){let t=this.payload;return new yR(t(e),xR,e)},ER=function(e){return new yR(this.payload,xR,e)},DR=e=>LR(e,UP),OR=L(2,(e,t)=>new yR(e,LN(t)?bR:wR,t)),kR=L(2,(e,t)=>new yR(e,LN(t)?ER:TR,t)),AR=e=>new yR(e,bR,KR),jR=(e,t)=>hP(n=>{let r=new Set;return cB(n,()=>r.size===0?void 0:KL(r)),cR(i=>{let a=!1,o=0;for(let s of e){if(a)break;let e=o++,c=FB(n,s,!0,!0,!1);r.add(c),c.addObserver(o=>{r.delete(c);let s=!a;a=!0,i(o),s&&t?.onWinner&&t.onWinner({fiber:c,index:e,parentFiber:n})})}})}),MR=L(e=>LN(e[1]),(e,t,n)=>jR([e,t],n)),NR=L(2,(e,t)=>new yR(e,wR,t)),PR=e=>e[DN]!==void 0,FR=L(2,(e,t)=>PR(e)?e._tag===`Success`?t(e.value):e:NR(e,t)),IR=e=>NR(e,R),LR=L(2,(e,t)=>new yR(e,CR,t)),RR=L(2,(e,t)=>PR(e)?qR(e,t):LR(e,t)),zR=L(2,(e,t)=>PR(e)?JR(e,t):yz(e,t)),BR=e=>fP(cL(e)),VR=e=>e._tag===`Success`,HR=e=>e._tag===`Failure`,UR=e=>e._tag===`Failure`?wF(e.cause):TF(e),WR=xI(UR,uL),GR=e=>e._tag===`Failure`&&mL(e.cause),KR=lP(void 0),qR=L(2,(e,t)=>e._tag===`Success`?lP(t(e.value)):e),JR=L(2,(e,t)=>e._tag===`Success`?e:fP(gL(e.cause,t))),YR=L(2,(e,t)=>VR(e)?t:e),XR=e=>{let t=[];for(let n of e)n._tag===`Failure`&&t.push(...n.cause.reasons);return t.length===0?KR:fP(qN(t))},ZR=e=>{let t=WR(e);return EF(t)?V():UP(t.success)},QR=e=>hP(t=>U(Cie(t.context,e))),$R=L(2,(e,t)=>hP(n=>{let r=n.context,i=t(r);return r===i?e:(n.setContext(i),cB(n,()=>{n.setContext(r)}),e)})),ez=L(3,(e,t,n)=>$R(e,e=>{let r=gF(e,t),i=n(r);return r===i?e:pF(e,t,i)})),tz=()=>nz,nz=hP(e=>U(e.context)),rz=e=>hP(t=>e(t.context)),iz=L(2,(e,t)=>PR(e)?e:$R(e,bF(t))),az=function(){return arguments.length===1?L(2,(e,t)=>oz(e,arguments[0],t)):L(3,(e,t,n)=>oz(e,t,n)).apply(this,arguments)},oz=(e,t,n)=>$R(e,pF(t,n)),sz=L(e=>LN(e[0]),(e,t)=>DB({while:zj,body:Rj(t?.disableYield?e:NR(e,e=>QL)),step:Hj})),cz=L(2,(e,t)=>new uz(e,t.length===1?t:e=>t(e))),lz=oP({op:`OnFailure`,[AN]:_R}),uz=function(e,t){this[B]=e,this[MN]=t};uz.prototype=lz;const dz=L(3,(e,t,n)=>cz(e,e=>{let r=t(e);return EF(r)?qL(r.failure):n(r.success,e)})),fz=L(2,(e,t)=>dz(e,pL,e=>t(e))),pz=L(3,(e,t,n)=>cz(e,e=>{let r=t(e);return EF(r)?qL(e):OR(n(r.success,e),qL(e))})),mz=L(2,(e,t)=>pz(e,uL,e=>t(e))),hz=L(e=>LN(e[0]),(e,t,n,r)=>cz(e,e=>{let i=pL(e);return EF(i)?qL(i.failure):t(i.success)?n(i.success):r?r(i.success):qL(e)})),gz=L(e=>LN(e[0]),(e,t,n,r)=>cz(e,e=>{let i=pL(e);if(EF(i))return qL(i.failure);let a=t(i.success);return EF(a)?r?r(a.failure):qL(e):n(a.success)})),_z=L(e=>LN(e[0]),(e,t,n,r)=>{let i=Array.isArray(t)?e=>z(e,`_tag`)&&t.includes(e._tag):pM(t);return hz(e,i,n,r)}),vz=L(e=>LN(e[0]),(e,t,n)=>{let r;return gz(e,e=>(r??=Object.keys(t),z(e,`_tag`)&&$j(e._tag)&&r.includes(e._tag)?wF(e):TF(e)),e=>t[e._tag](e),n)}),yz=L(2,(e,t)=>cz(e,e=>qL(gL(e,t)))),bz=e=>fz(e,tR),xz=L(e=>LN(e[0]),(e,t)=>{if(!t?.log)return Oz(e,{onFailure:e=>rR,onSuccess:e=>rR});let n=jV(t.log===!0?void 0:t.log);return Cz(e,{onFailure(e){let r=pL(e);return EF(r)?qL(r.failure):t.message===void 0?n(e):n(t.message,e)},onSuccess:e=>rR})}),Sz=e=>Az(e,{onFailure:TF,onSuccess:wF}),Cz=L(2,(e,t)=>new Tz(e,t.onSuccess.length===1?t.onSuccess:e=>t.onSuccess(e),t.onFailure.length===1?t.onFailure:e=>t.onFailure(e))),wz=oP({op:`OnSuccessAndFailure`,[AN]:_R}),Tz=function(e,t,n){this[B]=e,this[jN]=t,this[MN]=n};Tz.prototype=wz;const Ez=function(e,t){let n=this.payload;return t.succeedWith(SR?n.onSuccess(e):CN(()=>n.onSuccess(e)))},Dz=((e,t)=>{let n=oP({op:e,[AN]:_R,[jN]:Ez,[MN]:t}),r=function(e,t){this[B]=e,this.payload=t};return r.prototype=n,r})(`Match`,function(e,t){let n=pL(e);if(EF(n))return qL(n.failure);let r=this.payload;return t.succeedWith(SR?r.onFailure(n.success):CN(()=>r.onFailure(n.success)))}),Oz=L(2,(e,t)=>Cz(e,{onFailure:e=>{let n=pL(e);return EF(n)?qL(n.failure):t.onFailure(n.success)},onSuccess:t.onSuccess})),kz=L(2,(e,t)=>new Dz(e,t)),Az=L(2,(e,t)=>{if(PR(e)){if(e._tag===`Success`)return lP(t.onSuccess(e.value));let n=pL(e.cause);return EF(n)?fP(n.failure):lP(t.onFailure(n.success))}return kz(e,t)}),jz=e=>PR(e)?lP(e):Mz(e),Mz=sP({op:`Exit`,[AN](e){return e._stack.push(this),this[B]},[jN](e,t,n){return t.succeedWith(n??lP(e))},[MN](e,t,n){return t.succeedWith(n??fP(e))}}),Nz=L(2,(e,t)=>NR(Iz(e,t.duration),e=>WP(e)?t.orElse():U(e.value))),Pz=e=>new gV(`Operation timed out after '${bI(e)}'`),Fz=L(2,(e,t)=>{let n=eI(t);return Nz(e,{duration:n,orElse:()=>JL(Pz(n))})}),Iz=L(2,(e,t)=>MR(DR(e),gR(fV(t),V()))),Lz=`~effect/Scope`,Rz=`~effect/Scope/Closeable`,zz=$P(`effect/Scope`),Bz=(e,t)=>hP(n=>(CB(n),Vz(e,t)??rR)),Vz=(e,t)=>{let n=e.state;if(n._tag===`Closed`||(e.state={_tag:`Closed`,exit:t},e.parent!==void 0&&Xz(e.parent,e),n._tag===`Empty`))return;if(n.finalizer!==void 0)return Hz(n.finalizer,t);let r=n.finalizers;return r.size===1?Hz(r.values().next().value,t):Wz(e,r,t)},Hz=(e,t)=>{try{return e(t)}catch(e){return mP(e)}},Uz=(e,t)=>VR(e)?t:cz(t,t=>qL(fL(YN(e.cause,t)))),Wz=dR(function*(e,t,n){let r=[],i=[],a=Array.from(t),o=PL();for(let t=a.length-1;t>=0;t--){let[s,c]=a[t];e.strategy===`sequential`?r.push(yield*jz(Hz(c,n))):s!==o&&i.push(FB(o,Hz(c,n),!0,!0,`inherit`))}return i.length>0&&(r=yield*HL(i)),yield*XR(r)}),Gz=(e,t)=>YL(()=>Kz(e,t)),Kz=(e,t)=>{let n=Qz(t,e);return e.state._tag===`Closed`?(n.state=e.state,n):(Yz(e,n,e=>Bz(n,e)),n)},qz=(e,t)=>XL(()=>e.state._tag===`Closed`?t(e.state.exit):(Yz(e,{},t),rR)),Jz=(e,t)=>qz(e,Rj(t)),Yz=(e,t,n)=>{if(e.state._tag===`Empty`)e.state={_tag:`Open`,finalizerKey:t,finalizer:n,finalizers:void 0};else if(e.state._tag===`Open`){let r=e.state;r.finalizer===void 0?r.finalizers.set(t,n):(r.finalizers=new Map([[r.finalizerKey,r.finalizer]]),r.finalizerKey=void 0,r.finalizer=void 0,r.finalizers.set(t,n))}},Xz=(e,t)=>{if(e.state._tag!==`Open`)return;let n=e.state;n.finalizerKey===t?e.state=$z:n.finalizers!==void 0&&(n.finalizers.delete(t),n.finalizers.size===0&&(e.state=$z))},Zz=e=>Qz(e,void 0),Qz=(e=`sequential`,t)=>({[Rz]:Rz,[Lz]:Lz,strategy:e,parent:t,state:$z}),$z={_tag:`Empty`},eB=zz,tB=az(zz),nB=e=>hP(t=>{let n=t.context,r=Zz();return t.setContext(pF(t.context,zz,r)),cB(t,e=>(t.setContext(n),Vz(r,e))),e}),rB=e=>XL(()=>{let t=Zz();return lB(e(t),e=>XL(()=>Vz(t,e)??rR))}),iB=(e,t,n)=>rz(r=>TB(i=>NR(eB,a=>kR(n?.interruptible?i(e):e,e=>qz(a,n=>iz(t(e,n),r)))))),aB=e=>NR(eB,t=>rz(n=>qz(t,t=>iz(e(t),n)))),oB=function(){let e=oP({op:`OnExit`,[AN](e){return e._stack.push(this),this.effect},[NN](e){e.interruptible&&this.interruptible!==!0&&(e._stack.push(bB),e.interruptible=!1)},[jN](e,t,n){n??=lP(e);let r;try{r=this.onExit(n)}catch(e){r=mP(e)}return r?NR(r,e=>n):n},[MN](e,t,n){n??=fP(e);let r;try{r=this.onExit(n)}catch(e){r=mP(e)}return r?NR(Uz(n,r),e=>n):n}}),t=function(e,t,n){this.effect=e,this.onExit=t,this.interruptible=n};return t.prototype=e,t}(),sB=(e,t,n)=>new oB(e,t,n),cB=(e,t)=>{e._stack.push(new oB(void 0,t,void 0))},lB=L(2,sB),uB=L(2,(e,t)=>lB(e,e=>t)),dB=L(3,(e,t,n)=>lB(e,e=>{let r=t(e);return EF(r)?rR:n(r.success,e)})),fB=L(2,(e,t)=>dB(e,UR,t)),pB=(e,t,n)=>TB(r=>NR(e,e=>sB(XL(()=>r(t(e))),t=>n(e,t),!0))),mB=Rj(1/0),hB=(e,t)=>{let n=0,r,i,a=(e,t)=>(t.awaiters++,cB(e,()=>{if(!(--t.awaiters>0||t.done))return i===t&&(i=void 0),WL(t.fiber)}),UL(t.fiber));return[hP(o=>{if(i!==void 0)return o===i.fiber?UL(i.fiber):a(o,i);if(r!==void 0&&(n===1/0||o.getRef(aV).currentTimeMillisUnsafe()<n))return r;r=void 0;let s=o.getRef(aV),c={fiber:new FL(o.context),awaiters:0,done:!1};i=c;let l=a(o,c);return c.fiber.evaluate(sB(e,e=>{if(c.done=!0,i!==c||(i=void 0,GR(e)))return;let a=t(e);n=a===1/0?1/0:s.currentTimeMillisUnsafe()+a,r=e})),c.fiber._exit??l}),YL(()=>{i=void 0,r=void 0})]},gB=e=>YL(()=>hB(e,mB)[0]),_B=hP(e=>qL(cL(e.id))),vB=e=>hP(t=>t.interruptible?(t.interruptible=!1,t._stack.push(bB),e):e),yB=sP({op:`SetInterruptible`,[NN](e){if(e.interruptible=this[B],e._interruptedCause&&e.interruptible)return()=>qL(e._interruptedCause)}}),bB=yB(!0),xB=yB(!1),SB=e=>{if(e.interruptible=!0,e._stack.push(xB),e._interruptedCause)return qL(e._interruptedCause)},CB=e=>{let t=e;t.interruptible&&(t.interruptible=!1,t._stack.push(bB))},wB=e=>hP(t=>t.interruptible?e:SB(t)??e),TB=e=>hP(t=>t.interruptible?(t.interruptible=!1,t._stack.push(bB),e(wB)):e(R)),EB=(e,t)=>hM(e)?t?.mode===`result`?OB(e,Sz,t):OB(e,R,t):t?.discard?t.mode===`result`?OB(Object.values(e),Sz,t):OB(Object.values(e),R,t):XL(()=>LR(OB(Object.entries(e),([e,n])=>LR(t?.mode===`result`?Sz(n):n,t=>[e,t]),{concurrency:t?.concurrency}),Object.fromEntries)),DB=sP({op:`While`,[jN](e,t){return this[B].step(e),this[B].while()?(t._stack.push(this),this[B].body()):KR},[AN](e){return this[B].while()?(e._stack.push(this),this[B].body()):KR}}),OB=L(e=>typeof e[1]==`function`,(e,t,n)=>XL(()=>{let r=AB(n?.concurrency);if(r===1)return kB(e,t,n);let i=kF(e),a=i.length;if(a===0)return n?.discard?rR:U([]);let o=n?.discard?void 0:Array(a),s=PB({f:t,out:o},i,{concurrency:r});return s?gR(s,o):U(o)})),kB=(e,t,n)=>XL(()=>{let r=n?.discard?void 0:[],i=e[Symbol.iterator](),a=i.next(),o=0;return gR(DB({while:()=>!a.done,body:()=>t(a.value,o++),step:e=>{r&&r.push(e),a=i.next()}}),r)}),AB=e=>e===`unbounded`?1/0:Math.max(1,e??1),jB=()=>e=>{let t=e.onItem,n=e.step,r=(e,t,r,a,o)=>NR(jz(o),o=>n(e,t[r],o,r)??i(e,t,r+1,a)??rR),i=(e,i,a=0,o=i.length)=>{for(;a<o;a++){let s=i[a],c=t(e,s,a);if(!PR(c))return r(e,i,a,o,c);let l=n(e,s,c,a);if(l)return l._tag===`Failure`?l:void 0}};return i},MB=e=>{let t=e.onItem,n=e.step;return(e,r,i)=>{let a=0,o=i.end??r.length,s=i.concurrency,c=!1,l,u,d,f,p,m=e=>{let t=mP(e);return f=t,c=!0,u&&u.size>0?NR(vB(KL(Array.from(u))),()=>f??t):t},h=()=>{let i=!1;for(;!f&&a<o;a++){let o=r[a],g=p??t(e,o,a);if(PR(g)){if(f=n(e,o,g,a),f)break}else if(l){p=void 0;let t=FB(l,g,!0,!0,`inherit`);if(t._exit){if(f=n(e,o,t._exit,a),f)break;continue}u.add(t);let r=a;if(t.addObserver(a=>{u.delete(t);try{if(f){if(a._tag===`Failure`){let e=a.cause.reasons.filter(e=>e._tag!==`Interrupt`);if(e.length>0){let t=qN(e);f=fP(f._tag===`Failure`?fL(YN(f.cause,t)):t)}}}else{let t=n(e,o,a,r);t&&(f=t,h())}if(i){let e=h();e&&d(e)}else c&&u.size===0&&d(f??rR)}catch(e){d(m(e))}}),u.size<s)continue;i=!0,a++;return}else return cR(e=>{l=PL(),u=new Set,p=g,d=e;let t;try{t=h()}catch(t){return e(m(t))}return t?e(t):XL(()=>(f??=KR,NR(u?KL(u):rR,()=>f?._tag===`Failure`?f:rR)))})}if(c=!0,f){if(u&&u.size>0){let e=BL(l);u.forEach(t=>t.interruptUnsafe(l.id,e));return}if(d||f._tag===`Failure`)return f}else if(d){if(u)u.size===0&&d(rR);else return KR}};return h()}},NB=()=>e=>MB(e),PB=MB({onItem(e,t,n){return e.f(t,n)},step(e,t,n,r){if(n._tag===`Failure`)return n;e.out&&(e.out[r]=n.value)}}),FB=(e,t,n=!1,r=!1,i=!1)=>{let a=e,o=i===`inherit`?a.interruptible:!i,s=new FL(a.context,o);return r||(a.children().add(s),s._parent=a),n?s.evaluate(t):(s._asyncContext=NL(),a.currentDispatcher.scheduleTask(()=>s.evaluate(t),0)),s},IB=e=>()=>hP(t=>t===e?rR:WL(e)),LB=L(e=>LN(e[0]),(e,t,n)=>hP(r=>{let i=t.state._tag===`Closed`?new FL(r.context):FB(r,e,n?.startImmediately,!0,n?.uninterruptible);return i._exit||(t.state._tag===`Closed`?i.interruptUnsafe(r.id,BL(r)):(Yz(t,i,IB(i)),i.addObserver(()=>Xz(t,i)))),U(i)})),RB=L(e=>LN(e[0]),(e,t)=>NR(eB,n=>LB(e,n,t))),zB=e=>(t,n)=>{let r=new FL(n?.scheduler?pF(e,SI,n.scheduler):e,n?.uninterruptible!==!0);if(r.evaluate(t),r._exit)return r;if(n?.signal){if(n.signal.aborted)r.interruptUnsafe();else{let e=()=>r.interruptUnsafe();n.signal.addEventListener(`abort`,e,{once:!0}),r.addObserver(()=>n.signal.removeEventListener(`abort`,e))}}return n?.onFiberStart&&n.onFiberStart(r),r},BB=L(2,(e,t)=>e._exit?e:t.state._tag===`Closed`?(e.interruptUnsafe(e.id),e):(Xz(t,e),Yz(t,e,IB(e)),e.addObserver(()=>Xz(t,e)),e)),VB=zB(dF()),HB=(e=>{let t=zB(e);return(e,n)=>{let r=t(e,n);return new Promise(e=>{r.addObserver(t=>e(t))})}})(dF()),UB=(e=>{let t=zB(e);return e=>{if(PR(e))return e;let n=new DI(`sync`),r=t(e,{scheduler:n});return r._dispatcher?.flush(),r._exit??mP(new bV(r))}})(dF()),WB=U(!0),GB=U(!1);var KB=class{waiters=[];scheduled=void 0;_isOpen;constructor(e){this._isOpen=e}scheduleUnsafe(e){if(this.waiters.length===0)return WB;if(this.scheduled===void 0)this.scheduled=this.waiters,e.currentDispatcher.scheduleTask(this.flushScheduled,0);else for(let e=0;e<this.waiters.length;e++)this.scheduled.push(this.waiters[e]);return this.waiters=[],WB}flushScheduled=()=>{if(this.scheduled===void 0)return;let e=this.scheduled;this.scheduled=void 0;for(let t=0;t<e.length;t++)e[t](KR)};flushWaiters(){let e=this.waiters;this.waiters=[],this.flushScheduled();for(let t=0;t<e.length;t++)e[t](KR)}open=hP(e=>this._isOpen?GB:(this._isOpen=!0,this.scheduleUnsafe(e)));release=hP(e=>this._isOpen?GB:this.scheduleUnsafe(e));openUnsafe(){return!this._isOpen&&(this._isOpen=!0,this.flushWaiters(),!0)}await=cR(e=>this._isOpen?e(rR):(this.waiters.push(e),YL(()=>{let t=this.waiters.indexOf(e);t===-1?this.scheduled!==void 0&&(t=this.scheduled.indexOf(e),t!==-1&&this.scheduled.splice(t,1)):this.waiters.splice(t,1)})));closeUnsafe(){return this._isOpen?(this._isOpen=!1,!0):!1}close=YL(()=>this.closeUnsafe());whenOpen=e=>NR(this.await,()=>e);isOpen(){return this._isOpen}};const qB=e=>new KB(e??!1),JB=BigInt(0),YB={_tag:`Span`,spanId:`noop`,traceId:`noop`,sampled:!1,status:{_tag:`Ended`,startTime:JB,endTime:JB,exit:KR},attributes:new Map,links:[],kind:`internal`,attribute(){},event(){},end(){},addLinks(){}},XB=e=>Object.assign(Object.create(YB),e),ZB=e=>e?_F(e.annotations,GI)?e._tag===`Span`?ZB(XP(e.parent)):V():UP(e):V(),QB=(e,t,n)=>{let r=!e.cache.tracerEnabled||n?.annotations&&_F(n.annotations,GI),i=n?.parent===void 0?n?.root?V():ZB(e.cache.span):UP(n.parent),a;if(r)a=XB({name:t,parent:i,annotations:pF(n?.annotations??dF(),GI,!0)});else{let r=e.cache.tracer??JI,o=e.getRef(aV),s=e.getRef(QI),c=e.getRef($I),l=e.getRef(eL),u=n?.level??e.getRef(KI),d=n?.links===void 0?l.length===0?[]:l.slice():[...l,...n.links];a=r.span({name:t,parent:i,annotations:n?.annotations??dF(),links:d,startTime:s?o.currentTimeNanosUnsafe():JB,kind:n?.kind??`internal`,root:n?.root??!1,sampled:n?.sampled??(GP(i)&&i.value.sampled===!1?!1:!wV(e.getRef(qI),u))});for(let e in c)a.attribute(e,c[e]);if(n?.attributes!==void 0)for(let e in n.attributes)a.attribute(e,n.attributes[e])}return a},$B=(e,t)=>(t=typeof t==`function`?t:Vj,ez(XI,n=>({name:e,stack:t,parent:n}))),eV=(e,t,n,r)=>YL(()=>{e.status._tag!==`Ended`&&e.end(r?n.currentTimeNanosUnsafe():JB,t)}),tV=(e,...t)=>{let n=t.length===1?void 0:t[0],r=t[t.length-1];return hP(t=>{let i=QB(t,e,n),a=t.getRef(aV),o=t.getRef(QI);return cB(t,e=>eV(i,e,a,o)),r(i)})},nV=az(UI),rV=function(){let e=LN(arguments[0]),t=e?arguments[1]:arguments[0],n=e?arguments[2]:arguments[1],r=R;return t._tag===`Span`&&(n=aL(n),r=$B(t.name,n?.captureStackTrace)),e?nV(r(arguments[0]),t):e=>nV(r(e),t)},iV=function(){let e=typeof arguments[0]!=`string`,t=e?arguments[1]:arguments[0],n=aL(arguments[2]);if(e){let e=arguments[0];return tV(t,arguments[2],t=>rV(e,t,n))}let r=typeof arguments[1]==`function`?arguments[1]:void 0,i=r?void 0:arguments[1];return(e,...a)=>tV(t,r?r(...a):i,t=>rV(e,t,n))},aV=xF(`effect/Clock`,{defaultValue:()=>new sV}),oV=2**31-1;var sV=class{currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=YL(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return uV()}currentTimeNanos=YL(()=>this.currentTimeNanosUnsafe());monotonicTimeNanosUnsafe(){return lV()}monotonicTimeNanos=YL(()=>this.monotonicTimeNanosUnsafe());sleep(e){return this.sleepMillis(hI(e))}sleepMillis(e){return e<=0?QL:Number.isFinite(e)?cR(t=>{let n=e>oV?this.sleepMillis(e-oV):rR,r=setTimeout(()=>t(n),Math.min(e,oV));return YL(()=>clearTimeout(r))}):lR}};const cV=BigInt(1e6),lV=function(){let e=globalThis.process?.hrtime;if(typeof e?.bigint==`function`)return()=>e.bigint();if(typeof performance<`u`&&typeof performance.now==`function`)return()=>BigInt(Math.round(performance.now()*1e6));let t=BigInt(0);return()=>{let e=BigInt(Date.now())*cV;return e>t&&(t=e),t}}(),uV=function(){let e=BigInt(1e9),t;return()=>{let n=lV(),r=BigInt(Date.now())*cV;if(t===void 0)t=r-n;else{let i=t+n;(r>i?r-i:i-r)>e&&(t=r-n)}return t+n}}(),dV=e=>hP(t=>e(t.getRef(aV))),fV=e=>dV(t=>t.sleep(eI(e))),pV=dV(e=>e.currentTimeMillis),mV=dV(e=>e.monotonicTimeNanos),hV=`~effect/Cause/TimeoutError`;var gV=class extends vP(`TimeoutError`){[hV]=hV;constructor(e){super({message:e})}};const _V=`~effect/Cause/IllegalArgumentError`;var vV=class extends vP(`IllegalArgumentError`){[_V]=_V;constructor(e){super({message:e})}};const yV=`~effect/Cause/AsyncFiberError`;var bV=class extends vP(`AsyncFiberError`){[yV]=yV;constructor(e){super({message:`An asynchronous Effect was executed with Effect.runSync`,fiber:e})}};const xV=`~effect/Cause/UnknownError`;var SV=class extends vP(`UnknownError`){[xV]=xV;constructor(e,t){super({message:t,cause:e})}};const CV=xF(`effect/Console`,{defaultValue:()=>globalThis.console}),wV=HP(cie(BP,e=>{switch(e){case`All`:return-(2**53-1);case`Fatal`:return 5e4;case`Error`:return 4e4;case`Warn`:return 3e4;case`Info`:return 2e4;case`Debug`:return 1e4;case`Trace`:return 0;case`None`:return 2**53-1}})),TV=xF(`effect/Logger/CurrentLoggers`,{defaultValue:()=>new Set([PV,FV])}),EV=xF(`effect/Logger/LogToStderr`,{defaultValue:Bj}),DV={"~effect/Logger":{_Message:R,_Output:R},pipe(){return Fj(this,arguments)}},OV=e=>{let t=Object.create(DV);return t.log=e,t},kV=e=>e.replace(/[\s="]/g,`_`),AV=(e,t)=>`${kV(e[0])}=${t-e[1]}ms`,jV=e=>(...t)=>{let n;for(let e=0,r=t.length;e<r;e++){let r=t[e];VN(r)&&(n?t.splice(e,1):t=t.slice(0,e).concat(t.slice(e+1)),n=n?qN(n.reasons.concat(r.reasons)):r,e--)}return n===void 0&&(n=ZN),hP(r=>{let i=e??r.cache.logLevel;if(wV(r.cache.minimumLogLevel,i))return rR;let a=r.getRef(aV),o=r.getRef(TV);if(o.size>0){let e=new Date(a.currentTimeMillisUnsafe());for(let a of o)a.log({cause:n,fiber:r,date:e,logLevel:i,message:t})}return rR})},MV={bold:`1`,red:`31`,green:`32`,yellow:`33`,blue:`34`,cyan:`36`,white:`37`,gray:`90`,black:`30`,bgBrightRed:`101`};MV.gray,MV.blue,MV.green,MV.yellow,MV.red,MV.bgBrightRed,MV.black;const NV=e=>`${e.getHours().toString().padStart(2,`0`)}:${e.getMinutes().toString().padStart(2,`0`)}:${e.getSeconds().toString().padStart(2,`0`)}.${e.getMilliseconds().toString().padStart(3,`0`)}`,PV=OV(({cause:e,date:t,fiber:n,logLevel:r,message:i})=>{let a=Array.isArray(i)?i.slice():[i];e.reasons.length>0&&a.push(EL(e));let o=t.getTime(),s=n.getRef(iL),c=``;for(let e of s)c+=` ${AV(e,o)}`;let l=n.getRef(tL);Object.keys(l).length>0&&a.push(l);let u=n.getRef(CV);(n.getRef(EV)?u.error:u.log)(`[${NV(t)}] ${r.toUpperCase()} (#${n.id})${c}:`,...a)}),FV=OV(({cause:e,fiber:t,logLevel:n,message:r})=>{let i=t.getRef(aV),a=t.getRef(tL),o=t.cache.span;if(o===void 0||o._tag===`ExternalSpan`||o.status._tag===`Ended`)return;let s={};for(let[e,t]of Object.entries(a))wN(s,e,t);s[`effect.fiberId`]=t.id,s[`effect.logLevel`]=n.toUpperCase(),e.reasons.length>0&&(s[`effect.cause`]=EL(e)),o.event(_N(Array.isArray(r)&&r.length===1?r[0]:r),i.currentTimeNanosUnsafe(),s)}),IV={"~effect/Deferred":{_A:R,_E:R},pipe(){return Fj(this,arguments)}},LV=function(){this.resumes=void 0,this.effect=void 0};LV.prototype=IV;const RV=()=>new LV,zV=()=>YL(()=>RV()),BV=e=>cR(t=>e.effect?t(e.effect):(e.resumes??=[],e.resumes.push(t),YL(()=>{let n=e.resumes;if(n===void 0)return;let r=n.indexOf(t);r>=0&&n.splice(r,1)}))),VV=L(2,(e,t)=>YL(()=>qV(e,t))),HV=L(2,(e,t)=>VV(e,pP(t))),UV=e=>YL(()=>WV(e)),WV=e=>e.effect!==void 0;function GV(e){return YL(()=>YP(e.effect))}const KV=L(2,(e,t)=>VV(e,lP(t))),qV=(e,t)=>{if(e.effect)return!1;if(e.effect=t,e.resumes){let n=e.resumes;e.resumes=void 0;for(let e=0;e<n.length;e++)n[e](t)}return!0},JV=L(2,(e,t)=>TB(n=>NR(jz(n(e)),e=>VV(t,e)))),YV=rL,XV=zz,ZV=Zz,QV=tB,$V=qz,eH=Jz,tH=Gz,nH=Kz,rH=Bz,iH=`~effect/Layer/MemoMap`,aH=(e,t)=>{let n={observers:0,deferred:RV(),scope:ZV(),finalizer:r=>XL(()=>--n.observers>0?rR:(e.map.delete(t),rH(n.scope,r)))};return n},oH=(e,t)=>t.state._tag!==`Closed`&&(e.observers++,Yz(t,{},e.finalizer),!0),sH={"~effect/Layer":{_ROut:R,_E:R,_RIn:R},pipe(){return Fj(this,arguments)}},cH=e=>{let t=Object.create(sH);return t.build=e,t},lH=e=>cH((t,n)=>{let r=nH(n);return lB(e(t,r),e=>e._tag===`Failure`?rH(r,e):rR)}),uH=e=>{let t=lH((n,r)=>n.getOrElseMemoize(t,r,e));return t};var dH=class{get[iH](){return iH}parent;constructor(e){this.parent=e}map=new Map;get(e,t){let n=this.map.get(e);return n?(oH(n,t),n.deferred.effect??BV(n.deferred)):this.parent?.get(e,t)}getOrElseMemoize(e,t,n){return XL(()=>{let r;return sB(XL(()=>{let i=this.get(e,t);if(i)return i;let a=aH(this,e);return oH(a,t)?(r=a.deferred,this.map.set(e,a),n(this,a.scope)):n(this,t)}),e=>{r&&qV(r,e)})})}};const fH=()=>new dH,pH=e=>new dH(e);var mH=class e extends $P()(`effect/Layer/CurrentMemoMap`){static forkOrCreate(t){let n=mF(t,e);return n?pH(n):fH()}};const hH=L(3,(e,t,n)=>az(LR(XL(()=>e.build(t,n)),pF(mH,t)),mH,t)),gH=L(2,(e,t)=>hP(n=>hH(e,mH.forkOrCreate(n.context),t))),_H=function(){return arguments.length===1?e=>vH(fF(arguments[0],e)):vH(fF(arguments[0],arguments[1]))},vH=e=>cH(Rj(U(e))),yH=function(){return arguments.length===1?e=>bH(arguments[0],e):bH(arguments[0],arguments[1])},bH=(e,t)=>xH(LR(t,t=>fF(e,t))),xH=e=>uH((t,n)=>QV(e,n)),SH=(e,t,n)=>{let r=nH(n,`parallel`);return OB(e,e=>e.build(t,nH(r,`sequential`)),{concurrency:e.length}).pipe(LR(e=>wie(...e)))},CH=(...e)=>uH((t,n)=>SH(e,t,n)),wH=(e,t,n)=>uH((r,i)=>NR(Array.isArray(t)?SH(t,r,i):t.build(r,i),t=>e.build(r,i).pipe(iz(t),LR(e=>n(e,t))))),TH=L(2,(e,t)=>wH(e,t,(e,t)=>bF(t,e))),EH=lP,DH=fP,OH=pP,kH=KR,AH=VR,jH=HR,MH=ZR,NH=VN,PH=nP,FH=qN,IH=QN,LH=eP,RH=hL,zH=gL,BH=_L,VH=uL,HH=EL,UH=bP,WH=SP,GH=Yre,KH=vV,qH=SV,JH=pV,YH=mV,XH=`~effect/DateTime`,ZH=`~effect/DateTime/TimeZone`,QH={[XH]:XH,pipe(){return Fj(this,arguments)},[hN](){return this.toString()},toJSON(){return sU(this).toJSON()}},$H={...QH,_tag:`Utc`,[gM](){return CM(this.epochMilliseconds)},[FM](e){return tU(e)&&e._tag===`Utc`&&this.epochMilliseconds===e.epochMilliseconds},toString(){return`DateTime.Utc(${sU(this).toJSON()})`}};({...QH});const eU={[ZH]:ZH,[hN](){return this.toString()}};({...eU}),{...eU};const tU=e=>z(e,XH),nU=e=>{let t=Object.create($H);return t.epochMilliseconds=e,Object.defineProperty(t,"partsUtc",{value:void 0,enumerable:!1,writable:!0}),t},rU=e=>{let t=e.getTime();if(Number.isNaN(t))throw new KH(`Invalid date`);return nU(t)},iU=e=>{if(tU(e))return e;if(e instanceof Date)return rU(e);if(typeof e==`object`){if(`epochMilliseconds`in e)return rU(new Date(e.epochMilliseconds));let t=new Date(0);return cU(t,e),rU(t)}return typeof e==`string`&&!aU(e)?rU(new Date(e+`Z`)):rU(new Date(e))},aU=e=>/Z|GMT|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e)||/z$|gmt$/i.test(e),oU=LR(JH,nU),sU=e=>new Date(e.epochMilliseconds),cU=(e,t)=>{if((t.year!==void 0||t.month!==void 0||t.day!==void 0)&&e.setUTCFullYear(t.year??e.getUTCFullYear(),t.month===void 0?e.getUTCMonth():t.month-1,t.day??e.getUTCDate()),t.weekDay!==void 0){let n=t.weekDay-e.getUTCDay();e.setUTCDate(e.getUTCDate()+n)}t.hour!==void 0&&e.setUTCHours(t.hour),t.minute!==void 0&&e.setUTCMinutes(t.minute),t.second!==void 0&&e.setUTCSeconds(t.second),t.millisecond!==void 0&&e.setUTCMilliseconds(t.millisecond)},lU=e=>sU(e).toISOString();globalThis.Number;const uU=L(2,(e,t)=>{let n=10**t;return Math.round(e*n)/n}),dU=(e,t,n)=>{let r=n*(t-e)+e;if(r!==t||e>=t||!Number.isFinite(t))return r;if(t===0)return-Number.MIN_VALUE;let i=new DataView(new ArrayBuffer(8));i.setFloat64(0,t);let a=i.getBigUint64(0);return i.setBigUint64(0,t>0?a-BigInt(1):a+BigInt(1)),i.getFloat64(0)},fU=L(2,(e,t)=>dz(e,gU,e=>t(e))),pU=e=>e.reasons.some(mU),mU=e=>e._tag===`Fail`&&UH(e.error),hU=e=>{let t,n=!1;for(let r of e.reasons)mU(r)?t??=r.error:r._tag!==`Interrupt`&&(n=!0);return t===void 0?TF(e):n?TF(FH(e.reasons.filter(e=>!mU(e)))):wF(t)},gU=e=>{let t=hU(e);return EF(t)?t:wF(t.success.value)},_U=e=>{let t=hU(e);return EF(t)?DH(t.failure):EH(t.success.value)},vU=L(2,(e,t)=>Cz(e,{onSuccess:t.onSuccess,onFailure:e=>{let n=hU(e);return EF(n)?t.onFailure(n.failure):t.onDone(n.success.value)}})),yU=`~effect/Schedule`,bU=xF(`effect/Schedule/CurrentMetadata`,{defaultValue:Rj({input:void 0,output:void 0,duration:sI,attempt:0,start:0,now:0,elapsed:0,elapsedSincePrevious:0})}),xU={[yU]:{_Out:R,_In:R,_Env:R},pipe(){return Fj(this,arguments)}},SU=e=>z(e,yU),CU=e=>{let t=Object.create(xU);return t.step=e,t},wU=()=>{let e=0,t,n;return(r,i)=>{n===void 0&&(n=r);let a=r-n,o=t===void 0?0:r-t;return t=r,{input:i,attempt:++e,start:n,now:r,elapsed:a,elapsedSincePrevious:o}}},TU=e=>CU(LR(e,e=>{let t=wU();return(n,r)=>e(t(n,r))})),EU=e=>cz(e.step,e=>U(()=>qL(e))),DU=e=>dV(t=>LR(EU(e),e=>{let n=wU();return r=>XL(()=>{let i=t.currentTimeMillisUnsafe();return NR(e(i,r),([e,t])=>{let a=n(i,r);return a.output=e,a.duration=t,gR(fV(t),a)})})})),OU=e=>CU(LR(EU(e),e=>(t,n)=>vU(e(t,n),{onSuccess:e=>U([n,e[1]]),onFailure:qL,onDone:()=>GH(n)}))),kU=e=>{let t=eI(e);return TU(U(e=>U([e.attempt-1,t])))},AU=L(2,(e,t)=>CU(LR(EU(e),e=>{let n=wU();return(r,i)=>NR(e(r,i),e=>{let[a,o]=e,s=t({...n(r,i),output:a,duration:o});return NR(LN(s)?s:U(s),t=>t?U(e):GH(a))})}))),jU=kU(sI),MU=(e,t,n)=>rB(r=>NR(n?.local?hH(t,fH(),r):gH(t,r),t=>iz(e,t))),NU=L(e=>LN(e[0]),(e,t,n)=>lF(t)?iz(e,t):MU(e,Array.isArray(t)?CH(...t):t,n)),PU=L(3,(e,t,n)=>NR(DU(t),t=>{let r=bU.defaultValue(),i=n=>vU(t(n),{onSuccess(t){return r=t,NR(az(e,bU,r),i)},onFailure:qL,onDone:U});return dz(NR(az(e,bU,r),i),pL,e=>n(e,r.attempt===0?V():UP(r)))})),FU=L(2,(e,t)=>{let n=typeof t==`function`?t(R):SU(t)?t:LU(t);return PU(e,n,JL)}),IU=OU(jU),LU=e=>{let t=e.schedule?OU(e.schedule):IU;return e.while&&(t=AU(t,({input:t})=>{let n=e.while(t);return LN(n)?n:U(n)})),e.until&&(t=AU(t,({input:t})=>{let n=e.until(t);return LN(n)?LR(n,e=>!e):U(!n)})),e.times!==void 0&&(t=AU(t,({attempt:t})=>U(t<=e.times))),t},RU=LN,zU=EB,BU=OB,VU=DB,HU=aR,W=U,UU=XL,G=YL,WU=rR,GU=cR,KU=lR,qU=uR,K=JL,JU=nR,YU=qL,XU=eR,ZU=tR,QU=iR,$U=hP,eW=ZL,q=NR,tW=IR,nW=OR,rW=kR,iW=jz,J=LR,aW=gR,oW=AR,sW=fz,cW=_z,lW=vz,uW=cz,dW=hz,fW=gz,pW=yz,mW=bz,hW=mz,gW=xz,_W=Fz,vW=Nz,yW=fV,bW=MR,xW=kz,SW=Cz,CW=Oz,wW=tz,TW=rz,EW=NU,DW=iz,OW=QR,kW=az,AW=eB,jW=nB,MW=rB,NW=iB,PW=pB,FW=aB,IW=uB,LW=fB,RW=sB,zW=lB,BW=gB,VW=_B,HW=vB,UW=TB,WW=sz,GW=FU,KW=iV,qW=LB,JW=RB,YW=VB,XW=zB,ZW=HB,QW=UB,Y=dR,$W=dV,eG=(e,t,n)=>(...r)=>GU(i=>{let a=!0,o;try{e(...r,(e,n)=>{let s=e?t?UU(()=>K(t(e,r))):K(e):W(n);a?o??=s:i(s)})}catch(e){o=n?K(n(e,r)):ZU(e)}a=!1,o&&i(o)}),tG=RR,nG=zR,rG=FR,iG=pR,aG=globalThis.BigInt,oG=e=>e>aG(2**53-1)||e<aG(-(2**53-1))?V():UP(Number(e)),sG=BigInt(0),cG=BigInt(1),lG=BigInt(1e3),uG=BigInt(1024),dG=[{symbol:`B`,factor:cG,names:[`B`,`byte`,`bytes`]},{symbol:`kB`,factor:lG,names:[`kB`,`kilobyte`,`kilobytes`]},{symbol:`MB`,factor:lG**BigInt(2),names:[`MB`,`megabyte`,`megabytes`]},{symbol:`GB`,factor:lG**BigInt(3),names:[`GB`,`gigabyte`,`gigabytes`]},{symbol:`TB`,factor:lG**BigInt(4),names:[`TB`,`terabyte`,`terabytes`]},{symbol:`PB`,factor:lG**BigInt(5),names:[`PB`,`petabyte`,`petabytes`]},{symbol:`EB`,factor:lG**BigInt(6),names:[`EB`,`exabyte`,`exabytes`]},{symbol:`ZB`,factor:lG**BigInt(7),names:[`ZB`,`zettabyte`,`zettabytes`]},{symbol:`YB`,factor:lG**BigInt(8),names:[`YB`,`yottabyte`,`yottabytes`]},{symbol:`RB`,factor:lG**BigInt(9),names:[`RB`,`ronnabyte`,`ronnabytes`]},{symbol:`QB`,factor:lG**BigInt(10),names:[`QB`,`quettabyte`,`quettabytes`]}],fG=[dG[0],{symbol:`KiB`,factor:uG,names:[`KiB`,`kibibyte`,`kibibytes`]},{symbol:`MiB`,factor:uG**BigInt(2),names:[`MiB`,`mebibyte`,`mebibytes`]},{symbol:`GiB`,factor:uG**BigInt(3),names:[`GiB`,`gibibyte`,`gibibytes`]},{symbol:`TiB`,factor:uG**BigInt(4),names:[`TiB`,`tebibyte`,`tebibytes`]},{symbol:`PiB`,factor:uG**BigInt(5),names:[`PiB`,`pebibyte`,`pebibytes`]},{symbol:`EiB`,factor:uG**BigInt(6),names:[`EiB`,`exbibyte`,`exbibytes`]},{symbol:`ZiB`,factor:uG**BigInt(7),names:[`ZiB`,`zebibyte`,`zebibytes`]},{symbol:`YiB`,factor:uG**BigInt(8),names:[`YiB`,`yobibyte`,`yobibytes`]}],pG=[...dG,...fG.slice(1)],mG=new Map(pG.flatMap(e=>e.names.map(t=>[t,e]))),hG=e=>e,gG=e=>{throw Error(`Invalid ByteSize: ${e}`)},_G=e=>!Number.isSafeInteger(e)||e<0?gG(`expected a non-negative safe integer, received ${e}`):hG(BigInt(e)),vG=e=>{let t=/^\s*(\d+)(?:\.(\d+))?\s*([A-Za-z]+)\s*$/.exec(e);if(t===null)return gG(`unsupported syntax ${JSON.stringify(e)}`);let n=mG.get(t[3]);if(n===void 0)return gG(`unsupported unit ${JSON.stringify(t[3])}`);let r=t[2]??``,i=BigInt(10)**BigInt(r.length),a=BigInt(t[1]+r)*n.factor;return a%i===sG?hG(a/i):gG(`${JSON.stringify(e)} does not represent an integral number of bytes`)},yG=e=>{switch(typeof e){case`bigint`:return e<sG?gG(`expected a non-negative bigint, received ${e}`):hG(e);case`number`:return _G(e);case`string`:return vG(e)}return gG(`unsupported input ${e}`)},bG=e=>typeof e==`bigint`?yG(e):_G(e),xG=`~effect/PlatformError`;var SG=class extends PI(`BadArgument`){get message(){return`${this.module}.${this.method}${this.description?`: ${this.description}`:``}`}},CG=class extends NI{get message(){return`${this._tag}: ${this.module}.${this.method}${this.pathOrDescriptor===void 0?``:` (${this.pathOrDescriptor})`}${this.description?`: ${this.description}`:``}`}},wG=class extends PI(`PlatformError`){constructor(e){`cause`in e?super({reason:e,cause:e.cause}):super({reason:e})}[xG]=xG;get message(){return this.reason.message}};const TG=e=>new wG(new CG(e)),EG=e=>new wG(new SG(e)),DG=VL,OG=UL,kG=WL,AG=PL,jG=BB,MG=qB,NG=`~effect/MutableRef`,PG={[NG]:NG,...FN,[FM](e){return this===e},[gM](){return vM(this)},toJSON(){return{_id:`MutableRef`,current:gN(this.current)}}},FG=e=>{let t=Object.create(PG);return t.current=e,t},IG=L(2,(e,t)=>(e.current=t,e)),LG=Symbol.for(`effect/MutableList/Empty`),RG=()=>({head:void 0,tail:void 0,length:0}),zG=e=>{let t=e.head;t.offset>=1024&&t===e.tail&&t.mutable&&(t.array.length-t.offset)*8<=t.offset&&(e.head=e.tail={array:t.array.slice(t.offset),mutable:!0,offset:0,next:void 0})},BG=()=>({array:[],mutable:!0,offset:0,next:void 0}),VG=(e,t)=>{e.tail?e.tail.mutable||(e.tail.next=BG(),e.tail=e.tail.next):e.head=e.tail=BG(),e.tail.array.push(t),e.length++},HG=e=>{e.head=e.tail=void 0,e.length=0},UG=(e,t)=>{if(t=CF(t),t<=0||!e.head)return[];if(t=Math.min(t,e.length),t===e.length&&e.head?.offset===0&&!e.head.next){let t=e.head.array;return HG(e),t}let n=Array(t),r=0,i=e.head;for(;i;){for(;i.offset<i.array.length;)if(n[r++]=i.array[i.offset],i.mutable&&(i.array[i.offset]=void 0),i.offset++,r===t)return e.head=i.offset===i.array.length&&i.next?i.next:i,e.length-=t,e.length===0?HG(e):zG(e),n;i=i.next}return HG(e),n},WG=e=>{if(!e.head)return LG;let t=e.head.array[e.head.offset];return e.head.mutable&&(e.head.array[e.head.offset]=void 0),e.head.offset++,e.length--,e.head.offset===e.head.array.length?e.head.next?e.head=e.head.next:HG(e):zG(e),t},GG={_A:R,_E:R},KG={"~effect/Queue":GG,"~effect/Queue/Enqueue":GG,"~effect/Queue/Dequeue":GG,...FN,toJSON(){return{_id:`effect/Queue`,state:this.state._tag,size:sK(this)}}},qG=e=>hP(t=>{let n=Object.create(KG);return n.dispatcher=t.currentDispatcher,n.capacity=e?.capacity??1/0,n.strategy=e?.strategy??`suspend`,n.messages=RG(),n.scheduleRunning=!1,n.state={_tag:`Open`,takers:new Set,offers:new Set,awaiters:new Set},U(n)}),JG=e=>qG({capacity:e}),YG=L(2,(e,t)=>XL(()=>XG(e,t)?lK:e.state._tag===`Open`&&e.strategy===`suspend`?vK(e,t):cK)),XG=(e,t)=>e.state._tag===`Open`?e.messages.length>=e.capacity?e.strategy===`sliding`?(WG(e.messages),VG(e.messages,t),!0):e.capacity<=0&&e.state.takers.size>0&&(VG(e.messages,t),fK(e),!0):(VG(e.messages,t),pK(e),!0):!1,ZG=L(2,(e,t)=>YL(()=>QG(e,t))),QG=(e,t)=>{if(e.state._tag!==`Open`)return!1;let n=fP(t),r=YR(n,uK);return e.state.offers.size===0&&e.messages.length===0?(CK(e,r),!0):(e.state={...e.state,_tag:`Closing`,exit:r},pK(e),!0)},$G=e=>QG(e,QN(SP())),eK=e=>YL(()=>tK(e)),tK=e=>{if(e.state._tag===`Done`)return!1;HG(e.messages);let t=e.state.offers;CK(e,e.state._tag===`Open`?dK:e.state.exit);for(let e of t)bK(e);return!0},nK=e=>rK(e,1,1/0),rK=L(3,(e,t,n)=>(t=CF(t),n=CF(n),hK(()=>mK(e,t,n)??OR(_K(e,()=>gK(e,t)),rK(e,t,n))))),iK=e=>hK(()=>oK(e)??OR(_K(e,()=>gK(e,1)),iK(e))),aK=e=>hK(()=>{let t=oK(e);return t===void 0?U(V()):t._tag===`Success`?U(UP(t.value)):U(V())}),oK=e=>{if(e.state._tag===`Done`)return e.state.exit;if(e.messages.length>0){let t=WG(e.messages);return SK(e),lP(t)}if(e.capacity<=0&&e.state.offers.size>0){let t=xK(e.state.offers);return SK(e),lP(t)}},sK=e=>e.state._tag===`Done`?0:e.messages.length,cK=lP(!1),lK=lP(!0),uK=pP(SP()),dK=BR(),fK=e=>{if(e.state._tag!==`Done`&&e.state.takers.size!==0){for(let t of e.state.takers)if(t.ready()&&(e.state.takers.delete(t),t.resume(KR),e.messages.length===0))break}},pK=e=>{e.scheduleRunning||e.state._tag===`Done`||e.state.takers.size===0||(e.scheduleRunning=!0,e.dispatcher.scheduleTask(()=>{e.scheduleRunning=!1,fK(e)},0))},mK=(e,t,n)=>{if(e.state._tag===`Done`)return e.state.exit;if(n<=0||t<=0)return lP([]);if(!gK(e,t))return;let r=e.messages.length>0?UG(e.messages,n):[xK(e.state.offers)];return SK(e),lP(r)},hK=sP({op:`QueueTake`,[AN](e){let t=this[B]();return RN(t)?t[AN](e):t}}),gK=(e,t)=>e.messages.length>=(e.state._tag===`Closing`?1:Math.min(t,e.capacity||1))||e.capacity<=0&&e.state._tag!==`Done`&&e.state.offers.size>0,_K=(e,t)=>cR(n=>{if(e.state._tag===`Done`)return n(e.state.exit);if(t())return n(KR);let r={ready:t,resume:n};return e.state.takers.add(r),YL(()=>{e.state._tag!==`Done`&&e.state.takers.delete(r)})}),vK=(e,t)=>cR(n=>XG(e,t)?n(lK):yK(e,{_tag:`Single`,message:t,resume:n})),yK=(e,t)=>{if(e.state._tag!==`Open`)return bK(t);let n=e.state.offers;return n.add(t),YL(()=>{e.state._tag!==`Done`&&(n.delete(t),e.state._tag===`Closing`&&n.size===0&&e.messages.length===0&&CK(e,e.state.exit))})},bK=e=>e._tag===`Single`?e.resume(cK):e.resume(lP(e.remaining.slice(e.offset))),xK=e=>{let t=e.values().next().value;if(t._tag===`Single`)return e.delete(t),t.resume(lK),t.message;let n=t.remaining[t.offset++];return t.offset===t.remaining.length&&(e.delete(t),t.resume(lP([]))),n},SK=e=>{if(e.state._tag===`Done`)return pU(e.state.exit.cause);if(e.state.offers.size===0)return e.state._tag===`Closing`&&e.messages.length===0&&(CK(e,e.state.exit),pU(e.state.exit.cause));for(let t of e.state.offers){let n=e.capacity-e.messages.length;if(n<=0)break;if(t._tag===`Single`)VG(e.messages,t.message),e.state.offers.delete(t),t.resume(lK);else{for(;t.offset<t.remaining.length;t.offset++){if(n===0)return!1;VG(e.messages,t.remaining[t.offset]),n--}e.state.offers.delete(t),t.resume(lP([]))}let r=e.state;if(r._tag===`Done`)return pU(r.exit.cause)}return!1},CK=(e,t)=>{if(e.state._tag===`Done`)return;let n=e.state;e.state={_tag:`Done`,exit:t};for(let e of n.takers)e.resume(t);n.takers.clear();for(let e of n.awaiters)e(t);n.awaiters.clear()},wK=e=>new DK(e),TK=e=>{for(let t of e.waiters)if(t.permits<=e.free)return t},EK=(e,t,n,r=R)=>hP(i=>{if(e.free>=t&&TK(e)===void 0)return e.taken+=t,n();let a={permits:t,resume:void 0},o=()=>{e.waiters.delete(a)&&e.releaseUnsafe(i,0)};e.waiters.add(a),cB(i,o);let s=r(cR(t=>{TK(e)===a?t(rR):a.resume=t})),c=NR(s,()=>TK(e)===a?(e.taken+=t,o(),n()):c);return c});var DK=class{waiters=new Set;taken=0;permits;constructor(e){this.permits=e}get free(){return this.permits-this.taken}take(e){return EK(this,e,()=>U(e))}takeIfAvailable(e){return XL(()=>this.free<e?U(!1):(this.taken+=e,U(!0)))}releaseUnsafe(e,t){return this.taken-=t,this.waiters.size>0&&e.currentDispatcher.scheduleTask(()=>{let e=this.free;for(let t of Array.from(this.waiters)){if(!this.waiters.has(t)||t.permits>e)continue;e-=t.permits;let n=t.resume;t.resume=void 0,n?.(rR)}},0),this.free}resize(e){return hP(t=>(this.permits=e,this.free<0||this.releaseUnsafe(t,0),rR))}release(e){return hP(t=>U(this.releaseUnsafe(t,e)))}get releaseAll(){return hP(e=>U(this.releaseUnsafe(e,this.taken)))}withPermits(e){return t=>TB(n=>EK(this,e,()=>sB(n(t),()=>{this.releaseUnsafe(PL(),e)},!0),n))}withPermit=this.withPermits(1);withPermitsIfAvailable(e){return t=>TB(n=>this.free<e?$L:(this.taken+=e,sB(n(DR(t)),()=>{this.releaseUnsafe(PL(),e)},!0)))}};const OK=`~effect/Channel`,kK=e=>z(e,OK),AK={[OK]:{_Env:R,_InErr:R,_InElem:R,_OutErr:R,_OutElem:R},pipe(){return Fj(this,arguments)}},jK=e=>{let t=Object.create(AK);return t.transform=(t,n)=>uW(e(t,n),e=>W(YU(e))),t},MK=(e,t)=>jK((n,r)=>q(FK(e)(n,r),e=>t(e,r))),NK=e=>jK((t,n)=>e),PK=e=>jK(Y(function*(t,n){let r=nH(n),i=e=>rH(r,_U(e)),a=yield*LW(e(t,n,r),i);return LW(a,i)})),FK=e=>e.transform,IK=(e,t,n)=>qG({capacity:n?.bufferSize,strategy:n?.strategy}).pipe(rW(t=>eH(e,eK(t))),rW(n=>QV(t(n),e).pipe(uW(e=>ZG(n,e)),qW(e,{startImmediately:!0})))),LK=(e,t)=>jK((n,r)=>J(IK(r,e,t),nK)),RK=e=>VK(W(e)),zK=NK(W(GH())),BK=NK(W(KU)),VK=e=>NK(G(()=>{let t=!1;return UU(()=>t?GH():(t=!0,e))})),HK=e=>NK(q(e,()=>GH())),UK=L(2,(e,t)=>MK(e,e=>G(()=>{let n=0;return J(e,e=>t(e,n++))}))),WK=L(2,(e,t)=>GK(e,e=>W(t(e)))),GK=L(2,(e,t)=>MK(e,e=>W(fU(e,e=>q(t(e),GH))))),KK=e=>e===void 0||e!==`unbounded`&&e<=1,qK=L(e=>kK(e[0]),(e,t,n)=>KK(n?.concurrency)?JK(e,t):YK(e,t,n)),JK=(e,t)=>jK((n,r)=>{let i=0;return J(FK(e)(n,r),q(e=>t(e,i++)))}),YK=(e,t,n)=>PK(Y(function*(r,i,a){let o=0,s=yield*FK(e)(r,i),c=n.concurrency===`unbounded`?2**53-1:Math.min(n.concurrency,2**53-1),l=yield*JG(0);yield*eH(a,eK(l));let u=XW(yield*wW()),d=jG(a);if(n.unordered){let e=wK(c),n=Rj(e.release(1)),r=SW({onFailure:e=>q(ZG(l,e),n),onSuccess:e=>q(YG(l,e),n)});yield*e.take(1).pipe(q(()=>s),q(e=>{let n=o++;return d(u(r(UU(()=>t(e,n))))),WU}),WW({disableYield:!0}),uW(t=>e.withPermits(c-1)(ZG(l,t))),qW(a))}else{let e=yield*JG(c-2);yield*eH(a,eK(e)),yield*iK(e).pipe(tW,q(e=>YG(l,e)),WW({disableYield:!0}),uW(e=>ZG(l,e)),qW(a));let n,r=e=>{e._tag!==`Success`&&(n=e.cause,QG(l,e.cause))};yield*s.pipe(q(i=>{if(n)return YU(n);let a=o++,s=u(UU(()=>t(i,a)));return d(s),s.addObserver(r),YG(e,OG(s))}),WW({disableYield:!0}),uW(t=>YG(e,DH(t)).pipe(nW(ZG(e,t)))),qW(a))}return iK(l)})),XK=e=>MK(e,e=>{let t,n=0,r=UU(function r(){if(t===void 0)return q(e,e=>{switch(e.length){case 0:return r();case 1:return W(e[0]);default:return t=e,W(e[n++])}});let i=t[n++];return n>=t.length&&(t=void 0,n=0),W(i)});return W(r)}),ZK=L(2,(e,t)=>jK((n,r)=>{let i=nH(r);return J(FK(e)(n,i),e=>{let a=e.pipe(uW(e=>{if(pU(e))return YU(e);let o=i;return i=nH(r),rH(o,DH(e)).pipe(nW(FK(t(e))(n,i)),q(e=>(a=e,e)))}));return UU(()=>a)})})),QK=L(2,(e,t)=>MK(e,e=>W(hW(e,e=>UH(e)?WU:oW(t(e)))))),$K=L(e=>kK(e[0])&&kK(e[1]),(e,t,n)=>PK(Y(function*(r,i,a){let o=n?.haltStrategy??`both`,s=yield*JG(0);yield*eH(a,eK(s));let c=0;function l(e,t){if(c++,!pU(t))return ZG(s,t);switch(o){case`both`:return c===2?ZG(s,t):WU;case`left`:case`right`:return e===o?ZG(s,t):WU;case`either`:return ZG(s,t)}}let u=(e,t,n)=>FK(t)(r,n).pipe(q(e=>e.pipe(q(e=>YG(s,e)),WW)),LW(t=>RW(_U(t),e=>rH(n,e)).pipe(SW({onFailure:t=>l(e,t),onSuccess:()=>l(e,t)}))),qW(a));return yield*u(`left`,e,nH(a)),yield*u(`right`,t,nH(a)),iK(s)}))),eq=L(2,(e,t)=>$K(e,HK(t),{haltStrategy:`left`})),tq=()=>jK((e,t)=>G(()=>{let t=``,n=!1,r=V();function i(e){let r=[];function i(e){t.length===0?r.push(e):(r.push(t+e),t=``)}for(let r=0;r<e.length;r++){let a=e[r];if(a.length!==0){let e=0,r=a.indexOf(`\r`),o=a.indexOf(`
|
|
338
|
+
`);for(n&&=(o===0&&(e=1,o=a.indexOf(`
|
|
339
|
+
`,e)),!1);r!==-1||o!==-1;)r===-1||o!==-1&&o<r?(i(a.substring(e,o)),e=o+1,o=a.indexOf(`
|
|
340
|
+
`,e)):(i(a.substring(e,r)),a.length===r+1?(n=!0,e=a.length,r=-1):(e=r+(o===r+1?2:1),r=a.indexOf(`\r`,e),o=a.indexOf(`
|
|
341
|
+
`,e)));t+=a.substring(e)}}return MF(r)?r:null}let a=UU(()=>r._tag===`Some`?GH(r.value):vU(e,{onSuccess:o,onFailure:YU,onDone:e=>{if(r=UP(e),t.length>0){let e=t;return t=``,n=!1,W([e])}return GH(e)}}));function o(e){let t=i(e);return t===null?a:W(t)}return a})),nq=(e,t)=>jK((n,r)=>G(()=>{let r=new TextDecoder(e,t),i={stream:!0},a=n.pipe(J(IF(e=>r.decode(e,i))),fU(e=>{a=GH(e);let t=r.decode();return t.length>0?W(FF(t)):a}));return UU(()=>a)})),rq=L(2,(e,t)=>jK((n,r)=>q(FK(e)(n,r),e=>FK(t)(e,r)))),iq=e=>e._tag===`Die`&&UH(e.defect)&&NH(e.defect.value),aq=e=>e.reasons.some(iq),oq=e=>uW(e,e=>pU(e)?YU(e):ZU(WH(e))),sq=e=>aq(e)?FH(e.reasons.flatMap(e=>iq(e)?e.defect.value.reasons:[e])):e,cq=e=>uW(e,e=>YU(sq(e))),lq=e=>jK((t,n)=>{let r;return W(UU(()=>r||e.pipe(QV(n),q(e=>FK(e)(t,n)),q(e=>r=e))))}),uq=(e,t,n)=>UU(()=>{let r=ZV(),i=FK(e)(GH(),r);return fU(q(i,t),n||W).pipe(zW(e=>rH(r,e)))}),dq=e=>uq(e,e=>WW(e,{disableYield:!0})),fq=L(3,(e,t,n)=>UU(()=>{let r=t();return uq(e,e=>VU({while:zj,body:()=>e,step:e=>{r=n(r,e)}}),()=>W(r))})),pq=Y(function*(e){let t=wK(1),n=yield*wW(),r=_F(n,XV);return(yield*FK(e)(GH(),r)).pipe(DW(n),t.withPermits(1))},uW(e=>W(YU(e)))),mq=(e,t)=>FK(e)(GH(),t),hq={_R:R,_E:R,_A:R},gq=function(e){this.channel=e};gq.prototype={"~effect/Stream":hq,pipe(){return Fj(this,arguments)}};const _q=e=>new gq(e),vq=`~effect/Sink`,yq=W([void 0]),bq={_A:R,_In:R,_L:R,_E:R,_R:R},xq={[vq]:bq,pipe(){return Fj(this,arguments)}},Sq=e=>z(e,vq),Cq=e=>wq((t,n)=>FK(e)(t,n).pipe(q(WW({disableYield:!0})),fU(W))),wq=e=>{let t=Object.create(xq);return t.transform=e,t},Tq=e=>jK((t,n)=>W(q(e.transform(t,n),GH))),Eq=wq(e=>fU(WW(e,{disableYield:!0}),()=>yq)),Dq=e=>Oq(BU(t=>e(t),{discard:!0})),Oq=e=>wq(t=>t.pipe(q(e),WW({disableYield:!0}),fU(()=>yq))),kq=e=>Cq(lq(J(e,Tq))),Aq={_tag:`Empty`},jq={_tag:`Closed`},Mq={_A:R,_E:R};var Nq=class{"~effect/RcRef"=Mq;pipe(){return Fj(this,arguments)}state=Aq;acquire;context;scope;idleTimeToLive;constructor(e,t,n,r){this.acquire=e,this.context=t,this.scope=n,this.idleTimeToLive=r}};const Pq=e=>$U(t=>{let n=t.context,r=_F(n,XV),i=new Nq(e.acquire,n,r,e.idleTimeToLive===void 0?void 0:eI(e.idleTimeToLive));return aW($V(r,()=>{let e=i.state;return i.state=jq,e._tag===`Acquired`?rH(e.scope,kH):e._tag===`Acquiring`?kG(e.fiber):WU}),i)}),Fq=(e,t)=>{switch(e.state._tag){case`Closed`:return VW;case`Acquired`:{let t=e.state;return t.refCount++,t.fiber?aW(kG(t.fiber),t):W(t)}case`Acquiring`:{let n=e.state;return n.awaiters++,Iq(e,n,t)}case`Empty`:{let n={_tag:`Acquiring`,fiber:void 0,awaiters:1,acquired:void 0};e.state=n;let r=ZV(),i=DW(e.acquire,pF(e.context,XV,r)).pipe(q(t=>{if(e.state!==n)return VW;let i={_tag:`Acquired`,value:t,scope:r,fiber:void 0,refCount:n.awaiters,invalidated:!1};return e.state=i,n.acquired=i,W(i)}),zW(t=>AH(t)?WU:(e.state===n&&(e.state=Aq),rH(r,t))));return n.fiber=XW(AG().context)(i),Iq(e,n,t)}}},Iq=(e,t,n)=>zW(n(OG(t.fiber)),n=>{let r=t.acquired;return r===void 0?--t.awaiters>0||e.state!==t?WU:(e.state=Aq,kG(t.fiber)):jH(n)?Rq(e,r):WU}),Lq=e=>{let t=e;return UW(e=>q(AW,n=>q(Fq(t,e),e=>aW($V(n,()=>Rq(t,e)),e.value))))},Rq=(e,t)=>{if(t.refCount--,t.refCount>0)return WU;let n=e.idleTimeToLive;return n===void 0||t.invalidated?(e.state===t&&(e.state=Aq),rH(t.scope,kH)):(oI(n)&&(t.fiber=UW(r=>q(r(yW(n)),()=>e.state===t&&t.refCount===0?(e.state=Aq,rH(t.scope,kH)):WU)).pipe(IW(G(()=>{t.fiber=void 0})),XW(e.context),jG(e.scope))),WU)},zq=Pq,Bq=Lq,Vq=e=>z(e,`~effect/Stream`),Hq=_q,Uq=e=>Hq(NK(e)),Wq=(e,t)=>Hq(jK((n,r)=>q(mq(e.channel,r),e=>t(e,r)))),Gq=e=>e.channel,Kq=(e,t)=>Hq(LK(e,t)),qq=Hq(zK),Jq=(...e)=>Yq(e),Yq=e=>MF(e)?Hq(RK(e)):qq,Xq=Hq(BK),Zq=e=>Hq(lq(J(e,Gq))),Qq=L(e=>Vq(e[0]),(e,t,n)=>e.channel.pipe(XK,qK(t,n),UK(FF),Hq)),$q=L(e=>Vq(e[0]),(e,t,n)=>Qq(e,e=>aW(t(e),e),n)),eJ=L(2,(e,t)=>nJ(e,dJ(t))),tJ=L(e=>Vq(e[0])&&Vq(e[1]),(e,t,n)=>Hq($K(Gq(e),Gq(t),n))),nJ=L(2,(e,t)=>e.channel.pipe(eq(t),Hq)),rJ=L(2,(e,t)=>e.channel.pipe(ZK(e=>t(e).channel),Hq)),iJ=L(2,(e,t)=>e.channel.pipe(QK(t),Hq)),aJ=L(2,(e,t)=>Wq(e,(e,n)=>G(()=>{let r,i,a=UU(()=>{if(i!==void 0){let e=i;return i=void 0,W(e)}return e}).pipe(sW(e=>(r=OH(e),GH()))),o=J(UU(()=>t.transform(a,n)),([e,t])=>(i=t,FF(e)));return UU(()=>r||o)}))),oJ=L(e=>Vq(e[0]),(e,t)=>e.channel.pipe(rq(nq(t?.encoding)),Hq)),sJ=e=>e.channel.pipe(rq(tq()),Hq),cJ=L(2,(e,t)=>MW(n=>mq(e.channel,n).pipe(q(e=>lJ(t,e,n)),J(([e])=>e)))),lJ=(e,t,n)=>cq(e.transform(oq(t),n)),uJ=e=>fq(e.channel,()=>[],(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n]);return e}),dJ=e=>dq(e.channel),fJ=e=>pq(e.channel),pJ=e=>fq(e.channel,()=>``,(e,t)=>e+t.join(``)),mJ=`~effect/FileSystem`,hJ=$P(`effect/FileSystem`),gJ=e=>hJ.of({...e,[mJ]:mJ,exists:t=>Uj(e.access(t),aW(!0),cW(`PlatformError`,e=>e.reason._tag===`NotFound`?W(!1):K(e))),readFileString:(t,n)=>q(e.readFile(t),e=>QU({try:()=>new TextDecoder(n).decode(e),catch:e=>EG({module:`FileSystem`,method:`readFileString`,description:`invalid encoding`,cause:e})})),stream:Y(function*(t,n){let r=yield*e.open(t,{flag:`r`}),i=n?.offset===void 0?void 0:yG(n.offset);i&&(yield*r.seek(i,`start`));let a=n?.bytesToRead===void 0?void 0:yG(n.bytesToRead),o=BigInt(0),s=Number(BigInt(n?.chunkSize??65536)),c=r.readAlloc(s);return Uq(W(q(UU(()=>a!==void 0&&a<=o?GH():a!==void 0&&a-o<s?r.readAlloc(Number(a-o)):c),KP({onNone:()=>GH(),onSome:e=>(o+=BigInt(e.length),W(FF(e)))}))))},Zq),sink:(t,n)=>Uj(e.open(t,{...n,flag:n?.flag??`w`}),J(e=>Dq(t=>e.writeAll(t))),kq),writeFileString:(t,n,r)=>q(QU({try:()=>new TextEncoder().encode(n),catch:e=>EG({module:`FileSystem`,method:`writeFileString`,description:`could not encode string`,cause:e})}),n=>e.writeFile(t,n,r))}),_J=`~effect/FileSystem/File`;var vJ=class extends $P()(`effect/FileSystem/WatchBackend`){};const yJ=`~effect/Path`,bJ=$P(`effect/Path`),xJ=e=>bJ.of({...e,[yJ]:yJ,resolveWithin(t,n){if(e.parse(n).root!==``)return V();let r=e.resolve(t),i=e.resolve(r,n),a=e.relative(r,i);return a===`..`||a.startsWith(`..${e.sep}`)||e.isAbsolute(a)?V():UP(i)}});function SJ(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}const CJ=`~sentinels`,wJ=`~constructor`,TJ=Wj(e=>{let t=SJ(e)?.identifier;return typeof t==`string`?t:e.getExpected(TJ)}),EJ=Symbol(),DJ=EH,OJ=DJ(EJ),kJ=DJ(EJ),AJ=e=>e===EJ?V():UP(e),jJ=e=>e._tag===`None`?OJ:DJ(e.value),MJ=`~effect/SchemaIssue/Issue`;function NJ(e){return z(e,MJ)&&e[MJ]===MJ}function PJ(e){return Object.hasOwn(e,`input`)}var FJ=class{[MJ]=MJ;constructor(e,t){t?.reportInput===!0&&e!==EJ&&(this.input=e)}};const IJ=class extends FJ{_tag=`Filter`;filter;issue;constructor(e,t,n,r){super(n,r),this.filter=e,this.issue=t}},LJ=class extends FJ{_tag=`Encoding`;ast;issue;constructor(e,t,n,r){super(n,r),this.ast=e,this.issue=t}},RJ=class extends FJ{_tag=`Pointer`;path;issue;constructor(e,t){super(),this.path=e,this.issue=t}},zJ=class extends FJ{_tag=`MissingKey`;annotations;constructor(e){super(),this.annotations=e}},BJ=class extends FJ{_tag=`UnexpectedKey`;ast;constructor(e,t,n){super(t,n),this.ast=e}},VJ=class extends FJ{_tag=`Composite`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},HJ=class extends FJ{_tag=`InvalidType`;ast;constructor(e,t,n){super(t,n),this.ast=e}},UJ=class extends FJ{_tag=`InvalidValue`;annotations;constructor(e,t,n){super(t,n),this.annotations=e}},WJ=class extends FJ{_tag=`AnyOf`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},GJ=class extends FJ{_tag=`OneOf`;ast;successes;constructor(e,t,n,r){super(n,r),this.ast=e,this.successes=t}};function KJ(e,t,n){if(NJ(e))return e;if(typeof e==`string`)return new UJ({message:e},t,n);let r=typeof e.issue==`string`?new UJ({message:e.issue},t,n):e.issue;return new RJ(e.path,r)}function qJ(e,t,n){if(e!==void 0)return typeof e==`boolean`?e?void 0:new UJ(void 0,t,n):KJ(e,t,n)}function JJ(e,t,n,r){return Array.isArray(t)?MF(t)?t.length===1?KJ(t[0],n,r):new VJ(e,IF(t,e=>KJ(e,n,r)),n,r):void 0:qJ(t,n,r)}const YJ=e=>{let t=sY(e);if(t!==void 0)return t;switch(e._tag){case`InvalidType`:return eY(TJ(e.ast),e);case`InvalidValue`:{let t=$J(e);if(t!==void 0)return eY(t,e);let n=QJ(e);return n===void 0?`Expected a valid value`:`Invalid data ${n}`}case`MissingKey`:return`Missing key`;case`UnexpectedKey`:{let t=QJ(e);return t===void 0?`Expected no excess property`:`Unexpected key with value ${t}`}case`Forbidden`:return`Forbidden operation`;case`OneOf`:{let t=QJ(e);return t===void 0?`Expected exactly one member to match`:`Expected exactly one member to match the input ${t}`}}},XJ=e=>sY(e)??sY(e.issue);function ZJ(e){return t=>({issues:nY(t,[],e?.leafHook??YJ,e?.checkHook??XJ)})}function QJ(e){return PJ(e)?iN(e.input):void 0}function $J(e){let t=e.annotations?.expected;return typeof t==`string`?t:void 0}function eY(e,t){let n=QJ(t);return n===void 0?`Expected ${e}`:`Expected ${e}, got ${n}`}function tY(e,t){let n=t(e);if(n!==void 0||e.issue._tag!==`InvalidValue`)return n;let r=$J(e.issue);return r===void 0?eY(rY(e.filter),e):eY(r,e.issue)}function nY(e,t,n,r,i){switch(e._tag){case`Filter`:return nY(e.issue,t,n,r,i??tY(e,r));case`Encoding`:return nY(e.issue,t,n,r,i);case`Pointer`:return nY(e.issue,[...t,...e.path],n,r,i);case`Composite`:case`AnyOf`:return e._tag===`Composite`||e.issues.length>0?e.issues.flatMap(e=>nY(e,t,n,r,i)):[{path:t,message:i??sY(e)??eY(TJ(e.ast),e)}];default:return[{path:t,message:i??n(e)}]}}function rY(e){let t=e.annotations?.expected;if(typeof t==`string`)return t;switch(e._tag){case`Filter`:return`<filter>`;case`FilterGroup`:return e.checks.map(e=>rY(e)).join(` & `)}}function iY(){return e=>oY(e,``)}const aY=iY();function oY(e,t,n){let r;switch(e._tag){case`Filter`:return oY(e.issue,t,n??tY(e,XJ));case`Encoding`:return oY(e.issue,t,n);case`Pointer`:return oY(e.issue,t+sN(e.path),n);case`Composite`:case`AnyOf`:if(e._tag===`Composite`||e.issues.length>0)return e.issues.map(e=>oY(e,t,n)).join(`
|
|
342
|
+
`);r=n??sY(e)??eY(TJ(e.ast),e);break;default:r=n??YJ(e)}return t?`${r}\n at ${t}`:r}function sY(e){if(e._tag===`Pointer`||e._tag===`Composite`)return;if(e._tag===`Encoding`)return sY(e.issue);let t=(e._tag===`Filter`?e.filter.annotations:`annotations`in e?e.annotations:e.ast.annotations)?.[e._tag===`MissingKey`?`messageMissingKey`:e._tag===`UnexpectedKey`?`messageUnexpectedKey`:`message`];if(typeof t==`string`)return t}function cY(e){let t;for(let n of e.reasons){if(!PH(n)||!NJ(n.error))return;t??=n.error}return t}function lY(e,t){let n=cY(e);if(n===void 0)throw Error(t,{cause:e});return n}const uY=iU,dY=oU,fY=lU,pY=e=>hY(typeof e==`string`?vY.encode(e):e),mY=e=>{let t=bY(e),n=t.length;if(n%4!=0)return TF(new II({kind:`Decode`,module:`Base64`,input:t,message:`Length must be a multiple of 4, but is ${n}`}));let r=t.indexOf(`=`);if(r!==-1&&(r<n-2||r===n-2&&t[n-1]!==`=`))return TF(new II({kind:`Decode`,module:`Base64`,input:t,message:`Found a '=' character, but it is not at the end`}));try{let e=t.endsWith(`==`)?2:+!!t.endsWith(`=`),r=new Uint8Array(n/4*3-e);for(let e=0,i=0;e<n;e+=4,i+=3){let n=TY(t.charCodeAt(e))<<18|TY(t.charCodeAt(e+1))<<12|TY(t.charCodeAt(e+2))<<6|TY(t.charCodeAt(e+3));r[i]=n>>16,r[i+1]=n>>8&255,r[i+2]=n&255}return wF(r)}catch(e){return TF(new II({kind:`Decode`,module:`Base64`,input:t,message:e instanceof Error?e.message:`Invalid input`}))}},hY=e=>{let t=e.length,n=Uint8Array.prototype.toBase64;return t>=32&&typeof n==`function`?n.call(e):t<128?gY(e):_Y(e)},gY=e=>{let t=e.length,n=``,r=2;for(;r<t;r+=3)n+=xY[e[r-2]>>2],n+=xY[(e[r-2]&3)<<4|e[r-1]>>4],n+=xY[(e[r-1]&15)<<2|e[r]>>6],n+=xY[e[r]&63];return r===t+1&&(n+=xY[e[r-2]>>2],n+=xY[(e[r-2]&3)<<4],n+=`==`),r===t&&(n+=xY[e[r-2]>>2],n+=xY[(e[r-2]&3)<<4|e[r-1]>>4],n+=xY[(e[r-1]&15)<<2],n+=`=`),n},_Y=e=>{let t=e.length,n=new Uint8Array(Math.ceil(t/3)*4),r,i=0;for(r=2;r<t;r+=3,i+=4)n[i]=SY[e[r-2]>>2],n[i+1]=SY[(e[r-2]&3)<<4|e[r-1]>>4],n[i+2]=SY[(e[r-1]&15)<<2|e[r]>>6],n[i+3]=SY[e[r]&63];return r===t+1&&(n[i]=SY[e[r-2]>>2],n[i+1]=SY[(e[r-2]&3)<<4],n[i+2]=CY,n[i+3]=CY),r===t&&(n[i]=SY[e[r-2]>>2],n[i+1]=SY[(e[r-2]&3)<<4|e[r-1]>>4],n[i+2]=SY[(e[r-1]&15)<<2],n[i+3]=CY),yY.decode(n)},vY=new TextEncoder,yY=new TextDecoder,bY=e=>e.replace(/[\n\r]/g,``),xY=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,SY=vY.encode(xY),CY=61,wY=new Uint8Array(123).fill(255);for(let e=0;e<64;e++)wY[xY.charCodeAt(e)]=e;wY[61]=0;const TY=e=>{if(e>=wY.length||wY[e]===255)throw TypeError(`Invalid character ${String.fromCharCode(e)}`);return wY[e]},EY=e=>Object.assign(Object.create(Ij),e),DY=EY({_tag:`Passthrough`});function OY(){return DY}function kY(e){return EY({_tag:`Transform`,transform:e})}function AY(e){return EY({_tag:`TransformEffect`,transform:e})}function jY(){return kY(globalThis.String)}function MY(){return kY(globalThis.Number)}function NY(e){return AY((t,n)=>QU({try:()=>JSON.parse(t,e?.reviver),catch:()=>new UJ({expected:`a valid JSON string`},t,n)}))}function PY(e){return AY((t,n)=>QU({try:()=>{let n=JSON.stringify(t,e?.replacer,e?.space);if(n===void 0)throw TypeError(`Value cannot be represented as JSON`);return n},catch:()=>new UJ({expected:`a JSON-serializable value`},t,n)}))}function FY(){return kY(pY)}function IY(){return AY((e,t)=>nG(eW(mY(e)),()=>new UJ({expected:`a valid Base64 string`},e,t)))}const LY=`~effect/BigDecimal`,RY={[LY]:LY,[gM](){let e=KY(this);return bM(wM(String(e.value)),CM(e.scale))},[FM](e){return zY(e)&&XY(this,e)===0},toString(){return`BigDecimal(${QY(this)})`},toJSON(){return{_id:`BigDecimal`,value:String(this.value),scale:this.scale}},[hN](){return this.toJSON()},pipe(){return Fj(this,arguments)}},zY=e=>z(e,LY),BY=(e,t)=>{if(!Number.isSafeInteger(t))throw RangeError(`Scale must be a safe integer, got ${t}`);let n=Object.create(RY);return n.value=e,n.scale=t,n},VY=(e,t)=>{let n=BY(e,t);return n.normalized=n,n},HY=BigInt(0),UY=BigInt(1),WY=BigInt(10),GY=VY(HY,0),KY=e=>{if(e.normalized===void 0){if(e.value===HY)e.normalized=GY;else{let t=`${e.value}`,n=t.length;for(;t[n-1]===`0`;)n--;e.normalized=VY(BigInt(t.slice(0,n)),e.scale-(t.length-n))}}return e.normalized},qY=[UY],JY=(e,t)=>e===t?0:e<t?-1:1,YY=(e,t)=>{let n=`${e.value<HY?-e.value:e.value}`,r=`${t.value<HY?-t.value:t.value}`,i=BigInt(n.length-r.length)-BigInt(e.scale)+BigInt(t.scale);if(i!==HY)return i<HY?-1:1;let a=Math.max(n.length,r.length);return zP(n.padEnd(a,`0`),r.padEnd(a,`0`))},XY=(e,t)=>{if(e.scale===t.scale)return JY(e.value,t.value);let n=ZY(e),r=ZY(t);if(n!==r)return n<r?-1:1;if(n===0)return 0;let i=e.scale-t.scale,a=Math.abs(i);if(a>100)return n===-1?YY(t,e):YY(e,t);let o=qY[a]??=WY**BigInt(a);return i>0?JY(e.value,t.value*o):JY(e.value*o,t.value)},ZY=e=>e.value===HY?0:e.value<HY?-1:1,QY=e=>{let t=KY(e);if(Math.abs(t.scale)>=16)return $Y(t);let n=t.value<HY,r=`${n?-t.value:t.value}`,i=t.scale>0?r.padStart(t.scale+1,`0`):r.padEnd(r.length-t.scale,`0`),a=i.length-t.scale,o=t.scale>0?`${i.slice(0,a)}.${i.slice(a)}`:i;return n?`-${o}`:o},$Y=e=>{if(eX(e))return`0e+0`;let t=KY(e),n=`${t.value}`,r=t.value<HY?2:1,i=n.slice(0,r),a=n.slice(r),o=a.length-t.scale;return`${i}${a===``?``:`.${a}`}e${o>=0?`+`:``}${o}`},eX=e=>e.value===HY,tX=Symbol.for(`~effect/Schema/content`);function nX(e,t){return Object.defineProperty(e,tX,{value:t}),e}const rX=class extends Lj{_tag=`Middleware`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new rX(this.encode,this.decode)}},iX=`~effect/SchemaTransformation/Transformation`,aX=class extends Lj{[iX]=iX;_tag=`Transformation`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new aX(this.encode,this.decode)}};function oX(e){return z(e,iX)&&e[iX]===iX}const sX=e=>oX(e)?e:new aX(e.decode,e.encode);function cX(e){return new aX(kY(e.decode),kY(e.encode))}const lX=new aX(OY(),OY());function uX(){return lX}const dX=new aX(MY(),jY()),fX=e=>dM(e)&&typeof e.message==`string`,pX=e=>{let t=Object.hasOwn(e,`cause`)?Error(e.message,{cause:_X(e.cause)}):Error(e.message);return typeof e.name==`string`&&e.name!==`Error`&&(t.name=e.name),typeof e.stack==`string`&&(t.stack=e.stack),t},mX=e=>{try{let t=dN(e);return t===void 0?iN(e):JSON.parse(t)}catch{return iN(e)}},hX=(e,t,n)=>{let r={name:e.name,message:typeof e.message==`string`?e.message:``};return t?.includeStack&&typeof e.stack==`string`&&(r.stack=e.stack),!t?.excludeCause&&e.cause!==void 0&&(r.cause=n(e.cause)),r},gX=e=>{let t=new WeakSet,n=r=>{if(mM(r)){if(t.has(r))return`[Circular]`;t.add(r);let i=hX(r,e,n);return t.delete(r),i}return mX(r)};return n},_X=e=>fX(e)?pX(e):e,vX=e=>cX({decode:_X,encode:gX(e)}),yX=new aX(IY(),FY());function bX(e){return new aX(NY(e??{}),nX(PY(e),{mediaType:`application/json`,preserveSchema:e?.reviver===void 0&&e?.replacer===void 0}))}function xX(e){return t=>t._tag===e}const SX=xX(`Declaration`),CX=xX(`Never`),wX=xX(`String`),TX=xX(`Boolean`),EX=xX(`Literal`),DX=xX(`UniqueSymbol`),OX=xX(`Arrays`),kX=xX(`Objects`),AX=xX(`Suspend`),jX=class{to;transformation;constructor(e,t){this.to=e,this.transformation=t}},MX={},NX=class{isOptional;isMutable;constructorDefault;annotations;constructor(e,t,n=void 0,r=void 0){this.isOptional=e,this.isMutable=t,this.constructorDefault=n,this.annotations=r}},PX=`~effect/Schema`;var FX=class{[PX]=PX;annotations;checks;encoding;context;constructor(e=void 0,t=void 0,n=void 0,r=void 0){this.annotations=e,this.checks=t,this.encoding=n,this.context=r}toString(){return`<${this._tag}>`}};const IX=class extends FX{_tag=`Declaration`;typeParameters;run;encodingChecks;encodingRun;constructor(e,t,n,r,i,a,o,s){super(n,r,i,a),this.typeParameters=e,this.run=t,this.encodingChecks=o,this.encodingRun=s}getParser(){let e;return(t,n)=>{if(t===EJ)return OJ;e??=this.run(this.typeParameters);try{return e(t,this,n)}catch(e){return ZU(e)}}}_rebuild(e,t,n,r,i){let a=tQ(this.typeParameters,e);return a===this.typeParameters&&t===this.checks&&n===this.encodingChecks&&r===this.run&&i===this.encodingRun?this:new IX(a,r,this.annotations,t,void 0,this.context,n,i)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks,this.run,this.encodingRun)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks,this.encodingRun??this.run,this.run)}getExpected(){let e=this.annotations?.expected;return typeof e==`string`?e:`<Declaration>`}},LX=new class extends FX{_tag=`Null`;getParser(){return vQ(this,null)}getExpected(){return`null`}},RX=class extends FX{_tag=`Undefined`;getParser(){return vQ(this,void 0)}toCodecJson(){return UZ(this,[zX])}getExpected(){return`undefined`}},zX=new jX(LX,new aX(kY(()=>void 0),kY(()=>null))),BX=new RX,VX=new class extends FX{_tag=`Unknown`;getParser(){return yQ(this,uM)}getExpected(){return`unknown`}},HX=class extends FX{_tag=`Literal`;literal;constructor(e,t,n,r,i){if(super(t,n,r,i),typeof e==`number`&&!globalThis.Number.isFinite(e))throw Error(`A numeric literal must be finite, got ${iN(e)}`);this.literal=e}getParser(){return vQ(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal==`bigint`?UX(this):this}toCodecStringTree(){return typeof this.literal==`string`?this:UX(this)}getExpected(){return typeof this.literal==`string`?JSON.stringify(this.literal):globalThis.String(this.literal)}};function UX(e){let t=globalThis.String(e.literal);return UZ(e,[new jX(new HX(t),new aX(kY(()=>e.literal),kY(()=>t)))])}const WX=new class extends FX{_tag=`String`;getParser(){return yQ(this,$j)}matchPart(e,t){let n=this.checks;return n&&!t.disableChecks&&OQ(n,e,void 0,this,t)?void 0:e}getExpected(){return`string`}},GX=class extends FX{_tag=`Number`;getParser(){return yQ(this,eM)}matchKey(e,t){return this._match(CQ,e,t)}matchPart(e,t){return this._match(SQ,e,t)}_match(e,t,n){if(!e.test(t))return;let r=globalThis.Number(t);return n.disableChecks||!this.checks?r:OQ(this.checks,r,void 0,this,n)?void 0:r}toCodecJson(){return this.checks&&(KX(this.checks,`effect/schema/isFinite`)||KX(this.checks,`effect/schema/isInt`))?this:UZ(this,[RZ])}toCodecStringTree(){return this.toCodecJson()===this?UZ(this,[EQ]):UZ(this,[DQ])}getExpected(){return`number`}};function KX(e,t){return e.some(e=>e.annotations?.representation?.id===t||e._tag===`FilterGroup`&&KX(e.checks,t))}const qX=new GX,JX=new class extends FX{_tag=`Boolean`;getParser(){return yQ(this,tM)}getExpected(){return`boolean`}},YX=class extends FX{_tag=`Arrays`;isMutable;elements;rest;encodingChecks;constructor(e,t,n,r,i,a,o,s){super(r,i,a,o),this.isMutable=e,this.elements=t,this.rest=n,this.encodingChecks=s;let c=!1;for(let e=0;e<t.length;e++)if(uQ(t[e]))c=!0;else if(c)throw Error(`A required element cannot follow an optional element. ts(1257)`);if(c&&n.length>1)throw Error(`A required element cannot follow an optional element. ts(1257)`);for(let e=1;e<n.length;e++)if(uQ(n[e]))throw Error(`An optional element cannot follow a rest element. ts(1266)`)}getParser(e,t=e){let n=this,r,i,a=n.elements.length,o=Math.max(0,n.rest.length-1);function s(e,t){return t<a?r[t]:t>=e?i[t-e+1]:i[0]}let c=e=>{let{input:t,len:r,options:i}=e;if(n.rest.length===0&&r>a)for(let o=a;o<r;o++){let r=new BJ(n,t[o],i),a=new RJ([o],r);if(i.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return K(new VJ(n,[a],t,i))}return e.issues?K(new VJ(n,e.issues,t,i)):DJ(e.output)},l=(e,t)=>{let r=e.length,i={ast:n,getParser:s,input:e,len:r,tailThreshold:Math.max(a,r-o),output:[],issues:void 0,options:t},u=n.rest.length===0?a:Math.max(r,a+o),d=t.concurrency===void 0?1:AB(t.concurrency),f=d===1?QX(i,e,0,u):$X(i,e,{concurrency:d,end:u});if(!f)return c(i);if(PR(f))return rG(f,()=>c(i));let p=!0;return UU(()=>p?(p=!1,q(f,()=>c(i))):l(e,t))};return(e,a)=>{if(e===EJ)return OJ;try{return Array.isArray(e)?(r||(r=n.elements.map(e=>({ast:e,parser:t(e)})),i=n.rest.map(e=>({ast:e,parser:t(e)}))),l(e,a)):K(new HJ(n,e,a))}catch(e){return ZU(e)}}}_rebuild(e,t,n){let r=tQ(this.elements,e),i=tQ(this.rest,e);return r===this.elements&&i===this.rest&&t===this.checks&&n===this.encodingChecks?this:new YX(this.isMutable,r,i,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}getExpected(){return`array`}};function XX(e,t,n,r){if(n._tag===`Failure`)return eZ(e,e.ast,r,n);let i=n===kJ?t:n[B];if(i!==EJ)e.output[r]=i;else{let t=e.getParser(e.tailThreshold,r);if(uQ(t.ast))return;let n=new RJ([r],new zJ(t.ast.context?.annotations));if(e.options.errors===`all`)e.issues?e.issues.push(n):e.issues=[n];else return OH(new VJ(e.ast,[n],e.input,e.options))}}const ZX={onItem(e,t,n){let r=n<e.len?t:EJ;return e.getParser(e.tailThreshold,n).parser(r,e.options)},step:XX},QX=jB()(ZX),$X=NB()(ZX),eZ=(e,t,n,r)=>{if(r.cause.reasons.length===0)return r;let i=cY(r.cause);if(i===void 0)return DH(zH(r.cause,r=>new VJ(t,[new RJ([n],r)],e.input,e.options)));let a=new RJ([n],i);if(e.options.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return OH(new VJ(t,[a],e.input,e.options))},tZ=`[+-]?(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?:[Ee][+-]?\\d+)?`;function nZ(e,t,n=MX){let r,i;function a(t){switch(t._tag){case`String`:case`TemplateLiteral`:return(r??=Object.keys(e)).filter(e=>t.matchPart(e,n)!==void 0);case`Number`:return(r??=Object.keys(e)).filter(e=>t.matchKey(e,n)!==void 0);case`Symbol`:return(i??=Object.getOwnPropertySymbols(e)).filter(r=>Object.prototype.propertyIsEnumerable.call(e,r)&&t.matchKey(r,n)!==void 0);case`Union`:return[...new Set(t.types.flatMap(a))];default:return[]}}return a(bQ(hQ(t)))}const rZ=class{name;type;constructor(e,t){this.name=e,this.type=t}};function iZ(e){switch(e._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return e.types.every(iZ);default:return!1}}function aZ(e){let t=GZ(e);switch(t._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return t.types.every(aZ);default:return!1}}function oZ(e){return iZ(e)&&aZ(e)}const sZ=class{parameter;type;constructor(e,t){if(!oZ(e))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,uQ(t)||t.encoding!==void 0&&uQ(hQ(t)))throw Error("Cannot use `Schema.optionalKey` or `Schema.optional` with index signatures. Index signatures already allow keys to be absent; use `Schema.UndefinedOr` to allow `undefined` values.")}},cZ=class extends FX{_tag=`Objects`;propertySignatures;indexSignatures;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.propertySignatures=e,this.indexSignatures=t,this.encodingChecks=o}getParser(e,t=e){let n=this,r=n.propertySignatures.length,i=n.indexSignatures.length;if(!r&&!i)return yQ(n,lM);let a,o,s=()=>(a||(a=n.propertySignatures.map(e=>({parser:t(e.type),name:e.name,type:e.type})),o=i?n.indexSignatures.map(n=>({is:n,parserKey:e(bQ(n.parameter)),parserValue:t(n.type)})):void 0),a),c=()=>{let e=new Set(n.propertySignatures.map(e=>typeof e.name==`number`?globalThis.String(e.name):e.name)),t=(t,i,a,o,s)=>{if(s._tag===`Failure`)return eZ(t,n,i,s)??kH;let c=s===kJ?o:s[B];if(a!==EJ&&c!==EJ){if(r&&(e.has(i)||e.has(typeof a==`number`?globalThis.String(a):a)))return kH;wN(t.out,a,c)}return kH},c=(e,r,i,a)=>{if(!a){let t=i.parserKey(r,e.options);if(!PR(t))return q(iW(t),t=>c(e,r,i,t));a=t}if(a._tag===`Failure`)return eZ(e,n,r,a)??kH;let o=a===kJ?r:a[B],s=e.input[r],l=i.parserValue(s,e.options);return PR(l)?t(e,r,o,s,l):q(iW(l),n=>t(e,r,o,s,n))},l=(e,n,r)=>{let i=e.input[n],a=r.parserValue(i,e.options);return PR(a)?t(e,n,n,i,a):q(iW(a),r=>t(e,n,n,i,r))},u=i?NB()({onItem:(e,[t,n])=>n.is.parameter===WX?l(e,t,n):c(e,t,n),step:(e,t,n)=>n._tag===`Failure`?n:void 0}):void 0;return iG(function*(t,d){if(t===EJ)return EJ;if(typeof t!=`object`||!t||Array.isArray(t))return yield*K(new HJ(n,t,d));s();let f=t,p={},m={ast:n,input:f,out:p,issues:void 0,options:d},h=d.errors===`all`,g=d.onExcessProperty===`error`,_=d.concurrency===void 0?1:AB(d.concurrency),v=i&&g?n.indexSignatures.map(e=>nZ(f,e.parameter,d)):void 0;if(g){let r=v?new Set(e):e;if(v)for(let e of v)for(let t of e)r.add(t);let i=Reflect.ownKeys(f);for(let e=0;e<i.length;e++){let a=i[e];if(!r.has(a)&&Object.prototype.propertyIsEnumerable.call(f,a)){let e=new BJ(n,f[a],d),r=new RJ([a],e);if(h){m.issues?m.issues.push(r):m.issues=[r];continue}return yield*K(new VJ(n,[r],t,d))}}}if(r){let e=_===1?dZ(m,a):fZ(m,a,{concurrency:_});e&&(yield*e)}if(i&&_===1)for(let e=0;e<i;e++){let t=o[e],n=t.is.parameter===WX?l:c,r=v?.[e]??(t.is.parameter===WX?Object.keys(f):nZ(f,t.is.parameter,d));for(let e=0;e<r.length;e++){let i=n(m,r[e],t);if(!PR(i))yield*i;else if(i._tag===`Failure`)return yield*i}}else if(u){let e=PF();for(let t=0;t<i;t++){let n=o[t],r=v?.[t]??(n.is.parameter===WX?Object.keys(f):nZ(f,n.is.parameter,d));for(let t=0;t<r.length;t++)e.push([r[t],n])}let t=u(m,e,{concurrency:_});t&&(yield*t)}return m.issues?yield*K(new VJ(n,m.issues,t,d)):p})};if(i)return c();let l,u=(e,t,n)=>{let r=a[t];return q(iW(n),n=>{let i={...e,out:{...e.out}},o=lZ(i,r,n);if(o)return o;let s=()=>DJ(i.out),c=dZ(i,a.slice(t+1));return c?rG(c,s):s()})};return(e,t)=>{if(e===EJ)return OJ;if(t.errors===`all`||t.onExcessProperty!==void 0||t.concurrency!==void 0&&AB(t.concurrency)!==1)return(l??=c())(e,t);if(typeof e!=`object`||!e||Array.isArray(e))return K(new HJ(n,e,t));let r=s(),i=e,a={},o={ast:n,input:i,out:a,issues:void 0,options:t};try{for(let e=0;e<r.length;e++){let n=r[e],s=n.name,c=CZ(i,s),l=c?i[s]:EJ,d=n.parser(l,t);if(!PR(d))return u(o,e,d);if(d===kJ){c&&wN(a,s,l);continue}let f=lZ(o,n,d);if(f)return f}}catch(e){return ZU(e)}return DJ(a)}}_rebuild(e,t,n,r){let i=tQ(this.propertySignatures,t=>{let n=e(t.type);return n===t.type?t:new rZ(t.name,n)}),a=tQ(this.indexSignatures,n=>{let r=t(n.parameter),i=e(n.type);return r===n.parameter&&i===n.type?n:new sZ(r,i)});return i===this.propertySignatures&&a===this.indexSignatures&&n===this.checks&&r===this.encodingChecks?this:new cZ(i,a,this.annotations,n,void 0,this.context,r)}flip(e){return this._rebuild(e,e,this.encodingChecks,this.checks)}recur(e,t=e){return this._rebuild(e,t,this.checks,this.encodingChecks)}getExpected(){return this.propertySignatures.length===0&&this.indexSignatures.length===0?`object | array`:`object`}};function lZ(e,t,n){if(n._tag===`Failure`)return eZ(e,e.ast,t.name,n);if(n===kJ)return;let r=n[B];if(r!==EJ){wN(e.out,t.name,r);return}if(delete e.out[t.name],!uQ(t.type)){let n=new RJ([t.name],new zJ(t.type.context?.annotations));if(e.options.errors===`all`){e.issues?e.issues.push(n):e.issues=[n];return}return OH(new VJ(e.ast,[n],e.input,e.options))}}const uZ={onItem(e,t){if(!CZ(e.input,t.name))return t.parser(EJ,e.options);let n=e.input[t.name];return wN(e.out,t.name,n),t.parser(n,e.options)},step:lZ},dZ=jB()(uZ),fZ=NB()(uZ);function pZ(e,t){return e?t?[...e,...t]:e:t}function mZ(e,t,n){return new cZ(Reflect.ownKeys(e).map(t=>new rZ(t,e[t].ast)),[],n,t)}function hZ(e){return e.ast}function gZ(e,t,n){return new TZ(e.map(hZ),t,void 0,n)}const _Z=Gj(e=>{for(;;){if(AX(e))return VX;let t=e.encoding;if(!t)return e.recur?.(_Z,R)??e;if(t.some(e=>e.transformation._tag===`Middleware`&&e.transformation.decode!==R))return VX;e=t[t.length-1].to}});function vZ(e){switch(e._tag){case`Null`:return[`null`];case`Undefined`:return[`undefined`];case`String`:case`TemplateLiteral`:return[`string`];case`Number`:return[`number`];case`Boolean`:return[`boolean`];case`Symbol`:case`UniqueSymbol`:return[`symbol`];case`BigInt`:return[`bigint`];case`Arrays`:return[`array`];case`ObjectKeyword`:return[`object`,`array`,`function`];case`Objects`:return e.propertySignatures.length||e.indexSignatures.length?[`object`]:[`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`];case`Enum`:return Array.from(new Set(e.enums.map(([,e])=>typeof e)));case`Literal`:return[typeof e.literal];case`Union`:return Array.from(new Set(e.types.flatMap(vZ)));default:return[`null`,`undefined`,`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`]}}function yZ(e){switch(e._tag){default:return[];case`Declaration`:{let t=e.annotations?.[CJ];return Array.isArray(t)?t:[]}case`Objects`:return e.propertySignatures.flatMap(e=>{let t=e.type;if(!uQ(t)){if(EX(t))return[{key:e.name,literal:t.literal}];if(DX(t))return[{key:e.name,literal:t.symbol}]}return[]});case`Arrays`:return e.elements.flatMap((e,t)=>{if(!uQ(e)){if(EX(e))return[{key:t,literal:e.literal}];if(DX(e))return[{key:t,literal:e.symbol}]}return[]});case`Union`:{if(e.types.length===0)return[];let t=e.types.map(e=>yZ(_Z(e)));return t[0].filter(e=>t.every(t=>t.some(t=>t.key===e.key&&t.literal===e.literal)))}case`Suspend`:return yZ(e.thunk())}}const bZ=new WeakMap,xZ=Object.freeze([]),SZ=e=>e===null?`null`:Array.isArray(e)?`array`:typeof e,CZ=(e,t)=>t===`__proto__`?Object.hasOwn(e,t):t in e;function wZ(e){let t=bZ.get(e);if(t)return t;let n,r=0,i,a,o=!0,s=[];for(let t=0;t<e.length;t++){let c=e[t],l=_Z(c);if(CX(l))continue;if(EX(l)||DX(l)){a??=new Map;let e=EX(l)?l.literal:l.symbol;s[t]=e;let n=a.get(e);n||a.set(e,n=[]),n.push(t)}else o=!1;let u=yZ(l);if(u.length){n??=new Map,r++;for(let{key:e,literal:r}of u){let i=n.get(e);i||n.set(e,i=[new Map,new Set]),i[1].add(t);let a=i[0].get(r);a||i[0].set(r,a=new Set),a.add(t)}}else{i??={};let e=vZ(l);for(let n of e)(i[n]??=[]).push(t)}}let c={},l=e=>c[e]??=Object.freeze(i?.[e]??xZ);if(o&&a)a.forEach(Object.freeze),t=e=>a.get(e)??xZ;else if(n?.size===1&&!i){let[r,[i]]=n.entries().next().value,a=new Map;for(let[e,t]of i)a.set(e,Object.freeze(Array.from(t)));let o=Object.freeze(e.map((e,t)=>t));t=(e,t)=>{if(fM(e)){let n=CZ(e,r)?e[r]:void 0;if(n!==void 0)return a.get(n)??xZ;if(t)return o}return xZ}}else if(n){let e;for(let t of n)(!e||t[1][0].size>e[1][0].size)&&t[1][1].size===r&&(e=t);t=(t,r)=>{let a=SZ(t);if(!fM(t))return l(a);let o=new Set(i?.[a]),s;if(e){let[n,[i]]=e,c=CZ(t,n),u=c?t[n]:void 0;if(c&&(!r||u!==void 0)){let e=i.get(u);if(!e)return l(a);for(let t of e)o.add(t);s=n}}if(s===void 0)for(let[e,[i,a]]of n){let n=CZ(t,e),s=n?t[e]:void 0;if(n&&(!r||s!==void 0)){let e=i.get(s);if(e)for(let t of e)o.add(t)}else if(r)for(let e of a)o.add(e)}for(let[e,[i,a]]of n){if(e===s)continue;let n=CZ(t,e),c=n?t[e]:void 0;if(n&&(!r||c!==void 0)){let e=i.get(c);for(let t of o)a.has(t)&&!e?.has(t)&&o.delete(t)}}return Array.from(o).sort((e,t)=>e-t)}}else t=e=>{let t=l(SZ(e));return a?t.filter(t=>s[t]===void 0||s[t]===e):t};return bZ.set(e,t),t}const TZ=class extends FX{_tag=`Union`;types;options;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.types=e,this.options=t,this.encodingChecks=o}getParser(e,t){let n=this,r=t!==void 0,i=[],a=t=>i[t]??=e(n.types[t]),o;return(e,t)=>{if(e===EJ)return OJ;let i=(o??=wZ(n.types))(e,r);if(i.length===0)return K(new WJ(n,[],e,t));if(i.length===1){let r=a(i[0])(e,t);return r._tag===`Success`?r:PR(r)?EZ(n,r.cause,e,t):DZ(n,r,e,t)}return OZ(n,a,i,e,t)}}_rebuild(e,t,n){let r=tQ(this.types,e);return r===this.types&&t===this.checks&&n===this.encodingChecks?this:new TZ(r,this.options,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}matchPart(e,t){for(let n of this.types){let r=n.matchPart(e,t);if(r!==void 0)return r}}getExpected(e){let t=this.annotations?.expected;if(typeof t==`string`)return t;if(this.types.length===0)return`never`;let n=this.types.map(t=>{let n=hQ(t);switch(n._tag){case`Arrays`:{let t=n.elements.filter(EX);if(t.length>0)return`${MZ(n.isMutable)}[ ${t.map(t=>e(t)+NZ(t.context?.isOptional)).join(`, `)}, ... ]`;break}case`Objects`:{let t=n.propertySignatures.filter(e=>EX(e.type));if(t.length>0)return`{ ${t.map(t=>`${MZ(t.type.context?.isMutable)}${oN(t.name)}${NZ(t.type.context?.isOptional)}: ${e(t.type)}`).join(`, `)}, ... }`;break}}return e(n)});return Array.from(new Set(n)).join(` | `)}};function EZ(e,t,n,r){let i=cY(t);return i?OH(new WJ(e,[i],n,r)):DH(t)}function DZ(e,t,n,r){return uW(t,t=>EZ(e,t,n,r))}function OZ(e,t,n,r,i){let a={ast:e,parser:t,input:r,out:void 0,successes:e.options?.mode===`oneOf`?[]:void 0,issues:void 0,options:i},o=AZ(a,n);if(!o)return a.out?a.out:K(new WJ(e,a.issues??[],r,i));if(PR(o))return kZ(o,a);let s=!0;return UU(()=>s?(s=!1,kZ(o,a)):OZ(e,t,n,r,i))}function kZ(e,t){return rG(e,e=>t.out===kJ?W(t.input):t.out?t.out:K(new WJ(t.ast,t.issues??[],t.input,t.options)))}const AZ=jB()({onItem(e,t){return e.parser(t)(e.input,e.options)},step(e,t,n){if(n._tag===`Failure`){let t=cY(n.cause);if(t===void 0)return n;e.issues?e.issues.push(t):e.issues=[t]}else{if(e.out&&e.successes)return e.successes.push(e.ast.types[t]),OH(new GJ(e.ast,e.successes,e.input,e.options));if(e.out=n,e.successes)e.successes.push(e.ast.types[t]);else return kH}}}),jZ=new TZ([new HX(`Infinity`),new HX(`-Infinity`),new HX(`NaN`)]);function MZ(e){return e?``:`readonly `}function NZ(e){return e?`?`:``}const PZ=class extends Lj{_tag=`Filter`;run;annotations;aborted;constructor(e,t=void 0,n=!1){super(),this.run=e,this.annotations=t,this.aborted=n}annotate(e){return new PZ(this.run,{...this.annotations,...e},this.aborted)}abort(){return new PZ(this.run,this.annotations,!0)}and(e,t){return new FZ([this,e],t)}},FZ=class extends Lj{_tag=`FilterGroup`;checks;annotations;constructor(e,t=void 0){super(),this.checks=e,this.annotations=t}annotate(e){return new FZ(this.checks,{...this.annotations,...e})}and(e,t){return new FZ([this,e],t)}};function IZ(e,t,n=!1){return new PZ((t,n,r)=>JJ(n,e(t,n,r),t,r),t,n)}function LZ(e){return IZ(e=>globalThis.Number.isFinite(e),{expected:`a finite number`,representation:{id:`effect/schema/isFinite`,payload:null},toJsonSchema:()=>({type:`number`}),toCode:()=>({runtime:`Schema.isFinite()`}),arbitraryConstraint:{number:`finite`},...e})}const RZ=new jX(new TZ([JZ(qX,[LZ()]),jZ]),new aX(MY(),kY(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function zZ(e,t){let n=new globalThis.RegExp(e),r={source:n.source,flags:n.flags};return IZ(e=>(n.lastIndex=0,n.test(e)),{expected:`a string matching the RegExp ${r.source}`,representation:{id:`effect/schema/isPattern`,payload:r},toJsonSchema:()=>[{},!0],arbitraryConstraint:{patterns:[r]},...t})}const BZ=new WeakMap;function VZ(e,t){let n=Object.assign(Object.create(Object.getPrototypeOf(e)),e,t);return Reflect.ownKeys(t).every(e=>e===`context`||e===`encoding`)&&BZ.set(n,HZ(e)),n}function HZ(e){let t=BZ.get(e);if(t!==void 0)return t;if(e.encoding===void 0)return e;let n=Object.assign(Object.create(Object.getPrototypeOf(e)),e,{encoding:void 0});return BZ.set(e,n),n}function UZ(e,t){return e.encoding===t?e:VZ(e,{encoding:t})}function WZ(e,t){if(e.context===t)return e;let n=HZ(e);return n.context===t&&n.encoding===e.encoding?n:VZ(e,{context:t})}function GZ(e){return e.encoding?GZ(e.encoding[e.encoding.length-1].to):e}function KZ(e,t){if(e.checks){let n=e.checks[e.checks.length-1];return qZ(e,jF(e.checks.slice(0,-1),n.annotate(t)))}return VZ(e,{annotations:{...e.annotations,...t}})}function qZ(e,t){if(e._tag===`Suspend`&&t)throw Error(`Cannot add checks to Suspend`);return e.checks===t?e:VZ(e,{checks:t})}function JZ(e,t){return qZ(e,pZ(e.checks,t))}function YZ(e,t){let n=t(e.to);return n===e.to?e:new jX(n,e.transformation)}function XZ(e,t){let n=e,r=n[n.length-1],i=YZ(r,t);return i===r?e:jF(e.slice(0,e.length-1),i)}function ZZ(e){return t=>t.encoding?UZ(t,XZ(t.encoding,e)):t}function QZ(e,t){return ZZ(e=>WZ(e,t))(e)}function $Z(e,t){function n(r){if(r.encoding){let e=r.encoding[r.encoding.length-1];return t?.stopAt?.(e)?r:UZ(r,XZ(r.encoding,n))}return e(r)}return Gj(n)}function eQ(e,t,n){let r=new jX(e,t);return UZ(n,n.encoding?[...n.encoding,r]:[r])}function tQ(e,t){let n;for(let r=0;r<e.length;r++){let i=e[r],a=t(i);if(n)n[r]=a;else if(a!==i){n=Array(e.length);for(let t=0;t<r;t++)n[t]=e[t];n[r]=a}}return n??e}function nQ(e,t){return WZ(e,e.context?new NX(e.context.isOptional,e.context.isMutable,e.context.constructorDefault,{...e.context.annotations,...t}):new NX(!1,!1,void 0,t))}const rQ=Gj(e=>{let t=e.context?e.context.isOptional===!1?new NX(!0,e.context.isMutable,e.context.constructorDefault,e.context.annotations):e.context:new NX(!0,!1);return iQ(WZ(e,t))}),iQ=ZZ(rQ),aQ=Wj(e=>rQ(new TZ([e,BX])));function oQ(e,t){return WZ(e,e.context?new NX(e.context.isOptional,e.context.isMutable,t,e.context.annotations):new NX(!1,!1,t))}function sQ(e,t,n){return eQ(e,n,t)}function cQ(e){let t=[],n=[];function r(e){t.includes(e)||t.push(e)}function i(e){switch(e._tag){case`Literal`:rM(e.literal)&&r(e.literal);return;case`UniqueSymbol`:r(e.symbol);return;case`Enum`:for(let[,t]of e.enums)r(t);return;case`Never`:return;case`Union`:for(let t=0;t<e.types.length;t++)i(e.types[t]);return;default:n.push(e)}}return i(e),{literals:t,parameters:n}}function lQ(e,t){let{literals:n,parameters:r}=cQ(e);return new cZ(n.map(e=>new rZ(e,t)),r.map(e=>new sZ(e,t)))}function uQ(e){return e.context?.isOptional??!1}function dQ(e){return e.annotations?.[`~structural`]===!0||e._tag===`FilterGroup`&&e.checks.every(dQ)}function fQ(e){function t(e){return dQ(e)?[e]:e._tag===`FilterGroup`?e.checks.flatMap(t):[]}let n=e.flatMap(t);return Aie(n)?n:void 0}function pQ(e){let t=!0;function n(e){return t=t&&!e.encoding&&!AX(e),t&&`recur`in e&&e.recur(n),e}return`recur`in e&&e.recur(n),t}const mQ=Gj(e=>{let t=HZ(e);if(t!==e){let n=mQ(t);return n===t&&e.encoding===void 0?e:WZ(n,e.context)}let n=`recur`in e?e.recur(mQ):e;if(`encodingChecks`in n&&n.encodingChecks){let t=pQ(e)?n.encodingChecks:OX(n)||kX(n)||SX(n)&&n.typeParameters.length>0?fQ(n.encodingChecks):void 0;return VZ(n,{encodingChecks:void 0,checks:pZ(n.checks,t)})}return n}),hQ=Gj(e=>mQ(_Q(e)));function gQ(e,t){let n=t,r=n.length,i=n[r-1],a=[new jX(_Q(UZ(e,void 0)),n[0].transformation.flip())];for(let e=1;e<r;e++)a.unshift(new jX(_Q(n[e-1].to),n[e].transformation.flip()));let o=_Q(i.to);return o.encoding?UZ(o,[...o.encoding,...a]):UZ(o,a)}const _Q=Wj(e=>{if(e.encoding)return gQ(e,e.encoding);let t=HZ(e);if(t!==e){let n=_Q(t);return n===t?e:WZ(n,e.context)}return`flip`in e?e.flip(_Q):`recur`in e?e.recur(_Q):e});function vQ(e,t){let n=t===0?kJ:DJ(t);return(r,i)=>r===EJ?OJ:r===t?n:K(new HJ(e,r,i))}function yQ(e,t){return(n,r)=>n===EJ?OJ:t(n)?kJ:K(new HJ(e,n,r))}const bQ=$Z(e=>{switch(e._tag){default:return e;case`Number`:return e.toCodecStringTree();case`Union`:return e.recur(bQ)}}),xQ=$Z(e=>{switch(e._tag){default:return e;case`Symbol`:case`UniqueSymbol`:return e.toCodecStringTree();case`Union`:return e.recur(xQ)}}),SQ=new globalThis.RegExp(`^${tZ}$`),CQ=new globalThis.RegExp(`^(?:${tZ}|Infinity|-Infinity|NaN)$`);function wQ(e){return zZ(SQ,{expected:`a string representing a finite number`,representation:{id:`effect/schema/isStringFinite`,payload:null},toJsonSchema:()=>({pattern:SQ.source}),...e})}const TQ=JZ(WX,[wQ()]),EQ=new jX(TQ,dX),DQ=new jX(new TZ([TQ,jZ]),dX);function OQ(e,t,n,r,i){for(let a=0;a<e.length;a++){let o=e[a];if(o._tag===`FilterGroup`){if(n=OQ(o.checks,t,n,r,i),n&&(i.errors!==`all`||n[n.length-1].filter.aborted))return n}else{let e=o.run(t,r,i);if(e){let r=new IJ(o,e,t,i);if(n?n.push(r):n=[r],i.errors!==`all`||o.aborted)return n}}}return n}function kQ(e){if(!SX(e))return;let t=e.annotations?.[wJ];return iM(t)?t(e.typeParameters):void 0}function AQ(e){return e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&globalThis.Number.isFinite(e)}function jQ(e){return e===void 0||typeof e==`string`}function MQ(e,t){let n=new WeakMap,r=[];outer:for(;;){if(typeof e!=`object`||!e){if(!t(e))return!1}else{let t=e,i=n.get(t);if(i===!1)return!1;if(i===void 0){let e=Array.isArray(t);if(!e){let e=Object.getPrototypeOf(t);if(e!==null&&e!==Object.prototype&&Object.getPrototypeOf(e)!==null)return!1}n.set(t,!1),r.push({value:t,keys:e?t.length:Object.keys(t),index:0})}}for(;r.length>0;){let t=r[r.length-1],i=t.keys;if(typeof i==`number`){if(t.index<i){e=t.value[t.index++];continue outer}}else if(t.index<i.length){e=t.value[i[t.index++]];continue outer}n.set(t.value,!0),r.pop()}return!0}}function NQ(e){return MQ(e,AQ)}const PQ=new IX([],()=>(e,t,n)=>NQ(e)?kJ:K(new HJ(t,e,n)),{representation:{id:`effect/schema/Json`,payload:null},expected:`JSON value`,toCodecJson:()=>void 0,toCodecStringTree:()=>IQ});function FQ(e){return MQ(e,jQ)}const IQ=new jX(new IX([],()=>(e,t,n)=>FQ(e)?kJ:K(new HJ(t,e,n)),{expected:`StringTree`,toCodecStringTree:()=>void 0}),uX());function LQ(){return Object.assign(e=>e,{option:e=>UP(e),result:e=>wF(e),is:e=>!0})}const RQ=LQ(),zQ=LQ(),BQ=`~effect/process/ChildProcessSpawner/ChildProcessHandle`,VQ={[BQ]:BQ,...vN,toJSON(){return{_id:`ChildProcessHandle`,pid:this.pid}}},HQ=e=>Object.setPrototypeOf({...e},VQ),UQ=e=>{let t=(t,n)=>e(t).pipe(J(e=>oJ(n?.includeStderr===!0?e.all:eJ(e.stdout,e.stderr))),Zq),n=(e,n)=>sJ(t(e,n));return WQ.of({spawn:e,exitCode:t=>jW(q(e(t),e=>bW(e.exitCode,nW(dJ(e.all),KU)))),streamString:t,streamLines:n,lines:(e,t)=>uJ(n(e,t)),string:(e,n)=>pJ(t(e,n))})};var WQ=class extends $P()(`effect/process/ChildProcessSpawner`){};const GQ=`~effect/process/ChildProcess`,KQ={...CP({label:`Command`,evaluate(e){return gF(e.context,WQ).spawn(this)}}),[GQ]:GQ},qQ=(e,t,n)=>Object.assign(Object.create(KQ),{_tag:`StandardCommand`,command:e,args:t,options:n}),JQ=function(...e){if(YQ(e[0])){let[t,...n]=e,r=QQ(t,n);return qQ(r[0]??``,r.slice(1),{})}if(typeof e[0]==`object`&&!Array.isArray(e[0])&&!YQ(e[0])){let t=e[0];return function(e,...n){let r=QQ(e,n);return qQ(r[0]??``,r.slice(1),t)}}if(typeof e[0]==`string`&&!Array.isArray(e[1])){let[t,n={}]=e;return qQ(t,[],n)}let[t,n=[],r={}]=e;return qQ(t,n,r)},YQ=e=>Array.isArray(e)&&`raw`in e&&Array.isArray(e.raw),XQ=e=>{let t=/^fd(\d+)$/.exec(e);if(t===null)return;let n=parseInt(t[1],10);return n>=3?n:void 0},ZQ=e=>`fd${e}`,QQ=(e,t)=>{let n=[];for(let[r,i]of e.entries())n=$Q(e,t,n,i,r);return n},$Q=(e,t,n,r,i)=>{let a=e.raw[i];if(a===void 0)throw Error(`Invalid backslash sequence: ${e.raw[i]}`);let{hasLeadingWhitespace:o,hasTrailingWhitespace:s,tokens:c}=r$(r,a),l=i$(n,c,o);if(i===t.length)return l;let u=t[i],d=Array.isArray(u)?u.map(e=>e$(e)):[e$(u)];return i$(l,d,s)},e$=e=>typeof e==`string`?e:String(e),t$=new Set([` `,` `,`\r`,`
|
|
343
|
+
`]),n$={x:3,u:5},r$=(e,t)=>{if(t.length===0)return{tokens:[],hasLeadingWhitespace:!1,hasTrailingWhitespace:!1};let n=t$.has(t[0]),r=[],i=0;for(let n=0,a=0;n<e.length;n+=1,a+=1){let o=t[a];if(t$.has(o))i!==n&&r.push(e.slice(i,n)),i=n+1;else if(o===`\\`){let e=t[a+1];if(e===`
|
|
344
|
+
`)--n,a+=1;else if(e===`u`&&t[a+2]===`{`){let e=t.indexOf(`}`,a+3);parseInt(t.slice(a+3,e),16)>65535&&(n+=1),a=e}else a+=n$[e]??1}}let a=i===e.length;return a||r.push(e.slice(i)),{tokens:r,hasLeadingWhitespace:n,hasTrailingWhitespace:a}},i$=(e,t,n)=>n||e.length===0||t.length===0?[...e,...t]:[...e.slice(0,-1),`${e.at(-1)}${t.at(0)}`,...t.slice(1)],a$=(e,t,n)=>{let r=e.detached??n!==`win32`;return{...t,detached:r,shell:e.shell,windowsHide:e.windowsHide??!r}},o$=(e,t)=>(n,[r])=>{let i=`Unknown`;switch(n.code){case`ENOENT`:i=`NotFound`;break;case`EACCES`:case`EPERM`:i=`PermissionDenied`;break;case`EEXIST`:i=`AlreadyExists`;break;case`EISDIR`:i=`BadResource`;break;case`ENOTDIR`:i=`BadResource`;break;case`EBUSY`:i=`Busy`;break;case`ELOOP`:i=`BadResource`}return TG({_tag:i,module:e,method:t,pathOrDescriptor:r,syscall:n.syscall,cause:n})},s$=(e,t,n)=>{if(!(`closed`in e)){t(),n?.();return}let r=()=>{clearImmediate(a),e.off(`error`,r),e.off(`close`,r),n?.()},i=()=>{e.closed?r():(a=setImmediate(i),n||a.unref())},a=setImmediate(i);n||a.unref(),e.once(`error`,r),e.once(`close`,r),t(),e.closed||e.destroy()},c$=e=>Cq(WK(l$(e),e=>[e])),l$=e=>jK(t=>{let n=e.evaluate(),r=d$({...e,writable:n,pull:t});return W(e.endOnDone===!1?r:LW(r,e=>pU(e)?WU:u$(n)))}),u$=e=>GU(t=>{let n=()=>t(WU);if(e.closed){let t=oe(e,{readable:!1},()=>{t(),n()})}else s$(e,Hj,n)}),d$=e=>$U(t=>{let n=t.currentDispatcher,r=RV(),i=RV(),a=t=>qV(i,JU(()=>e.onError(t))),o=!1,s=e=>{o=!0,a(e)};e.writable.on(`error`,s);let c=oe(e.writable,{readable:!1},e=>{e?a(e):qV(r,WU)});return e.pull.pipe(q(t=>{let r=0;return GU(i=>{let o=!1,s=()=>n.scheduleTask(c,0),c=()=>{for(e.writable.off(`drain`,c),e.writable.off(`finish`,s);r<t.length;){if(o)return;if(!e.writable.write(t[r++],e.encoding,t=>{t&&(e.writable.closed?a(t):n.scheduleTask(()=>a(t),0))})){o||(e.writable.once(`drain`,c),e.writable.once(`finish`,s));return}}o||i(WU)};return c(),G(()=>{o=!0,e.writable.off(`drain`,c),e.writable.off(`finish`,s)})})}),WW({disableYield:!0}),e.endOnDone===!1?R:fU(t=>(e.writable.end(),nW(BV(r),GH(t)))),bW(BV(i)),IW(G(()=>{c();let t=()=>{e.writable.off(`error`,s),e.writable.off(`error`,t),e.writable.off(`close`,t)};e.writable.errored&&!e.writable.closed&&!o?(e.writable.once(`error`,t),e.writable.once(`close`,t)):t()})))}),f$=e=>Hq(p$(e)),p$=e=>jK((t,n)=>m$({scope:n,readable:e.evaluate(),onError:e.onError??h$,chunkSize:e.chunkSize,closeOnDone:e.closeOnDone})),m$=e=>{let t=e.readable,n=e.closeOnDone??!0,r=e.exit??FG(void 0),i=e.latch??MG(!1);function a(){i.openUnsafe()}t.on(`readable`,a);let o=oe(t,{readable:!0,writable:!1},t=>{r.current??=OH(t?e.onError(t):WH()),i.openUnsafe()}),s=UU(function n(){let a=e.readable.read(e.chunkSize);if(a===null)return r.current?r.current:t.readableEnded?K(WH()):(i.closeUnsafe(),q(i.await,n));let o=FF(a);for(;a=e.readable.read(e.chunkSize),a!==null;)o.push(a);return W(o)});return aW(eH(e.scope,G(()=>{t.off(`readable`,a),n?s$(t,o):o()})),s)},h$=e=>new qH(e),g$=e=>e instanceof globalThis.Error?e:new globalThis.Error(String(e)),_$=(e,t,n)=>{let{commands:r}=E$(n),i=r.reduce((e,t)=>{let n=`${t.command} ${t.args.join(` `)}`;return e.length===0?n:`${e} | ${n}`},``);return o$(`ChildProcess`,e)(t,[i])},v$=1e3,y$=e=>{let t=()=>{};e.on(`error`,t),e.once(`close`,()=>e.off(`error`,t))},b$=e=>e.exitCode!==null||e.signalCode!==null,x$=(e,t)=>e.options.detached!==!1||!b$(t),S$=e=>e?.code===`EPERM`,C$=(e,t)=>{if(!b$(t))return!0;if(globalThis.process.platform===`win32`||!x$(e,t))return!1;try{return globalThis.process.kill(-t.pid,0),!0}catch(e){return S$(e)}},w$=(e,t=()=>{})=>{if(b$(e)){t(null);return}De.execFile(`taskkill`,[`/pid`,String(e.pid),`/T`,`/F`],{windowsHide:!0},t)},T$=yH(WQ,qU(function*(){let e=yield*hJ,t=yield*bJ,n=Y(function*(n){if(!aM(n.cwd))return yield*e.access(n.cwd),t.resolve(n.cwd)}),r=e=>e.extendEnv?{...globalThis.process.env,...e.env}:e.env,i=e=>Vq(e)?`pipe`:e,a=e=>Sq(e)?`pipe`:e,o=e=>{let t={stream:`pipe`,encoding:`utf-8`,endOnDone:!0};return aM(e.stdin)?t:typeof e.stdin==`string`||Vq(e.stdin)?{...t,stream:e.stdin}:{stream:e.stdin.stream,encoding:e.stdin.encoding??t.encoding,endOnDone:e.stdin.endOnDone??t.endOnDone}},s=(e,t)=>{let n=e[t];return aM(n)?{stream:`pipe`}:typeof n==`string`||Sq(n)?{stream:n}:{stream:n.stream}},c=e=>{if(aM(e.additionalFds))return[];let t=[];for(let[n,r]of Object.entries(e.additionalFds)){let e=XQ(n);oM(e)&&t.push({fd:e,config:r})}return t.sort((e,t)=>e.fd-t.fd)},l=(e,t,n,r)=>{let o=[i(e.stream),a(t.stream),a(n.stream)];if(r.length===0)return o;let s=r.reduce((e,{fd:t})=>Math.max(e,t),2);for(let e=3;e<=s;e++)o[e]=`ignore`;for(let{fd:e}of r)o[e]=`pipe`;return o},u=(e,t,n)=>JW(cJ(iJ(e,e=>HV(n,e)),t)),d=Y(function*(e,t,n,r){if(n.length===0)return{getInputFd:()=>Eq,getOutputFd:()=>qq};let i=new Map,a=new Map;for(let{config:o,fd:s}of n){let n=t.stdio[s];switch(o.type){case`input`:{let t=Eq;n&&`write`in n&&(y$(n),t=c$({evaluate:()=>n,onError:t=>_$(`fromWritable(fd${s})`,g$(t),e)})),o.stream&&(yield*u(o.stream,t,r)),i.set(s,t);break}case`output`:{let t=qq;if(n&&`read`in n){let r=new ae;n.on(`error`,e=>r.destroy(e)),n.pipe(r),t=f$({evaluate:()=>r,onError:t=>_$(`fromReadable(fd${s})`,g$(t),e)})}o.sink&&(t=aJ(t,o.sink)),a.set(s,t);break}}}return{getInputFd:e=>i.get(e)??Eq,getOutputFd:e=>a.get(e)??qq}}),f=(e,t,n,r)=>UU(()=>{let i=Eq;return sM(t.stdin)&&(y$(t.stdin),i=c$({evaluate:()=>t.stdin,onError:t=>_$(`fromWritable(stdin)`,g$(t),e),endOnDone:n.endOnDone,encoding:n.encoding})),Vq(n.stream)?aW(u(n.stream,i,r),i):W(i)}),p=(e,t,n,r)=>{let i=t.stdout?(()=>{let n=new ae;return t.stdout.on(`error`,e=>n.destroy(e)),t.stdout.pipe(n),f$({evaluate:()=>n,onError:t=>_$(`fromReadable(stdout)`,g$(t),e)})})():qq,a=t.stderr?(()=>{let n=new ae;return t.stderr.on(`error`,e=>n.destroy(e)),t.stderr.pipe(n),f$({evaluate:()=>n,onError:t=>_$(`fromReadable(stderr)`,g$(t),e)})})():qq;Sq(n.stream)&&(i=aJ(i,n.stream)),Sq(r.stream)&&(a=aJ(a,r.stream));let o=tJ(i,a);return{stdout:i,stderr:a,all:o}},m=(e,t)=>GU(n=>{let r=RV(),i=De.spawn(e.command,e.args,t);return i.on(`error`,t=>{n(K(_$(`spawn`,t,e)))}),i.on(`exit`,(...e)=>{qV(r,EH(e))}),i.on(`spawn`,()=>{n(W([i,r]))}),G(()=>{i.kill(`SIGTERM`)})}),h=(e,t,n)=>globalThis.process.platform===`win32`?GU(n=>{w$(t,t=>{n(t?K(_$(`kill`,g$(t),e)):WU)})}):QU({try:()=>{globalThis.process.kill(-t.pid,n)},catch:t=>_$(`kill`,g$(t),e)}),g=(e,t)=>{if(globalThis.process.platform===`win32`){w$(e);return}try{globalThis.process.kill(-e.pid,t)}catch{}},_=(e,t,n)=>UU(()=>{if(!t.kill(n)){let t=new globalThis.Error(`Failed to kill child process`);return K(_$(`kill`,t,e))}return WU}),v=(e,t,n)=>GU(r=>{let i=Date.now()+n,a,o=()=>{clearTimeout(a),t.removeListener(`exit`,s)},s=()=>{if(clearTimeout(a),Date.now()>=i||!C$(e,t)){o(),r(WU);return}a=setTimeout(s,10)};return t.on(`exit`,s),s(),G(o)}),y=Y(function*(e,t,n,r){let i=n=>x$(e,t)?h(e,t,n).pipe(sW(r=>b$(t)&&S$(r.cause)?WU:_(e,t,n))):_(e,t,n);yield*i(r?.killSignal??`SIGTERM`),aM(r?.forceKillAfter)?(yield*BV(n),yield*v(e,t,v$)):(yield*v(e,t,hI(r.forceKillAfter)),C$(e,t)&&(yield*i(`SIGKILL`),yield*v(e,t,v$))),yield*BV(n)}),ee=(e,t)=>{let n=t??`stdout`;switch(n){case`stdout`:return e.stdout;case`stderr`:return e.stderr;case`all`:return e.all;default:{let t=XQ(n);return oM(t)?e.getOutputFd(t):e.stdout}}},b=Y(function*(e){switch(e._tag){case`StandardCommand`:{let t=o(e.options),i=s(e.options,`stdout`),a=s(e.options,`stderr`),u=c(e.options),h=!0,_=yield*n(e.options),v=r(e.options),ee=l(t,i,a,u),[b,te]=yield*NW(m(e,a$(e.options,{cwd:_,env:v,stdio:ee},process.platform)),Y(function*([t,n]){if(yield*UV(n)){let[r]=yield*BV(n);(r!==0&&sM(r)||h&&process.platform!==`win32`&&e.options.detached!==!1)&&(yield*gW(y(e,t,n,e.options)));return}h&&(yield*gW(y(e,t,n,e.options)))})),ne=zQ(b.pid);e.options.detached!==!1&&b.on(`exit`,t=>{t!==0&&sM(t)&&g(b,e.options.killSignal??`SIGTERM`)});let re=G(()=>{h||=(b.ref(),!0)}),ie=G(()=>(h&&=(b.unref(),!1),re)),ae=RV(),oe=yield*f(e,b,t,ae),{all:se,stderr:ce,stdout:x}=p(e,b,i,a),{getInputFd:le,getOutputFd:S}=yield*d(e,b,u,ae),ue=J(UV(te),e=>!e),de=q(bW(BV(te),BV(ae)),([t,n])=>{if(WV(ae))return BV(ae);if(sM(t))return W(RQ(t));let r=new globalThis.Error(`Process interrupted due to receipt of signal: '${n}'`);return K(_$(`exitCode`,r,e))});return HQ({pid:ne,exitCode:de,isRunning:ue,kill:t=>y(e,b,te,t),stdin:oe,stdout:x,stderr:ce,all:se,getInputFd:le,getOutputFd:S,unref:ie})}case`PipedCommand`:{let{commands:t,pipeOptions:n}=E$(e),[r,...i]=t,a=[yield*b(r)];for(let e=0;e<i.length;e++){let t=i[e],r=n[e]??{},s=o(t.options),c=Zq(W(ee(a[a.length-1],r.from))),l=r.to??`stdin`;if(l===`stdin`)a.push(yield*b(JQ(t.command,t.args,{...t.options,stdin:{...s,stream:c}})));else{let e=XQ(l);if(oM(e)){let n=ZQ(e),r=t.options.additionalFds??{};a.push(yield*b(JQ(t.command,t.args,{...t.options,additionalFds:{...r,[n]:{type:`input`,stream:c}}})))}else a.push(yield*b(JQ(t.command,t.args,{...t.options,stdin:{...s,stream:c}})))}}let s=a[a.length-1],c=e=>BU([...a].reverse(),t=>gW(t.kill(e)),{discard:!0}),l=qU(function*(){let e=[];for(let t of a)e.push(yield*t.unref);return BU([...e].reverse(),e=>e,{discard:!0})});return HQ({pid:s.pid,exitCode:s.exitCode,isRunning:s.isRunning,kill:c,stdin:a[0].stdin,stdout:s.stdout,stderr:s.stderr,all:s.all,getInputFd:s.getInputFd,getOutputFd:s.getOutputFd,unref:l})}}});return UQ(b)})),E$=e=>{let t=[],n=[],r=e=>{switch(e._tag){case`StandardCommand`:t.push(e);break;case`PipedCommand`:r(e.left),n.push(e.options),r(e.right)}};if(r(e),t.length===0)throw Error(`flattenCommand produced empty commands array`);let[i,...a]=t;return{commands:[i,...a],pipeOptions:n}},D$=2**48-1,O$=`0123456789ABCDEFGHJKMNPQRSTVWXYZ`,k$=(e,t)=>{if(t.length!==10)throw Error(`ULID randomness must be exactly 10 bytes, received ${t.length}`);let n=Math.min(Math.max(0,Math.trunc(e)),D$),r=``;for(let e=45;e>=0;e-=5)r+=O$[Math.floor(n/2**e)&31];let i=0,a=0;for(let e of t){for(i=i<<8|e,a+=8;a>=5;)a-=5,r+=O$[i>>>a&31];i&=(1<<a)-1}return r},A$=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`)),j$=e=>e.length<16?[e.subarray(0,4),e.subarray(4,6),e.subarray(6,8),e.subarray(8,10),e.subarray(10,16)].map(e=>Array.from(e,e=>A$[e]).join(``)).join(`-`):A$[e[0]]+A$[e[1]]+A$[e[2]]+A$[e[3]]+`-`+A$[e[4]]+A$[e[5]]+`-`+A$[e[6]]+A$[e[7]]+`-`+A$[e[8]]+A$[e[9]]+`-`+A$[e[10]]+A$[e[11]]+A$[e[12]]+A$[e[13]]+A$[e[14]]+A$[e[15]],M$=()=>globalThis.crypto.getRandomValues(new Uint8Array(16));function N$(e=M$()){return e[6]=e[6]&15|64,e[8]=e[8]&63|128,e}const P$=2**48-1;function F$(e,t=M$()){let n=Math.min(Math.max(0,Math.trunc(e)),P$);return t[0]=Math.floor(n/2**40),t[1]=Math.floor(n/2**32)&255,t[2]=Math.floor(n/2**24)&255,t[3]=Math.floor(n/2**16)&255,t[4]=Math.floor(n/256)&255,t[5]=n&255,t[6]=t[6]&15|112,t[8]=t[8]&63|128,t}const I$=`~effect/Crypto`,L$=$P(`effect/Crypto`),R$=e=>{let t=e.randomBytes,n=e=>J(z$(`randomBytes`,e),t),r=e=>(e[0]&31)*2**48+e[1]*2**40+e[2]*2**32+e[3]*2**24+e[4]*2**16+e[5]*256+e[6],i=()=>r(t(7))/2**53,a=()=>{for(;;){let e=t(7),n=r(e);if(!(e[0]&32))return n+-(2**53-1);if(n<2**53-1)return n+1}};return L$.of({[I$]:I$,randomBytes:n,nextDoubleUnsafe:i,nextIntUnsafe:a,digest:e.digest,random:G(()=>i()),randomBoolean:G(()=>i()>.5),randomInt:G(()=>a()),randomBetween:(e,t)=>G(()=>dU(e,t,i())),randomIntBetween(e,t,n){let r=n?.halfOpen===!0?0:1;return G(()=>{let n=Math.ceil(e),a=Math.floor(t);return Math.floor(i()*(a-n+r))+n})},randomShuffle:e=>G(()=>{let t=Array.from(e);for(let e=t.length-1;e>=1;--e){let n=Math.min(e,Math.floor(i()*(e+1))),r=t[e];t[e]=t[n],t[n]=r}return t}),randomUUIDv4:e=>G(()=>{let n=N$(t(16));return e?.format===`bytes`?n:j$(n)}),randomUUIDv7:e=>$W(n=>{let r=F$(n.currentTimeMillisUnsafe(),t(16));return W(e?.format===`bytes`?r:j$(r))}),randomULID:$W(e=>W(k$(e.currentTimeMillisUnsafe(),t(10))))})},z$=(e,t)=>Number.isSafeInteger(t)&&t>=0?W(t):K(EG({module:`Crypto`,method:e,description:`size must be a non-negative safe integer`})),B$=e=>{switch(e){case`SHA-1`:return`sha1`;case`SHA-256`:return`sha256`;case`SHA-384`:return`sha384`;case`SHA-512`:return`sha512`}},V$=_H(L$,R$({randomBytes:c.randomBytes,digest:(e,t)=>QU({try:()=>Uint8Array.from(c.createHash(B$(e)).update(t).digest()),catch:e=>TG({module:`Crypto`,method:`digest`,_tag:`Unknown`,description:`Could not compute digest`,cause:e})})})),H$=e=>t=>EG({module:`FileSystem`,method:e,description:t.message??String(t)}),U$=(e,t)=>{let n=Number(e);if(!Number.isSafeInteger(n))throw RangeError(`${t} exceeds the safe integer range: ${e}`);return n},W$=e=>ZP(JP(e),oG),G$=e=>BigInt.asUintN(64,e),K$=e=>mie(JP(e),G$),q$=(e,t)=>QU({try:()=>U$(e,`position`),catch:H$(t)}),J$=(()=>{let e=eG(x.access,o$(`FileSystem`,`access`),H$(`access`));return(t,n)=>{let r=x.constants.F_OK;return n?.readable&&(r|=x.constants.R_OK),n?.writable&&(r|=x.constants.W_OK),e(t,r)}})(),Y$=(()=>{let e=eG(x.cp,o$(`FileSystem`,`copy`),H$(`copy`));return(t,n,r)=>e(t,n,{force:r?.overwrite??!1,preserveTimestamps:r?.preserveTimestamps??!1,recursive:!0})})(),X$=(()=>{let e=eG(x.copyFile,o$(`FileSystem`,`copyFile`),H$(`copyFile`));return(t,n)=>e(t,n)})(),Z$=(()=>{let e=eG(x.chmod,o$(`FileSystem`,`chmod`),H$(`chmod`));return(t,n)=>e(t,n)})(),Q$=(()=>{let e=eG(x.chown,o$(`FileSystem`,`chown`),H$(`chown`));return(t,n,r)=>e(t,n,r)})(),$$=(()=>{let e=eG(x.glob,o$(`FileSystem`,`glob`),H$(`glob`));return(t,n)=>e(t,{cwd:n?.root,exclude:n?.exclude})})(),e1=(()=>{let e=eG(x.link,o$(`FileSystem`,`link`),H$(`link`));return(t,n)=>e(t,n)})(),t1=(()=>{let e=eG(x.mkdir,o$(`FileSystem`,`makeDirectory`),H$(`makeDirectory`));return(t,n)=>e(t,{recursive:n?.recursive??!1,mode:n?.mode})})(),n1=t=>{let n=eG(x.mkdtemp,o$(`FileSystem`,t),H$(t));return t=>UU(()=>{let r=t?.prefix??``,i=typeof t?.directory==`string`?e.join(t.directory,`.`):ye.tmpdir();return n(r?e.join(i,r):i+`/`)})},r1=n1(`makeTempDirectory`),i1=e=>{let t=eG(x.rm,o$(`FileSystem`,e),H$(e));return(e,n)=>t(e,{recursive:n?.recursive??!1,force:n?.force??!1})},a1=i1(`remove`),o1=(()=>{let e=n1(`makeTempDirectoryScoped`),t=i1(`makeTempDirectoryScoped`);return n=>NW(e(n),e=>mW(t(e,{recursive:!0,force:!0})))})(),s1=e=>{let{O_APPEND:t,O_CREAT:n,O_EXCL:r,O_RDONLY:i,O_RDWR:a,O_TRUNC:o,O_WRONLY:s}=x.constants;switch(e){case`r`:return i;case`r+`:return a;case`w`:return o|n|s;case`wx`:return o|n|s|r;case`w+`:return o|n|a;case`wx+`:return o|n|a|r;case`a`:return t|n|s;case`ax`:return t|n|s|r;case`a+`:return t|n|a;case`ax+`:return t|n|a|r}},c1=(e,t)=>UU(()=>{let{O_NOFOLLOW:n}=x.constants;return process.platform===`win32`||typeof n!=`number`||n===0?K(EG({module:`FileSystem`,method:e,description:`noFollow is not supported on this platform`})):W(s1(t)|n)}),l1=(e=>{let t=eG(x.open,o$(`FileSystem`,e),H$(e)),n=eG(x.close,o$(`FileSystem`,e),H$(e));return(r,i)=>Uj(NW(i?.noFollow===!0?q(c1(e,i.flag??`r`),e=>t(r,e,i.mode)):t(r,i?.flag??`r`,i?.mode),e=>mW(n(e))),J(e=>d1(e,i?.flag?.startsWith(`a`)??!1)))})(`open`),u1=e=>EG({module:`FileSystem`,method:e,description:`Cannot read before the start of the file`}),d1=(()=>{let e=e=>eG(x.read,o$(`FileSystem`,e),H$(e)),t=e(`read`),n=e(`readAlloc`),r=eG(x.fstat,o$(`FileSystem`,`stat`),H$(`stat`)),i=eG(x.ftruncate,o$(`FileSystem`,`truncate`),H$(`truncate`)),a=eG(x.fsync,o$(`FileSystem`,`sync`),H$(`sync`)),o=e=>eG(x.write,o$(`FileSystem`,e),H$(e)),s=o(`write`),c=o(`writeAll`);class l{[_J];fd;append;position=BigInt(0);constructor(e,t){this[_J]=_J,this.fd=e,this.append=t}get stat(){return q(r(this.fd,{bigint:!0}),b1)}get sync(){return a(this.fd)}seek(e,t){return UU(()=>{let n=t===`start`?e:this.position+e;return n<BigInt(0)?K(EG({module:`FileSystem`,method:`seek`,description:`Cannot seek before the start of the file`})):(this.position=n,W(n))})}read(e,n){return UU(()=>{let r=n?.position;if(r!==void 0)return r<BigInt(0)?K(u1(`read`)):t(this.fd,{buffer:e,position:r});let i=this.position;return J(t(this.fd,{buffer:e,position:i}),e=>(this.position=i+BigInt(e),e))})}readAlloc(e,t){return UU(()=>{try{if(!Number.isInteger(e)||e<0)throw RangeError(`size must be a non-negative integer`);let r=t?.position;if(r!==void 0&&r<BigInt(0))return K(u1(`readAlloc`));let i=Buffer.allocUnsafeSlow(e),a=r??this.position;return J(n(this.fd,{buffer:i,position:a}),t=>{if(t===0)return V();if(r===void 0&&(this.position=a+BigInt(t)),t===e)return UP(i);let n=Buffer.allocUnsafeSlow(t);return i.copy(n,0,0,t),UP(n)})}catch(e){return K(H$(`readAlloc`)(e))}})}truncate(e){return J(i(this.fd,e||void 0),()=>{if(!this.append){let t=BigInt(e??0);this.position>t&&(this.position=t)}})}write(e){return UU(()=>{let t=this.position;return q(this.append?W(void 0):q$(t,`write`),n=>J(s(this.fd,e,void 0,void 0,n),e=>(this.append||(this.position=t+BigInt(e)),e)))})}writeAllChunk(e){return UU(()=>{let t=this.position;return q(this.append?W(void 0):q$(t,`writeAll`),n=>q(c(this.fd,e,void 0,void 0,n),n=>n===0?K(TG({module:`FileSystem`,method:`writeAll`,_tag:`WriteZero`,pathOrDescriptor:this.fd,description:`write returned 0 bytes written`})):(this.append||(this.position=t+BigInt(n)),n<e.length?this.writeAllChunk(e.subarray(n)):WU)))})}writeAll(e){return e.length===0?WU:this.writeAllChunk(e)}}return(e,t)=>new l(e,t)})(),f1=t=>{let n=n1(t);return Y(function*(t){let r=yield*n(t),i=c.randomBytes(6).toString(`hex`),a=e.join(r,t?.suffix?`${i}${t.suffix}`:i);return yield*k1(a,new Uint8Array),a})},p1=f1(`makeTempFile`),m1=(()=>{let t=f1(`makeTempFileScoped`),n=i1(`makeTempFileScoped`);return r=>NW(t(r),t=>mW(n(e.dirname(t),{recursive:!0,force:!0})))})(),h1=(e,t)=>HU({try:()=>x.promises.readdir(e,t),catch:t=>o$(`FileSystem`,`readDirectory`)(t,[e])}),g1=e=>GU((t,n)=>{try{x.readFile(e,{signal:n},(n,r)=>{t(n?K(o$(`FileSystem`,`readFile`)(n,[e])):W(r))})}catch(e){t(K(H$(`readFile`)(e)))}}),_1=(()=>{let e=eG(x.readlink,o$(`FileSystem`,`readLink`),H$(`readLink`));return t=>e(t)})(),v1=(()=>{let e=eG(process.platform===`win32`?x.realpath.native:x.realpath,o$(`FileSystem`,`realPath`),H$(`realPath`));return t=>e(t)})(),y1=(()=>{let e=eG(x.rename,o$(`FileSystem`,`rename`),H$(`rename`));return(t,n)=>e(t,n)})(),b1=(e,t=`stat`)=>QU({try:()=>({type:e.isFile()?`File`:e.isDirectory()?`Directory`:e.isSymbolicLink()?`SymbolicLink`:e.isBlockDevice()?`BlockDevice`:e.isCharacterDevice()?`CharacterDevice`:e.isFIFO()?`FIFO`:e.isSocket()?`Socket`:`Unknown`,mtime:JP(e.mtime),atime:JP(e.atime),birthtime:JP(e.birthtime),dev:G$(e.dev),rdev:K$(e.rdev),ino:K$(e.ino),mode:U$(e.mode,`mode`),nlink:K$(e.nlink),uid:W$(e.uid),gid:W$(e.gid),size:bG(e.size),blksize:e.blksize===void 0?V():UP(bG(e.blksize)),blocks:JP(e.blocks)}),catch:H$(t)}),x1=(e,t)=>{let n=eG(t,o$(`FileSystem`,e),H$(e));return t=>q(n(t,{bigint:!0}),t=>b1(t,e))},S1=x1(`stat`,x.stat),C1=x1(`lstat`,x.lstat),w1=(()=>{let e=eG(x.symlink,o$(`FileSystem`,`symlink`),H$(`symlink`));return(t,n)=>e(t,n)})(),T1=(()=>{let e=eG(x.truncate,o$(`FileSystem`,`truncate`),H$(`truncate`));return(t,n)=>e(t,n)})(),E1=(()=>{let e=eG(x.utimes,o$(`FileSystem`,`utime`),H$(`utime`));return(t,n,r)=>e(t,n,r)})(),D1=(t,n,r)=>Kq(i=>NW(G(()=>{let a=n.type===`Directory`?t:e.dirname(t),o=x.watch(t,{recursive:r?.recursive??!1},(t,n)=>{if(n)switch(t){case`rename`:YW(CW(S1(e.resolve(a,n)),{onSuccess:e=>YG(i,{_tag:`Create`,path:n}),onFailure:e=>YG(i,{_tag:`Remove`,path:n})}));return;case`change`:XG(i,{_tag:`Update`,path:n});return}});return o.on(`error`,e=>{QG(i,IH(TG({module:`FileSystem`,_tag:`Unknown`,method:`watch`,pathOrDescriptor:t,cause:e})))}),o.on(`close`,()=>{$G(i)}),o}),e=>G(()=>e.close())).pipe(rW(()=>G(()=>r?.onReady?.())))),O1=(e,t,n)=>zU([S1(t),OW(vJ)]).pipe(J(([r,i])=>fie(i,()=>e).pipe(ZP(e=>e.register(t,r,n)),qP(()=>D1(t,r,n)))),Zq),k1=(e,t,n)=>GU((r,i)=>{try{x.writeFile(e,t,{signal:i,flag:n?.flag,mode:n?.mode},t=>{r(t?K(o$(`FileSystem`,`writeFile`)(t,[e])):WU)})}catch(e){r(K(H$(`writeFile`)(e)))}}),A1=J(OW(vJ),e=>gJ({access:J$,chmod:Z$,chown:Q$,copy:Y$,copyFile:X$,glob:$$,link:e1,lstat:C1,makeDirectory:t1,makeTempDirectory:r1,makeTempDirectoryScoped:o1,makeTempFile:p1,makeTempFileScoped:m1,open:l1,readDirectory:h1,readFile:g1,readLink:_1,realPath:v1,remove:a1,rename:y1,stat:S1,symlink:w1,truncate:T1,utimes:E1,watch(t,n){return O1(e,t,n)},writeFile:k1})),j1=yH(hJ)(A1),M1=e=>({fromFileUrl:t=>QU({try:()=>we.fileURLToPath(t,{windows:e}),catch:e=>new SG({module:`Path`,method:`fromFileUrl`,cause:e})}),toFileUrl:t=>QU({try:()=>we.pathToFileURL(t,{windows:e}),catch:e=>new SG({module:`Path`,method:`toFileUrl`,cause:e})})});({...e.posix,...M1(!1)}),{...e.win32,...M1(!0)};const N1=_H(bJ)(xJ({...e,...M1(void 0)})),P1=`~effect/Stdio`,F1=_H($P(P1),(e=>({[P1]:P1,stdinIsTerminal:W(!1),stdoutIsTerminal:W(!1),stderrIsTerminal:W(!1),...e}))({args:G(()=>process.argv.slice(2)),stdinIsTerminal:G(()=>process.stdin.isTTY===!0),stdoutIsTerminal:G(()=>process.stdout.isTTY===!0),stderrIsTerminal:G(()=>process.stderr.isTTY===!0),stdout:e=>c$({evaluate:()=>process.stdout,onError:e=>TG({module:`Stdio`,method:`stdout`,_tag:`Unknown`,cause:e}),endOnDone:e?.endOnDone??!1}),stderr:e=>c$({evaluate:()=>process.stderr,onError:e=>TG({module:`Stdio`,method:`stderr`,_tag:`Unknown`,cause:e}),endOnDone:e?.endOnDone??!1}),stdin:f$({evaluate:()=>process.stdin,onError:e=>TG({module:`Stdio`,method:`stdin`,_tag:`Unknown`,cause:e}),closeOnDone:!1})}));({...vN}),{...vN};const I1=new WeakMap,L1=e=>{if(I1.has(e))return I1.get(e);throw Error(`Unable to get redacted value`+(e.label?` with label: "${e.label}"`:``))},R1=`~effect/Redacted`,z1=e=>z(e,R1),B1=(e,t)=>{let n=Object.create(V1);return t?.label&&(n.label=t.label),I1.set(n,e),n},V1={[R1]:{_A:e=>e},label:void 0,...FN,toJSON(){return this.toString()},toString(){return`<redacted${$j(this.label)?`:`+this.label:``}>`},[gM](){return _M(I1.get(this))},[FM](e){return z1(e)&&IM(I1.get(this),I1.get(e))}},H1=L1;vN.toString,vN[hN],{...FN};const U1=(e,t,n)=>e===kJ?n(t):rG(e,n);function W1(e){let t=G1(e);return(e,n,r)=>{try{return t(e,n,r)}catch(e){return ZU(e)}}}function G1(e){if(e._tag===`Middleware`)return(t,n,r)=>{let i=t===kJ?e.decode(DJ(AJ(n)),r):e.decode(tG(t,AJ),r);return K1(i)};let t=e.decode;switch(t._tag){case`Passthrough`:return(e,t)=>e===kJ?DJ(t):e;case`Transform`:{let e=e=>e===EJ?OJ:DJ(t.transform(e));return(t,n)=>U1(t,n,e)}case`TransformOptional`:{let e=e=>jJ(t.transform(AJ(e)));return(t,n)=>U1(t,n,e)}case`TransformEffect`:return(e,n,r)=>U1(e,n,e=>e===EJ?OJ:t.transform(e,r));case`TransformOptionalEffect`:return(e,n,r)=>U1(e,n,e=>K1(t.transform(AJ(e),r)))}}const K1=e=>rG(e,jJ),q1=(e,t,n,r)=>uW(r,r=>XU(()=>zH(r,r=>new LJ(e,r,t,n))));function J1(e,t){let n=W1(e.link.transformation),r;return(i,a)=>{if(i===EJ)return OJ;if(e.isConstructed(i))return kJ;let o=(r??=t(e.link.to))(i,a);return n(o,i,a)}}function Y1(e,t){let n=e.context.constructorDefault;return(r,i)=>{if(r!==EJ&&r!==void 0)return t(r,i);let a=n;if(PR(a)&&a._tag===`Success`){let e=t(a[B],i);return e===kJ?a:e}return rG(q1(e,r,i,a),e=>{let n=t(e,i);return n===kJ?DJ(e):n})}}function X1(e,t){let n=t(e);return e.context?.constructorDefault===void 0?n:Y1(e,n)}function Z1(e,t,n,r,i){if(e._tag===`Declaration`)for(let n of e.typeParameters)t(n);let a=n?kQ(e):void 0,o=a?J1(a,t):r??e.getParser(t,n),s=e.checks,c=e.encoding,l=c?.map(e=>W1(e.transformation)),u=e.encodingChecks;if(!c&&!s&&!u)return o;let d,f=(t,n)=>{let r=o(t,n);try{if(u&&!n.disableChecks){if(PR(r)){if(r._tag===`Success`){let i=r===kJ?t:r[B];if(t!==EJ&&i!==EJ){let i=OQ(u,t,void 0,e,n);i&&(r=K(new VJ(e,i,t,n)))}}}else r=q(r,r=>{if(t!==EJ&&r!==EJ){let r=OQ(u,t,void 0,e,n);if(r)return K(new VJ(e,r,t,n))}return W(r)})}if(s&&!n.disableChecks){if(PR(r)){if(r._tag===`Success`){let i=r===kJ?t:r[B];if(i===EJ)return r;let a=OQ(s,i,void 0,e,n);a&&(r=K(new VJ(e,a,i,n)))}}else r=q(r,t=>{if(t!==EJ){let r=OQ(s,t,void 0,e,n);if(r)return K(new VJ(e,r,t,n))}return W(t)})}return r}catch(e){return ZU(e)}},p=i===void 0?f:i(f);return c?(n,r)=>{let i=d??=c.map(e=>t(e.to)),a=n,o=i[i.length-1](n,r);for(let e=c.length-1;e>=0;e--)if(o=l[e](o,a,r),e!==0){let t=i[e-1];o._tag===`Success`?(a=o[B],o=t(a,r)):o=rG(o,e=>{let n=t(e,r);return n===kJ?DJ(e):n})}if(o._tag===`Success`){let e=o[B],t=p(e,r);return t===kJ?o:t}return o=q1(e,n,r,o),rG(o,e=>{let t=p(e,r);return t===kJ?DJ(e):t})}:p}const Q1=Symbol(),$1=new WeakMap,e0=e=>i0(e).parser,t0=e=>i0(e).makeEffect,n0=e=>X1(e,t0);var r0=class{ast;constructor(e){this.ast=e}get decodeEffect(){return this.cachedDecodeEffect??=Z1(this.ast,e0)}get parser(){return this.decodeEffect}get makeEffect(){return this.cachedMakeEffect??=Z1(this.ast,t0,n0)}};function i0(e){let t=$1.get(e);if(t!==void 0)return t;let n=new r0(e);return $1.set(e,n),n}function a0(e){let t=e.ast,n;return(e,r)=>(n??=g0(T0,mQ(t)))(e,r?.disableChecks?r?.parseOptions?{...r.parseOptions,disableChecks:!0}:{disableChecks:!0}:r?.parseOptions)}function o0(e){let t=a0(e);return(e,n)=>{let r=QW(t(e,n));return AH(r)?UP(r.value):(lY(r.cause,`Option adapter can only return none for schema issues`),V())}}function s0(e){return x0(mQ(e.ast))}function c0(e){return u0(e.ast)}function l0(e){{let t=_0(m0(e));return e=>{let n=t(e,MX);return AH(n)?!0:(lY(n.cause,`Type guard adapter can only return false for schema issues`),!1)}}}function u0(e){let t=mQ(e),n=e=>(n=l0(t),n(e));return e=>n(e)}function d0(e,t){let n=m0(e.ast);return t===void 0?n:(e,r)=>n(e,f0(t,r))}function eae(e,t){let n=m0(_Q(e.ast));return t===void 0?n:(e,r)=>n(e,f0(t,r))}const f0=(e,t)=>t?{...e,...t}:e,p0=e=>e===EJ?K(new UJ):W(e);function m0(e){return g0(w0,e)}function h0(e,t){return e===kJ?W(t):PR(e)?e[B]===EJ?p0(EJ):e:rG(e,p0)}function g0(e,t){let n;return(r,i)=>{let a=(n??=e(t))(r,i??MX);return a===kJ?W(r):PR(a)?a[B]===EJ?p0(EJ):a:rG(a,p0)}}function _0(e){return(t,n)=>QW(e(t,n))}function v0(e,t){let n=QW(e);if(AH(n))return n.value;let r=lY(n.cause,t);throw Error(`Schema validation failed`,{cause:r})}const y0=`Constructor adapter can only throw schema issues`;function b0(e){throw Error(y0,{cause:LH(e)})}function x0(e){let t;return(n,r)=>S0(t??=i0(e),n,r)}function S0(e,t,n){let r=n?.disableChecks?n.parseOptions?{...n.parseOptions,disableChecks:!0}:{disableChecks:!0}:n?.parseOptions??MX,i=e.make;if(i!==void 0&&t!==EJ){let e;try{e=i(t,r)}catch(e){b0(e)}if(e!==Q1&&e!==EJ)return e}return v0(h0(e.makeEffect(t,r),t),y0)}function C0(e,t,n,r){let i=i0(e),a=kQ(e);if(a===void 0||i.make!==void 0||i.compiledMakeEffect!==void 0)return S0(i,t,n);if(a.isConstructed(t))return t;let o=S0((i.resolve??i0)(a.link.to),t,n);try{return r(o)}catch(e){b0(e)}}const w0=e=>i0(e).parser,T0=e=>i0(e).makeEffect,E0=`~effect/Schema/Schema`,D0=Symbol(),O0={[E0]:E0,get make(){let e=s0(this);return Object.defineProperty(this,"make",{value:e,enumerable:!0}),e},get makeEffect(){let e=a0(this);return Object.defineProperty(this,"makeEffect",{value:e,enumerable:!0}),e},get makeOption(){let e=o0(this);return Object.defineProperty(this,"makeOption",{value:e,enumerable:!0}),e},pipe(){return Fj(this,arguments)},annotate(e){return this.rebuild(KZ(this.ast,e))},annotateKey(e){return this.rebuild(nQ(this.ast,e))},check(...e){return this.rebuild(JZ(this.ast,e))},rebuild(e){return k0(e,this[D0])}};function k0(e,t){function n(){}let r=Object.setPrototypeOf(n,O0);return t&&(Object.hasOwn(t,`name`)||Object.hasOwn(t,`length`)||Object.hasOwn(t,`__proto__`))?Object.defineProperties(r,Object.getOwnPropertyDescriptors({...t})):Object.assign(r,t),r[D0]=t,r.ast=e,r}function A0(e,t){let n=Wj(t=>{let n=WZ(t,void 0),i=e(n,r);return i===n?null:i}),r=$Z(e=>{let t=n(HZ(e));if(t===null)return e;let r=WZ(t,e.context);return e.context===void 0?r:QZ(r,j0(e.context))},t);return r}function j0(e){return e.constructorDefault===void 0?e:new NX(e.isOptional,e.isMutable,void 0,e.annotations)}function M0(e){if(e.propertySignatures.some(e=>typeof e.name!=`string`))throw new globalThis.Error(`Objects property names must be strings`,{cause:e})}function N0(e){return t=>{let n=[...t].sort((t,n)=>e(hQ(t))-e(hQ(n)));return n.some((e,n)=>e!==t[n])?n:t}}function P0(e){return k0(B0(e.ast),{schema:e})}const F0=N0(e=>{switch(e._tag){case`Null`:case`Boolean`:case`Number`:case`BigInt`:case`Symbol`:case`UniqueSymbol`:return 0;default:return 1}});function I0(e,t,n){switch(e._tag){case`Declaration`:{let r=e.typeParameters.map(e=>k0(t(hQ(e)))),i=e.annotations?.toCodecStringTree;if(iM(i)){let n=i(r);return n===void 0?e:UZ(e,[YZ(n,t)])}let a=e.annotations?.toCodecJson,o=iM(a)?a(r):void 0,s=o===void 0?e.annotations?.toCodec:void 0,c=o??(iM(s)?s(r):void 0);return c===void 0?n(e):UZ(e,[YZ(c,t)])}case`Null`:return UZ(e,[L0]);case`Boolean`:return UZ(e,[R0]);case`Unknown`:case`ObjectKeyword`:return UZ(e,[IQ]);case`Enum`:case`Number`:case`Literal`:case`UniqueSymbol`:case`Symbol`:case`BigInt`:return e.toCodecStringTree();case`Objects`:return M0(e),e.recur(t,xQ);case`Union`:{let n=F0(e.types);return n===e.types?e.recur(t):new TZ(n,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t)}case`Arrays`:case`Suspend`:return e.recur(t)}return e}const L0=new jX(new HX(`null`),new aX(kY(()=>null),kY(()=>`null`))),R0=new jX(new TZ([new HX(`true`),new HX(`false`)]),new aX(kY(e=>e===`true`),jY())),z0=new aX(kY(e=>typeof e==`string`?[e]:e),OY()),B0=A0((e,t)=>I0(e,t,e=>{throw new globalThis.Error(`Missing structural codec for StringTree`,{cause:e})}),{stopAt:e=>e.transformation===z0}),V0=e=>e,H0=`~effect/Schema/SchemaError`;function U0(e){return z(e,`~effect/Schema/SchemaError`)&&e[`~effect/Schema/SchemaError`]===`~effect/Schema/SchemaError`}({...vN}),{...vN},{...vN},{...vN},{...vN},{...vN},{...vN},{...vN};const W0=`~effect/SemVer`,G0=`~effect/SemVer/SemVerError`;var K0=class extends PI(`SemVerError`){[G0]=G0};const q0=e=>z(e,G0),J0=e=>{throw new K0({message:e})},Y0=e=>Tie({try:e,catch:e=>{if(!q0(e))throw e;return e}}),X0=(e,t,n)=>Die(Y0(()=>n(t)),n=>new K0({message:`Invalid ${e} ${JSON.stringify(t)}: ${n.message}`,input:t})),Z0=/^(?:0|[1-9]\d*)$/,Q0=/^\d+$/,$0=/^[0-9A-Za-z-]+$/,e2=(e,t)=>!Number.isSafeInteger(e)||e<0?J0(`${t} must be a non-negative safe integer, received ${e}`):e,t2=(e,t)=>Z0.test(e)?e2(Number(e),t):J0(`${t} must be a non-negative integer without leading zeros, received ${JSON.stringify(e)}`),n2=e=>typeof e==`number`?e2(e,`numeric pre-release identifier`):$0.test(e)?Q0.test(e)?t2(e,`numeric pre-release identifier`):e:J0(`pre-release identifier must be non-empty [0-9A-Za-z-], received ${JSON.stringify(e)}`),r2=e=>$0.test(e)?e:J0(`build identifier must be non-empty [0-9A-Za-z-], received ${JSON.stringify(e)}`),i2=(e,t)=>{if(e.length===0)return t.length===0?0:1;if(t.length===0)return-1;let n=Math.min(e.length,t.length);for(let r=0;r<n;r++){let n=e[r],i=t[r];if(n!==i)return typeof n==`number`?typeof i==`number`?BP(n,i):-1:typeof i==`number`?1:zP(n,i)}return BP(e.length,t.length)},a2=(e,t)=>BP(e.major,t.major)||BP(e.minor,t.minor)||BP(e.patch,t.patch)||i2(e.prerelease,t.prerelease),o2={[W0]:W0,[FM](e){return c2(e)&&h2(this,e)},[gM](){return wM(f2(this))},toString(){return`SemVer(${f2(this)})`},toJSON(){return{_id:`SemVer`,value:f2(this)}},[hN](){return this.toJSON()},pipe(){return Fj(this,arguments)}},s2=(e,t,n,r,i)=>{let a=Object.create(o2);return a.major=e,a.minor=t,a.patch=n,a.prerelease=r,a.build=i,a},c2=e=>z(e,W0),l2=e=>s2(e2(e.major,`major`),e2(e.minor,`minor`),e2(e.patch,`patch`),e.prerelease?.map(n2)??[],e.build?.map(r2)??[]),u2=e=>{let t=e,n=[],r=t.indexOf(`+`);r!==-1&&(n=t.slice(r+1).split(`.`).map(r2),t=t.slice(0,r));let i=[],a=t.indexOf(`-`);a!==-1&&(i=t.slice(a+1).split(`.`).map(n2),t=t.slice(0,a));let o=t.split(`.`);return o.length===3?s2(t2(o[0],`major`),t2(o[1],`minor`),t2(o[2],`patch`),i,n):J0(`expected MAJOR.MINOR.PATCH`)},d2=e=>X0(`SemVer`,e,u2),f2=e=>{let t=`${e.major}.${e.minor}.${e.patch}`;return e.prerelease.length>0&&(t+=`-${e.prerelease.join(`.`)}`),e.build.length>0&&(t+=`+${e.build.join(`.`)}`),t},p2=RP(a2),m2=Qre(Zre()),h2=wP((e,t)=>e.major===t.major&&e.minor===t.minor&&e.patch===t.patch&&m2(e.prerelease,t.prerelease)&&m2(e.build,t.build)),g2=VP(p2),_2=E0;function v2(){return(e,t,n)=>A2(new IX(e.map(hZ),e=>t(e.map(e=>A2(e))),n))}function y2(e,t){return v2()([],()=>(t,n,r)=>e(t)?W(t):K(new HJ(n,t,r)),t)}var b2=class extends PI(`SchemaError`){[H0]=H0;constructor(e){let t=bN();xN(0);try{super({issue:e})}finally{xN(t)}}get message(){return aY(this.issue)}toJSON(){return{_tag:this._tag,message:this.message}}[hN](){return this.toJSON()}toString(){return`SchemaError(${this.message})`}};function x2(e){return U0(e)}function S2(e){return PR(e)?C2(e):uW(e,e=>XU(()=>zH(e,e=>new b2(e))))}function C2(e){return AH(e)?e:DH(zH(e.cause,e=>new b2(e)))}function w2(e,t){let n;for(let r of e.reasons){if(!PH(r)||!x2(r.error))throw new globalThis.Error(t,{cause:e});n??=r.error}if(n===void 0)throw new globalThis.Error(t,{cause:e});return n}function T2(e){let t=QW(e);if(AH(t))return t.value;throw w2(t.cause,`Sync adapter can only throw schema errors`)}const E2=c0;function D2(e,t){let n=d0(e,t);return(e,t)=>S2(n(e,t))}function O2(e,t){let n=D2(e,t);return(e,t)=>T2(n(e,t))}function k2(e,t){let n=eae(e,t);return(e,t)=>S2(n(e,t))}const A2=k0;function j2(e){return z(e,_2)&&e[_2]===_2}const M2=V0(e=>A2(rQ(e.ast),{schema:e})),N2=V0(e=>{let t=J2(e);return A2(aQ(e.ast),{schema:t})}),P2=V0(e=>A2(mQ(e.ast),{schema:e}));function F2(e){let t=A2(new HX(e),{literal:e,transform(n){return t.pipe(X2(F2(n),{decode:kY(()=>n),encode:kY(()=>e)}))}});return t}const I2=A2(VX),L2=A2(LX),R2=A2(BX),X=A2(WX),z2=A2(qX),B2=A2(JX);function V2(e,t){return A2(e,{fields:t,mapFields(e,t){let n=e(this.fields);return V2(mZ(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function Z(e){return V2(mZ(e,void 0),e)}function H2(e,t){return A2(lQ(e.ast,t.ast),{key:e,value:t})}const U2=V0(e=>A2(new YX(!1,[],[e.ast]),{value:e}));function W2(e,t){return A2(e,{members:t,mapMembers(e,t){let n=e(this.members);return W2(gZ(n,this.ast.options,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function G2(e,t){return W2(gZ(e,t,void 0),e)}function K2(e){let t=e.map(F2);return A2(gZ(t,void 0,void 0),{literals:e,members:t,mapMembers(e){return G2(e(this.members))},pick(e){return K2(e)},transform(e){return G2(t.map((t,n)=>t.transform(e[n])))}})}const q2=V0(e=>G2([e,L2])),J2=V0(e=>G2([e,R2]));function Y2(e){return t=>A2(t.ast,{schema:t,identifier:e})}function X2(e,t){return n=>A2(sQ(n.ast,e.ast,t?sX(t):uX()),{from:n,to:e})}const Z2=K2([`true`,`yes`,`on`,`1`,`y`]),Q2=K2([`false`,`no`,`off`,`0`,`n`]),$2=K2([...Z2.literals,...Q2.literals]).pipe(X2(B2,cX({decode:e=>e===`true`||e===`yes`||e===`on`||e===`1`||e===`y`,encode:e=>e?`true`:`false`})));function e4(e){return t=>A2(oQ(t.ast,e),{schema:t})}function t4(e){return F2(e).pipe(e4(W(e)))}function n4(e,t){return Z({_tag:t4(e),...t})}function r4(e,t){return y2(t=>t instanceof e,t)}function i4(){return(e,t)=>new jX(e.ast,sX(t))}const a4=IZ;function o4(e,t){let n=e.source,r=e.flags,i=/^[dg]*uy?$/.test(r),a=r===``?`new globalThis.RegExp(${iN(n)})`:`new globalThis.RegExp(${iN(n)}, ${iN(r)})`;return zZ(e,{toJsonSchema:()=>i?{pattern:r.endsWith(`y`)?`^(?:${n})`:n}:[{},!0],toCode:()=>({runtime:`Schema.isPattern(${a})`}),...t})}function s4(e){let t=uie(e.order),n=HP(e.order),r=lie(e.order),i=VP(e.order),a=e.formatter??iN;return(o,s)=>{let c=o.exclusiveMinimum?n:t,l=o.exclusiveMaximum?i:r;return a4(e=>c(e,o.minimum)&&l(e,o.maximum),{expected:`a value between ${a(o.minimum)}${o.exclusiveMinimum?` (excluded)`:``} and ${a(o.maximum)}${o.exclusiveMaximum?` (excluded)`:``}`,arbitraryConstraint:{order:e.order,minimum:o.minimum,maximum:o.maximum,...o.exclusiveMinimum&&{exclusiveMinimum:!0},...o.exclusiveMaximum&&{exclusiveMaximum:!0}},...e.annotate?.(o),...s})}}function c4(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${iN(e)}`);return e}const l4=s4({order:BP,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:`effect/schema/isBetween`,payload:{minimum:c4(e.minimum),maximum:c4(e.maximum),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>({[t?`exclusiveMinimum`:`minimum`]:e.minimum,[n?`exclusiveMaximum`:`maximum`]:e.maximum}),toCode:()=>({runtime:`Schema.isBetween({ minimum: ${iN(e.minimum)}, maximum: ${iN(e.maximum)}, exclusiveMinimum: ${iN(t)}, exclusiveMaximum: ${iN(n)} })`})}}});function u4(e){return a4(e=>globalThis.Number.isSafeInteger(e),{expected:`an integer`,representation:{id:`effect/schema/isInt`,payload:null},toJsonSchema:()=>({type:`integer`,minimum:globalThis.Number.MIN_SAFE_INTEGER,maximum:globalThis.Number.MAX_SAFE_INTEGER}),toCode:()=>({runtime:`Schema.isInt()`}),arbitraryConstraint:{number:`integer`},...e})}const d4=z2.check(u4());function f4(e,t){return e=h4(e),p4(e,Math.ceil(e/2),t)}function p4(e,t,n){return a4(t=>t.length>=e,{expected:`a value with a length of at least ${e}`,representation:{id:`effect/schema/isMinLength`,payload:{minLength:e}},toJsonSchema:({type:n})=>n===`string`?e<=1?{minLength:t}:[{minLength:t},!0]:n===`array`?{minItems:e}:n===void 0?[{minLength:t,minItems:e},!0]:[{},!0],toCode:()=>({runtime:`Schema.isMinLength(${e})`}),"~structural":!0,arbitraryConstraint:{minLength:e},...n})}function m4(e){return p4(1,1,e)}function h4(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${e}`);return Math.max(0,Math.floor(e))}const g4=X.check(m4()),_4=e=>+(e?.includeStack===!0)|(e?.excludeCause===!0?2:0),v4=e=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}},y4=[];function b4(e){let t=_4(e),n=y4[t];if(n!==void 0)return n;let r=I4.pipe(X2(I2,vX(v4(t))));return y4[t]=r,r}globalThis.RegExp,globalThis.URL;const x4=X.annotate({expected:`a string that will be decoded as JSON`});function S4(e,t){return x4.pipe(X2(e,bX(t)))}globalThis.File,globalThis.URLSearchParams;const C4=X.annotate({expected:`a base64 encoded string that will be decoded as Uint8Array`,format:`byte`,contentEncoding:`base64`}),w4=r4(globalThis.Uint8Array,{representation:{id:`effect/schema/Uint8Array`,payload:null},toCode:()=>({runtime:`Schema.Uint8Array`,Type:`globalThis.Uint8Array`}),expected:`Uint8Array`,toCodecJson:()=>i4()(C4,yX)}),T4=globalThis.Symbol.for(`immer-draftable`),E4={};function D4(e,t,n,r,i){let a=j4(n,t,r),o=A4(t),s=class extends e{constructor(...[e,t]){let r=t?.[`~payload`],i=r?.token===E4?r.value:n.make(e??{},t);super(i,{...t,disableChecks:!0,"~payload":{token:E4,value:i}})}static[_2]=_2;get[o](){return o}static[T4]=!0;static identifier=t;static fields=n.fields;static get ast(){return a(this).ast}static pipe(){return Fj(this,arguments)}static rebuild(e){return a(this).rebuild(e)}static make(e,t){return C0(mQ(a(this).ast),e??{},t,e=>O4(this,e))}static makeOption(e,t){return o0(a(this))(e??{},t)}static makeEffect(e,t){return a(this).makeEffect(e??{},t)}static annotate(e){return this.rebuild(KZ(this.ast,e))}static annotateKey(e){return this.rebuild(nQ(this.ast,e))}static check(...e){return this.rebuild(JZ(this.ast,e))}static extend(e){return(t,r)=>{let a=M4(t)?t:Z(t),o={...n.fields,...a.fields},s=mZ(o,n.ast.checks,{identifier:e});return D4(this,e,V2(JZ(s,a.ast.checks),o),r,i)}}static mapFields(e,t){return n.mapFields(e,t)}};return i!==void 0&&Object.assign(s.prototype,i(t)),s}function O4(e,t){return new e(t,{"~payload":{token:E4,value:t}})}function k4(e){return new aX(kY(t=>O4(e,t)),OY())}function A4(e){return`~effect/Schema/Class/${e}`}function j4(e,t,n){let r;return i=>{if(r!==void 0)return r;let a=A4(t),o=e=>e instanceof i||z(e,a),s=k4(i);return r=X2(A2(new IX([e.ast],()=>(e,t,n)=>o(e)?W(e):K(new HJ(t,e,n)),{identifier:t,[wJ]:([e])=>({isConstructed:o,link:new jX(e,s)}),toCodec:([e])=>new jX(e.ast,s),toEquivalence:([e])=>e,toFormatter:([e])=>t=>`${i.identifier}(${e(t)})`,[CJ]:yZ(e.ast),...n})),s)(e)}}function M4(e){return j2(e)}const N4=e=>(t,n)=>{let r=M4(t)?t:Z(t);return D4(_P,e,r,n,e=>({name:e}))},P4=e=>(t,n,r)=>{let i=M4(n)?n.mapFields(e=>({_tag:t4(t),...e}),{unsafePreserveChecks:!0}):n4(t,n);return N4(e??t)(i,r)},F4=P0,I4=A2(KZ(PQ,{toCode:()=>({runtime:`Schema.Json`,Type:`Schema.Json`})})),L4=`~effect/Terminal`,R4=`~effect/Terminal/QuitError`;var z4=class extends N4(`QuitError`)({_tag:t4(`QuitError`)}){[R4]=R4};const B4=e=>z(e,R4),V4=$P(`effect/Terminal`),H4=e=>V4.of({...e,[L4]:L4}),U4=yH(V4,Y(function*(e=W4){let t=process.stdin,n=process.stdout,r=yield*qG(),i=t.readableEnded,a=!1,o=()=>{i=!0,a||$G(r)};t.once(`end`,o),yield*FW(()=>G(()=>t.off(`end`,o)));let s=yield*zq({acquire:NW(G(()=>{let e=ke.createInterface({input:t,escapeCodeTimeout:50}),n=e=>XG(r,e),i=()=>{a=!1,$G(r)};return a=!0,ke.emitKeypressEvents(t,e),e.on(`line`,n),e.once(`close`,i),{rl:e,onClose:i,onLine:n}}),({rl:e,onClose:t,onLine:n})=>G(()=>{a=!1,e.off(`line`,n),e.off(`close`,t),e.close(),i&&$G(r)})),idleTimeToLive:`10 millis`}),c=e=>G(()=>{t.isTTY&&t.setRawMode(e)}),l=yield*zq({acquire:NW(c(!0),()=>c(!1)),idleTimeToLive:`10 millis`}),u=G(()=>n.columns??0),d=G(()=>n.rows??0),f=qU(function*(){let n=yield*qG(),r=(t,r)=>{let i={input:YP(t),key:{name:r.name??``,ctrl:!!r.ctrl,meta:!!r.meta,shift:!!r.shift}};XG(n,i),e(i)&&$G(n)},a=setInterval(()=>{},2147483647),o=()=>{clearInterval(a),$G(n)};return yield*FW(()=>G(()=>{clearInterval(a),t.off(`keypress`,r),t.off(`end`,o)})),t.on(`keypress`,r),i?o():(yield*Bq(s),yield*Bq(l),t.once(`end`,o)),n}),p=UU(()=>aK(r).pipe(q(KP({onNone:()=>jW(nW(Bq(s),iK(r))),onSome:W})),pW(()=>new z4({}))));return H4({columns:u,rows:d,readInput:f,readLine:p,display:e=>HW(GU(t=>{n.write(e,e=>cM(e)?t(WU):t(K(EG({module:`Terminal`,method:`display`,description:`Failed to write prompt to stdout`,cause:e}))))}))})})(W4));function W4(e){let t=e.key;return t.name===`escape`||t.ctrl&&(t.name===`c`||t.name===`d`)}const G4=TH(T$,CH(j1,V$,N1,F1,U4)),K4=CV,q4=e=>hP(t=>e(t.getRef(K4))),J4=(...e)=>q4(t=>YL(()=>{t.error(...e)})),Y4=(...e)=>q4(t=>YL(()=>{t.log(...e)})),X4={"~effect/Match/Matcher":{_input:R,_filters:R,_remaining:R,_result:R,_return:R,_args:R},_tag:`TypeMatcher`,add(e){return Z4(this.select,[...this.cases,e])},pipe(){return Fj(this,arguments)}};function Z4(e,t){let n=Object.create(X4);return n.select=e,n.cases=t,n}const Q4=(e,t)=>({_tag:`When`,guard:e,evaluate:t}),$4=L(2,(e,t)=>t3(t)(Z4(R,[]))(e)),e3=e=>t=>{let n=Q4(n=>n!=null&&Object.hasOwn(t,n[e]),n=>t[n[e]](n));return e=>e.add(n)},t3=(e=>t=>{let n=e3(e)(t);return e=>i3(n(e))})(`_tag`),n3=e=>{if(e._tag===`ValueMatcher`)return e.value;let t=e.cases.length;if(t===1){let t=e.cases[0];return(...n)=>{let r=e.select(...n);return t._tag===`When`&&t.guard(r)===!0||t._tag===`Not`&&t.guard(r)===!1?wF(t.evaluate(r,...n)):TF(r)}}return(...n)=>{let r=e.select(...n);for(let i=0;i<t;i++){let t=e.cases[i];if(t._tag===`When`&&t.guard(r)===!0||t._tag===`Not`&&t.guard(r)===!1)return wF(t.evaluate(r,...n))}return TF(r)}},r3=`effect/match/Match/exhaustive: absurd`,i3=e=>{let t=n3(e);if(Eie(t)){if(DF(t))return t.success;throw Error(r3)}return(...e)=>{let n=t(...e);if(DF(n))return n.success;throw Error(r3)}},a3=$4,o3={"~effect/Ref":{_A:R},...FN,[FM](e){return this===e},[gM](){return vM(this)},toJSON(){return{_id:`Ref`,ref:this.ref}}},s3=e=>{let t=Object.create(o3);return t.ref=FG(e),t},c3=e=>G(()=>s3(e)),l3=e=>G(()=>e.ref.current),u3=L(2,(e,t)=>G(()=>IG(e.ref,t))),d3=`~effect/Runtime/errorReported`,f3=`~effect/cli/CliError`,p3=e=>z(e,f3),m3=`~effect/cli/CliError/userMessage`,h3=e=>`~effect/cli/CliError/userMessage`in e&&typeof e[`~effect/cli/CliError/userMessage`]==`string`?e[m3]:void 0;var g3=class extends P4(`${f3}/UnrecognizedOption`)(`UnrecognizedOption`,{option:X,command:N2(U2(X)),suggestions:U2(X)}){[f3]=f3;get message(){let e=this.suggestions.length>0?`\n\n Did you mean this?\n ${this.suggestions.join(`
|
|
345
|
+
`)}`:``;return(this.command?`Unrecognized flag: ${this.option} in command ${this.command.join(` `)}`:`Unrecognized flag: ${this.option}`)+e}},_3=class extends P4(`${f3}/DuplicateOption`)(`DuplicateOption`,{option:X,parentCommand:X,childCommand:X}){[f3]=f3;get message(){return`Duplicate flag name "${this.option}" in parent command "${this.parentCommand}" and subcommand "${this.childCommand}". Parent will always claim this flag (Mode A semantics). Consider renaming one of them to avoid confusion.`}},v3=class extends P4(`${f3}/MissingOption`)(`MissingOption`,{option:X}){[f3]=f3;get message(){return`Missing required flag: --${this.option}`}},y3=class extends P4(`${f3}/MissingArgument`)(`MissingArgument`,{argument:X}){[f3]=f3;get message(){return`Missing required argument: ${this.argument}`}},b3=class extends P4(`${f3}/UnexpectedArgument`)(`UnexpectedArgument`,{arguments:U2(X)}){[f3]=f3;get message(){return`Unexpected positional ${this.arguments.length===1?`argument`:`arguments`}: ${this.arguments.map(e=>JSON.stringify(e)).join(`, `)}`}},x3=class extends P4(`${f3}/InvalidValue`)(`InvalidValue`,{option:X,value:X,expected:X,kind:G2([F2(`flag`),F2(`argument`)])}){[f3]=f3;get message(){let e=this.expected.startsWith(`Expected `)||this.expected.startsWith(`Expected:`)?this.expected:`Expected: ${this.expected}`;return this.kind===`argument`?`Invalid value for argument <${this.option}>: "${this.value}". ${e}`:this.value.length===0?`Missing value for flag --${this.option}. ${e}`:`Invalid value for flag --${this.option}: "${this.value}". ${e}`}},S3=class extends P4(`${f3}/UnknownSubcommand`)(`UnknownSubcommand`,{subcommand:X,parent:N2(U2(X)),suggestions:U2(X)}){[f3]=f3;get message(){let e=this.suggestions.length>0?`\n\n Did you mean this?\n ${this.suggestions.join(`
|
|
346
|
+
`)}`:``;return this.parent?`Unknown subcommand "${this.subcommand}" for "${this.parent.join(` `)}"${e}`:`Unknown subcommand "${this.subcommand}"${e}`}},C3=class extends P4(`${f3}/ValidationError`)(`ValidationError`,{message:X}){[f3]=f3},w3=class extends P4(`${f3}/UserError`)(`UserError`,{cause:b4(),userMessage:M2(X)}){[f3]=f3;[d3]=!0;get message(){return this.userMessage?this.userMessage:typeof this.cause==`string`&&this.cause?this.cause:this.cause instanceof Error&&this.cause.message?this.cause.message:`An error occurred`}get[m3](){return this.message}};const T3=G2([g3,_3,v3,y3,b3,x3,S3,C3,w3]);var E3=class extends P4(`${f3}/ShowHelp`)(`ShowHelp`,{commandPath:U2(X),errors:U2(T3)}){[f3]=f3;"~effect/Runtime/errorExitCode"=+!!this.errors.length;[d3]=!1;get message(){return`Help requested`}};const D3={"~effect/cli/Primitive":{_A:R}},O3=E2(Z2),k3=E2(Q2),A3=e=>e._tag===`Boolean`,j3=(e,t)=>Object.assign(Object.create(D3),{_tag:e,parse:t}),M3=((e,t)=>{let n=D2(F4(t));return j3(e,e=>pW(n(e),e=>e.message))})(`Boolean`,$2),N3=j3(`String`,e=>W(e)),P3=e=>{let t=new Map(e),n=e.map(([e])=>iN(e)).join(` | `),r=j3(`Choice`,e=>t.has(e)?W(t.get(e)):K(n));return Object.assign(r,{choiceKeys:e.map(([e])=>e)})},F3=e=>{switch(e._tag){case`Boolean`:return`boolean`;case`String`:return`string`;case`Int`:return`integer`;case`Finite`:return`number`;case`Date`:return`date`;case`Path`:return`path`;case`Choice`:return`choice`;case`Redacted`:return`string`;case`FileText`:return`file`;case`FileParse`:return`file`;case`FileSchema`:return`file`;case`KeyValuePair`:return`key=value`;case`Never`:return`none`;default:return`value`}},I3=e=>e._tag===`Choice`?e.choiceKeys:void 0,L3=e=>e._tag===`Path`?e.pathType:void 0,R3=`\x1B[1m`,z3=`\x1B[4m`,B3=`\x1B[?25l`,V3=`\x1B[31m`,H3=`\x1B[32m`,U3=`\x1B[37m`,W3=`\x1B[90m`,G3=`\x1B[96m`,K3=(e,t,...n)=>e?`${n.flat().join(``)}${t}[0m`:t,q3=()=>{let e=globalThis.process;return typeof e==`object`&&!!e&&typeof e.stdout==`object`&&e.stdout!==null&&e.stdout.isTTY===!0&&!e.env?.NO_COLOR},J3=(...e)=>e,Y3=(e,t)=>t===void 0?`[${Math.max(e+1,0)}G`:`[${t+1};${Math.max(e+1,0)}H`,X3=(e=1)=>`[${e}B`,Z3=(e,t=0)=>{let n=``;return t<0&&(n+=`[${-t}A`),t>0&&(n+=`[${t}B`),e>0&&(n+=`[${e}C`),e<0&&(n+=`[${-e}D`),n},Q3=e=>{let t=``;for(let n=0;n<e;n++)t+=`\x1B[2K`+(n<e-1?`\x1B[1A`:``);return e>0&&(t+=`\x1B[G`),t},$3={prefix:`?`,arrowUp:`↑`,arrowDown:`↓`,checkboxOn:`☒`,checkboxOff:`☐`,tick:`✔`,ellipsis:`…`,pointerSmall:`›`,pointer:`❯`,descriptionSeparator:`- `,passwordMask:`*`,toggleSeparator:`/`,primaryColor:G3,mutedColor:W3,successColor:H3,errorColor:V3,submittedColor:U3},e6={...$3,checkboxOn:`[*]`,checkboxOff:`[ ]`,tick:`√`,ellipsis:`...`,pointerSmall:`»`,pointer:`>`},t6=xF(`effect/cli/Prompt/Theme`,{defaultValue:e=>({...process.platform===`win32`?e6:$3,...e,colors:e?.colors??q3()})}),n6=e=>J(t6,t=>({...t,...e.theme})),r6=(e,t)=>K3(e.colors,t,J3(`\x1B[3m`,e.errorColor)),i6=(e,t,...n)=>t.length===0?``:K3(e.colors,t,...n),a6=(e,t)=>e.length===0?t:e+` `+t,tae=(e,t,n)=>{let r=Math.max(e.arrowUp.length,e.arrowDown.length);return t?e.arrowUp.padEnd(r):n?e.arrowDown.padEnd(r):` `.repeat(r)},o6=e=>{let t={initial:!1,...e,label:{confirm:`yes`,deny:`no`,...e.label},placeholder:{defaultConfirm:`(Y/n)`,defaultDeny:`(y/N)`,...e.placeholder}},n={value:t.initial};return s6(n,{render:gae(t),process:e=>yae(e,t.initial),clear:pae(t)})},s6=(e,...t)=>{let[n,r]=t.length===1?[void 0,t[0]]:[t[0],t[1]],i=Object.create(d6);return i._tag=`Loop`,i.initialState=e,i.render=r.render,i.process=r.process,i.clear=r.clear,i.events=n,i},nae=e=>{let t={initial:new globalThis.Date,dateMask:`YYYY-MM-DD HH:mm:ss`,validate:W,...e,locales:{...Aae,...e.locales}},n=Pae(t.dateMask,t.initial,t.locales),r={dateParts:n,typed:``,cursor:n.findIndex(e=>!e.isToken()),value:t.initial,error:V()};return s6(r,{render:jae(t),process:Mae(t),clear:bae(t)})},rae=L(2,(e,t)=>{let n=Object.create(d6);return n._tag=`OnSuccess`,n.prompt=e,n.onSuccess=t,n}),iae=e=>{let t={default:0,min:globalThis.Number.NEGATIVE_INFINITY,max:globalThis.Number.POSITIVE_INFINITY,incrementBy:1,decrementBy:1,precision:2,validate:e=>e<t.min?K(`${e} must be greater than or equal to ${t.min}`):e>t.max?K(`${e} must be less than or equal to ${t.max}`):W(e),...e},n=e.default===void 0?``:`${t.default}`,r={cursor:n.length,value:n,error:V()};return s6(r,{render:Yae(t),process:Xae(t),clear:x6(t)})},c6=e=>{let t={default:0,min:globalThis.Number.NEGATIVE_INFINITY,max:globalThis.Number.POSITIVE_INFINITY,incrementBy:1,decrementBy:1,validate:e=>e<t.min?K(`${e} must be greater than or equal to ${t.min}`):e>t.max?K(`${e} must be less than or equal to ${t.max}`):W(e),...e},n=e.default===void 0?``:`${t.default}`,r={cursor:n.length,value:n,error:V()};return s6(r,{render:qae(t),process:Jae(t),clear:x6(t)})},aae=L(2,(e,t)=>rae(e,e=>cae(t(e)))),oae=e=>F6(e,`password`).pipe(aae(B1)),l6=Y(function*(e){let t=yield*V4,n=yield*BW(t.readInput);return yield*f6(e,t,n)},pW(()=>new z4({})),jW),sae=e=>{let t=0,n=-1;for(let t=0;t<e.length;t++)if(e[t].selected===!0){if(n!==-1)throw Error(`InvalidArgumentException: only a single choice can be selected by default for Prompt.Select`);n=t}return n!==-1&&(t=n),t},u6=e=>{let t={maxPerPage:10,...e},n=sae(t.choices);return s6(n,{render:ioe(t),process:ooe(t),clear:aoe(t)})},cae=e=>{let t=Object.create(d6);return t._tag=`Succeed`,t.value=e,t},lae=e=>F6(e,`text`),uae=e=>{let t={initial:!1,active:`on`,inactive:`off`,...e};return s6(t.initial,{render:Coe(t),process:woe,clear:()=>boe(t)})},d6={...CP({label:`Prompt`,evaluate(){return l6(this)}}),"~effect/cli/Prompt":{_Output:e=>e}},f6=(e,t,n)=>UU(()=>{let r=e;switch(r._tag){case`Loop`:return q(n,e=>dae(r,t,e));case`OnSuccess`:return q(f6(r.prompt,t,n),e=>f6(r.onSuccess(e),t,n));case`Succeed`:return W(r.value)}}),dae=Y(function*(e,t,n){let r=RU(e.initialState)?yield*e.initialState:e.initialState,i=Q.NextFrame({state:r}),a=``;for(;;){let o=yield*e.render(r,i);if(yield*mW(t.display(a+o)),a=``,e.events){let t=iK(n).pipe(J(e=>({_tag:`Input`,input:e}))),a=yield*bW(t,iK(e.events).pipe(J(e=>({_tag:`Event`,value:e}))));i=yield*e.process(a,r)}else{let t=yield*iK(n);i=yield*e.process(t,r)}switch(i._tag){case`Beep`:continue;case`NextFrame`:a=yield*e.clear(r,i),r=i.state;continue;case`Submit`:{a=yield*e.clear(r,i);let n=yield*e.render(r,i);return yield*mW(t.display(a+n)),i.value}}}},(e,t,n)=>IW(e,mW(n.display(`\x1B[?25h`)))),Q=jI(),p6=(e,t)=>{if(t===0)return`\x1B[2K`+Y3(0);let n=0,r=e.split(h6);for(let e of r)n+=1+Math.floor(Math.max(e.length-1,0)/t);return Q3(n)},fae=(e,t)=>{let n=e.split(h6);return t===0?n.length:Uj(IF(n,e=>Math.ceil(e.length/t)),LF(0,(e,t)=>e+t))},m6=(e,t,n)=>n!==void 0&&n.length>0?X3(fae(n,t))+p6(`\n${n}`,t)+p6(e,t):p6(e,t),h6=/\r?\n/,pae=e=>Y(function*(t,n){let r=yield*(yield*V4).columns,i=yield*n6(e),a=t.value?e.placeholder.defaultConfirm:e.placeholder.defaultDeny,o=b6(a,e.message,i.prefix,i.pointerSmall,i,{plain:!0});return p6(o,r)+`\x1B[2K\x1B[G`}),mae=Y(function*(e,t){let n=yield*n6(t),r=i6(n,n.prefix,n.primaryColor),i=i6(n,n.pointerSmall,n.mutedColor),a=e.value?t.placeholder.defaultConfirm:t.placeholder.defaultDeny,o=K3(n.colors,a,n.mutedColor),s=b6(o,t.message,r,i,n);return B3+s}),hae=Y(function*(e,t){let n=yield*n6(t),r=i6(n,n.tick,n.successColor),i=i6(n,n.ellipsis,n.mutedColor),a=e?t.label.confirm:t.label.deny;return b6(a,t.message,r,i,n)+`
|
|
347
|
+
`}),gae=e=>(t,n)=>Q.$match(n,{Beep:()=>W(`\x07`),NextFrame:({state:t})=>mae(t,e),Submit:({value:t})=>hae(t,e)}),_ae=/^y|t$/,vae=/^n|f$/,yae=(e,t)=>{let n=qP(e.input,()=>``);return e.key.name===`enter`||e.key.name===`return`?W(Q.Submit({value:t})):_ae.test(n.toLowerCase())?W(Q.Submit({value:!0})):vae.test(n.toLowerCase())?W(Q.Submit({value:!1})):W(Q.Beep())},bae=e=>Y(function*(t,n){let r=yield*(yield*V4).columns,i=yield*n6(e),a=LF(t.dateParts,``,(e,t)=>e+t.toString()),o=b6(a,e.message,i.prefix,i.pointerSmall,i,{plain:!0}),s=GP(t.error)?AF(t.error.value.split(h6),{onEmpty:()=>``,onNonEmpty:e=>a6(i.pointerSmall,e.join(`
|
|
348
|
+
`))}):``;return m6(o,r,s)+`\x1B[2K\x1B[G`}),xae=(e,t,n)=>{if(GP(e.error)){let r=e.error.value.split(h6);if(MF(r)){let e=i6(n,t,n.errorColor),i=IF(r,e=>r6(n,e));return`\x1B[s
|
|
349
|
+
`+a6(e,i.join(`
|
|
350
|
+
`))+`\x1B[u`}}return``},g6=(e,t,n=!1)=>LF(e.dateParts,``,(r,i,a)=>{let o=i.toString();if(a===e.cursor&&!n){let e=J3(z3,t.primaryColor);return r+K3(t.colors,o,e)}return r+o}),Sae=Y(function*(e,t){let n=yield*n6(t),r=i6(n,n.prefix,n.primaryColor),i=i6(n,n.pointerSmall,n.mutedColor),a=g6(e,n),o=b6(a,t.message,r,i,n),s=xae(e,n.pointerSmall,n);return B3+o+s}),Cae=Y(function*(e,t){let n=yield*n6(t),r=i6(n,n.tick,n.successColor),i=i6(n,n.ellipsis,n.mutedColor),a=g6(e,n,!0);return b6(a,t.message,r,i,n)+`
|
|
351
|
+
`}),wae=e=>(e.dateParts[e.cursor].increment(),Q.NextFrame({state:{...e,typed:``}})),Tae=e=>(e.dateParts[e.cursor].decrement(),Q.NextFrame({state:{...e,typed:``}})),Eae=e=>{let t=e.dateParts[e.cursor].previousPart();return GP(t)?Q.NextFrame({state:{...e,typed:``,cursor:e.dateParts.indexOf(t.value)}}):Q.Beep()},Dae=e=>{let t=e.dateParts[e.cursor].nextPart();return GP(t)?Q.NextFrame({state:{...e,typed:``,cursor:e.dateParts.indexOf(t.value)}}):Q.Beep()},Oae=e=>{let t=e.dateParts[e.cursor].nextPart(),n=KP(t,{onNone:()=>e.dateParts.findIndex(e=>!e.isToken()),onSome:t=>e.dateParts.indexOf(t)});return Q.NextFrame({state:{...e,typed:``,cursor:n}})},kae=(e,t)=>{if(/\d/.test(e)){let n=t.typed+e;return t.dateParts[t.cursor].setValue(n),Q.NextFrame({state:{...t,typed:n}})}return Q.Beep()},Aae={months:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],monthsShort:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],weekdays:[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],weekdaysShort:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`]},jae=e=>(t,n)=>Q.$match(n,{Beep:()=>W(`\x07`),NextFrame:({state:t})=>Sae(t,e),Submit:()=>Cae(t,e)}),Mae=e=>(t,n)=>{switch(t.key.name){case`left`:return W(Eae(n));case`right`:return W(Dae(n));case`k`:case`up`:return W(wae(n));case`j`:case`down`:return W(Tae(n));case`tab`:return W(Oae(n));case`enter`:case`return`:return xW(e.validate(n.value),{onFailure:e=>Q.NextFrame({state:{...n,error:UP(e)}}),onSuccess:e=>Q.Submit({value:e})});default:return W(kae(qP(t.input,()=>``),n))}},Nae=/\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g,_6={1:({token:e,...t})=>new y6({token:e.replace(/\\(.)/g,`$1`),...t}),2:e=>new zae(e),3:e=>new Bae(e),4:e=>new Vae(e),5:e=>new Hae(e),6:e=>new Rae(e),7:e=>new Lae(e),8:e=>new Iae(e),9:e=>new Fae(e)},Pae=(e,t,n)=>{let r=[],i=null;for(;i=Nae.exec(e);){let e=i.shift(),a=i.findIndex(e=>e!==void 0);if(a in _6){let o=i[a]||e;r.push(_6[a]({token:o,date:t,parts:r,locales:n}))}else r.push(new y6({token:i[a]||e,date:t,parts:r,locales:n}))}let a=r.reduce((e,t)=>{let n=e[e.length-1];return t.isToken()&&n!==void 0&&n.isToken()?n.setValue(t.token):e.push(t),e},PF());return r.splice(0,r.length,...a),r};var v6=class{token;date;parts;locales;constructor(e){this.token=e.token,this.locales=e.locales,this.date=e.date||new globalThis.Date,this.parts=e.parts||[this]}isToken(){return!1}nextPart(){let e=qP(NF(this.parts,e=>e===this),()=>0);return jie(this.parts.slice(e+1),e=>!e.isToken())}previousPart(){let e=NF(this.parts,e=>e===this);return GP(e)?Mie(this.parts.slice(0,e.value),e=>!e.isToken()):V()}toString(){return globalThis.String(this.date)}},y6=class extends v6{increment(){}decrement(){}setValue(e){this.token+=e}isToken(){return!0}toString(){return this.token}},Fae=class extends v6{increment(){this.date.setMilliseconds(this.date.getMilliseconds()+1)}decrement(){this.date.setMilliseconds(this.date.getMilliseconds()-1)}setValue(e){this.date.setMilliseconds(globalThis.Number.parseInt(e.slice(-this.token.length)))}toString(){return`${this.date.getMilliseconds()}`.padStart(4,`0`).substring(0,this.token.length)}},Iae=class extends v6{increment(){this.date.setSeconds(this.date.getSeconds()+1)}decrement(){this.date.setSeconds(this.date.getSeconds()-1)}setValue(e){this.date.setSeconds(globalThis.Number.parseInt(e.slice(-2)))}toString(){let e=`${this.date.getSeconds()}`;return this.token.length>1?e.padStart(2,`0`):e}},Lae=class extends v6{increment(){this.date.setMinutes(this.date.getMinutes()+1)}decrement(){this.date.setMinutes(this.date.getMinutes()-1)}setValue(e){this.date.setMinutes(globalThis.Number.parseInt(e.slice(-2)))}toString(){let e=`${this.date.getMinutes()}`;return this.token.length>1?e.padStart(2,`0`):e}},Rae=class extends v6{increment(){this.date.setHours(this.date.getHours()+1)}decrement(){this.date.setHours(this.date.getHours()-1)}setValue(e){this.date.setHours(globalThis.Number.parseInt(e.slice(-2)))}toString(){let e=/h/.test(this.token)?this.date.getHours()%12||12:this.date.getHours();return this.token.length>1?`${e}`.padStart(2,`0`):`${e}`}},zae=class extends v6{increment(){this.date.setDate(this.date.getDate()+1)}decrement(){this.date.setDate(this.date.getDate()-1)}setValue(e){this.date.setDate(globalThis.Number.parseInt(e.slice(-2)))}toString(){let e=this.date.getDate(),t=this.date.getDay();switch(this.token){case`DD`:return`${e}`.padStart(2,`0`);case`Do`:return`${e}${this.ordinalIndicator(e)}`;case`d`:return`${t+1}`;case`ddd`:return this.locales.weekdaysShort[t];case`dddd`:return this.locales.weekdays[t];default:return`${e}`}}ordinalIndicator(e){if(e>=11&&e<=13)return`th`;switch(e%10){case 1:return`st`;case 2:return`nd`;case 3:return`rd`;default:return`th`}}},Bae=class extends v6{increment(){this.date.setMonth(this.date.getMonth()+1)}decrement(){this.date.setMonth(this.date.getMonth()-1)}setValue(e){let t=globalThis.Number.parseInt(e.slice(-2))-1;this.date.setMonth(t<0?0:t)}toString(){let e=this.date.getMonth();switch(this.token.length){case 2:return`${e+1}`.padStart(2,`0`);case 3:return this.locales.monthsShort[e];case 4:return this.locales.months[e];default:return`${e+1}`}}},Vae=class extends v6{increment(){this.date.setFullYear(this.date.getFullYear()+1)}decrement(){this.date.setFullYear(this.date.getFullYear()-1)}setValue(e){this.date.setFullYear(globalThis.Number.parseInt(e.slice(-4)))}toString(){let e=`${this.date.getFullYear()}`.padStart(4,`0`);return this.token.length===2?e.slice(-2):e}},Hae=class extends v6{increment(){this.date.setHours((this.date.getHours()+12)%24)}decrement(){this.increment()}setValue(e){}toString(){let e=this.date.getHours()>=12?`pm`:`am`;return/A/.test(this.token)?e.toUpperCase():e}};const b6=(e,t,n,r,i,a)=>{let o=n.length===0?``:n+` `,s=t=>{let n=o+t;return r.length>0&&(n+=` `+r),e.length>0?n+=` `+e:r.length>0&&(n+=` `),n};return AF(t.split(h6),{onEmpty:()=>s(``),onNonEmpty:e=>{let t=a?.plain===!0?e:IF(e,e=>K3(i.colors,e,R3));return s(t.join(`
|
|
352
|
+
`))}})},Uae=(e,t,n,r)=>{if(!e.disabled&&e.description&&t){let t=n.descriptionSeparator+e.description;return r?.plain===!0?t:K3(n.colors,t,n.mutedColor)}return``},x6=e=>Y(function*(t,n){let r=yield*(yield*V4).columns,i=yield*n6(e),a=S6(t,i.pointerSmall,i,{plain:!0}),o=C6(t,i.prefix,i.pointerSmall,e,i,{plain:!0});return m6(o,r,a)+`\x1B[2K\x1B[G`}),Wae=(e,t,n,r)=>{let i=e.value===``?``:`${e.value}`;if(t||r?.plain===!0)return i;let a=GP(e.error)?n.errorColor:J3(z3,n.primaryColor);return K3(n.colors,i,a)},S6=(e,t,n,r)=>GP(e.error)?AF(e.error.value.split(h6),{onEmpty:()=>``,onNonEmpty:e=>{if(r?.plain===!0)return a6(t,e.join(`
|
|
353
|
+
`));let i=i6(n,t,n.errorColor),a=IF(e,e=>r6(n,e));return`\x1B[s
|
|
354
|
+
`+a6(i,a.join(`
|
|
355
|
+
`))+`\x1B[u`}}):``,C6=(e,t,n,r,i,a,o=!1)=>{let s=Wae(e,o,i,a);return b6(s,r.message,t,n,i,a)},w6=Y(function*(e,t){let n=yield*n6(t),r=i6(n,n.prefix,n.primaryColor),i=i6(n,n.pointerSmall,n.mutedColor),a=S6(e,n.pointerSmall,n);return C6(e,r,i,t,n)+a}),T6=Y(function*(e,t){let n=yield*n6(t),r=i6(n,n.tick,n.successColor),i=i6(n,n.ellipsis,n.mutedColor);return C6(e,r,i,t,n,void 0,!0)+`
|
|
356
|
+
`}),E6=e=>{if(e.value.length<=0)return W(Q.Beep());let t=e.value.slice(0,e.value.length-1);return W(Q.NextFrame({state:{...e,value:t,error:V()}}))},D6=e=>W(Q.NextFrame({state:{...e,cursor:0,value:``,error:V()}})),Gae=(e,t)=>{if(t.value.length===0&&e===`-`)return W(Q.NextFrame({state:{...t,value:`-`,error:V()}}));let n=globalThis.Number.parseInt(t.value+e);return globalThis.Number.isNaN(n)?W(Q.Beep()):W(Q.NextFrame({state:{...t,value:`${n}`,error:V()}}))},Kae=(e,t)=>{if(e===`.`&&t.value.includes(`.`))return W(Q.Beep());if(t.value.length===0&&e===`-`)return W(Q.NextFrame({state:{...t,value:`-`,error:V()}}));let n=globalThis.Number.parseFloat(t.value+e);return globalThis.Number.isNaN(n)?W(Q.Beep()):W(Q.NextFrame({state:{...t,value:e===`.`?`${n}.`:t.value.includes(`.`)&&/^\d$/.test(e)?t.value+e:`${n}`,error:V()}}))},qae=e=>(t,n)=>Q.$match(n,{Beep:()=>W(`\x07`),NextFrame:({state:t})=>w6(t,e),Submit:()=>T6(t,e)}),Jae=e=>(t,n)=>{if(t.key.ctrl&&t.key.name===`u`)return D6(n);switch(t.key.name){case`backspace`:return E6(n);case`k`:case`up`:return W(Q.NextFrame({state:{...n,value:n.value===``||n.value===`-`?`${e.incrementBy}`:`${globalThis.Number.parseInt(n.value)+e.incrementBy}`,error:V()}}));case`j`:case`down`:return W(Q.NextFrame({state:{...n,value:n.value===``||n.value===`-`?`-${e.decrementBy}`:`${globalThis.Number.parseInt(n.value)-e.decrementBy}`,error:V()}}));case`enter`:case`return`:{let t=globalThis.Number.parseInt(n.value);return globalThis.Number.isNaN(t)?W(Q.NextFrame({state:{...n,error:UP(`Must provide an integer value`)}})):xW(e.validate(t),{onFailure:e=>Q.NextFrame({state:{...n,error:UP(e)}}),onSuccess:e=>Q.Submit({value:e})})}default:return Gae(qP(t.input,()=>``),n)}},Yae=e=>(t,n)=>Q.$match(n,{Beep:()=>W(`\x07`),NextFrame:({state:t})=>w6(t,e),Submit:()=>T6(t,e)}),Xae=e=>(t,n)=>{if(t.key.ctrl&&t.key.name===`u`)return D6(n);switch(t.key.name){case`backspace`:return E6(n);case`k`:case`up`:return W(Q.NextFrame({state:{...n,value:n.value===``||n.value===`-`?`${e.incrementBy}`:`${globalThis.Number.parseFloat(n.value)+e.incrementBy}`,error:V()}}));case`j`:case`down`:return W(Q.NextFrame({state:{...n,value:n.value===``||n.value===`-`?`-${e.decrementBy}`:`${globalThis.Number.parseFloat(n.value)-e.decrementBy}`,error:V()}}));case`enter`:case`return`:{let t=globalThis.Number.parseFloat(n.value);return globalThis.Number.isNaN(t)?W(Q.NextFrame({state:{...n,error:UP(`Must provide a floating point value`)}})):q(G(()=>uU(t,e.precision)),t=>xW(e.validate(t),{onFailure:e=>Q.NextFrame({state:{...n,error:UP(e)}}),onSuccess:e=>Q.Submit({value:e})}))}default:return Kae(qP(t.input,()=>``),n)}},O6=(e,t,n,r,i)=>n.message===void 0?void 0:b6(``,n.message,e,t,r,i),k6=(e,t)=>e===void 0?t:e+`
|
|
357
|
+
`+t,Zae=(e,t,n,r,i,a)=>{let o=tae(i,r===n.startIndex&&n.startIndex>0,r===n.endIndex-1&&n.endIndex<t.length);if(a?.plain===!0)return e===r?i.pointer+o:o+` `.repeat(i.pointer.length);if(t[r].disabled){let t=J3(R3,i.mutedColor);return e===r?i6(i,i.pointer,t)+o:o+` `.repeat(i.pointer.length)}return e===r?i6(i,i.pointer,i.primaryColor)+o:o+` `.repeat(i.pointer.length)},Qae=(e,t,n,r)=>{if(r?.plain===!0)return e.title;let i=e.title;return t?e.disabled?K3(n.colors,i,J3(z3,n.mutedColor)):K3(n.colors,i,J3(z3,n.primaryColor)):e.disabled?K3(n.colors,i,J3(`\x1B[9m`,n.mutedColor)):i},A6=(e,t,n,r)=>{let i=t.choices,a=Toe(e,i.length,t.maxPerPage),o=[];for(let t=a.startIndex;t<a.endIndex;t++){let s=i[t],c=e===t,l=Zae(e,i,a,t,n,r),u=Qae(s,c,n,r),d=Uae(s,c,n,r);o.push(l+u+` `+d)}return o.join(`
|
|
358
|
+
`)},$ae=Y(function*(e,t){let n=yield*n6(t),r=A6(e,t,n),i=i6(n,n.prefix,n.primaryColor),a=i6(n,n.pointerSmall,n.mutedColor),o=O6(i,a,t,n);return B3+k6(o,r)}),eoe=Y(function*(e,t){let n=yield*n6(t),r=t.choices[e].title,i=i6(n,n.tick,n.successColor),a=i6(n,n.ellipsis,n.mutedColor);return(O6(i,a,t,n)??i)+` `+K3(n.colors,r,n.submittedColor)+`
|
|
359
|
+
`}),toe=(e,t)=>W(e===0?Q.NextFrame({state:t.length-1}):Q.NextFrame({state:e-1})),noe=(e,t)=>e===t.length-1?W(Q.NextFrame({state:0})):W(Q.NextFrame({state:e+1})),roe=(e,t)=>W(Q.NextFrame({state:(e+1)%t.length})),ioe=e=>(t,n)=>Q.$match(n,{Beep:()=>W(`\x07`),NextFrame:({state:t})=>$ae(t,e),Submit:()=>eoe(t,e)}),aoe=e=>Y(function*(t,n){let r=yield*(yield*V4).columns,i=yield*n6(e),a=O6(i.prefix,i.pointerSmall,e,i,{plain:!0}),o=A6(t,e,i,{plain:!0});return p6(k6(a,o),r)+`\x1B[2K\x1B[G`}),ooe=e=>(t,n)=>{switch(t.key.name){case`k`:case`up`:return toe(n,e.choices);case`j`:case`down`:return noe(n,e.choices);case`tab`:return roe(n,e.choices);case`enter`:case`return`:{let t=e.choices[n];return t.disabled?W(Q.Beep()):W(Q.Submit({value:t.value}))}default:return W(Q.Beep())}},soe=Y(function*(e,t){let n=yield*(yield*V4).columns,r=yield*n6(t),i=j6(e,r.pointerSmall,r,{plain:!0});return m6(M6(e,r.prefix,r.pointerSmall,t,r,{plain:!0}),n,i)+`\x1B[2K\x1B[G`}),coe=(e,t,n,r,i)=>{let a=e.value;if(i?.plain===!0)switch(t.type){case`hidden`:return``;case`password`:return n.passwordMask.repeat(a.length);case`text`:return a}if(a.length===0)return``;let o=GP(e.error)?n.errorColor:r?n.submittedColor:J3(z3,n.primaryColor);switch(t.type){case`hidden`:return``;case`password`:return i6(n,n.passwordMask.repeat(a.length),o);case`text`:return K3(n.colors,a,o)}},j6=(e,t,n,r)=>GP(e.error)?AF(e.error.value.split(h6),{onEmpty:()=>``,onNonEmpty:e=>{if(r?.plain===!0)return a6(t,e.join(`
|
|
360
|
+
`));let i=i6(n,t,n.errorColor),a=IF(e,e=>r6(n,e));return`\x1B[s
|
|
361
|
+
`+a6(i,a.join(`
|
|
362
|
+
`))+`\x1B[u`}}):``,M6=(e,t,n,r,i,a,o=!1)=>{let s=coe(e,r,i,o,a);return b6(s,r.message,t,n,i,a)},loe=Y(function*(e,t){let n=yield*n6(t),r=i6(n,n.prefix,n.primaryColor),i=i6(n,n.pointerSmall,n.mutedColor),a=M6(e,r,i,t,n),o=j6(e,n.pointerSmall,n),s=t.type===`password`?n.passwordMask.length:1,c=(e.cursor-e.value.length)*s;return a+o+Z3(c)}),uoe=Y(function*(e,t){let n=yield*n6(t),r=i6(n,n.tick,n.successColor),i=i6(n,n.ellipsis,n.mutedColor);return M6(e,r,i,t,n,void 0,!0)+`
|
|
363
|
+
`}),doe=e=>{if(e.cursor<=0)return W(Q.Beep());let t=e.value.slice(0,e.cursor-1),n=e.value.slice(e.cursor),r=e.cursor-1,i=`${t}${n}`;return W(Q.NextFrame({state:{...e,cursor:r,value:i,error:V()}}))},foe=e=>W(Q.NextFrame({state:{...e,cursor:0,value:``,error:V()}})),poe=e=>{if(e.cursor<=0)return W(Q.Beep());let t=e.cursor-1;return W(Q.NextFrame({state:{...e,cursor:t,error:V()}}))},moe=e=>{if(e.cursor>=e.value.length)return W(Q.Beep());let t=Math.min(e.cursor+1,e.value.length);return W(Q.NextFrame({state:{...e,cursor:t,error:V()}}))},N6=e=>W(Q.NextFrame({state:{...e,cursor:0,error:V()}})),P6=e=>W(Q.NextFrame({state:{...e,cursor:e.value.length,error:V()}})),hoe=(e,t)=>{if(e.value===t.default)return W(Q.Beep());let n=e.value.length===0?t.default:e.value;return W(Q.NextFrame({state:{...e,value:n,cursor:n.length,error:V()}}))},goe=(e,t)=>{let n=`${t.value.slice(0,t.cursor)}${e}${t.value.slice(t.cursor)}`,r=t.cursor+e.length;return W(Q.NextFrame({state:{...t,cursor:r,value:n,error:V()}}))},_oe=e=>(t,n)=>Q.$match(n,{Beep:()=>W(`\x07`),NextFrame:({state:t})=>loe(t,e),Submit:()=>uoe(t,e)}),voe=e=>(t,n)=>{if(t.key.ctrl)switch(t.key.name){case`u`:return foe(n);case`a`:return N6(n);case`e`:return P6(n);default:return W(Q.Beep())}switch(t.key.name){case`backspace`:return doe(n);case`left`:return poe(n);case`right`:return moe(n);case`home`:return N6(n);case`end`:return P6(n);case`enter`:case`return`:{let t=n.value;return xW(e.validate(t),{onFailure:e=>Q.NextFrame({state:{...n,value:t,error:UP(e)}}),onSuccess:e=>Q.Submit({value:e})})}case`tab`:return hoe(n,e);default:return goe(qP(t.input,()=>``),n)}},yoe=e=>(t,n)=>soe(t,e),F6=(e,t)=>{let n={default:``,type:t,validate:W,...e},r={cursor:n.default.length,value:n.default,error:V()};return s6(r,{render:_oe(n),process:voe(n),clear:yoe(n)})},boe=Y(function*(e){let t=yield*(yield*V4).columns,n=yield*n6(e),r=e.active+` `+a6(n.toggleSeparator,e.inactive),i=b6(r,e.message,n.prefix,n.pointerSmall,n,{plain:!0});return p6(i,t)+`\x1B[2K\x1B[G`}),I6=(e,t,n,r=!1)=>{let i=i6(n,n.toggleSeparator,n.mutedColor),a=J3(z3,r?n.submittedColor:n.primaryColor),o=e?t.inactive:K3(n.colors,t.inactive,a);return(e?K3(n.colors,t.active,a):t.active)+` `+a6(i,o)},xoe=Y(function*(e,t){let n=yield*n6(t),r=i6(n,n.prefix,n.primaryColor),i=i6(n,n.pointerSmall,n.mutedColor),a=I6(e,t,n),o=b6(a,t.message,r,i,n);return B3+o}),Soe=Y(function*(e,t){let n=yield*n6(t),r=i6(n,n.tick,n.successColor),i=i6(n,n.ellipsis,n.mutedColor),a=I6(e,t,n,!0);return b6(a,t.message,r,i,n)+`
|
|
364
|
+
`}),L6=W(Q.NextFrame({state:!0})),R6=W(Q.NextFrame({state:!1})),Coe=e=>(t,n)=>{switch(n._tag){case`Beep`:return W(`\x07`);case`NextFrame`:return xoe(t,e);case`Submit`:return Soe(t,e)}},woe=(e,t)=>{switch(e.key.name){case`0`:case`j`:case`delete`:case`right`:case`down`:return R6;case`1`:case`k`:case`left`:case`up`:return L6;case` `:case`tab`:return t?R6:L6;case`enter`:case`return`:return W(Q.Submit({value:t}));default:return W(Q.Beep())}},Toe=(e,t,n)=>{let r=n===void 0?t:n,i=Math.min(t-r,e-Math.floor(r/2));i<0&&(i=0);let a=Math.min(i+r,t);return{startIndex:i,endIndex:a}},z6=xF(`effect/cli/TerminalCapabilities`,{defaultValue:()=>Ooe()}),B6=e=>e!==void 0&&e.length>0,Eoe=e=>B6(e)&&e!==`0`&&e.toLowerCase()!==`false`,Doe=e=>e.term===`dumb`?{canColor:!1,canAnimate:!1,canPrompt:!1}:{canColor:!B6(e.noColor)&&(Eoe(e.forceColor)||e.stdoutIsTerminal),canAnimate:e.stdoutIsTerminal,canPrompt:e.stdinIsTerminal&&e.stdoutIsTerminal},Ooe=()=>{let e=globalThis.process;return Doe({noColor:e?.env?.NO_COLOR,forceColor:e?.env?.FORCE_COLOR,term:e?.env?.TERM,stdinIsTerminal:e?.stdin?.isTTY===!0,stdoutIsTerminal:e?.stdout?.isTTY===!0})},V6=`~effect/cli/Param`,H6=`flag`,U6={[V6]:{_A:R},pipe(){return Fj(this,arguments)}},koe=e=>z(e,V6),W6=e=>e.kind===`flag`,G6=e=>{let t=t=>e.kind===`argument`?Boe(e.name,e.primitiveType,t):Voe(e.name,e.primitiveType,t);return Object.setPrototypeOf({_tag:`Single`,...e,description:e.description??V(),aliases:e.aliases??[],hidden:e.hidden??!1,parse:t},U6)},Aoe=(e,t)=>G6({name:t,primitiveType:N3,kind:e}),joe=(e,t)=>G6({name:t,primitiveType:M3,kind:e}),Moe=(e,t,n)=>G6({name:t,primitiveType:P3(n),kind:e}),Noe=/^-+/,Poe=L(2,(e,t)=>Z6(e,e=>G6({...e,aliases:[...e.aliases,t.replace(Noe,``)]}))),Foe=L(2,(e,t)=>Z6(e,e=>G6({...e,description:UP(t)}))),K6=L(2,(e,t)=>Object.assign(Object.create(U6),{_tag:`Map`,kind:e.kind,param:e,f:t,parse:n=>J(e.parse(n),([e,n])=>[e,t(n)])})),q6=(e,t,n=[])=>{let r=n.map(e=>()=>e().parse);return Object.assign(Object.create(U6),{_tag:`Transform`,kind:e.kind,param:e,alternatives:n,f:t,parse:t(e.parse,r)})},J6=L(2,(e,t)=>q6(e,e=>n=>q(e(n),([e,n])=>t(n).pipe(J(t=>[e,t]))))),Y6=e=>Object.assign(Object.create(U6),{_tag:`Optional`,kind:e.kind,param:e,parse:t=>e.parse(t).pipe(J(([e,t])=>[e,UP(t)]),lW({MissingOption:()=>W([t.arguments,V()]),MissingArgument:()=>W([t.arguments,V()])}))}),Ioe=L(2,(e,t)=>RU(t)?J6(Y6(e),KP({onNone:()=>t,onSome:W})):K6(Y6(e),qP(()=>t))),Loe=(e,t)=>{let n=$6(e);return Object.assign(Object.create(U6),{_tag:`Variadic`,kind:e.kind,param:e,min:YP(t?.min),max:YP(t?.max),parse:r=>n.kind===`argument`?Hoe(e,n,r,t):Uoe(e,n,r,t)})},Roe=L(2,(e,t)=>Z6(e,e=>G6({...e,typeName:t}))),zoe=L(2,(e,t)=>{let n=D2(t);return J6(e,t=>pW(n(t),n=>{let r=$6(e);return new x3({option:r.name,value:globalThis.String(t),expected:`Schema validation failed: ${n.message}`,kind:r.kind})}))}),Boe=Y(function*(e,t,n){if(n.arguments.length===0)return yield*new y3({argument:e});let r=n.arguments[0],i=yield*pW(t.parse(r),t=>new x3({option:e,value:r,expected:t,kind:`argument`}));return[n.arguments.slice(1),i]}),Voe=Y(function*(e,t,n){let r=n.flags[e];if(r===void 0||r.length===0)return yield*new v3({option:e});if(r.length>1)return yield*new x3({option:e,value:`${r.length} occurrences`,expected:`at most 1 value`,kind:`flag`});let i=r[0],a=yield*pW(t.parse(i),t=>new x3({option:e,value:i,expected:t,kind:`flag`}));return[n.arguments,a]}),Hoe=Y(function*(e,t,n,r){let i=[],a=r?.min??0,o=r?.max??1/0,s=0,c=n.arguments;for(;c.length>0&&s<o;){let[t,r]=yield*e.parse({flags:n.flags,arguments:c});i.push(r),c=t,s++}return s<a?yield*s===0?new y3({argument:t.name}):new x3({option:t.name,value:`${s} values`,expected:`at least ${a} value${a===1?``:`s`}`,kind:t.kind}):[c,i]}),Uoe=Y(function*(e,t,n,r){let i=[],a=[t.name,...t.aliases].flatMap(e=>n.flags[e]??[]),o=a.length;if(oM(r?.min)&&o<r.min)return yield*o===0?new v3({option:t.name}):new x3({option:t.name,value:`${o} occurrences`,expected:`at least ${r.min} value${r.min===1?``:`s`}`,kind:t.kind});if(oM(r?.max)&&o>r.max)return yield*new x3({option:t.name,value:`${o} occurrences`,expected:`at most ${r.max} value${r.max===1?``:`s`}`,kind:t.kind});for(let n of a){let[,r]=yield*e.parse({flags:{[t.name]:[n]},arguments:[]});i.push(r)}return[n.arguments,i]}),X6=(e,t)=>{let n=e;switch(n._tag){case`Single`:return t.Single(n);case`Map`:return t.Map(n);case`Transform`:return t.Transform(n);case`Optional`:return t.Optional(n);case`Variadic`:return t.Variadic(n)}},Z6=(e,t)=>X6(e,{Single:e=>t(e),Map:e=>K6(Z6(e.param,t),e.f),Transform:e=>q6(Z6(e.param,t),e.f,e.alternatives.map(e=>()=>Z6(e(),t))),Optional:e=>Y6(Z6(e.param,t)),Variadic:e=>Loe(Z6(e.param,t),{min:XP(e.min),max:XP(e.max)})}),Q6=e=>X6(e,{Single:e=>[e],Map:e=>Q6(e.param),Transform:e=>[...Q6(e.param),...e.alternatives.flatMap(e=>Q6(e()))],Optional:e=>Q6(e.param),Variadic:e=>Q6(e.param)}),$6=e=>{let t=Q6(e);if(t.length===0)throw Error(`No Single param found in param structure`);if(t.length>1)throw Error(`Multiple Single params found: ${t.map(e=>e.name).join(`, `)}`);return t[0]},e8=e=>X6(e,{Single:()=>({isOptional:!1,isVariadic:!1,variadicMin:V(),variadicMax:V()}),Map:e=>e8(e.param),Transform:e=>e8(e.param),Optional:e=>({...e8(e.param),isOptional:!0}),Variadic:e=>({...e8(e.param),isVariadic:!0,variadicMin:e.min,variadicMax:e.max})}),t8=xF(`effect/cli/CliOutput`,{defaultValue:()=>i8()}),Woe={present:Y(function*(e){let t=yield*wW(),n=mF(t,t8)??i8({colors:_F(t,z6).canColor});switch(e._tag){case`Help`:return yield*Y4(n.formatHelpDoc(e.helpDoc));case`InvalidInvocation`:return yield*Y4(n.formatHelpDoc(e.helpDoc)),yield*J4(n.formatErrors(e.errors));case`Version`:return yield*Y4(n.formatVersion(e.name,e.version))}})},n8=xF(`effect/cli/CliOutput/Presenter`,{defaultValue:()=>Woe}),r8=e=>e.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g,e=>`\\x${e.charCodeAt(0).toString(16).padStart(2,`0`)}`),i8=e=>{let t=e?.colors??q3(),n=t?{bold:e=>`\x1b[1m${e}\x1b[0m`,dim:e=>`\x1b[2m${e}\x1b[0m`,cyan:e=>`\x1b[36m${e}\x1b[0m`,green:e=>`\x1b[32m${e}\x1b[0m`,blue:e=>`\x1b[34m${e}\x1b[0m`,yellow:e=>`\x1b[33m${e}\x1b[0m`,magenta:e=>`\x1b[35m${e}\x1b[0m`}:{bold:e=>e,dim:e=>e,cyan:e=>e,green:e=>e,blue:e=>e,yellow:e=>e,magenta:e=>e},r=t?`\x1B[0m`:``,i=t?`\x1B[31m`:``,a=t?`\x1B[1m`:``;return{formatHelpDoc:e=>Qoe(e,n),formatCliError:e=>r8(e.message),formatError:e=>`\n${a}${i}ERROR${r}\n ${r8(e.message)}${r}`,formatErrors:e=>{if(e.length===0)return``;if(e.length===1)return`\n${a}${i}ERROR${r}\n ${r8(e[0].message)}${r}`;let t=new Map;for(let n of e){let e=n._tag??`Error`,r=t.get(e)??[];r.push(n),t.set(e,r)}let n=[];n.push(`\n${a}${i}ERRORS${r}`);for(let[,e]of t)for(let t of e)n.push(` ${r8(t.message)}${r}`);return n.join(`
|
|
365
|
+
`)},formatVersion:(e,t)=>`${n.bold(e)} ${n.dim(`v`)}${n.bold(t)}`}},Goe=e=>e.replace(/\u001B\[[0-9;]*m/g,``),Koe=new Intl.Segmenter(void 0,{granularity:`grapheme`}),qoe=/[\p{Mark}\p{Control}\p{Default_Ignorable_Code_Point}]/gu,Joe=/\p{Emoji_Presentation}/u,Yoe=e=>e<4352?!1:e<=4447||e===9001||e===9002||e>=11904&&e<=12350||e>=12352&&e<=42191||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65135||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=110592&&e<=111359||e>=127488&&e<=127569||e>=131072&&e<=262141,Xoe=e=>{let t=e.replace(qoe,``);return t.length===0?0:Joe.test(e)||e.includes(`️`)||Yoe(t.codePointAt(0))?2:1},a8=e=>{let t=0;for(let{segment:n}of Koe.segment(Goe(e)))t+=Xoe(n);return t},Zoe=(e,t)=>{let n=a8(e),r=Math.max(0,t-n);return e+` `.repeat(r)},o8=(e,t)=>{let n=Math.max(...e.map(e=>a8(e.left)))+4,r=t===void 0?n:Math.min(n,t);return e.map(({left:e,right:t})=>` ${Zoe(e,Math.max(r,a8(e)+1))}${t}`).join(`
|
|
366
|
+
`)},s8=(e,t)=>t?`${e}, ${t}`:e,Qoe=(e,t)=>{let n=[];if(e.description&&(n.push(t.bold(`DESCRIPTION`)),n.push(` ${e.description}`),n.push(``)),n.push(t.bold(`USAGE`)),n.push(` ${t.cyan(e.usage)}`),n.push(``),e.args&&e.args.length>0){n.push(t.bold(`ARGUMENTS`));let r=e.args.map(e=>{let n=e.name;e.variadic&&(n+=`...`);let r=`${t.green(n)} ${t.dim(e.type)}`,i=e.required?``:t.dim(` (optional)`);return{left:r,right:qP(e.description,()=>``)+i}});n.push(o8(r,25)),n.push(``)}if(e.flags.length>0){n.push(t.bold(`FLAGS`));let r=e.flags.map(e=>{let n=[];n.push(t.green(`--${e.name}`));for(let r of e.aliases)n.push(t.green(r));return{left:n.join(`, `)+(e.type===`boolean`?``:` ${t.dim(e.type)}`),right:qP(e.description,()=>``)}});n.push(o8(r)),n.push(``)}if(e.globalFlags&&e.globalFlags.length>0){n.push(t.bold(`GLOBAL FLAGS`));let r=e.globalFlags.map(e=>{let n=[];n.push(t.green(`--${e.name}`));for(let r of e.aliases)n.push(t.green(r));return{left:n.join(`, `)+(e.type===`boolean`?``:` ${t.dim(e.type)}`),right:qP(e.description,()=>``)}});n.push(o8(r)),n.push(``)}if(e.subcommands&&e.subcommands.length>0){let r=e.subcommands.find(e=>e.group===void 0);r&&(n.push(t.bold(`SUBCOMMANDS`)),n.push(o8(r.commands.map(e=>({left:t.cyan(s8(e.name,e.alias)),right:e.shortDescription??e.description})),20)),e.subcommands.length>1&&n.push(``));for(let r of e.subcommands)r.group!==void 0&&(n.push(t.bold(`${r.group}:`)),n.push(o8(r.commands.map(e=>({left:t.cyan(s8(e.name,e.alias)),right:e.shortDescription??e.description})),20)),n.push(``))}if(e.examples&&e.examples.length>0){n.push(t.bold(`EXAMPLES`));let r=!0,i=!1;for(let a of e.examples)a.description?(r||n.push(``),n.push(` ${t.dim(`# ${a.description}`)}`)):i&&n.push(``),n.push(` ${t.cyan(a.command)}`),r=!1,i=!!a.description;n.push(``)}return n[n.length-1]===``&&n.pop(),n.join(`
|
|
367
|
+
`)},c8=`~effect/cli/Command/Config/Internal`,l8=e=>{let t=[],n=[],r=[];function i(e){let t=Object.create(null);for(let n of Object.keys(e))t[n]=a(e[n]);return t}function a(e){if(Array.isArray(e))return{_tag:`Array`,children:e.map(e=>a(e))};if(koe(e)){let i=t.length;return t.push(e),e.kind===`argument`?r.push(e):n.push(e),{_tag:`Param`,index:i}}return{_tag:`Nested`,tree:i(e)}}return{[c8]:c8,flags:n,arguments:r,orderedParams:t,tree:i(e)}},$oe=l8({}),u8=(e,t)=>{let n={};for(let t of Object.keys(e))wN(n,t,r(e[t]));return n;function r(e){switch(e._tag){case`Param`:return t[e.index];case`Array`:return e.children.map(e=>r(e));case`Nested`:return u8(e.tree,t)}}},d8=`~effect/cli/Command`,f8=e=>e,ese={...CP({label:`Command`,evaluate(){return f8(this).service}})},p8=e=>{let t=e.config,n=e.contextConfig??$oe,r=e.service??$P(`~effect/cli/Command/${e.name}`),i=e.annotations??dF(),a=e.globalFlags??[],o=e.subcommands??[],s=e.resolveExamples??tse,c=(t,n)=>oM(e.handle)?e.handle(t,n):K(new E3({commandPath:n,errors:[]})),l=e.parse??h8(t),u=e.parseContext??h8(n,{allowLeftovers:!0}),d=n=>{let r=[],a=[];for(let e of t.arguments){let t=Q6(e),n=e8(e);for(let e of t)r.push({name:e.name,type:e.typeName??F3(e.primitiveType),description:e.description,required:!n.isOptional&&(!n.isVariadic||hie(n.variadicMin,e=>e>0)),variadic:n.isVariadic})}let c=n.length>0?n.join(` `):e.name;o.some(e=>e.commands.some(e=>!e.unlisted))&&(c+=` <subcommand>`),c+=` [flags]`;for(let e of r){let t=e.variadic?`<${e.name}...>`:`<${e.name}>`;c+=` ${e.required?t:`[${t}]`}`}for(let e of t.flags){let t=Q6(e),n=e8(e);for(let e of t)e.hidden||a.push(m8(e,n))}let l=[];for(let e of o){let t=e.commands.filter(e=>!e.unlisted);t.length!==0&&l.push({group:e.group,commands:IF(t,e=>({name:e.name,alias:e.alias,shortDescription:e.shortDescription,description:e.description??``}))})}let u=s(n);return{description:e.description??``,usage:c,flags:a,annotations:i,...r.length>0&&{args:r},...l.length>0&&{subcommands:l},...u.length>0&&{examples:u}}};return Object.assign(Object.create(ese),{[d8]:d8,name:e.name,examples:s([e.name]),resolveExamples:s,annotations:i,globalFlags:a,subcommands:o,unlisted:e.unlisted??!1,config:t,contextConfig:n,service:r,parse:l,parseContext:u,handle:c,buildHelpDoc:d,...oM(e.description)?{description:e.description}:{},...oM(e.shortDescription)?{shortDescription:e.shortDescription}:{},...oM(e.alias)?{alias:e.alias}:{}})},tse=()=>[],m8=(e,t)=>{let n=e.aliases.map(e=>e.length===1?`-${e}`:`--${e}`),r=e.typeName??F3(e.primitiveType);return{name:e.name,aliases:n,type:e.optionalValue===void 0?r:`[=${r}]`,description:nse(e.description,I3(e.primitiveType)),required:e.primitiveType._tag!==`Boolean`&&!t.isOptional}},nse=(e,t)=>{if(t===void 0||t.length===0)return e;let n=`(choices: ${t.join(`, `)})`;return KP(e,{onNone:()=>UP(n),onSome:e=>UP(`${e} ${n}`)})},h8=(e,t)=>Y(function*(n){let r={flags:n.flags,arguments:n.arguments},[i,a]=yield*rse(r,e.orderedParams);return t?.allowLeftovers!==!0&&i.length>0?yield*new b3({arguments:i}):u8(e.tree,a)}),rse=Y(function*(e,t){let n=[],r=e.arguments;for(let i of t){let[t,a]=yield*i.parse({flags:e.flags,arguments:r});n.push(a),r=t}return[r,n]}),ise=(e,t,n)=>{let r=f8(e),i=new Set;(e=>{for(let t of e){let e=Q6(t);for(let t of e)i.add(t.name)}})((n?.contextConfig??r.contextConfig).flags);for(let n of t){let t=f8(n);for(let r of t.config.flags){let t=Q6(r);for(let r of t)if(i.has(r.name))throw new _3({option:r.name,parentCommand:e.name,childCommand:n.name})}}},ase=e=>{switch(e.primitiveType._tag){case`Boolean`:return{_tag:`Boolean`};case`Int`:return{_tag:`Int`};case`Finite`:return{_tag:`Finite`};case`Date`:return{_tag:`Date`};case`Choice`:return{_tag:`Choice`,values:I3(e.primitiveType)??[]};case`Path`:return{_tag:`Path`,pathType:L3(e.primitiveType)??`either`};case`FileText`:case`FileParse`:case`FileSchema`:return{_tag:`Path`,pathType:`file`};default:return{_tag:`String`}}},ose=e=>{switch(e.primitiveType._tag){case`Int`:return{_tag:`Int`};case`Finite`:return{_tag:`Finite`};case`Date`:return{_tag:`Date`};case`Choice`:return{_tag:`Choice`,values:I3(e.primitiveType)??[]};case`Path`:return{_tag:`Path`,pathType:L3(e.primitiveType)??`either`};case`FileText`:case`FileParse`:case`FileSchema`:return{_tag:`Path`,pathType:`file`};default:return{_tag:`String`}}},g8=(e,t=[])=>{let n=f8(e),r=n.config,i=[],a=new Set;for(let[e,n]of[...r.flags,...t].entries()){let t=Q6(n);for(let n of t)n.kind===`flag`&&(n.hidden||e>=r.flags.length&&a.has(n.name)||(a.add(n.name),i.push({name:n.name,aliases:n.aliases,description:XP(n.description),type:ase(n),optionalValue:n.optionalValue!==void 0,negation:n.negation})))}let o=[];for(let e of r.arguments){let t=Q6(e),n=e8(e);for(let e of t)e.kind===`argument`&&o.push({name:e.name,description:XP(e.description),required:!n.isOptional,variadic:n.isVariadic,type:ose(e)})}let s=[],c=[...t,...n.contextConfig.flags];for(let t of e.subcommands)for(let e of t.commands){if(e.unlisted)continue;let t=g8(e,c);s.push(t),e.alias&&e.alias!==e.name&&s.push({...t,name:e.alias})}return{name:e.name,description:e.shortDescription??e.description,flags:i,arguments:o,subcommands:s}},_8=e=>e.type._tag!==`Boolean`&&e.optionalValue!==!0,v8=e=>e.type._tag!==`Boolean`||e.negation===!1?void 0:e.negation??`no-${e.name}`,y8=e=>e.replace(/'/g,`'\\''`),b8=e=>e.replace(/[^a-zA-Z0-9_]/g,`_`),x8=e=>{let t=[`--${e.name}`];for(let n of e.aliases)t.push(n.length===1?`-${n}`:`--${n}`);let n=v8(e);return n!==void 0&&t.push(`--${n}`),t},sse=(e,t)=>{if(e.length===0)return;let n=e.map(x8);t.push(` local ${n.map((e,t)=>`_used_${t}=""`).join(` `)}`),t.push(` for ((i = 1; i < cword; i++)); do`),t.push(' case "${words[i]%%=*}" in'),n.forEach((e,n)=>{t.push(` ${e.join(`|`)}) _used_${n}=1 ;;`)}),t.push(` esac`),t.push(` done`),t.push(` local _filtered_flags=""`),n.forEach((e,n)=>{t.push(` [[ -n "$_used_${n}" ]] || _filtered_flags+=" ${e.join(` `)}"`)}),t.push(``)},S8=e=>[`\\\\`,`\\"`,`\\'`].map(t=>`${e}=\${${e}//${t}/}`).join(`; `),cse=(e,t)=>{t.push(`${e}()`),t.push(`{`),t.push(` local _cur="$1" _word="$2"; shift 2`),t.push(``),t.push(' local _head="${_cur%"$_word"}"'),t.push(` local _open=""`),t.push(` case "$_head" in`),t.push(` *\\') _open="'" ;;`),t.push(` *\\") _open='"' ;;`),t.push(` esac`),t.push(``),t.push(` local _prefix="$_cur" _committed="$_head"`),t.push(` ${S8(`_prefix`)}`),t.push(` ${S8(`_committed`)}`),t.push(``),t.push(` COMPREPLY=()`),t.push(` local _choice _rest _match`),t.push(` for _choice in "$@"; do`),t.push(` [[ "$_choice" == "$_prefix"* ]] || continue`),t.push(' _rest="${_choice#"$_committed"}"'),t.push(` case "$_open" in`),t.push(` "'")`),t.push(` if [[ "$_head" == "'" ]]; then`),t.push(" _match=${_rest//\\'/\\'\\\\\\'\\'}"),t.push(` else`),t.push(` [[ "$_rest" == *\\'* ]] && continue`),t.push(` _match="$_rest"`),t.push(` fi`),t.push(` ;;`),t.push(` '"')`),t.push(' _match="${_rest//\\\\/\\\\\\\\}"'),t.push(' _match="${_match//\\$/\\\\$}"'),t.push(' _match="${_match//\\`/\\\\\\`}"'),t.push(' _match="${_match//\\"/\\\\\\"}"'),t.push(` ;;`),t.push(` *)`),t.push(` printf -v _match '%q' "$_rest"`),t.push(` [[ -z "$_head" && "$_match" == '~'* ]] && _match="\\\\$_match"`),t.push(` ;;`),t.push(` esac`),t.push(` [[ -n "$_open" && "$_match" == *"$_open" ]] && _match+="$_open"`),t.push(` COMPREPLY+=("$_match")`),t.push(` done`),t.push(`}`),t.push(``)},lse=(e,t)=>{t.push(`${e.paths}()`),t.push(`{`),t.push(` local _kind="$1" _cur="$2" _word="$3"`),t.push(``),t.push(' local _prefix="$_cur" _committed="${_cur%"$_word"}"'),t.push(` ${S8(`_prefix`)}`),t.push(` ${S8(`_committed`)}`),t.push(``),t.push(` local _typed="" _dir="$_committed" _open="" _i`),t.push(` if [[ "$_word" == */* ]]; then`),t.push(' _typed="${_word%/*}/"'),t.push(' _dir="${_prefix%/*}/"'),t.push(` if [[ "$_cur" == "$_word" ]]; then`),t.push(" for ((_i = 0; _i < ${#_typed}; _i++)); do"),t.push(' case "$_open${_typed:_i:1}" in'),t.push(` \\\\|\\"\\\\) ((_i += 1)) ;;`),t.push(` \\"|\\') _open="\${_typed:_i:1}" ;;`),t.push(` \\"\\"|\\'\\') _open="" ;;`),t.push(` esac`),t.push(` done`),t.push(` fi`),t.push(` fi`),t.push(``),t.push(' local _path _names=() _rest="${_word#"$_typed"}"'),t.push(` while IFS= read -r _path; do`),t.push(` if [[ "$_path" == "$_dir"* ]]; then`),t.push(' _names+=("$_committed${_path#"$_dir"}")'),t.push(` elif [[ -z "$_committed" ]]; then`),t.push(` _names+=("$_path")`),t.push(` _typed="" _rest="" _open=""`),t.push(` fi`),t.push(` done < <(compgen "$_kind" -- "$_prefix")`),t.push(` if [[ -n "$_open" ]]; then`),t.push(` _typed+="$_open"`),t.push(' _rest="${_prefix##*/}"'),t.push(` fi`),t.push(``),t.push(` ${e.choices} "\${_cur%"$_word"}$_rest" "$_rest" "\${_names[@]}"`),t.push(" for ((_i = 0; _i < ${#COMPREPLY[@]}; _i++)); do"),t.push(' COMPREPLY[_i]="$_typed${COMPREPLY[_i]}"'),t.push(` done`),t.push(`}`),t.push(``)},C8=(e,t)=>{switch(e._tag){case`Choice`:{let n=e.values.map(e=>`'${y8(e)}'`).join(` `);return`${t.choices} "$cur" "$_comp_word" ${n}`}case`Path`:return`${t.paths} ${e.pathType===`directory`?`-d`:`-f`} "$cur" "$_comp_word"`;default:return}},w8=(e,t,n,r)=>{let i=[...t,e.name],a=`_${i.map(b8).join(`_`)}`;n.push(`${a}()`),n.push(`{`),n.push(` local cur prev words cword i`),n.push(t.length===0?` local _command_index=0`:` local _command_index="$1"`),n.push(` _init_completion -n "$COMP_WORDBREAKS" || return`),t.length===0&&n.push(` local _comp_word="$2"`),n.push(``);let o=e.flags.filter(_8);if(o.length>0){n.push(` # Flag value completions`),n.push(` case "$prev" in`);for(let e of o){let t=[`--${e.name}`];for(let n of e.aliases)t.push(n.length===1?`-${n}`:`--${n}`);let i=C8(e.type,r);i&&(n.push(` ${t.join(`|`)})`),n.push(` ${i}`),n.push(` return`),n.push(` ;;`))}n.push(` esac`),n.push(``)}if(e.subcommands.length>0){n.push(` # Subcommand dispatch`),n.push(` local cmd _skip_next=0`),n.push(` for ((i = _command_index + 1; i < cword; i++)); do`),n.push(` if (( _skip_next )); then`),n.push(` _skip_next=0`),n.push(` continue`),n.push(` fi`),n.push(' case "${words[i]}" in');for(let t of e.flags){if(!_8(t))continue;let e=x8(t);n.push(` ${e.join(`|`)}) _skip_next=1 ;;`),n.push(` ${e.map(e=>`${e}=*`).join(`|`)}) ;;`)}for(let t of e.subcommands){let e=`_${[...i,t.name].map(b8).join(`_`)}`;n.push(` ${t.name})`),n.push(` ${e} "$i"`),n.push(` return`),n.push(` ;;`)}n.push(` esac`),n.push(` done`),n.push(``)}sse(e.flags,n),(e.flags.length>0||e.subcommands.length>0)&&(n.push(` # Complete flags (filtered) and subcommands`),n.push(` if [[ "$cur" == -* ]]; then`),e.flags.length>0&&n.push(` COMPREPLY=( $(compgen -W "$_filtered_flags" -- "$cur") )`),n.push(` return`),n.push(` fi`),n.push(``));let s=e.arguments.flatMap((e,t)=>{let n=C8(e.type,r);return n===void 0?[]:[{argument:e,completion:n,index:t}]});if(s.length>0){n.push(` # Positional argument completions`),n.push(` local _position=0 _skip_next=0 _end_of_options=0`),n.push(` for ((i = _command_index + 1; i < cword; i++)); do`),n.push(` if (( _skip_next )); then`),n.push(` _skip_next=0`),n.push(` continue`),n.push(` fi`),n.push(` if (( _end_of_options )); then`),n.push(` ((_position += 1))`),n.push(` continue`),n.push(` fi`),n.push(' case "${words[i]}" in'),n.push(` --) _end_of_options=1 ;;`);for(let t of e.flags){let e=x8(t);_8(t)?(n.push(` ${e.join(`|`)}) _skip_next=1 ;;`),n.push(` ${e.map(e=>`${e}=*`).join(`|`)}) ;;`)):n.push(` ${e.join(`|`)}) ;;`)}n.push(` -*) ;;`),n.push(` *) ((_position += 1)) ;;`),n.push(` esac`),n.push(` done`),n.push(` case "$_position" in`);for(let{argument:e,completion:t,index:r}of s)e.variadic||(n.push(` ${r})`),n.push(` ${t}`),n.push(` return`),n.push(` ;;`));n.push(` esac`);let t=s.find(({argument:e})=>e.variadic);t!==void 0&&(n.push(` if (( _position >= ${t.index} )); then`),n.push(` ${t.completion}`),n.push(` return`),n.push(` fi`))}else if(e.subcommands.length>0){let t=e.subcommands.map(e=>e.name);n.push(` COMPREPLY=( $(compgen -W '${t.join(` `)}' -- "$cur") )`)}n.push(`}`),n.push(``);for(let t of e.subcommands)w8(t,i,n,r)},use=(e,t)=>{let n=[],r=b8(e),i={choices:`_${r}--choices`,paths:`_${r}--paths`};return n.push(`###-begin-${y8(e)}-completions-###`),n.push(`#`),n.push(`# Static completion script for Bash`),n.push(`#`),n.push(`# Installation:`),n.push(`# ${y8(e)} --completions bash >> ~/.bashrc`),n.push(`#`),n.push(``),n.push(`if ! type _init_completion &>/dev/null; then`),n.push(` _init_completion()`),n.push(` {`),n.push(` COMPREPLY=()`),n.push(` local _i _j=0 _piece _line="$COMP_LINE"`),n.push(' words=("${COMP_WORDS[0]}")'),n.push(` cword=0`),n.push(' _line="${_line#*"${COMP_WORDS[0]}"}"'),n.push(" for ((_i = 1; _i < ${#COMP_WORDS[@]}; _i++)); do"),n.push(' _piece="${COMP_WORDS[_i]}"'),n.push(` if [[ "$_line" == [[:blank:]]* ]]; then`),n.push(` ((_j++))`),n.push(` words[_j]="$_piece"`),n.push(` else`),n.push(' words[_j]="${words[_j]}$_piece"'),n.push(` fi`),n.push(` ((_i == COMP_CWORD)) && cword=$_j`),n.push(' _line="${_line#*"$_piece"}"'),n.push(` done`),n.push(' cur="${words[cword]}"'),n.push(` prev=""`),n.push(' ((cword > 0)) && prev="${words[cword-1]}"'),n.push(` return 0`),n.push(` }`),n.push(`fi`),n.push(``),cse(i.choices,n),lse(i,n),w8(t,[],n,i),n.push(`complete -F _${r} ${y8(e)}`),n.push(`###-end-${y8(e)}-completions-###`),n.join(`
|
|
368
|
+
`)},T8=e=>e.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`),E8=e=>T8(e.replace(/[^A-Za-z0-9_.,/@%+-]/gu,`\\$&`)),dse=(e,t)=>{if(e.length===0)return t.length>0?`__fish_use_subcommand`:``;let n=e.map(e=>`__fish_seen_subcommand_from ${e}`).join(`; and `);return t.length>0?`${n}; and not __fish_seen_subcommand_from ${t.join(` `)}`:n},D8=e=>{let t=[];for(let n of e.aliases)n.length===1&&t.push(`-s ${n}`);t.push(e.name);for(let n of e.aliases)n.length>1&&t.push(n);let n=v8(e);return n!==void 0&&t.push(n),`not __fish_contains_opt ${t.join(` `)}`},fse=e=>{let t=[`--${e.name}`];for(let n of e.aliases)t.push(n.length===1?`-${n}`:`--${n}`);return`begin; ${D8(e)}; or contains -- (commandline -poc)[-1] ${t.join(` `)}; end`},pse=e=>{let t=[`-l ${e.name}`];for(let n of e.aliases)n.length===1?t.push(`-s ${n}`):t.push(`-l ${n}`);e.description&&t.push(`-d '${T8(e.description)}'`);let n=_8(e)?mse(e.type):void 0;return n&&t.push(n),t},mse=e=>{switch(e._tag){case`Boolean`:return;case`Choice`:return`-r -f -a '${e.values.map(E8).join(` `)}'`;case`Path`:return e.pathType,`-r -F`;default:return`-r -f`}},hse=e=>{switch(e._tag){case`Choice`:return`-r -f -a '${e.values.map(E8).join(` `)}'`;case`Path`:return`-r -F`;default:return}},O8=(e,t,n,r)=>{let i=t.subcommands.map(e=>e.name),a=dse(n,i),o=a?`-n '${a}'`:``;if(!t.arguments.some(e=>e.type._tag===`Path`)){let t=[`complete -c ${e}`];o&&t.push(o),t.push(`-f`),r.push(t.join(` `))}for(let n of t.subcommands){let t=[`complete -c ${e}`];o&&t.push(o),t.push(`-f -a '${T8(n.name)}'`),n.description&&t.push(`-d '${T8(n.description)}'`),r.push(t.join(` `))}for(let n of t.flags){let t=_8(n)?fse(n):D8(n),i=a?`${a}; and ${t}`:t,o=i?`-n '${i}'`:``,s=[`complete -c ${e}`];o&&s.push(o),s.push(...pse(n)),r.push(s.join(` `));let c=v8(n);if(c!==void 0){let t=[`complete -c ${e}`];o&&t.push(o),t.push(`-l ${c}`),n.description&&t.push(`-d '${T8(`Disable ${n.name}`)}'`),r.push(t.join(` `))}}if(t.flags.length>0){let n=`not string match -q -- "-*" (commandline -ct)`,i=a?`${a}; and ${n}`:n;for(let n of t.flags){let t=`${i}; and ${D8(n)}`,a=v8(n),o=[`complete -c ${e}`];if(o.push(`-n '${t}'`),o.push(`-f -a '--${n.name}'`),n.description&&o.push(`-d '${T8(n.description)}'`),r.push(o.join(` `)),a!==void 0){let i=[`complete -c ${e}`];i.push(`-n '${t}'`),i.push(`-f -a '--${a}'`),n.description&&i.push(`-d '${T8(`Disable ${n.name}`)}'`),r.push(i.join(` `))}}}for(let n of t.arguments){let t=hse(n.type);if(t){let i=[`complete -c ${e}`];o&&i.push(o),i.push(t),n.description&&i.push(`-d '${T8(n.description)}'`),r.push(i.join(` `))}}for(let i of t.subcommands)O8(e,i,[...n,i.name],r)},gse=(e,t)=>{let n=[];return n.push(`###-begin-${e}-completions-###`),n.push(`#`),n.push(`# Static completion script for Fish`),n.push(`#`),n.push(`# Installation:`),n.push(`# ${e} --completions fish > ~/.config/fish/completions/${e}.fish`),n.push(`#`),n.push(``),O8(e,t,[],n),n.push(``),n.push(`###-end-${e}-completions-###`),n.join(`
|
|
369
|
+
`)},k8=e=>{let t=[],n=``;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);if(i>=32&&i<128){n+=e[r]===`'`?`''`:e[r];continue}(n!==``||t.length===0)&&t.push(`'${n}'`),n=``,t.push(`[char]0x${i.toString(16).toUpperCase().padStart(4,`0`)}`)}return(n!==``||t.length===0)&&t.push(`'${n}'`),t.length===1?t[0]:`(${t.join(` + `)})`},A8=e=>`@(${e.map(k8).join(`, `)})`,j8=e=>e?k8(e):`$null`,_se=e=>e.replace(/[^a-zA-Z0-9_]/g,`_`),vse=e=>[`--${e.name}`,...e.aliases.map(e=>e.length===1?`-${e}`:`--${e}`)],M8=e=>`values = ${A8(e._tag===`Choice`?e.values:[])}; pathType = ${e._tag===`Path`?k8(e.pathType):`$null`}`,yse=e=>{let t=v8(e);return`@{ name = ${k8(e.name)}; forms = ${A8(vse(e))}; takesValue = $${e.type._tag!==`Boolean`}; `+(t===void 0?``:`negation = ${k8(`--${t}`)}; `)+(e.optionalValue===!0?`optionalValue = $true; `:``)+`${M8(e.type)}; description = ${j8(e.description)} }`},bse=e=>`@{ name = ${k8(e.name)}; variadic = $${e.variadic}; ${M8(e.type)}; description = ${j8(e.description)} }`,N8=(e,t,n)=>{if(n.length===0){e.push(` ${t} = @()`);return}e.push(` ${t} = @(`);for(let t of n)e.push(` ${t}`);e.push(` )`)},P8=(e,t,n,r,i)=>{let a=n.join(` `);if(!i.has(a)){i.add(a),r.push(`${e}[${k8(a)}] = @{`),N8(r,`subcommands`,t.subcommands.map(e=>`@{ name = ${k8(e.name)}; description = ${j8(e.description)} }`)),N8(r,`flags`,t.flags.map(yse)),N8(r,`arguments`,t.arguments.map(bse)),r.push(`}`);for(let a of t.subcommands)P8(e,a,[...n,a.name],r,i)}},xse=e=>String.raw` param($wordToComplete, $commandAst, $cursorPosition)
|
|
370
|
+
|
|
371
|
+
$spec = ${e}
|
|
372
|
+
$results = [System.Collections.Generic.List[System.Management.Automation.CompletionResult]]::new()
|
|
373
|
+
$booleanLiterals = @('true', 'yes', 'on', '1', 'y', 'false', 'no', 'off', '0', 'n')
|
|
374
|
+
|
|
375
|
+
$index = {
|
|
376
|
+
param($context)
|
|
377
|
+
$lookup = [hashtable]::new([System.StringComparer]::Ordinal)
|
|
378
|
+
foreach ($flag in $context.flags) {
|
|
379
|
+
foreach ($form in $flag.forms) { $lookup[$form] = $flag }
|
|
380
|
+
}
|
|
381
|
+
$lookup
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
$add = {
|
|
385
|
+
param([string]$value, [string]$type, $tooltip, [string]$typed, [string]$textPrefix)
|
|
386
|
+
if (-not $value.StartsWith($typed, [System.StringComparison]::OrdinalIgnoreCase)) { return }
|
|
387
|
+
$text = $value
|
|
388
|
+
if ($value -notmatch '^[\w./:%+=\\-]+$') { $text = "'" + ($value -replace "['\u2018-\u201b]", '$0$0') + "'" }
|
|
389
|
+
$text = $textPrefix + $text
|
|
390
|
+
$label = $value
|
|
391
|
+
if (-not $label) { $label = $text }
|
|
392
|
+
if (-not $tooltip) { $tooltip = $label }
|
|
393
|
+
$results.Add([System.Management.Automation.CompletionResult]::new($text, $label, $type, $tooltip))
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
$addValues = {
|
|
397
|
+
param($entry, [string]$typed, [string]$textPrefix)
|
|
398
|
+
foreach ($value in $entry.values) {
|
|
399
|
+
if ($textPrefix -eq '' -and (& $optionLike $value)) { continue }
|
|
400
|
+
& $add $value 'ParameterValue' $entry.description $typed $textPrefix
|
|
401
|
+
}
|
|
402
|
+
if ($entry.pathType) {
|
|
403
|
+
foreach ($file in [System.Management.Automation.CompletionCompleters]::CompleteFilename($typed)) {
|
|
404
|
+
if ($entry.pathType -eq 'directory' -and $file.ResultType -ne 'ProviderContainer') { continue }
|
|
405
|
+
$results.Add([System.Management.Automation.CompletionResult]::new($textPrefix + $file.CompletionText, $file.ListItemText, $file.ResultType, $file.ToolTip))
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
$addFlags = {
|
|
411
|
+
param([string]$typed)
|
|
412
|
+
foreach ($flag in $context.flags) {
|
|
413
|
+
if ($used.ContainsKey($flag.name)) { continue }
|
|
414
|
+
foreach ($form in $flag.forms) {
|
|
415
|
+
& $add $form 'ParameterName' $flag.description $typed ''
|
|
416
|
+
}
|
|
417
|
+
if ($flag.negation) {
|
|
418
|
+
$tooltip = $null
|
|
419
|
+
if ($flag.description) { $tooltip = 'Disable ' + $flag.name }
|
|
420
|
+
& $add $flag.negation 'ParameterName' $tooltip $typed ''
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
# As in the CLI lexer, nothing after '--' is an option, and negative numbers
|
|
426
|
+
# and a lone '-' are values.
|
|
427
|
+
$optionLike = {
|
|
428
|
+
param([string]$word)
|
|
429
|
+
-not $endOfOptions -and $word -match '^-.' -and $word -notmatch '^-(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$'
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
# A typed value that has no candidates completes to itself, so the engine
|
|
433
|
+
# does not fall back to listing files.
|
|
434
|
+
$keepTyped = {
|
|
435
|
+
if ($results.Count -eq 0 -and $current) {
|
|
436
|
+
$results.Add([System.Management.Automation.CompletionResult]::new($current, $current, 'ParameterValue', $current))
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
$path = ''
|
|
441
|
+
$context = $spec[$path]
|
|
442
|
+
$lookup = & $index $context
|
|
443
|
+
$used = [hashtable]::new([System.StringComparer]::Ordinal)
|
|
444
|
+
$pending = $null
|
|
445
|
+
$endOfOptions = $false
|
|
446
|
+
$position = 0
|
|
447
|
+
|
|
448
|
+
# The engine strips the quotes from a quoted word.
|
|
449
|
+
$typed = [string]$wordToComplete
|
|
450
|
+
if ($typed -match '^([''"])(.*?)\1?$') { $typed = $Matches[2] }
|
|
451
|
+
$current = $null
|
|
452
|
+
|
|
453
|
+
$elements = $commandAst.CommandElements
|
|
454
|
+
for ($i = 1; $i -lt $elements.Count; $i++) {
|
|
455
|
+
$element = $elements[$i]
|
|
456
|
+
$word = $element.Extent.Text
|
|
457
|
+
if ($element -is [System.Management.Automation.Language.StringConstantExpressionAst]) { $word = $element.Value }
|
|
458
|
+
if ($element.Extent.EndOffset -ge $cursorPosition) {
|
|
459
|
+
if ($element -is [System.Management.Automation.Language.ConstantExpressionAst] -and $element.Extent.StartOffset -le $cursorPosition) {
|
|
460
|
+
$current = $element.Extent.Text
|
|
461
|
+
if ($element.Extent.EndOffset -eq $cursorPosition) { $typed = $word }
|
|
462
|
+
}
|
|
463
|
+
break
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
# A flag takes the next word as its value unless it is an option or '--';
|
|
467
|
+
# a boolean flag only takes a boolean literal.
|
|
468
|
+
$isOption = & $optionLike $word
|
|
469
|
+
if ($null -ne $pending) {
|
|
470
|
+
$flag = $pending
|
|
471
|
+
$pending = $null
|
|
472
|
+
if ($flag.takesValue) {
|
|
473
|
+
if (-not $isOption) { continue }
|
|
474
|
+
} elseif ($booleanLiterals -ccontains $word) { continue }
|
|
475
|
+
}
|
|
476
|
+
if ($endOfOptions) { $position++; continue }
|
|
477
|
+
if ($word -ceq '--') { $endOfOptions = $true; continue }
|
|
478
|
+
|
|
479
|
+
if ($isOption) {
|
|
480
|
+
$hasValue = $word.Contains('=')
|
|
481
|
+
if ($hasValue) {
|
|
482
|
+
$forms = @($word.Substring(0, $word.IndexOf('=')))
|
|
483
|
+
} elseif ($word.StartsWith('--')) {
|
|
484
|
+
$forms = @($word)
|
|
485
|
+
} else {
|
|
486
|
+
$forms = @(foreach ($char in $word.Substring(1).ToCharArray()) { '-' + $char })
|
|
487
|
+
}
|
|
488
|
+
foreach ($form in $forms) {
|
|
489
|
+
$pending = $null
|
|
490
|
+
$flag = $lookup[$form]
|
|
491
|
+
# As in the CLI parser, a negation wins over an alias but not over a
|
|
492
|
+
# canonical name.
|
|
493
|
+
if ($null -eq $flag -or $form -cne ('--' + $flag.name)) {
|
|
494
|
+
$negated = $null
|
|
495
|
+
foreach ($candidate in $context.flags) {
|
|
496
|
+
if ($candidate.negation -ceq $form) { $negated = $candidate }
|
|
497
|
+
}
|
|
498
|
+
if ($null -ne $negated) {
|
|
499
|
+
$used[$negated.name] = $true
|
|
500
|
+
continue
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
if ($null -eq $flag) { continue }
|
|
504
|
+
$used[$flag.name] = $true
|
|
505
|
+
# A flag with an optional value only takes a value attached with '='.
|
|
506
|
+
if (-not $hasValue -and -not $flag.optionalValue) { $pending = $flag }
|
|
507
|
+
}
|
|
508
|
+
continue
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
if ($position -eq 0 -and $context.subcommands.name -ccontains $word) {
|
|
512
|
+
if ($path) { $path = $path + ' ' + $word } else { $path = $word }
|
|
513
|
+
$context = $spec[$path]
|
|
514
|
+
$lookup = & $index $context
|
|
515
|
+
$used = [hashtable]::new([System.StringComparer]::Ordinal)
|
|
516
|
+
continue
|
|
517
|
+
}
|
|
518
|
+
$position++
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
$typedIsOption = & $optionLike $typed
|
|
522
|
+
if ($null -ne $pending -and $pending.takesValue -and -not $typedIsOption) {
|
|
523
|
+
& $addValues $pending $typed ''
|
|
524
|
+
& $keepTyped
|
|
525
|
+
return $results
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
if ($typedIsOption) {
|
|
529
|
+
if ($typed -match '^(-[^=]+)=(.*)$') {
|
|
530
|
+
$form = $Matches[1]
|
|
531
|
+
$flag = $lookup[$form]
|
|
532
|
+
if ($null -ne $flag -and $flag.takesValue) {
|
|
533
|
+
& $addValues $flag $Matches[2] ($form + '=')
|
|
534
|
+
& $keepTyped
|
|
535
|
+
}
|
|
536
|
+
} else {
|
|
537
|
+
& $addFlags $typed
|
|
538
|
+
}
|
|
539
|
+
return $results
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
if (-not $endOfOptions -and $position -eq 0) {
|
|
543
|
+
foreach ($sub in $context.subcommands) {
|
|
544
|
+
& $add $sub.name 'Command' $sub.description $typed ''
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
$arguments = $context.arguments
|
|
549
|
+
if ($position -lt $arguments.Count) {
|
|
550
|
+
& $addValues $arguments[$position] $typed ''
|
|
551
|
+
} elseif ($arguments.Count -gt 0 -and $arguments[-1].variadic) {
|
|
552
|
+
& $addValues $arguments[-1] $typed ''
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
if (-not $endOfOptions) {
|
|
556
|
+
& $addFlags $typed
|
|
557
|
+
}
|
|
558
|
+
return $results`,Sse=(e,t)=>{let n=`$global:_${_se(e)}_Completions`,r=[];return r.push(`###-begin-${e}-completions-###`),r.push(`#`),r.push(`# Static completion script for PowerShell`),r.push(`#`),r.push(`# Installation:`),r.push(`# ${e} --completions powershell > ${e}-completion.ps1`),r.push(`# then add this line to your $PROFILE (use the full path to the file):`),r.push(`# . <PATH>\\${e}-completion.ps1`),r.push(`#`),r.push(``),r.push(`${n} = [hashtable]::new([System.StringComparer]::Ordinal)`),P8(n,t,[],r,new Set),r.push(``),r.push(`Register-ArgumentCompleter -Native -CommandName ${k8(e)} -ScriptBlock {`),r.push(xse(n)),r.push(`}`),r.push(``),r.push(`###-end-${e}-completions-###`),r.join(`
|
|
559
|
+
`)},F8=e=>e.replace(/\\/g,`\\\\`).replace(/'/g,`'\\''`).replace(/:/g,`\\:`),I8=e=>F8(e).replace(/]/g,`\\]`),L8=e=>e.replace(/[^A-Za-z0-9_.,/@%+-]/gu,`\\$&`).replace(/'/g,`'\\''`),R8=e=>e.replace(/[^a-zA-Z0-9_]/g,`_`),Cse=e=>{let t=[`--${e.name}`];for(let n of e.aliases)t.push(n.length===1?`-${n}`:`--${n}`);let n=v8(e);return n!==void 0&&t.push(`--${n}`),t},z8=e=>{switch(e._tag){case`Boolean`:return``;case`Choice`:return`:value:(${e.values.map(L8).join(` `)})`;case`Path`:return e.pathType===`directory`?`:directory:_directories`:`:file:_files`;case`Int`:return`:integer:`;case`Finite`:return`:float:`;case`Date`:return`:date:`;default:return`:value:`}},wse=e=>{switch(e._tag){case`Choice`:return`(${e.values.map(L8).join(` `)})`;case`Path`:return e.pathType===`directory`?`_directories`:`_files`;default:return``}},B8=e=>{let t=[],n=e.description?`[${I8(e.description)}]`:``,r=e.optionalValue===!0&&e.type._tag!==`Boolean`,i=r?`=-`:``,a=r?`:${z8(e.type)}`:z8(e.type),o=`(${Cse(e).join(` `)})`;t.push(`'${o}--${e.name}${i}${n}${a}'`);for(let r of e.aliases){let e=r.length===1?`-`:`--`;t.push(`'${o}${e}${r}${i}${n}${a}'`)}let s=v8(e);if(s!==void 0){let n=e.description?`[${I8(`Disable ${e.name}`)}]`:``;t.push(`'${o}--${s}${n}'`)}return t},V8=e=>{let t=e.description?F8(e.description):e.name,n=wse(e.type);return`'${e.variadic?`*`:``}:${t}:${n}'`},H8=(e,t,n)=>{let r=[...t,e.name],i=`_${r.map(R8).join(`_`)}`;if(n.push(`${i}() {`),e.subcommands.length>0){n.push(` local context state state_descr line`),n.push(` typeset -A opt_args`),n.push(``),n.push(` local -a commands`),n.push(` commands=(`);for(let t of e.subcommands){let e=t.description?F8(t.description):``;n.push(` '${t.name}:${e}'`)}n.push(` )`),n.push(``),n.push(` local -a specs`),n.push(` specs=(`);for(let t of e.flags)for(let e of B8(t))n.push(` ${e}`);if(e.arguments.length>0){n.push(` -`),n.push(` parent-arguments`);for(let t of e.arguments)n.push(` ${V8(t)}`);n.push(` -`),n.push(` subcommands`)}n.push(` '1:command:->command'`),n.push(` '*::arg:->args'`),n.push(` )`),n.push(``),n.push(' _arguments -C "${specs[@]}"'),n.push(``),n.push(` case "$state" in`),n.push(` command)`),n.push(` _describe -t commands 'commands' commands`),n.push(` ;;`),n.push(` args)`),n.push(` case "$words[1]" in`);for(let t of e.subcommands){let e=`_${[...r,t.name].map(R8).join(`_`)}`;n.push(` ${t.name})`),n.push(` ${e}`),n.push(` ;;`)}n.push(` esac`),n.push(` ;;`),n.push(` esac`)}else{let t=[];for(let n of e.flags)t.push(...B8(n));for(let n of e.arguments)t.push(V8(n));if(t.length>0){n.push(` local -a specs`),n.push(` specs=(`);for(let e of t)n.push(` ${e}`);n.push(` )`),n.push(' _arguments "${specs[@]}"')}}n.push(`}`),n.push(``);for(let t of e.subcommands)H8(t,r,n)},Tse=(e,t)=>{let n=[],r=R8(e);return n.push(`#compdef ${e}`),n.push(`###-begin-${e}-completions-###`),n.push(`#`),n.push(`# Static completion script for Zsh`),n.push(`#`),n.push(`# Installation:`),n.push(`# ${e} --completions zsh > ~/.zsh/completions/_${e}`),n.push(`# then add ~/.zsh/completions to your fpath`),n.push(`#`),n.push(``),H8(t,[],n),n.push(`# Handle both direct invocation and autoload`),n.push('if [[ "${zsh_eval_context[-1]}" == "loadautofunc" ]]; then'),n.push(` _${r} "$@"`),n.push(`else`),n.push(` compdef _${r} ${e}`),n.push(`fi`),n.push(`###-end-${e}-completions-###`),n.join(`
|
|
560
|
+
`)},Ese=e=>g8(e),Dse=(e,t,n)=>{switch(t){case`bash`:return use(e,n);case`zsh`:return Tse(e,n);case`fish`:return gse(e,n);case`powershell`:return Sse(e,n)}},Ose=e=>Aoe(H6,e),U8=e=>joe(H6,e),W8=(e,t)=>Moe(H6,e,t),G8=L(2,(e,t)=>Poe(e,t)),K8=L(2,(e,t)=>Foe(e,t)),q8=L(2,(e,t)=>Roe(e,t)),J8=e=>Y6(e),Y8=Ioe,X8=L(2,(e,t)=>zoe(e,t)),Z8=e=>{let t=new Set,n=[];for(let r of e)t.has(r)||(t.add(r),n.push(r));return n},Q8=(e,t)=>{let n=[e],r=e;for(let e=1;e<t.length;e++){let i=t[e],a;for(let e of r.subcommands)if(a=e.commands.find(e=>e.name===i),a)break;if(!a)break;n.push(a),r=a}return n},$8=(e,t,n)=>{let r=Q8(e,t).flatMap(e=>f8(e).globalFlags);return Z8([...n,...r])},kse=e=>{let t=[],n=e=>{let r=f8(e);for(let e of r.globalFlags)t.push(e);for(let t of e.subcommands)for(let e of t.commands)n(e)};return n(e),Z8(t)},Ase=(e,t)=>{if(e.length<=1)return[];let n=new Set(t.map(e=>e.name)),r=[];for(let t of e.slice(0,-1)){let e=f8(t);for(let t of e.contextConfig.flags){let e=Q6(t),i=e8(t);for(let t of e)n.has(t.name)||t.hidden||(n.add(t.name),r.push(m8(t,i)))}}return r},jse=(e,t)=>Z8([...t,...kse(e)]),e5=(e,t,n)=>qU(function*(){let r=Q8(e,t),i=r.length>0?r[r.length-1]:e,a=f8(i).buildHelpDoc(t),o=Ase(r,a.flags),s=$8(e,t,n),c=[];for(let e of s){let t=Q6(e.flag),n=e8(e.flag);for(let e of t)e.hidden||c.push({...m8(e,n),required:!1})}return{...a,flags:[...o,...a.flags],globalFlags:c}}),t5=e=>({_tag:`Action`,flag:e.flag,run:e.run}),Mse=e=>t=>{n5+=1;let n=$P(`effect/cli/GlobalFlag/${e}/${n5}`);return Object.assign(n,{_tag:`Setting`,id:e,flag:t.flag})};let n5=0;const Nse=t5({flag:U8(`help`).pipe(G8(`h`),K8(`Show help information`),Y8(!1)),run:Y(function*(e,{builtIns:t,command:n,commandPath:r}){let i=yield*n8,a=yield*e5(n,r,t);yield*i.present({_tag:`Help`,reason:`Requested`,commandPath:r,helpDoc:a})})}),Pse=t5({flag:U8(`version`).pipe(G8(`v`),K8(`Show version information`),Y8(!1)),run:Y(function*(e,{command:t,version:n}){yield*(yield*n8).present({_tag:`Version`,name:t.name,version:n})})}),r5=t5({flag:U8(`wizard`).pipe(K8(`Start wizard mode for a command`),Y8(!1)),run:()=>WU}),Fse=t5({flag:W8(`completions`,[[`bash`,`bash`],[`zsh`,`zsh`],[`fish`,`fish`],[`powershell`,`powershell`],[`sh`,`bash`],[`pwsh`,`powershell`]]).pipe(J8,q8(`<bash|zsh|fish|powershell|sh|pwsh>`),K8(`Print shell completion script`)),run:Y(function*(e,{command:t}){if(WP(e))return;let n=Ese(t);yield*Y4(Dse(t.name,e.value,n))})}),i5=Mse(`log-level`)({flag:W8(`log-level`,[[`all`,`All`],[`trace`,`Trace`],[`debug`,`Debug`],[`info`,`Info`],[`warn`,`Warn`],[`warning`,`Warn`],[`error`,`Error`],[`fatal`,`Fatal`],[`none`,`None`]]).pipe(J8,K8(`Sets the minimum log level`),q8(`<all|trace|debug|info|warn|warning|error|fatal|none>`))}),Ise=[Nse,Pse,r5,Fse,i5];var a5=class extends xF(`effect/cli/CliConfig`,{defaultValue:()=>Lse}){};const Lse={builtIns:Ise},Rse=TW(e=>W(mF(e,t8)??i8({colors:_F(e,z6).canColor})));function zse(e){let t=e.indexOf(`--`);return t===-1?{tokens:o5(e),trailingOperands:[]}:{tokens:o5(e.slice(0,t)),trailingOperands:e.slice(t+1)}}const Bse=/^-(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/,o5=e=>{let t=[];for(let n of e)if(!n.startsWith(`-`)||Bse.test(n))t.push({_tag:`Value`,value:n});else if(n.startsWith(`--`)){let e=n.indexOf(`=`);if(e!==-1){let r=n.slice(2,e);if(r===``)t.push({_tag:`Value`,value:n});else{let i=n.slice(e+1);t.push({_tag:`LongOption`,name:r,raw:n,value:i})}}else t.push({_tag:`LongOption`,name:n.slice(2),raw:n})}else if(n.length>1){let e=n.slice(1),r=e.indexOf(`=`);if(r!==-1){let n=Array.from(e.slice(0,r)),i=n.pop()??``;for(let e of n)t.push({_tag:`ShortOption`,flag:e,raw:`-${e}`});t.push({_tag:`ShortOption`,flag:i,raw:`-${i}`,value:e.slice(r+1)})}else for(let n of e)t.push({_tag:`ShortOption`,flag:n,raw:`-${n}`})}else t.push({_tag:`Value`,value:n});return t},Vse=(e,t)=>{let n=e.length,r=t.length,i=Array.from({length:n+1},()=>Array(r+1).fill(0));for(let e=0;e<=n;e++)i[e][0]=e;for(let e=0;e<=r;e++)i[0][e]=e;for(let a=1;a<=n;a++)for(let n=1;n<=r;n++){let r=e[a-1]===t[n-1]?0:1;i[a][n]=Math.min(i[a-1][n]+1,i[a][n-1]+1,i[a-1][n-1]+r)}return i[n][r]},s5=(e,t)=>{let n=t.map(t=>[Vse(e,t),t]).filter(([e])=>e<=2).sort(([e],[t])=>e-t);if(n.length===0)return[];let r=n[0][0];return n.filter(([e])=>e===r).map(([,e])=>e)},c5=e=>KP(e.subcommand,{onNone:()=>[],onSome:e=>[e.name,...c5(e.parsedInput)]}),l5=(e,t,n=[])=>qU(function*(){let{tokens:r,trailingOperands:i}=e,a=[...n,t.name],o=f8(t),s=o.config.flags.flatMap(Q6).filter(W6),c=f5(s),l=o.contextConfig.flags.flatMap(Q6).filter(W6),u=f5(l),d=new Set(l.map(e=>e.name)),f={command:t,commandPath:a,flagRegistry:c,inheritedFlagRegistry:u,localFlagNames:s.filter(e=>!d.has(e.name)).map(e=>e.name)},p=tce(r,f);if(p._tag===`Leaf`)return{flags:p.flags,arguments:[...p.arguments,...i],subcommand:V(),...p.errors.length>0&&{errors:p.errors}};let m={tokens:p.childTokens,trailingOperands:i},h=yield*l5(m,p.sub,a),g=[...p.errors,...h.errors??[]];return{flags:p.flags,arguments:[],subcommand:UP({name:p.sub.name,parsedInput:h}),...g.length>0&&{errors:g}}}),u5=e=>{let t=0;return{peek:()=>e[t],take:()=>e[t++],rest:()=>e.slice(t)}},d5=e=>!A3(e.primitiveType)||e.negation===!1?void 0:e.negation??`no-${e.name}`,f5=e=>{let t=new Map,n=new Map;for(let r of e){if(t.has(r.name))throw Error(`Duplicate flag name "${r.name}" in command definition`);t.set(r.name,r);for(let e of r.aliases){if(t.has(e))throw Error(`Duplicate flag/alias "${e}" in command definition (conflicts with "${t.get(e).name}")`);t.set(e,r)}let e=d5(r);if(e!==void 0){if(n.has(e))throw Error(`Duplicate negation "${e}" in command definition (conflicts with "${n.get(e).name}")`);n.set(e,r)}}return{params:e,index:t,negations:n}},p5=e=>{let t=new Map,n=(e,n)=>{let r=t.get(e);if(r&&r!==n)throw Error(`Duplicate subcommand name/alias "${e}" in command definition (conflicts with "${r.name}")`);t.set(e,n)};for(let t of e)for(let e of t.commands)n(e.name,e),e.alias&&e.alias!==e.name&&n(e.alias,e);return t},m5=e=>Object.fromEntries(e.map(e=>[e.name,[]])),Hse=e=>{let t=m5(e);return{add:(e,n)=>{n!==void 0&&t[e].push(n)},merge:e=>{for(let n in e){let r=e[n];if(r?.length)for(let e=0;e<r.length;e++)t[n].push(r[e])}},snapshot:()=>t}},h5=e=>e._tag===`LongOption`||e._tag===`ShortOption`,g5=e=>e._tag===`LongOption`?e.name:e.flag,_5=(e,t)=>{let n=g5(e),r=t.index.get(n);if(r&&r.name===n)return{param:r,negated:!1};let i=e._tag===`LongOption`?t.negations.get(e.name):void 0;if(i)return{param:i,negated:!0};if(r)return{param:r,negated:!1}},v5=(e,t,n)=>new x3({option:t.name,value:n,expected:`omit the value and use ${e.raw} by itself to set --${t.name} to false`,kind:`flag`}),Use=e=>{let t=I3(e.primitiveType);return new x3({option:e.name,value:``,expected:t===void 0?e.typeName??F3(e.primitiveType):t.join(` | `),kind:`flag`})},y5=e=>e?._tag===`Value`&&(O3(e.value)||k3(e.value))?e.value:void 0,b5=(e,t,n,r=!1)=>{let i=x5(e,t,n,r);switch(i._tag){case`Value`:return{_tag:`Value`,value:i.value};case`Error`:return{_tag:`Error`,error:i.error}}},x5=(e,t,n,r=!1)=>{if(r){if(t.value!==void 0)return{_tag:`Error`,error:v5(t,n,t.value),tokens:[]};let r=n.optionalValue===void 0?y5(e.peek()):void 0;if(r!==void 0){let i=e.take();return{_tag:`Error`,error:v5(t,n,r),tokens:i===void 0?[]:[i]}}return{_tag:`Value`,value:`false`,tokens:[]}}if(t.value!==void 0)return{_tag:`Value`,value:t.value,tokens:[]};if(n.optionalValue!==void 0)return{_tag:`Value`,value:n.optionalValue,tokens:[]};if(A3(n.primitiveType)){let t=y5(e.peek()),n=t===void 0?void 0:e.take();return{_tag:`Value`,value:t??`true`,tokens:n===void 0?[]:[n]}}let i=e.peek();if(i?._tag===`Value`){let t=e.take();return{_tag:`Value`,value:i.value,tokens:t===void 0?[]:[t]}}return{_tag:`Error`,error:Use(n),tokens:[]}},Wse=(e,t)=>{let n=m5(t.params),r=[],i=[],a=u5(e);for(let e=a.take();e;e=a.take()){if(!h5(e)){r.push(e);continue}let o=_5(e,t);if(!o){r.push(e);continue}let s=b5(a,e,o.param,o.negated);if(s._tag===`Error`){i.push(s.error);continue}s.value!==void 0&&n[o.param.name].push(s.value)}return{flagMap:n,remainder:r,errors:i}},Gse=e=>f8(e).config.flags.flatMap(Q6).filter(W6),Kse=e=>f8(e).contextConfig.flags.flatMap(Q6).filter(W6),S5=(e,t)=>{for(let n of t){let t=_5(e,n);if(t!==void 0)return t}},C5=(e,t,n,r)=>{e.push(n);let i=x5(t,n,r.param,r.negated);e.push(...i.tokens)},qse=(e,t,n,r,i)=>{let a=u5(t);x5(a,e,n.param,n.negated);for(let e=a.take();e;e=a.take()){if(h5(e)){let t=S5(e,i);t!==void 0&&x5(a,e,t.param,t.negated);continue}if(e._tag===`Value`)return r.has(e.value)}return!1},Jse=(e,t,n)=>{let r=m5(n.params),i=[],a=(e,t,o)=>{let s=f5(Gse(t)),c=f5(Kse(t)),l=p5(t.subcommands),u=u5(e),d=[],f=!0;for(let e=u.take();e;e=u.take()){if(h5(e)){let t=S5(e,o);if(t!==void 0){C5(d,u,e,t);continue}let a=_5(e,c);if(a!==void 0){C5(d,u,e,a);continue}let p=_5(e,s),m=_5(e,n);if(p!==void 0&&(m===void 0||!f||!qse(e,u.rest(),p,l,[s,c,n]))){C5(d,u,e,p);continue}if(m!==void 0){let t=x5(u,e,m.param,m.negated);if(t._tag===`Error`){i.push(t.error);continue}t.value!==void 0&&r[m.param.name].push(t.value);continue}d.push(e);continue}if(e._tag===`Value`&&f){let t=l.get(e.value);if(t!==void 0)return d.push(e),d.push(...a(u.rest(),t,[...o,c])),d;f=!1}d.push(e)}return d};return{flagMap:r,remainder:a(e,t,[]),errors:i}},Yse=(e,t,n)=>{let r=e._tag===`LongOption`?`--${e.name}`:`-${e.flag}`,i=[];for(let e of t){if(e.hidden)continue;i.push(e.name);let t=d5(e);t!==void 0&&i.push(t);for(let t of e.aliases)i.push(t)}return new g3({option:r,suggestions:s5(g5(e),i).map(e=>e.length===1?`-${e}`:`--${e}`),command:n})},Xse=e=>({flags:Hse(e.params),arguments:[],errors:[],mode:{_tag:`AwaitingFirstValue`}}),Zse=e=>({_tag:`Leaf`,flags:e.flags.snapshot(),arguments:e.arguments,errors:e.errors}),Qse=(e,t,n,r)=>{let{command:i,commandPath:a,inheritedFlagRegistry:o,localFlagNames:s}=n,c=p5(i.subcommands),l=c.get(e);if(l){let e=[...a,l.name],n=r.flags.snapshot();for(let t of s){let i=n[t];i!==void 0&&i.length>0&&r.errors.push(new g3({option:`--${t}`,suggestions:[],command:e}))}let i=Wse(t.rest(),o);return r.flags.merge(i.flagMap),r.errors.push(...i.errors),{_tag:`Subcommand`,result:{_tag:`Sub`,flags:r.flags.snapshot(),sub:l,childTokens:i.remainder,errors:r.errors}}}if(!(f8(i).config.arguments.length>0)&&c.size>0){let t=[];for(let[e,n]of c)n.unlisted||t.push(e);let n=s5(e,t);r.errors.push(new S3({subcommand:e,parent:a,suggestions:n}))}return{_tag:`Argument`}},$se=(e,t,n,r)=>{let{commandPath:i,flagRegistry:a}=n,o=_5(e,a);if(!o){r.errors.push(Yse(e,a.params,i));return}let s=b5(t,e,o.param,o.negated);if(s._tag===`Error`){r.errors.push(s.error);return}r.flags.add(o.param.name,s.value)},ece=(e,t,n,r)=>{if(r.mode._tag===`AwaitingFirstValue`){let i=Qse(e,t,n,r);if(i._tag===`Subcommand`)return i.result;r.mode={_tag:`CollectingArguments`}}r.arguments.push(e)},tce=(e,t)=>{let n=u5(e),r=Xse(t.flagRegistry);for(let e=n.take();e;e=n.take()){if(h5(e)){$se(e,n,t,r);continue}if(e._tag===`Value`){let i=ece(e.value,n,t,r);if(i)return i}}return Zse(r)},nce=Y(function*(e,t){let n=t?.commandPath??[e.name],r=rce(e,n),i=(t?.prefix??n).map(e=>E5(e)),{colors:a}=yield*t6;return yield*O5(i,a),yield*w5(r,i,r===e?`ROOT`:r.name,a),{args:i.map(e=>e.value),displayArgs:i.map(e=>e.displayValue)}}),rce=(e,t)=>{let n=e;for(let e of t.slice(1)){let t=n.subcommands.flatMap(e=>e.commands).find(t=>t.name===e||t.alias===e);if(t===void 0)break;n=t}return n},w5=Y(function*(e,t,n,r){let i=f8(e),a=e.subcommands.flatMap(e=>e.commands.filter(e=>!e.unlisted)),o=a.length===0?i.config:i.contextConfig;if(o.flags.length>0){yield*Y4(k5(n,`FLAGS`,r));for(let e of o.flags)t.push(...yield*T5(e));(o.arguments.length>0||a.length>0)&&(yield*O5(t,r))}if(o.arguments.length>0){yield*Y4(k5(n,`ARGUMENTS`,r));for(let e of o.arguments)t.push(...yield*T5(e));a.length>0&&(yield*O5(t,r))}if(a.length===0)return;let s=yield*l6(u6({message:`Command`,choices:a.map(e=>({title:e.name,value:e,...e.shortDescription===void 0?e.description===void 0?{}:{description:e.description}:{description:e.shortDescription}}))}));yield*Y4(),t.push(E5(s.name)),ice(s)&&(yield*O5(t,r)),yield*w5(s,t,s.name,r)}),ice=e=>e.subcommands.some(e=>e.commands.some(e=>!e.unlisted))||f8(e).config.orderedParams.length>0,T5=Y(function*(e){let t=$6(e),n=e8(e);if(n.isOptional&&!(yield*l6(o6({message:`Set ${D5(t)}?`,initial:!1}))))return yield*Y4(),[];let r=n.isVariadic?yield*l6(c6({message:`${D5(t)} count`,default:qP(n.variadicMin,()=>0),min:qP(n.variadicMin,()=>0),...GP(n.variadicMax)?{max:n.variadicMax.value}:{}})):1,i=[];for(let e=0;e<r;e++)i.push(yield*ace(t));let a=t.kind===`flag`?{flags:{[t.name]:i.map(e=>e.value)},arguments:[]}:{flags:{},arguments:i.map(e=>e.value)};return yield*e.parse(a),yield*Y4(),t.kind===`argument`?i:i.flatMap(e=>t.optionalValue!==void 0||e.value.startsWith(`-`)&&e.value.length>1?[E5(`--${t.name}=${e.value}`,`--${t.name}=${e.displayValue}`)]:[E5(`--${t.name}`),e])}),ace=e=>{let t=sce(e);switch(e.primitiveType._tag){case`Boolean`:return J(l6(o6({message:t,label:{confirm:`true`,deny:`false`},placeholder:{defaultConfirm:`(T/f)`,defaultDeny:`(t/F)`}})),e=>E5(String(e)));case`Choice`:{let n=I3(e.primitiveType)??[];return J(l6(u6({message:t,choices:n.map(e=>({title:e,value:e}))})),E5)}case`Date`:return J(l6(nae({message:t})),e=>E5(e.toISOString()));case`Finite`:return J(l6(iae({message:t})),e=>E5(String(e)));case`Int`:return J(l6(c6({message:t})),e=>E5(String(e)));case`Redacted`:return J(l6(oae({message:t})),e=>E5(H1(e),`<redacted>`));default:return J(l6(lae({message:t})),E5)}},E5=(e,t=e)=>({value:e,displayValue:t}),oce=e=>e.kind===`flag`?`--${e.name}`:e.name,sce=e=>D5(e),D5=e=>{let t=XP(e.description)?.trim(),n=e.kind===`flag`&&t!==void 0&&t.length<=32?t:cce(e.name);return e.kind===`flag`?`${n} (${oce(e)})`:n},cce=e=>{let t=e.split(/[-_]+/).filter(e=>e.length>0);return t.length===0?e:[t[0][0].toUpperCase()+t[0].slice(1),...t.slice(1)].join(` `)},O5=(e,t)=>Y4(A5(`Current command`,e.map(e=>e.displayValue),t,`\x1B[35m`)),k5=(e,t,n)=>`${K3(n,e.toUpperCase(),R3,G3)} ${K3(n,`·`,W3)} ${K3(n,t,R3,U3)}`,lce=(e,t,n,r)=>[`${K3(r,e,R3,G3)} ${K3(r,`v${t}`,U3)} ${K3(r,`· Command wizard`,R3,U3)}`,...n===void 0||n.length===0?[]:[n],K3(r,`Build a command interactively. Press Ctrl+C to cancel.`,W3),``].join(`
|
|
561
|
+
`),uce=(e,t)=>A5(`Command ready`,e,t,G3,H3),dce=e=>`\n${K3(e,`Wizard cancelled.`,V3)}`,A5=(e,t,n,r,i=U3)=>{let a=fce(t);return[K3(n,e,R3,i),...a.map(e=>K3(n,e,r)),``].join(`
|
|
562
|
+
`)},fce=e=>{let t=` $ `,n=` `,r=e.map(pce),i=[],a=t;for(let e of r){let r=a===t||a===n?``:` `;a.length+r.length+e.length>88&&a!==t?(i.push(`${a} \\`),a=`${n}${e}`):a+=`${r}${e}`}return a!==t&&i.push(a),i},pce=e=>/^[A-Za-z0-9_./:@%+=,-]+$/.test(e)?e:`'${e.replaceAll(`'`,`'"'"'`)}'`,mce=e=>z(e,d8),j5=(e,t,n)=>{let r=l8(t??{});return p8({name:e,config:r,...oM(n)?{handle:n}:{}})},hce=e=>{let t=[],n=new Map,r=(e,r)=>{t.push(r);let i=n.get(e);i?i.push(r):n.set(e,[r])};for(let t of e){if(mce(t)){r(void 0,t);continue}for(let e of t.commands)r(t.group,e)}let i=[],a=n.get(void 0);a&&a.length>0&&i.push({group:void 0,commands:a});for(let[e,t]of n)e!==void 0&&i.push({group:e,commands:t});return{flat:t,groups:i}},gce=L(2,(e,t)=>{let n=hce(t);ise(e,n.flat);let r=f8(e),i=new Map(n.flat.map(e=>[e.name,f8(e)])),a=Symbol(`effect/cli/SubcommandState`),o=Y(function*(e){if(WP(e.subcommand))return yield*r.parse(e);let t=i.get(e.subcommand.value.name);if(!t)return yield*r.parse(e);let n=yield*r.parseContext(e),o=yield*t.parse(e.subcommand.value.parsedInput);return{...n,[a]:{name:t.name,result:o}}}),s=Y(function*(e,t){let n=e[a];if(n){let a=i.get(n.name);return a?yield*a.handle(n.result,[...t,a.name]).pipe(kW(r.service,e)):yield*new E3({commandPath:t,errors:[]})}return yield*r.handle(e,t)});return p8({name:r.name,config:r.config,contextConfig:r.contextConfig,description:r.description,shortDescription:r.shortDescription,alias:r.alias,unlisted:r.unlisted,annotations:r.annotations,globalFlags:r.globalFlags,resolveExamples:r.resolveExamples,service:r.service,subcommands:n.groups,parse:o,parseContext:r.parseContext,handle:s})}),M5=L(2,(e,t)=>p8({...f8(e),description:t})),_ce=(e,t,n,r)=>{let i=new Set(t),a=[],o=new Set;for(let t of e){if(i.has(t))continue;let e=Q6(t.flag);for(let t of e){let e=n[t.name];if(!e||e.length===0)continue;let i=`--${t.name}`;o.has(i)||(o.add(i),a.push(new g3({option:i,suggestions:[],command:r})))}}return a},vce=(e,t,n)=>qU(function*(){let{builtIns:r}=yield*a5,i=yield*n8,{commandPath:a,errors:o}=t,s=yield*e5(e,a,r);yield*i.present(n&&o.length>0?{_tag:`InvalidInvocation`,commandPath:a,helpDoc:s,errors:o}:{_tag:`Help`,reason:`Implicit`,commandPath:a,helpDoc:s})}),yce=(e,t)=>qU(function*(){let n=yield*Rse,r=e instanceof w3?e:new w3({cause:e,userMessage:t});yield*J4(n.formatError(r)),Object.assign(e,{[d3]:!1})}),N5=(e,t)=>{let n=f8(e);return Y(function*(r){let{builtIns:i}=yield*a5,{tokens:a,trailingOperands:o}=zse(r),s=jse(e,i),c=s.flatMap(e=>Q6(e.flag)),l=f5(c.filter(W6)),{flagMap:u,remainder:d,errors:f}=Jse(a,e,l),p={flags:u,arguments:[]},m=yield*l5({tokens:d,trailingOperands:o},e),h=[e.name,...c5(m)],g=pW(e=>e._tag===`ShowHelp`?e:new E3({commandPath:h,errors:[e]})),_={builtIns:i,command:e,commandPath:h,version:t.version},v=$8(e,h,i),y=_ce(s,v,u,h);if(y.length>0||f.length>0){let e=m.errors??[];return yield*new E3({commandPath:h,errors:[...f,...y,...e]})}for(let n of v){if(n._tag!==`Action`||!Q6(n.flag).some(e=>{let t=u[e.name];return t!==void 0&&t.length>0}))continue;let[,i]=yield*n.flag.parse(p).pipe(g);if(n===r5){let{colors:n}=yield*t6;return yield*qU(function*(){yield*Y4(lce(e.name,t.version,e.description,n));let i=[e.name,...r.filter(e=>e!==`--wizard`&&!e.startsWith(`--wizard=`))],a=yield*nce(e,{commandPath:h,prefix:i});yield*Y4(uce(a.displayArgs,n)),(yield*l6(uae({message:`Run this command?`,initial:!0,active:`yes`,inactive:`no`})))&&(yield*Y4(),yield*N5(e,{...t,renderErrors:!1})(a.args.slice(1)))}).pipe(cW(`QuitError`,()=>Y4(dce(n))))}yield*n.run(i,_);return}if(m.errors&&m.errors.length>0)return yield*new E3({commandPath:h,errors:m.errors});let ee=yield*n.parse(m).pipe(g),b=n.handle(ee,[e.name]),te=v.includes(i5)?(yield*i5.flag.parse(p).pipe(g))[1]:V();b=kW(b,i5,te);for(let e of v){if(e._tag!==`Setting`||e===i5)continue;let[,t]=yield*e.flag.parse(p).pipe(g);b=kW(b,e,t)}let ne=KP(te,{onNone:()=>dF(),onSome:e=>fF(YV,e)});yield*DW(b,ne)},fW(e=>p3(e)&&e._tag===`ShowHelp`?wF(e):TF(e),n=>nW(vce(e,n,t.renderErrors!==!1),K(n))),fW(e=>{if(t.renderErrors===!1||!fM(e))return TF(e);let n=h3(e);return n===void 0?TF(e):wF({error:e,userMessage:n})},({error:e,userMessage:t})=>nW(yce(e,t),K(e))),fW(e=>B4(e)?wF(e):TF(e),e=>VW))},P5=e=>z(e,`code`)&&$j(e.code)?e.code:void 0,F5=e=>{try{process.kill(e,0);return}catch(e){return e}},I5=e=>UU(()=>{let t=F5(-e);if(t===void 0)return W({_tag:`Succeeded`});let n=P5(t);return n===void 0?ZU(t):W({_tag:`Failed`,code:n})}),L5=e=>e._tag===`Failed`&&e.code===`ESRCH`,bce=(e,t)=>L5(e)||t._tag===`Read`&&t.processes.length>0&&t.processes.every(({state:e})=>e.startsWith(`Z`))?`observed`:e._tag===`Succeeded`?`not-observed`:`unknown`,R5=/^\d+$/,xce=e=>{let[t,n,r,...i]=e.trim().split(/\s+/);return t!==void 0&&n!==void 0&&r!==void 0&&i.length===0&&R5.test(t)&&R5.test(n)?{pid:Number(t),pgid:Number(n),state:r}:void 0},Sce=(e,t)=>{let n=[];for(let r of e.split(`
|
|
563
|
+
`)){if(r.trim()===``)continue;let e=xce(r);if(e===void 0)return{_tag:`Unreadable`,why:`ps listed ${JSON.stringify(r)}, which is not a pid, a process group and a state`};e.pgid===t&&n.push({pid:e.pid,state:e.state})}return{_tag:`Read`,processes:n}},Cce=dI(10),wce=(e,t,n)=>qU(function*(){let r=yield*GW(I5(e),{schedule:kU(Cce),while:e=>!L5(e)&&J(YH,e=>e<t)});if(L5(r))return{groupGone:`observed`,evidence:{lastProbe:r,members:{_tag:`NotRead`}}};let i=yield*n,a=yield*I5(e);return{groupGone:bce(a,i),evidence:{lastProbe:a,members:i}}}),Tce=e=>{if(e===void 0)return`present`;let t=P5(e);return t===`ESRCH`?`absent`:t===`EPERM`?`present`:`unknown`},Ece=e=>G(()=>Tce(F5(e))),Dce=/^Process interrupted due to receipt of signal: '([A-Z0-9]+)'$/,Oce=e=>{if(e instanceof Error)return Dce.exec(e.message)?.[1]},z5=(e,t)=>({_tag:`Capture`,limitBytes:e,onExceed:t}),kce={_tag:`Ignore`},B5=G2([n4(`Captured`,{bytes:w4,totalBytes:d4,truncated:B2,omitted:M2(Z({at:d4,bytes:d4})),closed:B2}),n4(`Forwarded`,{forwardedBytes:d4,totalBytes:d4,truncated:B2,closed:B2}),n4(`Ignored`,{})]),Ace=G2([n4(`Exited`,{code:d4}),n4(`Signaled`,{signal:X})]),jce=G2([n4(`None`,{}),n4(`Fed`,{bytesWritten:d4,ended:K2([`source-done`,`child-closed`,`stopped`])})]),Mce=G2([n4(`Succeeded`,{}),n4(`Failed`,{code:X})]),Nce=G2([n4(`NotRead`,{}),n4(`Read`,{processes:U2(Z({pid:d4,state:X}))}),n4(`Unreadable`,{why:X})]),V5=Z({pid:d4,executable:X,exit:Ace,stdin:jce,stdout:B5,stderr:B5,termination:Z({by:q2(K2([`deadline`,`stop`,`output-limit`])),reason:q2(X),requestedAt:q2(X),groupGone:K2([`observed`,`not-observed`,`unknown`,`not-applicable`]),confirmedAt:q2(X),group:q2(Z({lastProbe:Mce,members:Nce}))}),durationMs:d4}).annotate({identifier:`@inkeep/impulse-owned-process/ProcessRecord`}),H5=Z({pid:d4.check(l4({minimum:1,maximum:2**31-1})),startedAt:X.check(f4(1))}),Pce=Z({identity:H5,releasedAt:X,deadlineAt:X}).annotate({identifier:`@inkeep/impulse-owned-process/HandOff`}),Fce=G2([n4(`SpawnFailed`,{code:X}),n4(`DeadlineExceeded`,{record:V5}),n4(`OutputLimit`,{stream:K2([`stdout`,`stderr`]),limitBytes:d4,record:V5}),n4(`ExitFailed`,{record:V5}),n4(`ReleaseRefused`,{why:K2([`exited`,`identity-unavailable`]),record:q2(V5)})]),Ice=e=>e.exit._tag===`Exited`?`exited ${e.exit.code}`:`ended by ${e.exit.signal}`,Lce=e=>{if(e._tag===`SpawnFailed`)return`SpawnFailed: ${e.code}`;if(e._tag===`ReleaseRefused`)return`ReleaseRefused: ${e.why}`;if(e._tag===`OutputLimit`)return`OutputLimit: ${e.record.executable} passed its ${e.limitBytes}-byte ${e.stream} capture`;let t=e._tag===`DeadlineExceeded`?` after its deadline`:``;return`${e._tag}: ${e.record.executable} ${Ice(e.record)}${t}`};var U5=class extends P4()(`ProcessError`,{reason:Fce}){get message(){return Lce(this.reason)}};const Rce=(e,t)=>{let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;return n},W5=(e,t,n)=>e.pipe(q(e=>(t.steps+=1,BU(e,n,{discard:!0}))),WW({disableYield:!0}),fU(()=>G(()=>{t.closed=!0})),uW(()=>WU)),zce=(e,t,n)=>{let r={steps:0,busy:!1,closed:!1},i=[],a=0,o=[],s=0,c=0,l=!1,u=e=>{let r=t.limitBytes-s;if(r>0){let t=e.byteLength>r?e.subarray(0,r):e;o.push(t),s+=t.byteLength}return e.byteLength<=r||l?WU:(l=!0,n)},d=t.onExceed===`keep-ends`?Math.floor(t.limitBytes/2):0,f=t.limitBytes-d,p=t.onExceed===`terminate`?u:e=>G(()=>{let t=e.subarray(0,d-a);t.byteLength>0&&(i.push(t),a+=t.byteLength);let n=e.subarray(t.byteLength);if(n.byteLength!==0)for(o.push(n),s+=n.byteLength;s>f;){let e=o[0];if(e===void 0)return;let t=s-f;e.byteLength<=t?(o.shift(),s-=e.byteLength):(o[0]=e.subarray(t),s-=t)}});return{progress:r,run:W5(e,r,e=>(c+=e.byteLength,p(e))),record:()=>{let e=c-a-s;return{_tag:`Captured`,bytes:Rce([...i,...o],a+s),totalBytes:c,truncated:e>0,...t.onExceed===`keep-ends`&&e>0?{omitted:{at:a,bytes:e}}:{},closed:r.closed}}}},Bce=(e,t,n)=>{let r={steps:0,busy:!1,closed:!1},i=0,a=0,o=!1,s=t.limitBytes??1/0,c=e=>G(()=>{o=!0,r.closed=e}),l=UU(()=>(r.busy=!1,s<=0?GH():vU(e,{onSuccess:e=>{r.steps+=1;let t=[];for(let n of e){if(a+=n.byteLength,s<=0)continue;let e=n.byteLength>s?n.subarray(0,s):n;t.push(e),s-=e.byteLength,i+=e.byteLength}let[n,...o]=t;return n===void 0?GH():(r.busy=!0,W([n,...o]))},onFailure:()=>nW(c(!1),GH()),onDone:()=>nW(c(!0),GH())}))),u=UU(()=>o?WU:W5(e,r,e=>G(()=>{a+=e.byteLength})));return{progress:r,run:cJ(Uq(W(l)),t.sink).pipe(IW(G(()=>{r.busy=!1})),uW(n),nW(u)),record:()=>({_tag:`Forwarded`,forwardedBytes:i,totalBytes:a,truncated:a>i,closed:r.closed})}},Vce=(e,t,n)=>q(YH,r=>{let i=gI(n.ceiling),a=nW(kG(e),G(()=>{t.closed=!1})),o=(s,c)=>q(DG(e).pipe(aW(!0),bW(aW(yW(n.tick),!1))),e=>e?WU:q(YH,e=>{let l=t.steps!==s||t.busy?0:c+1;return l>=n.idleTicks||e-r>=i?a:o(t.steps,l)}));return o(t.steps,0)}),Hce={PATH:`/usr/bin:/bin:/usr/sbin:/sbin`},Uce=(e,t)=>JQ(`/bin/sh`,[`-c`,`group=-$1 polls=$2
|
|
564
|
+
gone() { ! kill -s 0 -- "$group" 2>/dev/null; }
|
|
565
|
+
settle() { n=0; while [ "$n" -lt "$polls" ]; do gone && return 0; sleep 0.1; n=$((n + 1)); done; gone; }
|
|
566
|
+
read -r line && exit 0
|
|
567
|
+
kill -s TERM -- "$group" 2>/dev/null
|
|
568
|
+
settle && exit 0
|
|
569
|
+
kill -s KILL -- "$group" 2>/dev/null
|
|
570
|
+
settle`,`owned-process-tether`,String(e),String(Math.max(1,Math.ceil(hI(t)/100)))],{env:{...Hce},extendEnv:!1,stdin:`pipe`,stdout:`ignore`,stderr:`ignore`,detached:!0,killSignal:`SIGTERM`,forceKillAfter:t}),Wce=new TextEncoder().encode(`disarm
|
|
571
|
+
`),Gce=(e,t)=>nW(gW(cJ(Jq(Wce),e.stdin)),gW(_W(e.exitCode,t)));Z({executable:X,args:U2(X),env:H2(X,X)});const Kce=Z({code:X}),qce=xF(`@inkeep/impulse-owned-process/internal/NodeVersion`,{defaultValue:()=>process.versions.node}),G5=(e,t)=>{let n=zie(t);if(WP(n)||!oI(n.value))throw RangeError(`owned-process: ${e} must be a finite duration`);return n.value},K5=(e,t)=>{if(!Number.isSafeInteger(t)||t<=0)throw RangeError(`owned-process: ${e} must be a positive integer, got ${t}`)},q5=(e,t)=>{switch(t._tag){case`Capture`:K5(`${e}.limitBytes`,t.limitBytes);return;case`Forward`:t.limitBytes!==void 0&&K5(`${e}.limitBytes`,t.limitBytes);return;case`Ignore`:return}},Jce=e=>{if(e.executable.length===0)throw RangeError(`owned-process: executable must be non-empty`);if(e.cwd!==void 0&&!a(e.cwd))throw RangeError(`owned-process: cwd must be absolute, got ${e.cwd}`);for(let[t,n]of Object.entries(e.env))if(typeof n!=`string`)throw TypeError(`owned-process: env.${t} must be a string`);let t=G5(`deadline`,e.deadline);if(hI(t)<=0)throw RangeError(`owned-process: deadline must be greater than zero`);return q5(`stdout`,e.stdout),q5(`stderr`,e.stderr),{request:e,deadline:t,terminationGrace:G5(`terminationGrace`,e.terminationGrace),inheritGroup:e.processGroup===`inherit`}},Yce=e=>e.stdin===void 0&&e.stdout._tag===`Ignore`&&e.stderr._tag===`Ignore`,J5={tick:dI(250),idleTicks:8,ceiling:fI(30)},Y5=hI(fI(1)),X5=1000000n,Xce=BigInt(Y5)*X5,Z5=(e,t)=>Number((e-t)/X5),Q5=(e,t)=>{let n=hI(t),r=n>Y5;return{forceKillAfterMillis:n-(r?Y5:0),settleByNanos:e+gI(t)+(r?0n:Xce)}},Zce={Deadline:`deadline`,Stop:`stop`,OutputLimit:`output-limit`,CallerFailed:null},$5=e=>{let t=z(e.reason,`cause`)?e.reason.cause:void 0;return new U5({reason:{_tag:`SpawnFailed`,code:z(t,`code`)&&$j(t.code)?t.code:e.reason._tag}})},e7=e=>e._tag===`Ignore`?`ignore`:`pipe`,Qce=e=>e.exitCode.pipe(J(e=>({_tag:`Exited`,code:Number(e)})),cW(`PlatformError`,e=>{let t=z(e.reason,`cause`)?e.reason.cause:void 0,n=Oce(t);return n===void 0?ZU(e):W({_tag:`Signaled`,signal:n})})),t7=J(dY,fY),$ce=(e,t,n)=>{let r=0,i=`stopped`,a=(Vq(e)?e:Jq(e)).pipe($q(e=>G(()=>{r+=e.byteLength})),rJ(e=>Zq(aW(RH(e)?WU:n(e),Xq))));return{run:cJ(a,t).pipe(SW({onSuccess:()=>G(()=>{i=`source-done`}),onFailure:e=>{let t=VH(e);return EF(t)?RH(t.failure)?WU:n(t.failure):G(()=>{i=`child-closed`})}})),record:()=>({_tag:`Fed`,bytesWritten:r,ended:i})}},n7={_tag:`Ignored`},ele=Ee(new URL(import.meta.url.endsWith(`.ts`)?`./internal/launch.ts`:`./internal/launch.js`,import.meta.url)),r7=(e,t)=>qU(function*(){let{request:n,inheritGroup:r}=e,i=e=>t.spawned===void 0?WU:HV(t.spawned,e);if(!r){let e=d2(yield*qce);if(EF(e)||g2(e.success,l2({major:26,minor:10,patch:0}))||process.execve===void 0){let e=new U5({reason:{_tag:`SpawnFailed`,code:`ENOSYS`}});return yield*i(e),yield*e}}let a=yield*WQ,o=yield*c3({groupGone:`unknown`,confirmedAt:null,group:null}),s=yield*jW(qU(function*(){let s=yield*c3({_tag:`Unspawned`}),c=yield*tH(yield*AW);yield*FW(()=>qU(function*(){let t=yield*l3(s);if(r||t._tag===`Unspawned`||t._tag===`Released`)return;let n=t._tag===`Exited`?t.settleByNanos:t.settleByNanos??Q5(yield*YH,e.terminationGrace).settleByNanos,{groupGone:i,evidence:a}=yield*wce(t.pid,n,rle(t.pid,n));yield*u3(o,{groupGone:i,confirmedAt:i===`observed`?yield*t7:null,group:a})}));let l=yield*tH(yield*AW),u=yield*a.spawn(JQ(r?n.executable:process.execPath,r?[...n.args]:[`--no-warnings`,ele],{cwd:n.cwd,env:r?{...n.env}:{},extendEnv:!1,stdin:n.stdin===void 0?`ignore`:`pipe`,stdout:e7(n.stdout),stderr:e7(n.stderr),detached:!r,killSignal:`SIGTERM`,forceKillAfter:dI(Q5(0n,e.terminationGrace).forceKillAfterMillis),additionalFds:r?void 0:{fd3:{type:`input`},fd4:{type:`output`}}})).pipe(pW($5),hW(i)),d=yield*JH,f=yield*YH,p=f+gI(e.deadline),m=Number(u.pid);if(yield*u3(s,{_tag:`Running`,pid:m,settleByNanos:Q5(f,e.terminationGrace).settleByNanos}),!r){let t=yield*a.spawn(Uce(m,e.terminationGrace)).pipe(QV(c),pW($5),hW(i));yield*eH(c,Gce(t,e.terminationGrace));let r=cJ(Jq(new TextEncoder().encode(JSON.stringify({executable:n.executable,args:n.args,env:n.env}))),u.getInputFd(3)).pipe(nW(pJ(oJ(u.getOutputFd(4))))),o=Z5(p,yield*YH),s=()=>K(new U5({reason:{_tag:`SpawnFailed`,code:`ETIMEDOUT`}})),l=yield*(o<=0?s():r.pipe(pW($5),vW({duration:dI(o),orElse:s}))).pipe(hW(i));if(l!==``){let{code:e}=yield*D2(S4(Kce))(l).pipe(mW),t=new U5({reason:{_tag:`SpawnFailed`,code:e}});return yield*i(t),yield*t}}let h=yield*zV(),g=yield*zV(),_=yield*zV();yield*JW(JV(Qce(u),_)),t.spawned!==void 0&&(yield*KV(t.spawned,{pid:m,spawnedAtMillis:d,exited:UV(_)}));let v=e=>q(KV(h,e),t=>t||e._tag!==`OutputLimit`&&e._tag!==`CallerFailed`?WU:oW(KV(g,e))),y=e=>q(GV(e),KP({onNone:()=>W(void 0),onSome:e=>J(e,e=>e)})),ee=e=>v({_tag:`CallerFailed`,cause:e}),b=Z5(p,yield*YH),te=[yield*JW(nW(b<=0?WU:yW(dI(b)),v({_tag:`Deadline`})))];t.stop!==void 0&&te.push(yield*JW(SW(t.stop,{onSuccess:e=>v({_tag:`Stop`,reason:e}),onFailure:e=>RH(e)?WU:ee(e)}))),t.release!==void 0&&te.push(yield*JW(nW(t.release,v({_tag:`Release`}))));let ne=(e,t,n)=>qU(function*(){if(t._tag===`Ignore`)return;let r=yield*fJ(n);return t._tag===`Capture`?zce(r,t,v({_tag:`OutputLimit`,stream:e,limitBytes:t.limitBytes})):Bce(r,t,ee)}),re=yield*ne(`stdout`,n.stdout,u.stdout),ie=yield*ne(`stderr`,n.stderr,u.stderr),ae=[];for(let e of[re,ie].filter(oM))ae.push({drain:e,fiber:yield*JW(e.run)});let oe=n.stdin===void 0?void 0:$ce(n.stdin,u.stdin,ee),se=oe===void 0?void 0:yield*qW(oe.run,l),ce=Q5(yield*YH,e.terminationGrace);yield*u3(s,{_tag:`Running`,pid:m,settleByNanos:ce.settleByNanos});let x=yield*bW(aW(BV(_),void 0),BV(h));if(x?._tag===`Release`&&!(yield*UV(_)))return yield*gW(u.unref),yield*u3(s,{_tag:`Released`}),{_tag:`Released`};let le=x!==void 0&&x._tag!==`Release`?x:void 0,S=le===void 0?null:yield*t7;le===void 0&&(yield*BU(te,kG,{discard:!0}));let ue=Q5(yield*YH,e.terminationGrace);yield*u3(s,{_tag:`Running`,pid:m,settleByNanos:ue.settleByNanos});let de=yield*iW(u.kill({killSignal:`SIGTERM`,forceKillAfter:dI(ue.forceKillAfterMillis)}));if(AH(de))yield*gW(u.unref);else{let e=yield*iW(u.isRunning);AH(e)&&!e.value&&(yield*gW(u.unref))}let C=yield*BV(_);yield*u3(s,{_tag:`Exited`,pid:m,settleByNanos:ue.settleByNanos}),yield*BU(ae,({drain:e,fiber:t})=>Vce(t,e.progress,J5),{concurrency:`unbounded`,discard:!0}),se!==void 0&&(yield*bW(oW(DG(se)),nW(yW($ie(J5.tick,J5.idleTicks)),kG(se))));let fe=le===void 0?yield*y(h):void 0,pe=fe?._tag===`OutputLimit`||fe?._tag===`CallerFailed`?fe:yield*y(g);return{_tag:`Exited`,pid:m,spawnedAtMillis:d,spawnedAtNanos:f,exited:C,stopping:le,late:le===void 0?pe:void 0,requestedAt:S,stdin:oe===void 0?{_tag:`None`}:oe.record(),stdout:re===void 0?n7:re.record(),stderr:ie===void 0?n7:ie.record()}}));if(s._tag===`Released`)return s;let c=r?{groupGone:`not-applicable`,confirmedAt:null,group:null}:yield*l3(o),l=yield*YH,{stopping:u}=s,d=s.late?._tag===`OutputLimit`||s.late?._tag===`CallerFailed`?s.late:void 0,f=V5.make({pid:s.pid,executable:n.executable,exit:s.exited,stdin:s.stdin,stdout:s.stdout,stderr:s.stderr,termination:{by:u===void 0?null:Zce[u._tag],reason:u?._tag===`Stop`?u.reason:null,requestedAt:s.requestedAt,...c},durationMs:Math.max(0,Math.round(Number(l-s.spawnedAtNanos)/Number(X5)))}),p=u??d;return p===void 0||p._tag===`Stop`?{_tag:`Completed`,record:f}:p._tag===`CallerFailed`?yield*YU(p.cause):yield*new U5({reason:p._tag===`Deadline`?{_tag:`DeadlineExceeded`,record:f}:{_tag:`OutputLimit`,stream:p.stream,limitBytes:p.limitBytes,record:f}})}),i7=e=>G(()=>Jce(e)),a7=e=>e._tag===`Completed`?W(e.record):ZU(Error(`owned-process: a run cannot be released`)),o7=(e,t)=>q(i7(e),e=>q(r7(e,{stop:t?.stop}),a7)),tle=(e,t)=>q(o7(e,t),e=>e.exit._tag===`Exited`&&e.exit.code===0?W(e):K(new U5({reason:{_tag:`ExitFailed`,record:e}}))),nle={PATH:`/usr/bin:/bin:/usr/sbin:/sbin`,LC_ALL:`C`},rle=(e,t)=>qU(function*(){let n=Z5(t,yield*YH);return n<=Y5?{_tag:`Unreadable`,why:`termination grace exhausted before group-member read`}:yield*tle({executable:`/bin/ps`,args:[`-A`,`-o`,`pid=,pgid=,stat=`],env:nle,deadline:dI(n-Y5),terminationGrace:`0 millis`,processGroup:`inherit`,stdout:z5(1<<20,`terminate`),stderr:kce}).pipe(J(t=>Sce(t.stdout._tag===`Captured`?new TextDecoder().decode(t.stdout.bytes):``,e)),cW(`ProcessError`,e=>W({_tag:`Unreadable`,why:e.message})))}),ile={PATH:`/usr/bin:/bin:/usr/sbin:/sbin`,LC_ALL:`C`,TZ:`UTC`},ale=O2(H5.fields.pid);O2(H5);const ole=e=>qU(function*(){let t=yield*G(()=>ale(e)),n=yield*o7({executable:`/bin/ps`,args:[`-o`,`lstart=`,`-p`,String(t)],env:ile,deadline:`10 seconds`,terminationGrace:`1 second`,stdout:z5(4096,`terminate`),stderr:z5(4096,`keep-tail`)}),r=n.stdout._tag===`Captured`?new TextDecoder().decode(n.stdout.bytes).trim():``;return n.exit._tag===`Exited`&&n.exit.code===0&&r.length>0?UP(r):(yield*Ece(t))===`absent`?V():yield*new U5({reason:{_tag:`ExitFailed`,record:n}})}),s7=ZU(Error(`owned-process: the child was released, and the package no longer holds it`)),sle=ZU(Error(`owned-process: release takes only an unpiped child: no stdin, and Ignore on both outputs`)),c7=e=>{if(AH(e))return e.value._tag===`Completed`?e.value.record:null;let t=VH(e.cause);if(EF(t)||!(t.success instanceof U5))return null;let n=t.success.reason;return z(n,`record`)?n.record:null},l7=(e,t)=>new U5({reason:{_tag:`ReleaseRefused`,why:e,record:t}}),cle=e=>qU(function*(){let t=yield*i7(e),n=yield*WQ,r=yield*zV(),i=yield*zV(),a=yield*zV(),o=Yce(e),s=yield*JW(r7(t,{stop:BV(r),release:o?BV(i):void 0,spawned:a})),c=q(DG(s),e=>q(UV(a),t=>t?BV(a):ZU(jH(e)?BH(e.cause):Error(`owned-process: supervision ended before the child spawned`)))),l=yield*bW(BV(a),c),u=!1,d=UU(()=>u?s7:q(OG(s),a7)),f=UU(()=>u?s7:o?qU(function*(){let e=yield*ole(l.pid).pipe(kW(WQ,n),pW(()=>l7(`identity-unavailable`,null)));if(WP(e)||(yield*l.exited))return yield*l7(`exited`,c7(yield*DG(s)));yield*KV(i,void 0);let r=yield*DG(s);return AH(r)&&r.value._tag===`Released`?(u=!0,Pce.make({identity:{pid:l.pid,startedAt:e.value},releasedAt:yield*t7,deadlineAt:fY(uY(l.spawnedAtMillis+hI(t.deadline)))})):yield*l7(`exited`,c7(r))}):sle);return{pid:l.pid,await:d,stop:e=>UU(()=>u?s7:nW(KV(r,e),d)),release:f}});var u7=class extends P4()(`ProcessError`,{command:X,reason:K2([`SpawnFailed`,`DeadlineExceeded`,`Signaled`,`OutputLimit`]),stderr:X,cause:N2(b4())}){get message(){return`${this.command}: ${this.reason} ${this.stderr.trim().slice(-600)}`}},lle=class extends P4()(`ExitFailed`,{command:X,exitCode:d4,stderr:X}){get message(){return`${this.command}: exit ${this.exitCode} ${this.stderr.trim().slice(-600)}`}};fI(3);const d7=262144,ule=(e,t)=>{let n=new TextDecoder().decode(e);return t===0?n:`${n}${n===``||n.endsWith(`
|
|
572
|
+
`)?``:`
|
|
573
|
+
`}[offload: ${t} earlier bytes of stderr dropped]\n`},f7=(e,t)=>[e,...t].map(e=>/^[\w@%+=:,./-]+$/.test(e)?e:JSON.stringify(e)).join(` `),p7=new Uint8Array,m7=(e,t)=>{if(t.exit._tag===`Signaled`)return K(new u7({command:e,reason:`Signaled`,stderr:``,cause:new U5({reason:{_tag:`ExitFailed`,record:t}})}));let n=t.stderr._tag===`Captured`?t.stderr:void 0,r=n===void 0?0:n.totalBytes-n.bytes.byteLength;return W({exitCode:t.exit.code,stdout:t.stdout._tag===`Captured`?t.stdout.bytes:p7,stderr:ule(n?.bytes??p7,r),stderrDroppedBytes:r})},h7=(e,t)=>a3(t.reason,{SpawnFailed:()=>K(new u7({command:e,reason:`SpawnFailed`,stderr:``,cause:t})),DeadlineExceeded:()=>K(new u7({command:e,reason:`DeadlineExceeded`,stderr:``})),OutputLimit:({stream:t,limitBytes:n})=>K(new u7({command:e,reason:`OutputLimit`,stderr:`${t} passed its ${n}-byte capture; the process was stopped`})),ExitFailed:()=>ZU(t),ReleaseRefused:()=>ZU(t)});var g7=class e extends $P()(`@openteammate/offload/Processes`){static layer=yH(e,qU(function*(){let t=yield*WQ,n=e=>e instanceof U5,r=e=>{let r=f7(e.executable,e.args);return o7({...e,stdout:e.stdout??z5(8388608,`terminate`),stderr:z5(d7,`keep-tail`)}).pipe(dW(n,e=>h7(r,e)),q(e=>m7(r,e)),kW(WQ,t),KW(`Processes.run`))};return e.of({run:r,checked:e=>r(e).pipe(q(t=>t.exitCode===0?W(t):K(new lle({command:f7(e.executable,e.args),exitCode:t.exitCode,stderr:t.stderr}))),KW(`Processes.checked`)),hold:e=>{let r=f7(e.executable,e.args);return cle({...e,stdout:e.stdout??z5(8388608,`terminate`),stderr:z5(d7,`keep-tail`)}).pipe(dW(n,e=>h7(r,e)),J(e=>({pid:e.pid,ended:e.await.pipe(dW(n,e=>h7(r,e)),q(e=>m7(r,e)))})),kW(WQ,t),KW(`Processes.hold`))}})}))};const _7=e=>new TextDecoder().decode(e);var v7=class extends P4()(`InvalidInput`,{field:X,message:X}){};const y7=`teammates`,b7=`us-west-2`,x7=`mac-host`,S7=`c-team`,C7=mI(24),dle=mI(24),w7=pI(10),T7={pool:`ot-pool`,kind:`ot-kind`,owner:`ot-owner`,run:`ot-run`,retireAt:`ot-retire-at`,macos:`ot-macos`,ready:`ot-ready`,admission:`ot-admission`},E7=Z({Key:X,Value:X}),D7=Z({Hosts:U2(Z({HostId:X,State:X,AvailabilityZone:M2(X),AllocationTime:M2(X),HostProperties:M2(Z({InstanceType:M2(X)})),Instances:M2(U2(Z({InstanceId:X}))),Tags:M2(U2(E7))}))}),fle=Z({Reservations:U2(Z({Instances:U2(Z({InstanceId:X,State:Z({Name:X}),ImageId:M2(X),Placement:M2(Z({HostId:M2(X)})),Tags:M2(U2(E7))}))}))}),ple=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z$/,O7=e=>e.toISOString().replace(/\.\d{3}Z$/,`Z`),k7=e=>{let t=ple.exec(e??``);if(e===void 0||t===null||t[1]===`0000`)return;let n=new Date(e);return Number.isNaN(n.getTime())||O7(n)!==e?void 0:n},mle=e=>new Date(Math.ceil(e.getTime()/1e3)*1e3),A7=(e,t)=>O7(new Date(e.getTime()+Math.max(hI(dle),hI(t))+6e4)),j7=e=>e?.find(e=>e.Key===T7.retireAt)?.Value,hle=(e,t)=>{if(e===void 0)return{write:!1,reason:`current value is missing or malformed`};let n=mle(t);return e.getTime()>=n.getTime()?{write:!1,reason:`current value is already later`}:{write:!0,value:O7(n)}},M7=e=>Object.fromEntries((e??[]).map(e=>[e.Key,e.Value])),N7=Z({run:X,deadlineEpochSeconds:d4}),gle=(e,t)=>{let n=new Map(t.Reservations.flatMap(e=>e.Instances).map(e=>{let t=M7(e.Tags),n={id:e.InstanceId,state:e.State.Name,imageId:e.ImageId,tags:t,retireAt:k7(t[T7.retireAt])};return[e.InstanceId,n]}));return e.Hosts.map(e=>{let t=M7(e.Tags);return{id:e.HostId,state:e.State,zone:e.AvailabilityZone,instanceType:e.HostProperties?.InstanceType,allocatedAt:e.AllocationTime,tags:t,retireAt:k7(t[T7.retireAt]),instances:(e.Instances??[]).flatMap(e=>{let t=n.get(e.InstanceId);return t===void 0?[]:[t]})}})},_le=new Set([`released`,`released-permanent-failure`]),P7=e=>e.retireAt===void 0?void 0:e.instances.reduce((e,t)=>t.retireAt!==void 0&&t.retireAt.getTime()>e.getTime()?t.retireAt:e,e.retireAt),F7=(e,t)=>e.filter(e=>{let n=P7(e);return!_le.has(e.state)&&n!==void 0&&n.getTime()<t.getTime()}),vle=e=>{let t=/^(\d+)(?:\.\d+){0,2}$/.exec(e??``);return t===null?void 0:Number(t[1])},I7=(e,t)=>{let n=[];(e.tags[T7.pool]!==`teammates`||e.tags[T7.kind]!==`mac-host`)&&n.push(`not tagged as a team pool Mac`),e.state!==`available`&&n.push(`host state is ${e.state}`),e.tags[T7.ready]!==`true`&&n.push(`ot-ready is not true`);let r=vle(e.tags[T7.macos]);r===void 0?n.push(`ot-macos is missing or malformed`):r<t.guestMacosMajor&&n.push(`macOS ${e.tags[T7.macos]} cannot run a macOS ${t.guestMacosMajor} guest`);let i=P7(e);i===void 0?n.push(`ot-retire-at is missing or malformed`):i.getTime()-t.now.getTime()<hI(w7)&&n.push(`ot-retire-at ${O7(i)} leaves less than the ${Yie(w7)}-minute reuse margin`);let[a,...o]=e.instances;return a===void 0?n.push(`no instance on the host`):(o.length>0&&n.push(`${e.instances.length} instances on the host`),a.state!==`running`&&n.push(`instance ${a.id} is ${a.state}`),a.tags[T7.admission]!==`session-manager`&&n.push(`instance is not admitted to Session Manager`),(a.tags[T7.pool]!==`teammates`||a.tags[T7.kind]!==`mac-host`)&&n.push(`instance is not tagged as a team pool Mac`),a.retireAt===void 0&&n.push(`instance ot-retire-at is missing or malformed`)),n.length===0&&a!==void 0?{usable:!0,host:e,instance:a}:{usable:!1,host:e,reasons:n}},yle=(e,t)=>e.map(e=>I7(e,t)).filter(e=>e.usable).toSorted((e,t)=>(P7(t.host)?.getTime()??0)-(P7(e.host)?.getTime()??0)),ble=G2([Z({outcome:F2(`booted`),vm:X,ip:X,mac:X,guestMacos:X,guestHostKey:X,bootSeconds:z2,boundSeconds:z2}),Z({outcome:F2(`runner-exited`),vm:X,runnerExit:G2([z2,X]),frameworkDomain:X,frameworkCode:G2([z2,F2(``)]),frameworkStarted:B2,probe:K2([`present`,`absent`]),presentBeforeDelete:B2,absent:B2,log:X}),Z({outcome:F2(`not-established`),vm:X,boundSeconds:z2,presentBeforeDelete:B2,absent:B2,log:X}),Z({outcome:F2(`clone-failed`),vm:X,base:X,reason:X,absent:B2}),Z({outcome:F2(`cancelled`),vm:X,absent:B2,reason:X}),Z({outcome:K2([`name-taken`,`refused-input`]),reason:X}),Z({outcome:F2(`host-held`),reason:X})]),xle=e=>O2(ble)(e),L7=e=>{switch(e.outcome){case`host-held`:return{kind:`held`,reason:e.reason};case`booted`:return{kind:`booted`,vm:e.vm,ip:e.ip,mac:e.mac,guestMacos:e.guestMacos,guestHostKey:e.guestHostKey,bootSeconds:e.bootSeconds};case`runner-exited`:return e.frameworkDomain===`VZErrorDomain`&&e.frameworkCode===6&&!e.frameworkStarted?{kind:`limit`,cloneAbsent:e.absent}:{kind:`failed`,reason:e.probe===`absent`?`the VM's runner exited ${e.runnerExit}; no probe on the host to read the framework's error`:e.frameworkStarted?`the VM's runner exited ${e.runnerExit}, and the framework then started the same VM`:`the VM's runner exited ${e.runnerExit}; the framework reported ${e.frameworkDomain||`no domain`} code ${e.frameworkCode===``?`none`:e.frameworkCode}`,cloneAbsent:e.absent};case`not-established`:return{kind:`failed`,reason:`the guest did not answer over SSH within ${e.boundSeconds} s`,cloneAbsent:e.absent};case`clone-failed`:return{kind:`failed`,reason:`cloning ${e.base} failed: ${e.reason}`,cloneAbsent:e.absent};case`cancelled`:return{kind:`cancelled`,reason:e.reason,cloneAbsent:e.absent};case`name-taken`:case`refused-input`:return{kind:`refused`,reason:e.reason};default:return e}},R7=e=>Object.entries(e).map(([e,t])=>({Key:e,Value:t})),z7=e=>({[T7.pool]:y7,[T7.kind]:x7,[T7.owner]:e.owner,[T7.run]:e.run,[T7.retireAt]:e.retireAt,[T7.macos]:e.hostMacos,Name:`ot-${e.run}`}),Sle=(e,t)=>({InstanceType:`${e.family}.metal`,Quantity:1,AutoPlacement:`off`,HostRecovery:`off`,AvailabilityZone:e.zone,ClientToken:t,TagSpecifications:[{ResourceType:`dedicated-host`,Tags:R7(z7(e))}]}),Cle=(e,t)=>({ImageId:t.imageId,InstanceType:`${e.family}.metal`,MinCount:1,MaxCount:1,Placement:{HostId:t.hostId,Tenancy:`host`},IamInstanceProfile:{Name:`openteammate-host-ssm`},MetadataOptions:{HttpTokens:`required`,HttpPutResponseHopLimit:1,HttpEndpoint:`enabled`},SecurityGroupIds:[t.securityGroupId],SubnetId:t.subnetId,BlockDeviceMappings:[{DeviceName:t.rootDevice,Ebs:{VolumeSize:500,VolumeType:`gp3`,Iops:5e3,Throughput:500,DeleteOnTermination:!0}}],ClientToken:`${e.run}-instance`,TagSpecifications:[{ResourceType:`instance`,Tags:R7({...z7(e),[T7.admission]:`session-manager`})},{ResourceType:`volume`,Tags:R7(z7(e))}]}),wle=qie(3),Tle=(e,t)=>e.filter(e=>Date.parse(e.CreationDate)<=t.getTime()-hI(wle)).toSorted((e,t)=>Date.parse(t.CreationDate)-Date.parse(e.CreationDate)).at(0),B7=e=>`"${e.replaceAll(`"`,`\\"`)}"`,V7=e=>{let t=`${e.directory}/id_ed25519`,n=`${e.directory}/known_hosts`,r=[`Host mac`,` HostName ${e.instanceId}`,` User ${S7}`,` IdentityFile ${B7(t)}`,` IdentitiesOnly yes`,` UserKnownHostsFile ${B7(n)}`,` StrictHostKeyChecking yes`,` HostKeyAlias ${e.instanceId}`,` ProxyCommand ${B7(e.otFleet)} proxy-instance ${e.instanceId} ${S7} ${B7(`${t}.pub`)}`,` ServerAliveInterval 15`,` ServerAliveCountMax 3`,` ControlMaster auto`,` ControlPath /tmp/ot-%C`,` ControlPersist 60`];return e.vm!==void 0&&r.push(`Host vm`,` HostName ${e.vm.ip}`,` User lume`,` ProxyJump mac`,` IdentityFile ${B7(t)}`,` IdentitiesOnly yes`,` UserKnownHostsFile ${B7(n)}`,` StrictHostKeyChecking yes`,` HostKeyAlias ${e.vm.name}`,` ServerAliveInterval 15`),r.join(`
|
|
574
|
+
`)+`
|
|
575
|
+
`},H7=/^\s*(ssh-ed25519) ([A-Za-z0-9+/=]+)(?:\s|$)/,U7=X.check(o4(H7)),W7=(e,t)=>{let n=H7.exec(t.trim());if(n===null)throw Error(`not an ssh-ed25519 public key: ${t.slice(0,40)}`);return`${e} ${n[1]} ${n[2]}\n`},G7={repository:`trycua/macos-tahoe-vanilla`,tag:`latest`,digest:`sha256:10a8c1c95c5c2367c633d99be2aa91abf1e7db9cf80c7829061b57c997674b67`,macosMajor:26,baseVm:`ot-base-tahoe`},K7=e=>({hostId:e.id,state:e.state,zone:e.zone??null,instanceType:e.instanceType??null,allocatedAt:e.allocatedAt??null,owner:e.tags[T7.owner]??null,run:e.tags[T7.run]??null,retireAt:e.tags[T7.retireAt]??null,macos:e.tags[T7.macos]??null,ready:e.tags[T7.ready]??null,instances:e.instances.map(e=>({instanceId:e.id,state:e.state,admission:e.tags[T7.admission]??null,retireAt:e.tags[T7.retireAt]??null}))}),Ele=(e,t)=>{if(e.createdAtEpochSeconds===null||!Number.isFinite(e.createdAtEpochSeconds))return{name:e.name,state:e.state,isBaseImage:e.name===G7.baseVm,createdAt:null,ageSeconds:null};let n=new Date(e.createdAtEpochSeconds*1e3);return{name:e.name,state:e.state,isBaseImage:e.name===G7.baseVm,createdAt:O7(n),ageSeconds:Math.max(0,Math.floor((t.getTime()-n.getTime())/1e3))}},Dle=Z({instanceId:X,state:X,admission:q2(X),retireAt:q2(X)}),q7={hostId:X,state:X,zone:q2(X),instanceType:q2(X),allocatedAt:q2(X),owner:q2(X),run:q2(X),retireAt:q2(X),macos:q2(X),ready:q2(X),instances:U2(Dle)},Ole=Z({name:X,state:X,isBaseImage:B2,createdAt:q2(X),ageSeconds:q2(d4)}),kle=Z({schema:F2(`openteammate.team-mac/inventory@3`),observedAt:X,region:X,hosts:U2(Z({...q7,usable:B2,reasons:U2(X),vms:q2(U2(Ole)),vmInventoryError:q2(X),hold:q2(Z({...N7.fields,expired:B2})),holdInventoryError:q2(X)})),expiredStillAllocated:U2(Z(q7))}),Ale=(e,t,n={})=>{let r={now:t,guestMacosMajor:G7.macosMajor};return{schema:`openteammate.team-mac/inventory@3`,observedAt:O7(t),region:b7,hosts:e.map(e=>{let i=I7(e,r),a=n[e.id],o=a?.hold;return{...K7(e),usable:i.usable,reasons:i.usable?[]:i.reasons,vms:a?.vms?.map(e=>Ele(e,t))??null,vmInventoryError:a?.error??(a===void 0?`not queried`:null),hold:o==null?null:{...o,expired:o.deadlineEpochSeconds<=Math.floor(t.getTime()/1e3)},holdInventoryError:a?.holdError??(a===void 0?`not queried`:null)}}),expiredStillAllocated:F7(e,t).map(K7)}};var $=class extends P4()(`TeamMacError`,{step:X,message:X}){},J7=class extends P4()(`AwsFailure`,{step:X,code:X,message:X}){},Y7=class extends P4()(`TeamMacBlocked`,{reason:X,report:I2}){};const X7=e=>Ee(new URL(`../team-mac/${e}`,import.meta.url)),jle=[`PATH`,`HOME`,`AWS_CONFIG_FILE`,`AWS_SHARED_CREDENTIALS_FILE`,`AWS_RETRY_MODE`,`AWS_MAX_ATTEMPTS`,`OT_FLEET_AWS_ACCESS_KEY_ID`,`OT_FLEET_AWS_SECRET_ACCESS_KEY`,`OT_FLEET_AWS_SESSION_TOKEN`,`OT_FLEET_AWS_REGION`,`OT_FLEET_AWS_PROFILE`],Z7=e=>Object.fromEntries(jle.flatMap(t=>{let n=e[t];return n===void 0?[]:[[t,n]]})),Mle=e=>{let t={AWS_PROFILE:e.profile,AWS_REGION:e.region,AWS_PAGER:``,AWS_CLI_AUTO_PROMPT:`off`,AWS_RETRY_MODE:`standard`,AWS_MAX_ATTEMPTS:`5`,LC_ALL:`C`};for(let n of[`PATH`,`HOME`,`AWS_CONFIG_FILE`,`AWS_SHARED_CREDENTIALS_FILE`]){let r=e.env[n];r!==void 0&&(t[n]=r)}return t},Nle=e=>/An error occurred \(([A-Za-z0-9.]+)\)/.exec(e)?.[1]??`unknown`,Ple=[100,200],Q7=e=>({_tag:`success`,value:e}),Fle=e=>({_tag:`failure`,failure:e}),$7=JH.pipe(J(e=>new Date(e))),e9=(e,t,n=384)=>{pe(i(e),{recursive:!0,mode:448});let r=`${e}.tmp-${process.pid}`;_e(r,t,{mode:n}),ue(r,n),T(r,e)},t9=e=>o(e.directory,`known_hosts`),n9=e=>fe(t9(e))?he(t9(e),`utf8`).split(`
|
|
576
|
+
`).filter(e=>e!==``):[],Ile=(e,t)=>n9(e).some(e=>e.startsWith(`${t} `)),r9=(e,t,n)=>e9(t9(e),[...n9(e).filter(e=>!e.startsWith(`${t} `)),n.trimEnd()].join(`
|
|
577
|
+
`)+`
|
|
578
|
+
`),i9=(e,t,n)=>e9(o(e.directory,`steps`,`${t}.json`),JSON.stringify(n,null,2)+`
|
|
579
|
+
`),a9=Y(function*(e,t,n,r){let i=yield*g7,a=r===void 0?pI(5):dI(Math.max(1,r.getTime()-(yield*$7).getTime())),o=yield*i.run({executable:e.tools.aws,args:[...n,`--output`,`json`],env:Mle(e),deadline:a,terminationGrace:fI(3)}).pipe(pW(e=>new $({step:t,message:e.message})));if(o.exitCode!==0)return yield*new J7({step:t,code:Nle(o.stderr),message:o.stderr.trim().slice(-800)});let s=_7(o.stdout).trim();return yield*QU({try:()=>s===``?{}:JSON.parse(s),catch:()=>new $({step:t,message:`aws printed no JSON: ${s.slice(0,200)}`})})}),o9=(e,t,n)=>D2(e)(n).pipe(pW(e=>new $({step:t,message:`unexpected aws output: ${String(e)}`}))),s9=Y(function*(e){let t=yield*a9(e,`describe-hosts`,[`ec2`,`describe-hosts`,`--filter`,`Name=tag:${T7.pool},Values=${y7}`,`Name=tag:${T7.kind},Values=${x7}`]).pipe(q(e=>o9(D7,`describe-hosts`,e))),n=yield*a9(e,`describe-instances`,[`ec2`,`describe-instances`,`--filters`,`Name=tag:${T7.pool},Values=${y7}`,`Name=tag:${T7.kind},Values=${x7}`]).pipe(q(e=>o9(fle,`describe-instances`,e)));return gle(t,n)}),Lle=Z({Tags:U2(Z({ResourceId:X,Key:X,Value:X}))}),c9=Y(function*(e,t){return(yield*a9(e,`describe-tags`,[`ec2`,`describe-tags`,`--filters`,`Name=resource-id,Values=${t}`,`Name=key,Values=${T7.retireAt}`]).pipe(q(e=>o9(Lle,`describe-tags`,e)))).Tags.find(e=>e.ResourceId===t)?.Value}),l9=Y(function*(e,t,n){let r=[];for(let i of t){let t=yield*c9(e,i),a=hle(k7(t),n);if(!a.write){r.push({resource:i,before:t??null,after:t??null,wrote:!1,reason:a.reason});continue}let o,s=!0;for(let t=1;;t+=1){s&&(yield*a9(e,`create-tags`,[`ec2`,`create-tags`,`--resources`,i,`--tags`,`Key=${T7.retireAt},Value=${a.value}`])),o=yield*c9(e,i);let r=k7(o);if(r!==void 0&&r.getTime()>=n.getTime()-1e3)break;if(t>=5)return yield*new $({step:`keep-warm`,message:`${i}: wrote ot-retire-at ${a.value}, but after ${t} reads it still read ${o??`nothing`}`});s=r!==void 0,yield*yW(e.poll)}r.push({resource:i,before:t??null,after:o??null,wrote:!0,reason:`moved later`})}return r}),Rle=Z({Status:X,ResponseCode:M2(z2),StandardOutputContent:M2(X),StandardErrorContent:M2(X)}),u9=e=>{let t=e.trim().split(`
|
|
580
|
+
`).at(-1)??``;try{return JSON.parse(t)}catch{return}},zle=new Set([`Success`,`Failed`,`Cancelled`,`TimedOut`,`DeliveryTimedOut`,`ExecutionTimedOut`,`Undeliverable`,`Terminated`,`InvalidPlatform`,`AccessDenied`,`Cancelling`]),d9=Y(function*(e,t,n,r,i,a){if((yield*$7).getTime()>=a.getTime())return yield*new Y7({reason:`the run's deadline passed before Run Command ${t} could start`,report:{step:t,instanceId:n}});let s=o(e.directory,`steps`,`${t}.ssm-parameters.json`);e9(s,JSON.stringify({commands:r,executionTimeout:[String(i)]},null,2)+`
|
|
581
|
+
`);let c=(yield*a9(e,t,[`ssm`,`send-command`,`--instance-ids`,n,`--document-name`,`AWS-RunShellScript`,`--comment`,`team-mac ${t}`,`--timeout-seconds`,`600`,`--parameters`,`file://${s}`]).pipe(q(e=>o9(Z({Command:Z({CommandId:X})}),t,e)))).Command.CommandId,l=(yield*$7).getTime()+(i+720)*1e3,u=Math.min(l,a.getTime());for(let r=(yield*$7).getTime();r<u;r=(yield*$7).getTime()){yield*yW(dI(Math.min(hI(e.poll),u-r)));let i;for(let r=0;;r+=1){let o=a.getTime()-(yield*$7).getTime();if(o<=0)return yield*new Y7({reason:`Run Command ${t} reached its deadline while polling AWS`,report:{step:t,instanceId:n,commandId:c}});let s=yield*a9(e,t,[`ssm`,`get-command-invocation`,`--command-id`,c,`--instance-id`,n],a).pipe(J(Q7),cW(`TeamMacError`,e=>qU(function*(){return(yield*$7).getTime()>=a.getTime()?yield*new Y7({reason:`Run Command ${t} reached its deadline while polling AWS`,report:{step:t,instanceId:n,commandId:c}}):yield*e})),cW(`AwsFailure`,e=>qU(function*(){return(yield*$7).getTime()>=a.getTime()?yield*new Y7({reason:`Run Command ${t} reached its deadline while polling AWS`,report:{step:t,instanceId:n,commandId:c}}):e.code===`InvocationDoesNotExist`?Q7(void 0):Fle(e)})));if(s._tag===`success`){i=s.value;break}let l=Ple[r];if(s.failure.code!==`ThrottlingException`||l===void 0)return yield*s.failure;if(o<=l)return yield*new Y7({reason:`Run Command ${t} reached its deadline before the next AWS retry`,report:{step:t,instanceId:n,commandId:c}});yield*yW(dI(l))}if(i===void 0)continue;let o=yield*o9(Rle,t,i);if(!zle.has(o.Status))continue;let s={commandId:c,status:o.Status,responseCode:o.ResponseCode??null,record:u9(o.StandardOutputContent??``),stderrTail:(o.StandardErrorContent??``).trim().split(`
|
|
582
|
+
`).slice(-12).join(`
|
|
583
|
+
`)};return i9(e,t,s),s}return a.getTime()<=l?yield*new Y7({reason:`Run Command ${t} (${c}) had not finished at the run's deadline`,report:{step:t,instanceId:n,commandId:c}}):yield*new $({step:t,message:`Run Command ${c} did not finish in time`})}),f9=(e,t,n)=>{if(t.split(`
|
|
584
|
+
`).includes(n))throw Error(`${e} contains ${n}`);return[`cat > ${e} <<'${n}'`,...t.replace(/\n$/,``).split(`
|
|
585
|
+
`),n]},p9=e=>[`set -e`,`mkdir -p /var/tmp/ot-team-mac`,...f9(`/var/tmp/ot-team-mac/vz-start-probe.swift`,he(X7(`vz-start-probe.swift`),`utf8`),`OT_TEAM_MAC_PROBE_EOF`),...f9(`/var/tmp/ot-team-mac/host-prepare.sh`,he(X7(`host-prepare.sh`),`utf8`),`OT_TEAM_MAC_PREPARE_EOF`),`/bin/bash /var/tmp/ot-team-mac/host-prepare.sh ${e}`],m9=Z({phase:X,outcome:K2([`ok`,`failed`]),bootTime:M2(X),rebootScheduled:M2(B2),failedStep:M2(X),aqua:M2(X),hostKey:M2(X),lume:M2(X),base:M2(X),probe:M2(X),steps:M2(U2(Z({name:X,status:X,detail:X})))}),Ble=Z({hostId:X,instanceId:X,prepared:Z({setup:m9,check:m9})}),h9=(e,t)=>t.status!==`Success`&&t.status!==`Failed`?K(new $({step:e,message:`Run Command ended ${t.status}`})):t.record===void 0||t.record===null||typeof t.record!=`object`||Array.isArray(t.record)?K(new $({step:e,message:`Run Command ended ${t.status} without a JSON record${t.stderrTail===``?``:`: ${t.stderrTail}`}`})):o9(m9,e,t.record).pipe(cW(`TeamMacError`,()=>t.status===`Failed`?K(new $({step:e,message:`Run Command ended ${t.status}${t.stderrTail===``?``:`: ${t.stderrTail}`}`})):K(new $({step:e,message:`Run Command returned an invalid record`})))),g9=Y(function*(e,t,n){let r=yield*d9(e,`host-key`,t,p9(`check`),300,n),i=yield*h9(`host-key`,r);if(i.hostKey===void 0||i.hostKey===``)return yield*new $({step:`host-key`,message:`the host printed no ed25519 host key`});let a=yield*o9(U7,`host-key`,i.hostKey);return{record:i,line:W7(t,a)}}),_9=Y(function*(e,t,n){let r=yield*d9(e,`prepare-setup`,t.instanceId,p9(`setup`),3600,n),i=yield*h9(`prepare-setup`,r);if(i.outcome!==`ok`)return yield*new $({step:`prepare-setup`,message:`host preparation failed at ${i.failedStep??`an unknown step`}`});let a=d9(e,`prepare-check`,t.instanceId,p9(`check`),300,n).pipe(q(e=>h9(`prepare-check`,e)),J(e=>e),cW(`TeamMacError`,e=>W(e.message))),o=e=>typeof e!=`string`&&e.aqua===`ready`&&(i.rebootScheduled!==!0||e.bootTime!==i.bootTime);i.rebootScheduled===!0&&(yield*yW(e.poll));let s=yield*a;for(;!o(s);){if((yield*$7).getTime()>=n.getTime())return yield*new Y7({reason:`the Mac's Aqua session for c-team was not ready before the run's deadline`,report:{setup:i,lastCheck:s}});yield*yW(e.poll),s=yield*a}if(s.hostKey===void 0||s.base!==`present`||s.lume===void 0)return yield*new $({step:`prepare-check`,message:`the prepared host is incomplete: base=${s.base??`?`} lume=${s.lume??`?`}`});let c=yield*o9(U7,`prepare-check-host-key`,s.hostKey);return r9(e,t.instanceId,W7(t.instanceId,c)),yield*a9(e,`tag-ready`,[`ec2`,`create-tags`,`--resources`,t.hostId,t.instanceId,`--tags`,`Key=${T7.ready},Value=true`]),{setup:i,check:s}}),v9=e=>`'${e.replaceAll(`'`,`'\\''`)}'`,Vle=e=>({...Z7(e.env),LC_ALL:`C`}),y9=Y(function*(e,t,n,r,i){let a=yield*(yield*g7).run({executable:e.tools.ssh,args:[`-F`,o(e.directory,`ssh_config`),`-o`,`ControlMaster=no`,`-o`,`ControlPath=none`,`-o`,`BatchMode=yes`,`mac`,`/bin/bash`,`-s`,`--`,...r.map(v9)],env:Vle(e),stdin:new TextEncoder().encode((n===`vm-start.sh`||n===`host-hold.sh`?he(X7(`host-claim.sh`),`utf8`)+`
|
|
586
|
+
`:``)+he(X7(n),`utf8`)),deadline:i,terminationGrace:fI(5)}).pipe(pW(e=>new $({step:t,message:e.message}))),s=u9(_7(a.stdout));return i9(e,t,{exitCode:a.exitCode,record:s,stderrTail:a.stderr.slice(-2e3)}),s===void 0?yield*new $({step:t,message:`ssh to the Mac ended ${a.exitCode} with no result: ${a.stderr.trim().slice(-400)}`}):s}),Hle=U2(Z({name:X,status:X,createdAtEpochSeconds:q2(z2)})),Ule=Y(function*(e,t){let n=yield*$7,r=new Date(n.getTime()+hI(pI(5))),i=t.instances[0];if(i===void 0)return yield*new $({step:`inventory-vms`,message:`${t.id} has no instance to inspect`});yield*E9(e,`inventory-${t.id}`);let a=yield*d9(e,`inventory-host-key-${t.id}`,i.id,[`perl -MJSON::PP -e 'open my $f, q(<), q(/etc/ssh/ssh_host_ed25519_key.pub) or die q(cannot read host key); my $key = <$f>; print encode_json({hostKey => $key}), qq(\\n);'`],60,r);if(a.status!==`Success`)return yield*new $({step:`inventory-host-key`,message:`Run Command ended ${a.status}`});let s=yield*o9(Z({hostKey:U7}),`inventory-host-key`,a.record);r9(e,i.id,W7(i.id,s.hostKey)),e9(o(e.directory,`ssh_config`),V7({instanceId:i.id,directory:e.directory,otFleet:e.tools.otFleet}));let c=yield*y9(e,`inventory-hold-${t.id}`,`host-hold-read.sh`,[],pI(2)).pipe(q(e=>o9(q2(N7),`inventory-hold`,e)),J(e=>({hold:e,holdError:null})),sW(e=>W({hold:null,holdError:B9(e)}))),l=yield*y9(e,`inventory-vms-${t.id}`,`vm-list.sh`,[],pI(2)).pipe(q(e=>o9(Hle,`inventory-vms`,e)),J(e=>({vms:e.map(e=>({name:e.name,state:e.status,createdAtEpochSeconds:e.createdAtEpochSeconds})),error:null})),sW(e=>W({vms:null,error:B9(e)})));return{...c,...l}}),Wle=Z({resource:X,before:q2(X),after:q2(X),wrote:B2,reason:X}),Gle=Z({kind:F2(`booted`),vm:X,ip:X,mac:X,guestMacos:X,guestHostKey:X,bootSeconds:z2,owner:M2(X)}),b9=Z({hostId:X,instanceId:X,zone:q2(X)}),Kle=Z({owner:X,attempt:X,deadlineEpochSeconds:d4,released:B2}),x9=Z({outcome:K2([`held`,`released`,`not-owned`,`blocked`]),reason:M2(X)}),qle=Z({vm:X,host:b9,owner:X,startProtocol:M2(F2(`claim-v1`))}),S9=Z({schema:F2(`openteammate.team-mac/run@1`),run:X,owner:X,region:X,admittedAt:M2(X),vmDeadlineEpochSeconds:M2(d4),host:q2(b9),hold:M2(Kle),vm:q2(Gle),pending:M2(q2(qle)),attempts:U2(I2),allocated:I2,prepared:I2,retireAt:U2(Wle),stopped:I2}),C9=e=>o(e.directory,`record.json`),w9=(e,t)=>e9(C9(e),JSON.stringify(t,null,2)+`
|
|
587
|
+
`),T9=e=>QU({try:()=>JSON.parse(he(C9(e),`utf8`)),catch:e=>new $({step:`record`,message:`cannot read record.json: ${String(e)}`})}).pipe(q(e=>o9(S9,`record`,e))),E9=Y(function*(e,t){let n=o(e.directory,`id_ed25519`);return fe(n)&&fe(`${n}.pub`)?he(`${n}.pub`,`utf8`).trim():(pe(e.directory,{recursive:!0,mode:448}),yield*(yield*g7).checked({executable:e.tools.sshKeygen,args:[`-q`,`-t`,`ed25519`,`-N`,``,`-C`,`team-mac-${t}`,`-f`,n],env:{PATH:`/usr/bin:/bin`,LC_ALL:`C`},deadline:fI(30),terminationGrace:fI(2)}).pipe(pW(e=>new $({step:`run-key`,message:e.message}))),he(`${n}.pub`,`utf8`).trim())}),Jle=pI(2),Yle=fI(30),D9=Y(function*(e,t,n,r){let i=`hold-check-${t.hostId}`,a=yield*d9(e,i,t.instanceId,[`/bin/bash -s -- ${v9(n)} ${v9(S7)} <<'OT_TEAM_MAC_HOLD_CHECK_EOF'`,he(X7(`host-claim.sh`),`utf8`),he(X7(`host-hold-check.sh`),`utf8`),`OT_TEAM_MAC_HOLD_CHECK_EOF`],300,r);return a.status===`Success`?yield*o9(q2(X),i,a.record):yield*new $({step:i,message:`host hold read ended ${a.status}: ${a.stderrTail}`})}),Xle=Y(function*(e,t,n,r,i,a,s){let c=yield*D9(e,{hostId:n.host.id,instanceId:n.instanceId},r,i);if(c!==null)return{verdict:L7({outcome:`host-held`,reason:c}),record:{outcome:`host-held`,reason:c},retire:[],boundSeconds:0};let l=yield*l9(e,[n.host.id,n.instanceId],new Date(i.getTime()+hI(t.need)));if(!Ile(e,n.instanceId)){let t=yield*g9(e,n.instanceId,i);r9(e,n.instanceId,t.line)}e9(o(e.directory,`ssh_config`),V7({instanceId:n.instanceId,directory:e.directory,otFleet:e.tools.otFleet}));let u=i.getTime()-(yield*$7).getTime()-hI(Jle);if(u<hI(Yle))return yield*new Y7({reason:`the run's deadline left too little time to start a VM on ${n.host.id}`,report:{hostId:n.host.id,retireAt:l}});let f=Math.floor(u/1e3),p=`${r} ${d()}`;s({vm:t.vm,host:{hostId:n.host.id,instanceId:n.instanceId,zone:n.host.zone??null},owner:p,startProtocol:`claim-v1`});let m=yield*y9(e,`vm-start-${n.host.id}`,`vm-start.sh`,[t.vm,G7.baseVm,String(f),p,String(a)],fI(f+180)),h=yield*QU({try:()=>xle(m),catch:e=>new $({step:`vm-start`,message:`unexpected start record: ${String(e)}`})});return{verdict:L7(h),record:h,retire:l,boundSeconds:f}}),Zle=Z({InstanceTypeOfferings:U2(Z({Location:X}))}),Qle=Z({Images:U2(Z({ImageId:X,Name:X,CreationDate:X,RootDeviceName:X}))}),$le=Z({Quotas:U2(Z({QuotaName:X,QuotaCode:X,Value:z2}))}),eue=Z({RequestedQuotas:U2(Z({Id:X,Status:X,DesiredValue:M2(z2)}))}),tue=Z({SecurityGroups:U2(Z({GroupId:X,VpcId:X}))}),nue=Z({Subnets:U2(Z({SubnetId:X}))}),rue=Z({HostIds:U2(X)}),iue=Z({Instances:U2(Z({InstanceId:X}))}),aue=Z({InstanceInformationList:U2(Z({InstanceId:X,PingStatus:X}))}),oue=Y(function*(e,t){let n=`Running Dedicated ${t} Hosts`,r=(yield*a9(e,`quota`,[`service-quotas`,`list-service-quotas`,`--service-code`,`ec2`,`--query`,`{Quotas: Quotas[?QuotaName=='${n}']}`]).pipe(q(e=>o9($le,`quota`,e)))).Quotas[0];if(r===void 0)return yield*new $({step:`quota`,message:`no quota named ${n}`});let i=(yield*a9(e,`quota-usage`,[`ec2`,`describe-hosts`,`--filter`,`Name=instance-type,Values=${t}.metal`]).pipe(q(e=>o9(D7,`quota-usage`,e)))).Hosts.filter(e=>e.State!==`released`&&e.State!==`released-permanent-failure`).length,a=yield*a9(e,`quota-requests`,[`service-quotas`,`list-requested-service-quota-change-history-by-quota`,`--service-code`,`ec2`,`--quota-code`,r.QuotaCode]).pipe(q(e=>o9(eue,`quota-requests`,e)));return{name:n,code:r.QuotaCode,applied:r.Value,inUse:i,openRequests:a.RequestedQuotas.filter(e=>e.Status===`PENDING`||e.Status===`CASE_OPENED`)}}),sue=Z({Placement:Z({HostId:X})}),cue=e=>fe(e)?QU({try:()=>JSON.parse(he(e,`utf8`)),catch:e=>new $({step:`run-instances`,message:`cannot read this run's earlier launch request: ${String(e)}`})}).pipe(q(e=>o9(sue,`run-instances`,e)),J(e=>e.Placement.HostId)):W(void 0),O9=Y(function*(e,t){return(yield*a9(e,`find-run-host`,[`ec2`,`describe-hosts`,`--filter`,`Name=tag:${T7.run},Values=${t}`,`Name=tag:${T7.pool},Values=${y7}`]).pipe(q(e=>o9(D7,`find-run-host`,e)))).Hosts.find(e=>e.State!==`released`&&e.State!==`released-permanent-failure`)}),k9=Y(function*(e,t,n,r,i){let a=``;for(;a!==`Online`;)(yield*$7).getTime()>=i.getTime()&&(yield*new Y7({reason:`instance ${n} did not reach Session Manager before the run's deadline`,report:{hostId:t,instanceId:n,retireAt:r}})),yield*yW(e.poll),a=(yield*a9(e,`ssm-ping`,[`ssm`,`describe-instance-information`,`--filters`,`Key=InstanceIds,Values=${n}`]).pipe(q(e=>o9(aue,`ssm-ping`,e)))).InstanceInformationList[0]?.PingStatus??`absent`}),lue=Y(function*(e,t,n,r){let i=yield*$7,a=yield*O9(e,t.run),s=a?.Instances?.[0];if(a!==void 0&&s!==void 0){yield*k9(e,a.HostId,s.InstanceId,j7(a.Tags),r);let n=yield*D9(e,{hostId:a.HostId,instanceId:s.InstanceId},yield*E9(e,t.run),r);if(n!==null)return yield*new Y7({reason:n,report:{hostId:a.HostId}})}let c=yield*oue(e,t.family),l=F7(n,i).map(K7);if(a===void 0&&c.inUse>=c.applied)return yield*new Y7({reason:`the ${c.name} quota (${c.code}) is ${c.applied} and ${c.inUse} hosts hold it`,report:{quota:c,expiredStillAllocated:l}});let u=(yield*a9(e,`security-group`,[`ec2`,`describe-security-groups`,`--filters`,`Name=group-name,Values=ot-no-ingress`]).pipe(q(e=>o9(tue,`security-group`,e)))).SecurityGroups[0];if(u===void 0)return yield*new $({step:`security-group`,message:`no ot-no-ingress security group: the account's one-time pool setup has not been deployed`});let d=yield*a9(e,`image`,[`ec2`,`describe-images`,`--owners`,`amazon`,`--filters`,`Name=name,Values=amzn-ec2-macos-${t.hostMacos}*`,`Name=architecture,Values=arm64_mac`,`Name=state,Values=available`]).pipe(q(e=>o9(Qle,`image`,e))),f=Tle(d.Images,i);if(f===void 0)return yield*new Y7({reason:`AWS publishes no arm64 macOS ${t.hostMacos} image at least three days old`,report:{images:d.Images.map(e=>e.Name)}});let p=(yield*a9(e,`offerings`,[`ec2`,`describe-instance-type-offerings`,`--location-type`,`availability-zone`,`--filters`,`Name=instance-type,Values=${t.family}.metal`]).pipe(q(e=>o9(Zle,`offerings`,e)))).InstanceTypeOfferings.map(e=>e.Location).toSorted();if(p.length===0)return yield*new Y7({reason:`AWS offers ${t.family}.metal in no zone of ${e.region}`,report:{family:t.family,expiredStillAllocated:l}});let m=[],h=a?.HostId,g=j7(a?.Tags),_;for(let n=1;h===void 0;n+=1){for(let r of p){let i={...A9(t),zone:r,retireAt:A7(yield*$7,t.need)},a=o(e.directory,`steps`,`allocate-hosts-${r}-r${n}.json`);e9(a,JSON.stringify(Sle(i,`${t.run}-host-${r}-r${n}`),null,2)+`
|
|
588
|
+
`);let s=yield*a9(e,`allocate-hosts`,[`ec2`,`allocate-hosts`,`--cli-input-json`,`file://${a}`]).pipe(q(e=>o9(rue,`allocate-hosts`,e)),J(e=>e.HostIds[0]),cW(`AwsFailure`,e=>e.code===`InsufficientHostCapacity`?G(()=>{m.push({zone:r,round:n,code:e.code})}):K(e)));if(s!==void 0){h=s,_=r,g=i.retireAt;break}}if(h!==void 0)break;if((yield*$7).getTime()+hI(e.poll)>=r.getTime())return yield*new Y7({reason:`no zone had mac host capacity before the run's deadline`,report:{refusals:m,expiredStillAllocated:l}});yield*yW(e.poll);let i=yield*O9(e,t.run);h=i?.HostId,g=j7(i?.Tags)}let v=g??A7(yield*$7,t.need),y=``;for(;y!==`available`;){let t=yield*a9(e,`host-state`,[`ec2`,`describe-hosts`,`--host-ids`,h]).pipe(q(e=>o9(D7,`host-state`,e)));if(y=t.Hosts[0]?.State??`missing`,_=t.Hosts[0]?.AvailabilityZone??_,y===`available`)break;if((yield*$7).getTime()>=r.getTime())return yield*new Y7({reason:`host ${h} stayed ${y} until the run's deadline; it keeps its ot-retire-at ${v} and the administrator's sweep releases it`,report:{hostId:h,state:y,retireAt:v}});yield*yW(e.poll)}let ee=(yield*a9(e,`subnet`,[`ec2`,`describe-subnets`,`--filters`,`Name=vpc-id,Values=${u.VpcId}`,`Name=availability-zone,Values=${_??``}`,`Name=default-for-az,Values=true`]).pipe(q(e=>o9(nue,`subnet`,e)))).Subnets[0];if(ee===void 0)return yield*new $({step:`subnet`,message:`no default subnet in ${_??`the host's zone`}`});let b=o(e.directory,`steps`,`run-instances.json`);(yield*cue(b))!==h&&e9(b,JSON.stringify(Cle({...A9(t),zone:_??``,retireAt:v},{hostId:h,imageId:f.ImageId,rootDevice:f.RootDeviceName,securityGroupId:u.GroupId,subnetId:ee.SubnetId}),null,2)+`
|
|
589
|
+
`);let te=(yield*a9(e,`run-instances`,[`ec2`,`run-instances`,`--cli-input-json`,`file://${b}`]).pipe(q(e=>o9(iue,`run-instances`,e)))).Instances[0]?.InstanceId;return te===void 0?yield*new $({step:`run-instances`,message:`no instance ID`}):(yield*k9(e,h,te,v,r),{hostId:h,instanceId:te,zone:_??null,image:{id:f.ImageId,name:f.Name},retireAt:v,refusals:m,quota:c})}),A9=e=>({run:e.run,owner:e.owner,family:e.family,hostMacos:e.hostMacos}),uue=Y(function*(e,t){let n;if(fe(C9(e))){let r=yield*T9(e);if((r.vm!==null||r.pending!==null&&r.pending!==void 0)&&!E2(Z({absent:F2(!0)}))(r.stopped))return yield*new $({step:`vm-start`,message:`the run record already names a VM; run stop with this --dir before starting again`});if(r.hold!==void 0&&!r.hold.released){if(r.run!==t.run||t.host!==void 0&&t.host!==r.host?.hostId)return yield*new $({step:`vm-start`,message:`this directory holds a different run or host; stop it before starting another run`});n=r}}let r=yield*E9(e,t.run),i=yield*$7,a=new Date(i.getTime()+hI(t.within)),o=Math.floor((a.getTime()+hI(t.need))/1e3),s=yield*s9(e),c={now:i,guestMacosMajor:G7.macosMajor},l=[],u={schema:`openteammate.team-mac/run@1`,run:t.run,owner:t.owner,region:e.region,vmDeadlineEpochSeconds:o,host:n?.host??null,...n?.hold===void 0?{}:{hold:n.hold},vm:null,pending:null,attempts:l,allocated:null,prepared:null,retireAt:[],stopped:null},d=n?.host?.hostId??t.host,f=d===void 0?yle(s,c):s.filter(e=>e.id===d).map(e=>I7(e,c)).flatMap(e=>e.usable?[e]:(l.push({hostId:e.host.id,skipped:e.reasons}),[]));d!==void 0&&s.every(e=>e.id!==d)&&l.push({hostId:d,skipped:[`not a team pool Mac`]});let p=Y(function*(n){let i=yield*Xle(e,t,n,r,a,o,t=>{u={...u,pending:t},w9(e,u)}),s=i.verdict.kind===`refused`||i.verdict.kind===`held`||(i.verdict.kind===`limit`||i.verdict.kind===`failed`||i.verdict.kind===`cancelled`)&&i.verdict.cloneAbsent;return l.push({hostId:n.host.id,instanceId:n.instanceId,verdict:i.verdict,boundSeconds:i.boundSeconds}),u={...u,pending:s?null:u.pending??null,retireAt:[...u.retireAt,...i.retire]},w9(e,u),i.verdict});for(let t of f){let n=yield*p({host:t.host,instanceId:t.instance.id});if(n.kind===`booted`)return yield*j9(e,u,t.host,t.instance.id,n);if(n.kind===`limit`&&!n.cloneAbsent)return yield*new $({step:`vm-start`,message:`${t.host.id}: the clone is not confirmed absent; run stop with this --dir`});if(n.kind!==`limit`&&n.kind!==`held`)return yield*new $({step:`vm-start`,message:`${t.host.id}: ${n.reason}`})}if(d!==void 0||!t.allocate)return yield*new Y7({reason:d===void 0?`no team pool Mac took the VM, and this run does not allocate`:`pool Mac ${d} did not take the VM`,report:{attempts:l,expiredStillAllocated:F7(s,i).map(K7)}});let m=yield*lue(e,t,s,a);u={...u,allocated:m},w9(e,u);let h=yield*_9(e,{hostId:m.hostId,instanceId:m.instanceId},a);u={...u,prepared:h},w9(e,u);let g=(yield*s9(e)).find(e=>e.id===m.hostId);if(g===void 0)return yield*new $({step:`allocate`,message:`${m.hostId} is missing from the pool read`});let _=yield*p({host:g,instanceId:m.instanceId});return _.kind===`booted`?yield*j9(e,u,g,m.instanceId,_):yield*new $({step:`vm-start`,message:`the VM did not start on the Mac this run allocated: ${`reason`in _?_.reason:_.kind}`})}),j9=Y(function*(e,t,n,r,i){let a=yield*$7,s={...t,host:{hostId:n.id,instanceId:r,zone:n.zone??null},vm:{...i,...t.pending!==null&&t.pending!==void 0?{owner:t.pending.owner}:{}},pending:null,admittedAt:O7(a)};w9(e,s);let c=yield*QU({try:()=>W7(i.vm,i.guestHostKey),catch:()=>new $({step:`vm-start`,message:`${i.vm} booted, but its guest gave no ed25519 host key; it is recorded, so run stop with this --dir to delete it`})});return r9(e,i.vm,c),e9(o(e.directory,`ssh_config`),V7({instanceId:r,directory:e.directory,otFleet:e.tools.otFleet,vm:{name:i.vm,ip:i.ip}})),s}),M9=Z({outcome:X,reason:M2(X),vm:M2(X),absent:M2(B2),at:M2(X)}),due=Y(function*(e,t=fI(120)){let n=yield*T9(e),r=n.host??n.pending?.host,i=n.vm?.vm??n.pending?.vm;if(r===void 0||i===void 0&&n.hold===void 0)return yield*new $({step:`stop`,message:`the run record names no VM or host hold`});let a;if(E2(M9)(n.stopped)&&n.stopped.absent===!0)a=n.stopped;else if(i===void 0)a={outcome:`hold-only`,absent:!0};else{if(n.vm===null&&n.pending?.startProtocol!==`claim-v1`)return yield*new $({step:`vm-stop`,message:`this pending start predates startup claims; remote completion cannot be confirmed; the record and key are retained`});let r=n.vm?.owner??n.pending?.owner;if(n.vm===null&&(r===void 0||r===``))return yield*new $({step:`vm-stop`,message:`the run record has no VM attempt identity; ownership cannot be confirmed; the record and key are retained`});a=yield*y9(e,`vm-stop`,`vm-stop.sh`,[i,String(Jie(t)),r??``,n.vm?.mac??``],pI(5)).pipe(q(e=>o9(M9,`vm-stop`,e)))}if(a.outcome===`refused-owner`)return yield*new $({step:`vm-stop`,message:`${i}: ${a.reason??`the VM has no matching run ownership marker`}; the run record and key are retained`});if(a.outcome===`start-in-progress`)return yield*new Y7({reason:`${i}: ${a.reason??`another start or stop of this VM is active; retry stop after it exits`}`,report:{vm:i,hostId:r.hostId,instanceId:r.instanceId}});let s=yield*$7,c={...a,at:a.at??O7(s)},l={...n,host:r,stopped:c};if(w9(e,l),a.absent!==!0)return yield*new $({step:`vm-stop`,message:`the VM was not confirmed absent: ${a.outcome}`});if(n.hold!==void 0&&!n.hold.released){let t=yield*y9(e,`host-hold-release-${n.hold.attempt}`,`host-hold.sh`,[`release`,n.run,n.hold.owner,`0`,n.hold.attempt],pI(2)).pipe(q(e=>o9(x9,`host-hold-release`,e)));if(t.outcome!==`released`&&t.outcome!==`not-owned`)return yield*new $({step:`host-hold-release`,message:t.reason??`the host hold was not released`});l={...l,hold:{...n.hold,released:!0}},w9(e,l)}let u=yield*l9(e,[r.hostId,r.instanceId],new Date(s.getTime()+hI(C7))),d={...l,pending:null,retireAt:[...n.retireAt,...u]};return w9(e,d),yield*QU({try:()=>{let t=o(e.directory,`id_ed25519`);ge(t,{force:!0}),ge(`${t}.pub`,{force:!0})},catch:e=>new $({step:`run-key-cleanup`,message:`cannot remove the run key after confirming the VM absent: ${String(e)}`})}),{...d,stopped:c}}),N9=X.check(o4(/^[a-z0-9][a-z0-9-]{0,47}$/)).pipe(Y2(`TeamMacRunName`)),P9=X.check(o4(/^h-[0-9a-f]{8,17}$/)).pipe(Y2(`TeamMacHostId`)),F9=X.check(o4(/^[1-9][0-9]*(s|m|h)$/)).pipe(Y2(`DurationText`)),I9=e=>{let t=Number(e.slice(0,-1)),n=e.slice(-1);return n===`h`?mI(t):n===`m`?pI(t):fI(t)},L9=g4,R9={profile:L9,region:L9,otFleet:M2(L9)},fue=Z(R9),pue=Z({...R9,directory:L9}),mue=Z({...R9,directory:L9,run:N9,owner:L9,vm:M2(N9),need:F9,within:F9,host:M2(P9),noAllocate:B2,family:L9,hostMacos:L9}),hue=Z({...R9,directory:L9,host:P9,run:N9,adopt:B2,within:F9}),gue=Z({...R9,directory:L9,host:P9,run:N9,owner:L9,need:F9,within:F9}),z9=(e,t)=>{for(let n of(t??``).split(r)){if(n===``)continue;let t=o(n,e);try{return S(t,C.X_OK),t}catch{continue}}},B9=e=>e instanceof Y7?e.reason:e instanceof $||e instanceof J7?`${e.step}: ${e.message}`:String(e),V9=Y(function*(e,t,n){let r=t.otFleet??n.otFleet;if(r===void 0)return yield*new v7({field:`otFleet`,message:`no ot-fleet helper was given, and this entry has no default: pass the use-cloud-vms skill's scripts/ot-fleet`});let i={aws:z9(`aws`,e.PATH),ssh:z9(`ssh`,e.PATH),sshKeygen:z9(`ssh-keygen`,e.PATH)};for(let[e,t]of Object.entries(i))if(t===void 0)return yield*new $({step:`tools`,message:`no ${e} on PATH`});return{profile:t.profile,region:t.region,tools:{aws:i.aws??``,ssh:i.ssh??``,sshKeygen:i.sshKeygen??``,otFleet:r},env:Z7(e),directory:s(t.directory),poll:dI(Number(e.TEAM_MAC_POLL_MILLIS??`20000`))}}),_ue=(e,t,n)=>PW(G(()=>w(o(Se(),`team-mac-inventory-`))),r=>qU(function*(){let i=yield*V9(e,{...t,directory:r},n),a=yield*s9(i),o=yield*$7,s={};for(let e of a){let t=e.instances[0];if(t===void 0){s[e.id]={vms:null,error:`host has no instance to inspect`,hold:null,holdError:`host has no instance to inspect`};continue}if(t.state!==`running`){s[e.id]={vms:null,error:`not inspected: instance is ${t.state}`,hold:null,holdError:`not inspected: instance is ${t.state}`};continue}s[e.id]=yield*Ule(i,e).pipe(sW(e=>W({vms:null,error:B9(e),hold:null,holdError:B9(e)})))}return Ale(a,o,s)}),e=>G(()=>ge(e,{recursive:!0,force:!0}))),vue=Y(function*(e,t,n){let r=yield*V9(e,t,n);return yield*uue(r,{run:t.run,owner:t.owner,vm:t.vm??t.run,need:I9(t.need),within:I9(t.within),host:t.host,allocate:!t.noAllocate,family:t.family,hostMacos:t.hostMacos})}),yue=Y(function*(e,t,n){let r=yield*V9(e,t,n),i=fe(C9(r))?yield*T9(r):void 0,a=i!==void 0&&E2(Z({absent:F2(!0)}))(i.stopped)&&(i.hold===void 0||i.hold.released)&&!fe(o(r.directory,`id_ed25519`))&&!fe(o(r.directory,`id_ed25519.pub`))?void 0:i;if(a!==void 0&&(a.hold!==void 0||a.run!==t.run||a.host?.hostId!==t.host||a.pending!==null&&a.pending!==void 0))return yield*new $({step:`host-hold`,message:`finish stop for the run already recorded in this directory before requesting another hold`});let s=yield*$7,c=new Date(s.getTime()+hI(I9(t.within))),l=new Date(c.getTime()+hI(I9(t.need))),u=(yield*s9(r)).find(e=>e.id===t.host);if(u===void 0)return yield*new Y7({reason:`not a team pool Mac`,report:{hostId:t.host}});let f=I7(u,{now:s,guestMacosMajor:G7.macosMajor});if(!f.usable)return yield*new Y7({reason:f.reasons.join(`; `),report:{hostId:t.host}});let p=yield*E9(r,t.run),m=yield*g9(r,f.instance.id,c);r9(r,f.instance.id,m.line),e9(o(r.directory,`ssh_config`),V7({instanceId:f.instance.id,directory:r.directory,otFleet:r.tools.otFleet,...a?.vm===void 0||a.vm===null?{}:{vm:{name:a.vm.vm,ip:a.vm.ip}}}));let h=yield*l9(r,[u.id,f.instance.id],l),g=d(),_={schema:`openteammate.team-mac/run@1`,run:t.run,owner:t.owner,region:r.region,host:{hostId:u.id,instanceId:f.instance.id,zone:u.zone??null},vm:a?.vm??null,...a?.vmDeadlineEpochSeconds===void 0?{}:{vmDeadlineEpochSeconds:a.vmDeadlineEpochSeconds},pending:null,attempts:a?.attempts??[],allocated:a?.allocated??null,prepared:a?.prepared??null,retireAt:[...a?.retireAt??[],...h],stopped:null,hold:{owner:p,attempt:g,deadlineEpochSeconds:Math.floor(l.getTime()/1e3),released:!1}};w9(r,_);let v=yield*y9(r,`host-hold-${g}`,`host-hold.sh`,[`hold`,t.run,p,String(Math.floor(l.getTime()/1e3)),g],I9(t.within)).pipe(q(e=>o9(x9,`host-hold`,e)));if(v.outcome!==`held`)return yield*new Y7({reason:v.reason??`the host hold was refused`,report:{hostId:u.id}});let y=yield*T9(r);return y.hold?.attempt!==g||y.hold.released||y.stopped!==null?yield*new Y7({reason:`this host hold was stopped or replaced while acquisition was in progress`,report:{hostId:u.id}}):y}),bue=Y(function*(e,t,n){let r=yield*V9(e,t,n),i=(yield*s9(r)).find(e=>e.id===t.host),a=i?.instances[0];if(i===void 0||a===void 0)return yield*new $({step:`prepare`,message:`${t.host} is not a team pool Mac with an instance`});if(!t.adopt&&i.tags[T7.run]!==t.run)return yield*new $({step:`prepare`,message:`${i.id} belongs to run ${i.tags[T7.run]??`(no ot-run tag)`}, not ${t.run}: prepare only a Mac your run allocated`});if(!t.adopt&&i.tags[T7.ready]===`true`)return yield*new $({step:`prepare`,message:`${i.id} is already prepared (ot-ready=true) and runs may be using it: start reuses it as it is`});let o=new Date((yield*JH)+hI(I9(t.within))),s=yield*_9(r,{hostId:i.id,instanceId:a.id},o);return{hostId:i.id,instanceId:a.id,prepared:s}}),xue=Y(function*(e,t,n){let r=yield*V9(e,t,n);return yield*due(r)});var H9=class e extends $P()(`@openteammate/offload/Compute`){static local=(t,n)=>yH(e,qU(function*(){let r=yield*g7;return e.of({"team-mac.hold":e=>yue(t,e,n).pipe(kW(g7,r)),"team-mac.inventory":e=>_ue(t,e,n).pipe(kW(g7,r)),"team-mac.start":e=>vue(t,e,n).pipe(kW(g7,r)),"team-mac.prepare":e=>bue(t,e,n).pipe(kW(g7,r)),"team-mac.stop":e=>xue(t,e,n).pipe(kW(g7,r))})}))};const Sue=(e,t)=>qU(function*(){return yield*(yield*H9)[e](t)}),U9=(e,t)=>({name:e,...t,error:G2([v7,...t.errors])}),W9={profile:{flag:`profile`,description:`The AWS profile for the team's agent role (role_arn plus source_profile openteammate-team, session name <teammate>@<lane>)`},region:{flag:`region`,description:`The pool's region`,default:b7},otFleet:{flag:`ot-fleet`,description:`The use-cloud-vms skill's ot-fleet helper`,optional:!0}},G9={flag:`dir`,description:`This run's private directory outside the repository: run key, known_hosts, ssh_config, record.json and step records`},K9={"team-mac.inventory":U9(`team-mac.inventory`,{description:`List the team's pool Macs, say which can take a run's VM and why not, and name expired Macs that are still allocated. Read-only`,kind:`query`,payload:fue,success:kle,errors:[$,J7],cli:{command:[`team-mac`,`inventory`],flags:W9}}),"team-mac.start":U9(`team-mac.start`,{description:`Start this run's macOS VM on a team pool Mac: a compatible ready Mac with room, else a Mac this run allocates and prepares. Admits the VM only when its guest answers over SSH; reaches the Mac as ${S7} with the team credential`,kind:`mutation`,payload:mue,success:S9,errors:[Y7,$,J7],cli:{command:[`team-mac`,`start`],flags:{...W9,directory:G9,run:{flag:`run`,description:`This run's unique name: lowercase letters, digits and hyphens; the ot-run tag of any Mac it allocates`},owner:{flag:`owner`,description:`Your handle, for the ot-owner tag`},vm:{flag:`vm`,description:`The VM's name on the Mac (default: the run name)`,optional:!0},need:{flag:`need`,description:`How long the run will use the VM, such as 90m or 3h; before the VM starts, the Mac's ot-retire-at is moved to no earlier than the --within deadline plus this`},within:{flag:`within`,description:`The controller's acquisition budget for allocating, preparing and booting, such as 30m or 2h; remote work can outlive it`},host:{flag:`host`,description:`Use this pool Mac only; no other Mac, no allocation`,optional:!0},noAllocate:{flag:`no-allocate`,description:`Reuse a pool Mac only; report instead of allocating one`,default:!1},family:{flag:`family`,description:`Mac host family to allocate`,default:`mac-m4`},hostMacos:{flag:`host-macos`,description:`macOS major version for a Mac this run allocates`,default:`27`}}}}),"team-mac.hold":U9(`team-mac.hold`,{description:`Hold a ready pool Mac for this run alone until --within plus --need expires. Refuses VMs owned by other runs. Stop releases the hold; start from the same --dir may use it`,kind:`mutation`,payload:gue,success:S9,errors:[Y7,$,J7],cli:{command:[`team-mac`,`hold`],flags:{...W9,directory:G9,host:{flag:`host`,description:`The ready pool Mac to hold`},run:{flag:`run`,description:`This run's unique name: lowercase letters, digits and hyphens`},owner:{flag:`owner`,description:`Your handle`},need:{flag:`need`,description:`How long the run needs the host alone, such as 3h`},within:{flag:`within`,description:`Acquisition budget, such as 10m; the hold expires at this deadline plus --need`}}}}),"team-mac.prepare":U9(`team-mac.prepare`,{description:`Prepare a pool Mac this run allocated whose preparation did not finish, over Run Command: the c-team login user with auto-login, SSH host keys, Lume, the base image and the start probe; then publish ot-ready. Refuses another run's Mac and a Mac already ready, unless an administrator passes --adopt`,kind:`mutation`,payload:hue,success:Ble,errors:[Y7,$,J7],cli:{command:[`team-mac`,`prepare`],flags:{...W9,directory:G9,host:{flag:`host`,description:`The pool Mac this run allocated`},run:{flag:`run`,description:`This run's name: the Mac's ot-run tag must be it`},adopt:{flag:`adopt`,description:`For the account's administrator only: prepare a Mac made outside team-mac, or prepare a ready Mac again (scripts/cloud-qa/pool/README.md)`,default:!1},within:{flag:`within`,description:`Bound for preparing, such as 30m`}}}}),"team-mac.stop":U9(`team-mac.stop`,{description:`Stop and delete this run's VM, confirm it absent, and move the Mac's ot-retire-at to no earlier than now plus the keep-warm window`,kind:`mutation`,payload:pue,success:S9,errors:[Y7,$,J7],cli:{command:[`team-mac`,`stop`],flags:{...W9,directory:G9}}})},Cue=e=>wX(hQ(e.ast)),wue=e=>TX(hQ(e.ast)),Tue=(e,t,n,r)=>{if(wue(n))return U8(r.flag).pipe(K8(r.description),X8(n));if(Cue(n))return Ose(r.flag).pipe(K8(r.description),X8(n));throw Error(`${e}: payload field ${t} is neither text nor a switch, so it has no flag`)},Eue=(e,t,n,r)=>{let i=Tue(e,t,n,r);return r.optional===!0?J8(i):r.default===void 0?i:i.pipe(Y8(r.default))},Due=e=>Object.fromEntries(Object.entries(e).flatMap(([e,t])=>die(t)?KP(t,{onNone:()=>[],onSome:t=>[[e,t]]}):[[e,t]])),q9=(e,t)=>{if(Array.isArray(t))return t.map((t,n)=>q9(Array.isArray(e)?e[n]:void 0,t));if(!dM(t))return t;let n=dM(e)?e:{},r=[...Object.keys(n).filter(e=>Object.hasOwn(t,e)),...Object.keys(t).filter(e=>!Object.hasOwn(n,e))];return Object.fromEntries(r.map(e=>[e,q9(n[e],t[e])]))},Oue=e=>{let[t]=ZJ()(e.issue).issues,n=t?.path?.[0];return new v7({field:typeof n==`string`?n:`payload`,message:t?.message??e.message})},J9=(e,t,n,r)=>{let i=K9[e],a=i.cli.flags,o=r,s=Object.fromEntries(Object.entries(i.payload.fields).map(([t,n])=>{let r=a[t];if(r===void 0)throw Error(`${e}: payload field ${t} has no flag hint`);let i=o[t],s=i===void 0?r:{...r,description:`${r.description} (${i})`};return[t,Eue(e,t,n,s)]})),c=e=>{let t=a[e];return t===void 0?e:`--${t.flag}`};return j5(i.cli.command[1],s,r=>qU(function*(){let a=yield*D2(P2(i.payload))(Due(r),{onExcessProperty:`error`}).pipe(pW(Oue)),o=yield*Sue(e,a),s=yield*k2(i.success)(o).pipe(mW);t.out(JSON.stringify(q9(o,s),null,2)+`
|
|
590
|
+
`);let c=n[e];c!==void 0&&t.err(c(o,a))}).pipe(cW(`InvalidInput`,e=>K(new v7({field:c(e.field),message:e.message}))))).pipe(M5(i.description))},kue=(e,t,n,r)=>Object.values(K9).filter(t=>t.cli.command[0]===e).map(e=>J9(e.name,t,n,r)),Y9={out:e=>process.stdout.write(e),err:e=>process.stderr.write(e)},Aue=()=>({version:`0.1.0`,defaults:{otFleet:Ee(new URL(`../../../.agents/skills/use-cloud-vms/scripts/ot-fleet`,import.meta.url))},notes:{otFleet:`default: this checkout's copy`}}),jue={"team-mac.inventory":e=>[...e.hosts.map(e=>{let t=`VMs unknown: ${e.vmInventoryError}`;if(e.vms!==null){let n=e.vms.filter(e=>e.state===`running`).length,r=e.vms.filter(e=>e.state===`stopped`).length,i=e.vms.length-n-r,a=e.vms.find(e=>e.isBaseImage);t=`${n} running, ${r} stopped${i===0?``:`, ${i} other state`}${a===void 0?``:`; base image: ${a.name} (${a.state})`}`}let n=e.holdInventoryError===null?e.hold===null?`no hold`:`hold for ${e.hold.run} until epoch ${e.hold.deadlineEpochSeconds}${e.hold.expired?` (expired)`:``}`:`hold unknown: ${e.holdInventoryError}`;return`${e.hostId} ${e.state} retire-at ${e.retireAt??`?`} ${e.usable?`usable`:`not usable: ${e.reasons.join(`; `)}`} ${t}; ${n}\n`}),...e.expiredStillAllocated.map(e=>`expired but still allocated: ${e.hostId} (retire-at ${e.retireAt??`?`}, ${e.state}); the administrator's sweep releases it once AWS allows, and it counts against the account's Mac host quota until then\n`)].join(``),"team-mac.start":(e,t)=>`VM ${e.vm?.vm??`?`} booted on ${e.host?.hostId??`?`} at ${e.vm?.ip??`?`}: ssh -F ${o(s(t.directory),`ssh_config`)} vm\n`,"team-mac.hold":e=>`Mac ${e.host?.hostId??`?`} held for ${e.run} until epoch ${e.hold?.deadlineEpochSeconds??`?`}; stop with the same --dir to release it\n`,"team-mac.stop":e=>{let t=O2(M9)(e.stopped),n=e.retireAt.at(-1)?.after??`unknown`;if(t.outcome===`hold-only`)return`Host hold for ${e.host?.hostId??`?`} released\n`;let r=t.outcome===`absent-already`?`already absent`:`deleted and confirmed absent`;return`VM ${t.vm??e.vm?.vm??`?`} ${r}; the Mac's ot-retire-at is ${n} (moved to no earlier than now plus ${Xie(C7)} hours), and the administrator's sweep retires the Mac once it passes\n`}},Mue=async(e,t=process.env,n=Y9,r=Aue())=>{let i=j5(`team-mac`).pipe(M5(`Team cloud Macs for a run: inventory, hold, start, prepare and stop`),gce(kue(`team-mac`,n,jue,r.notes))),a=await ZW(N5(i,{version:r.version})(e).pipe(EW(H9.local(t,r.defaults).pipe(TH(g7.layer.pipe(TH(G4)))))));if(AH(a))return Pj.done;let o=XP(MH(a));return o instanceof Y7?(n.out(JSON.stringify({blocked:!0,reason:o.reason,report:o.report},null,2)+`
|
|
591
|
+
`),n.err(`team-mac: blocked: ${o.reason}\n`),Pj.blocked):o instanceof $||o instanceof J7?(n.err(`team-mac: ${o.step}: ${o.message}\n`),Pj.failure):o instanceof v7?(n.err(`team-mac: ${o.field}: ${o.message}\n`),Pj.usage):o===void 0?(n.err(`team-mac: ${HH(a.cause)}\n`),Pj.failure):(n.err(`team-mac: ${String(o)}\n`),Pj.usage)},Nue=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*)?$/,X9=[26,10,0],Pue=X9.join(`.`),Fue=(e,t)=>{let n=Nue.exec(e);if(n===null||!t)return!1;let[,r,i,a,o]=n,s=Number(r)-X9[0]||Number(i)-X9[1]||Number(a)-X9[2];return s>0||s===0&&o===void 0},Z9=`Usage: impulse-compute <group> [arguments]
|
|
592
|
+
|
|
593
|
+
Groups:
|
|
594
|
+
team-mac Team cloud Macs for a run: inventory, hold, start, prepare and stop
|
|
595
|
+
linux-desktop A Linux desktop in an E2B guest or on this machine: sessions, apps,
|
|
596
|
+
captures and exact-crop checks
|
|
597
|
+
|
|
598
|
+
Options:
|
|
599
|
+
--version, -v Print this package's version
|
|
600
|
+
--help, -h Print this help
|
|
601
|
+
|
|
602
|
+
Run "impulse-compute <group> --help" for a group's commands.
|
|
603
|
+
`,[Q9,...$9]=process.argv.slice(2);Q9===`team-mac`&&!Fue(process.versions.node,process.execve!==void 0)?(process.stderr.write(`impulse-compute: team-mac needs Node ${Pue} or later, with process.execve; this is Node ${process.versions.node}${process.execve===void 0?`, without process.execve`:``}\n`),process.exitCode=Pj.failure):Q9===`team-mac`?process.exitCode=await Mue($9,process.env,Y9,{version:Re,defaults:{},notes:{}}):Q9===`linux-desktop`?Nj($9):Q9===`--version`||Q9===`-v`?process.stdout.write(`${Re}\n`):Q9===`--help`||Q9===`-h`?process.stdout.write(Z9):(process.stderr.write(Q9===void 0?Z9:`impulse-compute: unknown group ${Q9}\n\n${Z9}`),process.exitCode=Pj.usage);export{};
|
|
604
|
+
/*!
|
|
605
|
+
@bufbuild/protobuf@2.17.0 ((Apache-2.0 AND BSD-3-Clause), package.json)
|
|
606
|
+
|
|
607
|
+
@connectrpc/connect-web@2.3.0 (Apache-2.0, package.json)
|
|
608
|
+
|
|
609
|
+
@connectrpc/connect@2.3.0 (Apache-2.0, package.json)
|
|
610
|
+
|
|
611
|
+
@e2b/dockerfile-utils@0.1.1 (Apache-2.0, LICENSE)
|
|
612
|
+
Apache License
|
|
613
|
+
Version 2.0, January 2004
|
|
614
|
+
http://www.apache.org/licenses/
|
|
615
|
+
|
|
616
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
617
|
+
|
|
618
|
+
1. Definitions.
|
|
619
|
+
|
|
620
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
621
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
622
|
+
|
|
623
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
624
|
+
the copyright owner that is granting the License.
|
|
625
|
+
|
|
626
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
627
|
+
other entities that control, are controlled by, or are under common
|
|
628
|
+
control with that entity. For the purposes of this definition,
|
|
629
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
630
|
+
direction or management of such entity, whether by contract or
|
|
631
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
632
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
633
|
+
|
|
634
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
635
|
+
exercising permissions granted by this License.
|
|
636
|
+
|
|
637
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
638
|
+
including but not limited to software source code, documentation
|
|
639
|
+
source, and configuration files.
|
|
640
|
+
|
|
641
|
+
"Object" form shall mean any form resulting from mechanical
|
|
642
|
+
transformation or translation of a Source form, including but
|
|
643
|
+
not limited to compiled object code, generated documentation,
|
|
644
|
+
and conversions to other media types.
|
|
645
|
+
|
|
646
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
647
|
+
Object form, made available under the License, as indicated by a
|
|
648
|
+
copyright notice that is included in or attached to the work
|
|
649
|
+
(an example is provided in the Appendix below).
|
|
650
|
+
|
|
651
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
652
|
+
form, that is based on (or derived from) the Work and for which the
|
|
653
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
654
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
655
|
+
of this License, Derivative Works shall not include works that remain
|
|
656
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
657
|
+
the Work and Derivative Works thereof.
|
|
658
|
+
|
|
659
|
+
"Contribution" shall mean any work of authorship, including
|
|
660
|
+
the original version of the Work and any modifications or additions
|
|
661
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
662
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
663
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
664
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
665
|
+
means any form of electronic, verbal, or written communication sent
|
|
666
|
+
to the Licensor or its representatives, including but not limited to
|
|
667
|
+
communication on electronic mailing lists, source code control systems,
|
|
668
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
669
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
670
|
+
excluding communication that is conspicuously marked or otherwise
|
|
671
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
672
|
+
|
|
673
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
674
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
675
|
+
subsequently incorporated within the Work.
|
|
676
|
+
|
|
677
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
678
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
679
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
680
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
681
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
682
|
+
Work and such Derivative Works in Source or Object form.
|
|
683
|
+
|
|
684
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
685
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
686
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
687
|
+
(except as stated in this section) patent license to make, have made,
|
|
688
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
689
|
+
where such license applies only to those patent claims licensable
|
|
690
|
+
by such Contributor that are necessarily infringed by their
|
|
691
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
692
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
693
|
+
institute patent litigation against any entity (including a
|
|
694
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
695
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
696
|
+
or contributory patent infringement, then any patent licenses
|
|
697
|
+
granted to You under this License for that Work shall terminate
|
|
698
|
+
as of the date such litigation is filed.
|
|
699
|
+
|
|
700
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
701
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
702
|
+
modifications, and in Source or Object form, provided that You
|
|
703
|
+
meet the following conditions:
|
|
704
|
+
|
|
705
|
+
(a) You must give any other recipients of the Work or
|
|
706
|
+
Derivative Works a copy of this License; and
|
|
707
|
+
|
|
708
|
+
(b) You must cause any modified files to carry prominent notices
|
|
709
|
+
stating that You changed the files; and
|
|
710
|
+
|
|
711
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
712
|
+
that You distribute, all copyright, patent, trademark, and
|
|
713
|
+
attribution notices from the Source form of the Work,
|
|
714
|
+
excluding those notices that do not pertain to any part of
|
|
715
|
+
the Derivative Works; and
|
|
716
|
+
|
|
717
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
718
|
+
distribution, then any Derivative Works that You distribute must
|
|
719
|
+
include a readable copy of the attribution notices contained
|
|
720
|
+
within such NOTICE file, excluding those notices that do not
|
|
721
|
+
pertain to any part of the Derivative Works, in at least one
|
|
722
|
+
of the following places: within a NOTICE text file distributed
|
|
723
|
+
as part of the Derivative Works; within the Source form or
|
|
724
|
+
documentation, if provided along with the Derivative Works; or,
|
|
725
|
+
within a display generated by the Derivative Works, if and
|
|
726
|
+
wherever such third-party notices normally appear. The contents
|
|
727
|
+
of the NOTICE file are for informational purposes only and
|
|
728
|
+
do not modify the License. You may add Your own attribution
|
|
729
|
+
notices within Derivative Works that You distribute, alongside
|
|
730
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
731
|
+
that such additional attribution notices cannot be construed
|
|
732
|
+
as modifying the License.
|
|
733
|
+
|
|
734
|
+
You may add Your own copyright statement to Your modifications and
|
|
735
|
+
may provide additional or different license terms and conditions
|
|
736
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
737
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
738
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
739
|
+
the conditions stated in this License.
|
|
740
|
+
|
|
741
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
742
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
743
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
744
|
+
this License, without any additional terms or conditions.
|
|
745
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
746
|
+
the terms of any separate license agreement you may have executed
|
|
747
|
+
with Licensor regarding such Contributions.
|
|
748
|
+
|
|
749
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
750
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
751
|
+
except as required for reasonable and customary use in describing the
|
|
752
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
753
|
+
|
|
754
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
755
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
756
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
757
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
758
|
+
implied, including, without limitation, any warranties or conditions
|
|
759
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
760
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
761
|
+
appropriateness of using or redistributing the Work and assume any
|
|
762
|
+
risks associated with Your exercise of permissions under this License.
|
|
763
|
+
|
|
764
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
765
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
766
|
+
unless required by applicable law (such as deliberate and grossly
|
|
767
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
768
|
+
liable to You for damages, including any direct, indirect, special,
|
|
769
|
+
incidental, or consequential damages of any character arising as a
|
|
770
|
+
result of this License or out of the use or inability to use the
|
|
771
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
772
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
773
|
+
other commercial damages or losses), even if such Contributor
|
|
774
|
+
has been advised of the possibility of such damages.
|
|
775
|
+
|
|
776
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
777
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
778
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
779
|
+
or other liability obligations and/or rights consistent with this
|
|
780
|
+
License. However, in accepting such obligations, You may act only
|
|
781
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
782
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
783
|
+
defend, and hold each Contributor harmless for any liability
|
|
784
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
785
|
+
of your accepting any such warranty or additional liability.
|
|
786
|
+
|
|
787
|
+
END OF TERMS AND CONDITIONS
|
|
788
|
+
|
|
789
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
790
|
+
|
|
791
|
+
To apply the Apache License to your work, attach the following
|
|
792
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
793
|
+
replaced with your own identifying information. (Don't include
|
|
794
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
795
|
+
comment syntax for the file format. We also recommend that a
|
|
796
|
+
file or class name and description of purpose be included on the
|
|
797
|
+
same "printed page" as the copyright notice for easier
|
|
798
|
+
identification within third-party archives.
|
|
799
|
+
|
|
800
|
+
Copyright 2023 FoundryLabs, Inc.
|
|
801
|
+
|
|
802
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
803
|
+
you may not use this file except in compliance with the License.
|
|
804
|
+
You may obtain a copy of the License at
|
|
805
|
+
|
|
806
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
807
|
+
|
|
808
|
+
Unless required by applicable law or agreed to in writing, software
|
|
809
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
810
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
811
|
+
See the License for the specific language governing permissions and
|
|
812
|
+
limitations under the License.
|
|
813
|
+
|
|
814
|
+
|
|
815
|
+
@e2b/dockerfile-utils@0.1.1 (Apache-2.0, NOTICE)
|
|
816
|
+
E2B Dockerfile utils
|
|
817
|
+
Copyright 2025 FoundryLabs, Inc.
|
|
818
|
+
|
|
819
|
+
This product includes software derived from moby/buildkit
|
|
820
|
+
(https://github.com/moby/buildkit), licensed under the Apache License 2.0:
|
|
821
|
+
the Dockerfile parser and shell lexer are ported from frontend/dockerfile.
|
|
822
|
+
|
|
823
|
+
This product includes software derived from moby/patternmatcher
|
|
824
|
+
(https://github.com/moby/patternmatcher), licensed under the Apache License 2.0.
|
|
825
|
+
Copyright 2012-2017 Docker, Inc.
|
|
826
|
+
This product includes software developed at Docker, Inc. (https://www.docker.com).
|
|
827
|
+
|
|
828
|
+
|
|
829
|
+
@effect/platform-node-shared@4.1.2 (MIT, LICENSE)
|
|
830
|
+
MIT License
|
|
831
|
+
|
|
832
|
+
Copyright (c) 2023 Effectful Technologies Inc
|
|
833
|
+
|
|
834
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
835
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
836
|
+
in the Software without restriction, including without limitation the rights
|
|
837
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
838
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
839
|
+
furnished to do so, subject to the following conditions:
|
|
840
|
+
|
|
841
|
+
The above copyright notice and this permission notice shall be included in all
|
|
842
|
+
copies or substantial portions of the Software.
|
|
843
|
+
|
|
844
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
845
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
846
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
847
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
848
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
849
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
850
|
+
SOFTWARE.
|
|
851
|
+
|
|
852
|
+
|
|
853
|
+
@effect/platform-node@4.1.2 (MIT, LICENSE)
|
|
854
|
+
MIT License
|
|
855
|
+
|
|
856
|
+
Copyright (c) 2023 Effectful Technologies Inc
|
|
857
|
+
|
|
858
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
859
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
860
|
+
in the Software without restriction, including without limitation the rights
|
|
861
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
862
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
863
|
+
furnished to do so, subject to the following conditions:
|
|
864
|
+
|
|
865
|
+
The above copyright notice and this permission notice shall be included in all
|
|
866
|
+
copies or substantial portions of the Software.
|
|
867
|
+
|
|
868
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
869
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
870
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
871
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
872
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
873
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
874
|
+
SOFTWARE.
|
|
875
|
+
|
|
876
|
+
|
|
877
|
+
chalk@5.6.2 (MIT, license)
|
|
878
|
+
MIT License
|
|
879
|
+
|
|
880
|
+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
881
|
+
|
|
882
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
883
|
+
|
|
884
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
885
|
+
|
|
886
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
887
|
+
|
|
888
|
+
|
|
889
|
+
compare-versions@6.1.1 (MIT, LICENSE)
|
|
890
|
+
The MIT License (MIT)
|
|
891
|
+
|
|
892
|
+
Copyright (c) 2015-2021 Ole Michelsen
|
|
893
|
+
|
|
894
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
895
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
896
|
+
in the Software without restriction, including without limitation the rights
|
|
897
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
898
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
899
|
+
furnished to do so, subject to the following conditions:
|
|
900
|
+
|
|
901
|
+
The above copyright notice and this permission notice shall be included in all
|
|
902
|
+
copies or substantial portions of the Software.
|
|
903
|
+
|
|
904
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
905
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
906
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
907
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
908
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
909
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
910
|
+
SOFTWARE.
|
|
911
|
+
|
|
912
|
+
|
|
913
|
+
e2b@2.63.0 (MIT, LICENSE)
|
|
914
|
+
MIT License
|
|
915
|
+
|
|
916
|
+
Copyright (c) 2025 FOUNDRYLABS, INC.
|
|
917
|
+
|
|
918
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
919
|
+
|
|
920
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
921
|
+
|
|
922
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
923
|
+
|
|
924
|
+
effect@4.1.2 (MIT, LICENSE)
|
|
925
|
+
MIT License
|
|
926
|
+
|
|
927
|
+
Copyright (c) 2023 Effectful Technologies Inc
|
|
928
|
+
|
|
929
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
930
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
931
|
+
in the Software without restriction, including without limitation the rights
|
|
932
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
933
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
934
|
+
furnished to do so, subject to the following conditions:
|
|
935
|
+
|
|
936
|
+
The above copyright notice and this permission notice shall be included in all
|
|
937
|
+
copies or substantial portions of the Software.
|
|
938
|
+
|
|
939
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
940
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
941
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
942
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
943
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
944
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
945
|
+
SOFTWARE.
|
|
946
|
+
|
|
947
|
+
|
|
948
|
+
openapi-fetch@0.17.0 (MIT, LICENSE)
|
|
949
|
+
MIT License
|
|
950
|
+
|
|
951
|
+
Copyright (c) 2023 Drew Powers
|
|
952
|
+
|
|
953
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
954
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
955
|
+
in the Software without restriction, including without limitation the rights
|
|
956
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
957
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
958
|
+
furnished to do so, subject to the following conditions:
|
|
959
|
+
|
|
960
|
+
The above copyright notice and this permission notice shall be included in all
|
|
961
|
+
copies or substantial portions of the Software.
|
|
962
|
+
|
|
963
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
964
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
965
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
966
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
967
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
968
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
969
|
+
SOFTWARE.
|
|
970
|
+
|
|
971
|
+
|
|
972
|
+
platform@1.3.6 (MIT, LICENSE)
|
|
973
|
+
Copyright 2014-2020 Benjamin Tan
|
|
974
|
+
Copyright 2011-2013 John-David Dalton
|
|
975
|
+
|
|
976
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
977
|
+
a copy of this software and associated documentation files (the
|
|
978
|
+
"Software"), to deal in the Software without restriction, including
|
|
979
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
980
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
981
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
982
|
+
the following conditions:
|
|
983
|
+
|
|
984
|
+
The above copyright notice and this permission notice shall be
|
|
985
|
+
included in all copies or substantial portions of the Software.
|
|
986
|
+
|
|
987
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
988
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
989
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
990
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
991
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
992
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
993
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
994
|
+
|
|
995
|
+
|
|
996
|
+
pngjs@7.0.0 (MIT, LICENSE)
|
|
997
|
+
pngjs original work Copyright (c) 2015 Luke Page & Original Contributors
|
|
998
|
+
pngjs derived work Copyright (c) 2012 Kuba Niegowski
|
|
999
|
+
|
|
1000
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
1001
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
1002
|
+
in the Software without restriction, including without limitation the rights
|
|
1003
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
1004
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
1005
|
+
furnished to do so, subject to the following conditions:
|
|
1006
|
+
|
|
1007
|
+
The above copyright notice and this permission notice shall be included in
|
|
1008
|
+
all copies or substantial portions of the Software.
|
|
1009
|
+
|
|
1010
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
1011
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
1012
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
1013
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
1014
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1015
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
1016
|
+
THE SOFTWARE.
|
|
1017
|
+
|
|
1018
|
+
|
|
1019
|
+
@effect/platform-node-shared@4.0.7 (MIT, LICENSE)
|
|
1020
|
+
MIT License
|
|
1021
|
+
|
|
1022
|
+
Copyright (c) 2023 Effectful Technologies Inc
|
|
1023
|
+
|
|
1024
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
1025
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
1026
|
+
in the Software without restriction, including without limitation the rights
|
|
1027
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
1028
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
1029
|
+
furnished to do so, subject to the following conditions:
|
|
1030
|
+
|
|
1031
|
+
The above copyright notice and this permission notice shall be included in all
|
|
1032
|
+
copies or substantial portions of the Software.
|
|
1033
|
+
|
|
1034
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
1035
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
1036
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
1037
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
1038
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1039
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1040
|
+
SOFTWARE.
|
|
1041
|
+
|
|
1042
|
+
|
|
1043
|
+
@effect/platform-node@4.0.7 (MIT, LICENSE)
|
|
1044
|
+
MIT License
|
|
1045
|
+
|
|
1046
|
+
Copyright (c) 2023 Effectful Technologies Inc
|
|
1047
|
+
|
|
1048
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
1049
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
1050
|
+
in the Software without restriction, including without limitation the rights
|
|
1051
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
1052
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
1053
|
+
furnished to do so, subject to the following conditions:
|
|
1054
|
+
|
|
1055
|
+
The above copyright notice and this permission notice shall be included in all
|
|
1056
|
+
copies or substantial portions of the Software.
|
|
1057
|
+
|
|
1058
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
1059
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
1060
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
1061
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
1062
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1063
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1064
|
+
SOFTWARE.
|
|
1065
|
+
|
|
1066
|
+
|
|
1067
|
+
@inkeep/impulse-owned-process@0.2.0 (UNLICENSED, package.json)
|
|
1068
|
+
|
|
1069
|
+
effect@4.0.7 (MIT, LICENSE)
|
|
1070
|
+
MIT License
|
|
1071
|
+
|
|
1072
|
+
Copyright (c) 2023 Effectful Technologies Inc
|
|
1073
|
+
|
|
1074
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
1075
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
1076
|
+
in the Software without restriction, including without limitation the rights
|
|
1077
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
1078
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
1079
|
+
furnished to do so, subject to the following conditions:
|
|
1080
|
+
|
|
1081
|
+
The above copyright notice and this permission notice shall be included in all
|
|
1082
|
+
copies or substantial portions of the Software.
|
|
1083
|
+
|
|
1084
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
1085
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
1086
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
1087
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
1088
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1089
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1090
|
+
SOFTWARE.
|
|
1091
|
+
|
|
1092
|
+
*/
|