@kaisers-io/refs 0.1.2 → 0.2.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/bin/refs.mjs +87 -395
- package/dist/refs.mjs +370 -0
- package/package.json +7 -6
package/bin/refs.mjs
CHANGED
|
@@ -1,404 +1,96 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{createRequire as e}from"node:module";import{access as t,chmod as n,constants as r,copyFile as i,lstat as a,mkdir as o,readFile as s,readdir as c,realpath as l,rename as u,rm as d,rmdir as f,stat as p,writeFile as m}from"node:fs/promises";import h,{basename as g,dirname as _,isAbsolute as v,join as y,relative as ee,resolve as te,sep as ne}from"node:path";import{randomUUID as re}from"node:crypto";import ie,{appendFileSync as ae,createReadStream as oe,createWriteStream as se,existsSync as ce,readFileSync as le,realpathSync as ue,statSync as de,writeFileSync as fe}from"node:fs";import{constants as pe,homedir as me}from"node:os";import{scheduler as he,setImmediate as ge,setTimeout as _e}from"node:timers/promises";import{fileURLToPath as ve}from"node:url";import ye,{ChildProcess as be,execFile as xe,spawn as Se,spawnSync as Ce}from"node:child_process";import{StringDecoder as we}from"node:string_decoder";import{aborted as Te,callbackify as Ee,debuglog as De,inspect as Oe,promisify as ke,stripVTControlCharacters as Ae}from"node:util";import b,{execArgv as je,execPath as Me,hrtime as Ne,platform as Pe}from"node:process";import Fe from"node:tty";import{EventEmitter as Ie,addAbortListener as Le,on as Re,once as x,setMaxListeners as ze}from"node:events";import{serialize as Be}from"node:v8";import{finished as Ve}from"node:stream/promises";import{Duplex as He,PassThrough as Ue,Readable as We,Transform as Ge,Writable as Ke,getDefaultHighWaterMark as qe}from"node:stream";import{Buffer as Je}from"node:buffer";var Ye=Object.create,Xe=Object.defineProperty,Ze=Object.getOwnPropertyDescriptor,Qe=Object.getOwnPropertyNames,$e=Object.getPrototypeOf,et=Object.prototype.hasOwnProperty,S=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),tt=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=Qe(t),a=0,o=i.length,s;a<o;a++)s=i[a],!et.call(e,s)&&s!==n&&Xe(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=Ze(t,s))||r.enumerable});return e},nt=(e,t,n)=>(n=e==null?{}:Ye($e(e)),tt(t||!e||!e.__esModule?Xe(n,`default`,{value:e,enumerable:!0}):n,e)),rt=e(import.meta.url);const it={CONFLICT:5,NOT_FOUND:4,OK:0,UNEXPECTED:1,USAGE:2,VALIDATION:3};var at=class extends Error{code;exitCode;constructor(e,t,n,r){super(n,r),this.code=t,this.exitCode=e,this.name=`RefsError`}};const ot=e=>new at(it.CONFLICT,`conflict`,e),C=e=>new at(it.NOT_FOUND,`not_found`,e),w=e=>new at(it.USAGE,`usage`,e),T=e=>new at(it.VALIDATION,`validation`,e),st=(e,t,n)=>n&&t!==void 0?`${e}\n${t}`:e,ct=(e,t)=>e instanceof at?{code:e.code,exitCode:e.exitCode,message:st(e.message,e.stack,t.verbose)}:e instanceof Error?{code:`unexpected`,exitCode:it.UNEXPECTED,message:st(e.message,e.stack,t.verbose)}:{code:`unexpected`,exitCode:it.UNEXPECTED,message:String(e)};var lt;function E(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var ut=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},dt=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(lt=globalThis).__zod_globalConfig??(lt.__zod_globalConfig={});const ft=globalThis.__zod_globalConfig;function pt(e){return e&&Object.assign(ft,e),ft}function mt(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function ht(e,t){return typeof t==`bigint`?t.toString():t}function gt(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}function _t(e){return e==null}function vt(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function yt(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}const bt=Symbol(`evaluating`);function D(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==bt)return r===void 0&&(r=bt,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function xt(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function St(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Ct(e){return JSON.stringify(e)}function wt(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}const Tt=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Et(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const Dt=gt(()=>{if(ft.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Ot(e){if(Et(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(Et(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function kt(e){return Ot(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const At=new Set([`string`,`number`,`symbol`]);function jt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Mt(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function O(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Nt(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}const Pt={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Ft(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return Mt(e,St(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return xt(this,`shape`,e),e},checks:[]}))}function It(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return Mt(e,St(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return xt(this,`shape`,r),r},checks:[]}))}function Lt(e,t){if(!Ot(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Mt(e,St(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return xt(this,`shape`,n),n}}))}function Rt(e,t){if(!Ot(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Mt(e,St(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return xt(this,`shape`,n),n}}))}function zt(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return Mt(e,St(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return xt(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Bt(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return Mt(t,St(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return xt(this,`shape`,i),i},checks:[]}))}function Vt(e,t,n){return Mt(t,St(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return xt(this,`shape`,i),i}}))}function Ht(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Ut(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Wt(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Gt(e){return typeof e==`string`?e:e?.message}function Kt(e,t,n){let r=e.message?e.message:Gt(e.inst?._zod.def?.error?.(e))??Gt(t?.error?.(e))??Gt(n.customError?.(e))??Gt(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function qt(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Jt(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}const Yt=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,ht,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Xt=E(`$ZodError`,Yt),Zt=E(`$ZodError`,Yt,{Parent:Error});function Qt(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function $t(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}function en(e){let t=[],n=e.map(e=>typeof e==`object`?e.key:e);for(let e of n)typeof e==`number`?t.push(`[${e}]`):typeof e==`symbol`?t.push(`[${JSON.stringify(String(e))}]`):/[^\w$]/.test(e)?t.push(`[${JSON.stringify(e)}]`):(t.length&&t.push(`.`),t.push(e));return t.join(``)}function k(e){let t=[],n=[...e.issues].sort((e,t)=>(e.path??[]).length-(t.path??[]).length);for(let e of n)t.push(`✖ ${e.message}`),e.path?.length&&t.push(` → at ${en(e.path)}`);return t.join(`
|
|
3
|
-
`)}const tn=e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new ut;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>Kt(e,a,pt())));throw Tt(t,i?.callee),t}return o.value},nn=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>Kt(e,a,pt())));throw Tt(t,i?.callee),t}return o.value},rn=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new ut;return a.issues.length?{success:!1,error:new(e??Xt)(a.issues.map(e=>Kt(e,i,pt())))}:{success:!0,data:a.value}},an=rn(Zt),on=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>Kt(e,i,pt())))}:{success:!0,data:a.value}},sn=on(Zt),cn=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return tn(e)(t,n,i)},ln=e=>(t,n,r)=>tn(e)(t,n,r),un=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return nn(e)(t,n,i)},dn=e=>async(t,n,r)=>nn(e)(t,n,r),fn=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return rn(e)(t,n,i)},pn=e=>(t,n,r)=>rn(e)(t,n,r),mn=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return on(e)(t,n,i)},hn=e=>async(t,n,r)=>on(e)(t,n,r),gn=/^[cC][0-9a-z]{6,}$/,_n=/^[0-9a-z]+$/,vn=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,yn=/^[0-9a-vA-V]{20}$/,bn=/^[A-Za-z0-9]{27}$/,xn=/^[a-zA-Z0-9_-]{21}$/,Sn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Cn=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,wn=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Tn=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function En(){return RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)}const Dn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,On=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,kn=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,An=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,jn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Mn=/^[A-Za-z0-9_-]*$/,Nn=/^https?$/,Pn=/^\+[1-9]\d{6,14}$/,Fn=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,In=RegExp(`^${Fn}$`);function Ln(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Rn(e){return RegExp(`^${Ln(e)}$`)}function zn(e){let t=Ln({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${Fn}T(?:${r})$`)}const Bn=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},Vn=/^-?\d+$/,Hn=/^-?\d+(?:\.\d+)?$/,Un=/^[^A-Z]*$/,Wn=/^[^a-z]*$/,A=E(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Gn={number:`number`,bigint:`bigint`,object:`date`},Kn=E(`$ZodCheckLessThan`,(e,t)=>{A.init(e,t);let n=Gn[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),qn=E(`$ZodCheckGreaterThan`,(e,t)=>{A.init(e,t);let n=Gn[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Jn=E(`$ZodCheckMultipleOf`,(e,t)=>{A.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):yt(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Yn=E(`$ZodCheckNumberFormat`,(e,t)=>{A.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Pt[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=Vn)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),Xn=E(`$ZodCheckMaxLength`,(e,t)=>{var n;A.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!_t(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=qt(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Zn=E(`$ZodCheckMinLength`,(e,t)=>{var n;A.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!_t(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=qt(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Qn=E(`$ZodCheckLengthEquals`,(e,t)=>{var n;A.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!_t(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=qt(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),$n=E(`$ZodCheckStringFormat`,(e,t)=>{var n,r;A.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),er=E(`$ZodCheckRegex`,(e,t)=>{$n.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),tr=E(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Un,$n.init(e,t)}),nr=E(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Wn,$n.init(e,t)}),rr=E(`$ZodCheckIncludes`,(e,t)=>{A.init(e,t);let n=jt(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),ir=E(`$ZodCheckStartsWith`,(e,t)=>{A.init(e,t);let n=RegExp(`^${jt(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),ar=E(`$ZodCheckEndsWith`,(e,t)=>{A.init(e,t);let n=RegExp(`.*${jt(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),or=E(`$ZodCheckOverwrite`,(e,t)=>{A.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var sr=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
...iss,
|
|
10
|
-
path: iss.path ? [${o}, ...iss.path] : [${o}]
|
|
11
|
-
})));
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (${n}.value === undefined) {
|
|
16
|
-
if (${o} in input) {
|
|
17
|
-
newResult[${o}] = undefined;
|
|
18
|
-
}
|
|
19
|
-
} else {
|
|
20
|
-
newResult[${o}] = ${n}.value;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
`):c?t.write(`
|
|
24
|
-
if (${n}.issues.length) {
|
|
25
|
-
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
26
|
-
...iss,
|
|
27
|
-
path: iss.path ? [${o}, ...iss.path] : [${o}]
|
|
28
|
-
})));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (${n}.value === undefined) {
|
|
32
|
-
if (${o} in input) {
|
|
33
|
-
newResult[${o}] = undefined;
|
|
34
|
-
}
|
|
35
|
-
} else {
|
|
36
|
-
newResult[${o}] = ${n}.value;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
`):t.write(`
|
|
40
|
-
const ${n}_present = ${o} in input;
|
|
41
|
-
if (${n}.issues.length) {
|
|
42
|
-
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
43
|
-
...iss,
|
|
44
|
-
path: iss.path ? [${o}, ...iss.path] : [${o}]
|
|
45
|
-
})));
|
|
46
|
-
}
|
|
47
|
-
if (!${n}_present && !${n}.issues.length) {
|
|
48
|
-
payload.issues.push({
|
|
49
|
-
code: "invalid_type",
|
|
50
|
-
expected: "nonoptional",
|
|
51
|
-
input: undefined,
|
|
52
|
-
path: [${o}]
|
|
53
|
-
});
|
|
54
|
-
}
|
|
2
|
+
// Committed stub — the published/linked `refs` executable. The real CLI is the tsdown
|
|
3
|
+
// bundle at ../dist/refs.mjs (gitignored build output; `pnpm build` produces it). This
|
|
4
|
+
// file exists so the bin path is always valid: a fresh clone gets an actionable message
|
|
5
|
+
// instead of a broken symlink and a shell-level "command not found".
|
|
6
|
+
import { existsSync } from 'node:fs';
|
|
7
|
+
import { join } from 'node:path';
|
|
8
|
+
import { pathToFileURL } from 'node:url';
|
|
55
9
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
newResult[${o}] = ${n}.value;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
10
|
+
const REQUIRED_NODE_MAJOR = 24;
|
|
11
|
+
const REQUIRED_NODE_MINOR_MIN = 12;
|
|
12
|
+
const EXIT_FAILURE = 1;
|
|
13
|
+
const FALLBACK_VERSION_PART = 0;
|
|
63
14
|
|
|
64
|
-
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=Et,s=!ft.jitless,c=s&&Dt.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?Wr([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function qr(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Ht(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Kt(e,r,pt())))}),t)}const Jr=E(`$ZodUnion`,(e,t)=>{j.init(e,t),D(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),D(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),D(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),D(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>vt(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>qr(t,r,e,i)):qr(o,r,e,i)}}),Yr=E(`$ZodIntersection`,(e,t)=>{j.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Zr(e,t,n)):Zr(e,i,a)}});function Xr(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Ot(e)&&Ot(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Xr(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Xr(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Zr(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),Ht(e))return e;let o=Xr(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const Qr=E(`$ZodRecord`,(e,t)=>{j.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Ot(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let c of o)if(typeof c==`string`||typeof c==`number`||typeof c==`symbol`){s.add(typeof c==`number`?c.toString():c);let o=t.keyType._zod.run({value:c,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>Kt(e,r,pt())),input:c,path:[c],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[c],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...Wt(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...Wt(c,u.issues)),n.value[l]=u.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&Hn.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>Kt(e,r,pt())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...Wt(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...Wt(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),$r=E(`$ZodEnum`,(e,t)=>{j.init(e,t);let n=mt(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>At.has(typeof e)).map(e=>typeof e==`string`?jt(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),ei=E(`$ZodTransform`,(e,t)=>{j.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new dt(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new ut;return n.value=i,n.fallback=!0,n}});function ti(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const ni=E(`$ZodOptional`,(e,t)=>{j.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,D(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),D(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${vt(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>ti(e,r)):ti(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),ri=E(`$ZodExactOptional`,(e,t)=>{ni.init(e,t),D(e._zod,`values`,()=>t.innerType._zod.values),D(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),ii=E(`$ZodNullable`,(e,t)=>{j.init(e,t),D(e._zod,`optin`,()=>t.innerType._zod.optin),D(e._zod,`optout`,()=>t.innerType._zod.optout),D(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${vt(e.source)}|null)$`):void 0}),D(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),ai=E(`$ZodDefault`,(e,t)=>{j.init(e,t),e._zod.optin=`optional`,D(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>oi(e,t)):oi(r,t)}});function oi(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const si=E(`$ZodPrefault`,(e,t)=>{j.init(e,t),e._zod.optin=`optional`,D(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),ci=E(`$ZodNonOptional`,(e,t)=>{j.init(e,t),D(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>li(t,e)):li(i,e)}});function li(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}const ui=E(`$ZodCatch`,(e,t)=>{j.init(e,t),e._zod.optin=`optional`,D(e._zod,`optout`,()=>t.innerType._zod.optout),D(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Kt(e,n,pt()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Kt(e,n,pt()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),di=E(`$ZodPipe`,(e,t)=>{j.init(e,t),D(e._zod,`values`,()=>t.in._zod.values),D(e._zod,`optin`,()=>t.in._zod.optin),D(e._zod,`optout`,()=>t.out._zod.optout),D(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>fi(e,t.in,n)):fi(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>fi(e,t.out,n)):fi(r,t.out,n)}});function fi(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}const pi=E(`$ZodPreprocess`,(e,t)=>{di.init(e,t)}),mi=E(`$ZodReadonly`,(e,t)=>{j.init(e,t),D(e._zod,`propValues`,()=>t.innerType._zod.propValues),D(e._zod,`values`,()=>t.innerType._zod.values),D(e._zod,`optin`,()=>t.innerType?._zod?.optin),D(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(hi):hi(r)}});function hi(e){return e.value=Object.freeze(e.value),e}const gi=E(`$ZodCustom`,(e,t)=>{A.init(e,t),j.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>_i(t,n,r,e));_i(i,n,r,e)}});function _i(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Jt(e))}}var vi,yi=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function bi(){return new yi}(vi=globalThis).__zod_globalRegistry??(vi.__zod_globalRegistry=bi());const xi=globalThis.__zod_globalRegistry;function Si(e,t){return new e({type:`string`,...O(t)})}function Ci(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...O(t)})}function wi(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...O(t)})}function Ti(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...O(t)})}function Ei(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...O(t)})}function Di(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...O(t)})}function Oi(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...O(t)})}function ki(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...O(t)})}function Ai(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...O(t)})}function ji(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...O(t)})}function Mi(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...O(t)})}function Ni(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...O(t)})}function Pi(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...O(t)})}function Fi(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...O(t)})}function Ii(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...O(t)})}function Li(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...O(t)})}function Ri(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...O(t)})}function zi(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...O(t)})}function Bi(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...O(t)})}function Vi(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...O(t)})}function Hi(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...O(t)})}function Ui(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...O(t)})}function Wi(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...O(t)})}function Gi(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...O(t)})}function Ki(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...O(t)})}function qi(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...O(t)})}function Ji(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...O(t)})}function Yi(e,t){return new e({type:`number`,checks:[],...O(t)})}function Xi(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...O(t)})}function Zi(e){return new e({type:`unknown`})}function Qi(e,t){return new e({type:`never`,...O(t)})}function $i(e,t){return new Kn({check:`less_than`,...O(t),value:e,inclusive:!1})}function ea(e,t){return new Kn({check:`less_than`,...O(t),value:e,inclusive:!0})}function ta(e,t){return new qn({check:`greater_than`,...O(t),value:e,inclusive:!1})}function na(e,t){return new qn({check:`greater_than`,...O(t),value:e,inclusive:!0})}function ra(e,t){return new Jn({check:`multiple_of`,...O(t),value:e})}function ia(e,t){return new Xn({check:`max_length`,...O(t),maximum:e})}function aa(e,t){return new Zn({check:`min_length`,...O(t),minimum:e})}function oa(e,t){return new Qn({check:`length_equals`,...O(t),length:e})}function sa(e,t){return new er({check:`string_format`,format:`regex`,...O(t),pattern:e})}function ca(e){return new tr({check:`string_format`,format:`lowercase`,...O(e)})}function la(e){return new nr({check:`string_format`,format:`uppercase`,...O(e)})}function ua(e,t){return new rr({check:`string_format`,format:`includes`,...O(t),includes:e})}function da(e,t){return new ir({check:`string_format`,format:`starts_with`,...O(t),prefix:e})}function fa(e,t){return new ar({check:`string_format`,format:`ends_with`,...O(t),suffix:e})}function pa(e){return new or({check:`overwrite`,tx:e})}function ma(e){return pa(t=>t.normalize(e))}function ha(){return pa(e=>e.trim())}function ga(){return pa(e=>e.toLowerCase())}function _a(){return pa(e=>e.toUpperCase())}function va(){return pa(e=>wt(e))}function ya(e,t,n){return new e({type:`array`,element:t,...O(n)})}function ba(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...O(n)})}function xa(e,t){let n=Sa(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Jt(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Jt(r))}},e(t.value,t)),t);return n}function Sa(e,t){let n=new A({check:`custom`,...O(t)});return n._zod.check=e,n}function Ca(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??xi,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function N(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,N(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&P(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function wa(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
15
|
+
// Node error codes a broken/un-installed source tree can realistically throw when the stub
|
|
16
|
+
// tries `await import(...)` on src/main.ts or src/context.ts: missing workspace deps (no
|
|
17
|
+
// `pnpm install`), TypeScript syntax Node's type stripping can't erase, or an extension Node
|
|
18
|
+
// refuses to load as a module.
|
|
19
|
+
const SOURCE_LOAD_ERROR_CODES = new Set([
|
|
20
|
+
'ERR_MODULE_NOT_FOUND',
|
|
21
|
+
'ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX',
|
|
22
|
+
'ERR_UNKNOWN_FILE_EXTENSION',
|
|
23
|
+
]);
|
|
65
24
|
|
|
66
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Ta(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Da(t,`input`,e.processors),output:Da(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function P(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return P(r.element,n);if(r.type===`set`)return P(r.valueType,n);if(r.type===`lazy`)return P(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return P(r.innerType,n);if(r.type===`intersection`)return P(r.left,n)||P(r.right,n);if(r.type===`record`||r.type===`map`)return P(r.keyType,n)||P(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:P(r.in,n)||P(r.out,n);if(r.type===`object`){for(let e in r.shape)if(P(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(P(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(P(e,n))return!0;return!!(r.rest&&P(r.rest,n))}return!1}const Ea=(e,t={})=>n=>{let r=Ca({...n,processors:t});return N(e,r),wa(r,e),Ta(r,e)},Da=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Ca({...i??{},target:a,io:t,processors:n});return N(e,o),wa(o,e),Ta(o,e)},Oa={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},ka=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Oa[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Aa=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},ja=(e,t,n,r)=>{n.not={}},Ma=(e,t,n,r)=>{let i=e._zod.def,a=mt(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Na=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Pa=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Fa=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=N(a.element,t,{...r,path:[...r.path,`items`]})},Ia=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=N(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=N(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},La=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>N(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Ra=(e,t,n,r)=>{let i=e._zod.def,a=N(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=N(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},za=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=N(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=N(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=N(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Ba=(e,t,n,r)=>{let i=e._zod.def,a=N(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Va=(e,t,n,r)=>{let i=e._zod.def;N(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ha=(e,t,n,r)=>{let i=e._zod.def;N(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Ua=(e,t,n,r)=>{let i=e._zod.def;N(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Wa=(e,t,n,r)=>{let i=e._zod.def;N(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Ga=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;N(o,t,r);let s=t.seen.get(e);s.ref=o},Ka=(e,t,n,r)=>{let i=e._zod.def;N(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},qa=(e,t,n,r)=>{let i=e._zod.def;N(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ja=E(`ZodISODateTime`,(e,t)=>{xr.init(e,t),R.init(e,t)});function Ya(e){return Gi(Ja,e)}const Xa=E(`ZodISODate`,(e,t)=>{Sr.init(e,t),R.init(e,t)});function Za(e){return Ki(Xa,e)}const Qa=E(`ZodISOTime`,(e,t)=>{Cr.init(e,t),R.init(e,t)});function $a(e){return qi(Qa,e)}const eo=E(`ZodISODuration`,(e,t)=>{wr.init(e,t),R.init(e,t)});function to(e){return Ji(eo,e)}const F=E(`ZodError`,(e,t)=>{Xt.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>$t(e,t)},flatten:{value:t=>Qt(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,ht,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,ht,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),no=tn(F),ro=nn(F),io=rn(F),ao=on(F),oo=cn(F),so=ln(F),co=un(F),lo=dn(F),uo=fn(F),fo=pn(F),po=mn(F),mo=hn(F),ho=new WeakMap;function go(e,t,n){let r=Object.getPrototypeOf(e),i=ho.get(r);if(i||(i=new Set,ho.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}const I=E(`ZodType`,(e,t)=>(j.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Da(e,`input`),output:Da(e,`output`)}}),e.toJSONSchema=Ea(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>no(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>io(e,t,n),e.parseAsync=async(t,n)=>ro(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>ao(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>oo(e,t,n),e.decode=(t,n)=>so(e,t,n),e.encodeAsync=async(t,n)=>co(e,t,n),e.decodeAsync=async(t,n)=>lo(e,t,n),e.safeEncode=(t,n)=>uo(e,t,n),e.safeDecode=(t,n)=>fo(e,t,n),e.safeEncodeAsync=async(t,n)=>po(e,t,n),e.safeDecodeAsync=async(t,n)=>mo(e,t,n),go(e,`ZodType`,{check(...e){let t=this.def;return this.clone(St(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Mt(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Ds(e,t))},superRefine(e,t){return this.check(Os(e,t))},overwrite(e){return this.check(pa(e))},optional(){return cs(this)},exactOptional(){return us(this)},nullable(){return fs(this)},nullish(){return cs(fs(this))},nonoptional(e){return vs(this,e)},array(){return qo(this)},or(e){return Qo([this,e])},and(e){return es(this,e)},transform(e){return Ss(this,os(e))},default(e){return ms(this,e)},prefault(e){return gs(this,e)},catch(e){return bs(this,e)},pipe(e){return Ss(this,e)},readonly(){return Ts(this)},describe(e){let t=this.clone();return xi.add(t,{description:e}),t},meta(...e){if(e.length===0)return xi.get(this);let t=this.clone();return xi.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return xi.get(e)?.description},configurable:!0}),e)),_o=E(`_ZodString`,(e,t)=>{lr.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ka(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,go(e,`_ZodString`,{regex(...e){return this.check(sa(...e))},includes(...e){return this.check(ua(...e))},startsWith(...e){return this.check(da(...e))},endsWith(...e){return this.check(fa(...e))},min(...e){return this.check(aa(...e))},max(...e){return this.check(ia(...e))},length(...e){return this.check(oa(...e))},nonempty(...e){return this.check(aa(1,...e))},lowercase(e){return this.check(ca(e))},uppercase(e){return this.check(la(e))},trim(){return this.check(ha())},normalize(...e){return this.check(ma(...e))},toLowerCase(){return this.check(ga())},toUpperCase(){return this.check(_a())},slugify(){return this.check(va())}})}),vo=E(`ZodString`,(e,t)=>{lr.init(e,t),_o.init(e,t),e.email=t=>e.check(Ci(yo,t)),e.url=t=>e.check(ki(So,t)),e.jwt=t=>e.check(Wi(Lo,t)),e.emoji=t=>e.check(Ai(Co,t)),e.guid=t=>e.check(wi(bo,t)),e.uuid=t=>e.check(Ti(xo,t)),e.uuidv4=t=>e.check(Ei(xo,t)),e.uuidv6=t=>e.check(Di(xo,t)),e.uuidv7=t=>e.check(Oi(xo,t)),e.nanoid=t=>e.check(ji(wo,t)),e.guid=t=>e.check(wi(bo,t)),e.cuid=t=>e.check(Mi(To,t)),e.cuid2=t=>e.check(Ni(Eo,t)),e.ulid=t=>e.check(Pi(Do,t)),e.base64=t=>e.check(Vi(Po,t)),e.base64url=t=>e.check(Hi(Fo,t)),e.xid=t=>e.check(Fi(Oo,t)),e.ksuid=t=>e.check(Ii(ko,t)),e.ipv4=t=>e.check(Li(Ao,t)),e.ipv6=t=>e.check(Ri(jo,t)),e.cidrv4=t=>e.check(zi(Mo,t)),e.cidrv6=t=>e.check(Bi(No,t)),e.e164=t=>e.check(Ui(Io,t)),e.datetime=t=>e.check(Ya(t)),e.date=t=>e.check(Za(t)),e.time=t=>e.check($a(t)),e.duration=t=>e.check(to(t))});function L(e){return Si(vo,e)}const R=E(`ZodStringFormat`,(e,t)=>{M.init(e,t),_o.init(e,t)}),yo=E(`ZodEmail`,(e,t)=>{fr.init(e,t),R.init(e,t)}),bo=E(`ZodGUID`,(e,t)=>{ur.init(e,t),R.init(e,t)}),xo=E(`ZodUUID`,(e,t)=>{dr.init(e,t),R.init(e,t)}),So=E(`ZodURL`,(e,t)=>{pr.init(e,t),R.init(e,t)}),Co=E(`ZodEmoji`,(e,t)=>{mr.init(e,t),R.init(e,t)}),wo=E(`ZodNanoID`,(e,t)=>{hr.init(e,t),R.init(e,t)}),To=E(`ZodCUID`,(e,t)=>{gr.init(e,t),R.init(e,t)}),Eo=E(`ZodCUID2`,(e,t)=>{_r.init(e,t),R.init(e,t)}),Do=E(`ZodULID`,(e,t)=>{vr.init(e,t),R.init(e,t)}),Oo=E(`ZodXID`,(e,t)=>{yr.init(e,t),R.init(e,t)}),ko=E(`ZodKSUID`,(e,t)=>{br.init(e,t),R.init(e,t)}),Ao=E(`ZodIPv4`,(e,t)=>{Tr.init(e,t),R.init(e,t)}),jo=E(`ZodIPv6`,(e,t)=>{Er.init(e,t),R.init(e,t)}),Mo=E(`ZodCIDRv4`,(e,t)=>{Dr.init(e,t),R.init(e,t)}),No=E(`ZodCIDRv6`,(e,t)=>{Or.init(e,t),R.init(e,t)}),Po=E(`ZodBase64`,(e,t)=>{Ar.init(e,t),R.init(e,t)}),Fo=E(`ZodBase64URL`,(e,t)=>{Mr.init(e,t),R.init(e,t)}),Io=E(`ZodE164`,(e,t)=>{Nr.init(e,t),R.init(e,t)}),Lo=E(`ZodJWT`,(e,t)=>{Fr.init(e,t),R.init(e,t)}),Ro=E(`ZodNumber`,(e,t)=>{Ir.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Aa(e,t,n,r),go(e,`ZodNumber`,{gt(e,t){return this.check(ta(e,t))},gte(e,t){return this.check(na(e,t))},min(e,t){return this.check(na(e,t))},lt(e,t){return this.check($i(e,t))},lte(e,t){return this.check(ea(e,t))},max(e,t){return this.check(ea(e,t))},int(e){return this.check(Vo(e))},safe(e){return this.check(Vo(e))},positive(e){return this.check(ta(0,e))},nonnegative(e){return this.check(na(0,e))},negative(e){return this.check($i(0,e))},nonpositive(e){return this.check(ea(0,e))},multipleOf(e,t){return this.check(ra(e,t))},step(e,t){return this.check(ra(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function zo(e){return Yi(Ro,e)}const Bo=E(`ZodNumberFormat`,(e,t)=>{Lr.init(e,t),Ro.init(e,t)});function Vo(e){return Xi(Bo,e)}const Ho=E(`ZodUnknown`,(e,t)=>{Rr.init(e,t),I.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Uo(){return Zi(Ho)}const Wo=E(`ZodNever`,(e,t)=>{zr.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ja(e,t,n,r)});function Go(e){return Qi(Wo,e)}const Ko=E(`ZodArray`,(e,t)=>{Vr.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fa(e,t,n,r),e.element=t.element,go(e,`ZodArray`,{min(e,t){return this.check(aa(e,t))},nonempty(e){return this.check(aa(1,e))},max(e,t){return this.check(ia(e,t))},length(e,t){return this.check(oa(e,t))},unwrap(){return this.element}})});function qo(e,t){return ya(Ko,e,t)}const Jo=E(`ZodObject`,(e,t)=>{Kr.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ia(e,t,n,r),D(e,`shape`,()=>t.shape),go(e,`ZodObject`,{keyof(){return is(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:Uo()})},loose(){return this.clone({...this._zod.def,catchall:Uo()})},strict(){return this.clone({...this._zod.def,catchall:Go()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return Lt(this,e)},safeExtend(e){return Rt(this,e)},merge(e){return zt(this,e)},pick(e){return Ft(this,e)},omit(e){return It(this,e)},partial(...e){return Bt(ss,this,e[0])},required(...e){return Vt(_s,this,e[0])}})});function Yo(e,t){return new Jo({type:`object`,shape:e,catchall:Go(),...O(t)})}function Xo(e,t){return new Jo({type:`object`,shape:e,catchall:Uo(),...O(t)})}const Zo=E(`ZodUnion`,(e,t)=>{Jr.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>La(e,t,n,r),e.options=t.options});function Qo(e,t){return new Zo({type:`union`,options:e,...O(t)})}const $o=E(`ZodIntersection`,(e,t)=>{Yr.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ra(e,t,n,r)});function es(e,t){return new $o({type:`intersection`,left:e,right:t})}const ts=E(`ZodRecord`,(e,t)=>{Qr.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>za(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function ns(e,t,n){return!t||!t._zod?new ts({type:`record`,keyType:L(),valueType:e,...O(t)}):new ts({type:`record`,keyType:e,valueType:t,...O(n)})}const rs=E(`ZodEnum`,(e,t)=>{$r.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ma(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new rs({...t,checks:[],...O(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new rs({...t,checks:[],...O(r),entries:i})}});function is(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new rs({type:`enum`,entries:n,...O(t)})}const as=E(`ZodTransform`,(e,t)=>{ei.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Pa(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new dt(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Jt(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Jt(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function os(e){return new as({type:`transform`,transform:e})}const ss=E(`ZodOptional`,(e,t)=>{ni.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function cs(e){return new ss({type:`optional`,innerType:e})}const ls=E(`ZodExactOptional`,(e,t)=>{ri.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function us(e){return new ls({type:`optional`,innerType:e})}const ds=E(`ZodNullable`,(e,t)=>{ii.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ba(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function fs(e){return new ds({type:`nullable`,innerType:e})}const ps=E(`ZodDefault`,(e,t)=>{ai.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ha(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ms(e,t){return new ps({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():kt(t)}})}const hs=E(`ZodPrefault`,(e,t)=>{si.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ua(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function gs(e,t){return new hs({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():kt(t)}})}const _s=E(`ZodNonOptional`,(e,t)=>{ci.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Va(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function vs(e,t){return new _s({type:`nonoptional`,innerType:e,...O(t)})}const ys=E(`ZodCatch`,(e,t)=>{ui.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wa(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function bs(e,t){return new ys({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const xs=E(`ZodPipe`,(e,t)=>{di.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ga(e,t,n,r),e.in=t.in,e.out=t.out});function Ss(e,t){return new xs({type:`pipe`,in:e,out:t})}const Cs=E(`ZodPreprocess`,(e,t)=>{xs.init(e,t),pi.init(e,t)}),ws=E(`ZodReadonly`,(e,t)=>{mi.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ka(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ts(e){return new ws({type:`readonly`,innerType:e})}const Es=E(`ZodCustom`,(e,t)=>{gi.init(e,t),I.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Na(e,t,n,r)});function Ds(e,t={}){return ba(Es,e,t)}function Os(e,t){return xa(e,t)}function ks(e,t){return new Cs({type:`pipe`,in:os(e),out:t})}const As=new Set([`__proto__`,`constructor`,`prototype`]),js=(e,t,n)=>ks((n,r)=>{if(typeof n==`object`&&n)for(let i of Reflect.ownKeys(n))(typeof i!=`string`||!e(i))&&r.addIssue({code:`custom`,message:t(String(i)),path:[String(i)]});return n},n),Ms=e=>e.length>=1&&!As.has(e),Ns=e=>js(Ms,()=>`package key must be non-empty and not "__proto__", "constructor", or "prototype"`,ns(L().min(1),e)),Ps=[`blobless`,`full`],Fs=[`ssh`,`https`],Is=/^(?!\.{1,2}$)[^/\\%:]+$/u,Ls=/^[a-z0-9][a-z0-9.-]*(?:_[1-9]\d{0,4})?$/u,Rs=/^(?<amount>[1-9]\d{0,3})(?<unit>[mhd])$/u,zs={d:864e5,h:36e5,m:6e4},Bs=e=>e!==``&&/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/u.test(e),Vs=e=>{let t=e.groups?.port;if(!t)return!0;let n=Number(t);return n>=1&&n<=65535},Hs=e=>{let t=e.match(/_(?<port>\d+)$/u);if(t&&!Vs(t))return!1;let n=e;return t&&(n=e.slice(0,e.length-t[0].length)),n.split(`.`).every(e=>Bs(e))},Us=L().refine(e=>{let[t,...n]=e.split(`/`);return t===void 0||n.length<2||!Ls.test(t)||!Hs(t)?!1:n.every(e=>Is.test(e))},`ref key must be host/path…/repo with safe, non-empty segments`).brand(),Ws=L().regex(Rs,`duration must be <n>m, <n>h, or <n>d`).brand(),Gs=e=>{let t=Rs.exec(e);if(t===null)throw Error(`invalid duration: ${e}`);let{amount:n,unit:r}=t.groups??{};if(!n||!r)throw Error(`invalid duration: ${e}`);return Number(n)*zs[r]},Ks=is(Ps),qs=is(Fs),Js=L().refine(e=>e.includes(`{version}`),`tag format must contain {version}`),Ys=L().refine(e=>{if(e===`.`)return!0;let t=e.split(`/`);return t.length>0&&t.every(e=>Is.test(e)&&e!==`.`)},`package path must be "." or a normalized relative path without traversal`),Xs={clone_mode:`blobless`,git_transport:`https`,sync_ttl:`1h`},Zs=Yo({clone_mode:Ks.default(Xs.clone_mode),git_transport:qs.default(Xs.git_transport),sync_ttl:Ws.default(Ws.parse(Xs.sync_ttl))}),Qs=Yo((e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.removeDefault().optional()])))(Zs.shape)),$s=Yo({description:L().min(1),path:Ys,tag_format:Js.optional()}),ec=Yo({default_branch:L().min(1),description:L().min(1),packages:Ns($s).optional(),tag_format:Js,url:L().min(1),...Qs.shape}),tc=Yo({meta:Xo({cli_version:L().min(1),schema_version:zo().int().positive()}),refs:js(e=>Us.safeParse(e).success,()=>`ref key must be host/path…/repo with safe, non-empty segments`,ns(L(),ec)).default({}),settings:Zs});
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
80
|
-
* may be used to endorse or promote products derived from this software without
|
|
81
|
-
* specific prior written permission.
|
|
82
|
-
*
|
|
83
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
84
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
85
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
86
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
87
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
88
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
89
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
90
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
91
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
92
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
93
|
-
*/
|
|
94
|
-
function nc(e,t){let n=e.slice(0,t).split(/\r\n|\n|\r/g);return[n.length,n.pop().length+1]}function rc(e,t,n){let r=e.split(/\r\n|\n|\r/g),i=``,a=(Math.log10(t+1)|0)+1;for(let e=t-1;e<=t+1;e++){let o=r[e-1];o&&(i+=e.toString().padEnd(a,` `),i+=`: `,i+=o,i+=`
|
|
95
|
-
`,e===t&&(i+=` `.repeat(a+n+2),i+=`^
|
|
96
|
-
`))}return i}var z=class extends Error{line;column;codeblock;constructor(e,t){let[n,r]=nc(t.toml,t.ptr),i=rc(t.toml,n,r);super(`Invalid TOML document: ${e}\n\n${i}`,t),this.line=n,this.column=r,this.codeblock=i}};
|
|
97
|
-
/*!
|
|
98
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
99
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
100
|
-
*
|
|
101
|
-
* Redistribution and use in source and binary forms, with or without
|
|
102
|
-
* modification, are permitted provided that the following conditions are met:
|
|
103
|
-
*
|
|
104
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
105
|
-
* list of conditions and the following disclaimer.
|
|
106
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
107
|
-
* this list of conditions and the following disclaimer in the
|
|
108
|
-
* documentation and/or other materials provided with the distribution.
|
|
109
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
110
|
-
* may be used to endorse or promote products derived from this software without
|
|
111
|
-
* specific prior written permission.
|
|
112
|
-
*
|
|
113
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
114
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
115
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
116
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
117
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
118
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
119
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
120
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
121
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
122
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
123
|
-
*/
|
|
124
|
-
function ic(e,t){let n=0;for(;e[t-++n]===`\\`;);return--n&&n%2}function ac(e,t=0,n=e.length){let r=e.indexOf(`
|
|
125
|
-
`,t);return e[r-1]===`\r`&&r--,r<=n?r:-1}function oc(e,t){for(let n=t;n<e.length;n++){let r=e[n];if(r===`
|
|
126
|
-
`)return n;if(r===`\r`&&e[n+1]===`
|
|
127
|
-
`)return n+1;if(r<` `&&r!==` `||r===``)throw new z(`control characters are not allowed in comments`,{toml:e,ptr:t})}return e.length}function sc(e,t,n,r){let i;for(;;){for(;(i=e[t])===` `||i===` `||!n&&(i===`
|
|
128
|
-
`||i===`\r`&&e[t+1]===`
|
|
129
|
-
`);)t++;if(r||i!==`#`)break;t=oc(e,t)}return t}function cc(e,t,n,r,i=!1){if(!r)return t=ac(e,t),t<0?e.length:t;for(let a=t;a<e.length;a++){let t=e[a];if(t===`#`)a=ac(e,a);else if(t===n)return a+1;else if(t===r||i&&(t===`
|
|
130
|
-
`||t===`\r`&&e[a+1]===`
|
|
131
|
-
`))return a}throw new z(`cannot find end of structure`,{toml:e,ptr:t})}function lc(e,t){let n=e[t],r=n===e[t+1]&&e[t+1]===e[t+2]?e.slice(t,t+3):n;t+=r.length-1;do t=e.indexOf(r,++t);while(t>-1&&n!==`'`&&ic(e,t));return t>-1&&(t+=r.length,r.length>1&&(e[t]===n&&t++,e[t]===n&&t++)),t}
|
|
132
|
-
/*!
|
|
133
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
134
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
135
|
-
*
|
|
136
|
-
* Redistribution and use in source and binary forms, with or without
|
|
137
|
-
* modification, are permitted provided that the following conditions are met:
|
|
138
|
-
*
|
|
139
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
140
|
-
* list of conditions and the following disclaimer.
|
|
141
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
142
|
-
* this list of conditions and the following disclaimer in the
|
|
143
|
-
* documentation and/or other materials provided with the distribution.
|
|
144
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
145
|
-
* may be used to endorse or promote products derived from this software without
|
|
146
|
-
* specific prior written permission.
|
|
147
|
-
*
|
|
148
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
149
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
150
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
151
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
152
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
153
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
154
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
155
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
156
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
157
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
158
|
-
*/
|
|
159
|
-
let uc=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;var dc=class e extends Date{#e=!1;#t=!1;#n=null;constructor(e){let t=!0,n=!0,r=`Z`;if(typeof e==`string`){let i=e.match(uc);i?(i[1]||(t=!1,e=`0000-01-01T${e}`),n=!!i[2],n&&e[10]===` `&&(e=e.replace(` `,`T`)),i[2]&&+i[2]>23?e=``:(r=i[3]||null,e=e.toUpperCase(),!r&&n&&(e+=`Z`))):e=``}super(e),isNaN(this.getTime())||(this.#e=t,this.#t=n,this.#n=r)}isDateTime(){return this.#e&&this.#t}isLocal(){return!this.#e||!this.#t||!this.#n}isDate(){return this.#e&&!this.#t}isTime(){return this.#t&&!this.#e}isValid(){return this.#e||this.#t}toISOString(){let e=super.toISOString();if(this.isDate())return e.slice(0,10);if(this.isTime())return e.slice(11,23);if(this.#n===null)return e.slice(0,-1);if(this.#n===`Z`)return e;let t=this.#n.slice(1,3)*60+ +this.#n.slice(4,6);return t=this.#n[0]===`-`?t:-t,new Date(this.getTime()-t*6e4).toISOString().slice(0,-1)+this.#n}static wrapAsOffsetDateTime(t,n=`Z`){let r=new e(t);return r.#n=n,r}static wrapAsLocalDateTime(t){let n=new e(t);return n.#n=null,n}static wrapAsLocalDate(t){let n=new e(t);return n.#t=!1,n.#n=null,n}static wrapAsLocalTime(t){let n=new e(t);return n.#e=!1,n.#n=null,n}};
|
|
160
|
-
/*!
|
|
161
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
162
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
163
|
-
*
|
|
164
|
-
* Redistribution and use in source and binary forms, with or without
|
|
165
|
-
* modification, are permitted provided that the following conditions are met:
|
|
166
|
-
*
|
|
167
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
168
|
-
* list of conditions and the following disclaimer.
|
|
169
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
170
|
-
* this list of conditions and the following disclaimer in the
|
|
171
|
-
* documentation and/or other materials provided with the distribution.
|
|
172
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
173
|
-
* may be used to endorse or promote products derived from this software without
|
|
174
|
-
* specific prior written permission.
|
|
175
|
-
*
|
|
176
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
177
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
178
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
179
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
180
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
181
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
182
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
183
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
184
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
185
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
186
|
-
*/
|
|
187
|
-
let fc=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,pc=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,mc=/^[+-]?0[0-9_]/,hc=/^[0-9a-f]{2,8}$/i,gc={b:`\b`,t:` `,n:`
|
|
188
|
-
`,f:`\f`,r:`\r`,e:`\x1B`,'"':`"`,"\\":`\\`};function _c(e,t=0,n=e.length){let r=e[t]===`'`,i=e[t++]===e[t]&&e[t]===e[t+1];i&&(n-=2,e[t+=2]===`\r`&&t++,e[t]===`
|
|
189
|
-
`&&t++);let a=0,o,s=``,c=t;for(;t<n-1;){let n=e[t++];if(n===`
|
|
190
|
-
`||n===`\r`&&e[t]===`
|
|
191
|
-
`){if(!i)throw new z(`newlines are not allowed in strings`,{toml:e,ptr:t-1})}else if(n<` `&&n!==` `||n===``)throw new z(`control characters are not allowed in strings`,{toml:e,ptr:t-1});if(o){if(o=!1,n===`x`||n===`u`||n===`U`){let r=e.slice(t,t+=n===`x`?2:n===`u`?4:8);if(!hc.test(r))throw new z(`invalid unicode escape`,{toml:e,ptr:a});try{s+=String.fromCodePoint(parseInt(r,16))}catch{throw new z(`invalid unicode escape`,{toml:e,ptr:a})}}else if(i&&(n===`
|
|
192
|
-
`||n===` `||n===` `||n===`\r`)){if(t=sc(e,t-1,!0),e[t]!==`
|
|
193
|
-
`&&e[t]!==`\r`)throw new z(`invalid escape: only line-ending whitespace may be escaped`,{toml:e,ptr:a});t=sc(e,t)}else if(n in gc)s+=gc[n];else throw new z(`unrecognized escape sequence`,{toml:e,ptr:a});c=t}else!r&&n===`\\`&&(a=t-1,o=!0,s+=e.slice(c,a))}return s+e.slice(c,n-1)}function vc(e,t,n,r){if(e===`true`)return!0;if(e===`false`)return!1;if(e===`-inf`)return-1/0;if(e===`inf`||e===`+inf`)return 1/0;if(e===`nan`||e===`+nan`||e===`-nan`)return NaN;if(e===`-0`)return r?0n:0;let i=fc.test(e);if(i||pc.test(e)){if(mc.test(e))throw new z(`leading zeroes are not allowed`,{toml:t,ptr:n});e=e.replace(/_/g,``);let a=+e;if(isNaN(a))throw new z(`invalid number`,{toml:t,ptr:n});if(i){if((i=!Number.isSafeInteger(a))&&!r)throw new z(`integer value cannot be represented losslessly`,{toml:t,ptr:n});(i||r===!0)&&(a=BigInt(e))}return a}let a=new dc(e);if(!a.isValid())throw new z(`invalid value`,{toml:t,ptr:n});return a}
|
|
194
|
-
/*!
|
|
195
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
196
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
197
|
-
*
|
|
198
|
-
* Redistribution and use in source and binary forms, with or without
|
|
199
|
-
* modification, are permitted provided that the following conditions are met:
|
|
200
|
-
*
|
|
201
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
202
|
-
* list of conditions and the following disclaimer.
|
|
203
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
204
|
-
* this list of conditions and the following disclaimer in the
|
|
205
|
-
* documentation and/or other materials provided with the distribution.
|
|
206
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
207
|
-
* may be used to endorse or promote products derived from this software without
|
|
208
|
-
* specific prior written permission.
|
|
209
|
-
*
|
|
210
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
211
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
212
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
213
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
214
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
215
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
216
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
217
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
218
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
219
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
220
|
-
*/
|
|
221
|
-
function yc(e,t,n){let r=e.slice(t,n),i=r.indexOf(`#`);return i>-1&&(oc(e,i),r=r.slice(0,i)),[r.trimEnd(),i]}function bc(e,t,n,r,i){if(r===0)throw new z(`document contains excessively nested structures. aborting.`,{toml:e,ptr:t});let a=e[t];if(a===`[`||a===`{`){let[o,s]=a===`[`?wc(e,t,r,i):Cc(e,t,r,i);if(n){if(s=sc(e,s),e[s]===`,`)s++;else if(e[s]!==n)throw new z(`expected comma or end of structure`,{toml:e,ptr:s})}return[o,s]}let o;if(a===`"`||a===`'`){o=lc(e,t);let r=_c(e,t,o);if(n){if(o=sc(e,o),e[o]&&e[o]!==`,`&&e[o]!==n&&e[o]!==`
|
|
222
|
-
`&&e[o]!==`\r`)throw new z(`unexpected character encountered`,{toml:e,ptr:o});o+=+(e[o]===`,`)}return[r,o]}o=cc(e,t,`,`,n);let s=yc(e,t,o-+(e[o-1]===`,`));if(!s[0])throw new z(`incomplete key-value declaration: no value specified`,{toml:e,ptr:t});return n&&s[1]>-1&&(o=sc(e,t+s[1]),o+=+(e[o]===`,`)),[vc(s[0],e,t,i),o]}
|
|
223
|
-
/*!
|
|
224
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
225
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
226
|
-
*
|
|
227
|
-
* Redistribution and use in source and binary forms, with or without
|
|
228
|
-
* modification, are permitted provided that the following conditions are met:
|
|
229
|
-
*
|
|
230
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
231
|
-
* list of conditions and the following disclaimer.
|
|
232
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
233
|
-
* this list of conditions and the following disclaimer in the
|
|
234
|
-
* documentation and/or other materials provided with the distribution.
|
|
235
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
236
|
-
* may be used to endorse or promote products derived from this software without
|
|
237
|
-
* specific prior written permission.
|
|
238
|
-
*
|
|
239
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
240
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
241
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
242
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
243
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
244
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
245
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
246
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
247
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
248
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
249
|
-
*/
|
|
250
|
-
let xc=/^[a-zA-Z0-9-_]+[ \t]*$/;function Sc(e,t,n=`=`){let r=t-1,i=[],a=e.indexOf(n,t);if(a<0)throw new z(`incomplete key-value: cannot find end of key`,{toml:e,ptr:t});do{let o=e[t=++r];if(o!==` `&&o!==` `)if(o===`"`||o===`'`){if(o===e[t+1]&&o===e[t+2])throw new z(`multiline strings are not allowed in keys`,{toml:e,ptr:t});let s=lc(e,t);if(s<0)throw new z(`unfinished string encountered`,{toml:e,ptr:t});r=e.indexOf(`.`,s);let c=e.slice(s,r<0||r>a?a:r),l=ac(c);if(l>-1)throw new z(`newlines are not allowed in keys`,{toml:e,ptr:t+r+l});if(c.trimStart())throw new z(`found extra tokens after the string part`,{toml:e,ptr:s});if(a<s&&(a=e.indexOf(n,s),a<0))throw new z(`incomplete key-value: cannot find end of key`,{toml:e,ptr:t});i.push(_c(e,t,s))}else{r=e.indexOf(`.`,t);let n=e.slice(t,r<0||r>a?a:r);if(!xc.test(n))throw new z(`only letter, numbers, dashes and underscores are allowed in keys`,{toml:e,ptr:t});i.push(n.trimEnd())}}while(r+1&&r<a);return[i,sc(e,a+1,!0,!0)]}function Cc(e,t,n,r){let i={},a=new Set,o;for(t++;(o=e[t++])!==`}`&&o;)if(o===`,`)throw new z(`expected value, found comma`,{toml:e,ptr:t-1});else if(o===`#`)t=oc(e,t);else if(o!==` `&&o!==` `&&o!==`
|
|
251
|
-
`&&o!==`\r`){let o,s=i,c=!1,[l,u]=Sc(e,t-1);for(let n=0;n<l.length;n++){if(n&&(s=c?s[o]:s[o]={}),o=l[n],(c=Object.hasOwn(s,o))&&(typeof s[o]!=`object`||a.has(s[o])))throw new z(`trying to redefine an already defined value`,{toml:e,ptr:t});!c&&o===`__proto__`&&Object.defineProperty(s,o,{enumerable:!0,configurable:!0,writable:!0})}if(c)throw new z(`trying to redefine an already defined value`,{toml:e,ptr:t});let[d,f]=bc(e,u,`}`,n-1,r);a.add(d),s[o]=d,t=f}if(!o)throw new z(`unfinished table encountered`,{toml:e,ptr:t});return[i,t]}function wc(e,t,n,r){let i=[],a;for(t++;(a=e[t++])!==`]`&&a;)if(a===`,`)throw new z(`expected value, found comma`,{toml:e,ptr:t-1});else if(a===`#`)t=oc(e,t);else if(a!==` `&&a!==` `&&a!==`
|
|
252
|
-
`&&a!==`\r`){let a=bc(e,t-1,`]`,n-1,r);i.push(a[0]),t=a[1]}if(!a)throw new z(`unfinished array encountered`,{toml:e,ptr:t});return[i,t]}
|
|
253
|
-
/*!
|
|
254
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
255
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
256
|
-
*
|
|
257
|
-
* Redistribution and use in source and binary forms, with or without
|
|
258
|
-
* modification, are permitted provided that the following conditions are met:
|
|
259
|
-
*
|
|
260
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
261
|
-
* list of conditions and the following disclaimer.
|
|
262
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
263
|
-
* this list of conditions and the following disclaimer in the
|
|
264
|
-
* documentation and/or other materials provided with the distribution.
|
|
265
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
266
|
-
* may be used to endorse or promote products derived from this software without
|
|
267
|
-
* specific prior written permission.
|
|
268
|
-
*
|
|
269
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
270
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
271
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
272
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
273
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
274
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
275
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
276
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
277
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
278
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
279
|
-
*/
|
|
280
|
-
function Tc(e,t,n,r){let i=t,a=n,o,s=!1,c;for(let t=0;t<e.length;t++){if(t){if(i=s?i[o]:i[o]={},a=(c=a[o]).c,r===0&&(c.t===1||c.t===2))return null;if(c.t===2){let e=i.length-1;i=i[e],a=a[e].c}}if(o=e[t],(s=Object.hasOwn(i,o))&&a[o]?.t===0&&a[o]?.d)return null;s||(o===`__proto__`&&(Object.defineProperty(i,o,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(a,o,{enumerable:!0,configurable:!0,writable:!0})),a[o]={t:t<e.length-1&&r===2?3:r,d:!1,i:0,c:{}})}if(c=a[o],c.t!==r&&!(r===1&&c.t===3)||(r===2&&(c.d||(c.d=!0,i[o]=[]),i[o].push(i={}),c.c[c.i++]=c={t:1,d:!1,i:0,c:{}}),c.d))return null;if(c.d=!0,r===1)i=s?i[o]:i[o]={};else if(r===0&&s)return null;return[o,i,c.c]}function Ec(e,{maxDepth:t=1e3,integersAsBigInt:n}={}){let r={},i={},a=r,o=i;for(let s=sc(e,0);s<e.length;){if(e[s]===`[`){let t=e[++s]===`[`,n=Sc(e,s+=+t,`]`);if(t){if(e[n[1]-1]!==`]`)throw new z(`expected end of table declaration`,{toml:e,ptr:n[1]-1});n[1]++}let c=Tc(n[0],r,i,t?2:1);if(!c)throw new z(`trying to redefine an already defined table or value`,{toml:e,ptr:s});o=c[2],a=c[1],s=n[1]}else{let r=Sc(e,s),i=Tc(r[0],a,o,0);if(!i)throw new z(`trying to redefine an already defined table or value`,{toml:e,ptr:s});let c=bc(e,r[1],void 0,t,n);i[1][i[0]]=c[0],s=c[1]}if(s=sc(e,s,!0),e[s]&&e[s]!==`
|
|
281
|
-
`&&e[s]!==`\r`)throw new z(`each key-value declaration must be followed by an end-of-line`,{toml:e,ptr:s});s=sc(e,s)}return r}
|
|
282
|
-
/*!
|
|
283
|
-
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
284
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
285
|
-
*
|
|
286
|
-
* Redistribution and use in source and binary forms, with or without
|
|
287
|
-
* modification, are permitted provided that the following conditions are met:
|
|
288
|
-
*
|
|
289
|
-
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
290
|
-
* list of conditions and the following disclaimer.
|
|
291
|
-
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
292
|
-
* this list of conditions and the following disclaimer in the
|
|
293
|
-
* documentation and/or other materials provided with the distribution.
|
|
294
|
-
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
295
|
-
* may be used to endorse or promote products derived from this software without
|
|
296
|
-
* specific prior written permission.
|
|
297
|
-
*
|
|
298
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
299
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
300
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
301
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
302
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
303
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
304
|
-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
305
|
-
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
306
|
-
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
307
|
-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
308
|
-
*/
|
|
309
|
-
let Dc=/^[a-z0-9-_]+$/i;function Oc(e){let t=typeof e;if(t===`object`){if(Array.isArray(e))return`array`;if(e instanceof Date)return`date`}return t}function kc(e){for(let t=0;t<e.length;t++)if(Oc(e[t])!==`object`)return!1;return e.length!=0}function Ac(e){return JSON.stringify(e).replace(/\x7f/g,`\\u007f`)}function jc(e,t,n,r){if(n===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);if(t===`number`)return isNaN(e)?`nan`:e===1/0?`inf`:e===-1/0?`-inf`:r&&Number.isInteger(e)?e.toFixed(1):e.toString();if(t===`bigint`||t===`boolean`)return e.toString();if(t===`string`)return Ac(e);if(t===`date`){if(isNaN(e.getTime()))throw TypeError(`cannot serialize invalid date`);return e.toISOString()}if(t===`object`)return Mc(e,n,r);if(t===`array`)return Nc(e,n,r)}function Mc(e,t,n){let r=Object.keys(e);if(r.length===0)return`{}`;let i=`{ `;for(let a=0;a<r.length;a++){let o=r[a];a&&(i+=`, `),i+=Dc.test(o)?o:Ac(o),i+=` = `,i+=jc(e[o],Oc(e[o]),t-1,n)}return i+` }`}function Nc(e,t,n){if(e.length===0)return`[]`;let r=`[ `;for(let i=0;i<e.length;i++){if(i&&(r+=`, `),e[i]===null||e[i]===void 0)throw TypeError(`arrays cannot contain null or undefined values`);r+=jc(e[i],Oc(e[i]),t-1,n)}return r+` ]`}function Pc(e,t,n,r){if(n===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);let i=``;for(let a=0;a<e.length;a++)i+=`${i&&`
|
|
310
|
-
`}[[${t}]]\n`,i+=Fc(0,e[a],t,n,r);return i}function Fc(e,t,n,r,i){if(r===0)throw Error(`Could not stringify the object: maximum object depth exceeded`);let a=``,o=``,s=Object.keys(t);for(let e=0;e<s.length;e++){let c=s[e];if(t[c]!==null&&t[c]!==void 0){let e=Oc(t[c]);if(e===`symbol`||e===`function`)throw TypeError(`cannot serialize values of type '${e}'`);let s=Dc.test(c)?c:Ac(c);if(e===`array`&&kc(t[c]))o+=(o&&`
|
|
311
|
-
`)+Pc(t[c],n?`${n}.${s}`:s,r-1,i);else if(e===`object`){let e=n?`${n}.${s}`:s;o+=(o&&`
|
|
312
|
-
`)+Fc(e,t[c],e,r-1,i)}else a+=s,a+=` = `,a+=jc(t[c],e,r,i),a+=`
|
|
313
|
-
`}}return e&&(a||!o)&&(a=a?`[${e}]\n${a}`:`[${e}]`),a&&o?`${a}\n${o}`:a||o}function Ic(e,{maxDepth:t=1e3,numbersAsFloat:n=!1}={}){if(Oc(e)!==`object`)throw TypeError(`stringify can only be called with an object`);let r=Fc(0,e,``,t,n);return r[r.length-1]===`
|
|
314
|
-
`?r:r+`
|
|
315
|
-
`}const Lc=e=>typeof e==`object`&&!!e&&`code`in e&&e.code===`ENOENT`,Rc=async(e,t)=>{await o(_(e),{recursive:!0});let n=`${e}.tmp-${re()}`;await m(n,t,`utf8`),await u(n,e)},B=e=>{let t=te(e.REFS_HOME??y(me(),`.kaisers-io`,`refs`));return{configPath:y(t,`config.toml`),hooksDir:y(t,`hooks`),locksDir:y(t,`locks`),root:t,sourcesDir:y(t,`sources`),statePath:y(t,`state.json`)}},V=(e,t)=>y(e.sourcesDir,...t.split(`/`)),zc=e=>`${e.configPath}.bak`,Bc=e=>{let t=[],n=e;for(;!ce(n);){let e=_(n);if(e===n)break;t.unshift(g(n)),n=e}return{ancestor:n,missing:t}},Vc=e=>{let{ancestor:t,missing:n}=Bc(e),r=ue(t);return n.length===0?r:y(r,...n)},Hc=(e,t)=>{let n=ee(Vc(e.sourcesDir),Vc(t)),r=n===`..`||n.startsWith(`..`+ne);if(!(n!==``&&!r&&!v(n)))throw T(`path escapes sources directory (containment violation): ${t}`)},Uc=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Wc=(e,t)=>Uc(e)?e:t,Gc=async e=>{try{return await s(e.configPath,`utf8`)}catch(e){throw Lc(e)?C(`no config found — run: refs init`):e}},Kc=(e,t)=>{try{return Ec(e)}catch(e){throw e instanceof z?T(`invalid TOML in ${t}: ${e.message}`):e}},qc=e=>typeof e==`number`&&Number.isInteger(e)&&e>=1,Jc=e=>{let{meta:t}=e;if(!Uc(t))return;let n=t.schema_version;if(qc(n))return n},Yc=(e,t)=>{let n=Jc(e);if(n===void 0)throw T(`config schema version is missing or invalid in ${t} — run: refs migrate`);if(n>1)throw T(`config schema ${n} is newer than this CLI supports — upgrade refs`);if(n<1)throw T(`config schema ${n} is older than expected 1 — run: refs migrate`)},H=async e=>{let t=await Gc(e),n=Kc(t,e.configPath);Yc(n,e.configPath);let r=tc.safeParse(n);if(!r.success)throw T(k(r.error));return r.data},Xc=async(e,t)=>{let n=tc.safeParse(t);if(!n.success)throw T(k(n.error));await Rc(e.configPath,Ic(n.data))},Zc=async e=>{try{return await p(e),!0}catch(e){if(Lc(e))return!1;throw e}},Qc=async(e,t)=>await Zc(e.configPath)?`noop`:(await Rc(e.configPath,`# refs configuration
|
|
316
|
-
#
|
|
317
|
-
# Every global setting under [settings] can also be set per-ref: add the same
|
|
318
|
-
# key directly inside a [refs."host/owner/repo"] table to override it just for
|
|
319
|
-
# that ref — every global setting is per-ref overridable.
|
|
25
|
+
const [major = FALLBACK_VERSION_PART, minor = FALLBACK_VERSION_PART] = process.versions.node
|
|
26
|
+
.split('.')
|
|
27
|
+
.map(Number);
|
|
28
|
+
if (
|
|
29
|
+
major < REQUIRED_NODE_MAJOR ||
|
|
30
|
+
(major === REQUIRED_NODE_MAJOR && minor < REQUIRED_NODE_MINOR_MIN)
|
|
31
|
+
) {
|
|
32
|
+
console.error(
|
|
33
|
+
`refs requires Node.js >=24.12 — you are running Node.js ${process.versions.node}.`,
|
|
34
|
+
);
|
|
35
|
+
console.error('Install a matching version, e.g.: nvm install 24');
|
|
36
|
+
process.exit(EXIT_FAILURE);
|
|
37
|
+
}
|
|
320
38
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
39
|
+
const printNotBuiltMessage = () => {
|
|
40
|
+
console.error('refs is not built — the CLI bundle (dist/refs.mjs) is missing.');
|
|
41
|
+
console.error('Run: pnpm install && pnpm build (or `pnpm dev` in packages/cli for watch mode)');
|
|
42
|
+
};
|
|
324
43
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
clone_mode = "blobless"
|
|
328
|
-
# Transport for npm:-resolved adds: their clone url is rewritten to this before cloning.
|
|
329
|
-
# One of "https" (default) or "ssh" (for private-package setups with forge ssh keys).
|
|
330
|
-
# Explicitly-typed git urls are always used verbatim.
|
|
331
|
-
git_transport = "https"
|
|
332
|
-
# How long a ref's fetched state is considered fresh before refs re-fetches it.
|
|
333
|
-
# Format: <n>m, <n>h, or <n>d (e.g. "30m", "1h", "1d"). Default: "1h".
|
|
334
|
-
sync_ttl = "1h"
|
|
44
|
+
const isSourceLoadError = (error) =>
|
|
45
|
+
error instanceof Error && SOURCE_LOAD_ERROR_CODES.has(error.code);
|
|
335
46
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
# url = "https://github.com/owner/repo"
|
|
342
|
-
# default_branch = "main"
|
|
343
|
-
# tag_format = "v{version}"
|
|
344
|
-
# # Per-ref overrides of [settings] go in the same table, e.g.:
|
|
345
|
-
# # clone_mode = "full"
|
|
346
|
-
`.replaceAll(`{{CLI_VERSION}}`,t)),`seeded`),$c=(e,t)=>{let n={...e};for(let[e,r]of Object.entries(t)){let t=n[e];t===void 0?n[e]=r:Uc(t)&&Uc(r)&&(n[e]=$c(t,r))}return n},el={meta:{},refs:{},settings:{}},tl=async e=>{try{return await Gc(e)}catch(e){if(e instanceof at&&e.code===`not_found`)return;throw e}},nl=e=>{if(e!==void 0&&e>1)throw T(`config schema ${e} is newer than this CLI supports — upgrade refs`)},rl=async(e,t,n)=>{let r=Wc(t.meta,{});if(r.cli_version===n)return;let i={...t,meta:{...r,cli_version:n}};await Rc(e.configPath,Ic(i))},il=async(e,t,n)=>{await i(e.configPath,zc(e));let r=$c(t,el),a=Wc(r.meta,{}),o={...r,meta:{...a,cli_version:n,schema_version:1}},s=tc.safeParse(o);if(!s.success)throw T(`config in ${e.configPath} is malformed beyond automatic migration (backup preserved at ${zc(e)}): ${k(s.error)}`);await Rc(e.configPath,Ic(o))},al=async(e,t)=>(await Qc(e,t),`seeded`),ol=async(e,t,n)=>{let r=Kc(t,e.configPath),i=Jc(r);return nl(i),i===1?(await rl(e,r,n),`noop`):(await il(e,r,n),`migrated`)},sl=async(e,t)=>{let n=await tl(e);return n===void 0?al(e,t):ol(e,n,t)},cl=e=>{let t=e.stderr.trim()||e.stdout.trim()||`exit code ${e.exitCode}`,n=t.split(`
|
|
347
|
-
`)[0]??t;return n.length<=200?n:`${n.slice(0,200)}…`},ll=(e,t)=>t?`restored`:e.oldSha===e.newSha?`fresh`:`updated`,ul=(e,t)=>{let n=[];if(e&&n.push(`checkout had local changes (managed checkouts are read-only) — discarded and restored to the remote state`),t!==void 0&&n.push(t),n.length!==0)return n.join(` | `)},dl=e=>{let{branchRenamedTo:t,dirty:n,setHeadWarning:r,shas:i}=e,a={...i,status:ll(i,n)};t!==void 0&&(a.branchRenamedTo=t);let o=ul(n,r);return o!==void 0&&(a.warning=o),a},fl=(e,t,n)=>{let r={dirty:t,shas:n};return e.branchRenamedTo!==void 0&&(r.branchRenamedTo=e.branchRenamedTo),e.warning!==void 0&&(r.setHeadWarning=e.warning),r},U=e=>ce(y(e,`.git`)),pl=e=>`refusing to sync ${e}: not a refs-managed checkout`,ml=async(e,t)=>{if(!U(t))throw T(pl(t));let n=await e.run(`git`,[`config`,`--local`,`--get`,`core.hooksPath`],{cwd:t});if(n.exitCode!==0||n.stdout.trim()===``)throw T(pl(t))},hl=/filtering not recognized/iu,gl=e=>e===void 0?{}:{cwd:e},W=(e,t,n)=>({action:e,args:t,cmd:`git`,...gl(n)}),_l=async(e,t)=>{let n=await e.run(t.cmd,t.args,gl(t.cwd));if(n.exitCode===0)return n;let r=n.stderr.trim()||n.stdout.trim()||`exit code ${n.exitCode}`;throw T(`${t.action} failed: ${r}`)},vl=async(e,t)=>{let n=[`clone`,`-q`];t.mode===`blobless`&&n.push(`--filter=blob:none`),n.push(t.cloneUrl,t.dest);let r=await _l(e,W(`git clone`,n));return await _l(e,W(`git config core.hooksPath`,[`config`,`core.hooksPath`,t.hooksDir],t.dest)),t.mode===`blobless`&&hl.test(r.stderr)?{effectiveMode:`full`,warning:`server did not honour the partial-clone filter (blob:none); fell back to a full clone`}:{effectiveMode:t.mode}},yl=async(e,t)=>{let n=await e.run(`git`,[`symbolic-ref`,`--short`,`refs/remotes/origin/HEAD`],{cwd:t});if(n.exitCode!==0)return;let r=n.stdout.trim();return r.startsWith(`origin/`)?r.slice(7):r},bl=async(e,t)=>{let n=await yl(e,t);if(n!==void 0)return n;await e.run(`git`,[`remote`,`set-head`,`origin`,`--auto`],{cwd:t});let r=await yl(e,t);if(r!==void 0)return r;throw T(`could not detect the default branch for checkout: ${t}`)},xl=async(e,t)=>(await _l(e,W(`git rev-parse HEAD`,[`rev-parse`,`HEAD`],t))).stdout.trim(),Sl=async(e,t)=>(await _l(e,W(`git status --porcelain`,[`status`,`--porcelain`],t))).stdout.trim()!==``,Cl=async(e,t)=>{await _l(e,W(`git fetch`,[`fetch`,`--prune`,`--tags`,`origin`],t.dir));let n=await e.run(`git`,[`remote`,`set-head`,`origin`,`--auto`],{cwd:t.dir}),r=await bl(e,t.dir),i={branch:r};return r!==t.defaultBranch&&(i.branchRenamedTo=r),n.exitCode!==0&&(i.warning=`could not refresh origin/HEAD: ${cl(n)}`),i},wl=e=>[W(`git reset --hard HEAD (pre-checkout)`,[`reset`,`--hard`,`HEAD`],e),W(`git clean -fd`,[`clean`,`-fd`],e)],Tl=async(e,t)=>{let{branch:n,dir:r,dirty:i}=t,a=[];i&&a.push(...wl(r)),a.push(W(`git checkout -B`,[`checkout`,`-B`,n,`origin/${n}`],r),W(`git reset --hard`,[`reset`,`--hard`,`origin/${n}`],r));for(let t of a)await _l(e,t)},El=async(e,t)=>{await ml(e,t.dir);let n=await xl(e,t.dir),r=await Cl(e,t),i=await Sl(e,t.dir);return await Tl(e,{branch:r.branch,dir:t.dir,dirty:i}),dl(fl(r,i,{newSha:await xl(e,t.dir),oldSha:n}))},Dl=async(e,t,n=20)=>(await _l(e,W(`git tag`,[`tag`,`--sort=-version:refname`],t))).stdout.split(`
|
|
348
|
-
`).map(e=>e.trim()).filter(e=>e!==``).slice(0,n),Ol=async(e,t,n)=>(await e.run(`git`,[`show-ref`,`--verify`,`--`,`refs/tags/${n}`],{cwd:t})).exitCode===0,kl=[`#!/bin/sh`,`echo "refs: this checkout is a managed read-only reference — commits are blocked" >&2`,`exit 1`,``].join(`
|
|
349
|
-
`),Al=async e=>{await Promise.all([`pre-commit`,`pre-push`].map(async t=>{let r=y(e.hooksDir,t);await Rc(r,kl),await n(r,493)}))},jl=/\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?/u,Ml=/\d+\.\d+\.\d+/gu,Nl=e=>Js.safeParse(e).success,Pl=e=>{let t=e.match(Ml);return t!==null&&t.length>1},Fl=e=>{let t=jl.exec(e);if(!t||Pl(e))return;let[n]=t,r=e.replace(n,`{version}`);if(Nl(r))return r},Il=(e,t,n)=>{let r=e.get(t);r===void 0?e.set(t,{count:1,index:n}):r.count+=1},Ll=e=>{let t=new Map;for(let n=0;n<e.length;n+=1){let r=e[n];if(r===void 0)continue;let i=Fl(r);i&&Il(t,i,n)}return t},Rl=(e,t)=>e.count>t.count||e.count===t.count&&e.index<t.index,zl=e=>{let t=[...e.entries()];if(t.length===0)return null;let n=t[0];if(!n)return null;let[r,i]=n;return t.slice(1).reduce(({format:e,data:t},[n,r])=>Rl(r,t)?{data:r,format:n}:{data:t,format:e},{data:i,format:r}).format},Bl=e=>{let t=Ll(e);return zl(t)},Vl=(e,t)=>e.replaceAll(`{version}`,()=>t),Hl=async(e,t,n,r)=>{let i=Vl(n,r);if(!await Ol(e,t,i))throw C(`tag '${i}' not found in ${t} — check the version or tag_format`);return i},Ul=/^(?<scheme>[a-z][a-z0-9+.-]*:\/\/)?[\s\S]*@/iu,G=e=>{let t=e.replace(Ul,`$<scheme><redacted>@`);return t.length<=200?t:`${t.slice(0,200)}…`},Wl=/^git@(?<host>[^:/\s]+):(?<path>[^\s]+)$/u,Gl=/^git\+/u,Kl={"https:":`443`,"ssh:":`22`},ql=e=>e.replace(/\.git$/u,``),Jl=e=>e.split(`/`).some(e=>e===`.`||e===`..`),Yl=e=>e.includes(`\\`),Xl=e=>e.includes(`%`),Zl=e=>{let t=Us.safeParse(e);if(!t.success)throw T(`not a supported git url: derived key '${G(e)}' is invalid`);return t.data},Ql=({host:e,port:t,protocol:n})=>{let r=Kl[n];return t===``||t===r?e.toLowerCase():`${e.toLowerCase()}_${t}`},$l=e=>{let t=ql(e.path.replace(/^\/+/u,``).replace(/\/+$/u,``));return Zl(`${Ql(e)}/${t}`)},eu=e=>{let t=decodeURIComponent(e).split(`/`).filter(e=>e!==``);if(t.length<2)throw T(`not a supported git url: file url path must have at least 2 segments`);let n=t.at(-2)??``,r=t.at(-1)??``;return Zl(`local/${n}/${r}`)},tu=(e,t)=>{try{return new URL(e)}catch{throw T(`not a supported git url: ${G(t)}`)}},nu=e=>{if(e.password!==``)throw T(`not a supported git url: credentials embedded in url`);if(e.protocol===`https:`&&e.username!==``)throw T(`not a supported git url: credentials embedded in https url`)},ru=(e,t)=>{if(e.protocol===`file:`){if(!t)throw T(`not a supported git url: unsupported protocol ${e.protocol}`);return eu(e.pathname)}if(e.protocol!==`https:`&&e.protocol!==`ssh:`)throw T(`not a supported git url: unsupported protocol ${e.protocol}`);return nu(e),$l({host:e.hostname,path:e.pathname,port:e.port,protocol:e.protocol})},iu=(e,t)=>{if(Xl(e))throw T(`not a supported git url: percent-encoding not supported in ${G(t)}`);if(e.includes(`:`))throw T(`not a supported git url: ambiguous ':' in scp-style path ${G(t)}; use the ssh:// url form instead`);if(e.startsWith(`/`)||e.startsWith(`~`))throw T(`not a supported git url: ambiguous absolute/home-relative scp path in ${G(t)}; use the ssh:// url form instead`)},au=(e,t)=>{let n=e.groups?.path??``;return iu(n,t),$l({host:e.groups?.host??``,path:n,port:``,protocol:`ssh:`})},ou=(e,t)=>{if(Yl(e))throw T(`not a supported git url: backslash not allowed in ${G(t)}`)},su=(e,t)=>{if(Jl(e))throw T(`not a supported git url: path traversal segment in ${G(t)}`)},cu=(e,t,n)=>{if(e.protocol!==`file:`&&Xl(t))throw T(`not a supported git url: percent-encoding not supported in ${G(n)}`)},lu=(e,t)=>{let n=t?.allowFileUrls??!1,r=e.replace(Gl,``);ou(r,e),su(r,e);let i=Wl.exec(r);if(i?.groups!==void 0)return{cloneUrl:r,key:au(i,e)};let a=tu(r,e);return cu(a,r,e),{cloneUrl:r,key:ru(a,n)}},uu=`.git`,du=e=>e.replace(/^\/+/u,``).replace(/\/+$/u,``),fu=e=>e.endsWith(uu)?e:`${e}${uu}`,pu=(e,t)=>`https://${e.toLowerCase()}/${du(t)}`,mu=(e,t)=>`git@${e.toLowerCase()}:${fu(du(t))}`,hu=e=>{if(e===`https:`)return`https`;if(e===`ssh:`)return`ssh`;throw T(`not a supported git url: unsupported protocol ${e}`)},gu=(e,t,n)=>{let r=Kl[e.protocol];if(e.port!==``&&e.port!==r)throw T(`cannot apply git_transport=${t} to ${G(n)}: its non-default port ${e.port} cannot be expressed in the ${t} url form — add the repo with an explicit url instead`)},_u=(e,t)=>t===`https`?pu(e.hostname,e.pathname):mu(e.hostname,e.pathname),vu=(e,t,n)=>{let r=lu(t).key;if(r!==n)throw T(`git_transport transform changed repo identity: '${G(e)}' → '${t}' (key '${n}' → '${r}')`);return t},yu=(e,t)=>{if(t.transport===`ssh`)return t.cloneUrl;let n=e.groups?.host??``,r=e.groups?.path??``;return vu(t.cloneUrl,pu(n,r),t.originalKey)},bu=e=>{let t=tu(e.cloneUrl,e.cloneUrl);return hu(t.protocol)===e.transport?e.cloneUrl:(gu(t,e.transport,e.cloneUrl),vu(e.cloneUrl,_u(t,e.transport),e.originalKey))},xu=(e,t)=>{if(e.startsWith(`file:`))return e;let n={cloneUrl:e,originalKey:lu(e).key,transport:t},r=Wl.exec(e);return r?.groups===void 0?bu(n):yu(r,n)},Su=`meta.json`,Cu=e=>{if(typeof e==`object`&&e&&`code`in e){let{code:t}=e;if(typeof t==`string`)return t}},wu=e=>{try{return process.kill(e,0),!0}catch(e){return Cu(e)!==`ESRCH`}},Tu=e=>{try{return JSON.parse(e)}catch{return}},Eu=async e=>{try{return await s(e,`utf8`)}catch{return}},Du=e=>{if(typeof e!=`string`)return;let t=Date.parse(e);if(!Number.isNaN(t))return t},Ou=e=>{if(typeof e!=`object`||!e)return;let t=e,{pid:n}=t,r=Du(t.acquired_at);if(!(typeof n!=`number`||r===void 0))return{acquiredAtMs:r,pid:n}},ku=async e=>{let t=await Eu(y(e,Su));if(t!==void 0)return Ou(Tu(t))},Au=e=>{if(typeof e!=`object`||!e)return;let{token:t}=e;if(typeof t==`string`)return t},ju=async e=>{let t=await Eu(y(e,Su));if(t!==void 0)return Au(Tu(t))},Mu=async e=>{try{return(await p(e)).mtimeMs}catch{return}},Nu=async(e,t)=>{let n=y(e,Su),r=`${n}.tmp-${re()}`;await m(r,t,`utf8`),await u(r,n)},Pu=async(e,t)=>{await Nu(e,JSON.stringify({acquired_at:new Date().toISOString(),pid:process.pid,token:t}))},Fu=/^[a-zA-Z0-9][a-zA-Z0-9_.:-]*$/u,Iu=async e=>{let t=await ku(e);if(t===void 0){let t=await Mu(e);return t===void 0?!1:Date.now()-t>5e3}return Date.now()-t.acquiredAtMs>6e5?!0:!wu(t.pid)},Lu=async(e,t)=>{try{await Pu(e,t)}catch(e){if(Cu(e)===`ENOENT`)return`retry`;throw e}return t},Ru=async e=>{try{return await o(e,{recursive:!1}),!0}catch(e){if(Cu(e)===`EEXIST`)return!1;throw e}},zu=async e=>{if(!await Ru(e))return;let t=await Lu(e,re());return t===`retry`?zu(e):t},Bu=e=>y(e.locksDir,`${e.name}.steal-claim`),Vu=e=>y(e.locksDir,`${e.name}.steal.${re()}`),Hu=async e=>{try{return await o(e,{recursive:!1}),!0}catch(e){if(Cu(e)===`EEXIST`)return!1;throw e}},Uu=async e=>{let t=await Mu(e);return t!==void 0&&Date.now()-t>2e3},Wu=async e=>await Hu(e)?!0:await Uu(e)?(await d(e,{force:!0,recursive:!0}),Hu(e)):!1,Gu=async e=>{let t=Vu(e);try{await u(e.lockPath,t)}catch(e){if(Cu(e)===`ENOENT`)return;throw e}return t},Ku=async e=>{if(!await Iu(e.lockPath))return;let t=await Gu(e);t!==void 0&&await d(t,{force:!0,recursive:!0})},qu=async e=>{let t=Bu(e);if(await Wu(t))try{await Ku(e)}finally{await d(t,{force:!0,recursive:!0})}},Ju=async(e,t)=>{if(await Iu(e.lockPath)){await qu(e);return}if(Date.now()>=t)throw ot(`lock ${e.name} is held — another refs process is running`);await _e(100)},Yu=async(e,t)=>{let n=await zu(e.lockPath);return n===void 0?(await Ju(e,t),Yu(e,t)):n},Xu=async(e,t)=>{await ju(e)===t&&await d(e,{force:!0,recursive:!0})},Zu=e=>{if(e===`.`||e===`..`||!Fu.test(e))throw T(`lock name must not contain "/" or other unsafe characters — only letters, digits, and "_.:-" are allowed, and it may not be "." or "..": ${e}`)},K=async(e,t,n,r)=>{Zu(t);let i={lockPath:y(e.locksDir,t),locksDir:e.locksDir,name:t};await o(e.locksDir,{recursive:!0});let a=Date.now()+(r?.timeoutMs??1e4),s=await Yu(i,a);try{return await n()}finally{await Xu(i.lockPath,s)}},Qu=Xo({directory:L().optional(),url:L().optional()}),$u=Xo({repository:Qo([L(),Qu]).optional()}),ed=/^(?:@[a-z0-9-~][a-z0-9._~-]*\/)?[a-z0-9-~][a-z0-9._~-]*$/u,td=new Set([`node_modules`,`favicon.ico`]),nd=e=>C(`package '${e}' has no usable repository field — find the repository and run: refs add <git-url>`),rd=e=>{let t=e.split(`/`);return t.length>=2?t[1]:e},id=e=>{if(e.length>214)throw w(`invalid package name: '${e}' exceeds maximum length of 214 characters`);if(!ed.test(e))throw w(`invalid package name: '${e}' does not match npm naming rules`);let t=rd(e);if(td.has(t))throw w(`invalid package name: '${e}' uses a reserved name`)},ad=e=>e.replace(`/`,`%2F`),od=e=>typeof e==`string`?e:e?.url,sd=e=>{if(typeof e==`object`&&e?.directory){let t=Ys.safeParse(e.directory);if(t.success)return t.data}},cd=async(e,t)=>{try{return await e.json()}catch{throw T(`invalid npm registry response for '${t}': not parseable JSON`)}},ld=async(e,t)=>{let n=await e(`https://registry.npmjs.org/${ad(t)}`);if(n.status===404)throw C(`npm package '${t}' not found`);if(n.status!==200)throw T(`failed to fetch npm package '${t}': status ${n.status}`);let r=await cd(n,t),i=$u.safeParse(r);if(!i.success)throw T(`invalid npm package response for '${t}'`);return i.data},ud=(e,t)=>{try{return lu(e)}catch{throw nd(t)}},dd=async(e,t)=>{id(t);let n=await ld(e,t),r=od(n.repository);if(r===void 0||r===``)throw nd(t);let{cloneUrl:i,key:a}=ud(r,t),o=sd(n.repository);return o===void 0?{cloneUrl:i,key:a}:{cloneUrl:i,directory:o,key:a}};function q(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}const fd=(e,t)=>{let n=hd(pd(e));if(typeof n!=`string`)throw TypeError(`${t} must be a string or a file URL: ${n}.`);return n},pd=e=>md(e)?e.toString():e,md=e=>typeof e!=`string`&&e&&Object.getPrototypeOf(e)===String.prototype,hd=e=>e instanceof URL?ve(e):e,gd=(e,t=[],n={})=>{let r=fd(e,`First argument`),[i,a]=q(t)?[[],t]:[t,n];if(!Array.isArray(i))throw TypeError(`Second argument must be either an array of arguments or an options object: ${i}`);if(i.some(e=>typeof e==`object`&&!!e))throw TypeError(`Second argument must be an array of strings: ${i}`);let o=i.map(String),s=o.find(e=>e.includes(`\0`));if(s!==void 0)throw TypeError(`Arguments cannot contain null bytes ("\\0"): ${s}`);if(!q(a))throw TypeError(`Last argument must be an options object: ${a}`);return[r,o,a]},{toString:_d}=Object.prototype,vd=e=>_d.call(e)===`[object ArrayBuffer]`,J=e=>_d.call(e)===`[object Uint8Array]`,yd=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),bd=new TextEncoder,xd=e=>bd.encode(e),Sd=new TextDecoder,Cd=e=>Sd.decode(e),wd=(e,t)=>Td(e,t).join(``),Td=(e,t)=>{if(t===`utf8`&&e.every(e=>typeof e==`string`))return e;let n=new we(t),r=e.map(e=>typeof e==`string`?xd(e):e).map(e=>n.write(e)),i=n.end();return i===``?r:[...r,i]},Ed=e=>e.length===1&&J(e[0])?e[0]:Od(Dd(e)),Dd=e=>e.map(e=>typeof e==`string`?xd(e):e),Od=e=>{let t=new Uint8Array(kd(e)),n=0;for(let r of e)t.set(r,n),n+=r.length;return t},kd=e=>{let t=0;for(let n of e)t+=n.length;return t},Ad=e=>Array.isArray(e)&&Array.isArray(e.raw),jd=(e,t)=>{let n=[];for(let[r,i]of e.entries())n=Md({templates:e,expressions:t,tokens:n,index:r,template:i});if(n.length===0)throw TypeError(`Template script must not be empty`);let[r,...i]=n;return[r,i,{}]},Md=({templates:e,expressions:t,tokens:n,index:r,template:i})=>{if(i===void 0)throw TypeError(`Invalid backslash sequence: ${e.raw[r]}`);let{nextTokens:a,leadingWhitespaces:o,trailingWhitespaces:s}=Nd(i,e.raw[r]),c=Id(n,a,o);if(r===t.length)return c;let l=t[r],u=Array.isArray(l)?l.map(e=>Ld(e)):[Ld(l)];return Id(c,u,s)},Nd=(e,t)=>{if(t.length===0)return{nextTokens:[],leadingWhitespaces:!1,trailingWhitespaces:!1};let n=[],r=0,i=Pd.has(t[0]);for(let i=0,a=0;i<e.length;i+=1,a+=1){let o=t[a];if(Pd.has(o))r!==i&&n.push(e.slice(r,i)),r=i+1;else if(o===`\\`){let e=t[a+1];e===`
|
|
350
|
-
`?(--i,a+=1):e===`u`&&t[a+2]===`{`?a=t.indexOf(`}`,a+3):a+=Fd[e]??1}}let a=r===e.length;return a||n.push(e.slice(r)),{nextTokens:n,leadingWhitespaces:i,trailingWhitespaces:a}},Pd=new Set([` `,` `,`\r`,`
|
|
351
|
-
`]),Fd={x:3,u:5},Id=(e,t,n)=>n||e.length===0||t.length===0?[...e,...t]:[...e.slice(0,-1),`${e.at(-1)}${t[0]}`,...t.slice(1)],Ld=e=>{let t=typeof e;if(t===`string`)return e;if(t===`number`)return String(e);if(q(e)&&(`stdout`in e||`isMaxBuffer`in e))return Rd(e);throw e instanceof be||Object.prototype.toString.call(e)===`[object Promise]`?TypeError("Unexpected subprocess in template expression. Please use ${await subprocess} instead of ${subprocess}."):TypeError(`Unexpected "${t}" in template expression`)},Rd=({stdout:e})=>{if(typeof e==`string`)return e;if(J(e))return Cd(e);throw TypeError(e===void 0?`Missing result.stdout in template expression. This is probably due to the previous subprocess' "stdout" option.`:`Unexpected "${typeof e}" stdout in template expression`)},zd=e=>Bd.includes(e),Bd=[b.stdin,b.stdout,b.stderr],Y=[`stdin`,`stdout`,`stderr`],Vd=e=>Y[e]??`stdio[${e}]`,Hd=e=>{let t={...e};for(let n of ef)t[n]=Ud(e,n);return t},Ud=(e,t)=>{let n=Array.from({length:Wd(e)+1}),r=Gd(e[t],n,t);return Qd(r,t)},Wd=({stdio:e})=>Array.isArray(e)?Math.max(e.length,Y.length):Y.length,Gd=(e,t,n)=>q(e)?Kd(e,t,n):t.fill(e),Kd=(e,t,n)=>{for(let r of Object.keys(e).sort(qd))for(let i of Yd(r,n,t))t[i]=e[r];return t},qd=(e,t)=>Jd(e)<Jd(t)?1:-1,Jd=e=>e===`stdout`||e===`stderr`?0:e===`all`?2:1,Yd=(e,t,n)=>{if(e===`ipc`)return[n.length-1];let r=Xd(e);if(r===void 0||r===0)throw TypeError(`"${t}.${e}" is invalid.
|
|
352
|
-
It must be "${t}.stdout", "${t}.stderr", "${t}.all", "${t}.ipc", or "${t}.fd3", "${t}.fd4" (and so on).`);if(r>=n.length)throw TypeError(`"${t}.${e}" is invalid: that file descriptor does not exist.
|
|
353
|
-
Please set the "stdio" option to ensure that file descriptor exists.`);return r===`all`?[1,2]:[r]},Xd=e=>{if(e===`all`)return e;if(Y.includes(e))return Y.indexOf(e);let t=Zd.exec(e);if(t!==null)return Number(t[1])},Zd=/^fd(\d+)$/,Qd=(e,t)=>e.map(e=>e===void 0?$d[t]:e),$d={lines:!1,buffer:!0,maxBuffer:1e3*1e3*100,verbose:De(`execa`).enabled?`full`:`none`,stripFinalNewline:!0},ef=[`lines`,`buffer`,`maxBuffer`,`verbose`,`stripFinalNewline`],tf=(e,t)=>t===`ipc`?e.at(-1):e[t],nf=({verbose:e},t)=>of(e,t)!==`none`,rf=({verbose:e},t)=>![`none`,`short`].includes(of(e,t)),af=({verbose:e},t)=>{let n=of(e,t);return cf(n)?n:void 0},of=(e,t)=>t===void 0?sf(e):tf(e,t),sf=e=>e.find(e=>cf(e))??lf.findLast(t=>e.includes(t)),cf=e=>typeof e==`function`,lf=[`none`,`short`,`full`],uf=(e,t)=>{let n=[e,...t];return{command:n.join(` `),escapedCommand:n.map(e=>_f(ff(e))).join(` `)}},df=e=>Ae(e).split(`
|
|
354
|
-
`).map(e=>ff(e)).join(`
|
|
355
|
-
`),ff=e=>e.replaceAll(mf,e=>pf(e)),pf=e=>{let t=hf[e];if(t!==void 0)return t;let n=e.codePointAt(0),r=n.toString(16);return n<=gf?`\\u${r.padStart(4,`0`)}`:`\\U${r}`},mf=(()=>{try{return RegExp(`\\p{Separator}|\\p{Other}`,`gu`)}catch{return/[\s\u0000-\u001F\u007F-\u009F\u00AD]/g}})(),hf={" ":` `,"\b":`\\b`,"\f":`\\f`,"\n":`\\n`,"\r":`\\r`," ":`\\t`},gf=65535,_f=e=>vf.test(e)?e:Pe===`win32`?`"${e.replaceAll(`"`,`""`)}"`:`'${e.replaceAll(`'`,`'\\''`)}'`,vf=/^[\w./-]+$/;function yf(){let{env:e}=b,{TERM:t,TERM_PROGRAM:n}=e;return b.platform===`win32`?!!e.WT_SESSION||!!e.TERMINUS_SUBLIME||e.ConEmuTask===`{cmd::Cmder}`||n===`Terminus-Sublime`||n===`vscode`||t===`xterm-256color`||t===`alacritty`||t===`rxvt-unicode`||t===`rxvt-unicode-256color`||e.TERMINAL_EMULATOR===`JetBrains-JediTerm`:t!==`linux`}const bf={circleQuestionMark:`(?)`,questionMarkPrefix:`(?)`,square:`█`,squareDarkShade:`▓`,squareMediumShade:`▒`,squareLightShade:`░`,squareTop:`▀`,squareBottom:`▄`,squareLeft:`▌`,squareRight:`▐`,squareCenter:`■`,bullet:`●`,dot:`․`,ellipsis:`…`,pointerSmall:`›`,triangleUp:`▲`,triangleUpSmall:`▴`,triangleDown:`▼`,triangleDownSmall:`▾`,triangleLeftSmall:`◂`,triangleRightSmall:`▸`,home:`⌂`,heart:`♥`,musicNote:`♪`,musicNoteBeamed:`♫`,arrowUp:`↑`,arrowDown:`↓`,arrowLeft:`←`,arrowRight:`→`,arrowLeftRight:`↔`,arrowUpDown:`↕`,almostEqual:`≈`,notEqual:`≠`,lessOrEqual:`≤`,greaterOrEqual:`≥`,identical:`≡`,infinity:`∞`,subscriptZero:`₀`,subscriptOne:`₁`,subscriptTwo:`₂`,subscriptThree:`₃`,subscriptFour:`₄`,subscriptFive:`₅`,subscriptSix:`₆`,subscriptSeven:`₇`,subscriptEight:`₈`,subscriptNine:`₉`,oneHalf:`½`,oneThird:`⅓`,oneQuarter:`¼`,oneFifth:`⅕`,oneSixth:`⅙`,oneEighth:`⅛`,twoThirds:`⅔`,twoFifths:`⅖`,threeQuarters:`¾`,threeFifths:`⅗`,threeEighths:`⅜`,fourFifths:`⅘`,fiveSixths:`⅚`,fiveEighths:`⅝`,sevenEighths:`⅞`,line:`─`,lineBold:`━`,lineDouble:`═`,lineDashed0:`┄`,lineDashed1:`┅`,lineDashed2:`┈`,lineDashed3:`┉`,lineDashed4:`╌`,lineDashed5:`╍`,lineDashed6:`╴`,lineDashed7:`╶`,lineDashed8:`╸`,lineDashed9:`╺`,lineDashed10:`╼`,lineDashed11:`╾`,lineDashed12:`−`,lineDashed13:`–`,lineDashed14:`‐`,lineDashed15:`⁃`,lineVertical:`│`,lineVerticalBold:`┃`,lineVerticalDouble:`║`,lineVerticalDashed0:`┆`,lineVerticalDashed1:`┇`,lineVerticalDashed2:`┊`,lineVerticalDashed3:`┋`,lineVerticalDashed4:`╎`,lineVerticalDashed5:`╏`,lineVerticalDashed6:`╵`,lineVerticalDashed7:`╷`,lineVerticalDashed8:`╹`,lineVerticalDashed9:`╻`,lineVerticalDashed10:`╽`,lineVerticalDashed11:`╿`,lineDownLeft:`┐`,lineDownLeftArc:`╮`,lineDownBoldLeftBold:`┓`,lineDownBoldLeft:`┒`,lineDownLeftBold:`┑`,lineDownDoubleLeftDouble:`╗`,lineDownDoubleLeft:`╖`,lineDownLeftDouble:`╕`,lineDownRight:`┌`,lineDownRightArc:`╭`,lineDownBoldRightBold:`┏`,lineDownBoldRight:`┎`,lineDownRightBold:`┍`,lineDownDoubleRightDouble:`╔`,lineDownDoubleRight:`╓`,lineDownRightDouble:`╒`,lineUpLeft:`┘`,lineUpLeftArc:`╯`,lineUpBoldLeftBold:`┛`,lineUpBoldLeft:`┚`,lineUpLeftBold:`┙`,lineUpDoubleLeftDouble:`╝`,lineUpDoubleLeft:`╜`,lineUpLeftDouble:`╛`,lineUpRight:`└`,lineUpRightArc:`╰`,lineUpBoldRightBold:`┗`,lineUpBoldRight:`┖`,lineUpRightBold:`┕`,lineUpDoubleRightDouble:`╚`,lineUpDoubleRight:`╙`,lineUpRightDouble:`╘`,lineUpDownLeft:`┤`,lineUpBoldDownBoldLeftBold:`┫`,lineUpBoldDownBoldLeft:`┨`,lineUpDownLeftBold:`┥`,lineUpBoldDownLeftBold:`┩`,lineUpDownBoldLeftBold:`┪`,lineUpDownBoldLeft:`┧`,lineUpBoldDownLeft:`┦`,lineUpDoubleDownDoubleLeftDouble:`╣`,lineUpDoubleDownDoubleLeft:`╢`,lineUpDownLeftDouble:`╡`,lineUpDownRight:`├`,lineUpBoldDownBoldRightBold:`┣`,lineUpBoldDownBoldRight:`┠`,lineUpDownRightBold:`┝`,lineUpBoldDownRightBold:`┡`,lineUpDownBoldRightBold:`┢`,lineUpDownBoldRight:`┟`,lineUpBoldDownRight:`┞`,lineUpDoubleDownDoubleRightDouble:`╠`,lineUpDoubleDownDoubleRight:`╟`,lineUpDownRightDouble:`╞`,lineDownLeftRight:`┬`,lineDownBoldLeftBoldRightBold:`┳`,lineDownLeftBoldRightBold:`┯`,lineDownBoldLeftRight:`┰`,lineDownBoldLeftBoldRight:`┱`,lineDownBoldLeftRightBold:`┲`,lineDownLeftRightBold:`┮`,lineDownLeftBoldRight:`┭`,lineDownDoubleLeftDoubleRightDouble:`╦`,lineDownDoubleLeftRight:`╥`,lineDownLeftDoubleRightDouble:`╤`,lineUpLeftRight:`┴`,lineUpBoldLeftBoldRightBold:`┻`,lineUpLeftBoldRightBold:`┷`,lineUpBoldLeftRight:`┸`,lineUpBoldLeftBoldRight:`┹`,lineUpBoldLeftRightBold:`┺`,lineUpLeftRightBold:`┶`,lineUpLeftBoldRight:`┵`,lineUpDoubleLeftDoubleRightDouble:`╩`,lineUpDoubleLeftRight:`╨`,lineUpLeftDoubleRightDouble:`╧`,lineUpDownLeftRight:`┼`,lineUpBoldDownBoldLeftBoldRightBold:`╋`,lineUpDownBoldLeftBoldRightBold:`╈`,lineUpBoldDownLeftBoldRightBold:`╇`,lineUpBoldDownBoldLeftRightBold:`╊`,lineUpBoldDownBoldLeftBoldRight:`╉`,lineUpBoldDownLeftRight:`╀`,lineUpDownBoldLeftRight:`╁`,lineUpDownLeftBoldRight:`┽`,lineUpDownLeftRightBold:`┾`,lineUpBoldDownBoldLeftRight:`╂`,lineUpDownLeftBoldRightBold:`┿`,lineUpBoldDownLeftBoldRight:`╃`,lineUpBoldDownLeftRightBold:`╄`,lineUpDownBoldLeftBoldRight:`╅`,lineUpDownBoldLeftRightBold:`╆`,lineUpDoubleDownDoubleLeftDoubleRightDouble:`╬`,lineUpDoubleDownDoubleLeftRight:`╫`,lineUpDownLeftDoubleRightDouble:`╪`,lineCross:`╳`,lineBackslash:`╲`,lineSlash:`╱`},xf={tick:`✔`,info:`ℹ`,warning:`⚠`,cross:`✘`,squareSmall:`◻`,squareSmallFilled:`◼`,circle:`◯`,circleFilled:`◉`,circleDotted:`◌`,circleDouble:`◎`,circleCircle:`ⓞ`,circleCross:`ⓧ`,circlePipe:`Ⓘ`,radioOn:`◉`,radioOff:`◯`,checkboxOn:`☒`,checkboxOff:`☐`,checkboxCircleOn:`ⓧ`,checkboxCircleOff:`Ⓘ`,pointer:`❯`,triangleUpOutline:`△`,triangleLeft:`◀`,triangleRight:`▶`,lozenge:`◆`,lozengeOutline:`◇`,hamburger:`☰`,smiley:`㋡`,mustache:`෴`,star:`★`,play:`▶`,nodejs:`⬢`,oneSeventh:`⅐`,oneNinth:`⅑`,oneTenth:`⅒`},Sf={tick:`√`,info:`i`,warning:`‼`,cross:`×`,squareSmall:`□`,squareSmallFilled:`■`,circle:`( )`,circleFilled:`(*)`,circleDotted:`( )`,circleDouble:`( )`,circleCircle:`(○)`,circleCross:`(×)`,circlePipe:`(│)`,radioOn:`(*)`,radioOff:`( )`,checkboxOn:`[×]`,checkboxOff:`[ ]`,checkboxCircleOn:`(×)`,checkboxCircleOff:`( )`,pointer:`>`,triangleUpOutline:`∆`,triangleLeft:`◄`,triangleRight:`►`,lozenge:`♦`,lozengeOutline:`◊`,hamburger:`≡`,smiley:`☺`,mustache:`┌─┐`,star:`✶`,play:`►`,nodejs:`♦`,oneSeventh:`1/7`,oneNinth:`1/9`,oneTenth:`1/10`},Cf={...bf,...xf},wf={...bf,...Sf},Tf=yf()?Cf:wf;Object.entries(xf);const Ef=Fe?.WriteStream?.prototype?.hasColors?.()??!1,X=(e,t)=>{if(!Ef)return e=>e;let n=`\u001B[${e}m`,r=`\u001B[${t}m`;return e=>{let i=e+``,a=i.indexOf(r);if(a===-1)return n+i+r;let o=n,s=0,c=(t===22?r:``)+n;for(;a!==-1;)o+=i.slice(s,a)+c,s=a+r.length,a=i.indexOf(r,s);return o+=i.slice(s)+r,o}};X(0,0);const Df=X(1,22);X(2,22),X(3,23),X(4,24),X(53,55),X(7,27),X(8,28),X(9,29),X(30,39),X(31,39),X(32,39),X(33,39),X(34,39),X(35,39),X(36,39),X(37,39);const Of=X(90,39);X(40,49),X(41,49),X(42,49),X(43,49),X(44,49),X(45,49),X(46,49),X(47,49),X(100,49);const kf=X(91,39);X(92,39);const Af=X(93,39);X(94,39),X(95,39),X(96,39),X(97,39),X(101,49),X(102,49),X(103,49),X(104,49),X(105,49),X(106,49),X(107,49);const jf=({type:e,message:t,timestamp:n,piped:r,commandId:i,result:{failed:a=!1}={},options:{reject:o=!0}})=>{let s=Mf(n),c=Ff[e]({failed:a,reject:o,piped:r}),l=Lf[e]({reject:o});return`${Of(`[${s}]`)} ${Of(`[${i}]`)} ${l(c)} ${l(t)}`},Mf=e=>`${Nf(e.getHours(),2)}:${Nf(e.getMinutes(),2)}:${Nf(e.getSeconds(),2)}.${Nf(e.getMilliseconds(),3)}`,Nf=(e,t)=>String(e).padStart(t,`0`),Pf=({failed:e,reject:t})=>e?t?Tf.cross:Tf.warning:Tf.tick,Ff={command:({piped:e})=>e?`|`:`$`,output:()=>` `,ipc:()=>`*`,error:Pf,duration:Pf},If=e=>e,Lf={command:()=>Df,output:()=>If,ipc:()=>If,error:({reject:e})=>e?kf:Af,duration:()=>Of},Rf=(e,t,n)=>{let r=af(t,n);return e.map(({verboseLine:e,verboseObject:t})=>zf(e,t,r)).filter(e=>e!==void 0).map(e=>Bf(e)).join(``)},zf=(e,t,n)=>{if(n===void 0)return e;let r=n(e,t);if(typeof r==`string`)return r},Bf=e=>e.endsWith(`
|
|
356
|
-
`)?e:`${e}\n`,Vf=({type:e,verboseMessage:t,fdNumber:n,verboseInfo:r,result:i})=>{let a=Hf({type:e,result:i,verboseInfo:r}),o=Rf(Uf(t,a),r,n);o!==``&&console.warn(o.slice(0,-1))},Hf=({type:e,result:t,verboseInfo:{escapedCommand:n,commandId:r,rawOptions:{piped:i=!1,...a}}})=>({type:e,escapedCommand:n,commandId:`${r}`,timestamp:new Date,piped:i,result:t,options:a}),Uf=(e,t)=>e.split(`
|
|
357
|
-
`).map(e=>Wf({...t,message:e})),Wf=e=>({verboseLine:jf(e),verboseObject:e}),Gf=e=>df(typeof e==`string`?e:Oe(e)).replaceAll(` `,` `.repeat(Kf)),Kf=2,qf=(e,t)=>{nf(t)&&Vf({type:`command`,verboseMessage:e,verboseInfo:t})},Jf=(e,t,n)=>(Zf(e),{verbose:e,escapedCommand:t,commandId:Yf(e),rawOptions:n}),Yf=e=>nf({verbose:e})?Xf++:void 0;let Xf=0n;const Zf=e=>{for(let t of e){if(t===!1)throw TypeError(`The "verbose: false" option was renamed to "verbose: 'none'".`);if(t===!0)throw TypeError(`The "verbose: true" option was renamed to "verbose: 'short'".`);if(!lf.includes(t)&&!cf(t)){let e=lf.map(e=>`'${e}'`).join(`, `);throw TypeError(`The "verbose" option must not be ${t}. Allowed values are: ${e} or a function.`)}}},Qf=()=>Ne.bigint(),$f=e=>Number(Ne.bigint()-e)/1e6,ep=(e,t,n)=>{let r=Qf(),{command:i,escapedCommand:a}=uf(e,t),o=Jf(Ud(n,`verbose`),a,{...n});return qf(a,o),{command:i,escapedCommand:a,startTime:r,verboseInfo:o}};var tp=S(((e,t)=>{t.exports=a,a.sync=o;var n=rt(`fs`);function r(e,t){var n=t.pathExt===void 0?process.env.PATHEXT:t.pathExt;if(!n||(n=n.split(`;`),n.indexOf(``)!==-1))return!0;for(var r=0;r<n.length;r++){var i=n[r].toLowerCase();if(i&&e.substr(-i.length).toLowerCase()===i)return!0}return!1}function i(e,t,n){return!e.isSymbolicLink()&&!e.isFile()?!1:r(t,n)}function a(e,t,r){n.stat(e,function(n,a){r(n,n?!1:i(a,e,t))})}function o(e,t){return i(n.statSync(e),e,t)}})),np=S(((e,t)=>{t.exports=r,r.sync=i;var n=rt(`fs`);function r(e,t,r){n.stat(e,function(e,n){r(e,e?!1:a(n,t))})}function i(e,t){return a(n.statSync(e),t)}function a(e,t){return e.isFile()&&o(e,t)}function o(e,t){var n=e.mode,r=e.uid,i=e.gid,a=t.uid===void 0?process.getuid&&process.getuid():t.uid,o=t.gid===void 0?process.getgid&&process.getgid():t.gid,s=64,c=8,l=1,u=s|c;return n&l||n&c&&i===o||n&s&&r===a||n&u&&a===0}})),rp=S(((e,t)=>{rt(`fs`);var n=process.platform===`win32`||global.TESTING_WINDOWS?tp():np();t.exports=r,r.sync=i;function r(e,t,i){if(typeof t==`function`&&(i=t,t={}),!i){if(typeof Promise!=`function`)throw TypeError(`callback not provided`);return new Promise(function(n,i){r(e,t||{},function(e,t){e?i(e):n(t)})})}n(e,t||{},function(e,n){e&&(e.code===`EACCES`||t&&t.ignoreErrors)&&(e=null,n=!1),i(e,n)})}function i(e,t){try{return n.sync(e,t||{})}catch(e){if(t&&t.ignoreErrors||e.code===`EACCES`)return!1;throw e}}})),ip=S(((e,t)=>{let n=process.platform===`win32`||process.env.OSTYPE===`cygwin`||process.env.OSTYPE===`msys`,r=rt(`path`),i=n?`;`:`:`,a=rp(),o=e=>Object.assign(Error(`not found: ${e}`),{code:`ENOENT`}),s=(e,t)=>{let r=t.colon||i,a=e.match(/\//)||n&&e.match(/\\/)?[``]:[...n?[process.cwd()]:[],...(t.path||process.env.PATH||``).split(r)],o=n?t.pathExt||process.env.PATHEXT||`.EXE;.CMD;.BAT;.COM`:``,s=n?o.split(r):[``];return n&&e.indexOf(`.`)!==-1&&s[0]!==``&&s.unshift(``),{pathEnv:a,pathExt:s,pathExtExe:o}},c=(e,t,n)=>{typeof t==`function`&&(n=t,t={}),t||={};let{pathEnv:i,pathExt:c,pathExtExe:l}=s(e,t),u=[],d=n=>new Promise((a,s)=>{if(n===i.length)return t.all&&u.length?a(u):s(o(e));let c=i[n],l=/^".*"$/.test(c)?c.slice(1,-1):c,d=r.join(l,e),p=!l&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d;a(f(p,n,0))}),f=(e,n,r)=>new Promise((i,o)=>{if(r===c.length)return i(d(n+1));let s=c[r];a(e+s,{pathExt:l},(a,o)=>{if(!a&&o)if(t.all)u.push(e+s);else return i(e+s);return i(f(e,n,r+1))})});return n?d(0).then(e=>n(null,e),n):d(0)};t.exports=c,c.sync=(e,t)=>{t||={};let{pathEnv:n,pathExt:i,pathExtExe:c}=s(e,t),l=[];for(let o=0;o<n.length;o++){let s=n[o],u=/^".*"$/.test(s)?s.slice(1,-1):s,d=r.join(u,e),f=!u&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d;for(let e=0;e<i.length;e++){let n=f+i[e];try{if(a.sync(n,{pathExt:c}))if(t.all)l.push(n);else return n}catch{}}}if(t.all&&l.length)return l;if(t.nothrow)return null;throw o(e)}})),ap=S(((e,t)=>{let n=(e={})=>{let t=e.env||process.env;return(e.platform||process.platform)===`win32`?Object.keys(t).reverse().find(e=>e.toUpperCase()===`PATH`)||`Path`:`PATH`};t.exports=n,t.exports.default=n})),op=S(((e,t)=>{let n=rt(`path`),r=ip(),i=ap();function a(e,t){let a=e.options.env||process.env,o=process.cwd(),s=e.options.cwd!=null,c=s&&process.chdir!==void 0&&!process.chdir.disabled;if(c)try{process.chdir(e.options.cwd)}catch{}let l;try{l=r.sync(e.command,{path:a[i({env:a})],pathExt:t?n.delimiter:void 0})}catch{}finally{c&&process.chdir(o)}return l&&=n.resolve(s?e.options.cwd:``,l),l}function o(e){return a(e)||a(e,!0)}t.exports=o})),sp=S(((e,t)=>{let n=/([()\][%!^"`<>&|;, *?])/g;function r(e){return e=e.replace(n,`^$1`),e}function i(e,t){return e=`${e}`,e=e.replace(/(?=(\\+?)?)\1"/g,`$1$1\\"`),e=e.replace(/(?=(\\+?)?)\1$/,`$1$1`),e=`"${e}"`,e=e.replace(n,`^$1`),t&&(e=e.replace(n,`^$1`)),e}t.exports.command=r,t.exports.argument=i})),cp=S(((e,t)=>{t.exports=/^#!(.*)/})),lp=S(((e,t)=>{let n=cp();t.exports=(e=``)=>{let t=e.match(n);if(!t)return null;let[r,i]=t[0].replace(/#! ?/,``).split(` `),a=r.split(`/`).pop();return a===`env`?i:i?`${a} ${i}`:a}})),up=S(((e,t)=>{let n=rt(`fs`),r=lp();function i(e){let t=Buffer.alloc(150),i;try{i=n.openSync(e,`r`),n.readSync(i,t,0,150,0),n.closeSync(i)}catch{}return r(t.toString())}t.exports=i})),dp=S(((e,t)=>{let n=rt(`path`),r=op(),i=sp(),a=up(),o=process.platform===`win32`,s=/\.(?:com|exe)$/i,c=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function l(e){e.file=r(e);let t=e.file&&a(e.file);return t?(e.args.unshift(e.file),e.command=t,r(e)):e.file}function u(e){if(!o)return e;let t=l(e),r=!s.test(t);if(e.options.forceShell||r){let r=c.test(t);e.command=n.normalize(e.command),e.command=i.command(e.command),e.args=e.args.map(e=>i.argument(e,r)),e.args=[`/d`,`/s`,`/c`,`"${[e.command].concat(e.args).join(` `)}"`],e.command=process.env.comspec||`cmd.exe`,e.options.windowsVerbatimArguments=!0}return e}function d(e,t,n){t&&!Array.isArray(t)&&(n=t,t=null),t=t?t.slice(0):[],n=Object.assign({},n);let r={command:e,args:t,options:n,file:void 0,original:{command:e,args:t}};return n.shell?r:u(r)}t.exports=d})),fp=S(((e,t)=>{let n=process.platform===`win32`;function r(e,t){return Object.assign(Error(`${t} ${e.command} ENOENT`),{code:`ENOENT`,errno:`ENOENT`,syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function i(e,t){if(!n)return;let r=e.emit;e.emit=function(n,i){if(n===`exit`){let n=a(i,t);if(n)return r.call(e,`error`,n)}return r.apply(e,arguments)}}function a(e,t){return n&&e===1&&!t.file?r(t.original,`spawn`):null}function o(e,t){return n&&e===1&&!t.file?r(t.original,`spawnSync`):null}t.exports={hookChildProcess:i,verifyENOENT:a,verifyENOENTSync:o,notFoundError:r}})),pp=nt(S(((e,t)=>{let n=rt(`child_process`),r=dp(),i=fp();function a(e,t,a){let o=r(e,t,a),s=n.spawn(o.command,o.args,o.options);return i.hookChildProcess(s,o),s}function o(e,t,a){let o=r(e,t,a),s=n.spawnSync(o.command,o.args,o.options);return s.error=s.error||i.verifyENOENTSync(s.status,o),s}t.exports=a,t.exports.spawn=a,t.exports.sync=o,t.exports._parse=r,t.exports._enoent=i}))(),1);function mp(e={}){let{env:t=process.env,platform:n=process.platform}=e;return n===`win32`?Object.keys(t).reverse().find(e=>e.toUpperCase()===`PATH`)||`Path`:`PATH`}ke(xe);function hp(e){return e instanceof URL?ve(e):e}function gp(e){return{*[Symbol.iterator](){let t=h.resolve(hp(e)),n;for(;n!==t;)yield t,n=t,t=h.resolve(t,`..`)}}}const _p=({cwd:e=b.cwd(),path:t=b.env[mp()],preferLocal:n=!0,execPath:r=b.execPath,addExecPath:i=!0}={})=>{let a=h.resolve(hp(e)),o=[],s=t.split(h.delimiter);return n&&vp(o,s,a),i&&yp(o,s,r,a),t===``||t===h.delimiter?`${o.join(h.delimiter)}${t}`:[...o,t].join(h.delimiter)},vp=(e,t,n)=>{for(let r of gp(n)){let n=h.join(r,`node_modules/.bin`);t.includes(n)||e.push(n)}},yp=(e,t,n,r)=>{let i=h.resolve(r,hp(n),`..`);t.includes(i)||e.push(i)},bp=({env:e=b.env,...t}={})=>{e={...e};let n=mp({env:e});return t.path=e[n],e[n]=_p(t),e},xp=(e,t,n)=>new(n?Op:Dp)(t,e instanceof Sp?{}:{cause:e});var Sp=class extends Error{};const Cp=(e,t)=>{Object.defineProperty(e.prototype,"name",{value:t,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,Tp,{value:!0,writable:!1,enumerable:!1,configurable:!1})},wp=e=>Ep(e)&&Tp in e,Tp=Symbol(`isExecaError`),Ep=e=>Object.prototype.toString.call(e)===`[object Error]`;var Dp=class extends Error{};Cp(Dp,Dp.name);var Op=class extends Error{};Cp(Op,Op.name);const kp=()=>{let e=64-jp+1;return Array.from({length:e},Ap)},Ap=(e,t)=>({name:`SIGRT${t+1}`,number:jp+t,action:`terminate`,description:`Application-specific signal (realtime)`,standard:`posix`}),jp=34,Mp=[{name:`SIGHUP`,number:1,action:`terminate`,description:`Terminal closed`,standard:`posix`},{name:`SIGINT`,number:2,action:`terminate`,description:`User interruption with CTRL-C`,standard:`ansi`},{name:`SIGQUIT`,number:3,action:`core`,description:`User interruption with CTRL-\\`,standard:`posix`},{name:`SIGILL`,number:4,action:`core`,description:`Invalid machine instruction`,standard:`ansi`},{name:`SIGTRAP`,number:5,action:`core`,description:`Debugger breakpoint`,standard:`posix`},{name:`SIGABRT`,number:6,action:`core`,description:`Aborted`,standard:`ansi`},{name:`SIGIOT`,number:6,action:`core`,description:`Aborted`,standard:`bsd`},{name:`SIGBUS`,number:7,action:`core`,description:`Bus error due to misaligned, non-existing address or paging error`,standard:`bsd`},{name:`SIGEMT`,number:7,action:`terminate`,description:`Command should be emulated but is not implemented`,standard:`other`},{name:`SIGFPE`,number:8,action:`core`,description:`Floating point arithmetic error`,standard:`ansi`},{name:`SIGKILL`,number:9,action:`terminate`,description:`Forced termination`,standard:`posix`,forced:!0},{name:`SIGUSR1`,number:10,action:`terminate`,description:`Application-specific signal`,standard:`posix`},{name:`SIGSEGV`,number:11,action:`core`,description:`Segmentation fault`,standard:`ansi`},{name:`SIGUSR2`,number:12,action:`terminate`,description:`Application-specific signal`,standard:`posix`},{name:`SIGPIPE`,number:13,action:`terminate`,description:`Broken pipe or socket`,standard:`posix`},{name:`SIGALRM`,number:14,action:`terminate`,description:`Timeout or timer`,standard:`posix`},{name:`SIGTERM`,number:15,action:`terminate`,description:`Termination`,standard:`ansi`},{name:`SIGSTKFLT`,number:16,action:`terminate`,description:`Stack is empty or overflowed`,standard:`other`},{name:`SIGCHLD`,number:17,action:`ignore`,description:`Child process terminated, paused or unpaused`,standard:`posix`},{name:`SIGCLD`,number:17,action:`ignore`,description:`Child process terminated, paused or unpaused`,standard:`other`},{name:`SIGCONT`,number:18,action:`unpause`,description:`Unpaused`,standard:`posix`,forced:!0},{name:`SIGSTOP`,number:19,action:`pause`,description:`Paused`,standard:`posix`,forced:!0},{name:`SIGTSTP`,number:20,action:`pause`,description:`Paused using CTRL-Z or "suspend"`,standard:`posix`},{name:`SIGTTIN`,number:21,action:`pause`,description:`Background process cannot read terminal input`,standard:`posix`},{name:`SIGBREAK`,number:21,action:`terminate`,description:`User interruption with CTRL-BREAK`,standard:`other`},{name:`SIGTTOU`,number:22,action:`pause`,description:`Background process cannot write to terminal output`,standard:`posix`},{name:`SIGURG`,number:23,action:`ignore`,description:`Socket received out-of-band data`,standard:`bsd`},{name:`SIGXCPU`,number:24,action:`core`,description:`Process timed out`,standard:`bsd`},{name:`SIGXFSZ`,number:25,action:`core`,description:`File too big`,standard:`bsd`},{name:`SIGVTALRM`,number:26,action:`terminate`,description:`Timeout or timer`,standard:`bsd`},{name:`SIGPROF`,number:27,action:`terminate`,description:`Timeout or timer`,standard:`bsd`},{name:`SIGWINCH`,number:28,action:`ignore`,description:`Terminal window size changed`,standard:`bsd`},{name:`SIGIO`,number:29,action:`terminate`,description:`I/O is available`,standard:`other`},{name:`SIGPOLL`,number:29,action:`terminate`,description:`Watched event`,standard:`other`},{name:`SIGINFO`,number:29,action:`ignore`,description:`Request for process information`,standard:`other`},{name:`SIGPWR`,number:30,action:`terminate`,description:`Device running out of power`,standard:`systemv`},{name:`SIGSYS`,number:31,action:`core`,description:`Invalid system call`,standard:`other`},{name:`SIGUNUSED`,number:31,action:`terminate`,description:`Invalid system call`,standard:`other`}],Np=()=>{let e=kp();return[...Mp,...e].map(Pp)},Pp=({name:e,number:t,description:n,action:r,forced:i=!1,standard:a})=>{let{signals:{[e]:o}}=pe,s=o!==void 0;return{name:e,number:s?o:t,description:n,supported:s,action:r,forced:i,standard:a}},Fp=()=>{let e=Np();return Object.fromEntries(e.map(Ip))},Ip=({name:e,number:t,description:n,supported:r,action:i,forced:a,standard:o})=>[e,{name:e,number:t,description:n,supported:r,action:i,forced:a,standard:o}],Lp=Fp(),Rp=()=>{let e=Np(),t=Array.from({length:65},(t,n)=>zp(n,e));return Object.assign({},...t)},zp=(e,t)=>{let n=Bp(e,t);if(n===void 0)return{};let{name:r,description:i,supported:a,action:o,forced:s,standard:c}=n;return{[e]:{name:r,number:e,description:i,supported:a,action:o,forced:s,standard:c}}},Bp=(e,t)=>{let n=t.find(({name:t})=>pe.signals[t]===e);return n===void 0?t.find(t=>t.number===e):n};Rp();const Vp=e=>{let t="option `killSignal`";if(e===0)throw TypeError(`Invalid ${t}: 0 cannot be used.`);return Up(e,t)},Hp=e=>e===0?e:Up(e,"`subprocess.kill()`'s argument"),Up=(e,t)=>{if(Number.isInteger(e))return Wp(e,t);if(typeof e==`string`)return Kp(e,t);throw TypeError(`Invalid ${t} ${String(e)}: it must be a string or an integer.\n${qp()}`)},Wp=(e,t)=>{if(Gp.has(e))return Gp.get(e);throw TypeError(`Invalid ${t} ${e}: this signal integer does not exist.\n${qp()}`)},Gp=new Map(Object.entries(pe.signals).reverse().map(([e,t])=>[t,e])),Kp=(e,t)=>{if(e in pe.signals)return e;throw e.toUpperCase()in pe.signals?TypeError(`Invalid ${t} '${e}': please rename it to '${e.toUpperCase()}'.`):TypeError(`Invalid ${t} '${e}': this signal name does not exist.\n${qp()}`)},qp=()=>`Available signal names: ${Jp()}.
|
|
358
|
-
Available signal numbers: ${Yp()}.`,Jp=()=>Object.keys(pe.signals).sort().map(e=>`'${e}'`).join(`, `),Yp=()=>[...new Set(Object.values(pe.signals).sort((e,t)=>e-t))].join(`, `),Xp=e=>Lp[e].description,Zp=e=>{if(e===!1)return e;if(e===!0)return Qp;if(!Number.isFinite(e)||e<0)throw TypeError(`Expected the \`forceKillAfterDelay\` option to be a non-negative integer, got \`${e}\` (${typeof e})`);return e},Qp=1e3*5,$p=({kill:e,options:{forceKillAfterDelay:t,killSignal:n},onInternalError:r,context:i,controller:a},o,s)=>{let{signal:c,error:l}=em(o,s,n);tm(l,r);let u=e(c);return nm({kill:e,signal:c,forceKillAfterDelay:t,killSignal:n,killResult:u,context:i,controller:a}),u},em=(e,t,n)=>{let[r=n,i]=Ep(e)?[void 0,e]:[e,t];if(typeof r!=`string`&&!Number.isInteger(r))throw TypeError(`The first argument must be an error instance or a signal name string/integer: ${String(r)}`);if(i!==void 0&&!Ep(i))throw TypeError(`The second argument is optional. If specified, it must be an error instance: ${i}`);return{signal:Hp(r),error:i}},tm=(e,t)=>{e!==void 0&&t.reject(e)},nm=async({kill:e,signal:t,forceKillAfterDelay:n,killSignal:r,killResult:i,context:a,controller:o})=>{t===r&&i&&rm({kill:e,forceKillAfterDelay:n,context:a,controllerSignal:o.signal})},rm=async({kill:e,forceKillAfterDelay:t,context:n,controllerSignal:r})=>{if(t!==!1)try{await _e(t,void 0,{signal:r}),e(`SIGKILL`)&&(n.isForcefullyTerminated??=!0)}catch{}},im=async(e,t)=>{e.aborted||await x(e,`abort`,{signal:t})},am=({cancelSignal:e})=>{if(e!==void 0&&Object.prototype.toString.call(e)!==`[object AbortSignal]`)throw Error(`The \`cancelSignal\` option must be an AbortSignal: ${String(e)}`)},om=({subprocess:e,cancelSignal:t,gracefulCancel:n,context:r,controller:i})=>t===void 0||n?[]:[sm(e,t,r,i)],sm=async(e,t,n,{signal:r})=>{throw await im(t,r),n.terminationReason??=`cancel`,e.kill(),t.reason},cm=({methodName:e,isSubprocess:t,ipc:n,isConnected:r})=>{lm(e,t,n),um(e,t,r)},lm=(e,t,n)=>{if(!n)throw Error(`${Z(e,t)} can only be used if the \`ipc\` option is \`true\`.`)},um=(e,t,n)=>{if(!n)throw Error(`${Z(e,t)} cannot be used: the ${wm(t)} has already exited or disconnected.`)},dm=e=>{throw Error(`${Z(`getOneMessage`,e)} could not complete: the ${wm(e)} exited or disconnected.`)},fm=e=>{throw Error(`${Z(`sendMessage`,e)} failed: the ${wm(e)} is sending a message too, instead of listening to incoming messages.
|
|
359
|
-
This can be fixed by both sending a message and listening to incoming messages at the same time:
|
|
47
|
+
const printSourceLoadFailure = (error) => {
|
|
48
|
+
const [firstLine = ''] = error.message.split('\n');
|
|
49
|
+
console.error(`refs could not run from source (${error.code}: ${firstLine})`);
|
|
50
|
+
console.error('Run: pnpm install && pnpm build');
|
|
51
|
+
};
|
|
360
52
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
53
|
+
// Imports the two source modules the dev fallback needs. Split out of loadFromSource so the
|
|
54
|
+
// narrow try/catch around the import calls stays isolated: a module-loading failure here gets
|
|
55
|
+
// an actionable message, while a failure from actually running the CLI (see the bottom of this
|
|
56
|
+
// file) must keep propagating unchanged.
|
|
57
|
+
const importSourceModules = async (srcMain) => {
|
|
58
|
+
try {
|
|
59
|
+
const { run } = await import(pathToFileURL(srcMain).href);
|
|
60
|
+
const { realContext } = await import(
|
|
61
|
+
pathToFileURL(join(import.meta.dirname, '../src/context.ts')).href
|
|
62
|
+
);
|
|
63
|
+
return { realContext, run };
|
|
64
|
+
} catch (error) {
|
|
65
|
+
if (!isSourceLoadError(error)) {
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
printSourceLoadFailure(error);
|
|
69
|
+
process.exit(EXIT_FAILURE);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
374
72
|
|
|
375
|
-
|
|
376
|
-
`):h_(e),h_=e=>typeof e==`string`?e:J(e)?Cd(e):``,g_=({command:e,escapedCommand:t,stdio:n,all:r,ipcOutput:i,options:{cwd:a},startTime:o})=>b_({command:e,escapedCommand:t,cwd:a,durationMs:$f(o),failed:!1,timedOut:!1,isCanceled:!1,isGracefullyCanceled:!1,isTerminated:!1,isMaxBuffer:!1,isForcefullyTerminated:!1,exitCode:0,stdout:n[1],stderr:n[2],all:r,stdio:n,ipcOutput:i,pipedFrom:[]}),__=({error:e,command:t,escapedCommand:n,fileDescriptors:r,options:i,startTime:a,isSync:o})=>v_({error:e,command:t,escapedCommand:n,startTime:a,timedOut:!1,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:!1,isForcefullyTerminated:!1,stdio:Array.from({length:r.length}),ipcOutput:[],options:i,isSync:o}),v_=({error:e,command:t,escapedCommand:n,startTime:r,timedOut:i,isCanceled:a,isGracefullyCanceled:o,isMaxBuffer:s,isForcefullyTerminated:c,exitCode:l,signal:u,stdio:d,all:f,ipcOutput:p,options:{timeoutDuration:m,timeout:h=m,forceKillAfterDelay:g,killSignal:_,cwd:v,maxBuffer:y},isSync:ee})=>{let{exitCode:te,signal:ne,signalDescription:re}=x_(l,u),{originalMessage:ie,shortMessage:ae,message:oe}=l_({stdio:d,all:f,ipcOutput:p,originalError:e,signal:ne,signalDescription:re,exitCode:te,escapedCommand:n,timedOut:i,isCanceled:a,isGracefullyCanceled:o,isMaxBuffer:s,isForcefullyTerminated:c,forceKillAfterDelay:g,killSignal:_,maxBuffer:y,timeout:h,cwd:v}),se=xp(e,oe,ee);return Object.assign(se,y_({error:se,command:t,escapedCommand:n,startTime:r,timedOut:i,isCanceled:a,isGracefullyCanceled:o,isMaxBuffer:s,isForcefullyTerminated:c,exitCode:te,signal:ne,signalDescription:re,stdio:d,all:f,ipcOutput:p,cwd:v,originalMessage:ie,shortMessage:ae})),se},y_=({error:e,command:t,escapedCommand:n,startTime:r,timedOut:i,isCanceled:a,isGracefullyCanceled:o,isMaxBuffer:s,isForcefullyTerminated:c,exitCode:l,signal:u,signalDescription:d,stdio:f,all:p,ipcOutput:m,cwd:h,originalMessage:g,shortMessage:_})=>b_({shortMessage:_,originalMessage:g,command:t,escapedCommand:n,cwd:h,durationMs:$f(r),failed:!0,timedOut:i,isCanceled:a,isGracefullyCanceled:o,isTerminated:u!==void 0,isMaxBuffer:s,isForcefullyTerminated:c,exitCode:l,signal:u,signalDescription:d,code:e.cause?.code,stdout:f[1],stderr:f[2],all:p,stdio:f,ipcOutput:m,pipedFrom:[]}),b_=e=>Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0)),x_=(e,t)=>{let n=e===null?void 0:e,r=t===null?void 0:t;return{exitCode:n,signal:r,signalDescription:r===void 0?void 0:Xp(t)}},S_=e=>Number.isFinite(e)?e:0;function C_(e){return{days:Math.trunc(e/864e5),hours:Math.trunc(e/36e5%24),minutes:Math.trunc(e/6e4%60),seconds:Math.trunc(e/1e3%60),milliseconds:Math.trunc(e%1e3),microseconds:Math.trunc(S_(e*1e3)%1e3),nanoseconds:Math.trunc(S_(e*1e6)%1e3)}}function w_(e){return{days:e/86400000n,hours:e/3600000n%24n,minutes:e/60000n%60n,seconds:e/1000n%60n,milliseconds:e%1000n,microseconds:0n,nanoseconds:0n}}function T_(e){switch(typeof e){case`number`:if(Number.isFinite(e))return C_(e);break;case`bigint`:return w_(e)}throw TypeError(`Expected a finite number or bigint`)}const E_=e=>e===0||e===0n,D_=(e,t)=>t===1||t===1n?e:`${e}s`,O_=24n*60n*60n*1000n;function k_(e,t){let n=typeof e==`bigint`;if(!n&&!Number.isFinite(e))throw TypeError(`Expected a finite number or bigint`);t={...t};let r=e<0?`-`:``;e=e<0?-e:e,t.colonNotation&&(t.compact=!1,t.formatSubMilliseconds=!1,t.separateMilliseconds=!1,t.verbose=!1),t.compact&&(t.unitCount=1,t.secondsDecimalDigits=0,t.millisecondsDecimalDigits=0);let i=[],a=(e,t)=>{let n=Math.floor(e*10**t+1e-7);return(Math.round(n)/10**t).toFixed(t)},o=(e,n,r,a)=>{if(!((i.length===0||!t.colonNotation)&&E_(e)&&!(t.colonNotation&&r===`m`))){if(a??=String(e),t.colonNotation){let e=a.includes(`.`)?a.split(`.`)[0].length:a.length,t=i.length>0?2:1;a=`0`.repeat(Math.max(0,t-e))+a}else a+=t.verbose?` `+D_(n,e):r;i.push(a)}},s=T_(e),c=BigInt(s.days);if(t.hideYearAndDays?o(BigInt(c)*24n+BigInt(s.hours),`hour`,`h`):(t.hideYear?o(c,`day`,`d`):(o(c/365n,`year`,`y`),o(c%365n,`day`,`d`)),o(Number(s.hours),`hour`,`h`)),o(Number(s.minutes),`minute`,`m`),!t.hideSeconds)if(t.separateMilliseconds||t.formatSubMilliseconds||!t.colonNotation&&e<1e3&&!t.subSecondsAsDecimals){let e=Number(s.seconds),n=Number(s.milliseconds),r=Number(s.microseconds),i=Number(s.nanoseconds);if(o(e,`second`,`s`),t.formatSubMilliseconds)o(n,`millisecond`,`ms`),o(r,`microsecond`,`µs`),o(i,`nanosecond`,`ns`);else{let e=n+r/1e3+i/1e6,a=typeof t.millisecondsDecimalDigits==`number`?t.millisecondsDecimalDigits:0,s=a?e.toFixed(a):e>=1?Math.round(e):Math.ceil(e);o(Number.parseFloat(s),`millisecond`,`ms`,s)}}else{let r=a((n?Number(e%O_):e)/1e3%60,typeof t.secondsDecimalDigits==`number`?t.secondsDecimalDigits:1),i=t.keepDecimalsOnWholeSeconds?r:r.replace(/\.0+$/,``);o(Number.parseFloat(i),`second`,`s`,i)}if(i.length===0)return r+`0`+(t.verbose?` milliseconds`:`ms`);let l=t.colonNotation?`:`:` `;return typeof t.unitCount==`number`&&(i=i.slice(0,Math.max(t.unitCount,1))),r+i.join(l)}const A_=(e,t)=>{e.failed&&Vf({type:`error`,verboseMessage:e.shortMessage,verboseInfo:t,result:e})},j_=(e,t)=>{nf(t)&&(A_(e,t),M_(e,t))},M_=(e,t)=>{Vf({type:`duration`,verboseMessage:`(done in ${k_(e.durationMs)})`,verboseInfo:t,result:e})},N_=(e,t,{reject:n})=>{if(j_(e,t),e.failed&&n)throw e;return e},P_=(e,t)=>U_(e)?`asyncGenerator`:W_(e)?`generator`:K_(e)?`fileUrl`:J_(e)?`filePath`:tv(e)?`webStream`:og(e,{checkOpen:!1})?`native`:J(e)?`uint8Array`:rv(e)?`asyncIterable`:iv(e)?`iterable`:nv(e)?L_({transform:e},t):G_(e)?F_(e,t):`native`,F_=(e,t)=>lg(e.transform,{checkOpen:!1})?I_(e,t):nv(e.transform)?L_(e,t):B_(e,t),I_=(e,t)=>(R_(e,t,`Duplex stream`),`duplex`),L_=(e,t)=>(R_(e,t,`web TransformStream`),`webTransform`),R_=({final:e,binary:t,objectMode:n},r,i)=>{z_(e,`${r}.final`,i),z_(t,`${r}.binary`,i),V_(n,`${r}.objectMode`)},z_=(e,t,n)=>{if(e!==void 0)throw TypeError(`The \`${t}\` option can only be defined when using a generator, not a ${n}.`)},B_=({transform:e,final:t,binary:n,objectMode:r},i)=>{if(e!==void 0&&!H_(e))throw TypeError(`The \`${i}.transform\` option must be a generator, a Duplex stream or a web TransformStream.`);if(lg(t,{checkOpen:!1}))throw TypeError(`The \`${i}.final\` option must not be a Duplex stream.`);if(nv(t))throw TypeError(`The \`${i}.final\` option must not be a web TransformStream.`);if(t!==void 0&&!H_(t))throw TypeError(`The \`${i}.final\` option must be a generator.`);return V_(n,`${i}.binary`),V_(r,`${i}.objectMode`),U_(e)||U_(t)?`asyncGenerator`:`generator`},V_=(e,t)=>{if(e!==void 0&&typeof e!=`boolean`)throw TypeError(`The \`${t}\` option must use a boolean.`)},H_=e=>U_(e)||W_(e),U_=e=>Object.prototype.toString.call(e)===`[object AsyncGeneratorFunction]`,W_=e=>Object.prototype.toString.call(e)===`[object GeneratorFunction]`,G_=e=>q(e)&&(e.transform!==void 0||e.final!==void 0),K_=e=>Object.prototype.toString.call(e)===`[object URL]`,q_=e=>K_(e)&&e.protocol!==`file:`,J_=e=>q(e)&&Object.keys(e).length>0&&Object.keys(e).every(e=>Y_.has(e))&&X_(e.file),Y_=new Set([`file`,`append`]),X_=e=>typeof e==`string`,Z_=(e,t)=>e===`native`&&typeof t==`string`&&!Q_.has(t),Q_=new Set([`ipc`,`ignore`,`inherit`,`overlapped`,`pipe`]),$_=e=>Object.prototype.toString.call(e)===`[object ReadableStream]`,ev=e=>Object.prototype.toString.call(e)===`[object WritableStream]`,tv=e=>$_(e)||ev(e),nv=e=>$_(e?.readable)&&ev(e?.writable),rv=e=>av(e)&&typeof e[Symbol.asyncIterator]==`function`,iv=e=>av(e)&&typeof e[Symbol.iterator]==`function`,av=e=>typeof e==`object`&&!!e,ov=new Set([`generator`,`asyncGenerator`,`duplex`,`webTransform`]),sv=new Set([`fileUrl`,`filePath`,`fileNumber`]),cv=new Set([`fileUrl`,`filePath`]),lv=new Set([...cv,`webStream`,`nodeStream`]),uv=new Set([`webTransform`,`duplex`]),dv={generator:`a generator`,asyncGenerator:`an async generator`,fileUrl:`a file URL`,filePath:`a file path string`,fileNumber:`a file descriptor number`,webStream:`a web stream`,nodeStream:`a Node.js stream`,webTransform:`a web TransformStream`,duplex:`a Duplex stream`,native:`any value`,iterable:`an iterable`,asyncIterable:`an async iterable`,string:`a string`,uint8Array:`a Uint8Array`},fv=(e,t,n,r)=>r===`output`?pv(e,t,n):mv(e,t,n),pv=(e,t,n)=>{let r=t!==0&&n[t-1].value.readableObjectMode;return{writableObjectMode:r,readableObjectMode:e??r}},mv=(e,t,n)=>{let r=t===0?e===!0:n[t-1].value.readableObjectMode;return{writableObjectMode:r,readableObjectMode:t!==n.length-1&&(e??r)}},hv=(e,t)=>{let n=e.findLast(({type:e})=>ov.has(e));return n===void 0?!1:t===`input`?n.value.writableObjectMode:n.value.readableObjectMode},gv=(e,t,n,r)=>[...e.filter(({type:e})=>!ov.has(e)),..._v(e,t,n,r)],_v=(e,t,n,{encoding:r})=>{let i=e.filter(({type:e})=>ov.has(e)),a=Array.from({length:i.length});for(let[e,o]of Object.entries(i))a[e]=vv({stdioItem:o,index:Number(e),newTransforms:a,optionName:t,direction:n,encoding:r});return Sv(a,n)},vv=({stdioItem:e,stdioItem:{type:t},index:n,newTransforms:r,optionName:i,direction:a,encoding:o})=>t===`duplex`?yv({stdioItem:e,optionName:i}):t===`webTransform`?bv({stdioItem:e,index:n,newTransforms:r,direction:a}):xv({stdioItem:e,index:n,newTransforms:r,direction:a,encoding:o}),yv=({stdioItem:e,stdioItem:{value:{transform:t,transform:{writableObjectMode:n,readableObjectMode:r},objectMode:i=r}},optionName:a})=>{if(i&&!r)throw TypeError(`The \`${a}.objectMode\` option can only be \`true\` if \`new Duplex({objectMode: true})\` is used.`);if(!i&&r)throw TypeError(`The \`${a}.objectMode\` option cannot be \`false\` if \`new Duplex({objectMode: true})\` is used.`);return{...e,value:{transform:t,writableObjectMode:n,readableObjectMode:r}}},bv=({stdioItem:e,stdioItem:{value:t},index:n,newTransforms:r,direction:i})=>{let{transform:a,objectMode:o}=q(t)?t:{transform:t},{writableObjectMode:s,readableObjectMode:c}=fv(o,n,r,i);return{...e,value:{transform:a,writableObjectMode:s,readableObjectMode:c}}},xv=({stdioItem:e,stdioItem:{value:t},index:n,newTransforms:r,direction:i,encoding:a})=>{let{transform:o,final:s,binary:c=!1,preserveNewlines:l=!1,objectMode:u}=q(t)?t:{transform:t},d=c||Vh.has(a),{writableObjectMode:f,readableObjectMode:p}=fv(u,n,r,i);return{...e,value:{transform:o,final:s,binary:d,preserveNewlines:l,writableObjectMode:f,readableObjectMode:p}}},Sv=(e,t)=>t===`input`?e.reverse():e,Cv=(e,t,n)=>{let r=e.map(e=>wv(e,t));if(r.includes(`input`)&&r.includes(`output`))throw TypeError(`The \`${n}\` option must not be an array of both readable and writable values.`);return r.find(Boolean)??Av},wv=({type:e,value:t},n)=>Tv[n]??Ov[e](t),Tv=[`input`,`output`,`output`],Ev=()=>void 0,Dv=()=>`input`,Ov={generator:Ev,asyncGenerator:Ev,fileUrl:Ev,filePath:Ev,iterable:Dv,asyncIterable:Dv,uint8Array:Dv,webStream:e=>ev(e)?`output`:`input`,nodeStream(e){return cg(e,{checkOpen:!1})?sg(e,{checkOpen:!1})?void 0:`input`:`output`},webTransform:Ev,duplex:Ev,native(e){let t=kv(e);if(t!==void 0)return t;if(og(e,{checkOpen:!1}))return Ov.nodeStream(e)}},kv=e=>{if([0,b.stdin].includes(e))return`input`;if([1,2,b.stdout,b.stderr].includes(e))return`output`},Av=`output`,jv=(e,t)=>t&&!e.includes(`ipc`)?[...e,`ipc`]:e,Mv=({stdio:e,ipc:t,buffer:n,...r},i,a)=>{let o=Nv(e,r).map((e,t)=>Fv(e,t));return a?Iv(o,n,i):jv(o,t)},Nv=(e,t)=>{if(e===void 0)return Y.map(e=>t[e]);if(Pv(t))throw Error(`It's not possible to provide \`stdio\` in combination with one of ${Y.map(e=>`\`${e}\``).join(`, `)}`);if(typeof e==`string`)return[e,e,e];if(!Array.isArray(e))throw TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof e}\``);let n=Math.max(e.length,Y.length);return Array.from({length:n},(t,n)=>e[n])},Pv=e=>Y.some(t=>e[t]!==void 0),Fv=(e,t)=>Array.isArray(e)?e.map(e=>Fv(e,t)):e??(t>=Y.length?`ignore`:`pipe`),Iv=(e,t,n)=>e.map((e,r)=>!t[r]&&r!==0&&!rf(n,r)&&Lv(e)?`ignore`:e),Lv=e=>e===`pipe`||Array.isArray(e)&&e.every(e=>e===`pipe`),Rv=({stdioItem:e,stdioItem:{type:t},isStdioArray:n,fdNumber:r,direction:i,isSync:a})=>!n||t!==`native`?e:a?zv({stdioItem:e,fdNumber:r,direction:i}):Hv({stdioItem:e,fdNumber:r}),zv=({stdioItem:e,stdioItem:{value:t,optionName:n},fdNumber:r,direction:i})=>{let a=Bv({value:t,optionName:n,fdNumber:r,direction:i});if(a!==void 0)return a;if(og(t,{checkOpen:!1}))throw TypeError(`The \`${n}: Stream\` option cannot both be an array and include a stream with synchronous methods.`);return e},Bv=({value:e,optionName:t,fdNumber:n,direction:r})=>{let i=Vv(e,n);if(i!==void 0){if(r===`output`)return{type:`fileNumber`,value:i,optionName:t};if(Fe.isatty(i))throw TypeError(`The \`${t}: ${Lm(e)}\` option is invalid: it cannot be a TTY with synchronous methods.`);return{type:`uint8Array`,value:yd(le(i)),optionName:t}}},Vv=(e,t)=>{if(e===`inherit`)return t;if(typeof e==`number`)return e;let n=Bd.indexOf(e);if(n!==-1)return n},Hv=({stdioItem:e,stdioItem:{value:t,optionName:n},fdNumber:r})=>t===`inherit`?{type:`nodeStream`,value:Uv(r,t,n),optionName:n}:typeof t==`number`?{type:`nodeStream`,value:Uv(t,t,n),optionName:n}:og(t,{checkOpen:!1})?{type:`nodeStream`,value:t,optionName:n}:e,Uv=(e,t,n)=>{let r=Bd[e];if(r===void 0)throw TypeError(`The \`${n}: ${t}\` option is invalid: no such standard stream.`);return r},Wv=({input:e,inputFile:t},n)=>n===0?[...Gv(e),...qv(t)]:[],Gv=e=>e===void 0?[]:[{type:Kv(e),value:e,optionName:`input`}],Kv=e=>{if(cg(e,{checkOpen:!1}))return`nodeStream`;if(typeof e==`string`)return`string`;if(J(e))return`uint8Array`;throw Error("The `input` option must be a string, a Uint8Array or a Node.js Readable stream.")},qv=e=>e===void 0?[]:[{...Jv(e),optionName:`inputFile`}],Jv=e=>{if(K_(e))return{type:`fileUrl`,value:e};if(X_(e))return{type:`filePath`,value:{file:e}};throw Error("The `inputFile` option must be a file path string or a file URL.")},Yv=e=>e.filter((t,n)=>e.every((e,r)=>t.value!==e.value||n>=r||t.type===`generator`||t.type===`asyncGenerator`)),Xv=({stdioItem:{type:e,value:t,optionName:n},direction:r,fileDescriptors:i,isSync:a})=>{let o=Zv(i,e);if(o.length!==0){if(a){Qv({otherStdioItems:o,type:e,value:t,optionName:n,direction:r});return}if(lv.has(e))return $v({otherStdioItems:o,type:e,value:t,optionName:n,direction:r});uv.has(e)&&ty({otherStdioItems:o,type:e,value:t,optionName:n})}},Zv=(e,t)=>e.flatMap(({direction:e,stdioItems:n})=>n.filter(e=>e.type===t).map((t=>({...t,direction:e})))),Qv=({otherStdioItems:e,type:t,value:n,optionName:r,direction:i})=>{cv.has(t)&&$v({otherStdioItems:e,type:t,value:n,optionName:r,direction:i})},$v=({otherStdioItems:e,type:t,value:n,optionName:r,direction:i})=>{let a=e.filter(e=>ey(e,n));if(a.length===0)return;let o=a.find(e=>e.direction!==i);return ny(o,r,t),i===`output`?a[0].stream:void 0},ey=({type:e,value:t},n)=>e===`filePath`?t.file===n.file:e===`fileUrl`?t.href===n.href:t===n,ty=({otherStdioItems:e,type:t,value:n,optionName:r})=>{let i=e.find(({value:{transform:e}})=>e===n.transform);ny(i,r,t)},ny=(e,t,n)=>{if(e!==void 0)throw TypeError(`The \`${e.optionName}\` and \`${t}\` options must not target ${dv[n]} that is the same.`)},ry=(e,t,n,r)=>{let i=Mv(t,n,r).map((e,n)=>iy({stdioOption:e,fdNumber:n,options:t,isSync:r})),a=fy({initialFileDescriptors:i,addProperties:e,options:t,isSync:r});return t.stdio=a.map(({stdioItems:e})=>gy(e)),a},iy=({stdioOption:e,fdNumber:t,options:n,isSync:r})=>{let i=Vd(t),{stdioItems:a,isStdioArray:o}=ay({stdioOption:e,fdNumber:t,options:n,optionName:i}),s=Cv(a,t,i),c=gv(a.map(e=>Rv({stdioItem:e,isStdioArray:o,fdNumber:t,direction:s,isSync:r})),i,s,n),l=hv(c,s);return dy(c,l),{direction:s,objectMode:l,stdioItems:c}},ay=({stdioOption:e,fdNumber:t,options:n,optionName:r})=>{let i=Yv([...(Array.isArray(e)?e:[e]).map(e=>oy(e,r)),...Wv(n,t)]),a=i.length>1;return sy(i,a,r),ly(i),{stdioItems:i,isStdioArray:a}},oy=(e,t)=>({type:P_(e,t),value:e,optionName:t}),sy=(e,t,n)=>{if(e.length===0)throw TypeError(`The \`${n}\` option must not be an empty array.`);if(t){for(let{value:t,optionName:n}of e)if(cy.has(t))throw Error(`The \`${n}\` option must not include \`${t}\`.`)}},cy=new Set([`ignore`,`ipc`]),ly=e=>{for(let t of e)uy(t)},uy=({type:e,value:t,optionName:n})=>{if(q_(t))throw TypeError(`The \`${n}: URL\` option must use the \`file:\` scheme.
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
if (condition) { yield value; }`)},Uy=(e,t,n)=>{if(n)return;if(e)return{transform:Wy.bind(void 0,new TextEncoder)};let r=new we(t);return{transform:Gy.bind(void 0,r),final:Ky.bind(void 0,r)}},Wy=function*(e,t){Je.isBuffer(t)?yield yd(t):typeof t==`string`?yield e.encode(t):yield t},Gy=function*(e,t){yield J(t)?e.write(t):t},Ky=function*(e){let t=e.end();t!==``&&(yield t)},qy=Ee(async(e,t,n,r)=>{t.currentIterable=e(...n);try{for await(let e of t.currentIterable)r.push(e)}finally{delete t.currentIterable}}),Jy=async function*(e,t,n){if(n===t.length){yield e;return}let{transform:r=Qy}=t[n];for await(let i of r(e))yield*Jy(i,t,n+1)},Yy=async function*(e){for(let[t,{final:n}]of Object.entries(e))yield*Xy(n,Number(t),e)},Xy=async function*(e,t,n){if(e!==void 0)for await(let r of e())yield*Jy(r,n,t+1)},Zy=Ee(async({currentIterable:e},t)=>{if(e!==void 0){await(t?e.throw(t):e.return());return}if(t)throw t}),Qy=function*(e){yield e},$y=(e,t,n,r)=>{try{for(let r of e(...t))n.push(r);r()}catch(e){r(e)}},eb=(e,t)=>[...t.flatMap(t=>[...tb(t,e,0)]),...nb(e)],tb=function*(e,t,n){if(n===t.length){yield e;return}let{transform:r=ib}=t[n];for(let i of r(e))yield*tb(i,t,n+1)},nb=function*(e){for(let[t,{final:n}]of Object.entries(e))yield*rb(n,Number(t),e)},rb=function*(e,t,n){if(e!==void 0)for(let r of e())yield*tb(r,n,t+1)},ib=function*(e){yield e},ab=({value:e,value:{transform:t,final:n,writableObjectMode:r,readableObjectMode:i},optionName:a},{encoding:o})=>{let s={},c=sb(e,o,a),l=U_(t),u=U_(n),d=l?qy.bind(void 0,Jy,s):$y.bind(void 0,tb),f=l||u?qy.bind(void 0,Yy,s):$y.bind(void 0,nb),p=l||u?Zy.bind(void 0,s):void 0;return{stream:new Ge({writableObjectMode:r,writableHighWaterMark:qe(r),readableObjectMode:i,readableHighWaterMark:qe(i),transform(e,t,n){d([e,c,0],this,n)},flush(e){f([c],this,e)},destroy:p})}},ob=(e,t,n,r)=>{let i=t.filter(({type:e})=>e===`generator`),a=r?i.reverse():i;for(let{value:t,optionName:r}of a)e=eb(sb(t,n,r),e);return e},sb=({transform:e,final:t,binary:n,writableObjectMode:r,readableObjectMode:i,preserveNewlines:a},o,s)=>{let c={};return[{transform:Ly(r,s)},Uy(n,o,r),Ty(n,a,r,c),{transform:e,final:t},{transform:zy(i,s)},My({binary:n,preserveNewlines:a,readableObjectMode:i,state:c})].filter(Boolean)},cb=(e,t)=>{for(let n of lb(e))ub(e,n,t)},lb=e=>new Set(Object.entries(e).filter(([,{direction:e}])=>e===`input`).map(([e])=>Number(e))),ub=(e,t,n)=>{let{stdioItems:r}=e[t],i=r.filter(({contents:e})=>e!==void 0);if(i.length!==0){if(t!==0){let[{type:e,optionName:t}]=i;throw TypeError(`Only the \`stdin\` option, not \`${t}\`, can be ${dv[e]} with synchronous methods.`)}n.input=Ed(i.map(({contents:e})=>e).map(e=>db(e,r)))}},db=(e,t)=>{let n=ob(e,t,`utf8`,!0);return fb(n),Ed(n)},fb=e=>{let t=e.find(e=>typeof e!=`string`&&!J(e));if(t!==void 0)throw TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${t}.`)},pb=({stdioItems:e,encoding:t,verboseInfo:n,fdNumber:r})=>r!==`all`&&rf(n,r)&&!Vh.has(t)&&mb(r)&&(e.some(({type:e,value:t})=>e===`native`&&hb.has(t))||e.every(({type:e})=>ov.has(e))),mb=e=>e===1||e===2,hb=new Set([`pipe`,`overlapped`]),gb=async(e,t,n,r)=>{for await(let i of e)vb(t)||yb(i,n,r)},_b=(e,t,n)=>{for(let r of e)yb(r,t,n)},vb=e=>e._readableState.pipes.length>0,yb=(e,t,n)=>{Vf({type:`output`,verboseMessage:Gf(e),fdNumber:t,verboseInfo:n})},bb=({fileDescriptors:e,syncResult:{output:t},options:n,isMaxBuffer:r,verboseInfo:i})=>{if(t===null)return{output:Array.from({length:3})};let a={},o=new Set([]);return{output:t.map((t,s)=>xb({result:t,fileDescriptors:e,fdNumber:s,state:a,outputFiles:o,isMaxBuffer:r,verboseInfo:i},n)),...a}},xb=({result:e,fileDescriptors:t,fdNumber:n,state:r,outputFiles:i,isMaxBuffer:a,verboseInfo:o},{buffer:s,encoding:c,lines:l,stripFinalNewline:u,maxBuffer:d})=>{if(e===null)return;let f=yd(s_(e,a,d)),{stdioItems:p,objectMode:m}=t[n],h=Sb([f],p,c,r),{serializedResult:g,finalResult:_=g}=Cb({chunks:h,objectMode:m,encoding:c,lines:l,stripFinalNewline:u,fdNumber:n});wb({serializedResult:g,fdNumber:n,state:r,verboseInfo:o,encoding:c,stdioItems:p,objectMode:m});let v=s[n]?_:void 0;try{return r.error===void 0&&Tb(g,p,i),v}catch(e){return r.error=e,v}},Sb=(e,t,n,r)=>{try{return ob(e,t,n,!1)}catch(t){return r.error=t,e}},Cb=({chunks:e,objectMode:t,encoding:n,lines:r,stripFinalNewline:i,fdNumber:a})=>{if(t)return{serializedResult:e};if(n===`buffer`)return{serializedResult:Ed(e)};let o=wd(e,n);return r[a]?{serializedResult:o,finalResult:Ey(o,!i[a],t)}:{serializedResult:o}},wb=({serializedResult:e,fdNumber:t,state:n,verboseInfo:r,encoding:i,stdioItems:a,objectMode:o})=>{if(!pb({stdioItems:a,encoding:i,verboseInfo:r,fdNumber:t}))return;let s=Ey(e,!1,o);try{_b(s,t,r)}catch(e){n.error??=e}},Tb=(e,t,n)=>{for(let{path:r,append:i}of t.filter(({type:e})=>sv.has(e))){let t=typeof r==`string`?r:r.toString();i||n.has(t)?ae(r,e):(n.add(t),fe(r,e))}},Eb=([,e,t],n)=>{if(n.all)return e===void 0?t:t===void 0?e:Array.isArray(e)?Array.isArray(t)?[...e,...t]:[...e,Cy(t,n,`all`)]:Array.isArray(t)?[Cy(e,n,`all`),...t]:J(e)&&J(t)?Od([e,t]):`${e}${t}`},Db=async(e,t)=>{let[n,r]=await Ob(e);return t.isForcefullyTerminated??=!1,[n,r]},Ob=async e=>{let[t,n]=await Promise.allSettled([x(e,`spawn`),x(e,`exit`)]);return t.status===`rejected`?[]:n.status===`rejected`?kb(e):n.value},kb=async e=>{try{return await x(e,`exit`)}catch{return kb(e)}},Ab=async e=>{let[t,n]=await e;if(!jb(t,n)&&Mb(t,n))throw new Sp;return[t,n]},jb=(e,t)=>e===void 0&&t===void 0,Mb=(e,t)=>e!==0||t!==null,Nb=({error:e,status:t,signal:n,output:r},{maxBuffer:i})=>{let a=Pb(e,t,n);return{resultError:a,exitCode:t,signal:n,timedOut:a?.code===`ETIMEDOUT`,isMaxBuffer:o_(a,r,i)}},Pb=(e,t,n)=>e===void 0?Mb(t,n)?new Sp:void 0:e,Fb=(e,t,n)=>{let{file:r,commandArguments:i,command:a,escapedCommand:o,startTime:s,verboseInfo:c,options:l,fileDescriptors:u}=Ib(e,t,n);return N_(Bb({file:r,commandArguments:i,options:l,command:a,escapedCommand:o,verboseInfo:c,fileDescriptors:u,startTime:s}),c,l)},Ib=(e,t,n)=>{let{command:r,escapedCommand:i,startTime:a,verboseInfo:o}=ep(e,t,n),{file:s,commandArguments:c,options:l}=Yh(e,t,Lb(n));return Rb(l),{file:s,commandArguments:c,command:r,escapedCommand:i,startTime:a,verboseInfo:o,options:l,fileDescriptors:_y(l,o)}},Lb=e=>e.node&&!e.ipc?{...e,ipc:!1}:e,Rb=({ipc:e,ipcInput:t,detached:n,cancelSignal:r})=>{t&&zb(`ipcInput`),e&&zb(`ipc: true`),n&&zb(`detached: true`),r&&zb(`cancelSignal`)},zb=e=>{throw TypeError(`The "${e}" option cannot be used with synchronous methods.`)},Bb=({file:e,commandArguments:t,options:n,command:r,escapedCommand:i,verboseInfo:a,fileDescriptors:o,startTime:s})=>{let c=Vb({file:e,commandArguments:t,options:n,command:r,escapedCommand:i,fileDescriptors:o,startTime:s});if(c.failed)return c;let{resultError:l,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p}=Nb(c,n),{output:m,error:h=l}=bb({fileDescriptors:o,syncResult:c,options:n,isMaxBuffer:p,verboseInfo:a}),g=m.map((e,t)=>Cy(e,n,t)),_=Cy(Eb(m,n),n,`all`);return Ub({error:h,exitCode:u,signal:d,timedOut:f,isMaxBuffer:p,stdio:g,all:_,options:n,command:r,escapedCommand:i,startTime:s})},Vb=({file:e,commandArguments:t,options:n,command:r,escapedCommand:i,fileDescriptors:a,startTime:o})=>{try{return cb(a,n),Ce(...Qh(e,t,Hb(n)))}catch(e){return __({error:e,command:r,escapedCommand:i,fileDescriptors:a,options:n,startTime:o,isSync:!0})}},Hb=({encoding:e,maxBuffer:t,...n})=>({...n,encoding:`buffer`,maxBuffer:c_(t)}),Ub=({error:e,exitCode:t,signal:n,timedOut:r,isMaxBuffer:i,stdio:a,all:o,options:s,command:c,escapedCommand:l,startTime:u})=>e===void 0?g_({command:c,escapedCommand:l,stdio:a,all:o,ipcOutput:[],options:s,startTime:u}):v_({error:e,command:c,escapedCommand:l,timedOut:r,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:t,signal:n,stdio:a,all:o,ipcOutput:[],options:s,startTime:u,isSync:!0}),Wb=({anyProcess:e,channel:t,isSubprocess:n,ipc:r},{reference:i=!0,filter:a}={})=>(cm({methodName:`getOneMessage`,isSubprocess:n,ipc:r,isConnected:Zm(e)}),Gb({anyProcess:e,channel:t,isSubprocess:n,filter:a,reference:i})),Gb=async({anyProcess:e,channel:t,isSubprocess:n,filter:r,reference:i})=>{zm(t,i);let a=Jm(e,t,n),o=new AbortController;try{return await Promise.race([Kb(a,r,o),qb(a,n,o),Jb(a,n,o)])}catch(t){throw Tm(e),t}finally{o.abort(),Vm(t,i)}},Kb=async(e,t,{signal:n})=>{if(t===void 0){let[t]=await x(e,`message`,{signal:n});return t}for await(let[r]of Re(e,`message`,{signal:n}))if(t(r))return r},qb=async(e,t,{signal:n})=>{await x(e,`disconnect`,{signal:n}),dm(t)},Jb=async(e,t,{signal:n})=>{let[r]=await x(e,`strict:error`,{signal:n});throw pm(r,t)},Yb=({anyProcess:e,channel:t,isSubprocess:n,ipc:r},{reference:i=!0}={})=>Xb({anyProcess:e,channel:t,isSubprocess:n,ipc:r,shouldAwait:!n,reference:i}),Xb=({anyProcess:e,channel:t,isSubprocess:n,ipc:r,shouldAwait:i,reference:a})=>{cm({methodName:`getEachMessage`,isSubprocess:n,ipc:r,isConnected:Zm(e)}),zm(t,a);let o=Jm(e,t,n),s=new AbortController,c={};return Zb(e,o,s),Qb({ipcEmitter:o,isSubprocess:n,controller:s,state:c}),$b({anyProcess:e,channel:t,ipcEmitter:o,isSubprocess:n,shouldAwait:i,controller:s,state:c,reference:a})},Zb=async(e,t,n)=>{try{await x(t,`disconnect`,{signal:n.signal}),n.abort()}catch{}},Qb=async({ipcEmitter:e,isSubprocess:t,controller:n,state:r})=>{try{let[i]=await x(e,`strict:error`,{signal:n.signal});r.error=pm(i,t),n.abort()}catch{}},$b=async function*({anyProcess:e,channel:t,ipcEmitter:n,isSubprocess:r,shouldAwait:i,controller:a,state:o,reference:s}){try{for await(let[e]of Re(n,`message`,{signal:a.signal}))ex(o),yield e}catch{ex(o)}finally{a.abort(),Vm(t,s),r||Tm(e),i&&await e}},ex=({error:e})=>{if(e)throw e},tx=(e,{ipc:t})=>{Object.assign(e,rx(e,!1,t))},nx=()=>{let e=b,t=b.channel!==void 0;return{...rx(e,!0,t),getCancelSignal:bh.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:!0,ipc:t})}},rx=(e,t,n)=>({sendMessage:mh.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:n}),getOneMessage:Wb.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:n}),getEachMessage:Yb.bind(void 0,{anyProcess:e,channel:e.channel,isSubprocess:t,ipc:n})}),ix=({error:e,command:t,escapedCommand:n,fileDescriptors:r,options:i,startTime:a,verboseInfo:o})=>{hy(r);let s=new be;ax(s,r),Object.assign(s,{readable:sx,writable:cx,duplex:lx});let c=__({error:e,command:t,escapedCommand:n,fileDescriptors:r,options:i,startTime:a,isSync:!1});return{subprocess:s,promise:ux(c,o,i)}},ax=(e,t)=>{let n=ox(),r=ox(),i=ox(),a=Array.from({length:t.length-3},ox),o=ox(),s=[n,r,i,...a];Object.assign(e,{stdin:n,stdout:r,stderr:i,all:o,stdio:s})},ox=()=>{let e=new Ue;return e.end(),e},sx=()=>new We({read(){}}),cx=()=>new Ke({write(){}}),lx=()=>new He({read(){},write(){}}),ux=async(e,t,n)=>N_(e,t,n),dx=(e,t)=>ry(mx,e,t,!1),fx=({type:e,optionName:t})=>{throw TypeError(`The \`${t}\` option cannot be ${dv[e]}.`)},px={fileNumber:fx,generator:ab,asyncGenerator:ab,nodeStream:({value:e})=>({stream:e}),webTransform({value:{transform:e,writableObjectMode:t,readableObjectMode:n}}){let r=t||n;return{stream:He.fromWeb(e,{objectMode:r})}},duplex:({value:{transform:e}})=>({stream:e}),native(){}},mx={input:{...px,fileUrl:({value:e})=>({stream:oe(e)}),filePath:({value:{file:e}})=>({stream:oe(e)}),webStream:({value:e})=>({stream:We.fromWeb(e)}),iterable:({value:e})=>({stream:We.from(e)}),asyncIterable:({value:e})=>({stream:We.from(e)}),string:({value:e})=>({stream:We.from(e)}),uint8Array:({value:e})=>({stream:We.from(Je.from(e))})},output:{...px,fileUrl:({value:e})=>({stream:se(e)}),filePath:({value:{file:e,append:t}})=>({stream:se(e,t?{flags:`a`}:{})}),webStream:({value:e})=>({stream:Ke.fromWeb(e)}),iterable:fx,asyncIterable:fx,string:fx,uint8Array:fx}};function hx(e){if(!Array.isArray(e))throw TypeError(`Expected an array, got \`${typeof e}\`.`);for(let t of e)xx(t);let t=e.some(({readableObjectMode:e})=>e),n=gx(e,t),r=new _x({objectMode:t,writableHighWaterMark:n,readableHighWaterMark:n});for(let t of e)r.add(t);return r}const gx=(e,t)=>{if(e.length===0)return qe(t);let n=e.filter(({readableObjectMode:e})=>e===t).map(({readableHighWaterMark:e})=>e);return Math.max(...n)};var _x=class extends Ue{#e=new Set([]);#t=new Set([]);#n=new Set([]);#r;#i=Symbol(`unpipe`);#a=new WeakMap;add(e){if(xx(e),this.#e.has(e))return;this.#e.add(e),this.#r??=vx(this,this.#e,this.#i);let t=Sx({passThroughStream:this,stream:e,streams:this.#e,ended:this.#t,aborted:this.#n,onFinished:this.#r,unpipeEvent:this.#i});this.#a.set(e,t),e.pipe(this,{end:!1})}async remove(e){if(xx(e),!this.#e.has(e))return!1;let t=this.#a.get(e);return t===void 0?!1:(this.#a.delete(e),e.unpipe(this),await t,!0)}};const vx=async(e,t,n)=>{Mx(e,Nx);let r=new AbortController;try{await Promise.race([yx(e,r),bx(e,t,n,r)])}finally{r.abort(),Mx(e,-Nx)}},yx=async(e,{signal:t})=>{try{await Ve(e,{signal:t,cleanup:!0})}catch(t){throw Dx(e,t),t}},bx=async(e,t,n,{signal:r})=>{for await(let[i]of Re(e,`unpipe`,{signal:r}))t.has(i)&&i.emit(n)},xx=e=>{if(typeof e?.pipe!=`function`)throw TypeError(`Expected a readable stream, got: \`${typeof e}\`.`)},Sx=async({passThroughStream:e,stream:t,streams:n,ended:r,aborted:i,onFinished:a,unpipeEvent:o})=>{Mx(e,Px);let s=new AbortController;try{await Promise.race([Cx(a,t,s),wx({passThroughStream:e,stream:t,streams:n,ended:r,aborted:i,controller:s}),Tx({stream:t,streams:n,ended:r,aborted:i,unpipeEvent:o,controller:s})])}finally{s.abort(),Mx(e,-Px)}n.size>0&&n.size===r.size+i.size&&(r.size===0&&i.size>0?kx(e):Ex(e))},Cx=async(e,t,{signal:n})=>{try{await e,n.aborted||kx(t)}catch(e){n.aborted||Dx(t,e)}},wx=async({passThroughStream:e,stream:t,streams:n,ended:r,aborted:i,controller:{signal:a}})=>{try{await Ve(t,{signal:a,cleanup:!0,readable:!0,writable:!1}),n.has(t)&&r.add(t)}catch(r){if(a.aborted||!n.has(t))return;Ox(r)?i.add(t):Ax(e,r)}},Tx=async({stream:e,streams:t,ended:n,aborted:r,unpipeEvent:i,controller:{signal:a}})=>{if(await x(e,i,{signal:a}),!e.readable)return x(a,`abort`,{signal:a});t.delete(e),n.delete(e),r.delete(e)},Ex=e=>{e.writable&&e.end()},Dx=(e,t)=>{Ox(t)?kx(e):Ax(e,t)},Ox=e=>e?.code===`ERR_STREAM_PREMATURE_CLOSE`,kx=e=>{(e.readable||e.writable)&&e.destroy()},Ax=(e,t)=>{e.destroyed||(e.once(`error`,jx),e.destroy(t))},jx=()=>{},Mx=(e,t)=>{let n=e.getMaxListeners();n!==0&&n!==1/0&&e.setMaxListeners(n+t)},Nx=2,Px=1,Fx=(e,t)=>{e.pipe(t),Ix(e,t),Rx(e,t)},Ix=async(e,t)=>{if(!(zd(e)||zd(t))){try{await Ve(e,{cleanup:!0,readable:!0,writable:!1})}catch{}Lx(t)}},Lx=e=>{e.writable&&e.end()},Rx=async(e,t)=>{if(!(zd(e)||zd(t))){try{await Ve(t,{cleanup:!0,readable:!1,writable:!0})}catch{}zx(e)}},zx=e=>{e.readable&&e.destroy()},Bx=(e,t,n)=>{let r=new Map;for(let[i,{stdioItems:a,direction:o}]of Object.entries(t)){for(let{stream:t}of a.filter(({type:e})=>ov.has(e)))Vx(e,t,o,i);for(let{stream:t}of a.filter(({type:e})=>!ov.has(e)))Ux({subprocess:e,stream:t,direction:o,fdNumber:i,pipeGroups:r,controller:n})}for(let[e,t]of r.entries())Fx(t.length===1?t[0]:hx(t),e)},Vx=(e,t,n,r)=>{n===`output`?Fx(e.stdio[r],t):Fx(t,e.stdio[r]);let i=Hx[r];i!==void 0&&(e[i]=t),e.stdio[r]=t},Hx=[`stdin`,`stdout`,`stderr`],Ux=({subprocess:e,stream:t,direction:n,fdNumber:r,pipeGroups:i,controller:a})=>{if(t===void 0)return;Wx(t,a);let[o,s]=n===`output`?[t,e.stdio[r]]:[e.stdio[r],t],c=i.get(o)??[];i.set(o,[...c,s])},Wx=(e,{signal:t})=>{zd(e)&&Rm(e,Gx,t)},Gx=2,Kx=[];Kx.push(`SIGHUP`,`SIGINT`,`SIGTERM`),process.platform!==`win32`&&Kx.push(`SIGALRM`,`SIGABRT`,`SIGVTALRM`,`SIGXCPU`,`SIGXFSZ`,`SIGUSR2`,`SIGTRAP`,`SIGSYS`,`SIGQUIT`,`SIGIOT`),process.platform===`linux`&&Kx.push(`SIGIO`,`SIGPOLL`,`SIGPWR`,`SIGSTKFLT`);const qx=e=>!!e&&typeof e==`object`&&typeof e.removeListener==`function`&&typeof e.emit==`function`&&typeof e.reallyExit==`function`&&typeof e.listeners==`function`&&typeof e.kill==`function`&&typeof e.pid==`number`&&typeof e.on==`function`,Jx=Symbol.for(`signal-exit emitter`),Yx=globalThis,Xx=Object.defineProperty.bind(Object);var Zx=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(Yx[Jx])return Yx[Jx];Xx(Yx,Jx,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,t){this.listeners[e].push(t)}removeListener(e,t){let n=this.listeners[e],r=n.indexOf(t);r!==-1&&(r===0&&n.length===1?n.length=0:n.splice(r,1))}emit(e,t,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let r=!1;for(let i of this.listeners[e])r=i(t,n)===!0||r;return e===`exit`&&(r=this.emit(`afterExit`,t,n)||r),r}},Qx=class{};const $x=e=>({onExit(t,n){return e.onExit(t,n)},load(){return e.load()},unload(){return e.unload()}});var eS=class extends Qx{onExit(){return()=>{}}load(){}unload(){}},tS=class extends Qx{#e=nS.platform===`win32`?`SIGINT`:`SIGHUP`;#t=new Zx;#n;#r;#i;#a={};#o=!1;constructor(e){super(),this.#n=e,this.#a={};for(let t of Kx)this.#a[t]=()=>{let n=this.#n.listeners(t),{count:r}=this.#t,i=e;if(typeof i.__signal_exit_emitter__==`object`&&typeof i.__signal_exit_emitter__.count==`number`&&(r+=i.__signal_exit_emitter__.count),n.length===r){this.unload();let n=this.#t.emit(`exit`,null,t),r=t===`SIGHUP`?this.#e:t;n||e.kill(e.pid,r)}};this.#i=e.reallyExit,this.#r=e.emit}onExit(e,t){if(!qx(this.#n))return()=>{};this.#o===!1&&this.load();let n=t?.alwaysLast?`afterExit`:`exit`;return this.#t.on(n,e),()=>{this.#t.removeListener(n,e),this.#t.listeners.exit.length===0&&this.#t.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#t.count+=1;for(let e of Kx)try{let t=this.#a[e];t&&this.#n.on(e,t)}catch{}this.#n.emit=(e,...t)=>this.#c(e,...t),this.#n.reallyExit=e=>this.#s(e)}}unload(){this.#o&&(this.#o=!1,Kx.forEach(e=>{let t=this.#a[e];if(!t)throw Error(`Listener not defined for signal: `+e);try{this.#n.removeListener(e,t)}catch{}}),this.#n.emit=this.#r,this.#n.reallyExit=this.#i,--this.#t.count)}#s(e){return qx(this.#n)?(this.#n.exitCode=e||0,this.#t.emit(`exit`,this.#n.exitCode,null),this.#i.call(this.#n,this.#n.exitCode)):0}#c(e,...t){let n=this.#r;if(e===`exit`&&qx(this.#n)){typeof t[0]==`number`&&(this.#n.exitCode=t[0]);let r=n.call(this.#n,e,...t);return this.#t.emit(`exit`,this.#n.exitCode,null),r}else return n.call(this.#n,e,...t)}};const nS=globalThis.process,{onExit:rS,load:iS,unload:aS}=$x(qx(nS)?new tS(nS):new eS),oS=(e,{cleanup:t,detached:n},{signal:r})=>{if(!t||n)return;let i=rS(()=>{e.kill()});Le(r,()=>{i()})},sS=({source:e,sourcePromise:t,boundOptions:n,createNested:r},...i)=>{let a=Qf(),{destination:o,destinationStream:s,destinationError:c,from:l,unpipeSignal:u}=cS(n,r,i),{sourceStream:d,sourceError:f}=dS(e,l),{options:p,fileDescriptors:m}=km.get(e);return{sourcePromise:t,sourceStream:d,sourceOptions:p,sourceError:f,destination:o,destinationStream:s,destinationError:c,unpipeSignal:u,fileDescriptors:m,startTime:a}},cS=(e,t,n)=>{try{let{destination:r,pipeOptions:{from:i,to:a,unpipeSignal:o}={}}=lS(e,t,...n);return{destination:r,destinationStream:Dm(r,a),from:i,unpipeSignal:o}}catch(e){return{destinationError:e}}},lS=(e,t,n,...r)=>{if(Array.isArray(n))return{destination:t(uS,e)(n,...r),pipeOptions:e};if(typeof n==`string`||n instanceof URL||md(n)){if(Object.keys(e).length>0)throw TypeError(`Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).`);let[i,a,o]=gd(n,...r);return{destination:t(uS)(i,a,o),pipeOptions:o}}if(km.has(n)){if(Object.keys(e).length>0)throw TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:n,pipeOptions:r[0]}}throw TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${n}`)},uS=({options:e})=>({options:{...e,stdin:`pipe`,piped:!0}}),dS=(e,t)=>{try{return{sourceStream:Om(e,t)}}catch(e){return{sourceError:e}}},fS=({sourceStream:e,sourceError:t,destinationStream:n,destinationError:r,fileDescriptors:i,sourceOptions:a,startTime:o})=>{let s=pS({sourceStream:e,sourceError:t,destinationStream:n,destinationError:r});if(s!==void 0)throw mS({error:s,fileDescriptors:i,sourceOptions:a,startTime:o})},pS=({sourceStream:e,sourceError:t,destinationStream:n,destinationError:r})=>{if(t!==void 0&&r!==void 0)return r;if(r!==void 0)return zx(e),r;if(t!==void 0)return Lx(n),t},mS=({error:e,fileDescriptors:t,sourceOptions:n,startTime:r})=>__({error:e,command:hS,escapedCommand:hS,fileDescriptors:t,options:n,startTime:r,isSync:!1}),hS=`source.pipe(destination)`,gS=async e=>{let[{status:t,reason:n,value:r=n},{status:i,reason:a,value:o=a}]=await e;if(o.pipedFrom.includes(r)||o.pipedFrom.push(r),i===`rejected`)throw o;if(t===`rejected`)throw r;return o},_S=(e,t,n)=>{let r=xS.has(t)?yS(e,t):vS(e,t);return Rm(e,SS,n.signal),Rm(t,CS,n.signal),bS(t),r},vS=(e,t)=>{let n=hx([e]);return Fx(n,t),xS.set(t,n),n},yS=(e,t)=>{let n=xS.get(t);return n.add(e),n},bS=async e=>{try{await Ve(e,{cleanup:!0,readable:!1,writable:!0})}catch{}xS.delete(e)},xS=new WeakMap,SS=2,CS=1,wS=(e,t)=>e===void 0?[]:[TS(e,t)],TS=async(e,{sourceStream:t,mergedStream:n,fileDescriptors:r,sourceOptions:i,startTime:a})=>{throw await Te(e,t),await n.remove(t),mS({error:Error("Pipe canceled by `unpipeSignal` option."),fileDescriptors:r,sourceOptions:i,startTime:a})},ES=(e,...t)=>{if(q(t[0]))return ES.bind(void 0,{...e,boundOptions:{...e.boundOptions,...t[0]}});let{destination:n,...r}=sS(e,...t),i=DS({...r,destination:n});return i.pipe=ES.bind(void 0,{...e,source:n,sourcePromise:i,boundOptions:{}}),i},DS=async({sourcePromise:e,sourceStream:t,sourceOptions:n,sourceError:r,destination:i,destinationStream:a,destinationError:o,unpipeSignal:s,fileDescriptors:c,startTime:l})=>{let u=OS(e,i);fS({sourceStream:t,sourceError:r,destinationStream:a,destinationError:o,fileDescriptors:c,sourceOptions:n,startTime:l});let d=new AbortController;try{let e=_S(t,a,d);return await Promise.race([gS(u),...wS(s,{sourceStream:t,mergedStream:e,sourceOptions:n,fileDescriptors:c,startTime:l})])}finally{d.abort()}},OS=(e,t)=>Promise.allSettled([e,t]),kS=({subprocessStdout:e,subprocess:t,binary:n,shouldEncode:r,encoding:i,preserveNewlines:a})=>{let o=new AbortController;return AS(t,o),NS({stream:e,controller:o,binary:n,shouldEncode:!e.readableObjectMode&&r,encoding:i,shouldSplit:!e.readableObjectMode,preserveNewlines:a})},AS=async(e,t)=>{try{await e}catch{}finally{t.abort()}},jS=({stream:e,onStreamEnd:t,lines:n,encoding:r,stripFinalNewline:i,allMixed:a})=>{let o=new AbortController;MS(t,o,e);let s=e.readableObjectMode&&!a;return NS({stream:e,controller:o,binary:r===`buffer`,shouldEncode:!s,encoding:r,shouldSplit:!s&&n,preserveNewlines:!i})},MS=async(e,t,n)=>{try{await e}catch{n.destroy()}finally{t.abort()}},NS=({stream:e,controller:t,binary:n,shouldEncode:r,encoding:i,shouldSplit:a,preserveNewlines:o})=>{let s=Re(e,`data`,{signal:t.signal,highWaterMark:FS,highWatermark:FS});return IS({onStdoutChunk:s,controller:t,binary:n,shouldEncode:r,encoding:i,shouldSplit:a,preserveNewlines:o})},PS=qe(!0),FS=PS,IS=async function*({onStdoutChunk:e,controller:t,binary:n,shouldEncode:r,encoding:i,shouldSplit:a,preserveNewlines:o}){let s=LS({binary:n,shouldEncode:r,encoding:i,shouldSplit:a,preserveNewlines:o});try{for await(let[t]of e)yield*tb(t,s,0)}catch(e){if(!t.signal.aborted)throw e}finally{yield*nb(s)}},LS=({binary:e,shouldEncode:t,encoding:n,shouldSplit:r,preserveNewlines:i})=>[Uy(e,n,!t),Ty(e,i,!r,{})].filter(Boolean),RS=async({stream:e,onStreamEnd:t,fdNumber:n,encoding:r,buffer:i,maxBuffer:a,lines:o,allMixed:s,stripFinalNewline:c,verboseInfo:l,streamInfo:u})=>{let d=zS({stream:e,onStreamEnd:t,fdNumber:n,encoding:r,allMixed:s,verboseInfo:l,streamInfo:u});if(!i){await Promise.all([BS(e),d]);return}let f=jS({stream:e,onStreamEnd:t,lines:o,encoding:r,stripFinalNewline:wy(c,n),allMixed:s}),[p]=await Promise.all([VS({stream:e,iterable:f,fdNumber:n,encoding:r,maxBuffer:a,lines:o}),d]);return p},zS=async({stream:e,onStreamEnd:t,fdNumber:n,encoding:r,allMixed:i,verboseInfo:a,streamInfo:{fileDescriptors:o}})=>{pb({stdioItems:o[n]?.stdioItems,encoding:r,verboseInfo:a,fdNumber:n})&&await gb(jS({stream:e,onStreamEnd:t,lines:!0,encoding:r,stripFinalNewline:!0,allMixed:i}),e,n,a)},BS=async e=>{await ge(),e.readableFlowing===null&&e.resume()},VS=async({stream:e,stream:{readableObjectMode:t},iterable:n,fdNumber:r,encoding:i,maxBuffer:a,lines:o})=>{try{return t||o?await Pg(n,{maxBuffer:a}):i===`buffer`?new Uint8Array(await Ig(n,{maxBuffer:a})):await Zg(n,{maxBuffer:a})}catch(n){return US(t_({error:n,stream:e,readableObjectMode:t,lines:o,encoding:i,fdNumber:r}))}},HS=async e=>{try{return await e}catch(e){return US(e)}},US=({bufferedData:e})=>vd(e)?new Uint8Array(e):e,WS=async(e,t,n,{isSameDirection:r,stopOnExit:i=!1}={})=>{let a=GS(e,n),o=new AbortController;try{await Promise.race([...i?[n.exitPromise]:[],Ve(e,{cleanup:!0,signal:o.signal})])}catch(e){a.stdinCleanedUp||JS(e,t,n,r)}finally{o.abort()}},GS=(e,{originalStreams:[t],subprocess:n})=>{let r={stdinCleanedUp:!1};return e===t&&KS(e,n,r),r},KS=(e,t,n)=>{let{_destroy:r}=e;e._destroy=(...i)=>{qS(t,n),r.call(e,...i)}},qS=({exitCode:e,signalCode:t},n)=>{(e!==null||t!==null)&&(n.stdinCleanedUp=!0)},JS=(e,t,n,r)=>{if(!YS(e,t,n,r))throw e},YS=(e,t,n,r=!0)=>n.propagating?QS(e)||ZS(e):(n.propagating=!0,XS(n,t)===r?QS(e):ZS(e)),XS=({fileDescriptors:e},t)=>t!==`all`&&e[t].direction===`input`,ZS=e=>e?.code===`ERR_STREAM_PREMATURE_CLOSE`,QS=e=>e?.code===`EPIPE`,$S=({subprocess:e,encoding:t,buffer:n,maxBuffer:r,lines:i,stripFinalNewline:a,verboseInfo:o,streamInfo:s})=>e.stdio.map((e,c)=>eC({stream:e,fdNumber:c,encoding:t,buffer:n[c],maxBuffer:r[c],lines:i[c],allMixed:!1,stripFinalNewline:a,verboseInfo:o,streamInfo:s})),eC=async({stream:e,fdNumber:t,encoding:n,buffer:r,maxBuffer:i,lines:a,allMixed:o,stripFinalNewline:s,verboseInfo:c,streamInfo:l})=>{if(!e)return;let u=WS(e,t,l);if(XS(l,t)){await u;return}let[d]=await Promise.all([RS({stream:e,onStreamEnd:u,fdNumber:t,encoding:n,buffer:r,maxBuffer:i,lines:a,allMixed:o,stripFinalNewline:s,verboseInfo:c,streamInfo:l}),u]);return d},tC=({stdout:e,stderr:t},{all:n})=>n&&(e||t)?hx([e,t].filter(Boolean)):void 0,nC=({subprocess:e,encoding:t,buffer:n,maxBuffer:r,lines:i,stripFinalNewline:a,verboseInfo:o,streamInfo:s})=>eC({...rC(e,n),fdNumber:`all`,encoding:t,maxBuffer:r[1]+r[2],lines:i[1]||i[2],allMixed:iC(e),stripFinalNewline:a,verboseInfo:o,streamInfo:s}),rC=({stdout:e,stderr:t,all:n},[,r,i])=>{let a=r||i;return a?r?i?{stream:n,buffer:a}:{stream:e,buffer:a}:{stream:t,buffer:a}:{stream:n,buffer:a}},iC=({all:e,stdout:t,stderr:n})=>e&&t&&n&&t.readableObjectMode!==n.readableObjectMode,aC=e=>rf(e,`ipc`),oC=(e,t)=>{Vf({type:`ipc`,verboseMessage:Gf(e),fdNumber:`ipc`,verboseInfo:t})},sC=async({subprocess:e,buffer:t,maxBuffer:n,ipc:r,ipcOutput:i,verboseInfo:a})=>{if(!r)return i;let o=aC(a),s=tf(t,`ipc`),c=tf(n,`ipc`);for await(let t of Xb({anyProcess:e,channel:e.channel,isSubprocess:!1,ipc:r,shouldAwait:!1,reference:!0}))s&&(r_(e,i,c),i.push(t)),o&&oC(t,a);return i},cC=async(e,t)=>(await Promise.allSettled([e]),t),lC=async({subprocess:e,options:{encoding:t,buffer:n,maxBuffer:r,lines:i,timeoutDuration:a,cancelSignal:o,gracefulCancel:s,forceKillAfterDelay:c,stripFinalNewline:l,ipc:u,ipcInput:d},context:f,verboseInfo:p,fileDescriptors:m,originalStreams:h,onInternalError:g,controller:_})=>{let v=Db(e,f),y={originalStreams:h,fileDescriptors:m,subprocess:e,exitPromise:v,propagating:!1},ee=$S({subprocess:e,encoding:t,buffer:n,maxBuffer:r,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:y}),te=nC({subprocess:e,encoding:t,buffer:n,maxBuffer:r,lines:i,stripFinalNewline:l,verboseInfo:p,streamInfo:y}),ne=[],re=sC({subprocess:e,buffer:n,maxBuffer:r,ipc:u,ipcOutput:ne,verboseInfo:p}),ie=uC(h,e,y),ae=dC(m,y);try{return await Promise.race([Promise.all([{},Ab(v),Promise.all(ee),te,re,Rh(e,d),...ie,...ae]),g,fC(e,_),...Mh(e,a,f,_),...om({subprocess:e,cancelSignal:o,gracefulCancel:s,context:f,controller:_}),...Oh({subprocess:e,cancelSignal:o,gracefulCancel:s,forceKillAfterDelay:c,context:f,controller:_})])}catch(e){return f.terminationReason??=`other`,Promise.all([{error:e},v,Promise.all(ee.map(e=>HS(e))),HS(te),cC(re,ne),Promise.allSettled(ie),Promise.allSettled(ae)])}},uC=(e,t,n)=>e.map((e,r)=>e===t.stdio[r]?void 0:WS(e,r,n)),dC=(e,t)=>e.flatMap(({stdioItems:e},n)=>e.filter(({value:e,stream:t=e})=>og(t,{checkOpen:!1})&&!zd(t)).map(({type:e,value:r,stream:i=r})=>WS(i,n,t,{isSameDirection:ov.has(e),stopOnExit:e===`native`}))),fC=async(e,{signal:t})=>{let[n]=await x(e,`error`,{signal:t});throw n},pC=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),mC=(e,t,n)=>{let r=e[n];r.has(t)||r.set(t,[]);let i=r.get(t),a=Em();return i.push(a),{resolve:a.resolve.bind(a),promises:i}},hC=async({resolve:e,promises:t},n)=>{e();let[r]=await Promise.race([Promise.allSettled([!0,n]),Promise.all([!1,...t])]);return!r},gC=async e=>{if(e!==void 0)try{await vC(e)}catch{}},_C=async e=>{if(e!==void 0)try{await yC(e)}catch{}},vC=async e=>{await Ve(e,{cleanup:!0,readable:!1,writable:!0})},yC=async e=>{await Ve(e,{cleanup:!0,readable:!0,writable:!1})},bC=async(e,t)=>{if(await e,t)throw t},xC=(e,t,n)=>{n&&!ZS(n)?e.destroy(n):t&&e.destroy()},SC=({subprocess:e,concurrentStreams:t,encoding:n},{from:r,binary:i=!0,preserveNewlines:a=!0}={})=>{let o=i||Vh.has(n),{subprocessStdout:s,waitReadableDestroy:c}=CC(e,r,t),{readableEncoding:l,readableObjectMode:u,readableHighWaterMark:d}=wC(s,o),{read:f,onStdoutDataDone:p}=TC({subprocessStdout:s,subprocess:e,binary:o,encoding:n,preserveNewlines:a}),m=new We({read:f,destroy:Ee(OC.bind(void 0,{subprocessStdout:s,subprocess:e,waitReadableDestroy:c})),highWaterMark:d,objectMode:u,encoding:l});return DC({subprocessStdout:s,onStdoutDataDone:p,readable:m,subprocess:e}),m},CC=(e,t,n)=>{let r=Om(e,t);return{subprocessStdout:r,waitReadableDestroy:mC(n,r,`readableDestroy`)}},wC=({readableEncoding:e,readableObjectMode:t,readableHighWaterMark:n},r)=>r?{readableEncoding:e,readableObjectMode:t,readableHighWaterMark:n}:{readableEncoding:e,readableObjectMode:!0,readableHighWaterMark:PS},TC=({subprocessStdout:e,subprocess:t,binary:n,encoding:r,preserveNewlines:i})=>{let a=Em(),o=kS({subprocessStdout:e,subprocess:t,binary:n,shouldEncode:!n,encoding:r,preserveNewlines:i});return{read(){EC(this,o,a)},onStdoutDataDone:a}},EC=async(e,t,n)=>{try{let{value:r,done:i}=await t.next();i?n.resolve():e.push(r)}catch{}},DC=async({subprocessStdout:e,onStdoutDataDone:t,readable:n,subprocess:r,subprocessStdin:i})=>{try{await yC(e),await r,await gC(i),await t,n.readable&&n.push(null)}catch(e){await gC(i),kC(n,e)}},OC=async({subprocessStdout:e,subprocess:t,waitReadableDestroy:n},r)=>{await hC(n,t)&&(kC(e,r),await bC(t,r))},kC=(e,t)=>{xC(e,e.readable,t)},AC=({subprocess:e,concurrentStreams:t},{to:n}={})=>{let{subprocessStdin:r,waitWritableFinal:i,waitWritableDestroy:a}=jC(e,n,t),o=new Ke({...MC(r,e,i),destroy:Ee(IC.bind(void 0,{subprocessStdin:r,subprocess:e,waitWritableFinal:i,waitWritableDestroy:a})),highWaterMark:r.writableHighWaterMark,objectMode:r.writableObjectMode});return FC(r,o),o},jC=(e,t,n)=>{let r=Dm(e,t);return{subprocessStdin:r,waitWritableFinal:mC(n,r,`writableFinal`),waitWritableDestroy:mC(n,r,`writableDestroy`)}},MC=(e,t,n)=>({write:NC.bind(void 0,e),final:Ee(PC.bind(void 0,e,t,n))}),NC=(e,t,n,r)=>{e.write(t,n)?r():e.once(`drain`,r)},PC=async(e,t,n)=>{await hC(n,t)&&(e.writable&&e.end(),await t)},FC=async(e,t,n)=>{try{await vC(e),t.writable&&t.end()}catch(e){await _C(n),LC(t,e)}},IC=async({subprocessStdin:e,subprocess:t,waitWritableFinal:n,waitWritableDestroy:r},i)=>{await hC(n,t),await hC(r,t)&&(LC(e,i),await bC(t,i))},LC=(e,t)=>{xC(e,e.writable,t)},RC=({subprocess:e,concurrentStreams:t,encoding:n},{from:r,to:i,binary:a=!0,preserveNewlines:o=!0}={})=>{let s=a||Vh.has(n),{subprocessStdout:c,waitReadableDestroy:l}=CC(e,r,t),{subprocessStdin:u,waitWritableFinal:d,waitWritableDestroy:f}=jC(e,i,t),{readableEncoding:p,readableObjectMode:m,readableHighWaterMark:h}=wC(c,s),{read:g,onStdoutDataDone:_}=TC({subprocessStdout:c,subprocess:e,binary:s,encoding:n,preserveNewlines:o}),v=new He({read:g,...MC(u,e,d),destroy:Ee(zC.bind(void 0,{subprocessStdout:c,subprocessStdin:u,subprocess:e,waitReadableDestroy:l,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:h,writableHighWaterMark:u.writableHighWaterMark,readableObjectMode:m,writableObjectMode:u.writableObjectMode,encoding:p});return DC({subprocessStdout:c,onStdoutDataDone:_,readable:v,subprocess:e,subprocessStdin:u}),FC(u,v,c),v},zC=async({subprocessStdout:e,subprocessStdin:t,subprocess:n,waitReadableDestroy:r,waitWritableFinal:i,waitWritableDestroy:a},o)=>{await Promise.all([OC({subprocessStdout:e,subprocess:n,waitReadableDestroy:r},o),IC({subprocessStdin:t,subprocess:n,waitWritableFinal:i,waitWritableDestroy:a},o)])},BC=(e,t,{from:n,binary:r=!1,preserveNewlines:i=!1}={})=>{let a=r||Vh.has(t),o=Om(e,n),s=kS({subprocessStdout:o,subprocess:e,binary:a,shouldEncode:!0,encoding:t,preserveNewlines:i});return VC(s,o,e)},VC=async function*(e,t,n){try{yield*e}finally{t.readable&&t.destroy(),await n}},HC=(e,{encoding:t})=>{let n=pC();e.readable=SC.bind(void 0,{subprocess:e,concurrentStreams:n,encoding:t}),e.writable=AC.bind(void 0,{subprocess:e,concurrentStreams:n}),e.duplex=RC.bind(void 0,{subprocess:e,concurrentStreams:n,encoding:t}),e.iterable=BC.bind(void 0,e,t),e[Symbol.asyncIterator]=BC.bind(void 0,e,t,{})},UC=(e,t)=>{for(let[n,r]of GC){let i=r.value.bind(t);Reflect.defineProperty(e,n,{...r,value:i})}},WC=(async()=>{})().constructor.prototype,GC=[`then`,`catch`,`finally`].map(e=>[e,Reflect.getOwnPropertyDescriptor(WC,e)]),KC=(e,t,n,r)=>{let{file:i,commandArguments:a,command:o,escapedCommand:s,startTime:c,verboseInfo:l,options:u,fileDescriptors:d}=qC(e,t,n),{subprocess:f,promise:p}=YC({file:i,commandArguments:a,options:u,startTime:c,verboseInfo:l,command:o,escapedCommand:s,fileDescriptors:d});return f.pipe=ES.bind(void 0,{source:f,sourcePromise:p,boundOptions:{},createNested:r}),UC(f,p),km.set(f,{options:u,fileDescriptors:d}),f},qC=(e,t,n)=>{let{command:r,escapedCommand:i,startTime:a,verboseInfo:o}=ep(e,t,n),{file:s,commandArguments:c,options:l}=Yh(e,t,n),u=JC(l);return{file:s,commandArguments:c,command:r,escapedCommand:i,startTime:a,verboseInfo:o,options:u,fileDescriptors:dx(u,o)}},JC=({timeout:e,signal:t,...n})=>{if(t!==void 0)throw TypeError(`The "signal" option has been renamed to "cancelSignal" instead.`);return{...n,timeoutDuration:e}},YC=({file:e,commandArguments:t,options:n,startTime:r,verboseInfo:i,command:a,escapedCommand:o,fileDescriptors:s})=>{let c;try{c=Se(...Qh(e,t,n))}catch(e){return ix({error:e,command:a,escapedCommand:o,fileDescriptors:s,options:n,startTime:r,verboseInfo:i})}let l=new AbortController;ze(1/0,l.signal);let u=[...c.stdio];Bx(c,s,l),oS(c,n,l);let d={},f=Em();c.kill=$p.bind(void 0,{kill:c.kill.bind(c),options:n,onInternalError:f,context:d,controller:l}),c.all=tC(c,n),HC(c,n),tx(c,n);let p=XC({subprocess:c,options:n,startTime:r,verboseInfo:i,fileDescriptors:s,originalStreams:u,command:a,escapedCommand:o,context:d,onInternalError:f,controller:l});return{subprocess:c,promise:p}},XC=async({subprocess:e,options:t,startTime:n,verboseInfo:r,fileDescriptors:i,originalStreams:a,command:o,escapedCommand:s,context:c,onInternalError:l,controller:u})=>{let[d,[f,p],m,h,g]=await lC({subprocess:e,options:t,context:c,verboseInfo:r,fileDescriptors:i,originalStreams:a,onInternalError:l,controller:u});u.abort(),l.resolve();let _=m.map((e,n)=>Cy(e,t,n)),v=Cy(h,t,`all`);return N_(ZC({errorInfo:d,exitCode:f,signal:p,stdio:_,all:v,ipcOutput:g,context:c,options:t,command:o,escapedCommand:s,startTime:n}),r,t)},ZC=({errorInfo:e,exitCode:t,signal:n,stdio:r,all:i,ipcOutput:a,context:o,options:s,command:c,escapedCommand:l,startTime:u})=>`error`in e?v_({error:e.error,command:c,escapedCommand:l,timedOut:o.terminationReason===`timeout`,isCanceled:o.terminationReason===`cancel`||o.terminationReason===`gracefulCancel`,isGracefullyCanceled:o.terminationReason===`gracefulCancel`,isMaxBuffer:e.error instanceof Og,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:t,signal:n,stdio:r,all:i,ipcOutput:a,options:s,startTime:u,isSync:!1}):g_({command:c,escapedCommand:l,stdio:r,all:i,ipcOutput:a,options:s,startTime:u}),QC=(e,t)=>{let n=Object.fromEntries(Object.entries(t).map(([t,n])=>[t,$C(t,e[t],n)]));return{...e,...n}},$C=(e,t,n)=>ew.has(e)&&q(t)&&q(n)?{...t,...n}:n,ew=new Set([`env`,...ef]),tw=(e,t,n,r)=>{let i=(e,t,r)=>tw(e,t,n,r),a=(...a)=>nw({mapArguments:e,deepOptions:n,boundOptions:t,setBoundExeca:r,createNested:i},...a);return r!==void 0&&r(a,i,t),a},nw=({mapArguments:e,deepOptions:t={},boundOptions:n={},setBoundExeca:r,createNested:i},a,...o)=>{if(q(a))return i(e,QC(n,a),r);let{file:s,commandArguments:c,options:l,isSync:u}=rw({mapArguments:e,firstArgument:a,nextArguments:o,deepOptions:t,boundOptions:n});return u?Fb(s,c,l):KC(s,c,l,i)},rw=({mapArguments:e,firstArgument:t,nextArguments:n,deepOptions:r,boundOptions:i})=>{let[a,o,s]=gd(...Ad(t)?jd(t,n):[t,...n]),c=QC(QC(r,i),s),{file:l=a,commandArguments:u=o,options:d=c,isSync:f=!1}=e({file:a,commandArguments:o,options:c});return{file:l,commandArguments:u,options:d,isSync:f}},iw=({file:e,commandArguments:t})=>ow(e,t),aw=({file:e,commandArguments:t})=>({...ow(e,t),isSync:!0}),ow=(e,t)=>{if(t.length>0)throw TypeError(`The command and its arguments must be passed as a single string: ${e} ${t}.`);let[n,...r]=sw(e);return{file:n,commandArguments:r}},sw=e=>{if(typeof e!=`string`)throw TypeError(`The command must be a string: ${String(e)}.`);let t=e.trim();if(t===``)return[];let n=[];for(let e of t.split(cw)){let t=n.at(-1);t&&t.endsWith(`\\`)?n[n.length-1]=`${t.slice(0,-1)} ${e}`:n.push(e)}return n},cw=/ +/g,lw=(e,t,n)=>{e.sync=t(dw,n),e.s=e.sync},uw=({options:e})=>fw(e),dw=({options:e})=>({...fw(e),isSync:!0}),fw=e=>({options:{...pw(e),...e}}),pw=({input:e,inputFile:t,stdio:n})=>e===void 0&&t===void 0&&n===void 0?{stdin:`inherit`}:{},mw={preferLocal:!0},hw=tw(()=>({}));tw(()=>({isSync:!0})),tw(iw),tw(aw),tw(Ph),tw(uw,{},mw,lw);const{sendMessage:gw,getOneMessage:_w,getEachMessage:vw,getCancelSignal:yw}=nx(),bw=e=>e===void 0?{}:{cwd:e},xw=e=>e===void 0?{}:{timeout:e},Sw=(e,t)=>[e,`refs: command timed out after ${String(t)}ms`].filter(e=>e!==``).join(`
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
- if '${n}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
400
|
-
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
401
|
-
- ${t?`searched for local subcommand relative to directory '${t}'`:`no directory for search for local subcommand, use .executableDir() to supply a custom directory`}`;throw Error(r)}_executeSubCommand(e,t){t=t.slice();let n=[`.js`,`.ts`,`.tsx`,`.mjs`,`.cjs`];function r(e,t){let r=h.resolve(e,t);if(ie.existsSync(r))return r;if(n.includes(h.extname(t)))return;let i=n.find(e=>ie.existsSync(`${r}${e}`));if(i)return`${r}${i}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let i=e._executableFile||`${this._name}-${e._name}`,a=this._executableDir||``;if(this._scriptPath){let e;try{e=ie.realpathSync(this._scriptPath)}catch{e=this._scriptPath}a=h.resolve(h.dirname(e),a)}if(a){let t=r(a,i);if(!t&&!e._executableFile&&this._scriptPath){let n=h.basename(this._scriptPath,h.extname(this._scriptPath));n!==this._name&&(t=r(a,`${n}-${e._name}`))}i=t||i}let o=n.includes(h.extname(i)),s;b.platform===`win32`?(this._checkForMissingExecutable(i,a,e._name),t.unshift(i),t=gT(b.execArgv).concat(t),s=ye.spawn(b.execPath,t,{stdio:`inherit`})):o?(t.unshift(i),t=gT(b.execArgv).concat(t),s=ye.spawn(b.argv[0],t,{stdio:`inherit`})):s=ye.spawn(i,t,{stdio:`inherit`}),s.killed||[`SIGUSR1`,`SIGUSR2`,`SIGTERM`,`SIGINT`,`SIGHUP`].forEach(e=>{b.on(e,()=>{s.killed===!1&&s.exitCode===null&&s.kill(e)})});let c=this._exitCallback;s.on(`close`,e=>{e??=1,c?c(new iT(e,`commander.executeSubCommandAsync`,`(close)`)):b.exit(e)}),s.on(`error`,t=>{if(t.code===`ENOENT`)this._checkForMissingExecutable(i,a,e._name);else if(t.code===`EACCES`)throw Error(`'${i}' not executable`);if(!c)b.exit(1);else{let e=new iT(1,`commander.executeSubCommandAsync`,`(error)`);e.nestedError=t,c(e)}}),this.runningCommand=s}_dispatchSubcommand(e,t,n){let r=this._findCommand(e);r||this.help({error:!0}),r._prepareForParse();let i;return i=this._chainOrCallSubCommandHook(i,r,`preSubcommand`),i=this._chainOrCall(i,()=>{if(r._executableHandler)this._executeSubCommand(r,t.concat(n));else return r._parseCommand(t,n)}),i}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??`--help`])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(e,t,n)=>{let r=t;if(t!==null&&e.parseArg){let i=`error: command-argument value '${t}' is invalid for argument '${e.name()}'.`;r=this._callParseArg(e,t,n,i)}return r};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((n,r)=>{let i=n.defaultValue;n.variadic?r<this.args.length?(i=this.args.slice(r),n.parseArg&&(i=i.reduce((t,r)=>e(n,r,t),n.defaultValue))):i===void 0&&(i=[]):r<this.args.length&&(i=this.args[r],n.parseArg&&(i=e(n,i,n.defaultValue))),t[r]=i}),this.processedArgs=t}_chainOrCall(e,t){return e?.then&&typeof e.then==`function`?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let n=e,r=[];return this._getCommandAndAncestors().reverse().filter(e=>e._lifeCycleHooks[t]!==void 0).forEach(e=>{e._lifeCycleHooks[t].forEach(t=>{r.push({hookedCommand:e,callback:t})})}),t===`postAction`&&r.reverse(),r.forEach(e=>{n=this._chainOrCall(n,()=>e.callback(e.hookedCommand,this))}),n}_chainOrCallSubCommandHook(e,t,n){let r=e;return this._lifeCycleHooks[n]!==void 0&&this._lifeCycleHooks[n].forEach(e=>{r=this._chainOrCall(r,()=>e(this,t))}),r}_parseCommand(e,t){let n=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(n.operands),t=n.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},i=`command:${this.name()}`;if(this._actionHandler){r(),this._processArguments();let n;return n=this._chainOrCallHooks(n,`preAction`),n=this._chainOrCall(n,()=>this._actionHandler(this.processedArgs)),this.parent&&(n=this._chainOrCall(n,()=>{this.parent.emit(i,e,t)})),n=this._chainOrCallHooks(n,`postAction`),n}if(this.parent?.listenerCount(i))r(),this._processArguments(),this.parent.emit(i,e,t);else if(e.length){if(this._findCommand(`*`))return this._dispatchSubcommand(`*`,e,t);this.listenerCount(`command:*`)?this.emit(`command:*`,e,t):this.commands.length?this.unknownCommand():(r(),this._processArguments())}else this.commands.length?(r(),this.help({error:!0})):(r(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(e=>{let t=e.attributeName();return this.getOptionValue(t)===void 0?!1:this.getOptionValueSource(t)!=="default"});e.filter(e=>e.conflictsWith.length>0).forEach(t=>{let n=e.find(e=>t.conflictsWith.includes(e.attributeName()));n&&this._conflictingOption(t,n)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],n=[],r=t;function i(e){return e.length>1&&e[0]===`-`}let a=e=>/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(e)?!this._getCommandAndAncestors().some(e=>e.options.map(e=>e.short).some(e=>/^-\d$/.test(e))):!1,o=null,s=null,c=0;for(;c<e.length||s;){let l=s??e[c++];if(s=null,l===`--`){r===n&&r.push(l),r.push(...e.slice(c));break}if(o&&(!i(l)||a(l))){this.emit(`option:${o.name()}`,l);continue}if(o=null,i(l)){let t=this._findOption(l);if(t){if(t.required){let n=e[c++];n===void 0&&this.optionMissingArgument(t),this.emit(`option:${t.name()}`,n)}else if(t.optional){let n=null;c<e.length&&(!i(e[c])||a(e[c]))&&(n=e[c++]),this.emit(`option:${t.name()}`,n)}else this.emit(`option:${t.name()}`);o=t.variadic?t:null;continue}}if(l.length>2&&l[0]===`-`&&l[1]!==`-`){let e=this._findOption(`-${l[1]}`);if(e){e.required||e.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${e.name()}`,l.slice(2)):(this.emit(`option:${e.name()}`),s=`-${l.slice(2)}`);continue}}if(/^--[^=]+=/.test(l)){let e=l.indexOf(`=`),t=this._findOption(l.slice(0,e));if(t&&(t.required||t.optional)){this.emit(`option:${t.name()}`,l.slice(e+1));continue}}if(r===t&&i(l)&&!(this.commands.length===0&&a(l))&&(r=n),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&n.length===0){if(this._findCommand(l)){t.push(l),n.push(...e.slice(c));break}else if(this._getHelpCommand()&&l===this._getHelpCommand().name()){t.push(l,...e.slice(c));break}else if(this._defaultCommandName){n.push(l,...e.slice(c));break}}if(this._passThroughOptions){r.push(l,...e.slice(c));break}r.push(l)}return{operands:t,unknown:n}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let n=0;n<t;n++){let t=this.options[n].attributeName();e[t]=t===this._versionOptionName?this._version:this[t]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}\n`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==`string`?this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
|
|
402
|
-
`),this.outputHelp({error:!0}));let n=t||{},r=n.exitCode||1,i=n.code||`commander.error`;this._exit(r,i,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in b.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||[`default`,`config`,`env`].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,b.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new uT(this.options),t=e=>this.getOptionValue(e)!==void 0&&![`default`,`implied`].includes(this.getOptionValueSource(e));this.options.filter(n=>n.implied!==void 0&&t(n.attributeName())&&e.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(e=>{Object.keys(e.implied).filter(e=>!t(e)).forEach(t=>{this.setOptionValueWithSource(t,e.implied[t],`implied`)})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:`commander.missingArgument`})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:`commander.optionMissingArgument`})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:`commander.missingMandatoryOptionValue`})}_conflictingOption(e,t){let n=e=>{let t=e.attributeName(),n=this.getOptionValue(t),r=this.options.find(e=>e.negate&&t===e.attributeName()),i=this.options.find(e=>!e.negate&&t===e.attributeName());return r&&(r.presetArg===void 0&&n===!1||r.presetArg!==void 0&&n===r.presetArg)?r:i||e},r=e=>{let t=n(e),r=t.attributeName();return this.getOptionValueSource(r)===`env`?`environment variable '${t.envVar}'`:`option '${t.flags}'`},i=`error: ${r(e)} cannot be used with ${r(t)}`;this.error(i,{code:`commander.conflictingOption`})}unknownOption(e){if(this._allowUnknownOption)return;let t=``;if(e.startsWith(`--`)&&this._showSuggestionAfterError){let n=[],r=this;do{let e=r.createHelp().visibleOptions(r).filter(e=>e.long).map(e=>e.long);n=n.concat(e),r=r.parent}while(r&&!r._enablePositionalOptions);t=mT(e,n)}let n=`error: unknown option '${e}'${t}`;this.error(n,{code:`commander.unknownOption`})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,n=t===1?``:`s`,r=e.length,i=`error: too many arguments${this.parent?` for '${this.name()}'`:``}. Expected ${t} argument${n} but got ${r}: ${e.join(`, `)}.`;this.error(i,{code:`commander.excessArguments`})}unknownCommand(){let e=this.args[0],t=``;if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach(e=>{n.push(e.name()),e.alias()&&n.push(e.alias())}),t=mT(e,n)}let n=`error: unknown command '${e}'${t}`;this.error(n,{code:`commander.unknownCommand`})}version(e,t,n){if(e===void 0)return this._version;this._version=e,t||=`-V, --version`,n||=`output the version number`;let r=this.createOption(t,n);return this._versionOptionName=r.attributeName(),this._registerOption(r),this.on(`option:`+r.name(),()=>{this._outputConfiguration.writeOut(`${e}\n`),this._exit(0,`commander.version`,e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw Error(`Command alias can't be the same as its name`);let n=this.parent?._findCommand(e);if(n){let t=[n.name()].concat(n.aliases()).join(`|`);throw Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${t}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(e=>this.alias(e)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let e=this.registeredArguments.map(e=>sT(e));return[].concat(this.options.length||this._helpOption!==null?`[options]`:[],this.commands.length?`[command]`:[],this.registeredArguments.length?e:[]).join(` `)}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}helpGroup(e){return e===void 0?this._helpGroupHeading??``:(this._helpGroupHeading=e,this)}commandsGroup(e){return e===void 0?this._defaultCommandGroup??``:(this._defaultCommandGroup=e,this)}optionsGroup(e){return e===void 0?this._defaultOptionGroup??``:(this._defaultOptionGroup=e,this)}_initOptionGroup(e){this._defaultOptionGroup&&!e.helpGroupHeading&&e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){this._defaultCommandGroup&&!e.helpGroup()&&e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=h.basename(e,h.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp(),n=this._getOutputContext(e);t.prepareContext({error:n.error,helpWidth:n.helpWidth,outputHasColors:n.hasColors});let r=t.formatHelp(this,t);return n.hasColors?r:this._outputConfiguration.stripColor(r)}_getOutputContext(e){e||={};let t=!!e.error,n,r,i;return t?(n=e=>this._outputConfiguration.writeErr(e),r=this._outputConfiguration.getErrHasColors(),i=this._outputConfiguration.getErrHelpWidth()):(n=e=>this._outputConfiguration.writeOut(e),r=this._outputConfiguration.getOutHasColors(),i=this._outputConfiguration.getOutHelpWidth()),{error:t,write:e=>(r||(e=this._outputConfiguration.stripColor(e)),n(e)),hasColors:r,helpWidth:i}}outputHelp(e){let t;typeof e==`function`&&(t=e,e=void 0);let n=this._getOutputContext(e),r={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach(e=>e.emit(`beforeAllHelp`,r)),this.emit(`beforeHelp`,r);let i=this.helpInformation({error:n.error});if(t&&(i=t(i),typeof i!=`string`&&!Buffer.isBuffer(i)))throw Error(`outputHelp callback must return a string or a Buffer`);n.write(i),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit(`afterHelp`,r),this._getCommandAndAncestors().forEach(e=>e.emit(`afterAllHelp`,r))}helpOption(e,t){return typeof e==`boolean`?(e?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(e??`-h, --help`,t??`display help for command`),(e||t)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let t=Number(b.exitCode??0);t===0&&e&&typeof e!=`function`&&e.error&&(t=1),this._exit(t,`commander.help`,`(outputHelp)`)}addHelpText(e,t){let n=[`beforeAll`,`before`,`after`,`afterAll`];if(!n.includes(e))throw Error(`Unexpected value for position to addHelpText.
|
|
403
|
-
Expecting one of '${n.join(`', '`)}'`);let r=`${e}Help`;return this.on(r,e=>{let n;n=typeof t==`function`?t({error:e.error,command:e.command}):t,n&&e.write(`${n}\n`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(e=>t.is(e))&&(this.outputHelp(),this._exit(0,`commander.helpDisplayed`,`(outputHelp)`))}};function gT(e){return e.map(e=>{if(!e.startsWith(`--inspect`))return e;let t,n=`127.0.0.1`,r=`9229`,i;return(i=e.match(/^(--inspect(-brk)?)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))===null?(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=i[1],n=i[3],r=i[4]):(t=i[1],/^\d+$/.test(i[3])?r=i[3]:n=i[3]):t=i[1],t&&r!==`0`?`${t}=${n}:${parseInt(r)+1}`:e})}function _T(){if(b.env.NO_COLOR||b.env.FORCE_COLOR===`0`||b.env.FORCE_COLOR===`false`)return!1;if(b.env.FORCE_COLOR||b.env.CLICOLOR_FORCE!==void 0)return!0}new hT;const vT=[],yT=e=>Array.isArray(e)?e:[e],Q=(e,t,n,r,i)=>{if(t.json){let t={data:r,ok:!0,warnings:i??vT};e.out(JSON.stringify(t));return}for(let t of yT(n))e.out(t);for(let t of i??vT)e.errLine(`refs: warning: ${t}`)},bT=(e,t,n)=>{if(t.json){let t={error:{code:n.code,message:n.message},ok:!1};e.out(JSON.stringify(t));return}e.errLine(`refs: ${n.message}`)},xT=(e,t)=>{e.errLine(`refs: ${t}`)},$=(e,t,n)=>async()=>{try{await n()}catch(n){let r=ct(n,{verbose:t.verbose});bT(e,t,r),process.exitCode=r.exitCode}};var ST=`0.1.2`;const CT=async e=>{let t=await e.runner.run(`git`,[`--version`]);return t.exitCode===0?{detail:t.stdout.trim(),name:`git`,status:`ok`}:{detail:t.stderr.trim()||`git --version exited with code ${t.exitCode}`,name:`git`,status:`fail`}},wT=/^v(?<major>\d+)\.(?<minor>\d+)/u,TT=e=>{let t=wT.exec(e),n=t?.groups?.major,r=t?.groups?.minor;if(!(n===void 0||r===void 0))return{major:Number(n),minor:Number(r)}},ET=e=>e===void 0?!1:e.major===24&&e.minor>=12,DT=e=>{let{nodeVersion:t}=e;return ET(TT(t))?{detail:t,name:`node`,status:`ok`}:{detail:`${t} does not satisfy the required range >=24.12 <25`,name:`node`,status:`fail`}},OT=e=>e instanceof Error?e.message:String(e),kT=()=>tc.parse({meta:{cli_version:`0.0.0`,schema_version:1},refs:{},settings:{}}),AT=async e=>{try{return{config:await H(e)}}catch(e){return{config:kT(),errorMessage:OT(e)}}},jT=e=>e===void 0?{detail:`config is present and matches the current schema`,name:`config`,status:`ok`}:{detail:e,name:`config`,status:`fail`},MT=[`.claude`,`skills`,`refs`,`SKILL.md`],NT=[`.codex`,`skills`,`refs`,`SKILL.md`],PT=e=>e===void 0?[]:[y(e,...MT),y(e,...NT)],FT=async e=>{try{return await t(e),!0}catch{return!1}},IT=async e=>{let t=PT(e.env.HOME);return(await Promise.all(t.map(e=>FT(e)))).some(Boolean)?{detail:`the refs skill is installed`,name:`skill`,status:`ok`}:{detail:`refs skill not found — install it: npx skills add kaisers-io/refs`,name:`skill`,status:`warn`}},LT=(e,t)=>Object.keys(t.refs).map(t=>({dest:V(e,Us.parse(t)),key:t})).filter(e=>U(e.dest)),RT=[`pre-commit`,`pre-push`],zT=async(e,n)=>{try{return await t(y(e.hooksDir,n),r.X_OK),!0}catch{return!1}},BT=async e=>{let t=await Promise.all(RT.map(t=>zT(e,t)));return RT.filter((e,n)=>!t[n])},VT=async(e,t,n)=>{let r=await e.runner.run(`git`,[`config`,`--local`,`--get`,`core.hooksPath`],{cwd:n});return r.exitCode===0&&r.stdout.trim()===t.hooksDir},HT=e=>e.missingHooks.length>0?{detail:`${e.missingHooks.map(e=>`hooks/${e}`).join(`, `)} missing or not executable — run: refs init`,name:`hooks-guard`,status:`fail`}:e.badKeys.length>0?{detail:`core.hooksPath not set for: ${e.badKeys.join(`, `)} — run: refs init`,name:`hooks-guard`,status:`fail`}:{detail:`${RT.map(e=>`hooks/${e}`).join(`, `)} present; ${e.checkoutCount} checkout(s) guarded`,name:`hooks-guard`,status:`ok`},UT=async(e,t,n)=>{let r=LT(t,n),[i,a]=await Promise.all([BT(t),Promise.all(r.map(n=>VT(e,t,n.dest)))]),o=r.filter((e,t)=>!a[t]).map(e=>e.key);return HT({badKeys:o,checkoutCount:r.length,missingHooks:i})},WT=async(e,t)=>{let n=await e.runner.run(`git`,[`status`,`--porcelain`],{cwd:t.dest});return n.exitCode===0?{broken:!1,detail:``,dirty:n.stdout.trim()!==``,key:t.key}:{broken:!0,detail:n.stderr.trim(),dirty:!1,key:t.key}},GT=e=>{let t=e.filter(e=>e.broken);if(t.length>0)return{detail:t.map(e=>`${e.key}: git status failed — ${e.detail}`).join(`; `),name:`dirty-checkouts`,status:`fail`};let n=e.filter(e=>e.dirty).map(e=>e.key);return n.length===0?{detail:`no local changes in any checkout`,name:`dirty-checkouts`,status:`ok`}:{detail:`local changes will be discarded on next sync: ${n.join(`, `)}`,name:`dirty-checkouts`,status:`warn`}},KT=async(e,t,n)=>{let r=LT(t,n),i=await Promise.all(r.map(t=>WT(e,t)));return GT(i)},qT=async e=>{try{return await Nw(e)}catch{return kw.parse({})}},JT=async e=>{try{return(await c(e,{withFileTypes:!0})).filter(e=>e.isDirectory()).map(e=>e.name)}catch(e){if(Lc(e))return[];throw e}},YT=async(e,t)=>{if(U(e))return[[...t]];let n=await JT(e);return(await Promise.all(n.map(n=>YT(y(e,n),[...t,n])))).flat()},XT=(e,t,n)=>{let r=e.refs[t]?.pending_proposal_at;return r===void 0?!1:n-Date.parse(r)<864e5},ZT=(e,t,n)=>XT(t,e.key,n)?`${e.key}: pending add`:`${e.key}: orphan — remove with: rm -rf ${e.dest}`,QT=(e,t)=>({dest:y(e.sourcesDir,...t),key:t.join(`/`)}),$T=async(e,t,n)=>{let r=(await YT(e.sourcesDir,[])).map(t=>QT(e,t)).filter(e=>!Object.hasOwn(t.refs,e.key));if(r.length===0)return{detail:`no orphaned checkouts under sources/`,name:`orphans`,status:`ok`};let i=Date.now();return{detail:r.map(e=>ZT(e,n,i)).join(`; `),name:`orphans`,status:`warn`}},eE=/^(?<user>[^/\s@]+)@(?<host>[^:/\s]+):/u,tE=e=>e===``?{}:{user:e},nE=e=>e===``?{}:{port:e},rE=e=>{try{let t=new URL(e);return t.protocol===`ssh:`?{host:t.hostname,...tE(t.username),...nE(t.port)}:void 0}catch{return}},iE=e=>{let t=eE.exec(e),n=t?.groups?.host;return n===void 0?rE(e):{host:n,user:t?.groups?.user??`git`}},aE=e=>e.port===void 0?e.host:`${e.host}:${e.port}`,oE=e=>e.user===void 0?aE(e):`${e.user}@${aE(e)}`,sE=e=>{let t=Object.values(e.refs).map(e=>iE(e.url)).filter(e=>e!==void 0),n=new Map;for(let e of t)n.set(oE(e),e);return[...n.values()].toSorted((e,t)=>oE(e).localeCompare(oE(t)))},cE=/Permission denied/u,lE=[/Could not resolve hostname/u,/Connection refused/u,/Host key verification failed/u,/timed out/u],uE=e=>e.user===void 0?e.host:`${e.user}@${e.host}`,dE=e=>{let t=[`-o`,`ConnectTimeout=5`,`-o`,`BatchMode=yes`],n=uE(e);return e.port===void 0?[...t,`-T`,n]:[...t,`-p`,e.port,`-T`,n]},fE=async(e,t,n)=>{let r=oE(t),i=await e.runner.run(`ssh`,dE(t),{timeoutMs:n});return i.timedOut===!0?{host:r,outcome:`timeout`}:cE.test(i.stderr)?{host:r,outcome:`denied`}:lE.some(e=>e.test(i.stderr))?{detail:i.stderr.trim(),host:r,outcome:`connection-warn`}:{host:r,outcome:`ok`}},pE=(e,t)=>{let n=e.filter(e=>e.outcome===`timeout`).map(e=>e.host);if(n.length!==0)return{detail:`ssh probe timed out after ${t/1e3}s: ${n.join(`, `)}`,name:`ssh-auth`,status:`fail`}},mE=e=>{let t=e.filter(e=>e.outcome===`denied`).map(e=>e.host);if(t.length!==0)return{detail:`ssh permission denied for: ${t.join(`, `)}`,name:`ssh-auth`,status:`fail`}},hE=e=>{let t=e.filter(e=>e.outcome===`connection-warn`);if(t.length!==0)return{detail:`ssh connection issue, treated as warn: ${t.map(e=>`${e.host} (${e.detail??``})`).join(`; `)}`,name:`ssh-auth`,status:`warn`}},gE=e=>({detail:`ssh auth ok for: ${e.map(e=>e.host).join(`, `)}`,name:`ssh-auth`,status:`ok`}),_E=(e,t)=>pE(e,t)??mE(e)??hE(e)??gE(e),vE=async(e,t,n)=>{let r=sE(t);if(r.length===0)return;let i=n?.timeoutMs??1e4,a=await Promise.all(r.map(t=>fE(e,t,i)));return _E(a,i)},yE=async e=>{try{return await e.run()}catch(t){return{detail:`check crashed: ${OT(t)}`,name:e.name,status:`fail`}}},bE=async e=>{let[t,...n]=e;if(t===void 0)return[];let r=await yE(t),i=await bE(n);return r===void 0?i:[r,...i]},xE=e=>{let{configLoad:t,ctx:n,home:r,state:i}=e;return[{name:`git`,run:()=>CT(n)},{name:`node`,run:()=>Promise.resolve(DT(n))},{name:`config`,run:()=>Promise.resolve(jT(t.errorMessage))},{name:`hooks-guard`,run:()=>UT(n,r,t.config)},{name:`dirty-checkouts`,run:()=>KT(n,r,t.config)},{name:`orphans`,run:()=>$T(r,t.config,i)},{name:`skill`,run:()=>IT(n)},{name:`ssh-auth`,run:()=>vE(n,t.config)}]},SE=async e=>{let t=B(e.env),n=await AT(t),r=await qT(t);return bE(xE({configLoad:n,ctx:e,home:t,state:r}))},CE={fail:`FAIL`,ok:`OK`,warn:`WARN`},wE=e=>e.map(e=>`[${CE[e.status]}] ${e.name}: ${e.detail}`),TE=e=>e.some(e=>e.status===`fail`),EE=(e,t)=>{e.command(`doctor`).description(`Run environment/integrity checks (git, node, config, hooks, checkouts, ssh).`).action((e,n)=>{let r=n.optsWithGlobals(),i={json:r.json===!0,verbose:r.verbose===!0};return $(t,i,async()=>{let e=await SE(t);Q(t,i,wE(e),{checks:e}),TE(e)&&(process.exitCode=it.UNEXPECTED)})()})},DE=async e=>{let t=B(e.env),n=await K(t,`home`,()=>sl(t,ST));return n===`migrated`?{backup:zc(t),result:n}:{backup:null,result:n}},OE=e=>e.result===`migrated`&&e.backup!==null?`config migrated (backup: ${g(e.backup)})`:e.result===`seeded`?`config seeded`:`config up to date`,kE=(e,t)=>{e.command(`migrate`).description(`Migrate the refs config to the current schema, seeding it if absent.`).action((e,n)=>{let r=n.optsWithGlobals(),i={json:r.json===!0,verbose:r.verbose===!0};return $(t,i,async()=>{let e=await DE(t);Q(t,i,OE(e),e)})()})},AE=(e,t,n)=>e===void 0?!0:n-Date.parse(e)>t,jE=(e,t,n)=>{let r=e.state.refs[t],i=Gs(Aw(`sync_ttl`,n,e.settings));return{clone_mode:Aw(`clone_mode`,n,e.settings),description:n.description,key:t,missing:!U(V(e.home,Us.parse(t))),packages:Object.keys(n.packages??{}).toSorted(),stale:AE(r?.last_fetched_at,i,e.now)}},ME=e=>{let t={home:e.home,now:e.now,settings:e.config.settings,state:e.state};return Object.entries(e.config.refs).map(([e,n])=>jE(t,e,n)).toSorted((e,t)=>e.key.localeCompare(t.key))},NE=async e=>{let t=B(e.env),n=await H(t),r=await Nw(t);return ME({config:n,home:t,now:Date.now(),state:r})},PE=e=>{let t=[];return e.stale&&t.push(`[stale]`),e.missing&&t.push(`[missing]`),t.length===0?``:` ${t.join(` `)}`},FE=e=>e.length===0?[`no refs configured — run: refs add <source>`]:e.map(e=>`${e.key} ${e.description}${PE(e)}`),IE=e=>e.split(`/`),LE=(e,t)=>{let n=IE(e);if(t.length>n.length)return!1;let r=n.length-t.length;return t.every((e,t)=>e===n[r+t])},RE=(e,t)=>{if(Object.hasOwn(e.refs,t))return Us.parse(t);let n=IE(t),r=Object.keys(e.refs).filter(e=>LE(e,n)).toSorted(),[i]=r;if(i===void 0)throw C(`no ref matches '${t}'`);if(r.length>1)throw w(`'${t}' matches more than one ref: ${r.join(`, `)}`);return Us.parse(i)},zE=(e,t)=>{e.command(`list`).description(`List configured refs with their staleness/missing checkout status.`).action((e,n)=>{let r=n.optsWithGlobals(),i={json:r.json===!0,verbose:r.verbose===!0};return $(t,i,async()=>{let e=await NE(t);Q(t,i,FE(e),e)})()})},BE=e=>`ref:${e.replaceAll(`/`,`_`)}`,VE=e=>e.REFS_ALLOW_FILE_URLS===`1`,HE=(e,t)=>{let n=lu(t,{allowFileUrls:VE(e.env)});return{cloneUrl:n.cloneUrl,key:n.key}},UE=async(e,t)=>{if(t===``)throw w(`refs add npm: requires a package name, e.g. npm:left-pad`);xT(e,`resolving npm package '${t}'…`);let n=await dd(e.fetcher,t),r={cloneUrl:n.cloneUrl,key:n.key,npmPkgName:t};return n.directory!==void 0&&(r.npmDirectory=n.directory),r},WE=(e,t)=>t.startsWith(`npm:`)?UE(e,t.slice(4)):Promise.resolve(HE(e,t)),GE=(e,t)=>{if(e.npmPkgName===void 0)return e;let n=Aw(`git_transport`,void 0,t);return{...e,cloneUrl:xu(e.cloneUrl,n)}},KE=e=>`ref '${e}' already exists — use refs edit or refs remove`,qE=(e,t)=>{if(e.refs[t]!==void 0)throw ot(KE(t))},JE=async e=>{try{return await c(e,{withFileTypes:!0})}catch(e){if(Lc(e))return;throw e}},YE=e=>e.filter(e=>e.isDirectory()).map(e=>e.name),XE=async(e,t)=>{let n=await JE(e);if(n===void 0)return{kind:`stop`};let r=YE(n);if(r.includes(t))return{kind:`continue`,nextDir:y(e,t)};let i=r.find(e=>e.toLowerCase()===t.toLowerCase());return i===void 0?{kind:`stop`}:{kind:`collision`,name:i}},ZE=async(e,t,n)=>{let[r,...i]=t;if(r===void 0)return;let a=await XE(e,r);if(a.kind!==`stop`)return a.kind===`collision`?[...n,a.name].join(`/`):ZE(a.nextDir,i,[...n,r])},QE=[],$E=async(e,t)=>{let n=await ZE(e.sourcesDir,t.split(`/`),QE);if(n!==void 0)throw ot(`checkout path for '${t}' collides case-insensitively with existing '${n}'`)},eD=[],tD=e=>e===void 0?eD:[e],nD=async e=>{try{return await a(e),!0}catch(e){if(Lc(e))return!1;throw e}},rD=async e=>{try{return await c(e)}catch(e){if(Lc(e))return;throw e}},iD=async e=>{try{return(await a(e)).isDirectory()}catch(e){if(Lc(e))return;throw e}},aD=async e=>{let t=await rD(e);if(t===void 0)return!0;if(t.length!==0)return!1;try{await f(e)}catch(e){if(!Lc(e))throw e}return!0},oD=async e=>{let t=await iD(e);return t===void 0?!0:t?aD(e):!1},sD=async(e,t)=>{t!==e.sourcesDir&&await oD(t)&&await sD(e,_(t))},cD=async(e,t)=>await nD(t)?(Hc(e,t),await d(t,{force:!0,recursive:!0}),await sD(e,_(t)),{removedCheckout:!0}):{removedCheckout:!1,warning:`checkout was already missing`},lD=(e,t)=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)),uD=async(e,t)=>{let n=await H(e);await Xc(e,{...n,refs:lD(n.refs,t)});let r=await Nw(e);await Pw(e,{...r,refs:lD(r.refs,t)})},dD=async(e,t)=>{let n=B(e.env),r=RE(await H(n),t),i=V(n,r),{removedCheckout:a,warning:o}=await K(n,BE(r),()=>cD(n,i));return await K(n,`home`,()=>uD(n,r)),{data:{key:r,removed_checkout:a},warnings:tD(o)}},fD=e=>e.removed_checkout?[`removed ${e.key} (checkout deleted)`]:[`removed ${e.key} (checkout was already missing)`],pD=(e,t)=>{e.command(`remove`).description(`Remove a configured ref: its config/state entry AND its checkout directory.`).argument(`<ref>`,`full ref key or a unique suffix, e.g. next.js`).action((e,n,r)=>{let i=r.optsWithGlobals(),a={json:i.json===!0,verbose:i.verbose===!0};return $(t,a,async()=>{let{data:n,warnings:r}=await dD(t,e);Q(t,a,fD(n),n,r)})()})},mD=e=>`no ref matches '${e}' — run refs list, or add it: refs add <url>`,hD=/^[a-z][a-z0-9+.-]*:\/\//iu,gD=/^git@[^:/\s]+:[^\s]+$/u,_D=e=>hD.test(e)||gD.test(e),vD=(e,t)=>{try{return lu(e,t)}catch{if(_D(e))throw T(`query looks like a git url but is not a supported form — check the url (credentials are never accepted) or run: refs resolve <package|ref-suffix>`);return}},yD=(e,t,n)=>{let r=vD(t,n);if(r!==void 0){if(Object.hasOwn(e.refs,r.key))return{key:r.key};throw C(mD(t))}},bD=(e,t)=>{let n=[];for(let r of Object.keys(e.refs).toSorted()){let i=e.refs[r]?.packages?.[t];i!==void 0&&n.push({entry:i,key:Us.parse(r)})}return n},xD=(e,t)=>`package '${e}' is registered by more than one ref: ${t.join(`, `)} — use the full ref key`,SD=(e,t)=>{let n=bD(e,t),[r]=n;if(r!==void 0){if(n.length>1)throw w(xD(t,n.map(e=>e.key)));return r}},CD=(e,t)=>{let n=t.split(`/`);for(let t=n.length-1;t>=1;--t){let r=n.slice(0,t).join(`/`),i=SD(e,r);if(i!==void 0)return{...i,name:r}}},wD=(e,t)=>{try{return RE(e,t)}catch(e){throw e instanceof at&&e.code===`not_found`?C(mD(t)):e}},TD=(e,t,n)=>{let r=yD(e,t,n);if(r!==void 0)return r;let i=SD(e,t);if(i!==void 0)return{key:i.key,packageMatch:{...i,name:t}};let a=CD(e,t);return a===void 0?{key:wD(e,t)}:{key:a.key,packageMatch:a}},ED=(e,t)=>{let n=e.refs[t];if(n===void 0)throw Error(`internal: resolved ref key '${t}' is missing from config.refs`);return n},DD=(e,t)=>{if(e.packageMatch===void 0)return null;let{entry:n,name:r}=e.packageMatch;return{local_path:y(t,n.path),name:r,path:n.path}},OD=async(e,t)=>{let n=B(e.env),r=await H(n),i=TD(r,t,{allowFileUrls:VE(e.env)}),a=ED(r,i.key),o=await Nw(n),s=V(n,i.key),c=Gs(Aw(`sync_ttl`,a,r.settings));return{key:i.key,local_path:s,missing:!U(s),package:DD(i,s),stale:AE(o.refs[i.key]?.last_fetched_at,c,Date.now())}},kD=e=>{let t=[e.key,`local_path: ${e.local_path}`];return e.package!==null&&t.push(`package: ${e.package.name}`,`local_path: ${e.package.local_path}`),t},AD=(e,t)=>{e.command(`resolve`).description(`Resolve a git url, npm package name, import path, or ref-key suffix to its ref/package.`).argument(`<query>`,`git url, npm package name, import path, or unique ref-key suffix`).action((e,n,r)=>{let i=r.optsWithGlobals(),a={json:i.json===!0,verbose:i.verbose===!0};return $(t,a,async()=>{let n=await OD(t,e);Q(t,a,kD(n),n)})()})},jD={},MD=(e,t)=>{let n=e.refs[t];if(n===void 0)throw Error(`internal: matched ref key '${t}' is missing from config.refs`);return n},ND=e=>e instanceof Error?e.message:String(e),PD=async(e,t)=>{if(!U(t))return{tags:[]};try{return{tags:await Dl(e.runner,t,5)}}catch(e){return{tags:[],warning:`could not list tags: ${ND(e)}`}}},FD=[],ID=e=>e===void 0?FD:[e],LD=async(e,t)=>{let n=B(e.env),r=await H(n),i=RE(r,t),a=MD(r,i),o=await Nw(n),s=V(n,i),{tags:c,warning:l}=await PD(e,s);return{data:{...a,key:i,local_path:s,sample_tags:c,state:o.refs[i]??jD},warnings:ID(l)}},RD=e=>{let t=[`${e.key} ${e.description}`,`url: ${e.url}`,`local_path: ${e.local_path}`];return e.sample_tags.length>0&&t.push(`tags: ${e.sample_tags.join(`, `)}`),t},zD=(e,t)=>{e.command(`show`).description(`Show a configured ref: full entry, state, local path, and sample tags.`).argument(`<ref>`,`full ref key or a unique suffix, e.g. next.js`).action((e,n,r)=>{let i=r.optsWithGlobals(),a={json:i.json===!0,verbose:i.verbose===!0};return $(t,a,async()=>{let{data:n,warnings:r}=await LD(t,e);Q(t,a,RD(n),n,r)})()})},BD=(e,t)=>{let n={head_sha:t.headSha,last_fetched_at:new Date().toISOString()},r=t.effectiveCloneMode??e?.effective_clone_mode;return r!==void 0&&(n.effective_clone_mode=r),n},VD=async(e,t,n)=>{let r=await H(e),i=r.refs[t];i!==void 0&&(r.refs[t]={...i,default_branch:n},await Xc(e,r))},HD=(e,t,n)=>K(e,`home`,async()=>{n.branchRenamedTo!==void 0&&await VD(e,t,n.branchRenamedTo);let r=await Nw(e);r.refs[t]=BD(r.refs[t],n),await Pw(e,r)}),UD=async(e,t,n)=>{try{await K(e,`home`,async()=>{let r=await Nw(e);r.refs[t]={...r.refs[t],last_error:n},await Pw(e,r)})}catch{}},WD=e=>{let t=0,n=[];return{acquire:()=>{if(t<e)return t+=1,Promise.resolve();let{promise:r,resolve:i}=Promise.withResolvers();return n.push(()=>{t+=1,i()}),r},release:()=>{--t;let e=n.shift();e!==void 0&&e()}}},GD=async(e,t)=>{await e.acquire();try{return await t()}finally{e.release()}},KD=(e,t,n)=>`checkout at ${e} points at '${G(t)}' — expected '${G(n)}'; remove the checkout directory or run refs remove before retrying`,qD=e=>e.exitCode===0?e.stdout.trim():`(no origin remote)`,JD=(e,t)=>{try{return lu(e,{allowFileUrls:t}).key}catch{return}},YD=async(e,t)=>{let n=await e.run(`git`,[`remote`,`get-url`,`origin`],{cwd:t.dest}),r=qD(n),i=JD(t.expectedUrl,t.allowFileUrls),a=JD(r,t.allowFileUrls);if(!(i!==void 0&&a===i))throw ot(KD(t.dest,r,t.expectedUrl))},XD=e=>`checkout at ${e} exists but is not refs-managed — remove it (rm -rf ${e}) and retry`,ZD=async(e,t)=>{let n=await e.run(`git`,[`config`,`--local`,`core.hooksPath`],{cwd:t.dest});if(n.exitCode!==0||n.stdout.trim()!==t.hooksDir)throw ot(XD(t.dest))},QD=async(e,t)=>{await o(_(t.dest),{recursive:!0}),xT(e,`cloning ${G(t.cloneUrl)} into ${t.dest}…`);let n=await vl(e.runner,t);return n.warning===void 0?{effectiveMode:n.effectiveMode}:{effectiveMode:n.effectiveMode,warning:n.warning}},$D=async(e,t)=>(Hc(t.home,t.dest),U(t.dest)?(await YD(e.runner,{allowFileUrls:t.allowFileUrls,dest:t.dest,expectedUrl:t.cloneUrl}),await ZD(e.runner,{dest:t.dest,hooksDir:t.hooksDir}),{}):QD(e,t)),eO=(e,t)=>`checkout for '${e}' at ${t} is missing or corrupt (git rev-parse HEAD failed) — run: refs remove ${e}, then refs add <source> --dry-run again`,tO=(e,t,n)=>`checkout for '${e}' at ${t} has a HEAD sha refs cannot store yet (${n.length} hex chars, expected 40) — only SHA-1 repositories are supported for now; \`--object-format=sha256\` repositories are not yet supported`,nO=async(e,t)=>{await YD(e,t),await ZD(e,{dest:t.dest,hooksDir:t.hooksDir});let n=await e.run(`git`,[`rev-parse`,`HEAD`],{cwd:t.dest});if(n.exitCode!==0)throw T(eO(t.key,t.dest));let r=n.stdout.trim();if(!Ow.shape.head_sha.safeParse(r).success)throw T(tO(t.key,t.dest,r));return r},rO=(e,t,n)=>`sync produced a HEAD sha for '${e}' at ${t} that refs cannot store yet (${n.length} hex chars) — only SHA-1 repositories are supported for now`,iO=(e,t,n)=>{if(!Ow.shape.head_sha.safeParse(n).success)throw T(rO(e,t,n));return n},aO=(e,t,n)=>{let r={effectiveCloneMode:t.effectiveMode,headSha:n.headSha,status:`cloned`};return n.actualBranch!==e.ref.default_branch&&(r.branchRenamedTo=n.actualBranch),t.warning!==void 0&&(r.warning=t.warning),r},oO=async(e,t,n)=>{await o(_(n),{recursive:!0});let r=Aw(`clone_mode`,t.ref,t.settings),i=await vl(e.runner,{cloneUrl:t.ref.url,dest:n,hooksDir:t.home.hooksDir,mode:r}),a=await bl(e.runner,n),s=await nO(e.runner,{allowFileUrls:VE(e.env),dest:n,expectedUrl:t.ref.url,hooksDir:t.home.hooksDir,key:t.key});return aO(t,i,{actualBranch:a,headSha:s})},sO=async(e,t,n)=>{await ZD(e.runner,{dest:n,hooksDir:t.home.hooksDir}),await YD(e.runner,{allowFileUrls:VE(e.env),dest:n,expectedUrl:t.ref.url});let r=await El(e.runner,{defaultBranch:t.ref.default_branch,dir:n}),i={headSha:iO(t.key,n,r.newSha),status:r.status};return r.branchRenamedTo!==void 0&&(i.branchRenamedTo=r.branchRenamedTo),r.warning!==void 0&&(i.warning=r.warning),i},cO=(e,t)=>K(t.home,BE(t.key),()=>{let n=V(t.home,t.key);return Hc(t.home,n),U(n)?sO(e,t,n):oO(e,t,n)}),lO=e=>e instanceof Error?e.message:String(e),uO=e=>{let t=[];e.branchRenamedTo!==void 0&&t.push(`default branch renamed to ${e.branchRenamedTo}`),e.warning!==void 0&&t.push(e.warning);let[n]=t;if(n!==void 0)return t.join(` | `)},dO=(e,t)=>{let n={key:e,status:t.status},r=uO(t);return r!==void 0&&(n.warning=r),n},fO=async(e,t)=>{try{let n=await cO(e,t);return await HD(t.home,t.key,n),dO(t.key,n)}catch(e){let n=lO(e);return await UD(t.home,t.key,n),{error:n,key:t.key,status:`failed`}}},pO=(e,t)=>e.status===`fulfilled`?e.value:{error:lO(e.reason),key:t,status:`failed`},mO=async(e,t)=>{let n=WD(4);return(await Promise.allSettled(t.map(t=>GD(n,()=>fO(e,t))))).map((e,n)=>{let r=t[n];if(r===void 0)throw Error(`internal: sync target at index ${n} is missing`);return pO(e,r.key)})},hO=(e,t)=>{let n=e.refs[t];if(n===void 0)throw Error(`internal: matched ref key '${t}' is missing from config.refs`);return n},gO=(e,t,n)=>({home:e,key:n,ref:hO(t,n),settings:t.settings}),_O=(e,t,n)=>n.length===0?Object.keys(t.refs).toSorted().map(n=>gO(e,t,Us.parse(n))):n.map(n=>gO(e,t,RE(t,n))),vO=(e,t,n)=>{let r=Date.now();return t.filter(t=>{let i=Gs(Aw(`sync_ttl`,t.ref,t.settings)),a=AE(n.refs[t.key]?.last_fetched_at,i,r),o=!U(V(e,t.key));return a||o})},yO=async(e,t,n)=>{if(!n)return t;let r=await Nw(e);return vO(e,t,r)},bO=async(e,t)=>{let n=B(e.env),r=await H(n),i=_O(n,r,t.refs),a=await mO(e,await yO(n,i,t.staleOnly));return{failedCount:a.filter(e=>e.status===`failed`).length,results:a}},xO=[`updated`,`fresh`,`cloned`,`restored`,`failed`],SO={cloned:`Cloned`,failed:`Failed`,fresh:`Fresh`,restored:`Restored`,updated:`Updated`},CO=e=>{let t={cloned:[],failed:[],fresh:[],restored:[],updated:[]};for(let n of e)t[n.status].push(n);return t},wO=e=>e.status===`failed`?` ${e.key}: ${e.error??`unknown error`}`:e.warning===void 0?` ${e.key}`:` ${e.key} (${e.warning})`,TO=e=>{let t=CO(e),n=[xO.map(e=>`${SO[e]} (${t[e].length})`).join(` / `)];for(let e of xO)for(let r of t[e])n.push(wO(r));return n},EO=(e,t)=>({refs:e,staleOnly:t.staleOnly===!0}),DO=(e,t)=>{e.command(`sync`).description(`Fetch (or re-clone, if the checkout is missing) configured refs — all by default.`).argument(`[refs...]`,`ref keys or unique suffixes to sync (default: every configured ref)`).option(`--stale-only`,`skip refs whose last sync is still within their ref's sync_ttl`).action((e,n,r)=>{let i=r.optsWithGlobals(),a={json:i.json===!0,verbose:i.verbose===!0};return $(t,a,async()=>{let r=await bO(t,EO(e,n));Q(t,a,TO(r.results),{results:r.results}),r.failedCount>0&&(process.exitCode=it.UNEXPECTED)})()})},OO=(e,t)=>{let n=e.refs[t];if(n===void 0)throw Error(`internal: matched ref key '${t}' is missing from config.refs`);return n},kO=(e,t,n)=>{if(n===void 0)return e.tag_format;let r=e.packages?.[n];if(r===void 0)throw C(`no package '${n}' registered on ref '${t}'`);return r.tag_format??e.tag_format},AO=(e,t)=>{if(!U(e))throw C(`checkout for '${t}' is missing — run: refs sync ${t}`)},jO=async(e,t)=>{let n=B(e.env),r=await H(n),i=RE(r,t.query),a=OO(r,i),o=kO(a,i,t.opts.packageName),s=V(n,i);AO(s,i);let c=await Hl(e.runner,s,o,t.version);return{key:i,ref_path:`refs/tags/${c}`,tag:c,version:t.version}},MO=e=>[`${e.key}@${e.version} -> ${e.tag}`],NO=e=>{let t={};return e.package!==void 0&&(t.packageName=e.package),t},PO=[EE,kE,pD,AD,zD,DO,(e,t)=>{e.command(`tag`).description(`Resolve a version to its git tag, via the ref's (or a package's) tag_format.`).argument(`<ref>`,`full ref key or a unique suffix, e.g. next.js`).argument(`<version>`,`version to resolve, e.g. 15.3.0`).option(`--package <name>`,`resolve against this package's tag_format instead of the ref's`).action((e,n,r,i)=>{let a=i.optsWithGlobals(),o={json:a.json===!0,verbose:a.verbose===!0};return $(t,o,async()=>{let i=await jO(t,{opts:NO(r),query:e,version:n});Q(t,o,MO(i),i)})()})}],FO=e=>e.description===void 0?{path:e.path}:{description:e.description,path:e.path},IO=(e,t,n)=>e.length>0?Object.fromEntries(e.map(e=>[e.name,FO(e)])):n===void 0?{}:{[n]:{path:t??`.`}},LO=(e,t)=>{let n=e.description??t;return e.tag_format===void 0?{description:n,path:e.path}:{description:n,path:e.path,tag_format:e.tag_format}},RO=(e,t)=>{let n=Object.entries(e);if(n.length!==0)return Object.fromEntries(n.map(([e,n])=>[e,LO(n,t)]))},zO=e=>{if(Object.keys(e).length!==0)return e},BO=e=>{if(e===null)throw T(`tag_format_candidate must be set to a valid tag format (containing '{version}') before finalizing — edit the proposal and provide one, or add the ref manually`);return e},VO=e=>e.packages===void 0?{default_branch:e.default_branch,description:e.description,tag_format:e.tag_format,url:e.url}:{default_branch:e.default_branch,description:e.description,packages:e.packages,tag_format:e.tag_format,url:e.url},HO=[],UO=e=>e===void 0?[...HO]:[e],WO=async(e,t,n)=>{let r=await bl(e.runner,t),i=Bl(await Dl(e.runner,t));return xT(e,`detecting workspace packages…`),{defaultBranch:r,packages:IO(await tT(t),n.npmDirectory,n.npmPkgName),tagFormatCandidate:i}},GO=(e,t)=>K(t.home,BE(t.resolved.key),async()=>{let n=await $D(e,{allowFileUrls:VE(e.env),cloneUrl:t.resolved.cloneUrl,dest:t.dest,home:t.home,hooksDir:t.home.hooksDir,mode:t.cloneMode}),r={fields:await WO(e,t.dest,t.resolved)};return n.effectiveMode!==void 0&&(r.effectiveMode=n.effectiveMode),n.warning!==void 0&&(r.warning=n.warning),r}),KO=e=>{let t={default_branch:e.cloneResult.fields.defaultBranch,description:``,key:e.resolved.key,packages:e.cloneResult.fields.packages,tag_format_candidate:e.cloneResult.fields.tagFormatCandidate,url:e.resolved.cloneUrl},n={dest:e.dest,proposal:t};return e.cloneResult.effectiveMode!==void 0&&(n.effectiveCloneMode=e.cloneResult.effectiveMode),e.cloneResult.warning!==void 0&&(n.warning=e.cloneResult.warning),n},qO=async(e,t)=>{let n=B(e.env),r=await H(n),i=GE(await WE(e,t),r.settings);qE(r,i.key),await $E(n,i.key);let a=V(n,i.key),o=Aw(`clone_mode`,void 0,r.settings),s=await GO(e,{cloneMode:o,dest:a,home:n,resolved:i});return KO({cloneResult:s,dest:a,resolved:i})},JO=(e,t,n)=>K(e,`home`,async()=>{qE(await H(e),t);let r=await Nw(e),i=r.refs[t],a=n??i?.effective_clone_mode,o={...i,pending_proposal_at:new Date().toISOString()};a!==void 0&&(o.effective_clone_mode=a),r.refs[t]=o,await Pw(e,r)}),YO=(e,t)=>{let n=tc.safeParse(e);if(!n.success)throw T(k(n.error));let r=kw.safeParse(t);if(!r.success)throw T(k(r.error));return{config:n.data,state:r.data}},XO=async(e,t)=>{let n=await H(e.home);qE(n,e.ref.key);let r=VO(e.ref);n.refs[e.ref.key]=r;let i=await Nw(e.home);return i.refs[e.ref.key]={effective_clone_mode:e.effectiveCloneMode??i.refs[e.ref.key]?.effective_clone_mode??Aw(`clone_mode`,void 0,n.settings),head_sha:t,last_fetched_at:new Date().toISOString()},{...YO(n,i),entry:r}},ZO=async(e,t)=>{let n=VE(e.env),r=await K(t.home,BE(t.ref.key),()=>(Hc(t.home,t.dest),nO(e.runner,{allowFileUrls:n,dest:t.dest,expectedUrl:t.ref.url,hooksDir:t.home.hooksDir,key:t.ref.key})));return K(t.home,`home`,async()=>{let{config:e,entry:n,state:i}=await XO(t,r);return await Pw(t.home,i),await Xc(t.home,e),{entry:n,key:t.ref.key}})},QO=(e,t)=>t===`-`?e.readStdin():s(t,`utf8`),$O=e=>e instanceof Error?e.message:String(e),ek=e=>{try{return JSON.parse(e)}catch(e){throw T(`invalid JSON in proposal: ${$O(e)}`)}},tk=e=>typeof e==`object`&&!!e&&!Array.isArray(e),nk=e=>tk(e)&&`ok`in e&&!(`key`in e),rk=e=>{if(!nk(e))return e;if(e.ok===!1)throw T(`proposal file contains a failed refs envelope (ok is false) — re-run the dry-run`);if(tk(e.data))return e.data;throw T(`proposal file is a refs envelope without a usable data object — re-run the dry-run`)},ik=e=>{let t=Dw.safeParse(e);if(!t.success)throw T(k(t.error));return t.data},ak=async(e,t)=>{let n=await QO(e,t);return ik(rk(ek(n)))},ok=(e,t)=>[`refs add: dry-run proposal ready for '${e}' (checkout: ${t})`,`next: review the proposal, then run refs add --proposal <file> to finalize`],sk=async(e,t)=>{let n=await qO(e,t);await JO(B(e.env),n.proposal.key,n.effectiveCloneMode);let r=UO(n.warning);return{data:n.proposal,human:ok(n.proposal.key,n.dest),warnings:r}},ck=e=>[`refs add: '${e}' added to config`],lk=e=>{let t={default_branch:e.default_branch,description:e.description,key:e.key,tag_format:BO(e.tag_format_candidate),url:e.url},n=zO(e.packages);return n!==void 0&&(t.packages=n),t},uk=async(e,t)=>{let n=await ak(e,t),r=B(e.env),i=V(r,n.key);if(!U(i))throw C(`no checkout found at ${i} — run: refs add <source> --dry-run first`);let{entry:a,key:o}=await ZO(e,{dest:i,home:r,ref:lk(n)});return{data:{entry:a,key:o},human:ck(o),warnings:[]}},dk=(e,t)=>{let n={default_branch:e.proposal.default_branch,description:t,key:e.proposal.key,tag_format:BO(e.proposal.tag_format_candidate),url:e.proposal.url},r=RO(e.proposal.packages,t);return r!==void 0&&(n.packages=r),n},fk=async(e,t,n)=>{let r=await qO(e,t),i=B(e.env),a=dk(r,n),o={dest:r.dest,home:i,ref:a};r.effectiveCloneMode!==void 0&&(o.effectiveCloneMode=r.effectiveCloneMode);let{entry:s,key:c}=await ZO(e,o),l=UO(r.warning);return{data:{entry:s,key:c},human:ck(c),warnings:l}},pk=e=>{let t=[e.dryRun,e.proposal!==void 0,e.description!==void 0].filter(Boolean).length;if(t>1)throw w(`refs add: use only one of --dry-run, --proposal, or --description`);if(t===0)throw w(`refs add needs --dry-run, --proposal, or --description`)},mk=e=>{if(e===void 0||e===``)throw w(`refs add requires <source> (a git url or npm:<package>)`);return e},hk=(e,t)=>(pk(t),t.proposal===void 0?t.description===void 0?sk(e,mk(t.source)):fk(e,mk(t.source),t.description):uk(e,t.proposal)),gk=(e,t)=>{let n={dryRun:t.dryRun===!0};return e!==void 0&&(n.source=e),t.proposal!==void 0&&(n.proposal=t.proposal),t.description!==void 0&&(n.description=t.description),n},_k=(e,t)=>{e.command(`add`).description(`Add a git reference in two phases: propose (--dry-run), then finalize (--proposal).`).argument(`[source]`,`git url or npm:<package> (omit when finalizing with --proposal)`).option(`--dry-run`,`resolve and clone the source, writing a reviewable proposal`).option(`--proposal <file>`,`finalize from a completed proposal JSON file (- for stdin)`).option(`--description <text>`,`one-shot: dry-run then finalize immediately with this description`).action((e,n,r)=>{let i=r.optsWithGlobals(),a={json:i.json===!0,verbose:i.verbose===!0};return $(t,a,async()=>{let r=await hk(t,gk(e,n));Q(t,a,r.human,r.data,r.warnings)})()})},vk=e=>e===void 0?null:e,yk=()=>Object.keys($s.shape).toSorted().join(`, `),bk=e=>`unknown package field '${e}' — valid fields: ${yk()}`,xk=e=>Object.hasOwn($s.shape,e),Sk=(e,t,n)=>{let r=e.packages?.[n];if(r===void 0)throw C(`no package '${n}' registered on ref '${t}'`);return r},Ck=(e,t,n)=>{if(!xk(t))throw w(bk(t));let r=e[t],i=$s.safeParse({...e,[t]:n});if(!i.success)throw T(k(i.error));return{field:t,newValue:i.data[t],oldValue:r,updated:i.data}},wk=async e=>{let t=Sk(e.entry,e.key,e.packageName),n=Ck(t,e.field,e.value),r={...e.entry,packages:{...e.entry.packages,[e.packageName]:n.updated}};return await Xc(e.home,{...e.config,refs:{...e.config.refs,[e.key]:r}}),{field:n.field,key:e.key,new:vk(n.newValue),old:vk(n.oldValue)}},Tk=`packages`,Ek=(e,t)=>{let n=e.refs[t];if(n===void 0)throw Error(`internal: matched ref key '${t}' is missing from config.refs`);return n},Dk=()=>Object.keys(ec.shape).filter(e=>e!==Tk).toSorted().join(`, `),Ok=e=>`unknown ref field '${e}' — valid fields: ${Dk()}`,kk=e=>Object.hasOwn(ec.shape,e),Ak=(e,t,n)=>`failed to rewrite git remote at ${e} to '${G(t)}': ${n.trim()}`,jk=async(e,t)=>{if(Hc(t.home,t.dest),!U(t.dest))return;let n=await e.runner.run(`git`,[`remote`,`set-url`,`origin`,t.cloneUrl],{cwd:t.dest});if(n.exitCode!==0)throw T(Ak(t.dest,t.cloneUrl,n.stderr))},Mk=async(e,t)=>{let n=lu(t.value,{allowFileUrls:VE(e.env)});if(n.key!==t.key)throw T(`new url derives a different key — remove and re-add instead`);let r=V(t.home,t.key);return await jk(e,{cloneUrl:n.cloneUrl,dest:r,home:t.home}),{...t.entry,url:n.cloneUrl}},Nk=(e,t,n)=>{let r={...e,[t]:n},i=ec.safeParse(r);if(!i.success)throw T(k(i.error));return i.data},Pk=(e,t)=>t.field===`url`?Mk(e,{entry:t.entry,home:t.home,key:t.key,value:t.value}):Promise.resolve(Nk(t.entry,t.field,t.value)),Fk=async(e,t)=>{let{field:n}=t;if(n===Tk)throw w(`use --package <name> <field> <value>`);if(!kk(n))throw w(Ok(n));let r=t.entry[n],i=await Pk(e,{entry:t.entry,field:n,home:t.home,key:t.key,value:t.value});return{new:i[n],old:r,updated:i}},Ik=(e,t)=>{let n=B(e.env),{field:r,opts:i,query:a,value:o}=t;return K(n,`home`,async()=>{let t=await H(n),s=RE(t,a),c=Ek(t,s);if(i.packageName!==void 0)return wk({config:t,entry:c,field:r,home:n,key:s,packageName:i.packageName,value:o});let l=await Fk(e,{entry:c,field:r,home:n,key:s,value:o});return await Xc(n,{...t,refs:{...t.refs,[s]:l.updated}}),{field:r,key:s,new:vk(l.new),old:vk(l.old)}})},Lk=`settings`,Rk=[],zk=()=>Object.keys(Zs.shape).toSorted().join(`, `),Bk=e=>`unknown setting '${e}' — valid settings: ${zk()}`,Vk=e=>Object.hasOwn(Zs.shape,e),Hk=e=>`note: 'settings' addressed the global settings, not ${e} — use the full ref key to edit that ref`,Uk=e=>{try{let t=RE(e,Lk);return[Hk(`ref '${t}'`)]}catch(e){if(e instanceof at&&e.code===`usage`)return[Hk("one of several matching refs — see `refs list`")];if(e instanceof at&&e.code===`not_found`)return Rk;throw e}},Wk=e=>({data:{field:e.key,key:Lk,new:vk(e.parsed[e.key]),old:vk(e.old)},warnings:Uk(e.config)}),Gk=(e,t)=>{let n=B(e.env);return K(n,`home`,async()=>{let e=await H(n);if(!Vk(t.key))throw w(Bk(t.key));let r=e.settings[t.key],i={...e.settings,[t.key]:t.value},a=Zs.safeParse(i);if(!a.success)throw T(k(a.error));return await Xc(n,{...e,settings:a.data}),Wk({config:e,key:t.key,old:r,parsed:a.data})})},Kk=[],qk=e=>{let t={};return e.package!==void 0&&(t.packageName=e.package),t},Jk=async(e,t)=>{if(t.first===`settings`){if(t.opts.packageName!==void 0)throw w(`--package is not valid with 'refs edit settings ...' — it only applies to ref/package edits`);return Gk(e,{key:t.second,value:t.value})}return{data:await Ik(e,{field:t.second,opts:t.opts,query:t.first,value:t.value}),warnings:Kk}},Yk=e=>e==null?`(unset)`:String(e),Xk=e=>[`${e.key}: ${e.field} '${Yk(e.old)}' -> '${Yk(e.new)}'`],Zk=(e,t)=>{e.command(`edit`).description(`Edit one field: 'refs edit settings <key> <value>' for a global setting, or 'refs edit <ref> <field> <value> [--package <name>]' for a ref or package field.`).argument(`<ref-or-settings>`,`a ref key/unique suffix, or the literal 'settings'`).argument(`<field-or-key>`,`field to edit (or, in settings mode, the setting key)`).argument(`<value>`,`the new value`).option(`--package <name>`,`edit this package's field instead of a top-level ref field`).action((e,n,r,i,a)=>{let o=a.optsWithGlobals(),s={json:o.json===!0,verbose:o.verbose===!0};return $(t,s,async()=>{let{data:a,warnings:o}=await Jk(t,{first:e,opts:qk(i),second:n,value:r});Q(t,s,Xk(a),a,o)})()})},Qk=`Install the agent skill: npx skills add kaisers-io/refs (private phase: npx skills add <path-to-this-repo> --skill refs)`,$k=async e=>{await o(e.root,{recursive:!0}),await o(e.sourcesDir,{recursive:!0}),await o(e.locksDir,{recursive:!0}),await o(e.hooksDir,{recursive:!0})},eA=async e=>{let t=B(e.env);return await $k(t),{config:await K(t,`home`,async()=>{let e=await sl(t,ST);return await Al(t),e}),home:t.root,skill_hint:Qk}},tA=[(e,t)=>{e.command(`init`).description(`Seed or migrate the refs home directory, its config, and the git hooks guard.`).action((e,n)=>{let r=n.optsWithGlobals(),i={json:r.json===!0,verbose:r.verbose===!0};return $(t,i,async()=>{let e=await eA(t);Q(t,i,[`refs home: ${e.home} (${e.config})`,Qk],e)})()})},_k,Zk,zE,...PO],nA=(e,t)=>{for(let n of tA)n(e,t)},rA=[``,`Examples:`,` $ refs list --json`,` $ refs sync --stale-only --json`,` $ refs resolve next/navigation --json`,``,`Every command accepts --json for structured output and --verbose for stack traces on error.`].join(`
|
|
404
|
-
`),iA=new Set([`commander.help`,`commander.helpDisplayed`,`commander.version`]),aA=`--json`,oA=`--verbose`,sA=/\n$/u,cA=/^error: /u,lA=e=>e.replace(cA,``),uA=(e,t)=>{for(let n of e){if(n===`--`)return!1;if(n===t)return!0}return!1},dA=e=>uA(e,aA),fA=e=>uA(e,oA),pA=(e,t,n)=>n&&t!==void 0?`${e}\n${t}`:e,mA=e=>{let t=new hT().name(`refs`).description(`Manage git-based reference checkouts shared across a workspace.`).version(ST).option(aA,`emit machine-readable JSON on stdout instead of human-readable text`).option(oA,`include stack traces in error output`).allowExcessArguments(!1).exitOverride().configureOutput({outputError:()=>{},writeErr:t=>{e.errLine(t.replace(sA,``))},writeOut:t=>{e.out(t.replace(sA,``))}});return t.addHelpText(`after`,rA),nA(t,e),t},hA=()=>{process.exitCode=it.OK},gA=(e,t,n)=>{bT(e,t,{code:`usage`,message:pA(lA(n.message),n.stack,t.verbose)}),process.exitCode=it.USAGE},_A=(e,t,n)=>{if(iA.has(n.code)){hA();return}gA(e,t,n)},vA=(e,t,n)=>{let r=ct(n,{verbose:t.verbose});bT(e,t,r),process.exitCode=r.exitCode},yA=async(e,t,n)=>{let r={json:dA(n),verbose:fA(n)};try{await t.parseAsync(n)}catch(t){if(t instanceof iT){_A(e,r,t);return}vA(e,r,t)}},bA=(e,t)=>yA(e,mA(e),t);import.meta.main&&await bA(rT(),process.argv);export{mA as buildProgram,Q as emit,bT as emitError,xT as progress,rT as realContext,nA as registerCommands,bA as run,yA as runProgram,$ as wrapAction};
|
|
73
|
+
// Dev fallback: run the TypeScript source directly via Node's native type stripping
|
|
74
|
+
// (stable in the exact engine range this package requires). Works only in a workspace
|
|
75
|
+
// checkout where ../src exists; the published package always ships dist/.
|
|
76
|
+
const loadFromSource = () => {
|
|
77
|
+
const srcMain = join(import.meta.dirname, '../src/main.ts');
|
|
78
|
+
// eslint-disable-next-line node/no-sync -- one-shot startup check before any I/O; simplest correct option for a zero-dependency stub
|
|
79
|
+
if (!existsSync(srcMain)) {
|
|
80
|
+
printNotBuiltMessage();
|
|
81
|
+
process.exit(EXIT_FAILURE);
|
|
82
|
+
// Unreachable in practice — defense-in-depth in case process.exit is ever intercepted.
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
return importSourceModules(srcMain);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const bundle = join(import.meta.dirname, '../dist/refs.mjs');
|
|
89
|
+
let loadModules = loadFromSource;
|
|
90
|
+
// eslint-disable-next-line node/no-sync -- one-shot startup check before any I/O; simplest correct option for a zero-dependency stub
|
|
91
|
+
if (existsSync(bundle)) {
|
|
92
|
+
loadModules = () => import(pathToFileURL(bundle).href);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const { realContext, run } = await loadModules();
|
|
96
|
+
await run(realContext(), process.argv);
|