@intentius/chant 0.124.74 → 0.124.76

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.
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
- // @intentius/chant 0.124.74 wave-job runtime (#3896): run wave, run resume, approve, workspace points.
2
+ // @intentius/chant 0.124.76 wave-job runtime (#3896): run wave, run resume, approve, workspace points.
3
3
  import { createRequire as __chantCreateRequire } from "node:module";
4
4
  const require = __chantCreateRequire(import.meta.url);
5
5
  var $xe=Object.create;var P0=Object.defineProperty;var Sxe=Object.getOwnPropertyDescriptor;var Exe=Object.getOwnPropertyNames;var Oxe=Object.getPrototypeOf,Pxe=Object.prototype.hasOwnProperty;var x=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(o){throw n=[o],o}};var ye=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(n){throw t=0,n}},Re=(e,t)=>{for(var n in t)P0(e,n,{get:t[n],enumerable:!0})},Axe=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Exe(t))!Pxe.call(e,r)&&r!==n&&P0(e,r,{get:()=>t[r],enumerable:!(o=Sxe(t,r))||o.enumerable});return e};var nt=(e,t,n)=>(n=e!=null?$xe(Oxe(e)):{},Axe(t||!e||!e.__esModule?P0(n,"default",{value:e,enumerable:!0}):n,e));function C0(e,t=new Set){let n=[];for(let o of e)if(o.startsWith("--")&&o.includes("=")){let r=o.indexOf("="),i=o.slice(0,r),s=o.slice(r+1);if(t.has(i))throw new Error(`${o} \u2014 ${i} is a boolean flag and does not take a value. Pass ${i} on its own.`);n.push(i,s)}else n.push(o);return n}var A0,_0=x(()=>{"use strict";A0=new Set(["build","lint","list","describe","import","audit","migrate","carve","init","update","doctor","dev","run","graph","vendor","lifecycle","lc","components","emulator","serve","operator","approve","workspace"])});function _xe(){return!process.env.NO_COLOR&&process.stdout.isTTY!==!1}function Ac(e,t){return _xe()?`${t}${e}${ha.reset}`:e}function $e(e){let t=[];if(e.file){let n=e.file;e.line!==void 0&&(n+=`:${e.line}`,e.column!==void 0&&(n+=`:${e.column}`)),t.push(Ac(n,ha.cyan)),t.push(" - ")}return t.push(Ac("error",ha.red)),t.push(": "),t.push(e.message),e.hint&&(t.push(`
6
6
  `),t.push(Ac(e.hint,ha.gray))),t.join("")}function ur(e){let t=[];if(e.file){let n=e.file;e.line!==void 0&&(n+=`:${e.line}`,e.column!==void 0&&(n+=`:${e.column}`)),t.push(Ac(n,ha.cyan)),t.push(" - ")}return t.push(Ac("warning",ha.yellow)),t.push(": "),t.push(e.message),e.hint&&(t.push(`
7
- `),t.push(Ac(e.hint,ha.gray))),t.join("")}function Rh(e){return Ac(e,ha.green)}function In(e){return Ac(e,ha.gray)}var ha,Qn=x(()=>{"use strict";ha={red:"\x1B[31m",yellow:"\x1B[33m",green:"\x1B[32m",cyan:"\x1B[36m",gray:"\x1B[90m",reset:"\x1B[0m",bold:"\x1B[1m"}});var LR,I0=x(()=>{"use strict";LR="0.124.74"});function V(e,t,n){function o(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:s,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);let l=s.prototype,u=Object.keys(l);for(let d=0;d<u.length;d++){let p=u[d];p in a||(a[p]=l[p].bind(a))}}let r=n?.Parent??Object;class i extends r{}Object.defineProperty(i,"name",{value:e});function s(a){var c;let l=n?.Parent?new i:this;o(l,a),(c=l._zod).deferred??(c.deferred=[]);for(let u of l._zod.deferred)u();return l}return Object.defineProperty(s,"init",{value:o}),Object.defineProperty(s,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}function xn(e){return e&&Object.assign(xh,e),xh}var D0,MR,Fi,Cc,xh,Ep=x(()=>{D0=Object.freeze({status:"aborted"});MR=Symbol("zod_brand"),Fi=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Cc=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}},xh={}});var Se={};Re(Se,{BIGINT_FORMAT_RANGES:()=>z0,Class:()=>j0,NUMBER_FORMAT_RANGES:()=>U0,aborted:()=>Dc,allowsEval:()=>F0,assert:()=>Lxe,assertEqual:()=>Ixe,assertIs:()=>Nxe,assertNever:()=>jxe,assertNotEqual:()=>Dxe,assignProp:()=>Tc,base64ToUint8Array:()=>W6,base64urlToUint8Array:()=>e$e,cached:()=>Pp,captureStackTrace:()=>GR,cleanEnum:()=>Xxe,cleanRegex:()=>Eh,clone:()=>jr,cloneDef:()=>Fxe,createTransparentProxy:()=>Hxe,defineLazy:()=>mt,esc:()=>FR,escapeRegex:()=>Yo,extend:()=>Kxe,finalizeIssue:()=>oo,floatSafeRemainder:()=>L0,getElementAtPath:()=>Gxe,getEnumValues:()=>Sh,getLengthableOrigin:()=>Ah,getParsedType:()=>zxe,getSizableOrigin:()=>Ph,hexToUint8Array:()=>n$e,isObject:()=>Ru,isPlainObject:()=>Ic,issue:()=>Ap,joinValues:()=>se,jsonStringifyReplacer:()=>Op,merge:()=>Zxe,mergeDefs:()=>ya,normalizeParams:()=>Ee,nullish:()=>_c,numKeys:()=>Uxe,objectClone:()=>Mxe,omit:()=>Vxe,optionalKeys:()=>B0,parsedType:()=>xe,partial:()=>Yxe,pick:()=>qxe,prefixIssues:()=>Ao,primitiveTypes:()=>W0,promiseAllObject:()=>Wxe,propertyKeyTypes:()=>Oh,randomString:()=>Bxe,required:()=>Qxe,safeExtend:()=>Jxe,shallowClone:()=>G0,slugify:()=>M0,stringifyPrimitive:()=>be,uint8ArrayToBase64:()=>B6,uint8ArrayToBase64url:()=>t$e,uint8ArrayToHex:()=>r$e,unwrapMessage:()=>$h});function Ixe(e){return e}function Dxe(e){return e}function Nxe(e){}function jxe(e){throw new Error("Unexpected value in exhaustive check")}function Lxe(e){}function Sh(e){let t=Object.values(e).filter(o=>typeof o=="number");return Object.entries(e).filter(([o,r])=>t.indexOf(+o)===-1).map(([o,r])=>r)}function se(e,t="|"){return e.map(n=>be(n)).join(t)}function Op(e,t){return typeof t=="bigint"?t.toString():t}function Pp(e){return{get value(){{let n=e();return Object.defineProperty(this,"value",{value:n}),n}throw new Error("cached value already set")}}}function _c(e){return e==null}function Eh(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function L0(e,t){let n=(e.toString().split(".")[1]||"").length,o=t.toString(),r=(o.split(".")[1]||"").length;if(r===0&&/\d?e-\d?/.test(o)){let c=o.match(/\d?e-(\d?)/);c?.[1]&&(r=Number.parseInt(c[1]))}let i=n>r?n:r,s=Number.parseInt(e.toFixed(i).replace(".","")),a=Number.parseInt(t.toFixed(i).replace(".",""));return s%a/10**i}function mt(e,t,n){let o;Object.defineProperty(e,t,{get(){if(o!==G6)return o===void 0&&(o=G6,o=n()),o},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function Mxe(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Tc(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function ya(...e){let t={};for(let n of e){let o=Object.getOwnPropertyDescriptors(n);Object.assign(t,o)}return Object.defineProperties({},t)}function Fxe(e){return ya(e._zod.def)}function Gxe(e,t){return t?t.reduce((n,o)=>n?.[o],e):e}function Wxe(e){let t=Object.keys(e),n=t.map(o=>e[o]);return Promise.all(n).then(o=>{let r={};for(let i=0;i<t.length;i++)r[t[i]]=o[i];return r})}function Bxe(e=10){let t="abcdefghijklmnopqrstuvwxyz",n="";for(let o=0;o<e;o++)n+=t[Math.floor(Math.random()*t.length)];return n}function FR(e){return JSON.stringify(e)}function M0(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function Ru(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ic(e){if(Ru(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let n=t.prototype;return!(Ru(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function G0(e){return Ic(e)?{...e}:Array.isArray(e)?[...e]:e}function Uxe(e){let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}function Yo(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function jr(e,t,n){let o=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(o._zod.parent=e),o}function Ee(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 new 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 Hxe(e){let t;return new Proxy({},{get(n,o,r){return t??(t=e()),Reflect.get(t,o,r)},set(n,o,r,i){return t??(t=e()),Reflect.set(t,o,r,i)},has(n,o){return t??(t=e()),Reflect.has(t,o)},deleteProperty(n,o){return t??(t=e()),Reflect.deleteProperty(t,o)},ownKeys(n){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,o){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,o)},defineProperty(n,o,r){return t??(t=e()),Reflect.defineProperty(t,o,r)}})}function be(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function B0(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function qxe(e,t){let n=e._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let i=ya(e._zod.def,{get shape(){let s={};for(let a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(s[a]=n.shape[a])}return Tc(this,"shape",s),s},checks:[]});return jr(e,i)}function Vxe(e,t){let n=e._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let i=ya(e._zod.def,{get shape(){let s={...e._zod.def.shape};for(let a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete s[a]}return Tc(this,"shape",s),s},checks:[]});return jr(e,i)}function Kxe(e,t){if(!Ic(t))throw new Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let i=e._zod.def.shape;for(let s in t)if(Object.getOwnPropertyDescriptor(i,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let r=ya(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return Tc(this,"shape",i),i}});return jr(e,r)}function Jxe(e,t){if(!Ic(t))throw new Error("Invalid input to safeExtend: expected a plain object");let n=ya(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t};return Tc(this,"shape",o),o}});return jr(e,n)}function Zxe(e,t){let n=ya(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t._zod.def.shape};return Tc(this,"shape",o),o},get catchall(){return t._zod.def.catchall},checks:[]});return jr(e,n)}function Yxe(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let s=ya(t._zod.def,{get shape(){let a=t._zod.def.shape,c={...a};if(n)for(let l in n){if(!(l in a))throw new Error(`Unrecognized key: "${l}"`);n[l]&&(c[l]=e?new e({type:"optional",innerType:a[l]}):a[l])}else for(let l in a)c[l]=e?new e({type:"optional",innerType:a[l]}):a[l];return Tc(this,"shape",c),c},checks:[]});return jr(t,s)}function Qxe(e,t,n){let o=ya(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let s in n){if(!(s in i))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(i[s]=new e({type:"nonoptional",innerType:r[s]}))}else for(let s in r)i[s]=new e({type:"nonoptional",innerType:r[s]});return Tc(this,"shape",i),i}});return jr(t,o)}function Dc(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 Ao(e,t){return t.map(n=>{var o;return(o=n).path??(o.path=[]),n.path.unshift(e),n})}function $h(e){return typeof e=="string"?e:e?.message}function oo(e,t,n){let o={...e,path:e.path??[]};if(!e.message){let r=$h(e.inst?._zod.def?.error?.(e))??$h(t?.error?.(e))??$h(n.customError?.(e))??$h(n.localeError?.(e))??"Invalid input";o.message=r}return delete o.inst,delete o.continue,t?.reportInput||delete o.input,o}function Ph(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function Ah(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function xe(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function Ap(...e){let[t,n,o]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:o}:{...t}}function Xxe(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function W6(e){let t=atob(e),n=new Uint8Array(t.length);for(let o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return n}function B6(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function e$e(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return W6(t+n)}function t$e(e){return B6(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function n$e(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let n=new Uint8Array(t.length/2);for(let o=0;o<t.length;o+=2)n[o/2]=Number.parseInt(t.slice(o,o+2),16);return n}function r$e(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var G6,GR,F0,zxe,Oh,W0,U0,z0,j0,He=x(()=>{G6=Symbol("evaluating");GR="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};F0=Pp(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});zxe=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},Oh=new Set(["string","number","symbol"]),W0=new Set(["string","number","bigint","boolean","symbol","undefined"]);U0={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},z0={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};j0=class{constructor(...t){}}});function _h(e,t=n=>n.message){let n={},o=[];for(let r of e.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(t(r))):o.push(t(r));return{formErrors:o,fieldErrors:n}}function Th(e,t=n=>n.message){let n={_errors:[]},o=r=>{for(let i of r.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(s=>o({issues:s}));else if(i.code==="invalid_key")o({issues:i.issues});else if(i.code==="invalid_element")o({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let s=n,a=0;for(;a<i.path.length;){let c=i.path[a];a===i.path.length-1?(s[c]=s[c]||{_errors:[]},s[c]._errors.push(t(i))):s[c]=s[c]||{_errors:[]},s=s[c],a++}}};return o(e),n}function H0(e,t=n=>n.message){let n={errors:[]},o=(r,i=[])=>{var s,a;for(let c of r.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(l=>o({issues:l},c.path));else if(c.code==="invalid_key")o({issues:c.issues},c.path);else if(c.code==="invalid_element")o({issues:c.issues},c.path);else{let l=[...i,...c.path];if(l.length===0){n.errors.push(t(c));continue}let u=n,d=0;for(;d<l.length;){let p=l[d],f=d===l.length-1;typeof p=="string"?(u.properties??(u.properties={}),(s=u.properties)[p]??(s[p]={errors:[]}),u=u.properties[p]):(u.items??(u.items=[]),(a=u.items)[p]??(a[p]={errors:[]}),u=u.items[p]),f&&u.errors.push(t(c)),d++}}};return o(e),n}function z6(e){let t=[],n=e.map(o=>typeof o=="object"?o.key:o);for(let o of n)typeof o=="number"?t.push(`[${o}]`):typeof o=="symbol"?t.push(`[${JSON.stringify(String(o))}]`):/[^\w$]/.test(o)?t.push(`[${JSON.stringify(o)}]`):(t.length&&t.push("."),t.push(o));return t.join("")}function q0(e){let t=[],n=[...e.issues].sort((o,r)=>(o.path??[]).length-(r.path??[]).length);for(let o of n)t.push(`\u2716 ${o.message}`),o.path?.length&&t.push(` \u2192 at ${z6(o.path)}`);return t.join(`
7
+ `),t.push(Ac(e.hint,ha.gray))),t.join("")}function Rh(e){return Ac(e,ha.green)}function In(e){return Ac(e,ha.gray)}var ha,Qn=x(()=>{"use strict";ha={red:"\x1B[31m",yellow:"\x1B[33m",green:"\x1B[32m",cyan:"\x1B[36m",gray:"\x1B[90m",reset:"\x1B[0m",bold:"\x1B[1m"}});var LR,I0=x(()=>{"use strict";LR="0.124.76"});function V(e,t,n){function o(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:s,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);let l=s.prototype,u=Object.keys(l);for(let d=0;d<u.length;d++){let p=u[d];p in a||(a[p]=l[p].bind(a))}}let r=n?.Parent??Object;class i extends r{}Object.defineProperty(i,"name",{value:e});function s(a){var c;let l=n?.Parent?new i:this;o(l,a),(c=l._zod).deferred??(c.deferred=[]);for(let u of l._zod.deferred)u();return l}return Object.defineProperty(s,"init",{value:o}),Object.defineProperty(s,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}function xn(e){return e&&Object.assign(xh,e),xh}var D0,MR,Fi,Cc,xh,Ep=x(()=>{D0=Object.freeze({status:"aborted"});MR=Symbol("zod_brand"),Fi=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Cc=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}},xh={}});var Se={};Re(Se,{BIGINT_FORMAT_RANGES:()=>z0,Class:()=>j0,NUMBER_FORMAT_RANGES:()=>U0,aborted:()=>Dc,allowsEval:()=>F0,assert:()=>Lxe,assertEqual:()=>Ixe,assertIs:()=>Nxe,assertNever:()=>jxe,assertNotEqual:()=>Dxe,assignProp:()=>Tc,base64ToUint8Array:()=>W6,base64urlToUint8Array:()=>e$e,cached:()=>Pp,captureStackTrace:()=>GR,cleanEnum:()=>Xxe,cleanRegex:()=>Eh,clone:()=>jr,cloneDef:()=>Fxe,createTransparentProxy:()=>Hxe,defineLazy:()=>mt,esc:()=>FR,escapeRegex:()=>Yo,extend:()=>Kxe,finalizeIssue:()=>oo,floatSafeRemainder:()=>L0,getElementAtPath:()=>Gxe,getEnumValues:()=>Sh,getLengthableOrigin:()=>Ah,getParsedType:()=>zxe,getSizableOrigin:()=>Ph,hexToUint8Array:()=>n$e,isObject:()=>Ru,isPlainObject:()=>Ic,issue:()=>Ap,joinValues:()=>se,jsonStringifyReplacer:()=>Op,merge:()=>Zxe,mergeDefs:()=>ya,normalizeParams:()=>Ee,nullish:()=>_c,numKeys:()=>Uxe,objectClone:()=>Mxe,omit:()=>Vxe,optionalKeys:()=>B0,parsedType:()=>xe,partial:()=>Yxe,pick:()=>qxe,prefixIssues:()=>Ao,primitiveTypes:()=>W0,promiseAllObject:()=>Wxe,propertyKeyTypes:()=>Oh,randomString:()=>Bxe,required:()=>Qxe,safeExtend:()=>Jxe,shallowClone:()=>G0,slugify:()=>M0,stringifyPrimitive:()=>be,uint8ArrayToBase64:()=>B6,uint8ArrayToBase64url:()=>t$e,uint8ArrayToHex:()=>r$e,unwrapMessage:()=>$h});function Ixe(e){return e}function Dxe(e){return e}function Nxe(e){}function jxe(e){throw new Error("Unexpected value in exhaustive check")}function Lxe(e){}function Sh(e){let t=Object.values(e).filter(o=>typeof o=="number");return Object.entries(e).filter(([o,r])=>t.indexOf(+o)===-1).map(([o,r])=>r)}function se(e,t="|"){return e.map(n=>be(n)).join(t)}function Op(e,t){return typeof t=="bigint"?t.toString():t}function Pp(e){return{get value(){{let n=e();return Object.defineProperty(this,"value",{value:n}),n}throw new Error("cached value already set")}}}function _c(e){return e==null}function Eh(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function L0(e,t){let n=(e.toString().split(".")[1]||"").length,o=t.toString(),r=(o.split(".")[1]||"").length;if(r===0&&/\d?e-\d?/.test(o)){let c=o.match(/\d?e-(\d?)/);c?.[1]&&(r=Number.parseInt(c[1]))}let i=n>r?n:r,s=Number.parseInt(e.toFixed(i).replace(".","")),a=Number.parseInt(t.toFixed(i).replace(".",""));return s%a/10**i}function mt(e,t,n){let o;Object.defineProperty(e,t,{get(){if(o!==G6)return o===void 0&&(o=G6,o=n()),o},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function Mxe(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Tc(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function ya(...e){let t={};for(let n of e){let o=Object.getOwnPropertyDescriptors(n);Object.assign(t,o)}return Object.defineProperties({},t)}function Fxe(e){return ya(e._zod.def)}function Gxe(e,t){return t?t.reduce((n,o)=>n?.[o],e):e}function Wxe(e){let t=Object.keys(e),n=t.map(o=>e[o]);return Promise.all(n).then(o=>{let r={};for(let i=0;i<t.length;i++)r[t[i]]=o[i];return r})}function Bxe(e=10){let t="abcdefghijklmnopqrstuvwxyz",n="";for(let o=0;o<e;o++)n+=t[Math.floor(Math.random()*t.length)];return n}function FR(e){return JSON.stringify(e)}function M0(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function Ru(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ic(e){if(Ru(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let n=t.prototype;return!(Ru(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function G0(e){return Ic(e)?{...e}:Array.isArray(e)?[...e]:e}function Uxe(e){let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}function Yo(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function jr(e,t,n){let o=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(o._zod.parent=e),o}function Ee(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 new 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 Hxe(e){let t;return new Proxy({},{get(n,o,r){return t??(t=e()),Reflect.get(t,o,r)},set(n,o,r,i){return t??(t=e()),Reflect.set(t,o,r,i)},has(n,o){return t??(t=e()),Reflect.has(t,o)},deleteProperty(n,o){return t??(t=e()),Reflect.deleteProperty(t,o)},ownKeys(n){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,o){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,o)},defineProperty(n,o,r){return t??(t=e()),Reflect.defineProperty(t,o,r)}})}function be(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function B0(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function qxe(e,t){let n=e._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let i=ya(e._zod.def,{get shape(){let s={};for(let a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(s[a]=n.shape[a])}return Tc(this,"shape",s),s},checks:[]});return jr(e,i)}function Vxe(e,t){let n=e._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let i=ya(e._zod.def,{get shape(){let s={...e._zod.def.shape};for(let a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete s[a]}return Tc(this,"shape",s),s},checks:[]});return jr(e,i)}function Kxe(e,t){if(!Ic(t))throw new Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let i=e._zod.def.shape;for(let s in t)if(Object.getOwnPropertyDescriptor(i,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let r=ya(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return Tc(this,"shape",i),i}});return jr(e,r)}function Jxe(e,t){if(!Ic(t))throw new Error("Invalid input to safeExtend: expected a plain object");let n=ya(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t};return Tc(this,"shape",o),o}});return jr(e,n)}function Zxe(e,t){let n=ya(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t._zod.def.shape};return Tc(this,"shape",o),o},get catchall(){return t._zod.def.catchall},checks:[]});return jr(e,n)}function Yxe(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let s=ya(t._zod.def,{get shape(){let a=t._zod.def.shape,c={...a};if(n)for(let l in n){if(!(l in a))throw new Error(`Unrecognized key: "${l}"`);n[l]&&(c[l]=e?new e({type:"optional",innerType:a[l]}):a[l])}else for(let l in a)c[l]=e?new e({type:"optional",innerType:a[l]}):a[l];return Tc(this,"shape",c),c},checks:[]});return jr(t,s)}function Qxe(e,t,n){let o=ya(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let s in n){if(!(s in i))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(i[s]=new e({type:"nonoptional",innerType:r[s]}))}else for(let s in r)i[s]=new e({type:"nonoptional",innerType:r[s]});return Tc(this,"shape",i),i}});return jr(t,o)}function Dc(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 Ao(e,t){return t.map(n=>{var o;return(o=n).path??(o.path=[]),n.path.unshift(e),n})}function $h(e){return typeof e=="string"?e:e?.message}function oo(e,t,n){let o={...e,path:e.path??[]};if(!e.message){let r=$h(e.inst?._zod.def?.error?.(e))??$h(t?.error?.(e))??$h(n.customError?.(e))??$h(n.localeError?.(e))??"Invalid input";o.message=r}return delete o.inst,delete o.continue,t?.reportInput||delete o.input,o}function Ph(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function Ah(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function xe(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function Ap(...e){let[t,n,o]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:o}:{...t}}function Xxe(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function W6(e){let t=atob(e),n=new Uint8Array(t.length);for(let o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return n}function B6(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function e$e(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return W6(t+n)}function t$e(e){return B6(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function n$e(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let n=new Uint8Array(t.length/2);for(let o=0;o<t.length;o+=2)n[o/2]=Number.parseInt(t.slice(o,o+2),16);return n}function r$e(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var G6,GR,F0,zxe,Oh,W0,U0,z0,j0,He=x(()=>{G6=Symbol("evaluating");GR="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};F0=Pp(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});zxe=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},Oh=new Set(["string","number","symbol"]),W0=new Set(["string","number","bigint","boolean","symbol","undefined"]);U0={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},z0={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};j0=class{constructor(...t){}}});function _h(e,t=n=>n.message){let n={},o=[];for(let r of e.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(t(r))):o.push(t(r));return{formErrors:o,fieldErrors:n}}function Th(e,t=n=>n.message){let n={_errors:[]},o=r=>{for(let i of r.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(s=>o({issues:s}));else if(i.code==="invalid_key")o({issues:i.issues});else if(i.code==="invalid_element")o({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let s=n,a=0;for(;a<i.path.length;){let c=i.path[a];a===i.path.length-1?(s[c]=s[c]||{_errors:[]},s[c]._errors.push(t(i))):s[c]=s[c]||{_errors:[]},s=s[c],a++}}};return o(e),n}function H0(e,t=n=>n.message){let n={errors:[]},o=(r,i=[])=>{var s,a;for(let c of r.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(l=>o({issues:l},c.path));else if(c.code==="invalid_key")o({issues:c.issues},c.path);else if(c.code==="invalid_element")o({issues:c.issues},c.path);else{let l=[...i,...c.path];if(l.length===0){n.errors.push(t(c));continue}let u=n,d=0;for(;d<l.length;){let p=l[d],f=d===l.length-1;typeof p=="string"?(u.properties??(u.properties={}),(s=u.properties)[p]??(s[p]={errors:[]}),u=u.properties[p]):(u.items??(u.items=[]),(a=u.items)[p]??(a[p]={errors:[]}),u=u.items[p]),f&&u.errors.push(t(c)),d++}}};return o(e),n}function z6(e){let t=[],n=e.map(o=>typeof o=="object"?o.key:o);for(let o of n)typeof o=="number"?t.push(`[${o}]`):typeof o=="symbol"?t.push(`[${JSON.stringify(String(o))}]`):/[^\w$]/.test(o)?t.push(`[${JSON.stringify(o)}]`):(t.length&&t.push("."),t.push(o));return t.join("")}function q0(e){let t=[],n=[...e.issues].sort((o,r)=>(o.path??[]).length-(r.path??[]).length);for(let o of n)t.push(`\u2716 ${o.message}`),o.path?.length&&t.push(` \u2192 at ${z6(o.path)}`);return t.join(`
8
8
  `)}var U6,Ch,io,V0=x(()=>{Ep();He();U6=(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,Op,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ch=V("$ZodError",U6),io=V("$ZodError",U6,{Parent:Error})});var Cp,WR,_p,BR,Tp,K0,Ip,J0,UR,i$e,zR,s$e,HR,a$e,qR,c$e,VR,l$e,KR,u$e,JR,d$e,ZR,p$e,Z0=x(()=>{Ep();V0();He();Cp=e=>(t,n,o,r)=>{let i=o?Object.assign(o,{async:!1}):{async:!1},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new Fi;if(s.issues.length){let a=new(r?.Err??e)(s.issues.map(c=>oo(c,i,xn())));throw GR(a,r?.callee),a}return s.value},WR=Cp(io),_p=e=>async(t,n,o,r)=>{let i=o?Object.assign(o,{async:!0}):{async:!0},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise&&(s=await s),s.issues.length){let a=new(r?.Err??e)(s.issues.map(c=>oo(c,i,xn())));throw GR(a,r?.callee),a}return s.value},BR=_p(io),Tp=e=>(t,n,o)=>{let r=o?{...o,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},r);if(i instanceof Promise)throw new Fi;return i.issues.length?{success:!1,error:new(e??Ch)(i.issues.map(s=>oo(s,r,xn())))}:{success:!0,data:i.value}},K0=Tp(io),Ip=e=>async(t,n,o)=>{let r=o?Object.assign(o,{async:!0}):{async:!0},i=t._zod.run({value:n,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(s=>oo(s,r,xn())))}:{success:!0,data:i.value}},J0=Ip(io),UR=e=>(t,n,o)=>{let r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return Cp(e)(t,n,r)},i$e=UR(io),zR=e=>(t,n,o)=>Cp(e)(t,n,o),s$e=zR(io),HR=e=>async(t,n,o)=>{let r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return _p(e)(t,n,r)},a$e=HR(io),qR=e=>async(t,n,o)=>_p(e)(t,n,o),c$e=qR(io),VR=e=>(t,n,o)=>{let r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return Tp(e)(t,n,r)},l$e=VR(io),KR=e=>(t,n,o)=>Tp(e)(t,n,o),u$e=KR(io),JR=e=>async(t,n,o)=>{let r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return Ip(e)(t,n,r)},d$e=JR(io),ZR=e=>async(t,n,o)=>Ip(e)(t,n,o),p$e=ZR(io)});var Qo={};Re(Qo,{base64:()=>pT,base64url:()=>YR,bigint:()=>wT,boolean:()=>vT,browserEmail:()=>v$e,cidrv4:()=>uT,cidrv6:()=>dT,cuid:()=>Y0,cuid2:()=>Q0,date:()=>mT,datetime:()=>hT,domain:()=>x$e,duration:()=>rT,e164:()=>fT,email:()=>iT,emoji:()=>sT,extendedDuration:()=>f$e,guid:()=>oT,hex:()=>$$e,hostname:()=>R$e,html5Email:()=>y$e,idnEmail:()=>b$e,integer:()=>bT,ipv4:()=>aT,ipv6:()=>cT,ksuid:()=>tT,lowercase:()=>xT,mac:()=>lT,md5_base64:()=>E$e,md5_base64url:()=>O$e,md5_hex:()=>S$e,nanoid:()=>nT,null:()=>kT,number:()=>QR,rfc5322Email:()=>w$e,sha1_base64:()=>A$e,sha1_base64url:()=>C$e,sha1_hex:()=>P$e,sha256_base64:()=>T$e,sha256_base64url:()=>I$e,sha256_hex:()=>_$e,sha384_base64:()=>N$e,sha384_base64url:()=>j$e,sha384_hex:()=>D$e,sha512_base64:()=>M$e,sha512_base64url:()=>F$e,sha512_hex:()=>L$e,string:()=>yT,time:()=>gT,ulid:()=>X0,undefined:()=>RT,unicodeEmail:()=>H6,uppercase:()=>$T,uuid:()=>xu,uuid4:()=>m$e,uuid6:()=>g$e,uuid7:()=>h$e,xid:()=>eT});function sT(){return new RegExp(k$e,"u")}function V6(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 gT(e){return new RegExp(`^${V6(e)}$`)}function hT(e){let t=V6({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let o=`${t}(?:${n.join("|")})`;return new RegExp(`^${q6}T(?:${o})$`)}function Ih(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function Dh(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var Y0,Q0,X0,eT,tT,nT,rT,f$e,oT,xu,m$e,g$e,h$e,iT,y$e,w$e,H6,b$e,v$e,k$e,aT,cT,lT,uT,dT,pT,YR,R$e,x$e,fT,q6,mT,yT,wT,bT,QR,vT,kT,RT,xT,$T,$$e,S$e,E$e,O$e,P$e,A$e,C$e,_$e,T$e,I$e,D$e,N$e,j$e,L$e,M$e,F$e,XR=x(()=>{He();Y0=/^[cC][^\s-]{8,}$/,Q0=/^[0-9a-z]+$/,X0=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,eT=/^[0-9a-vA-V]{20}$/,tT=/^[A-Za-z0-9]{27}$/,nT=/^[a-zA-Z0-9_-]{21}$/,rT=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,f$e=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,oT=/^([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})$/,xu=e=>e?new 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)$/,m$e=xu(4),g$e=xu(6),h$e=xu(7),iT=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,y$e=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,w$e=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,H6=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,b$e=H6,v$e=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,k$e="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";aT=/^(?:(?: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])$/,cT=/^(([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}|:))$/,lT=e=>{let t=Yo(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},uT=/^((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])$/,dT=/^(([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])$/,pT=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,YR=/^[A-Za-z0-9_-]*$/,R$e=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,x$e=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,fT=/^\+[1-9]\d{6,14}$/,q6="(?:(?:\\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])))",mT=new RegExp(`^${q6}$`);yT=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},wT=/^-?\d+n?$/,bT=/^-?\d+$/,QR=/^-?\d+(?:\.\d+)?$/,vT=/^(?:true|false)$/i,kT=/^null$/i,RT=/^undefined$/i,xT=/^[^A-Z]*$/,$T=/^[^a-z]*$/,$$e=/^[0-9a-fA-F]*$/;S$e=/^[0-9a-fA-F]{32}$/,E$e=Ih(22,"=="),O$e=Dh(22),P$e=/^[0-9a-fA-F]{40}$/,A$e=Ih(27,"="),C$e=Dh(27),_$e=/^[0-9a-fA-F]{64}$/,T$e=Ih(43,"="),I$e=Dh(43),D$e=/^[0-9a-fA-F]{96}$/,N$e=Ih(64,""),j$e=Dh(64),L$e=/^[0-9a-fA-F]{128}$/,M$e=Ih(86,"=="),F$e=Dh(86)});function K6(e,t,n){e.issues.length&&t.issues.push(...Ao(n,e.issues))}var Yt,J6,ex,tx,ST,ET,OT,PT,AT,CT,_T,TT,IT,Dp,DT,NT,jT,LT,MT,FT,GT,WT,BT,nx=x(()=>{Ep();XR();He();Yt=V("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),J6={number:"number",bigint:"bigint",object:"date"},ex=V("$ZodCheckLessThan",(e,t)=>{Yt.init(e,t);let n=J6[typeof t.value];e._zod.onattach.push(o=>{let r=o._zod.bag,i=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value<=t.value:o.value<t.value)||o.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),tx=V("$ZodCheckGreaterThan",(e,t)=>{Yt.init(e,t);let n=J6[typeof t.value];e._zod.onattach.push(o=>{let r=o._zod.bag,i=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value>=t.value:o.value>t.value)||o.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ST=V("$ZodCheckMultipleOf",(e,t)=>{Yt.init(e,t),e._zod.onattach.push(n=>{var o;(o=n._zod.bag).multipleOf??(o.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):L0(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})}}),ET=V("$ZodCheckNumberFormat",(e,t)=>{Yt.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),o=n?"int":"number",[r,i]=U0[t.format];e._zod.onattach.push(s=>{let a=s._zod.bag;a.format=t.format,a.minimum=r,a.maximum=i,n&&(a.pattern=bT)}),e._zod.check=s=>{let a=s.value;if(n){if(!Number.isInteger(a)){s.issues.push({expected:o,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort});return}}a<r&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),a>i&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),OT=V("$ZodCheckBigIntFormat",(e,t)=>{Yt.init(e,t);let[n,o]=z0[t.format];e._zod.onattach.push(r=>{let i=r._zod.bag;i.format=t.format,i.minimum=n,i.maximum=o}),e._zod.check=r=>{let i=r.value;i<n&&r.issues.push({origin:"bigint",input:i,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),i>o&&r.issues.push({origin:"bigint",input:i,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),PT=V("$ZodCheckMaxSize",(e,t)=>{var n;Yt.init(e,t),(n=e._zod.def).when??(n.when=o=>{let r=o.value;return!_c(r)&&r.size!==void 0}),e._zod.onattach.push(o=>{let r=o._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(o._zod.bag.maximum=t.maximum)}),e._zod.check=o=>{let r=o.value;r.size<=t.maximum||o.issues.push({origin:Ph(r),code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),AT=V("$ZodCheckMinSize",(e,t)=>{var n;Yt.init(e,t),(n=e._zod.def).when??(n.when=o=>{let r=o.value;return!_c(r)&&r.size!==void 0}),e._zod.onattach.push(o=>{let r=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(o._zod.bag.minimum=t.minimum)}),e._zod.check=o=>{let r=o.value;r.size>=t.minimum||o.issues.push({origin:Ph(r),code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),CT=V("$ZodCheckSizeEquals",(e,t)=>{var n;Yt.init(e,t),(n=e._zod.def).when??(n.when=o=>{let r=o.value;return!_c(r)&&r.size!==void 0}),e._zod.onattach.push(o=>{let r=o._zod.bag;r.minimum=t.size,r.maximum=t.size,r.size=t.size}),e._zod.check=o=>{let r=o.value,i=r.size;if(i===t.size)return;let s=i>t.size;o.issues.push({origin:Ph(r),...s?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),_T=V("$ZodCheckMaxLength",(e,t)=>{var n;Yt.init(e,t),(n=e._zod.def).when??(n.when=o=>{let r=o.value;return!_c(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{let r=o._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(o._zod.bag.maximum=t.maximum)}),e._zod.check=o=>{let r=o.value;if(r.length<=t.maximum)return;let s=Ah(r);o.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),TT=V("$ZodCheckMinLength",(e,t)=>{var n;Yt.init(e,t),(n=e._zod.def).when??(n.when=o=>{let r=o.value;return!_c(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{let r=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(o._zod.bag.minimum=t.minimum)}),e._zod.check=o=>{let r=o.value;if(r.length>=t.minimum)return;let s=Ah(r);o.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),IT=V("$ZodCheckLengthEquals",(e,t)=>{var n;Yt.init(e,t),(n=e._zod.def).when??(n.when=o=>{let r=o.value;return!_c(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{let r=o._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=o=>{let r=o.value,i=r.length;if(i===t.length)return;let s=Ah(r),a=i>t.length;o.issues.push({origin:s,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),Dp=V("$ZodCheckStringFormat",(e,t)=>{var n,o;Yt.init(e,t),e._zod.onattach.push(r=>{let i=r._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(o=e._zod).check??(o.check=()=>{})}),DT=V("$ZodCheckRegex",(e,t)=>{Dp.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})}}),NT=V("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=xT),Dp.init(e,t)}),jT=V("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=$T),Dp.init(e,t)}),LT=V("$ZodCheckIncludes",(e,t)=>{Yt.init(e,t);let n=Yo(t.includes),o=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=o,e._zod.onattach.push(r=>{let i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(o)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),MT=V("$ZodCheckStartsWith",(e,t)=>{Yt.init(e,t);let n=new RegExp(`^${Yo(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(o=>{let r=o._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=o=>{o.value.startsWith(t.prefix)||o.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:o.value,inst:e,continue:!t.abort})}}),FT=V("$ZodCheckEndsWith",(e,t)=>{Yt.init(e,t);let n=new RegExp(`.*${Yo(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(o=>{let r=o._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=o=>{o.value.endsWith(t.suffix)||o.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:o.value,inst:e,continue:!t.abort})}});GT=V("$ZodCheckProperty",(e,t)=>{Yt.init(e,t),e._zod.check=n=>{let o=t.schema._zod.run({value:n.value[t.property],issues:[]},{});if(o instanceof Promise)return o.then(r=>K6(r,n,t.property));K6(o,n,t.property)}}),WT=V("$ZodCheckMimeType",(e,t)=>{Yt.init(e,t);let n=new Set(t.mime);e._zod.onattach.push(o=>{o._zod.bag.mime=t.mime}),e._zod.check=o=>{n.has(o.value.type)||o.issues.push({code:"invalid_value",values:t.mime,input:o.value.type,inst:e,continue:!t.abort})}}),BT=V("$ZodCheckOverwrite",(e,t)=>{Yt.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}})});var Nh,UT=x(()=>{Nh=class{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let o=t.split(`
9
9
  `).filter(s=>s),r=Math.min(...o.map(s=>s.length-s.trimStart().length)),i=o.map(s=>s.slice(r)).map(s=>" ".repeat(this.indent*2)+s);for(let s of i)this.content.push(s)}compile(){let t=Function,n=this?.args,r=[...(this?.content??[""]).map(i=>` ${i}`)];return new t(...n,r.join(`
10
10
  `))}}});var zT,HT=x(()=>{zT={major:4,minor:3,patch:6}});function fI(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}function cJ(e){if(!YR.test(e))return!1;let t=e.replace(/[-_]/g,o=>o==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return fI(n)}function lJ(e,t=null){try{let n=e.split(".");if(n.length!==3)return!1;let[o]=n;if(!o)return!1;let r=JSON.parse(atob(o));return!("typ"in r&&r?.typ!=="JWT"||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}}function Y6(e,t,n){e.issues.length&&t.issues.push(...Ao(n,e.issues)),t.value[n]=e.value}function ax(e,t,n,o,r){if(e.issues.length){if(r&&!(n in o))return;t.issues.push(...Ao(n,e.issues))}e.value===void 0?n in o&&(t.value[n]=void 0):t.value[n]=e.value}function uJ(e){let t=Object.keys(e.shape);for(let o of t)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${o}": expected a Zod schema`);let n=B0(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function dJ(e,t,n,o,r,i){let s=[],a=r.keySet,c=r.catchall._zod,l=c.def.type,u=c.optout==="optional";for(let d in t){if(a.has(d))continue;if(l==="never"){s.push(d);continue}let p=c.run({value:t[d],issues:[]},o);p instanceof Promise?e.push(p.then(f=>ax(f,n,d,t,u))):ax(p,n,d,t,u)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}function Q6(e,t,n,o){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let r=e.filter(i=>!Dc(i));return r.length===1?(t.value=r[0].value,r[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(s=>oo(s,o,xn())))}),t)}function X6(e,t,n,o){let r=e.filter(i=>i.issues.length===0);return r.length===1?(t.value=r[0].value,t):(r.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(s=>oo(s,o,xn())))}):t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:[],inclusive:!1}),t)}function qT(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Ic(e)&&Ic(t)){let n=Object.keys(t),o=Object.keys(e).filter(i=>n.indexOf(i)!==-1),r={...e,...t};for(let i of o){let s=qT(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};r[i]=s.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let o=0;o<e.length;o++){let r=e[o],i=t[o],s=qT(r,i);if(!s.valid)return{valid:!1,mergeErrorPath:[o,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function eJ(e,t,n){let o=new Map,r;for(let a of t.issues)if(a.code==="unrecognized_keys"){r??(r=a);for(let c of a.keys)o.has(c)||o.set(c,{}),o.get(c).l=!0}else e.issues.push(a);for(let a of n.issues)if(a.code==="unrecognized_keys")for(let c of a.keys)o.has(c)||o.set(c,{}),o.get(c).r=!0;else e.issues.push(a);let i=[...o].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(i.length&&r&&e.issues.push({...r,keys:i}),Dc(e))return e;let s=qT(t.value,n.value);if(!s.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}function rx(e,t,n){e.issues.length&&t.issues.push(...Ao(n,e.issues)),t.value[n]=e.value}function tJ(e,t,n,o,r,i,s){e.issues.length&&(Oh.has(typeof o)?n.issues.push(...Ao(o,e.issues)):n.issues.push({code:"invalid_key",origin:"map",input:r,inst:i,issues:e.issues.map(a=>oo(a,s,xn()))})),t.issues.length&&(Oh.has(typeof o)?n.issues.push(...Ao(o,t.issues)):n.issues.push({origin:"map",code:"invalid_element",input:r,inst:i,key:o,issues:t.issues.map(a=>oo(a,s,xn()))})),n.value.set(e.value,t.value)}function nJ(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}function rJ(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}function oJ(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}function iJ(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}function ox(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}function ix(e,t,n){if(e.issues.length)return e.aborted=!0,e;if((n.direction||"forward")==="forward"){let r=t.transform(e.value,e);return r instanceof Promise?r.then(i=>sx(e,i,t.out,n)):sx(e,r,t.out,n)}else{let r=t.reverseTransform(e.value,e);return r instanceof Promise?r.then(i=>sx(e,i,t.in,n)):sx(e,r,t.in,n)}}function sx(e,t,n,o){return e.issues.length?(e.aborted=!0,e):n._zod.run({value:t,issues:e.issues},o)}function sJ(e){return e.value=Object.freeze(e.value),e}function aJ(e,t,n,o){if(!e){let r={code:"custom",input:n,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};o._zod.def.params&&(r.params=o._zod.def.params),t.issues.push(Ap(r))}}var rt,$u,Ht,VT,KT,JT,ZT,YT,QT,XT,eI,tI,nI,rI,oI,iI,sI,aI,cI,lI,uI,dI,pI,mI,gI,hI,yI,wI,cx,bI,jh,lx,vI,kI,RI,xI,$I,SI,EI,OI,PI,AI,pJ,CI,Lh,_I,TI,II,ux,DI,NI,jI,LI,MI,FI,GI,dx,WI,BI,UI,zI,HI,qI,VI,KI,JI,Mh,ZI,YI,QI,XI,eD,tD,nD=x(()=>{nx();Ep();UT();Z0();XR();He();HT();He();rt=V("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=zT;let o=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&o.unshift(e);for(let r of o)for(let i of r._zod.onattach)i(e);if(o.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let r=(s,a,c)=>{let l=Dc(s),u;for(let d of a){if(d._zod.def.when){if(!d._zod.def.when(s))continue}else if(l)continue;let p=s.issues.length,f=d._zod.check(s);if(f instanceof Promise&&c?.async===!1)throw new Fi;if(u||f instanceof Promise)u=(u??Promise.resolve()).then(async()=>{await f,s.issues.length!==p&&(l||(l=Dc(s,p)))});else{if(s.issues.length===p)continue;l||(l=Dc(s,p))}}return u?u.then(()=>s):s},i=(s,a,c)=>{if(Dc(s))return s.aborted=!0,s;let l=r(a,o,c);if(l instanceof Promise){if(c.async===!1)throw new Fi;return l.then(u=>e._zod.parse(u,c))}return e._zod.parse(l,c)};e._zod.run=(s,a)=>{if(a.skipChecks)return e._zod.parse(s,a);if(a.direction==="backward"){let l=e._zod.parse({value:s.value,issues:[]},{...a,skipChecks:!0});return l instanceof Promise?l.then(u=>i(u,s,a)):i(l,s,a)}let c=e._zod.parse(s,a);if(c instanceof Promise){if(a.async===!1)throw new Fi;return c.then(l=>r(l,o,a))}return r(c,o,a)}}mt(e,"~standard",()=>({validate:r=>{try{let i=K0(e,r);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return J0(e,r).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),$u=V("$ZodString",(e,t)=>{rt.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??yT(e._zod.bag),e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Ht=V("$ZodStringFormat",(e,t)=>{Dp.init(e,t),$u.init(e,t)}),VT=V("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=oT),Ht.init(e,t)}),KT=V("$ZodUUID",(e,t)=>{if(t.version){let o={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(o===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=xu(o))}else t.pattern??(t.pattern=xu());Ht.init(e,t)}),JT=V("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=iT),Ht.init(e,t)}),ZT=V("$ZodURL",(e,t)=>{Ht.init(e,t),e._zod.check=n=>{try{let o=n.value.trim(),r=new URL(o);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(r.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=r.href:n.value=o;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),YT=V("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=sT()),Ht.init(e,t)}),QT=V("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=nT),Ht.init(e,t)}),XT=V("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Y0),Ht.init(e,t)}),eI=V("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Q0),Ht.init(e,t)}),tI=V("$ZodULID",(e,t)=>{t.pattern??(t.pattern=X0),Ht.init(e,t)}),nI=V("$ZodXID",(e,t)=>{t.pattern??(t.pattern=eT),Ht.init(e,t)}),rI=V("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=tT),Ht.init(e,t)}),oI=V("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=hT(t)),Ht.init(e,t)}),iI=V("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=mT),Ht.init(e,t)}),sI=V("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=gT(t)),Ht.init(e,t)}),aI=V("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=rT),Ht.init(e,t)}),cI=V("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=aT),Ht.init(e,t),e._zod.bag.format="ipv4"}),lI=V("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=cT),Ht.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),uI=V("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=lT(t.delimiter)),Ht.init(e,t),e._zod.bag.format="mac"}),dI=V("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=uT),Ht.init(e,t)}),pI=V("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=dT),Ht.init(e,t),e._zod.check=n=>{let o=n.value.split("/");try{if(o.length!==2)throw new Error;let[r,i]=o;if(!i)throw new Error;let s=Number(i);if(`${s}`!==i)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${r}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});mI=V("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=pT),Ht.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{fI(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});gI=V("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=YR),Ht.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{cJ(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),hI=V("$ZodE164",(e,t)=>{t.pattern??(t.pattern=fT),Ht.init(e,t)});yI=V("$ZodJWT",(e,t)=>{Ht.init(e,t),e._zod.check=n=>{lJ(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),wI=V("$ZodCustomStringFormat",(e,t)=>{Ht.init(e,t),e._zod.check=n=>{t.fn(n.value)||n.issues.push({code:"invalid_format",format:t.format,input:n.value,inst:e,continue:!t.abort})}}),cx=V("$ZodNumber",(e,t)=>{rt.init(e,t),e._zod.pattern=e._zod.bag.pattern??QR,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let r=n.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;let i=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...i?{received:i}:{}}),n}}),bI=V("$ZodNumberFormat",(e,t)=>{ET.init(e,t),cx.init(e,t)}),jh=V("$ZodBoolean",(e,t)=>{rt.init(e,t),e._zod.pattern=vT,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=!!n.value}catch{}let r=n.value;return typeof r=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}}),lx=V("$ZodBigInt",(e,t)=>{rt.init(e,t),e._zod.pattern=wT,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch{}return typeof n.value=="bigint"||n.issues.push({expected:"bigint",code:"invalid_type",input:n.value,inst:e}),n}}),vI=V("$ZodBigIntFormat",(e,t)=>{OT.init(e,t),lx.init(e,t)}),kI=V("$ZodSymbol",(e,t)=>{rt.init(e,t),e._zod.parse=(n,o)=>{let r=n.value;return typeof r=="symbol"||n.issues.push({expected:"symbol",code:"invalid_type",input:r,inst:e}),n}}),RI=V("$ZodUndefined",(e,t)=>{rt.init(e,t),e._zod.pattern=RT,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(n,o)=>{let r=n.value;return typeof r>"u"||n.issues.push({expected:"undefined",code:"invalid_type",input:r,inst:e}),n}}),xI=V("$ZodNull",(e,t)=>{rt.init(e,t),e._zod.pattern=kT,e._zod.values=new Set([null]),e._zod.parse=(n,o)=>{let r=n.value;return r===null||n.issues.push({expected:"null",code:"invalid_type",input:r,inst:e}),n}}),$I=V("$ZodAny",(e,t)=>{rt.init(e,t),e._zod.parse=n=>n}),SI=V("$ZodUnknown",(e,t)=>{rt.init(e,t),e._zod.parse=n=>n}),EI=V("$ZodNever",(e,t)=>{rt.init(e,t),e._zod.parse=(n,o)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)}),OI=V("$ZodVoid",(e,t)=>{rt.init(e,t),e._zod.parse=(n,o)=>{let r=n.value;return typeof r>"u"||n.issues.push({expected:"void",code:"invalid_type",input:r,inst:e}),n}}),PI=V("$ZodDate",(e,t)=>{rt.init(e,t),e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=new Date(n.value)}catch{}let r=n.value,i=r instanceof Date;return i&&!Number.isNaN(r.getTime())||n.issues.push({expected:"date",code:"invalid_type",input:r,...i?{received:"Invalid Date"}:{},inst:e}),n}});AI=V("$ZodArray",(e,t)=>{rt.init(e,t),e._zod.parse=(n,o)=>{let r=n.value;if(!Array.isArray(r))return n.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),n;n.value=Array(r.length);let i=[];for(let s=0;s<r.length;s++){let a=r[s],c=t.element._zod.run({value:a,issues:[]},o);c instanceof Promise?i.push(c.then(l=>Y6(l,n,s))):Y6(c,n,s)}return i.length?Promise.all(i).then(()=>n):n}});pJ=V("$ZodObject",(e,t)=>{if(rt.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let a=t.shape;Object.defineProperty(t,"shape",{get:()=>{let c={...a};return Object.defineProperty(t,"shape",{value:c}),c}})}let o=Pp(()=>uJ(t));mt(e._zod,"propValues",()=>{let a=t.shape,c={};for(let l in a){let u=a[l]._zod;if(u.values){c[l]??(c[l]=new Set);for(let d of u.values)c[l].add(d)}}return c});let r=Ru,i=t.catchall,s;e._zod.parse=(a,c)=>{s??(s=o.value);let l=a.value;if(!r(l))return a.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),a;a.value={};let u=[],d=s.shape;for(let p of s.keys){let f=d[p],m=f._zod.optout==="optional",g=f._zod.run({value:l[p],issues:[]},c);g instanceof Promise?u.push(g.then(h=>ax(h,a,p,l,m))):ax(g,a,p,l,m)}return i?dJ(u,l,a,c,o.value,e):u.length?Promise.all(u).then(()=>a):a}}),CI=V("$ZodObjectJIT",(e,t)=>{pJ.init(e,t);let n=e._zod.parse,o=Pp(()=>uJ(t)),r=p=>{let f=new Nh(["shape","payload","ctx"]),m=o.value,g=v=>{let b=FR(v);return`shape[${b}]._zod.run({ value: input[${b}], issues: [] }, ctx)`};f.write("const input = payload.value;");let h=Object.create(null),w=0;for(let v of m.keys)h[v]=`key_${w++}`;f.write("const newResult = {};");for(let v of m.keys){let b=h[v],$=FR(v),O=p[v]?._zod?.optout==="optional";f.write(`const ${b} = ${g(v)};`),O?f.write(`
@@ -102,7 +102,7 @@ ${e.timestamp}`,"utf-8")}function PAe(e,t,n){let o=`the approval of gate ${n.gat
102
102
  `+A.slice(de+1):Ne+=A.slice(me),Ne.slice(1)}function Tn(A){let Z="",ie=0;for(let fe=0;fe<A.length;ie>=65536?fe+=2:fe++){ie=Ae(A,fe);let me=C[ie];!me&&X(ie)?(Z+=A[fe],ie>=65536&&(Z+=A[fe+1])):Z+=me||Y(ie)}return Z}function ar(A,Z,ie){let fe="",me=A.tag;for(let we=0,de=ie.length;we<de;we+=1){let Oe=ie[we];A.replacer&&(Oe=A.replacer.call(ie,String(we),Oe)),(U(A,Z,Oe,!1,!1)||typeof Oe>"u"&&U(A,Z,null,!1,!1))&&(fe!==""&&(fe+=","+(A.condenseFlow?"":" ")),fe+=A.dump)}A.tag=me,A.dump="["+fe+"]"}function Nr(A,Z,ie,fe){let me="",we=A.tag;for(let de=0,Oe=ie.length;de<Oe;de+=1){let Ne=ie[de];A.replacer&&(Ne=A.replacer.call(ie,String(de),Ne)),(U(A,Z+1,Ne,!0,!0,!1,!0)||typeof Ne>"u"&&U(A,Z+1,null,!0,!0,!1,!0))&&((!fe||me!=="")&&(me+=K(A,Z)),A.dump&&a===A.dump.charCodeAt(0)?me+="-":me+="- ",me+=A.dump)}A.tag=we,A.dump=me||"[]"}function kr(A,Z,ie){let fe="",me=A.tag,we=Object.keys(ie);for(let de=0,Oe=we.length;de<Oe;de+=1){let Ne="";fe!==""&&(Ne+=", "),A.condenseFlow&&(Ne+='"');let Ve=we[de],Je=ie[Ve];A.replacer&&(Je=A.replacer.call(ie,Ve,Je)),U(A,Z,Ve,!1,!1)&&(A.dump.length>1024&&(Ne+="? "),Ne+=A.dump+(A.condenseFlow?'"':"")+":"+(A.condenseFlow?"":" "),U(A,Z,Je,!1,!1)&&(Ne+=A.dump,fe+=Ne))}A.tag=me,A.dump="{"+fe+"}"}function Oc(A,Z,ie,fe){let me="",we=A.tag,de=Object.keys(ie);if(A.sortKeys===!0)de.sort();else if(typeof A.sortKeys=="function")de.sort(A.sortKeys);else if(A.sortKeys)throw new t("sortKeys must be a boolean or a function");for(let Oe=0,Ne=de.length;Oe<Ne;Oe+=1){let Ve="";(!fe||me!=="")&&(Ve+=K(A,Z));let Je=de[Oe],et=ie[Je];if(A.replacer&&(et=A.replacer.call(ie,Je,et)),!U(A,Z+1,Je,!0,!0,!0))continue;let ut=A.tag!==null&&A.tag!=="?"||A.dump&&A.dump.length>1024;ut&&(A.dump&&a===A.dump.charCodeAt(0)?Ve+="?":Ve+="? "),Ve+=A.dump,ut&&(Ve+=K(A,Z)),U(A,Z+1,et,!0,ut)&&(A.dump&&a===A.dump.charCodeAt(0)?Ve+=":":Ve+=": ",Ve+=A.dump,me+=Ve)}A.tag=we,A.dump=me||"{}"}function R(A,Z,ie){let fe=ie?A.explicitTypes:A.implicitTypes;for(let me=0,we=fe.length;me<we;me+=1){let de=fe[me];if((de.instanceOf||de.predicate)&&(!de.instanceOf||typeof Z=="object"&&Z instanceof de.instanceOf)&&(!de.predicate||de.predicate(Z))){if(ie?de.multi&&de.representName?A.tag=de.representName(Z):A.tag=de.tag:A.tag="?",de.represent){let Oe=A.styleMap[de.tag]||de.defaultStyle,Ne;if(o.call(de.represent)==="[object Function]")Ne=de.represent(Z,Oe);else if(r.call(de.represent,Oe))Ne=de.represent[Oe](Z,Oe);else throw new t("!<"+de.tag+'> tag resolver accepts not "'+Oe+'" style');A.dump=Ne}return!0}}return!1}function U(A,Z,ie,fe,me,we,de){A.tag=null,A.dump=ie,R(A,ie,!1)||R(A,ie,!0);let Oe=o.call(A.dump),Ne=fe;fe&&(fe=A.flowLevel<0||A.flowLevel>Z);let Ve=Oe==="[object Object]"||Oe==="[object Array]",Je,et;if(Ve&&(Je=A.duplicates.indexOf(ie),et=Je!==-1),(A.tag!==null&&A.tag!=="?"||et||A.indent!==2&&Z>0)&&(me=!1),et&&A.usedDuplicates[Je])A.dump="*ref_"+Je;else{if(Ve&&et&&!A.usedDuplicates[Je]&&(A.usedDuplicates[Je]=!0),Oe==="[object Object]")fe&&Object.keys(A.dump).length!==0?(Oc(A,Z,A.dump,me),et&&(A.dump="&ref_"+Je+A.dump)):(kr(A,Z,A.dump),et&&(A.dump="&ref_"+Je+" "+A.dump));else if(Oe==="[object Array]")fe&&A.dump.length!==0?(A.noArrayIndent&&!de&&Z>0?Nr(A,Z-1,A.dump,me):Nr(A,Z,A.dump,me),et&&(A.dump="&ref_"+Je+A.dump)):(ar(A,Z,A.dump),et&&(A.dump="&ref_"+Je+" "+A.dump));else if(Oe==="[object String]")A.tag!=="?"&&Dt(A,A.dump,Z,we,Ne);else{if(Oe==="[object Undefined]")return!1;if(A.skipInvalid)return!1;throw new t("unacceptable kind of an object to dump "+Oe)}if(A.tag!==null&&A.tag!=="?"){let ut=encodeURI(A.tag[0]==="!"?A.tag.slice(1):A.tag).replace(/!/g,"%21");A.tag[0]==="!"?ut="!"+ut:ut.slice(0,18)==="tag:yaml.org,2002:"?ut="!!"+ut.slice(18):ut="!<"+ut+">",A.dump=ut+" "+A.dump}}return!0}function oe(A,Z){let ie=[],fe=[];ue(A,ie,fe);let me=fe.length;for(let we=0;we<me;we+=1)Z.duplicates.push(ie[fe[we]]);Z.usedDuplicates=new Array(me)}function ue(A,Z,ie){if(A!==null&&typeof A=="object"){let fe=Z.indexOf(A);if(fe!==-1)ie.indexOf(fe)===-1&&ie.push(fe);else if(Z.push(A),Array.isArray(A))for(let me=0,we=A.length;me<we;me+=1)ue(A[me],Z,ie);else{let me=Object.keys(A);for(let we=0,de=me.length;we<de;we+=1)ue(A[me[we]],Z,ie)}}}function re(A,Z){Z=Z||{};let ie=new H(Z);ie.noRefs||oe(A,ie);let fe=A;return ie.replacer&&(fe=ie.replacer.call({"":fe},"",fe)),U(ie,0,fe,!0,!0)?ie.dump+`
103
103
  `:""}return LF.dump=re,LF}function ENe(){if(u7)return Er;u7=1;let e=$Ne(),t=SNe();function n(o,r){return function(){throw new Error("Function yaml."+o+" is removed in js-yaml 4. Use yaml."+r+" instead, which is now safe by default.")}}return Er.Type=zr(),Er.Schema=d7(),Er.FAILSAFE_SCHEMA=g7(),Er.JSON_SCHEMA=v7(),Er.CORE_SCHEMA=k7(),Er.DEFAULT_SCHEMA=MF(),Er.load=e.load,Er.loadAll=e.loadAll,Er.dump=t.dump,Er.YAMLException=yw(),Er.types={binary:$7(),float:b7(),map:m7(),null:h7(),pairs:E7(),set:O7(),timestamp:R7(),bool:y7(),int:w7(),merge:x7(),omap:S7(),seq:f7(),str:p7()},Er.safeLoad=n("safeLoad","load"),Er.safeLoadAll=n("safeLoadAll","loadAll"),Er.safeDump=n("safeDump","dump"),Er}var Er,VS,ol,GX,hF,WX,yF,BX,wF,UX,bF,zX,vF,HX,kF,qX,RF,VX,xF,KX,$F,JX,SF,ZX,EF,YX,OF,QX,PF,XX,AF,e7,CF,t7,_F,n7,TF,r7,IF,o7,DF,i7,NF,s7,jF,a7,c7,LF,l7,u7,ONe,Aa,Ndt,jdt,Ldt,Mdt,Fdt,Gdt,Wdt,Bdt,Udt,zdt,Hdt,qdt,Vdt,Kdt,KS=x(()=>{Er={},VS={},ol={};LF={};ONe=ENe(),Aa=RNe(ONe),{Type:Ndt,Schema:jdt,FAILSAFE_SCHEMA:Ldt,JSON_SCHEMA:Mdt,CORE_SCHEMA:Fdt,DEFAULT_SCHEMA:Gdt,load:Wdt,loadAll:Bdt,dump:Udt,YAMLException:zdt,types:Hdt,safeLoad:qdt,safeLoadAll:Vdt,safeDump:Kdt}=Aa});import{existsSync as PNe,readFileSync as ZS}from"node:fs";import{isAbsolute as GF,join as WF,relative as BF,resolve as UF}from"node:path";function A7(e=[]){let t=new Map;for(let n of[...P7,...e]){if(t.has(n.name))throw new Error(`kind ${n.name} is registered twice`);t.set(n.name,n)}return{get:n=>t.get(n),names:()=>[...t.values()].filter(n=>n.shape==="member").map(n=>n.name).sort(),all:()=>[...t.values()]}}function C7(){return A7()}function _7(e,t,n){if("directory"in e.probe)return!0;if("chantProject"in e.probe)return qF(t,n);if("repo"in e.probe)return!0;let{anyFile:o,anyBlock:r,anyJsonKey:i,anyLine:s,anyDocument:a}=e.probe;if(o&&ww(t,n,o).length>0)return!0;if(i)for(let c of ww(t,n,i.in))try{let l=JSON.parse(t.read(c));if(i.pointers.some(u=>T7(l,u)!==void 0))return!0}catch{}if(s){let c=s.starts.map(l=>l.toLowerCase());for(let l of ww(t,n,s.in))try{if(t.read(l).split(/\r?\n/).some(u=>c.some(d=>u.trimStart().toLowerCase().startsWith(d))))return!0}catch{}}if(a)for(let c of ww(t,n,a.in))try{if(_Ne(t.read(c)).some(l=>a.match.some(u=>TNe(l,u))))return!0}catch{}if(r){let c=new RegExp(`^\\s*(?:${r.blocks.map(HF).join("|")})\\s*\\{`,"m");for(let l of ww(t,n,r.in))try{if(c.test(t.read(l)))return!0}catch{}}return!1}function ww(e,t,n){let o=[],r=n.filter(i=>i.includes("*"));for(let i of n)!i.includes("*")&&e.stat(Fe(t,i))==="file"&&o.push(Fe(t,i));if(r.length>0){let i=r.map(s=>new RegExp(`^${s.split("*").map(a=>HF(a).replace(/\\\[0-9\\\]/g,"[0-9]")).join("[^/]*")}$`));for(let s of e.list(t)??[])s.type==="file"&&i.some(a=>a.test(s.name))&&o.push(Fe(t,s.name))}return o.sort()}function _Ne(e){try{return Aa.loadAll(e)}catch{try{return Aa.loadAll(e.replace(/(^|[\s:\-[,{])!(?:[A-Za-z][\w]*:?)+/gm,"$1"))}catch{return[]}}}function TNe(e,t){let n=Object.entries(t);return n.length>0&&n.every(([o,r])=>{let i=T7(e,o);return i===void 0?!1:r.some(s=>new RegExp(`^${s.split("*").map(HF).join(".*")}$`).test(String(i)))})}function T7(e,t){let n=e;for(let o of t.split("/").slice(1)){let r=o.replace(/~1/g,"/").replace(/~0/g,"~");if(n===null||typeof n!="object"||!Object.prototype.hasOwnProperty.call(n,r))return;n=n[r]}return n}function HF(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function qF(e,t){let n=Fe(t,"package.json");if(e.stat(n)==="file")try{let r=JSON.parse(e.read(n));for(let i of["dependencies","devDependencies","peerDependencies"]){let s=r[i];if(s&&typeof s=="object"&&Object.keys(s).some(NNe))return!0}}catch{}let o=(r,i)=>{let s=e.list(r)??[];return s.some(a=>a.type==="file"&&INe.includes(a.name))?!0:i===DNe?!1:s.some(a=>a.type==="dir"&&!jo(a.name)&&o(Fe(r,a.name),i+1))};return o(t,0)}function NNe(e){return e==="@intentius/chant"||e.startsWith("@intentius/chant-lexicon-")}function jNe(){if(JS)return JS;let e=Pa();return JS=new e({allErrors:!0,strict:!0}).compile(HL),JS}function LNe(e,t){let n;try{n=JSON.parse(e)}catch(a){return{kinds:[],problems:[`${t}: the kinds file is not JSON (${a.message})`]}}let o=jNe();if(!o(n)){let a=(o.errors??[]).map(c=>`${t}: ${c.instancePath||"the kinds file"} ${c.message??"is invalid"}`);return{kinds:[],problems:[...new Set(a)]}}let r=[],i=[],s=new Set;for(let a of n.kinds){if(CNe.includes(a.name)){r.push(`${t}: kind ${a.name} is built in and can't be supplied by a package`);continue}if(s.has(a.name)){r.push(`${t}: kind ${a.name} is listed twice`);continue}s.add(a.name),i.push({name:a.name,description:a.description,probe:{...a.probe.anyFile?{anyFile:[...a.probe.anyFile]}:{},...a.probe.anyBlock?{anyBlock:{in:[...a.probe.anyBlock.in],blocks:[...a.probe.anyBlock.blocks]}}:{},...a.probe.anyJsonKey?{anyJsonKey:{in:[...a.probe.anyJsonKey.in],pointers:[...a.probe.anyJsonKey.pointers]}}:{},...a.probe.anyLine?{anyLine:{in:[...a.probe.anyLine.in],starts:[...a.probe.anyLine.starts]}}:{},...a.probe.anyDocument?{anyDocument:{in:[...a.probe.anyDocument.in],match:a.probe.anyDocument.match.map(c=>structuredClone(c))}}:{}},precedence:a.precedence,shape:"member",outputs:{from:"declared",names:[...a.outputs??[]]},source:t,...a.graph?{graph:{...a.graph.lexicon?{lexicon:a.graph.lexicon}:{},...a.graph.reader?{reader:a.graph.reader}:{},config:structuredClone(a.graph.config??{})}}:{},...a.fields?{fields:structuredClone(a.fields)}:{},...a.reader&&FF.includes(a.reader)?{reader:a.reader}:{},...a.memberFile?{memberFile:{path:a.memberFile.path,schema:a.memberFile.schema}}:{}}),a.reader&&!FF.includes(a.reader)&&r.push(`${t}: kind ${a.name} names link reader ${a.reader}, which this chant does not have (it has ${FF.join(", ")}); the kind is kept, and its members' links are only those their entries state`);for(let c of WNe(a.fields??{}))r.push(`${t}: kind ${a.name} ${c}`)}return{kinds:i,problems:r}}function MNe(e,t=zF){return sM(e,t)}function FNe(e,t){let n=WF(e,"package.json"),o;try{o=JSON.parse(ZS(n,"utf-8"))}catch{return{kinds:[],problems:[`${t??e}: no readable package.json in ${e}`],file:void 0}}let r=t??(typeof o.name=="string"?o.name:e),i=MNe(o);if(i===void 0)return{kinds:[],problems:[],file:void 0};if(typeof i!="string")return{kinds:[],problems:[`${r}: ${i.problem}`],file:void 0};let s=UF(e,i),a=BF(e,s);if(a.startsWith("..")||GF(a))return{kinds:[],problems:[`${r}: exports["${zF}"] points outside the package`],file:void 0};let c;try{c=ZS(s,"utf-8")}catch{return{kinds:[],problems:[`${r}: exports["${zF}"] names ${i}, which does not exist`],file:s}}let l=LNe(c,r),u=typeof o.name=="string"?o.name:void 0;for(let d of l.kinds){if(d.packageDir=e,d.memberFile){let p=GNe(d.memberFile,e);p&&l.problems.push(`${r}: kind ${d.name} ${p}; members of the kind fail WSP012 until it is fixed`)}if(d.graph?.reader){let p=UF(e,...d.graph.reader.split("/")),f=BF(e,p);f.startsWith("..")||GF(f)?(l.problems.push(`${r}: kind ${d.name} names graph reader ${d.graph.reader}, which is outside the package; the kind is kept, and workspace graph lists its members with kind-not-run`),delete d.graph):PNe(p)?d.graph.readerFile=p:(l.problems.push(`${r}: kind ${d.name} names graph reader ${d.graph.reader}, which does not exist in the package; the kind is kept, and workspace graph lists its members with kind-not-run`),delete d.graph)}else d.graph?.lexicon&&u!==YS(d.graph.lexicon)&&(l.problems.push(`${r}: kind ${d.name} reads its members with lexicon ${d.graph.lexicon}, which is ${YS(d.graph.lexicon)}, and this package is ${u??"unnamed"}; the kind is kept, and workspace graph lists its members with kind-not-run`),delete d.graph)}return{...l,file:s}}function GNe(e,t){let n=UF(t,...e.schema.split("/"));e.schemaFile=n;let o=BF(t,n);if(o.startsWith("..")||GF(o))return`names member-file schema ${e.schema}, which is outside the package`;let r;try{r=JSON.parse(ZS(n,"utf-8"))}catch(i){return i.code==="ENOENT"?`names member-file schema ${e.schema}, which does not exist`:`names member-file schema ${e.schema}, which is not JSON (${i.message})`}if(r===null||typeof r!="object"||Array.isArray(r))return`names member-file schema ${e.schema}, which is not a JSON Schema object`;try{let i=Pa();e.validate=new i({allErrors:!0,strict:!1}).compile(r)}catch(i){return`names member-file schema ${e.schema}, which does not compile as a draft 2020-12 schema (${i.message})`}}function YS(e){return`@intentius/chant-lexicon-${e}`}function VF(e,t){let n=r=>r.replace(/\{(member|dir|workspace)\}/g,(i,s)=>t[s]),o=r=>typeof r=="string"?n(r):Array.isArray(r)?r.map(o):r!==null&&typeof r=="object"?Object.fromEntries(Object.entries(r).map(([i,s])=>[n(i),o(s)])):r;return o(e)}function KF(e,t,n=fS){if(e.package){let o=Cs(e.package,t)??Cs(e.package,n);if(!o)return{problem:`pinned package ${e.package} is not installed; install it to read the kinds it supplies`};let r;try{r=JSON.parse(ZS(WF(o,"package.json"),"utf-8")).version}catch{r=void 0}return e.version&&r!==e.version?{problem:`${e.package} is pinned at ${e.version}, and ${String(r??"an unknown version")} is installed`}:{dir:o,source:e.package}}if(e.path){let o=WF(t,...e.path.split("/"));if(e.integrity){let r=M8(o,e.integrity,e.path);if(!r.ok)return{problem:r.message}}return{dir:o,source:e.path}}return null}function il(e,t){let n=[],o=[],r=new Map,i=new Set;return e.forEach((s,a)=>{let c=KF(s,t);if(c===null)return;if("problem"in c){n.push({pin:a,message:c.problem});return}let{dir:l,source:u}=c,d=FNe(l,u);for(let p of d.problems)n.push({pin:a,message:p});for(let p of d.kinds){let f=r.get(p.name);if(f){i.add(p.name),n.push({pin:a,message:`kind ${p.name} is supplied by both ${f} and ${u}; a kind name has one source`});continue}r.set(p.name,u),o.push(p)}}),{registry:A7(o.filter(s=>!i.has(s.name))),problems:n}}function I7(e,t){if(!(e.type==="integer"?typeof t=="number"&&Number.isInteger(t):typeof t===e.type))return`is ${JSON.stringify(t)}, and the field is ${e.type==="integer"?"an integer":`a ${e.type}`}`;if(e.pattern!==void 0&&typeof t=="string"){let o;try{o=new RegExp(e.pattern,"u")}catch{return}if(!o.test(t))return`is ${JSON.stringify(t)}, which does not match ${e.pattern}`}}function WNe(e){let t=[],n=(o,r)=>{if(r.pattern!==void 0)try{new RegExp(r.pattern,"u")}catch{t.push(`declares field ${o} with pattern ${r.pattern}, which is not a regular expression`);return}if(r.default===void 0)return;let i=I7(r,r.default);i&&t.push(`declares field ${o} whose default ${i}`)};for(let[o,r]of Object.entries(e))if(r.type==="object")for(let[i,s]of Object.entries(r.properties))n(`${o}.${i}`,s);else n(o,r);return t}function JF(e,t){if(e===void 0)return{fields:null,problems:[]};let n=e.fields,o=[];if(n===void 0)return t!==null&&o.push({path:"",message:`kind ${e.name} declares no fields, and the entry sets ${Object.keys(t).join(", ")||"an empty fields block"}`}),{fields:null,problems:o};let r=t??{};for(let a of Object.keys(r))a in n||o.push({path:a,message:`kind ${e.name} declares no field ${a}; its fields are ${Object.keys(n).join(", ")}`});let i=(a,c,l)=>{if(l!==void 0){let u=I7(c,l);if(!u)return l;o.push({path:a,message:`field ${a.replace("/",".")} ${u}`})}return c.default??null},s={};for(let[a,c]of Object.entries(n)){if(c.type!=="object"){s[a]=i(a,c,r[a]);continue}let l=r[a],u={};l!==void 0&&(l!==null&&typeof l=="object"&&!Array.isArray(l)?u=l:o.push({path:a,message:`field ${a} is ${JSON.stringify(l)}, and the field is an object`}));for(let d of Object.keys(u))d in c.properties||o.push({path:`${a}/${d}`,message:`kind ${e.name} declares no field ${a}.${d}; ${a} has ${Object.keys(c.properties).join(", ")}`});s[a]=Object.fromEntries(Object.entries(c.properties).map(([d,p])=>[d,i(`${a}/${d}`,p,u[d])]))}return{fields:s,problems:o}}var opt,zF,FF,QS,Ca,ANe,P7,CNe,INe,DNe,JS,li=x(()=>{"use strict";I8();zt();F8();Lu();gw();KS();opt=HL.$id,zF="./workspace-kinds",FF=["dbt-project","goose-dir","golang-migrate-dir","clickhouse-migrations-dir","flyway-dir"],QS="examples",Ca="repo",ANe="design",P7=[{name:"chant",description:"a chant project, with a chant.config.ts or chant.config.json in its directory",probe:{anyFile:["chant.config.ts","chant.config.json"]},precedence:500,shape:"member",outputs:{from:"chant-source"},source:"builtin"},{name:"workspace",description:"a nested workspace, with its own chant.workspace.json; the outer one reads it through its own chant workspace graph and never writes inside it",probe:{anyFile:["chant.workspace.json","chant.workspace.jsonc"]},precedence:1e3,shape:"member",outputs:{from:"none"},source:"builtin"},{name:Ca,description:"another repository's workspace, named by URL and pinned revision; chant reads it through that repository's own chant workspace graph and never writes there",probe:{repo:!0},precedence:0,shape:"member",outputs:{from:"none"},source:"builtin"},{name:"other",description:"a directory chant does not read; the entry says why in `because`",probe:{directory:!0},precedence:0,shape:"member",outputs:{from:"declared",names:[]},source:"builtin"},{name:ANe,description:"a data member holding the design artifacts the workspace owns; chant reads its files for record pins and builds nothing",probe:{directory:!0},precedence:0,shape:"member",outputs:{from:"declared",names:[]},source:"builtin"},{name:QS,description:"an example group: every directory its glob matches that holds a chant project is built and linted",probe:{chantProject:!0},precedence:0,shape:"group",outputs:{from:"none"},source:"builtin"}],CNe=P7.map(e=>e.name);INe=["chant.config.ts","chant.config.json"],DNe=4});function _a(e){return String(e).replace(/~/g,"~0").replace(/\//g,"~1")}function sl(e,t){let n=[0];for(let h=0;h<e.length;h++)e.charCodeAt(h)===10&&n.push(h+1);let o=h=>{let w=0,k=n.length-1;for(;w<k;){let v=w+k+1>>1;n[v]<=h?w=v:k=v-1}return{line:w+1,column:h-n[w]+1}},r=new Map,i=new Map,s=new Map,a=e.charCodeAt(0)===65279?1:0,c=(h,w=a)=>{throw new XS(h,w)},l=h=>h>=e.length?"the end of the file":`${JSON.stringify(e[h])}`;function u(){for(;;){let h=e[a];if(h===" "||h===" "||h===`
104
104
  `||h==="\r")a++;else if(h==="/"&&(e[a+1]==="/"||e[a+1]==="*"))if(t.jsonc||c("comments are only allowed in chant.workspace.jsonc"),e[a+1]==="/")for(;a<e.length&&e[a]!==`
105
- `;)a++;else{let w=e.indexOf("*/",a+2);w<0&&c("unterminated /* comment"),a=w+2}else return}}function d(){let h=a;for(a++;;){a>=e.length&&c("unterminated string",h);let w=e.charCodeAt(a);if(w===34)break;w<32&&c("control character in a string; escape it",a),a+=w===92?2:1}a++;try{return JSON.parse(e.slice(h,a))}catch{return c("invalid escape in a string",h)}}function p(h){u(),r.set(h,a);let w=f(h);return i.set(h,a),w}function f(h){let w=e[a];if(w==="{")return m(h);if(w==="[")return g(h);if(w==='"')return d();for(let[v,b]of[["true",!0],["false",!1],["null",null]])if(e.startsWith(v,a))return a+=v.length,b;let k=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/.exec(e.slice(a,a+64));return k?(a+=k[0].length,Number(k[0])):c(`expected a value, found ${l(a)}`)}function m(h){let w={},k=new Set;if(a++,u(),e[a]==="}")return a++,w;for(;;){u(),e[a]!=='"'&&c(`expected a quoted key, found ${l(a)}`);let v=a,b=d();k.has(b)&&c(`duplicate key ${JSON.stringify(b)}`,v),k.add(b);let $=`${h}/${_a(b)}`;if(s.set($,v),u(),e[a]!==":"&&c(`expected ":" after key ${JSON.stringify(b)}, found ${l(a)}`),a++,Object.defineProperty(w,b,{value:p($),enumerable:!0,writable:!0,configurable:!0}),u(),e[a]===","){if(a++,u(),e[a]==="}")return t.jsonc||c("trailing comma; only chant.workspace.jsonc allows one"),a++,w;continue}if(e[a]==="}")return a++,w;c(`expected "," or "}", found ${l(a)}`)}}function g(h){let w=[];if(a++,u(),e[a]==="]")return a++,w;for(;;){if(w.push(p(`${h}/${w.length}`)),u(),e[a]===","){if(a++,u(),e[a]==="]")return t.jsonc||c("trailing comma; only chant.workspace.jsonc allows one"),a++,w;continue}if(e[a]==="]")return a++,w;c(`expected "," or "]", found ${l(a)}`)}}try{u(),a>=e.length&&c("the file is empty");let h=p("");return u(),a<e.length&&c(`unexpected ${l(a)} after the value`),{ok:!0,value:h,locate(w,k){if(k&&s.has(w))return o(s.get(w));for(let v=w;;v=v.slice(0,v.lastIndexOf("/"))){let b=r.get(v);if(b!==void 0)return o(b);if(v==="")return o(0)}},span(w){let k=r.get(w),v=i.get(w);if(!(k===void 0||v===void 0))return{key:s.get(w)??null,start:k,end:v}}}}catch(h){if(!(h instanceof XS))throw h;return{ok:!1,message:h.message,location:o(h.offset)}}}var XS,Wf=x(()=>{"use strict";XS=class extends Error{constructor(n,o){super(n);this.offset=o}}});function D7(){return"0.124.74"}var N7=x(()=>{"use strict"});function Bf(e=process.env){let t=e.CI?.trim().toLowerCase();return t&&t!=="false"&&t!=="0"?"ledger":void 0}function eE(e){if(e!==void 0)return typeof e=="string"?{name:e}:e}function Zu(e,t=!1){let n=[];t&&n.push("a gate that asks a decision point takes its quorum from the point: give `approval` or `point`, not both");let o=typeof e=="string"?{name:e}:e;if(o===null||typeof o!="object"||Array.isArray(o))return[...n,"`point` is a decision point's name or { name, inputs?, pass?, store? }"];let{name:r,inputs:i,pass:s,store:a,...c}=o;if((typeof r!="string"||!BNe.test(r))&&n.push("`point.name` is a decision point's name: lower case letters, digits and hyphens, starting with a letter"),i!==void 0&&(i===null||typeof i!="object"||Array.isArray(i))&&n.push("`point.inputs` is an object of input name to value"),i&&typeof i=="object"){let u=Object.keys(i).filter(d=>d in bw);u.length>0&&n.push(`\`point.inputs\` gives ${u.join(", ")}, which the gate passes itself`)}s!==void 0&&(!Array.isArray(s)||s.length===0||s.some(u=>typeof u!="string"&&typeof u!="boolean"))&&n.push("`point.pass` is a non-empty list of the answers that pass the gate"),a!==void 0&&a!=="tree"&&a!=="ledger"&&n.push("`point.store` is tree or ledger: where the question is held");let l=Object.keys(c);return l.length>0&&n.push(`\`point\` takes name, inputs, pass and store, not ${l.join(", ")}`),n}function Yu(e,t,n,o={}){if(n.planDigest!==null&&!t.includes("gate.planDigest"))throw new Error(`gate "${n.name}" binds a plan and asks decision point ${e}, which does not declare the input gate.planDigest: declare it in the points file, so each plan is its own question and an answer for one plan never passes another`);let r={};for(let[i,s]of Object.entries(bw))t.includes(i)&&n[s]!==null&&(r[i]=n[s]);return{...o,...r}}function vw(e,t,n){return`gate:${e}/${t}${n?`@${n}`:""}`}function tE(e){if(!e||!e.startsWith("gate:"))return;let t=e.slice(5),n=t.lastIndexOf("@"),o=n>0?t.slice(0,n):t,r=o.indexOf("/");if(!(r<=0||r===o.length-1))return{op:o.slice(0,r),gate:o.slice(r+1),...n>0?{env:t.slice(n+1)}:{}}}var Uf,BNe,bw,Ta=x(()=>{"use strict";Uf=[!0];BNe=/^[a-z][a-z0-9-]*$/;bw={"gate.component":"component","gate.name":"name","gate.env":"env","gate.planDigest":"planDigest"}});function ui(e){return e===void 0?[]:Array.isArray(e)?[...e]:[e]}function ZF(e,t){let n=e.replace(/\\/g,"/").replace(/\/+$/,""),o="";for(let r=0;r<n.length;r++){let i=n[r];i==="*"&&n[r+1]==="*"?n[r+2]==="/"?(o+="(?:.*/)?",r+=2):(o+=".*",r+=1):i==="*"?o+="[^/]*":i==="?"?o+="[^/]":o+=i.replace(/[.+^${}()|[\]\\]/g,"\\$&")}return new RegExp(`^${o}$`).test(t.replace(/\\/g,"/").replace(/\/+$/,""))}function zf(e,t){return e.filter(n=>n.targets===void 0||n.targets.some(o=>t.some(r=>ZF(o,r))))}function Rw(e){return e.reduce((t,n)=>Math.max(t,n.count),1)}function di(e,t,n){let o=Array.isArray(e)?e:[e],r=[];return Array.isArray(e)&&e.length===0&&r.push(`\`${t}\` must name at least one rule`),o.forEach((i,s)=>{let a=Array.isArray(e)?`${t}[${s}]`:t;if(typeof i!="object"||i===null||Array.isArray(i)){r.push(`\`${a}\` must be an object`);return}let c=i;(typeof c.count!="number"||!Number.isInteger(c.count)||c.count<1)&&r.push(`\`${a}.count\` must be an integer of at least 1`),c.roles!==void 0&&(!Array.isArray(c.roles)||c.roles.length===0||c.roles.some(u=>typeof u!="string"||u===""))&&r.push(`\`${a}.roles\` must be a non-empty list of role names`),c.targets!==void 0&&(!Array.isArray(c.targets)||c.targets.length===0||c.targets.some(u=>typeof u!="string"||u===""))&&r.push(`\`${a}.targets\` must be a non-empty list of globs`),c.notAuthor!==void 0&&typeof c.notAuthor!="boolean"&&r.push(`\`${a}.notAuthor\` must be true or false`),c.notAuthor===!0&&!n.notAuthor&&r.push(`\`${a}.notAuthor\` is not read here: an Op gate has no author to judge by. An Op waves spec's \`approvals.quorum\` reads it from the merged pull request`);let l=new Set(["targets","count","roles","notAuthor"]);for(let u of Object.keys(c))l.has(u)||r.push(`\`${a}.${u}\` is not a quorum field; use targets, count, roles or notAuthor`)}),r}function rE(e,t){return Object.entries(t).filter(([,n])=>n.some(o=>Lo(o,e))).map(([n])=>n).sort()}function xw(e,t){let n=new Set,o=[];for(let s of[...t].sort((a,c)=>Date.parse(a.at)-Date.parse(c.at)))n.has(nE(s.who))||s.judged.excluded!==void 0||e.roles?.length&&!(s.judged.proven&&s.judged.roles.some(a=>e.roles.includes(a)))||(n.add(nE(s.who)),o.push(s));let r=!e.notAuthor||o.some(s=>s.judged.proven&&s.judged.author===!1),i=e.notAuthor===!0&&!r&&o.some(s=>s.judged.proven&&s.judged.author===void 0);return{...e.targets?{targets:[...e.targets]}:{},count:e.count,...e.roles?.length?{roles:[...e.roles]}:{},...e.notAuthor?{notAuthor:!0}:{},approvers:o.map(s=>s.who),met:o.length>=e.count&&r,...i?{authorUnknown:!0}:{}}}function al(e){let t=e.targets?e.targets.join(", "):"every target",n=`${e.approvers.length} of ${e.count} approval${e.count===1?"":"s"}${e.approvers.length?` (${e.approvers.join(", ")})`:""}`;if(e.met)return`${t}: ${n}, met`;let o=e.count-e.approvers.length,r=[];o>0&&r.push(`${o} more${e.roles?.length?` from ${e.roles.join(" or ")}`:""}`),e.notAuthor&&r.push(o>0?"one of them not the author":"an approver who is not the author");let i=e.authorUnknown?" (the change's author is not known, so no approver can show they are someone else)":"";return`${t}: ${n}, needs ${r.join(", ")}${i}`}function $w(e){return e.filter(t=>!t.met).map(al).join("; ")}function oE(e){let t=[];for(let n of e.replace(/\r\n/g,`
105
+ `;)a++;else{let w=e.indexOf("*/",a+2);w<0&&c("unterminated /* comment"),a=w+2}else return}}function d(){let h=a;for(a++;;){a>=e.length&&c("unterminated string",h);let w=e.charCodeAt(a);if(w===34)break;w<32&&c("control character in a string; escape it",a),a+=w===92?2:1}a++;try{return JSON.parse(e.slice(h,a))}catch{return c("invalid escape in a string",h)}}function p(h){u(),r.set(h,a);let w=f(h);return i.set(h,a),w}function f(h){let w=e[a];if(w==="{")return m(h);if(w==="[")return g(h);if(w==='"')return d();for(let[v,b]of[["true",!0],["false",!1],["null",null]])if(e.startsWith(v,a))return a+=v.length,b;let k=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/.exec(e.slice(a,a+64));return k?(a+=k[0].length,Number(k[0])):c(`expected a value, found ${l(a)}`)}function m(h){let w={},k=new Set;if(a++,u(),e[a]==="}")return a++,w;for(;;){u(),e[a]!=='"'&&c(`expected a quoted key, found ${l(a)}`);let v=a,b=d();k.has(b)&&c(`duplicate key ${JSON.stringify(b)}`,v),k.add(b);let $=`${h}/${_a(b)}`;if(s.set($,v),u(),e[a]!==":"&&c(`expected ":" after key ${JSON.stringify(b)}, found ${l(a)}`),a++,Object.defineProperty(w,b,{value:p($),enumerable:!0,writable:!0,configurable:!0}),u(),e[a]===","){if(a++,u(),e[a]==="}")return t.jsonc||c("trailing comma; only chant.workspace.jsonc allows one"),a++,w;continue}if(e[a]==="}")return a++,w;c(`expected "," or "}", found ${l(a)}`)}}function g(h){let w=[];if(a++,u(),e[a]==="]")return a++,w;for(;;){if(w.push(p(`${h}/${w.length}`)),u(),e[a]===","){if(a++,u(),e[a]==="]")return t.jsonc||c("trailing comma; only chant.workspace.jsonc allows one"),a++,w;continue}if(e[a]==="]")return a++,w;c(`expected "," or "]", found ${l(a)}`)}}try{u(),a>=e.length&&c("the file is empty");let h=p("");return u(),a<e.length&&c(`unexpected ${l(a)} after the value`),{ok:!0,value:h,locate(w,k){if(k&&s.has(w))return o(s.get(w));for(let v=w;;v=v.slice(0,v.lastIndexOf("/"))){let b=r.get(v);if(b!==void 0)return o(b);if(v==="")return o(0)}},span(w){let k=r.get(w),v=i.get(w);if(!(k===void 0||v===void 0))return{key:s.get(w)??null,start:k,end:v}}}}catch(h){if(!(h instanceof XS))throw h;return{ok:!1,message:h.message,location:o(h.offset)}}}var XS,Wf=x(()=>{"use strict";XS=class extends Error{constructor(n,o){super(n);this.offset=o}}});function D7(){return"0.124.76"}var N7=x(()=>{"use strict"});function Bf(e=process.env){let t=e.CI?.trim().toLowerCase();return t&&t!=="false"&&t!=="0"?"ledger":void 0}function eE(e){if(e!==void 0)return typeof e=="string"?{name:e}:e}function Zu(e,t=!1){let n=[];t&&n.push("a gate that asks a decision point takes its quorum from the point: give `approval` or `point`, not both");let o=typeof e=="string"?{name:e}:e;if(o===null||typeof o!="object"||Array.isArray(o))return[...n,"`point` is a decision point's name or { name, inputs?, pass?, store? }"];let{name:r,inputs:i,pass:s,store:a,...c}=o;if((typeof r!="string"||!BNe.test(r))&&n.push("`point.name` is a decision point's name: lower case letters, digits and hyphens, starting with a letter"),i!==void 0&&(i===null||typeof i!="object"||Array.isArray(i))&&n.push("`point.inputs` is an object of input name to value"),i&&typeof i=="object"){let u=Object.keys(i).filter(d=>d in bw);u.length>0&&n.push(`\`point.inputs\` gives ${u.join(", ")}, which the gate passes itself`)}s!==void 0&&(!Array.isArray(s)||s.length===0||s.some(u=>typeof u!="string"&&typeof u!="boolean"))&&n.push("`point.pass` is a non-empty list of the answers that pass the gate"),a!==void 0&&a!=="tree"&&a!=="ledger"&&n.push("`point.store` is tree or ledger: where the question is held");let l=Object.keys(c);return l.length>0&&n.push(`\`point\` takes name, inputs, pass and store, not ${l.join(", ")}`),n}function Yu(e,t,n,o={}){if(n.planDigest!==null&&!t.includes("gate.planDigest"))throw new Error(`gate "${n.name}" binds a plan and asks decision point ${e}, which does not declare the input gate.planDigest: declare it in the points file, so each plan is its own question and an answer for one plan never passes another`);let r={};for(let[i,s]of Object.entries(bw))t.includes(i)&&n[s]!==null&&(r[i]=n[s]);return{...o,...r}}function vw(e,t,n){return`gate:${e}/${t}${n?`@${n}`:""}`}function tE(e){if(!e||!e.startsWith("gate:"))return;let t=e.slice(5),n=t.lastIndexOf("@"),o=n>0?t.slice(0,n):t,r=o.indexOf("/");if(!(r<=0||r===o.length-1))return{op:o.slice(0,r),gate:o.slice(r+1),...n>0?{env:t.slice(n+1)}:{}}}var Uf,BNe,bw,Ta=x(()=>{"use strict";Uf=[!0];BNe=/^[a-z][a-z0-9-]*$/;bw={"gate.component":"component","gate.name":"name","gate.env":"env","gate.planDigest":"planDigest"}});function ui(e){return e===void 0?[]:Array.isArray(e)?[...e]:[e]}function ZF(e,t){let n=e.replace(/\\/g,"/").replace(/\/+$/,""),o="";for(let r=0;r<n.length;r++){let i=n[r];i==="*"&&n[r+1]==="*"?n[r+2]==="/"?(o+="(?:.*/)?",r+=2):(o+=".*",r+=1):i==="*"?o+="[^/]*":i==="?"?o+="[^/]":o+=i.replace(/[.+^${}()|[\]\\]/g,"\\$&")}return new RegExp(`^${o}$`).test(t.replace(/\\/g,"/").replace(/\/+$/,""))}function zf(e,t){return e.filter(n=>n.targets===void 0||n.targets.some(o=>t.some(r=>ZF(o,r))))}function Rw(e){return e.reduce((t,n)=>Math.max(t,n.count),1)}function di(e,t,n){let o=Array.isArray(e)?e:[e],r=[];return Array.isArray(e)&&e.length===0&&r.push(`\`${t}\` must name at least one rule`),o.forEach((i,s)=>{let a=Array.isArray(e)?`${t}[${s}]`:t;if(typeof i!="object"||i===null||Array.isArray(i)){r.push(`\`${a}\` must be an object`);return}let c=i;(typeof c.count!="number"||!Number.isInteger(c.count)||c.count<1)&&r.push(`\`${a}.count\` must be an integer of at least 1`),c.roles!==void 0&&(!Array.isArray(c.roles)||c.roles.length===0||c.roles.some(u=>typeof u!="string"||u===""))&&r.push(`\`${a}.roles\` must be a non-empty list of role names`),c.targets!==void 0&&(!Array.isArray(c.targets)||c.targets.length===0||c.targets.some(u=>typeof u!="string"||u===""))&&r.push(`\`${a}.targets\` must be a non-empty list of globs`),c.notAuthor!==void 0&&typeof c.notAuthor!="boolean"&&r.push(`\`${a}.notAuthor\` must be true or false`),c.notAuthor===!0&&!n.notAuthor&&r.push(`\`${a}.notAuthor\` is not read here: an Op gate has no author to judge by. An Op waves spec's \`approvals.quorum\` reads it from the merged pull request`);let l=new Set(["targets","count","roles","notAuthor"]);for(let u of Object.keys(c))l.has(u)||r.push(`\`${a}.${u}\` is not a quorum field; use targets, count, roles or notAuthor`)}),r}function rE(e,t){return Object.entries(t).filter(([,n])=>n.some(o=>Lo(o,e))).map(([n])=>n).sort()}function xw(e,t){let n=new Set,o=[];for(let s of[...t].sort((a,c)=>Date.parse(a.at)-Date.parse(c.at)))n.has(nE(s.who))||s.judged.excluded!==void 0||e.roles?.length&&!(s.judged.proven&&s.judged.roles.some(a=>e.roles.includes(a)))||(n.add(nE(s.who)),o.push(s));let r=!e.notAuthor||o.some(s=>s.judged.proven&&s.judged.author===!1),i=e.notAuthor===!0&&!r&&o.some(s=>s.judged.proven&&s.judged.author===void 0);return{...e.targets?{targets:[...e.targets]}:{},count:e.count,...e.roles?.length?{roles:[...e.roles]}:{},...e.notAuthor?{notAuthor:!0}:{},approvers:o.map(s=>s.who),met:o.length>=e.count&&r,...i?{authorUnknown:!0}:{}}}function al(e){let t=e.targets?e.targets.join(", "):"every target",n=`${e.approvers.length} of ${e.count} approval${e.count===1?"":"s"}${e.approvers.length?` (${e.approvers.join(", ")})`:""}`;if(e.met)return`${t}: ${n}, met`;let o=e.count-e.approvers.length,r=[];o>0&&r.push(`${o} more${e.roles?.length?` from ${e.roles.join(" or ")}`:""}`),e.notAuthor&&r.push(o>0?"one of them not the author":"an approver who is not the author");let i=e.authorUnknown?" (the change's author is not known, so no approver can show they are someone else)":"";return`${t}: ${n}, needs ${r.join(", ")}${i}`}function $w(e){return e.filter(t=>!t.met).map(al).join("; ")}function oE(e){let t=[];for(let n of e.replace(/\r\n/g,`
106
106
  `).split(`
107
107
  `)){let o=/^requested-by:\s*(\S+)\s*$/i.exec(n.trim());o&&UNe.test(o[1])&&!t.some(r=>Lo(r,o[1]))&&t.push(o[1])}return t}function kw(e){let t=/^(?:github|gitlab|forgejo|gitea|codeberg)(?:@[^:\s]+)?:(.+)$/i.exec(e.trim());return t?[e,t[1]]:[e]}function iE(e,t){let n=kw(t);return e.find(o=>kw(o.who).some(r=>n.some(i=>Lo(r,i))))?.why}function Sw(e){let t=[],n=(o,r)=>{o.trim()&&!t.some(i=>Lo(i.who,o))&&t.push({who:o,why:r})};e.author&&n(e.author,`${e.author} opened the change`);for(let o of e.commits??[])for(let r of oE(o.message))n(e.principal?e.principal(r):r,`${r} asked for ${o.sha.slice(0,7)}`);for(let o of e.agents??[])n(o,`${o} is an account an agent acts as`);return t}function sE(e){let t=e;return t.via!=="pr-review"||typeof t.head!="string"||t.head===""||!Array.isArray(t.reviewers)||t.reviewers.length===0||t.reviewers.some(n=>typeof n!="string"||n==="")?null:{...typeof t.pr=="number"?{pr:t.pr}:{},head:t.head,reviewers:[...t.reviewers]}}function Ew(e,t=n=>n){let n=[],o=[];for(let r of e){let i=sE(r);if(!i){n.push(r);continue}let s=i.reviewers.map(t);o.push({head:i.head,approvers:s});let{seal:a,...c}=r,l=Object.fromEntries(Object.entries(c).filter(([u])=>!["via","reviewers","head","pr","excluded"].includes(u)));for(let u of s)n.push({...l,resolvedBy:u,approver:{kind:"human"},review:{pr:i.pr??0,head:i.head,approvers:s}})}return{records:n,reviews:o}}function pi(e){let t=(n,o)=>n.some(r=>Lo(r,o));return n=>{let o=n.seal!==void 0&&n.seal!==null&&Ps(e.signers,n)===null,r=e.review!==void 0&&n.review?.head===e.review.head&&t(e.review.approvers,n.resolvedBy),i=n.review!==void 0&&(e.recorded??[]).some(l=>l.head===n.review.head&&t(l.approvers,n.resolvedBy)),s=o||r||i,c=e.authors!==void 0&&e.authors.some(l=>Lo(l,n.resolvedBy))?`${n.resolvedBy} wrote the change`:iE(e.involved??[],n.resolvedBy);return{proven:s,roles:s?rE(n.resolvedBy,e.roles):[],...c!==void 0?{author:!0}:e.authors!==void 0?{author:!1}:{},...c!==void 0&&e.excludeInvolved?{excluded:`${c}, so ${n.resolvedBy}'s approval does not count`}:{}}}}var Ia,nE,Lo,Da,UNe,Mo=x(()=>{"use strict";Hi();Ia=()=>({proven:!1,roles:[]});nE=e=>e.normalize("NFKC").trim().toLowerCase(),Lo=(e,t)=>nE(e)===nE(t);Da=e=>(e.roles?.length??0)>0||e.notAuthor===!0,UNe=/^[A-Za-z0-9][A-Za-z0-9._-]*(\[bot\])?$/});function YF(e,t,n){return(e??aE).replaceAll("{gate}",t).replaceAll("{k}",String(n))}function QF(e,t,n,o){let r=[...e].sort((l,u)=>{let d=o(l),p=o(u);return d<p?-1:d>p?1:0}),i=Math.floor(r.length/n),s=r.length%n,a=(t-1)*i+Math.min(t-1,s),c=i+(t<=s?1:0);return r.slice(a,a+c)}var aE,XF=x(()=>{"use strict";aE="{gate}-wave-{k}"});var G7={};Re(G7,{WAVE_OUTCOME_VERSION:()=>cE,blockedMembers:()=>lE,blockedWords:()=>uE,earlierWaveOutcomes:()=>nG,onlyWaiting:()=>ZNe,passesThrough:()=>Hf,readWaveOutcomeFile:()=>rG,runSummary:()=>YNe,settleEarlierWaves:()=>JNe,waveOutcomeFileName:()=>qf,writeWaveOutcomeFile:()=>tG});import{existsSync as zNe,readdirSync as HNe,readFileSync as j7,statSync as qNe,writeFileSync as VNe}from"node:fs";import{basename as KNe,join as L7}from"node:path";function Hf(e){return e!==void 0&&eG.has(e.status)}function lE(e,t,n,o,r){if(r!==void 0)return new Map(e.map(s=>[s,`wave-${r}`]));let i=new Map;for(let s of e){let a=[...t.get(s)??[]].filter(c=>n.has(c)).sort().map(c=>{let l=o.get(c);if(!Hf(l))return l?.status==="blocked"&&l.by?l.by:c}).find(c=>c!==void 0);a!==void 0&&i.set(s,a)}return i}function JNe(e,t,n,o){let r=new Map(o),i=[],s=new Set;for(let a=1;a<t&&a<=e.length;a++){let c=e[a-1],l=c.filter(d=>!r.has(d)),u=lE(l,n,s,r);for(let d of l){let p=u.get(d);p!==void 0?r.set(d,{status:"blocked",by:p}):i.push(d)}for(let d of c)s.add(d)}return{outcomes:r,unsettled:i}}function ZNe(e){let t=!1;for(let n of e.values())if(!eG.has(n.status)&&(t=!0,n.status!=="waiting"&&!(n.status==="blocked"&&n.by!==void 0&&e.get(n.by)?.status==="waiting")))return!1;return t}function uE(e){let t=new Map;for(let[n,o]of[...e].sort(M7))t.set(o,[...t.get(o)??[],n]);return[...t].map(([n,o])=>`${o.join(", ")} (blocked by ${n})`).join("; ")}function YNe(e){let t=new Map;for(let o of e)t.set(o.status,(t.get(o.status)??0)+1);if(![...t.keys()].some(o=>!eG.has(o)))return;let n=[`${t.get("applied")??0} applied`,`${t.get("failed")??0} failed`,`${t.get("blocked")??0} blocked`];for(let o of["waiting","refused","decided","not-applied"])t.get(o)&&n.push(`${t.get(o)} ${o==="decided"?"not reported by their share":o}`);return t.get("unchanged")&&n.push(`${t.get("unchanged")} unchanged`),n.join(", ")}function qf(e,t={}){let n=t.group!==void 0?`-group-${t.group.replace(/[^A-Za-z0-9._-]/g,"_")}`:"",o=t.share!==void 0?`-share-${t.share}`:"";return`outcome-wave-${e}${n}${o}.json`}function tG(e,t,n,o,r=new Date().toISOString(),i=!1){let s=L7(e,qf(t,n)),a={version:cE,wave:t,at:r,members:Object.fromEntries(Object.entries(o).sort(M7)),...i?{holds_all:!0}:{}};return VNe(s,JSON.stringify(a,null,2)+`
108
108
  `),s}function F7(e){let t=[],n=(o,r)=>{let i;try{i=HNe(o)}catch{return}for(let s of i){let a=L7(o,s),c=!1;try{c=qNe(a).isDirectory()}catch{continue}c?r<4&&n(a,r+1):/^outcome-wave-\d+.*\.json$/.test(s)&&t.push(a)}};for(let o of e)zNe(o)&&n(o,0);return t.sort()}function nG(e,t){let n=new Map,o=new Map;for(let i of F7(e)){let s;try{s=JSON.parse(j7(i,"utf-8"))}catch{continue}let a=s?.members??s?.roots;if(s?.version!==cE||!Number.isInteger(s.wave)||s.wave>=t||typeof s.at!="string"||typeof a!="object"||a===null)continue;for(let[l,u]of Object.entries(a)){let d=n.get(l);d&&(d.at>s.at||d.at===s.at&&u.status==="decided"&&d.status!=="decided")||n.set(l,{...u,wave:s.wave,at:s.at})}let c=o.get(s.wave);(!c||c.at<=s.at)&&o.set(s.wave,{at:s.at,holdsAll:s.holds_all===!0})}let r=[...o].filter(([,i])=>i.holdsAll).map(([i])=>i).sort((i,s)=>i-s);return{members:n,...r.length?{holdsAll:r[0]}:{}}}function rG(e,t){let n;for(let o of F7(e)){if(KNe(o)!==t)continue;let r;try{r=JSON.parse(j7(o,"utf-8"))}catch{continue}r?.version!==cE||typeof r.at!="string"||typeof r.members!="object"||r.members===null||(!n||n.at<=r.at)&&(n=r)}return n}var cE,eG,M7,Ow=x(()=>{"use strict";cE=1,eG=new Set(["applied","unchanged"]);M7=([e],[t])=>e<t?-1:e>t?1:0});function fE(e){let t=e.step;if(t===void 0)return[];if(t===null||typeof t!="object"||Array.isArray(t))return['`step` must be { "kind": "<capability>", ...input }'];let n=[],o=t.kind;(typeof o!="string"||o.trim()==="")&&n.push('`step.kind` must name a capability, such as "terraform-apply"');for(let r of["plan","apply","planWave","applyWave"])e[r]!==void 0&&n.push(`\`step\` and \`${r}\` are both set; a wave plans and applies through its capability or through commands, so give one`);e.hooks?.apply?.runBy==="apply"&&n.push('`hooks.apply.runBy: "apply"` hands the apply-stage hooks to an apply command, and a `step` has none; leave runBy as chant');for(let r of e.waves){r.discover&&n.push(`wave "${r.name}" discovers its runs, which only \`planWave\` can report; a \`step\` plans the runs the spec lists`),r.hooks?.apply?.runBy==="apply"&&n.push(`wave "${r.name}" hands its apply-stage hooks to an apply command, and a \`step\` has none`);for(let i of r.runs??[]){let s=i.input;s!==void 0&&(s===null||typeof s!="object"||Array.isArray(s))&&n.push(`wave "${r.name}" run "${i.target}": \`input\` must be an object laid over the step's input`),s&&typeof s=="object"&&"kind"in s&&n.push(`wave "${r.name}" run "${i.target}": \`input\` cannot change the step's kind`)}}return n}function W7(e){let t=[];for(let[n,o]of[["parallelism",e.parallelism],...e.waves.map(r=>[`wave "${r.name}" parallelism`,r.parallelism])])o!==void 0&&(typeof o!="number"||!Number.isInteger(o)||o<1?t.push(`${n} is ${JSON.stringify(o)}; give a whole number of 1 or more, the most that run at once`):o>1&&e.step===void 0&&t.push(`${n} is ${o}, and runs apply at once only through \`step\`; drop it or give step`));return t}function Vf(e){if(e===void 0)return[];if(e===null||typeof e!="object"||Array.isArray(e))return['`holds` must be { "policy"?: true, "cost"?: {...} }'];let t=[];for(let[n,o]of Object.entries(e))n==="policy"?typeof o!="boolean"&&t.push("`holds.policy` must be true or false"):n==="cost"?t.push(...QNe(o)):t.push(`\`holds.${n}\` is not a setting; the ones there are holds.policy and holds.cost`);return t}function QNe(e){if(e===null||typeof e!="object"||Array.isArray(e))return['`holds.cost` must be { "command": [...], "approveAbove": <number>, "format"?, "currency"? }'];let t=e,n=[];(!Array.isArray(t.command)||t.command.length===0||!t.command.every(o=>typeof o=="string"&&o!==""))&&n.push("`holds.cost.command` must be argv, a non-empty list of strings"),(typeof t.approveAbove!="number"||!Number.isFinite(t.approveAbove)||t.approveAbove<0)&&n.push("`holds.cost.approveAbove` must be a monthly amount of 0 or more"),t.format!==void 0&&!dE.includes(t.format)&&n.push(`\`holds.cost.format\` must be ${dE.join(" or ")}`),t.currency!==void 0&&(typeof t.currency!="string"||!/^[A-Z]{3}$/.test(t.currency))&&n.push('`holds.cost.currency` must be a three-letter currency code, such as "USD"');for(let o of Object.keys(t))["command","approveAbove","format","currency"].includes(o)||n.push(`\`holds.cost.${o}\` is not a setting`);return n}function mE(e,t){let n=e?.policy===!0||t?.policy===!0,o=e!==void 0?e.cost:t?.cost;if(!(!n&&!o))return{...n?{policy:!0}:{},...o?{cost:o}:{}}}var dE,pE,gE=x(()=>{"use strict";dE=["infracost","chant"],pE="(monthly cost)"});function oG(e){let t=[],n=(o,r,i)=>{if(o!==void 0&&!(o===!1&&i)){if(o===null||typeof o!="object"||Array.isArray(o)){t.push(`${r} must be { "env"?: "<env>", "component"?: "<name>" }${i?" or false":""}`);return}for(let[s,a]of Object.entries(o))s!=="env"&&s!=="component"?t.push(`${r} has an unknown key "${s}"; it takes env and component`):(typeof a!="string"||a.trim()==="")&&t.push(`${r}.${s} must be a non-empty string`)}};n(e.release,"`release`",!0);for(let o of e.waves)for(let r of o.runs??[])n(r.release,`wave "${o.name}" run "${r.target}": \`release\``,!1);return t}function B7(e,t){return e.replaceAll("{target}",t.target).replaceAll("{op}",t.op).replaceAll("{wave}",t.wave)}function iG(e,t,n){if(!e.step||e.release===!1)return null;let o={target:n.target,op:n.op??e.op,wave:t.name},r=e.release??{},i=n.release?.env??r.env,s=n.release?.component??r.component;return{env:i!==void 0?B7(i,o):e.labels?.Env??t.name,component:s!==void 0?B7(s,o):n.target}}function sG(e,t,n,o){let r=new Map;for(let a of t){let c=r.get(a.releaseDigest);(c===void 0||a.timestamp>c)&&r.set(a.releaseDigest,a.timestamp)}let s=e.filter(a=>a.commit===n.commit).map(a=>({r:a,digest:o(a,n.env,n.component)})).filter(a=>a.digest!==null).sort((a,c)=>(r.get(c.r.releaseDigest)??"").localeCompare(r.get(a.r.releaseDigest)??"")||a.r.releaseDigest.localeCompare(c.r.releaseDigest))[0];return s?{releaseDigest:s.r.releaseDigest,templatesDigest:s.digest}:null}var Pw=x(()=>{"use strict"});function Tw(e){let n=e.replace(/^https?:\/\//,"").replace(/\.git$/,"").replace(/\/+$/,"").split("/");if(n.length<3||n.some(i=>i===""))throw new Cw(`project key "${e}" must be <host>/<owner>/<name>, such as github.com/acme/infra`);let[o,...r]=n;return{key:e,host:o,path:r.join("/"),owner:r.slice(0,-1).join("/"),name:r[r.length-1]}}function q7(e){let t=e.toLowerCase().replace(/:\d+$/,"");if(t==="github.com"||t.startsWith("github."))return"github";if(t==="gitlab.com"||t.startsWith("gitlab.")||t.includes(".gitlab."))return"gitlab";if(t==="codeberg.org"||t.startsWith("forgejo.")||t.startsWith("gitea.")||t.includes("forgejo"))return"forgejo"}function tje(e,t){let n=t.toLowerCase();return e==="github"?n==="github.com"?"https://api.github.com":`https://${t}/api/v3`:e==="gitlab"?`https://${t}/api/v4`:`https://${t}/api/v1`}function uG(e,t="control"){if(typeof e!="object"||e===null||Array.isArray(e))return[`${t} must be a mapping with repo and op`];let n=e,o=[],r;if(typeof n.repo!="string")o.push(`${t}.repo must name the control repo, such as github.com/acme/control`);else try{r=Tw(n.repo).host}catch(i){o.push(`${t}.repo: ${i.message}`)}return typeof n.op=="string"&&Aw.test(n.op)||o.push(`${t}.op must name the Op the control repo runs on this repo's dependents, such as deploy`),n.forge!==void 0&&!z7.includes(n.forge)&&o.push(`${t}.forge must be one of ${z7.join(", ")}`),r!==void 0&&n.forge===void 0&&!q7(r)&&o.push(`${t}.forge is needed: ${n.repo}'s host does not say which forge it is`),n.member!==void 0&&!(typeof n.member=="string"&&Aw.test(n.member))&&o.push(`${t}.member must be this repo's name in the control repo's workspace`),n.tokenSecret!==void 0&&!(typeof n.tokenSecret=="string"&&U7.test(n.tokenSecret))&&o.push(`${t}.tokenSecret must name the secret holding the dispatch token, such as ${aG}`),n.readTokenSecret!==void 0&&!(typeof n.readTokenSecret=="string"&&U7.test(n.readTokenSecret))?o.push(`${t}.readTokenSecret must name the secret holding a read-only token for the control repo, such as ${H7}`):typeof n.readTokenSecret=="string"&&n.readTokenSecret===(n.tokenSecret??aG)&&o.push(`${t}.readTokenSecret must not be the dispatch token's secret (${n.readTokenSecret}): the plan job runs the change's code`),n.ref!==void 0&&!(typeof n.ref=="string"&&XNe.test(n.ref))&&o.push(`${t}.ref must be a branch name`),n.apiBase!==void 0&&!(typeof n.apiBase=="string"&&/^https?:\/\/[^\s'"]+$/.test(n.apiBase))&&o.push(`${t}.apiBase must be an http(s) URL`),o}function V7(e,t){let n=uG(e);if(n.length>0)throw new Cw(n.join("; "),n);let o=Tw(e.repo),r=e.forge??q7(o.host),i=e.member??t;if(!Aw.test(i))throw new Cw(`control.member: "${i}" is not a name the control repo's workspace can hold; set control.member`);return{repo:e.repo,host:o.host,path:o.path,forge:r,apiBase:(e.apiBase??tje(r,o.host)).replace(/\/+$/,""),op:e.op,member:i,ref:e.ref??eje,tokenSecret:e.tokenSecret??aG,readTokenSecret:e.readTokenSecret??H7}}var Aw,XNe,U7,aG,H7,cG,_w,lG,eje,Cw,z7,K7,Iw=x(()=>{"use strict";ri();Aw=/^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/,XNe=/^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/,U7=/^[A-Za-z_][A-Za-z0-9_]{0,127}$/,aG="CHANT_CONTROL_TOKEN",H7="CHANT_CONTROL_READ_TOKEN",cG="CHANT_CONTROL_OUTCOME",_w=["applied","partial","unchanged","waiting","failed"],lG=["applied","partial"],eje="main",Cw=class extends Error{constructor(n,o=[n]){super(n);this.problems=o;this.name="ControlConfigError"}};z7=["github","gitlab","forgejo"];K7="control-dispatch"});var ree={};Re(ree,{CHECK_HOOK_MOMENT:()=>nje,CI_CHECK_HOOK_FLOOR:()=>rje,GATE_APPROVAL_SOURCES:()=>Na,OP_LEDGER_NAME:()=>Qf,OP_WAVES_APPROVAL_STATUS_VAR:()=>pje,OP_WAVES_CONTROL_FLOOR:()=>oje,OP_WAVES_CONTROL_JOB:()=>ije,OP_WAVES_DIGEST_OVER:()=>Q7,OP_WAVE_APPLY_HOOKS_RUNNERS:()=>hE,OP_WAVE_DEFAULT_APPLY:()=>bE,OP_WAVE_DEFAULT_GATE_NAME:()=>fG,OP_WAVE_GATE_POLICIES:()=>Zf,OP_WAVE_HOOK_FAILURES:()=>Yf,OP_WAVE_HOOK_MOMENTS:()=>Nw,OP_WAVE_JOB_TIMEOUT_MINUTES:()=>Y7,PR_LOOP_HOOK_MOMENTS:()=>eee,assertCheckHooks:()=>tee,assertOpWaveCloud:()=>mG,assertOpWaveHooks:()=>ja,assertOpWavesSpec:()=>Xu,assertPrLoopHooks:()=>$E,notifyVariables:()=>n8,opWaveApplyHooksRunBy:()=>Mw,opWaveBinArgv:()=>Xf,opWaveGateName:()=>jw,opWaveGroupOf:()=>bje,opWaveGroupRuns:()=>RE,opWaveGroupsProblem:()=>xE,opWaveHookRuns:()=>tm,opWaveHooksAt:()=>Lw,opWaveJobTimeout:()=>lje,opWaveJobs:()=>nee,opWaveOf:()=>vje,opWaveOutcomeDir:()=>vE,opWaveOutcomePath:()=>Kf,opWavePointAt:()=>yE,opWavePointOf:()=>J7,opWavePointProblems:()=>Dw,opWaveRecordPath:()=>em,opWaveRunMatches:()=>kE,opWaveShare:()=>Fw,opWavesApprovalStatusCommand:()=>mje,opWavesControlProblems:()=>Z7,opWavesControlTarget:()=>sje,opWavesInvolvedProblems:()=>wE,opWavesLastJobs:()=>cje,opWavesOutcomeCommand:()=>aje,opWavesPostsApprovalStatus:()=>fje,opWavesRecordPlansCommand:()=>dje,opWavesResumeCommand:()=>uje,waveApproveTarget:()=>Qu});function J7(e){if(e!==void 0)return typeof e=="string"?{name:e}:e}function Dw(e){if(e!==null&&typeof e=="object"&&!Array.isArray(e)&&"timeout"in e){let{timeout:t,...n}=e,o=Zu(n);return(typeof t!="string"||!/^(\d+(ms|s|m|h|d))+$/.test(t))&&o.push('`point.timeout` is a duration such as "48h"'),o}return Zu(e)}function yE(e,t){let n=e.waves.find(o=>o.name===t);return J7(n?.point??e.point)}function Qu(e,t){return t.length===1?t[0]:e}function Z7(e){let t=uG(e,"control");if(t.length>0)return t;let n=e,o=[];typeof n.member=="string"&&Aw.test(n.member)||o.push("control.member must name this repo in the control repo's workspace: an Op waves spec has no repository name to default it to");for(let r of["sentCheck","markSent"])n[r]!==void 0&&!(typeof n[r]=="string"&&n[r]!==""&&!n[r].includes(`
@@ -491,7 +491,7 @@ ${r}${r.endsWith(`
491
491
  `);let E=await i(`
492
492
  Approve this plan for ${h}, ${m}? Type ${h} to approve: `);if(E===null||E.trim()!==h)return r(`Not approved: the answer was not ${h}.
493
493
  `),{status:"refused",code:We.declined};if(n.plan===void 0){let O;try{O=gxe((await l(e)).pending,t,n.environment,u)}catch{return{status:"confirmed",plan:m,target:h}}if(O?.planDigest===void 0||!p(O.planDigest,m))return r(`Not approved: the plan moved while you were asked (now ${O?.planDigest??"no pending plan"}); run chant approve ${e} ${t} again.
494
- `),{status:"refused",code:We.moved}}return{status:"confirmed",plan:m,target:h}}var bxe=x(()=>{"use strict";Ui()});import{readFileSync as vxe}from"node:fs";import{resolve as Wrt}from"node:path";async function kxe(e){let{pushed:t,pushWarning:n}=await Ma().catch(o=>{if(o instanceof Fo)return{pushed:!1,pushWarning:o.message};throw o});return t?{pushed:t,suffix:""}:nd(n)?{pushed:t,suffix:` (${td})`}:(console.error(ur({message:`The push to the remote did not land: ${n??"no reason given"}`,hint:e})),{pushed:t,suffix:" (local only \u2014 the push did not land)"})}async function Rxe(e){let t=e.args.path,n=e.args.extraPositional;if(!t||t==="."||!n)return console.error($e({message:"Usage: chant approve <op> <gate>"})),1;if(e.args.expire){try{await Hr()}catch(l){return console.error($e({message:`Cannot expire the gate: ${l instanceof Error?l.message:String(l)}`})),1}let s=new Date().toISOString(),a=Nn((await yr(t)).pending,n);if(!a||Vn(a,s))return console.error(ur({message:`Gate "${n}" on "${t}" has no standing pending fact \u2014 nothing to expire`})),0;await bm({op:t,gate:n,timestamp:s,expiresAt:s,...a.description?{description:a.description}:{},...a.runId?{runId:a.runId}:{},...a.gitSha?{gitSha:a.gitSha}:{}});let c=await kxe(`The expiry is recorded locally on ${NR}. Until it reaches the remote, a run in another checkout still sees the old pending fact.`);return console.error(Rh(`Gate "${n}" on "${t}" expired at ${s} \u2014 not approved`+c.suffix)),console.error(In(t===mm?"The next `chant components fan-out` decides this gate from scratch and records a fresh pending fact.":rA.test(t)?"The next `chant components pr-apply` decides this gate from scratch and records a fresh pending fact.":t===tb?`The next \`chant workspace promote ${n}\` decides this gate from scratch and records a fresh pending fact.`:t===gm?`The next \`chant workspace upgrade ${n}\` decides this gate from scratch and records a fresh pending fact.`:t===hm?"The next `chant workspace exit` decides this gate from scratch and records a fresh pending fact.":t===bi?"The next `chant components promote --release` decides this gate from scratch and records a fresh pending fact.":`The next \`chant run ${t}\` decides this gate from scratch and records a fresh pending fact.`)),0}if(t===ul){let{runOverrideApprove:s}=await Promise.resolve().then(()=>(uxe(),lxe));return s(e)}if(e.args.rules!==void 0||e.args.reason!==void 0)return console.error($e({message:`--rule and --reason override a denied plan: chant approve ${ul} <subject> --rule <id> --reason <text>`,hint:`To approve gate "${n}" on "${t}", put any prose in --note.`})),1;if(e.args.statement){if(e.args.sign!==void 0||e.args.signature!==void 0)return console.error($e({message:"--statement prints what to sign and records nothing, so it takes neither --sign nor --signature"})),1;let s={actor:e.args.approver??e.args.actor,...e.args.plan!==void 0?{plan:e.args.plan}:{},...e.args.env!==void 0?{environment:e.args.env}:{},...e.args.relayedBy!==void 0?{relayedBy:e.args.relayedBy}:{},...e.args.at!==void 0?{at:e.args.at}:{},...e.args.binding!==void 0?{binding:e.args.binding}:{},allowSameOrigin:e.args.allowSameOrigin},a=await Urt(t,n,s);return a?(console.log(JSON.stringify(a,null,2)),console.error(In(`Have ${a.resolvedBy} sign these bytes (an ssh key in the ${a.namespace} namespace, or a passkey with challenge ${a.challenge}), then record it: chant approve ${t} ${n} --actor ${a.resolvedBy}`+(a.relayedBy!==null?` --relayed-by ${a.relayedBy}`:"")+(a.planDigest!==null?` --plan ${a.planDigest}`:"")+(a.environment!==null?` --env ${a.environment}`:"")+(a.binding!==null?` --binding ${qrt(a.binding)}`:"")+` --at ${a.timestamp} --signature <file>`)),0):1}let o=e.args.plan,r=await Promise.resolve().then(()=>(bxe(),wxe));if(e.args.signature===void 0&&await r.interactiveApproval(e.args)){let s=await r.confirmApproval(t,n,{...o!==void 0?{plan:o}:{},...e.args.env!==void 0?{environment:e.args.env}:{}});if(s.status==="refused")return s.code;s.status==="confirmed"&&(o=s.plan)}let i=await T6(t,n,{actor:e.args.approver??e.args.actor,note:e.args.note,url:e.args.url,plan:o,...e.args.env!==void 0?{environment:e.args.env}:{},allowSameOrigin:e.args.allowSameOrigin,...e.args.roles?{roles:e.args.roles}:{},...e.args.agent?{agent:!0}:{},...e.args.sign!==void 0?{sign:e.args.sign}:{},...e.args.signature!==void 0?{signature:e.args.signature}:{},...e.args.at!==void 0?{at:e.args.at}:{},...e.args.binding!==void 0?{binding:e.args.binding}:{},...e.args.relayedBy!==void 0?{relayedBy:e.args.relayedBy}:{}});if(!i.ok)return 1;if(e.args.resumeRun||e.args.resume!==void 0){let{resumeAfterApproval:s}=await Promise.resolve().then(()=>(i0(),e6));return s(t,n,i.record.environment,i.pushed)}return console.error(In("This records the resolution as a fact; it does not itself re-run anything. "+(t===mm?`Repeat the \`chant components fan-out\` command and it walks through gate "${n}".`:rA.test(t)?`The pull request's apply (\`chant components pr-apply\`) walks through gate "${n}" when it plans this same digest.`:t===tb?`Repeat \`chant workspace promote ${n}\`, and it applies the patch this approval names.`:t===gm?`Repeat \`chant workspace upgrade ${n}\` with the same target, and it applies the patch this approval names.`:t===hm?"Repeat `chant workspace exit` with the same members, and it applies the patch this approval names.":t===bi?`Repeat the same \`chant components promote --release\`, and it walks through gate "${n}" when it plans this same change set for this release.`:`Run \`chant run ${t}\` and it walks through gate "${n}".`))),0}async function Brt(e,t,n,o){let{readRelease:r,readCuts:i,labelsByDigest:s}=await Promise.resolve().then(()=>(Ka(),Jm)),{readRevokedCommits:a,revocationOf:c,revokedRefusal:l}=await Promise.resolve().then(()=>(I_(),UK)),u=await r(n,{cwd:o}).catch(()=>null);if(!u)return console.error($e({message:`Gate "${t}" on "${e}" binds release ${n}, which can't be read from ${NR}, so whether it is revoked is unknown [release-unreadable]`,hint:`Fetch the ledger branch (git fetch origin ${NR}:${NR}) and approve again from the member's directory.`})),!0;let d;try{d=await a(o)}catch(m){return console.error($e({message:`Gate "${t}" on "${e}" binds release ${n}, and the ci tags can't be judged: ${m instanceof Error?m.message:String(m)} [declaration-invalid]`,hint:"Fix ci.green in chant.workspace.json at base; chant workspace check names the problem."})),!0}let p=c(u,d);if(!p)return!1;let f=s((await i({cwd:o}).catch(()=>({cuts:[]}))).cuts).get(n)??null;return console.error($e(l({releaseDigest:n,label:f},p,`Clear the pending gate with \`chant approve ${e} ${t} --expire\`, then promote a release cut from a green commit: \`chant ci last-green\` names the newest, and \`chant release list\` marks the revoked releases.`))),!0}async function T6(e,t,n){let o=await xxe(e,t,n,!1);return"statement"in o?{ok:!1}:o}async function Urt(e,t,n){let o=await xxe(e,t,n,!0);return"statement"in o?o.statement:null}async function xxe(e,t,n,o){if(!o&&Ar())return console.error($e({message:`Cannot record the approval of "${t}": ${gi} is set, so nothing is written to chant/lifecycle`,hint:`Unset ${gi} to approve the gate.`})),{ok:!1};let{ops:r}=await Fl(),i=vhe([...r.values()].map(W=>W.config),e,t);!i&&!r.has(e)&&e!==mm&&e!==gm&&e!==hm&&e!==tb&&e!==ul&&e!==bi&&console.error(ur({message:`Op "${e}" was not found among discovered *.op.ts declarations \u2014 recording the resolution anyway`}));try{await Hr()}catch(W){return console.error($e({message:`Cannot record the approval: ${W instanceof Error?W.message:String(W)}`,hint:"The pending fact this answers lives on that branch; appending without it would drop it."})),{ok:!1}}if(i){let W=Nn((await yr(i.op)).pending,i.gate);if(W&&!Vn(W,new Date().toISOString()))return console.error($e({message:`Gate "${t}" on "${e}" is now gate "${i.gate}" on "${i.op}", which lists it as an alias, and "${i.gate}" has a standing pending fact`,hint:`Approve that gate instead: chant approve ${i.op} ${i.gate}`})),{ok:!1};console.error(In(`Gate "${t}" on "${e}" is an alias of gate "${i.gate}" on "${i.op}": the next run of ${i.op} counts this approval there while the pending fact it answers stands and the plan is the same.`))}let s=n.url??pl();if(s&&!JE(s))return console.error($e({message:`--url must be an absolute http/https URL (got "${s}")`,hint:"Pass the PR/MR link, or omit --url and put prose in --note."})),{ok:!1};let a=await yr(e),c=W=>W.some(q=>q.gate===t&&q.environment!==void 0)&&n.environment!==void 0?W.filter(q=>q.environment===n.environment):W,l=Nn(c(a.pending),t),u=l?.environment,d;if(n.plan!==void 0){if(!tS(n.plan))return console.error($e({message:`--plan must be a plan digest ("jcs1-sha256:" or "sha256:", then 64 hex characters), got "${n.plan}"`,hint:"Copy it from the gated run's `plan :` line, or from the pending-gate summary. It is not a plan file path."})),{ok:!1};d=n.plan}else{if(!l)return console.error($e({message:n.environment!==void 0&&a.pending.some(W=>W.gate===t&&W.environment!==void 0)?`Gate "${t}" on "${e}" has no pending fact in environment "${n.environment}", so there is no plan to approve`:`Gate "${t}" on "${e}" has no pending fact, so there is no plan to approve`,hint:`Run \`chant run ${e}\` first \u2014 it plans, stops at the gate, and records the plan this approval would be for. To approve a plan you already have the digest for, pass \`--plan <digest>\`.`})),{ok:!1};d=l.planDigest}let p=l?.checkpointDigest!==void 0&&Xe(d,l.planDigest)?l.checkpointDigest:void 0,f=l?.releaseDigest!==void 0&&Xe(d,l.planDigest)?l.releaseDigest:void 0,m=l?.changeSet!==void 0&&Xe(d,l.planDigest)?l.changeSet:void 0;if(l?.releaseDigest!==void 0&&await Brt(e,t,l.releaseDigest,n.cwd??process.cwd()))return{ok:!1};let g=n.origin??Ns(),h=await yr(e),w=Nn(c(h.pending),t);if(bo(g)&&(w?.neverOverMcp||r.get(e)?.config.neverOverMcp))return console.error($e({message:`Gate "${t}" on "${e}" is never resolved over ${g==="acp"?"ACP":"MCP"}`,hint:`Approvals belong to people: \`chant approve ${e} ${t}\` at a shell.`})),{ok:!1};if(w?.answer)return console.error($e({message:`Gate "${t}" on "${e}" asks decision point ${w.answer.point}, so its answer passes the gate, not an approval`,hint:`Answer the question: \`chant workspace points answer ${w.answer.id} --answer <value> --by <name>\`, then run \`chant run ${e}\` again.`})),{ok:!1};let k=UG(w?.origin,g);if(k&&!n.allowSameOrigin)return console.error($e({message:`Gate "${t}" on "${e}" cannot be resolved from here: ${k}`,hint:`Approve it from a channel the run did not come from \u2014 \`chant approve ${e} ${t}\` at a shell is the usual one. If resolving from the same channel genuinely is the intent, pass --allow-same-origin, which records that it was deliberate.`})),{ok:!1};let v=n.relayedBy?.trim();if(n.relayedBy!==void 0&&(!v||/[\r\n]/.test(v)))return console.error($e({message:`--relayed-by needs one principal on one line (got ${JSON.stringify(n.relayedBy)})`,hint:"Name who relayed the approval, such as --relayed-by github:<login> or a principal the signers file lists."})),{ok:!1};let b=n.actor??(bo(g)?rb:process.env.GITHUB_ACTOR??process.env.GITLAB_USER_LOGIN??process.env.USER??"unknown"),$={kind:n.agent||bo(g)?"agent":"human",...n.roles&&n.roles.length>0?{roles:[...new Set(n.roles)]}:{}},E=n.cwd??process.cwd(),O=await Promise.resolve().then(()=>(kd(),DW)),{scopeSource:P}=await Promise.resolve().then(()=>(Ro(),Eb)),I=P(E);try{O.refuseUnidentified(I,[b],n.actor!==void 0?"--actor":"the approver"),v&&O.refuseUnidentified(I,[v],"--relayed-by")}catch(W){if(!(W instanceof O.IdentityError))throw W;return console.error($e({message:`Gate "${t}" on "${e}" was not approved: ${W.message}`,hint:"Pass --actor <forge identity or signer>, as the surface that signed the person in maps them, for example --actor github:<login>."})),{ok:!1}}let S=(W,K)=>(console.error($e({message:`Gate "${t}" on "${e}" was not approved: ${W}`,...K?{hint:K}:{}})),{ok:!1});if(n.signature!==void 0&&n.sign!==void 0)return S("--sign signs here and --signature brings a signature made elsewhere; pass one of them");if(n.at!==void 0&&!o&&n.signature===void 0)return S("--at sets the time of a statement signed elsewhere, so it goes with --statement or --signature");if(n.signature!==void 0&&n.at===void 0)return S("--signature needs --at <timestamp>, the statement's time, since the signature covers it",`Pass the timestamp \`chant approve ${e} ${t} --statement\` printed.`);if(n.binding!==void 0){if(!o&&n.signature===void 0&&n.sign===void 0)return S("--binding is a line the approver's signature covers, so it goes with --statement, --signature or --sign");let W=nxe(n.binding);if(W!==null)return S(`--binding takes one line of printable text, and ${W}`)}let T=new Date().toISOString();if(n.at!==void 0){let W=Date.parse(n.at);if(!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(n.at)||Number.isNaN(W)||new Date(W).toISOString()!==n.at)return S(`--at takes a UTC time as chant writes one, such as ${T}, not ${JSON.stringify(n.at)}`);if(W>Date.now()+zrt)return S(`--at ${n.at} is in the future`);if(l&&n.at<l.timestamp)return S(`--at ${n.at} is before the pending fact it answers (${l.timestamp}), and a run counts only approvals newer than that`,`Take a fresh statement: chant approve ${e} ${t} --statement.`);T=n.at}let F={op:e,gate:t,...u!==void 0?{environment:u}:{},...d!==void 0?{planDigest:d}:{},resolvedBy:b,...v?{relayedBy:v}:{},timestamp:T,...p!==void 0?{checkpointDigest:p}:{},...n.binding!==void 0?{binding:n.binding}:{}};if(o){let{CHANT_VERSION:W}=await Promise.resolve().then(()=>(MO(),Ire));return{statement:rxe(F,W)}}let L=O.gateAdmissionFrom(I,t);if(L&&n.sign===void 0&&n.signature===void 0)return console.error($e({message:`Gate "${t}" needs a signed approval: chant.workspace.json at base names it in identity.gates`+(L.requirement.class!==null?`, from the class ${L.requirement.class}`:"")+", and this approval is not signed",hint:`chant approve ${e} ${t} --actor <principal> --sign [<key file>], with a key ${I.policy.signersPath} at base lists for that principal, or --signature <file> --at <timestamp> with a signature made elsewhere over the statement --statement prints.`})),{ok:!1};let C;if(n.signature!==void 0){let W=Hrt(n.signature,F,I.policy,E);if("refused"in W)return S(W.refused);C=W.seal}if(n.sign!==void 0){let{resolveSigningKey:W,sealGateApproval:K,gateSealVersion:q,SealError:ee}=await Promise.resolve().then(()=>($g(),xg));try{let X=W(n.sign,E);try{let Ce=q(F);C={...K(X.file,F),...Ce!==1?{version:Ce}:{}}}finally{X.cleanup()}}catch(X){if(!(X instanceof ee))throw X;return console.error($e({message:`Gate "${t}" on "${e}" was not approved: ${X.message}`})),{ok:!1}}}if(L){let W=L.refuses({op:e,gate:t,...u!==void 0?{environment:u}:{},...d!==void 0?{planDigest:d}:{},resolvedBy:b,...v?{relayedBy:v}:{},timestamp:T,...p!==void 0?{checkpointDigest:p}:{},...n.binding!==void 0?{binding:n.binding}:{},seal:C});if(W!==null)return console.error($e({message:`Gate "${t}" on "${e}" was not approved: ${W}`,hint:`identity.gates.${t} in chant.workspace.json at base counts only an approval signed by a key ${I.policy.signersPath} lists for the approver`+(L.requirement.class!==null?`, who holds the role of the class ${L.requirement.class}`:"")+"."})),{ok:!1}}let _=w?.approval,M=pi({signers:I.policy,roles:I.policy.roles}),J=M({version:1,op:e,gate:t,...u!==void 0?{environment:u}:{},...d!==void 0?{planDigest:d}:{},resolvedBy:b,...v?{relayedBy:v}:{},timestamp:T,...p!==void 0?{checkpointDigest:p}:{},...n.binding!==void 0?{binding:n.binding}:{},...C?{seal:C}:{}}).roles,Y;if(_?.policy)try{let K=await(n.evaluator??await gG(_.policy.lexicon)).evaluateGatePolicy(_.policy,hG({op:e,gate:t,resolvedBy:b,approver:$,roles:J,...d!==void 0?{planDigest:d}:{},..._.context?{context:_.context}:{}}));Y={policy:_.policy.name,version:_.policy.version,mode:_.mode,contextDigest:zw(_.context),decision:K.decision,determining:K.determining,errors:K.errors}}catch(W){return console.error($e({message:`Gate "${t}" on "${e}" declares policy "${_.policy.name}", which could not be evaluated: ${W instanceof Error?W.message:String(W)}`,hint:`Install the ${_.policy.lexicon} lexicon in this project, or approve from a checkout that has it.`})),{ok:!1}}let{record:N}=await ib({op:e,gate:t,resolvedBy:b,...v?{relayedBy:v}:{},timestamp:T,...C?{seal:C}:{},approver:$,...Y?{policyDecision:Y}:{},...n.note?{note:n.note}:{},...s?{url:s}:{},...d!==void 0?{planDigest:d}:{},...p!==void 0?{checkpointDigest:p}:{},...n.binding!==void 0?{binding:n.binding}:{},...u!==void 0?{environment:u}:{},...f!==void 0?{releaseDigest:f}:{},...m!==void 0?{changeSet:m}:{},...l?.gitSha?{gitSha:l.gitSha}:{},...l?.runId?{runId:l.runId}:{},origin:g,...k&&n.allowSameOrigin?{sameOriginOverride:!0}:{}}),z=await kxe(`The resolution is recorded locally on ${NR}. Until it reaches the remote, a run in another checkout will not see it.`);console.error(Rh(`Gate "${t}" on "${e}" resolved by ${N.resolvedBy}`+(N.relayedBy?`, relayed by ${N.relayedBy},`:"")+` at ${N.timestamp}`+(N.url?` (${N.url})`:"")+(N.seal?`, signed with ${N.seal.kind===Es?"passkey ":""}${N.seal.key}`:"")+z.suffix)),N.binding!==void 0&&console.error(In(`The signature also binds ${JSON.stringify(N.binding)} (--binding).`)),N.planDigest&&console.error(In(`This approves the plan ${N.planDigest}`+(N.environment!==void 0?` in environment "${N.environment}"`:"")+(N.releaseDigest!==void 0?` for release ${N.releaseDigest}`:"")+", and only that plan. A run whose fresh plan differs refuses rather than applying it.")),N.checkpointDigest&&console.error(In(`The next run resumes at this gate from run ${l?.runId??"(unknown)"}'s checkpoint ${N.checkpointDigest}, after it plans again. A moved plan or another commit starts it at the first phase.`));let H=($.roles??[]).filter(W=>!J.includes(W));if(H.length>0&&console.error(In(`--role ${H.join(", ")} is recorded on the approval and trusted by nothing: a gate's quorum and policy read ${N.resolvedBy}'s roles from .chant/trust.json at base, and only for an approval sealed by a signer listed at base (chant approve --sign).`)),_)for(let W of Vrt(_,N,h.resolutions,w,h.pending,M))console.error(In(W));return{ok:!0,record:N,pushed:z.pushed}}function Hrt(e,t,n,o){let r;try{r=e==="-"?vxe(0,"utf-8"):vxe(Wrt(o,e),"utf-8")}catch(l){return{refused:`--signature ${e} can't be read: ${l instanceof Error?l.message:String(l)}`}}let i=oxe(r);if("problem"in i)return{refused:`--signature ${e}: ${i.problem}`};let s=i.kind==="ssh"?{signer:t.resolvedBy,key:"",signature:i.signature}:{kind:Es,signer:t.resolvedBy,key:i.assertion.id,signature:i.assertion.signature,clientDataJSON:i.assertion.clientDataJSON,authenticatorData:i.assertion.authenticatorData},a=Os(n,t.resolvedBy,s,Wr(t));if(!a.ok)return{refused:a.unlisted?`${t.resolvedBy} has no ${i.kind==="ssh"?`key in ${n.signersPath}`:"passkey in .chant/trust.json"} at base, so a signature made elsewhere can't be checked`:`the ${i.kind==="ssh"?"ssh signature":"passkey's assertion"} does not verify for ${t.resolvedBy} over this approval's statement: ${a.reason}`};let c=Jc(t);return{seal:{...s,key:a.key,...c!==1?{version:c}:{}}}}function qrt(e){return/^[\w@%+=:,./-]+$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}function Vrt(e,t,n,o,r=o?[o]:[],i=Ia){let s=[],a=t.policyDecision;if(a){let p=a.determining.length>0?` (${a.determining.join(", ")})`:"",f=e.mode==="enforce"?a.decision==="allow"?"In enforce mode this permit passes the gate on its own.":"In enforce mode only a permit passes the gate on its own, so this approval counts only toward the quorum.":"The gate is in log-only mode, so the decision is recorded and does not change the outcome.";s.push(`Policy "${a.policy}" ${a.version}: ${a.decision}${p}. ${f}`);for(let m of a.errors)s.push(`Policy evaluation error: ${m}`)}let c=o?.timestamp??new Date(0).toISOString(),l=o&&Xe(o.planDigest,t.planDigest)?Sl(r,o):c,u=$l([...n,t],t.gate,c,t.planDigest,e,l,i),d=u.counted.map(p=>p.resolvedBy).join(", ")||"none yet";if(Array.isArray(e.quorum))for(let p of u.rules??[])s.push(`Quorum: ${al(p)}.`);else{let p=ui(e.quorum)[0],f=p?.roles?` with role ${p.roles.join(" or ")}`:"";s.push(`Quorum: ${u.counted.length} of ${u.need} human approval(s)${f} for this plan (${d}).`)}if(!u.counted.includes(t)){let p=ui(e.quorum).flatMap(f=>f.roles??[]);s.push(zm(t).kind==="agent"?"An agent's approval does not count toward the quorum.":i(t).proven?`This approval does not count toward the quorum: .chant/trust.json at base gives ${t.resolvedBy} none of its roles (${[...new Set(p)].join(", ")}).`:"This approval does not count toward the quorum: its roles are read from .chant/trust.json at base, and only for an approval sealed by a signer listed at base (chant approve --sign).")}return s}var NR,zrt,I6=x(()=>{"use strict";Zs();YC();dl();Cr();Ft();nm();Jr();Mo();qr();oA();lt();sm();Ds();Hi();ixe();Qn();NR="chant/lifecycle";zrt=300*1e3});_0();var D6=new Set(["--help","--open","--version","--agents","--agent","--all-projects","--all","--force","--fix","--watch","--verbose","--live","--overlay","--explain","--owned","--verbatim","--skip-undeclarable","--apply-rewrites","--write","--strict","--validate","--use-composites","--composites","--stacks","--components","--pr-build","--pr-env","--up","--down","--include-dependents","--cross-root","--local","--json","--progress-json","--events-json","--follow","--update-snapshot","--update-baseline","--run-examples","--check","--bump","--no-release-record","--deploy-unchanged","--no-record","--fold","--no-fold","--no-cache","--sandbox","--yes","--confirm-prod","--once","--rerun-failed","--setup-key","--trust","--unsigned","--in-place","--require-runner-start","--require-clouds","--no-push","--list","--no-require-review","--expire","--check-live","--stream","--check-snapshot","--fail-on-drift","--durable-requests","--skip-mcp","--read-only","--mcp-read-only","--propose","--current","--uncommitted","--allow-code","--allow-skip","--allow-unsigned","--override-green","--require-provenance","--root-only","--generated","--decide","--record-plans","--approval-status","--waves-outcome","--loopback","--artifacts","--push","--only"]);function N6(e){e=e.slice();let t={command:"",path:".",extraPositional:void 0,extraPositional2:void 0,output:void 0,format:"",force:void 0,fix:!1,lexicon:void 0,template:void 0,watch:!1,verbose:!1,help:!1,param:void 0,paramsFile:void 0,report:void 0,local:void 0,profile:void 0,json:void 0,live:!1,migrateFrom:void 0,migrateTo:void 0,emit:void 0,strict:!1,validate:!1,useComposites:!1,reportFile:void 0,skill:void 0,skipMcp:void 0,readOnly:void 0,mcpReadOnly:void 0,propose:void 0,src:void 0,env:void 0},n=e.indexOf("--");e=n<0?C0(e,D6):[...C0(e.slice(0,n),D6),...e.slice(n)];let o=!1,r=s=>{t.command&&(t.positionals??=[]).push(s),t.command?t.path==="."?t.path=s:t.extraPositional?t.extraPositional2=s:t.extraPositional=s:t.command=s},i=0;for(;i<e.length;){let s=e[i];if(o)r(s);else if(s==="--")o=!0;else if(s==="--help"||s==="-h")t.help=!0;else if(s==="--version"||s==="-V")t.version=!0;else if(s==="--output"||s==="-o")t.output=e[++i];else if(s==="--format"||s==="-f")t.format=e[++i];else if(s==="--lexicon"||s==="-d")t.lexicon=e[++i];else if(s==="--template"||s==="-t")t.template=e[++i];else if(s==="--force")t.force=!0;else if(s==="--fix")t.fix=!0;else if(s==="--watch"||s==="-w")t.watch=!0;else if(s==="--verbose"||s==="-v")t.verbose=!0;else if(s==="--profile"||s==="-p")t.profile=e[++i];else if(s==="--report"){let a=e[i+1];a&&!a.startsWith("-")?(t.reportFile=a,i++):t.report=!0}else if(s==="--live")t.live=!0;else if(s==="--overlay")t.overlay=!0;else if(s==="--between"){if(t.betweenA=e[++i],t.betweenB=e[++i],!t.betweenA||!t.betweenB)throw new Error("--between needs two snapshot refs: --between <refA> <refB>")}else if(s==="--traffic"){let a=e[++i];if(!a)throw new Error('--traffic needs a level, passed to the engine verbatim: --traffic "100 rps, p50"');t.traffic=a}else if(s==="--overlay-anchor"){let a=e[++i];if(a!=="source"&&a!=="live")throw new Error(`--overlay-anchor must be 'source' or 'live', got '${a}'`);t.overlayAnchor=a}else if(s==="--scan"){let a=e[++i];if(a===void 0||a==="--"||a.startsWith("--"))throw new Error("--scan needs a directory: --scan <dir>");(t.scanDirs??=[]).push(a)}else if(s==="--from")t.migrateFrom=e[++i];else if(s==="--kustomize")t.kustomize=e[++i];else if(s==="--parser-option"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--parser-option needs key or key=value: --parser-option acceptLossyV1");(t.parserOption??=[]).push(a)}else if(s==="--tag"){let a=e[++i];if(!a||a.startsWith("-")||!a.includes("="))throw new Error("--tag needs key=value: --tag team=payments");(t.selectTags??=[]).push(a)}else if(s==="--type")t.selectType=e[++i];else if(s==="--name")t.selectName=e[++i];else if(s==="--owned")t.owned=!0;else if(s==="--namespace"){if(t.namespace=e[++i],!t.namespace||t.namespace.startsWith("-"))throw new Error("--namespace needs a namespace: --namespace <ns>")}else if(s==="--verbatim")t.verbatim=!0;else if(s==="--skip-undeclarable")t.skipUndeclarable=!0;else if(s==="--state")t.statePath=e[++i],t.statePath!==void 0&&(t.statePaths??=[]).push(t.statePath);else if(s==="--state-dir"){if(t.stateDir=e[++i],!t.stateDir||t.stateDir.startsWith("-"))throw new Error("--state-dir needs a directory: --state-dir <dir>")}else if(s==="--wave-size"){let a=e[++i],c=Number(a);if(!Number.isInteger(c)||c<1)throw new Error(`--wave-size needs a whole number from 1: got "${a??""}"`);t.waveSize=c}else if(s==="--all")t.all=!0;else if(s==="--select")t.selectAddress=e[++i];else if(s==="--live-name")t.liveName=e[++i];else if(s==="--apply-rewrites")t.applyRewrites=!0;else if(s==="--stack")t.carveStack=e[++i];else if(s==="--write")t.write=!0;else if(s==="--write-source")t.writeSource=!0;else if(s==="--to")t.migrateTo=e[++i];else if(s==="--emit")t.emit=e[++i];else if(s==="--dry-run")t.dryRun=!0;else if(s==="--drill")t.drill=!0;else if(s==="--yes")t.yes=!0;else if(s==="--push")t.push=!0;else if(s==="--confirm-prod")t.confirmProd=!0;else if(s==="--strict")t.strict=!0;else if(s==="--validate")t.validate=!0;else if(s==="--use-composites")t.useComposites=!0;else if(s==="--skill")t.skill=e[++i];else if(s==="--skip-mcp")t.skipMcp=!0;else if(s==="--read-only")t.readOnly=!0;else if(s==="--mcp-read-only")t.mcpReadOnly=!0;else if(s==="--propose")t.propose=!0;else if(s==="--src")t.src=e[++i];else if(s==="--env")t.env=e[++i];else if(s==="--port"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--port needs a port: --port <container-port>=<host-port>");(t.port??=[]).push(a)}else if(s==="--image"){if(t.image=e[++i],!t.image||t.image.startsWith("-"))throw new Error("--image needs an image reference: --image <name>:<tag>");(t.images??=[]).push(t.image)}else if(s==="--network"){if(t.network=e[++i],!t.network||t.network.startsWith("-"))throw new Error("--network needs a Docker network name: --network <name>")}else if(s==="--setting"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--setting needs a value: --setting <KEY>=<VALUE>");(t.setting??=[]).push(a)}else if(s==="--loopback")t.loopback=!0;else if(s==="--promote-to"){if(t.promoteTo=e[++i],!t.promoteTo||t.promoteTo.startsWith("-"))throw new Error("--promote-to needs an environment: --promote-to <env>")}else if(s==="--tier")t.tier=e[++i];else if(s==="--agents")t.agents=!0;else if(s==="--scope")t.scope=e[++i];else if(s==="--all-projects")t.allProjects=!0;else if(s==="--runtime")t.runtime=e[++i];else if(s==="--fail-on")t.failOn=e[++i];else if(s==="--max-files")t.maxFiles=Number(e[++i]);else if(s==="--theme")t.theme=e[++i];else if(s==="--stacks")t.stacks=!0;else if(s==="--components")t.components=!0;else if(s==="--generate")t.generate=e[++i];else if(s==="--spec")t.opsSpec=e[++i];else if(s==="--dump-outputs")t.dumpOutputs=e[++i];else if(s==="--digest-file")t.digestFile=e[++i];else if(s==="--seed-outputs")(t.seedOutputs??=[]).push(e[++i]);else if(s==="--keep")t.keepLocks=!0;else if(s==="--runs"||s==="--plans"||s==="--wave-outputs"){let a=e[++i];if(a===void 0||a.startsWith("-"))throw new Error(`${s} needs a file`);t[{"--runs":"runsFile","--plans":"plansFile","--wave-outputs":"waveOutputs"}[s]]=a}else if(s==="--detail")t.detail=Number(e[++i]);else if(s==="--lens")t.lens=e[++i];else if(s==="--explain")t.explain=!0;else if(s==="--show")t.show=e[++i];else if(s==="--count-by"){if(t.countBy=e[++i],!t.countBy||t.countBy.startsWith("-"))throw new Error("--count-by needs a grouping: --count-by kind, --count-by module or --count-by attr:<name>")}else if(s==="--up")t.up=!0;else if(s==="--down")t.down=!0;else if(s==="--node-sizes")t.nodeSizes=e[++i];else if(s==="--layout-engine")t.layoutEngine=e[++i];else if(s==="--base")t.base=e[++i];else if(s==="--head")t.head=e[++i];else if(s==="--include-dependents")t.includeDependents=!0;else if(s==="--cross-root")t.crossRoot=!0;else if(s==="--dependents-of"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--dependents-of needs a member name: --dependents-of <member>");t.dependentsOf=a}else if(s==="--pin"){let a=e[++i];if(!a||a.startsWith("-")||!a.includes("="))throw new Error("--pin needs a member and a release: --pin <member>=<label|digest>");(t.pins??=[]).push(a)}else if(s==="--from-affected")t.fromAffected=e[++i];else if(s==="--gate")t.gate=e[++i];else if(s==="--wave-gate"){if(t.waveGate=e[++i],!t.waveGate||t.waveGate.startsWith("-"))throw new Error("--wave-gate needs a gate name: --wave-gate <name>")}else if(s==="--wave"){let a=e[++i],c=Number(a);if(!Number.isInteger(c)||c<1)throw new Error(`--wave needs a wave number from 1: got "${a??""}"`);t.wave=c}else if(s==="--decide")t.decide=!0;else if(s==="--record-plans")t.recordPlans=!0;else if(s==="--approval-status")t.approvalStatus=!0;else if(s==="--waves-outcome")t.wavesOutcome=!0;else if(s==="--group"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--group needs a job group's name: --group <name>");t.group=a}else if(s==="--share"){let a=e[++i],c=Number(a);if(!Number.isInteger(c)||c<1)throw new Error(`--share needs a share number from 1: got "${a??""}"`);t.share=c}else if(s==="--target"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--target needs an address: --target <component>:<address>, or on pr-plan --target <address>");(t.targets??=[]).push(a)}else if(s==="--refresh")t.refresh=!0;else if(s==="--target-dependents")t.targetDependents=!0;else if(s==="--comment-targets")t.commentTargets=!0;else if(s==="--parallelism"){let a=e[++i],c=Number(a);if(!Number.isInteger(c)||c<1)throw new Error(`--parallelism needs a whole number of 1 or more: got "${a??""}"`);t.parallelism=c}else if(s==="--canary"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--canary needs a component name: --canary <name>[,<name>...]");(t.canary??=[]).push(...a.split(",").map(c=>c.trim()).filter(Boolean))}else if(s==="--pr"){let a=e[++i],c=Number(a);if(!Number.isInteger(c)||c<1)throw new Error(`--pr needs a pull or merge request number: got "${a??""}"`);t.pr=c,(t.prs??=[]).push(c)}else if(s==="--channel"){if(t.channel=e[++i],!t.channel||!/^[A-Za-z][A-Za-z0-9._-]*$/.test(t.channel))throw new Error(`--channel needs a channel name, such as next or hotfix: got "${t.channel??""}"`)}else if(s==="--forge"){if(t.forge=e[++i],!t.forge||t.forge.startsWith("-"))throw new Error("--forge needs a forge: --forge github|gitlab|forgejo")}else if(s==="--require-clouds")t.requireClouds=!0;else if(s==="--require-review")t.requireReview=!0;else if(s==="--list")t.list=!0;else if(s==="--stage"){if(t.lockStage=e[++i],!t.lockStage||t.lockStage.startsWith("-"))throw new Error("--stage needs plan, apply or lock: --stage <stage>")}else if(s==="--alive"){if(t.aliveRun=e[++i],!t.aliveRun||t.aliveRun.startsWith("-"))throw new Error("--alive needs a run id: --alive <run>")}else if(s==="--beat"){if(t.beatRun=e[++i],!t.beatRun||t.beatRun.startsWith("-"))throw new Error("--beat needs a run id: --beat <run> --parent <pid>")}else if(s==="--parent"){let a=Number(e[++i]);if(!Number.isInteger(a)||a<1)throw new Error("--parent needs a process id: --parent <pid>");t.parentPid=a}else if(s==="--run"){if(t.unlockRun=e[++i],!t.unlockRun||t.unlockRun.startsWith("-"))throw new Error("--run needs a run id: --run <id>")}else if(s==="--from-report"){if(t.fromReport=e[++i],!t.fromReport||t.fromReport.startsWith("-"))throw new Error("--from-report needs a report file: --from-report <pr-plan.json>")}else if(s==="--report-url"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--report-url needs a URL: --report-url s3://<bucket>/<prefix>, gs://<bucket>/<prefix>, az://<account>/<container>/<prefix> or file://<directory>");t.reportUrl=a}else if(s==="--result"){if(t.planResult=e[++i],!t.planResult||t.planResult.startsWith("-"))throw new Error("--result needs the plan job's result: --result success|failure|cancelled")}else if(s==="--no-status")t.noStatus=!0;else if(s==="--status-url"){if(t.statusUrl=e[++i],!t.statusUrl||t.statusUrl.startsWith("-"))throw new Error("--status-url needs a URL template: --status-url https://host/reports/{key}")}else if(s==="--override-green")t.overrideGreen=!0;else if(s==="--allow-unsigned")t.allowUnsigned=!0;else if(s==="--require-provenance")t.requireProvenance=!0;else if(s==="--pr-loop")t.prLoop=!0;else if(s==="--green")t.green=!0;else if(s==="--before-merge")t.beforeMerge=!0;else if(s==="--requires"){let a=e[++i];if(a===void 0||a.startsWith("-"))throw new Error("--requires needs a list of checks: --requires approved,mergeable,undiverged,checks");t.requires=a.split(",").map(c=>c.trim()).filter(Boolean)}else if(s==="--respond"){let a=e[++i];if(a===void 0||a.startsWith("-"))throw new Error("--respond needs a list of responses: --respond wave-refused=diff,apply-failed=off,description=check");t.respond=[...t.respond??[],a]}else if(s==="--decide-backend"){let a=e[++i];if(a===void 0||a.startsWith("-"))throw new Error("--decide-backend needs the name of a decide.backends entry");t.decideBackend=a}else if(s==="--decide-model"){let a=e[++i];if(a===void 0||a.startsWith("-"))throw new Error("--decide-model needs a model id");t.decideModel=a}else if(s==="--merge"||s==="--merge-token-env"||s==="--merge-method"){let a=e[++i];if(a===void 0||a.startsWith("-"))throw new Error(`${s} needs a value: --merge manual|auto, --merge-token-env <VAR>, --merge-method merge|squash|rebase`);s==="--merge"?t.merge=a:s==="--merge-token-env"?t.mergeTokenEnv=a:t.mergeMethod=a}else if(s==="--apply-before-merge")t.applyBeforeMerge=!0;else if(s==="--apply-on-merge")t.applyOnMerge=!0;else if(s==="--action-job")t.actionJob=!0;else if(s==="--preview-comment")t.previewComment=!0;else if(s==="--pr-env")t.prEnv=!0;else if(s==="--pr-runner"){let a=e[++i]??"",c=/^(plan|apply|default)=(.+)$/.exec(a);if(!c)throw new Error(`--pr-runner needs <stage>=<label>[,<label>...], the stage plan, apply or default: got "${a}"`);let l=c[2].split(",").map(u=>u.trim()).filter(Boolean);if(l.length===0)throw new Error(`--pr-runner ${c[1]} names no label`);(t.prRunners??={})[c[1]]=l}else if(s==="--pr-variable"||s==="--pr-secret"){let a=e[++i]??"",c=a.indexOf("=");if(c<1)throw new Error(`${s} needs <NAME>=<${s==="--pr-secret"?"secret":"value"}>: got "${a}"`);let l=s==="--pr-secret"?t.prSecrets??={}:t.prVariables??={};l[a.slice(0,c)]=a.slice(c+1)}else if(s==="--pr-build")t.prBuild=!0;else if(s==="--build-command"){let a=e[++i];if(a===void 0||a==="")throw new Error("--build-command needs a shell line: --build-command '<line>'");t.ciBuildCommand=a}else if(s==="--land")t.ciLand=!0;else if(s==="--pr-build-command"){let a=e[++i];if(a===void 0||a==="")throw new Error("--pr-build-command needs a shell line: --pr-build-command '<line>'");t.prBuildCommand=a}else if(s==="--before-script"){let a=e[++i];if(a===void 0||a==="")throw new Error("--before-script needs a shell line: --before-script '<line>'");(t.beforeScript??=[]).push(a)}else if(s==="--resume"){let a=e[i+1];a===void 0||a.startsWith("-")?t.resumeRun=!0:t.resume=e[++i]}else if(s==="--local")t.local=!0;else if(s==="--json")t.json=!0;else if(s==="--progress-json")t.progressJson=!0;else if(s==="--events-json")t.eventsJson=!0;else if(s==="--follow")t.follow=!0;else if(s==="--gated-exit")t.gatedExit=Number(e[++i]);else if(s==="--durable-requests")t.durableRequests=!0;else if(s==="--update-snapshot")t.updateSnapshot=!0;else if(s==="--update-baseline")t.updateBaseline=!0;else if(s==="--deep")t.deep=!0;else if(s==="--at")t.at=e[++i];else if(s==="--capability-view")t.capabilityView=!0;else if(s==="--capabilities")t.capabilities=!0;else if(s==="--snapshot"){if(t.snapshot=e[++i],!t.snapshot||t.snapshot.startsWith("-"))throw new Error("--snapshot needs a snapshot ref: --snapshot latest")}else if(s==="--kind"){if(t.kind=e[++i],!t.kind||t.kind.startsWith("-"))throw new Error("--kind needs a kind file: --kind <path>");(t.kinds??=[]).push(t.kind)}else if(s==="--composites")t.composites=!0;else if(s==="--intent"){let a=e[i+1];if(a!==void 0&&!a.startsWith("-"))t.intent=e[++i];else if(e.includes("--record"))t.intent="";else throw new Error("--intent needs a region: --intent <path[:start-end]|path#symbol|member/node|sha>, or --intent --record <id>")}else if(s==="--follow-squash")t.followSquash=!0;else if(s==="--forge-issues")t.forgeIssues=!0;else if(s==="--record"){if(t.record=e[++i],!t.record||t.record.startsWith("-"))throw new Error("--record needs a record id: --record <id>")}else if(s==="--path"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--path needs a path: --path <path>");(t.paths??=[]).push(a)}else if(s==="--worktree")t.worktree=!0;else if(s==="--max-bytes"){let a=Number(e[++i]);if(!Number.isInteger(a)||a<1)throw new Error("--max-bytes needs a whole number of bytes above 0");t.maxBytes=a}else if(s==="--changes"){if(t.changes=e[++i],!t.changes||t.changes.startsWith("-"))throw new Error("--changes needs a range: --changes <base>..<head>")}else if(s==="--severity"){if(t.severity=e[++i],!t.severity||t.severity.startsWith("-"))throw new Error("--severity needs off, warn or fail")}else if(s==="--current")t.current=!0;else if(s==="--uncommitted")t.uncommitted=!0;else if(s==="--set"){if(t.set=e[++i],!t.set||t.set.startsWith("-")&&t.set!=="-")throw new Error("--set needs a JSON file, or - for standard input: --set <file|->")}else if(s==="--cover"){if(t.cover=e[++i],!t.cover||t.cover.startsWith("-"))throw new Error("--cover needs a PNG, JPEG or WebP file: --cover <image>")}else if(s==="--cover-path"){if(t.coverPath=e[++i],!t.coverPath||t.coverPath.startsWith("-"))throw new Error("--cover-path needs a path from the workspace root: --cover-path <path>")}else if(s==="--records")t.records=!0;else if(s==="--expect"){if(t.expect=e[++i],!t.expect||t.expect.startsWith("-"))throw new Error("--expect needs the record's digest, as records --json prints it: --expect <digest>")}else if(s==="--label"){if(t.label=e[++i],!t.label||t.label.startsWith("-"))throw new Error("--label needs the snapshot's name, such as a turn id: --label <text>")}else if(s==="--branch"){if(t.branch=e[++i],!t.branch||t.branch.startsWith("-"))throw new Error("--branch needs a branch name: --branch <branch>")}else if(s==="--security"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--security needs a group: --security verified-releases|supply-chain|who-ran-it|review-rules|isolated-runners");t.securityGroups=[...t.securityGroups??[],a]}else if(s==="--workflow"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--workflow needs a workflow's name: --workflow <name>");t.ciWorkflows=[...t.ciWorkflows??[],a]}else if(s==="--chant"){if(t.ciChant=e[++i],!t.ciChant||t.ciChant.startsWith("-"))throw new Error('--chant needs the command that runs chant, such as "npx tsx packages/core/src/cli/main.ts": --chant <command>')}else if(s==="--commit"){if(t.commit=e[++i],!t.commit||t.commit.startsWith("-"))throw new Error("--commit needs the commit the job runs at: --commit <sha>")}else if(s==="--pass-env"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--pass-env needs a variable's name, such as AWS_PROFILE: --pass-env <NAME>");(t.passEnv??=[]).push(a)}else if(s==="--secrets"){if(t.ciSecrets=e[++i],!t.ciSecrets||t.ciSecrets.startsWith("-"))throw new Error("--secrets needs the host's secrets file, a dotenv or JSON file only its owner can read: --secrets <file>")}else if(s==="--repo"){if(t.ciRepo=e[++i],!t.ciRepo||!/^[^/\s-][^/\s]*\/[^/\s]+$/.test(t.ciRepo))throw new Error("--repo needs the repository as owner/name: --repo <owner/repo>")}else if(s==="--run-index-limit"){let a=Number(e[++i]);if(!Number.isInteger(a)||a<1)throw new Error("--run-index-limit needs a whole number of runs, 1 or more: --run-index-limit <n>");t.runIndexLimit=a}else if(s==="--max-jobs"){let a=Number(e[++i]);if(!Number.isInteger(a)||a<1)throw new Error("--max-jobs needs a whole number of jobs, 1 or more: --max-jobs <n>");t.maxJobs=a}else if(s==="--author"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--author needs a forge login: --author <login>");(t.ciAuthors??=[]).push(a)}else if(s==="--rerun-failed")t.rerunFailed=!0;else if(s==="--install"){if(t.ciInstall=e[++i],!t.ciInstall||t.ciInstall.startsWith("-"))throw new Error('--install needs the install command, such as "npm install": --install <command>')}else if(s==="--token-secret"){if(t.ciTokenSecret=e[++i],!t.ciTokenSecret||t.ciTokenSecret.startsWith("-"))throw new Error("--token-secret needs a repository secret's name, such as CI_GREEN_TOKEN: --token-secret <NAME>")}else if(s==="--app-id-var"){if(t.ciAppIdVar=e[++i],!t.ciAppIdVar||t.ciAppIdVar.startsWith("-"))throw new Error("--app-id-var needs the Actions variable holding the App's id: --app-id-var <VAR>")}else if(s==="--app-key-secret"){if(t.ciAppKeySecret=e[++i],!t.ciAppKeySecret||t.ciAppKeySecret.startsWith("-"))throw new Error("--app-key-secret needs the secret holding the App's private key: --app-key-secret <NAME>")}else if(s==="--runner-key-secret"){if(t.ciRunnerKeySecret=e[++i],!t.ciRunnerKeySecret||t.ciRunnerKeySecret.startsWith("-"))throw new Error("--runner-key-secret needs the repository secret holding the runner key, such as CHANT_RUNNER_KEY: --runner-key-secret <NAME>")}else if(s==="--verdict"){if(t.verdict=e[++i],!t.verdict||t.verdict.startsWith("-"))throw new Error("--verdict needs agree, dissent or abstain")}else if(s==="--class"){if(t.runnerClass=e[++i],!t.runnerClass||t.runnerClass.startsWith("-"))throw new Error("--class needs runner or service: --class <class>")}else if(s==="--by"){if(t.by=e[++i],!t.by||t.by.startsWith("-"))throw new Error("--by needs the reviewer: --by <principal>");(t.bys??=[]).push(t.by)}else if(s==="--stale-notes")t.staleNotes=!0;else if(s==="--stale")t.stale=!0;else if(s==="--tip"){let a=e[++i];if(!a||!/^[0-9a-f]{40}$/.test(a))throw new Error(`--tip needs the target branch's full commit sha: got "${a??""}"`);t.tip=a}else if(s==="--open")t.open=!0;else if(s==="--inputs"){if(t.inputs=e[++i],!t.inputs||t.inputs.startsWith("-")&&t.inputs!=="-")throw new Error("--inputs needs a JSON file, - for standard input, or the JSON itself: --inputs <file|-|json>")}else if(s==="--candidates"){if(t.candidates=e[++i],!t.candidates||t.candidates.startsWith("-")&&t.candidates!=="-")throw new Error("--candidates needs a JSON file, - for standard input, or the JSON itself: --candidates <file|-|json>")}else if(s==="--response"){if(t.response=e[++i],!t.response||t.response.startsWith("-"))throw new Error("--response needs a JSON file: --response <file>")}else if(s==="--subject"){if(t.subject=e[++i],!t.subject||t.subject.startsWith("-"))throw new Error("--subject needs what the question is about, such as a work item id: --subject <id>")}else if(s==="--store"){let a=e[++i];if(a!=="tree"&&a!=="ledger")throw new Error("--store is tree (the answer kind's directory in the working tree) or ledger (chant/lifecycle): --store <tree|ledger>");t.store=a}else if(s==="--answer"){if(t.answer=e[++i],t.answer===void 0||t.answer==="")throw new Error("--answer needs one of the question's candidates: --answer <value>")}else if(s==="--sign"){let a=e[i+1];t.sign=a!==void 0&&!a.startsWith("-")?e[++i]:!0}else if(s==="--session"){if(t.session=e[++i],!t.session||t.session.startsWith("-"))throw new Error("--session needs a session id: --session <id>")}else if(s==="--prefix"){if(t.prefix=e[++i],!t.prefix||t.prefix.startsWith("-"))throw new Error("--prefix needs an id prefix: --prefix <prefix>")}else if(s==="--key"||s==="--check-id"||s==="--claim"||s==="--environment"||s==="--envelope"||s==="--threshold"){let a=e[++i];if(a===void 0||a.startsWith("-"))throw new Error(`${s} needs a value`);let c={"--key":"key","--check-id":"checkId","--claim":"claim","--environment":"environment","--envelope":"envelope","--threshold":"threshold"}[s];t[c]=a}else if(s==="--require"){if(t.require=e[++i],!t.require||t.require.startsWith("-"))throw new Error("--require needs a provenance level: --require attested")}else if(s==="--ambient")t.ambient=!0;else if(s==="--check-live")t.checkLive=!0;else if(s==="--check-snapshot")t.checkSnapshot=!0;else if(s==="--fail-on-drift")t.failOnDrift=!0;else if(s==="--run-examples")t.runExamples=!0;else if(s==="--pinned-digest")t.pinnedDigest=e[++i];else if(s==="--check")t.check=!0;else if(s==="--bump")t.bump=!0;else if(s==="--component")t.component=e[++i];else if(s==="--digest")t.digest=e[++i],t.digest!==void 0&&(t.digests??=[]).push(t.digest);else if(s==="--release-plan")t.releasePlanFile=e[++i];else if(s==="--release"){if(t.release=e[++i],!t.release||t.release.startsWith("-"))throw new Error("--release needs a release's label or digest: --release <label|digest>")}else if(s==="--build"){if(t.buildCommand=e[++i],!t.buildCommand)throw new Error("--build needs a shell command: --build '<command>'")}else if(s==="--deploy-unchanged")t.deployUnchanged=!0;else if(s==="--artifacts")t.artifacts=!0;else if(s==="--git-sha")t.gitSha=e[++i];else if(s==="--run-id")t.runId=e[++i];else if(s==="--actor")t.actor=e[++i];else if(s==="--approver")t.approver=e[++i];else if(s==="--statement")t.statement=!0;else if(s==="--signature"){if(t.signature=e[++i],!t.signature||t.signature.startsWith("-")&&t.signature!=="-")throw new Error("--signature needs a file holding the signature, or - for stdin: --signature <file|->")}else if(s==="--binding"){if(t.binding=e[++i],!t.binding||t.binding.startsWith("-"))throw new Error("--binding needs the line the signature binds, which does not start with -: --binding <text>")}else if(s==="--relayed-by"){if(t.relayedBy=e[++i],!t.relayedBy||t.relayedBy.startsWith("-"))throw new Error("--relayed-by needs the principal that relayed it: --relayed-by <principal>")}else if(s==="--on"){if(t.on=e[++i],!t.on||t.on.startsWith("-"))throw new Error("--on needs a runtime name: --on <lexicon>")}else if(s==="--compare-to")t.compareTo=e[++i];else if(s==="--no-release-record")t.noReleaseRecord=!0;else if(s==="--no-record")t.noRecord=!0;else if(s==="--fold")t.fold=!0;else if(s==="--no-cache")t.noCache=!0;else if(s==="--no-fold")t.fold=!1;else if(s==="--sandbox")t.sandbox=!0;else if(s==="--fold-rank"){let a=e[i+1];a&&!a.startsWith("-")?(t.foldRankCollapsedFile=a,i++):t.foldRank=!0}else if(s==="--param")(t.param??=[]).push(e[++i]);else if(s==="--lexicon-output")(t.lexiconOutput??=[]).push(e[++i]);else if(s==="--params-file")t.paramsFile=e[++i];else if(s==="--projection")t.projection=e[++i];else if(s==="--interval")t.interval=e[++i];else if(s==="--lease-ttl")t.leaseTtl=e[++i];else if(s==="--steward"){let a=e[i+1];a!==void 0&&!a.startsWith("-")?(t.steward=a,i++):t.steward=""}else if(s==="--once")t.once=!0;else if(s==="--setup-key")t.setupKey=!0;else if(s==="--trust")t.trustKey=!0;else if(s==="--in-place")t.ciInPlace=!0;else if(s==="--require-runner-start")t.requireRunnerStart=!0;else if(s==="--job"){if(t.ciJob=e[++i],!t.ciJob||t.ciJob.startsWith("-"))throw new Error("--job needs the job as JSON or @<file>: --job @job.json")}else if(s==="--no-push")t.noPush=!0;else if(s==="--no-require-review")t.requireReview=!1;else if(s==="--unsigned")t.unsigned=!0;else if(s==="--principal"){if(t.ciPrincipal=e[++i],!t.ciPrincipal||t.ciPrincipal.startsWith("-"))throw new Error("--principal needs the runner's principal: --principal <name>")}else if(s==="--work"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--work needs a work item id: --work <id>");t.work=a,(t.works??=[]).push(a)}else if(s==="--holder"||s==="--ttl"||s==="--token"||s==="--outcome"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error(`${s} needs a value: ${s} <${s.slice(2)}>`);t[s.slice(2)]=a}else if(s==="--input"||s==="--org"||s==="--endpoint"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error(`${s} needs a value: ${s} <${s==="--input"?"file":s.slice(2)}>`);t[s.slice(2)]=a}else if(s==="--signer"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--signer needs a principal: --signer <principal>");t.signer=a}else if(s==="--unit"||s==="--decision"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error(`${s} needs an id: ${s} <id>`);t[s.slice(2)]=a}else if(s==="--note")t.note=e[++i];else if(s==="--reason"){if(t.reason=e[++i],t.reason===void 0||t.reason.startsWith("-"))throw new Error("--reason needs the text of the reason: --reason <text>")}else if(s==="--rule"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--rule needs a rule id: --rule <id>");(t.rules??=[]).push(a)}else if(s==="--expire")t.expire=!0;else if(s==="--role"){let a=e[++i]??"";t.roles=[...t.roles??[],...a.split(",").map(c=>c.trim()).filter(Boolean)]}else if(s==="--agent")t.agent=!0;else if(s==="--allow-code")t.allowCode=!0;else if(s==="--allow-skip")t.allowSkip=!0;else if(s==="--source"){if(t.source=e[++i],!t.source||t.source.startsWith("-"))throw new Error("--source needs a template: --source <repo>[#<member>] for workspace upgrade, or a source for ci tick and ci list: --source checks|runs")}else if(s==="--tags"){if(t.tags=e[++i],!t.tags||t.tags.startsWith("-"))throw new Error("--tags needs a tag glob: --tags 'v*'")}else if(s==="--index"){if(t.index=e[++i],!t.index||t.index.startsWith("-"))throw new Error("--index needs a value: --index <file> for workspace adopt-lineage, --index <scope key>[@<version>] for search and lifecycle diff")}else if(s==="--adopt"){if(t.adopt=e[++i],!t.adopt||t.adopt.startsWith("-"))throw new Error("--adopt needs an adoption file: --adopt <file>")}else if(s==="--adopt-out"){if(t.adoptOut=e[++i],!t.adoptOut||t.adoptOut.startsWith("-"))throw new Error("--adopt-out needs a file: --adopt-out <file>")}else if(s==="--remove")t.remove=!0;else if(s==="--available")t.available=!0;else if(s==="--root-only")t.rootOnly=!0;else if(s==="--forge-repos"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--forge-repos needs a file: --forge-repos <repos.json>");t.forgeRepos=a}else if(s==="--generated")t.generated=!0;else if(s==="--member"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--member needs a member or group name: --member <name>");t.members=[...t.members??[],...a.split(",").map(c=>c.trim()).filter(Boolean)]}else if(s==="--allow-same-origin")t.allowSameOrigin=!0;else if(s==="--plan")t.plan=e[++i];else if(s==="--url")t.url=e[++i];else if(s==="--op")t.op=e[++i];else if(s==="--where"){let a=e[++i];if(a===void 0||a.startsWith("--"))throw new Error("--where needs a clause: --where <field><op><value>");t.where=[...t.where??[],a]}else if(s==="--read"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--read needs a read: --read <state|plan|refresh|live-read|ownership>");t.driftRead=a}else if(s==="--stream")t.stream=!0;else if(s==="--resource"){let a=e[++i];if(!a||a.startsWith("--"))throw new Error("--resource needs an address: --resource <addr>");t.resource=a}else if(s==="--since")t.since=e[++i];else if(s==="--wait")t.ciWait=!0;else if(s==="--retries"){let a=e[++i];if(a===void 0||!/^\d+$/.test(a))throw new Error(`--retries needs a whole number of re-runs: --retries <n>, got ${JSON.stringify(a??"")}`);t.ciRetries=Number(a)}else if(s==="--timeout-minutes"){let a=e[++i],c=a===void 0?NaN:Number(a);if(a===void 0||a.trim()===""||!Number.isFinite(c)||c<=0)throw new Error(`--timeout-minutes needs a number of minutes above 0: --timeout-minutes <n>, got ${JSON.stringify(a??"")}`);t.ciTimeoutMinutes=c}else if(s==="--lane")t.lane=e[++i];else if(s==="--runner")t.quarantineRunner=e[++i];else if(s==="--junit"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--junit needs the JUnit XML file the run wrote: --junit <file>");(t.quarantineJunit??=[]).push(a)}else if(s==="--only")t.quarantineOnly=!0;else if(s==="--phase")t.phase=e[++i];else if(s==="--audit-log"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--audit-log needs the log: --audit-log aws[:<region>]");t.auditLog=a}else if(s==="--limit")t.limit=Number(e[++i]);else{if(s.startsWith("--"))throw new Error(`Unknown flag: ${s}
494
+ `),{status:"refused",code:We.moved}}return{status:"confirmed",plan:m,target:h}}var bxe=x(()=>{"use strict";Ui()});import{readFileSync as vxe}from"node:fs";import{resolve as Wrt}from"node:path";async function kxe(e){let{pushed:t,pushWarning:n}=await Ma().catch(o=>{if(o instanceof Fo)return{pushed:!1,pushWarning:o.message};throw o});return t?{pushed:t,suffix:""}:nd(n)?{pushed:t,suffix:` (${td})`}:(console.error(ur({message:`The push to the remote did not land: ${n??"no reason given"}`,hint:e})),{pushed:t,suffix:" (local only \u2014 the push did not land)"})}async function Rxe(e){let t=e.args.path,n=e.args.extraPositional;if(!t||t==="."||!n)return console.error($e({message:"Usage: chant approve <op> <gate>"})),1;if(e.args.expire){try{await Hr()}catch(l){return console.error($e({message:`Cannot expire the gate: ${l instanceof Error?l.message:String(l)}`})),1}let s=new Date().toISOString(),a=Nn((await yr(t)).pending,n);if(!a||Vn(a,s))return console.error(ur({message:`Gate "${n}" on "${t}" has no standing pending fact \u2014 nothing to expire`})),0;await bm({op:t,gate:n,timestamp:s,expiresAt:s,...a.description?{description:a.description}:{},...a.runId?{runId:a.runId}:{},...a.gitSha?{gitSha:a.gitSha}:{}});let c=await kxe(`The expiry is recorded locally on ${NR}. Until it reaches the remote, a run in another checkout still sees the old pending fact.`);return console.error(Rh(`Gate "${n}" on "${t}" expired at ${s} \u2014 not approved`+c.suffix)),console.error(In(t===mm?"The next `chant components fan-out` decides this gate from scratch and records a fresh pending fact.":rA.test(t)?"The next `chant components pr-apply` decides this gate from scratch and records a fresh pending fact.":t===tb?`The next \`chant workspace promote ${n}\` decides this gate from scratch and records a fresh pending fact.`:t===gm?`The next \`chant workspace upgrade ${n}\` decides this gate from scratch and records a fresh pending fact.`:t===hm?"The next `chant workspace exit` decides this gate from scratch and records a fresh pending fact.":t===bi?"The next `chant components promote --release` decides this gate from scratch and records a fresh pending fact.":`The next \`chant run ${t}\` decides this gate from scratch and records a fresh pending fact.`)),0}if(t===ul){let{runOverrideApprove:s}=await Promise.resolve().then(()=>(uxe(),lxe));return s(e)}if(e.args.rules!==void 0||e.args.reason!==void 0)return console.error($e({message:`--rule and --reason override a denied plan: chant approve ${ul} <subject> --rule <id> --reason <text>`,hint:`To approve gate "${n}" on "${t}", put any prose in --note.`})),1;if(e.args.statement){if(e.args.sign!==void 0||e.args.signature!==void 0)return console.error($e({message:"--statement prints what to sign and records nothing, so it takes neither --sign nor --signature"})),1;let s={actor:e.args.approver??e.args.actor,...e.args.plan!==void 0?{plan:e.args.plan}:{},...e.args.env!==void 0?{environment:e.args.env}:{},...e.args.relayedBy!==void 0?{relayedBy:e.args.relayedBy}:{},...e.args.at!==void 0?{at:e.args.at}:{},...e.args.binding!==void 0?{binding:e.args.binding}:{},allowSameOrigin:e.args.allowSameOrigin},a=await Urt(t,n,s);return a?(console.log(JSON.stringify(a,null,2)),console.error(In(`Have ${a.resolvedBy} sign these bytes (an ssh key in the ${a.namespace} namespace, or a passkey with challenge ${a.challenge}), then record it: chant approve ${t} ${n} --actor ${a.resolvedBy}`+(a.relayedBy!==null?` --relayed-by ${a.relayedBy}`:"")+(a.planDigest!==null?` --plan ${a.planDigest}`:"")+(a.environment!==null?` --env ${a.environment}`:"")+(a.binding!==null?` --binding ${qrt(a.binding)}`:"")+` --at ${a.timestamp} --signature <file>`)),0):1}let o=e.args.plan,r=await Promise.resolve().then(()=>(bxe(),wxe));if(e.args.signature===void 0&&await r.interactiveApproval(e.args)){let s=await r.confirmApproval(t,n,{...o!==void 0?{plan:o}:{},...e.args.env!==void 0?{environment:e.args.env}:{}});if(s.status==="refused")return s.code;s.status==="confirmed"&&(o=s.plan)}let i=await T6(t,n,{actor:e.args.approver??e.args.actor,note:e.args.note,url:e.args.url,plan:o,...e.args.env!==void 0?{environment:e.args.env}:{},allowSameOrigin:e.args.allowSameOrigin,...e.args.roles?{roles:e.args.roles}:{},...e.args.agent?{agent:!0}:{},...e.args.sign!==void 0?{sign:e.args.sign}:{},...e.args.signature!==void 0?{signature:e.args.signature}:{},...e.args.at!==void 0?{at:e.args.at}:{},...e.args.binding!==void 0?{binding:e.args.binding}:{},...e.args.relayedBy!==void 0?{relayedBy:e.args.relayedBy}:{}});if(!i.ok)return 1;if(e.args.resumeRun||e.args.resume!==void 0){let{resumeAfterApproval:s}=await Promise.resolve().then(()=>(i0(),e6));return s(t,n,i.record.environment,i.pushed)}return console.error(In("This records the resolution as a fact; it does not itself re-run anything. "+(t===mm?`Repeat the \`chant components fan-out\` command and it walks through gate "${n}".`:rA.test(t)?`The pull request's apply (\`chant components pr-apply\`) walks through gate "${n}" when it plans this same digest.`:t===tb?`Repeat \`chant workspace promote ${n}\`, and it applies the patch this approval names.`:t===gm?`Repeat \`chant workspace upgrade ${n}\` with the same target, and it applies the patch this approval names.`:t===hm?"Repeat `chant workspace exit` with the same members, and it applies the patch this approval names.":t===bi?`Repeat the same \`chant components promote --release\`, and it walks through gate "${n}" when it plans this same change set for this release.`:`Run \`chant run ${t}\` and it walks through gate "${n}".`))),0}async function Brt(e,t,n,o){let{readRelease:r,readCuts:i,labelsByDigest:s}=await Promise.resolve().then(()=>(Ka(),Jm)),{readRevokedCommits:a,revocationOf:c,revokedRefusal:l}=await Promise.resolve().then(()=>(I_(),UK)),u=await r(n,{cwd:o}).catch(()=>null);if(!u)return console.error($e({message:`Gate "${t}" on "${e}" binds release ${n}, which can't be read from ${NR}, so whether it is revoked is unknown [release-unreadable]`,hint:`Fetch the ledger branch (git fetch origin ${NR}:${NR}) and approve again from the member's directory.`})),!0;let d;try{d=await a(o)}catch(m){return console.error($e({message:`Gate "${t}" on "${e}" binds release ${n}, and the ci tags can't be judged: ${m instanceof Error?m.message:String(m)} [declaration-invalid]`,hint:"Fix ci.green in chant.workspace.json at base; chant workspace check names the problem."})),!0}let p=c(u,d);if(!p)return!1;let f=s((await i({cwd:o}).catch(()=>({cuts:[]}))).cuts).get(n)??null;return console.error($e(l({releaseDigest:n,label:f},p,`Clear the pending gate with \`chant approve ${e} ${t} --expire\`, then promote a release cut from a green commit: \`chant ci last-green\` names the newest, and \`chant release list\` marks the revoked releases.`))),!0}async function T6(e,t,n){let o=await xxe(e,t,n,!1);return"statement"in o?{ok:!1}:o}async function Urt(e,t,n){let o=await xxe(e,t,n,!0);return"statement"in o?o.statement:null}async function xxe(e,t,n,o){if(!o&&Ar())return console.error($e({message:`Cannot record the approval of "${t}": ${gi} is set, so nothing is written to chant/lifecycle`,hint:`Unset ${gi} to approve the gate.`})),{ok:!1};let{ops:r}=await Fl(),i=vhe([...r.values()].map(W=>W.config),e,t);!i&&!r.has(e)&&e!==mm&&e!==gm&&e!==hm&&e!==tb&&e!==ul&&e!==bi&&console.error(ur({message:`Op "${e}" was not found among discovered *.op.ts declarations \u2014 recording the resolution anyway`}));try{await Hr()}catch(W){return console.error($e({message:`Cannot record the approval: ${W instanceof Error?W.message:String(W)}`,hint:"The pending fact this answers lives on that branch; appending without it would drop it."})),{ok:!1}}if(i){let W=Nn((await yr(i.op)).pending,i.gate);if(W&&!Vn(W,new Date().toISOString()))return console.error($e({message:`Gate "${t}" on "${e}" is now gate "${i.gate}" on "${i.op}", which lists it as an alias, and "${i.gate}" has a standing pending fact`,hint:`Approve that gate instead: chant approve ${i.op} ${i.gate}`})),{ok:!1};console.error(In(`Gate "${t}" on "${e}" is an alias of gate "${i.gate}" on "${i.op}": the next run of ${i.op} counts this approval there while the pending fact it answers stands and the plan is the same.`))}let s=n.url??pl();if(s&&!JE(s))return console.error($e({message:`--url must be an absolute http/https URL (got "${s}")`,hint:"Pass the PR/MR link, or omit --url and put prose in --note."})),{ok:!1};let a=await yr(e),c=W=>W.some(q=>q.gate===t&&q.environment!==void 0)&&n.environment!==void 0?W.filter(q=>q.environment===n.environment):W,l=Nn(c(a.pending),t),u=l?.environment,d;if(n.plan!==void 0){if(!tS(n.plan))return console.error($e({message:`--plan must be a plan digest ("jcs1-sha256:" or "sha256:", then 64 hex characters), got "${n.plan}"`,hint:"Copy it from the gated run's `plan :` line, or from the pending-gate summary. It is not a plan file path."})),{ok:!1};d=n.plan}else{if(!l)return console.error($e({message:n.environment!==void 0&&a.pending.some(W=>W.gate===t&&W.environment!==void 0)?`Gate "${t}" on "${e}" has no pending fact in environment "${n.environment}", so there is no plan to approve`:`Gate "${t}" on "${e}" has no pending fact, so there is no plan to approve`,hint:`Run \`chant run ${e}\` first \u2014 it plans, stops at the gate, and records the plan this approval would be for. To approve a plan you already have the digest for, pass \`--plan <digest>\`.`})),{ok:!1};d=l.planDigest}let p=l?.checkpointDigest!==void 0&&Xe(d,l.planDigest)?l.checkpointDigest:void 0,f=l?.releaseDigest!==void 0&&Xe(d,l.planDigest)?l.releaseDigest:void 0,m=l?.changeSet!==void 0&&Xe(d,l.planDigest)?l.changeSet:void 0;if(l?.releaseDigest!==void 0&&await Brt(e,t,l.releaseDigest,n.cwd??process.cwd()))return{ok:!1};let g=n.origin??Ns(),h=await yr(e),w=Nn(c(h.pending),t);if(bo(g)&&(w?.neverOverMcp||r.get(e)?.config.neverOverMcp))return console.error($e({message:`Gate "${t}" on "${e}" is never resolved over ${g==="acp"?"ACP":"MCP"}`,hint:`Approvals belong to people: \`chant approve ${e} ${t}\` at a shell.`})),{ok:!1};if(w?.answer)return console.error($e({message:`Gate "${t}" on "${e}" asks decision point ${w.answer.point}, so its answer passes the gate, not an approval`,hint:`Answer the question: \`chant workspace points answer ${w.answer.id} --answer <value> --by <name>\`, then run \`chant run ${e}\` again.`})),{ok:!1};let k=UG(w?.origin,g);if(k&&!n.allowSameOrigin)return console.error($e({message:`Gate "${t}" on "${e}" cannot be resolved from here: ${k}`,hint:`Approve it from a channel the run did not come from \u2014 \`chant approve ${e} ${t}\` at a shell is the usual one. If resolving from the same channel genuinely is the intent, pass --allow-same-origin, which records that it was deliberate.`})),{ok:!1};let v=n.relayedBy?.trim();if(n.relayedBy!==void 0&&(!v||/[\r\n]/.test(v)))return console.error($e({message:`--relayed-by needs one principal on one line (got ${JSON.stringify(n.relayedBy)})`,hint:"Name who relayed the approval, such as --relayed-by github:<login> or a principal the signers file lists."})),{ok:!1};let b=n.actor??(bo(g)?rb:process.env.GITHUB_ACTOR??process.env.GITLAB_USER_LOGIN??process.env.USER??"unknown"),$={kind:n.agent||bo(g)?"agent":"human",...n.roles&&n.roles.length>0?{roles:[...new Set(n.roles)]}:{}},E=n.cwd??process.cwd(),O=await Promise.resolve().then(()=>(kd(),DW)),{scopeSource:P}=await Promise.resolve().then(()=>(Ro(),Eb)),I=P(E);try{O.refuseUnidentified(I,[b],n.actor!==void 0?"--actor":"the approver"),v&&O.refuseUnidentified(I,[v],"--relayed-by")}catch(W){if(!(W instanceof O.IdentityError))throw W;return console.error($e({message:`Gate "${t}" on "${e}" was not approved: ${W.message}`,hint:"Pass --actor <forge identity or signer>, as the surface that signed the person in maps them, for example --actor github:<login>."})),{ok:!1}}let S=(W,K)=>(console.error($e({message:`Gate "${t}" on "${e}" was not approved: ${W}`,...K?{hint:K}:{}})),{ok:!1});if(n.signature!==void 0&&n.sign!==void 0)return S("--sign signs here and --signature brings a signature made elsewhere; pass one of them");if(n.at!==void 0&&!o&&n.signature===void 0)return S("--at sets the time of a statement signed elsewhere, so it goes with --statement or --signature");if(n.signature!==void 0&&n.at===void 0)return S("--signature needs --at <timestamp>, the statement's time, since the signature covers it",`Pass the timestamp \`chant approve ${e} ${t} --statement\` printed.`);if(n.binding!==void 0){if(!o&&n.signature===void 0&&n.sign===void 0)return S("--binding is a line the approver's signature covers, so it goes with --statement, --signature or --sign");let W=nxe(n.binding);if(W!==null)return S(`--binding takes one line of printable text, and ${W}`)}let T=new Date().toISOString();if(n.at!==void 0){let W=Date.parse(n.at);if(!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(n.at)||Number.isNaN(W)||new Date(W).toISOString()!==n.at)return S(`--at takes a UTC time as chant writes one, such as ${T}, not ${JSON.stringify(n.at)}`);if(W>Date.now()+zrt)return S(`--at ${n.at} is in the future`);if(l&&n.at<l.timestamp)return S(`--at ${n.at} is before the pending fact it answers (${l.timestamp}), and a run counts only approvals newer than that`,`Take a fresh statement: chant approve ${e} ${t} --statement.`);T=n.at}let F={op:e,gate:t,...u!==void 0?{environment:u}:{},...d!==void 0?{planDigest:d}:{},resolvedBy:b,...v?{relayedBy:v}:{},timestamp:T,...p!==void 0?{checkpointDigest:p}:{},...n.binding!==void 0?{binding:n.binding}:{}};if(o){let{CHANT_VERSION:W}=await Promise.resolve().then(()=>(MO(),Ire));return{statement:rxe(F,W)}}let L=O.gateAdmissionFrom(I,t);if(L&&n.sign===void 0&&n.signature===void 0)return console.error($e({message:`Gate "${t}" needs a signed approval: chant.workspace.json at base names it in identity.gates`+(L.requirement.class!==null?`, from the class ${L.requirement.class}`:"")+", and this approval is not signed",hint:`chant approve ${e} ${t} --actor <principal> --sign [<key file>], with a key ${I.policy.signersPath} at base lists for that principal, or --signature <file> --at <timestamp> with a signature made elsewhere over the statement --statement prints.`})),{ok:!1};let C;if(n.signature!==void 0){let W=Hrt(n.signature,F,I.policy,E);if("refused"in W)return S(W.refused);C=W.seal}if(n.sign!==void 0){let{resolveSigningKey:W,sealGateApproval:K,gateSealVersion:q,SealError:ee}=await Promise.resolve().then(()=>($g(),xg));try{let X=W(n.sign,E);try{let Ce=q(F);C={...K(X.file,F),...Ce!==1?{version:Ce}:{}}}finally{X.cleanup()}}catch(X){if(!(X instanceof ee))throw X;return console.error($e({message:`Gate "${t}" on "${e}" was not approved: ${X.message}`})),{ok:!1}}}if(L){let W=L.refuses({op:e,gate:t,...u!==void 0?{environment:u}:{},...d!==void 0?{planDigest:d}:{},resolvedBy:b,...v?{relayedBy:v}:{},timestamp:T,...p!==void 0?{checkpointDigest:p}:{},...n.binding!==void 0?{binding:n.binding}:{},seal:C});if(W!==null)return console.error($e({message:`Gate "${t}" on "${e}" was not approved: ${W}`,hint:`identity.gates.${t} in chant.workspace.json at base counts only an approval signed by a key ${I.policy.signersPath} lists for the approver`+(L.requirement.class!==null?`, who holds the role of the class ${L.requirement.class}`:"")+"."})),{ok:!1}}let _=w?.approval,M=pi({signers:I.policy,roles:I.policy.roles}),J=M({version:1,op:e,gate:t,...u!==void 0?{environment:u}:{},...d!==void 0?{planDigest:d}:{},resolvedBy:b,...v?{relayedBy:v}:{},timestamp:T,...p!==void 0?{checkpointDigest:p}:{},...n.binding!==void 0?{binding:n.binding}:{},...C?{seal:C}:{}}).roles,Y;if(_?.policy)try{let K=await(n.evaluator??await gG(_.policy.lexicon)).evaluateGatePolicy(_.policy,hG({op:e,gate:t,resolvedBy:b,approver:$,roles:J,...d!==void 0?{planDigest:d}:{},..._.context?{context:_.context}:{}}));Y={policy:_.policy.name,version:_.policy.version,mode:_.mode,contextDigest:zw(_.context),decision:K.decision,determining:K.determining,errors:K.errors}}catch(W){return console.error($e({message:`Gate "${t}" on "${e}" declares policy "${_.policy.name}", which could not be evaluated: ${W instanceof Error?W.message:String(W)}`,hint:`Install the ${_.policy.lexicon} lexicon in this project, or approve from a checkout that has it.`})),{ok:!1}}let{record:N}=await ib({op:e,gate:t,resolvedBy:b,...v?{relayedBy:v}:{},timestamp:T,...C?{seal:C}:{},approver:$,...Y?{policyDecision:Y}:{},...n.note?{note:n.note}:{},...s?{url:s}:{},...d!==void 0?{planDigest:d}:{},...p!==void 0?{checkpointDigest:p}:{},...n.binding!==void 0?{binding:n.binding}:{},...u!==void 0?{environment:u}:{},...f!==void 0?{releaseDigest:f}:{},...m!==void 0?{changeSet:m}:{},...l?.gitSha?{gitSha:l.gitSha}:{},...l?.runId?{runId:l.runId}:{},origin:g,...k&&n.allowSameOrigin?{sameOriginOverride:!0}:{}}),z=await kxe(`The resolution is recorded locally on ${NR}. Until it reaches the remote, a run in another checkout will not see it.`);console.error(Rh(`Gate "${t}" on "${e}" resolved by ${N.resolvedBy}`+(N.relayedBy?`, relayed by ${N.relayedBy},`:"")+` at ${N.timestamp}`+(N.url?` (${N.url})`:"")+(N.seal?`, signed with ${N.seal.kind===Es?"passkey ":""}${N.seal.key}`:"")+z.suffix)),N.binding!==void 0&&console.error(In(`The signature also binds ${JSON.stringify(N.binding)} (--binding).`)),N.planDigest&&console.error(In(`This approves the plan ${N.planDigest}`+(N.environment!==void 0?` in environment "${N.environment}"`:"")+(N.releaseDigest!==void 0?` for release ${N.releaseDigest}`:"")+", and only that plan. A run whose fresh plan differs refuses rather than applying it.")),N.checkpointDigest&&console.error(In(`The next run resumes at this gate from run ${l?.runId??"(unknown)"}'s checkpoint ${N.checkpointDigest}, after it plans again. A moved plan or another commit starts it at the first phase.`));let H=($.roles??[]).filter(W=>!J.includes(W));if(H.length>0&&console.error(In(`--role ${H.join(", ")} is recorded on the approval and trusted by nothing: a gate's quorum and policy read ${N.resolvedBy}'s roles from .chant/trust.json at base, and only for an approval sealed by a signer listed at base (chant approve --sign).`)),_)for(let W of Vrt(_,N,h.resolutions,w,h.pending,M))console.error(In(W));return{ok:!0,record:N,pushed:z.pushed}}function Hrt(e,t,n,o){let r;try{r=e==="-"?vxe(0,"utf-8"):vxe(Wrt(o,e),"utf-8")}catch(l){return{refused:`--signature ${e} can't be read: ${l instanceof Error?l.message:String(l)}`}}let i=oxe(r);if("problem"in i)return{refused:`--signature ${e}: ${i.problem}`};let s=i.kind==="ssh"?{signer:t.resolvedBy,key:"",signature:i.signature}:{kind:Es,signer:t.resolvedBy,key:i.assertion.id,signature:i.assertion.signature,clientDataJSON:i.assertion.clientDataJSON,authenticatorData:i.assertion.authenticatorData},a=Os(n,t.resolvedBy,s,Wr(t));if(!a.ok)return{refused:a.unlisted?`${t.resolvedBy} has no ${i.kind==="ssh"?`key in ${n.signersPath}`:"passkey in .chant/trust.json"} at base, so a signature made elsewhere can't be checked`:`the ${i.kind==="ssh"?"ssh signature":"passkey's assertion"} does not verify for ${t.resolvedBy} over this approval's statement: ${a.reason}`};let c=Jc(t);return{seal:{...s,key:a.key,...c!==1?{version:c}:{}}}}function qrt(e){return/^[\w@%+=:,./-]+$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}function Vrt(e,t,n,o,r=o?[o]:[],i=Ia){let s=[],a=t.policyDecision;if(a){let p=a.determining.length>0?` (${a.determining.join(", ")})`:"",f=e.mode==="enforce"?a.decision==="allow"?"In enforce mode this permit passes the gate on its own.":"In enforce mode only a permit passes the gate on its own, so this approval counts only toward the quorum.":"The gate is in log-only mode, so the decision is recorded and does not change the outcome.";s.push(`Policy "${a.policy}" ${a.version}: ${a.decision}${p}. ${f}`);for(let m of a.errors)s.push(`Policy evaluation error: ${m}`)}let c=o?.timestamp??new Date(0).toISOString(),l=o&&Xe(o.planDigest,t.planDigest)?Sl(r,o):c,u=$l([...n,t],t.gate,c,t.planDigest,e,l,i),d=u.counted.map(p=>p.resolvedBy).join(", ")||"none yet";if(Array.isArray(e.quorum))for(let p of u.rules??[])s.push(`Quorum: ${al(p)}.`);else{let p=ui(e.quorum)[0],f=p?.roles?` with role ${p.roles.join(" or ")}`:"";s.push(`Quorum: ${u.counted.length} of ${u.need} human approval(s)${f} for this plan (${d}).`)}if(!u.counted.includes(t)){let p=ui(e.quorum).flatMap(f=>f.roles??[]);s.push(zm(t).kind==="agent"?"An agent's approval does not count toward the quorum.":i(t).proven?`This approval does not count toward the quorum: .chant/trust.json at base gives ${t.resolvedBy} none of its roles (${[...new Set(p)].join(", ")}).`:"This approval does not count toward the quorum: its roles are read from .chant/trust.json at base, and only for an approval sealed by a signer listed at base (chant approve --sign).")}return s}var NR,zrt,I6=x(()=>{"use strict";Zs();YC();dl();Cr();Ft();nm();Jr();Mo();qr();oA();lt();sm();Ds();Hi();ixe();Qn();NR="chant/lifecycle";zrt=300*1e3});_0();var D6=new Set(["--help","--open","--version","--agents","--agent","--all-projects","--all","--force","--fix","--watch","--verbose","--live","--overlay","--explain","--owned","--verbatim","--skip-undeclarable","--apply-rewrites","--write","--strict","--validate","--use-composites","--composites","--stacks","--components","--pr-build","--pr-env","--up","--down","--include-dependents","--cross-root","--local","--json","--progress-json","--events-json","--follow","--update-snapshot","--update-baseline","--run-examples","--check","--bump","--no-release-record","--deploy-unchanged","--no-record","--fold","--no-fold","--no-cache","--no-build","--sandbox","--yes","--confirm-prod","--once","--rerun-failed","--setup-key","--trust","--unsigned","--in-place","--require-runner-start","--require-clouds","--no-push","--list","--no-require-review","--expire","--check-live","--stream","--check-snapshot","--fail-on-drift","--durable-requests","--skip-mcp","--read-only","--mcp-read-only","--propose","--current","--uncommitted","--allow-code","--allow-skip","--allow-unsigned","--override-green","--require-provenance","--root-only","--generated","--decide","--record-plans","--approval-status","--waves-outcome","--loopback","--artifacts","--push","--only"]);function N6(e){e=e.slice();let t={command:"",path:".",extraPositional:void 0,extraPositional2:void 0,output:void 0,format:"",force:void 0,fix:!1,lexicon:void 0,template:void 0,watch:!1,verbose:!1,help:!1,param:void 0,paramsFile:void 0,report:void 0,local:void 0,profile:void 0,json:void 0,live:!1,migrateFrom:void 0,migrateTo:void 0,emit:void 0,strict:!1,validate:!1,useComposites:!1,reportFile:void 0,skill:void 0,skipMcp:void 0,readOnly:void 0,mcpReadOnly:void 0,propose:void 0,src:void 0,env:void 0},n=e.indexOf("--");e=n<0?C0(e,D6):[...C0(e.slice(0,n),D6),...e.slice(n)];let o=!1,r=s=>{t.command&&(t.positionals??=[]).push(s),t.command?t.path==="."?t.path=s:t.extraPositional?t.extraPositional2=s:t.extraPositional=s:t.command=s},i=0;for(;i<e.length;){let s=e[i];if(o)r(s);else if(s==="--")o=!0;else if(s==="--help"||s==="-h")t.help=!0;else if(s==="--version"||s==="-V")t.version=!0;else if(s==="--output"||s==="-o")t.output=e[++i];else if(s==="--format"||s==="-f")t.format=e[++i];else if(s==="--lexicon"||s==="-d")t.lexicon=e[++i];else if(s==="--template"||s==="-t")t.template=e[++i];else if(s==="--force")t.force=!0;else if(s==="--fix")t.fix=!0;else if(s==="--watch"||s==="-w")t.watch=!0;else if(s==="--verbose"||s==="-v")t.verbose=!0;else if(s==="--profile"||s==="-p")t.profile=e[++i];else if(s==="--report"){let a=e[i+1];a&&!a.startsWith("-")?(t.reportFile=a,i++):t.report=!0}else if(s==="--live")t.live=!0;else if(s==="--overlay")t.overlay=!0;else if(s==="--between"){if(t.betweenA=e[++i],t.betweenB=e[++i],!t.betweenA||!t.betweenB)throw new Error("--between needs two snapshot refs: --between <refA> <refB>")}else if(s==="--traffic"){let a=e[++i];if(!a)throw new Error('--traffic needs a level, passed to the engine verbatim: --traffic "100 rps, p50"');t.traffic=a}else if(s==="--overlay-anchor"){let a=e[++i];if(a!=="source"&&a!=="live")throw new Error(`--overlay-anchor must be 'source' or 'live', got '${a}'`);t.overlayAnchor=a}else if(s==="--scan"){let a=e[++i];if(a===void 0||a==="--"||a.startsWith("--"))throw new Error("--scan needs a directory: --scan <dir>");(t.scanDirs??=[]).push(a)}else if(s==="--from")t.migrateFrom=e[++i];else if(s==="--kustomize")t.kustomize=e[++i];else if(s==="--parser-option"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--parser-option needs key or key=value: --parser-option acceptLossyV1");(t.parserOption??=[]).push(a)}else if(s==="--tag"){let a=e[++i];if(!a||a.startsWith("-")||!a.includes("="))throw new Error("--tag needs key=value: --tag team=payments");(t.selectTags??=[]).push(a)}else if(s==="--type")t.selectType=e[++i];else if(s==="--name")t.selectName=e[++i];else if(s==="--owned")t.owned=!0;else if(s==="--namespace"){if(t.namespace=e[++i],!t.namespace||t.namespace.startsWith("-"))throw new Error("--namespace needs a namespace: --namespace <ns>")}else if(s==="--verbatim")t.verbatim=!0;else if(s==="--skip-undeclarable")t.skipUndeclarable=!0;else if(s==="--state")t.statePath=e[++i],t.statePath!==void 0&&(t.statePaths??=[]).push(t.statePath);else if(s==="--state-dir"){if(t.stateDir=e[++i],!t.stateDir||t.stateDir.startsWith("-"))throw new Error("--state-dir needs a directory: --state-dir <dir>")}else if(s==="--wave-size"){let a=e[++i],c=Number(a);if(!Number.isInteger(c)||c<1)throw new Error(`--wave-size needs a whole number from 1: got "${a??""}"`);t.waveSize=c}else if(s==="--all")t.all=!0;else if(s==="--select")t.selectAddress=e[++i];else if(s==="--live-name")t.liveName=e[++i];else if(s==="--apply-rewrites")t.applyRewrites=!0;else if(s==="--stack")t.carveStack=e[++i];else if(s==="--write")t.write=!0;else if(s==="--write-source")t.writeSource=!0;else if(s==="--to")t.migrateTo=e[++i];else if(s==="--emit")t.emit=e[++i];else if(s==="--dry-run")t.dryRun=!0;else if(s==="--drill")t.drill=!0;else if(s==="--yes")t.yes=!0;else if(s==="--push")t.push=!0;else if(s==="--confirm-prod")t.confirmProd=!0;else if(s==="--strict")t.strict=!0;else if(s==="--validate")t.validate=!0;else if(s==="--use-composites")t.useComposites=!0;else if(s==="--skill")t.skill=e[++i];else if(s==="--skip-mcp")t.skipMcp=!0;else if(s==="--read-only")t.readOnly=!0;else if(s==="--mcp-read-only")t.mcpReadOnly=!0;else if(s==="--propose")t.propose=!0;else if(s==="--src")t.src=e[++i];else if(s==="--env")t.env=e[++i];else if(s==="--port"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--port needs a port: --port <container-port>=<host-port>");(t.port??=[]).push(a)}else if(s==="--image"){if(t.image=e[++i],!t.image||t.image.startsWith("-"))throw new Error("--image needs an image reference: --image <name>:<tag>");(t.images??=[]).push(t.image)}else if(s==="--network"){if(t.network=e[++i],!t.network||t.network.startsWith("-"))throw new Error("--network needs a Docker network name: --network <name>")}else if(s==="--setting"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--setting needs a value: --setting <KEY>=<VALUE>");(t.setting??=[]).push(a)}else if(s==="--loopback")t.loopback=!0;else if(s==="--promote-to"){if(t.promoteTo=e[++i],!t.promoteTo||t.promoteTo.startsWith("-"))throw new Error("--promote-to needs an environment: --promote-to <env>")}else if(s==="--tier")t.tier=e[++i];else if(s==="--agents")t.agents=!0;else if(s==="--scope")t.scope=e[++i];else if(s==="--all-projects")t.allProjects=!0;else if(s==="--runtime")t.runtime=e[++i];else if(s==="--fail-on")t.failOn=e[++i];else if(s==="--max-files")t.maxFiles=Number(e[++i]);else if(s==="--theme")t.theme=e[++i];else if(s==="--stacks")t.stacks=!0;else if(s==="--components")t.components=!0;else if(s==="--generate")t.generate=e[++i];else if(s==="--spec")t.opsSpec=e[++i];else if(s==="--dump-outputs")t.dumpOutputs=e[++i];else if(s==="--digest-file")t.digestFile=e[++i];else if(s==="--seed-outputs")(t.seedOutputs??=[]).push(e[++i]);else if(s==="--keep")t.keepLocks=!0;else if(s==="--runs"||s==="--plans"||s==="--wave-outputs"){let a=e[++i];if(a===void 0||a.startsWith("-"))throw new Error(`${s} needs a file`);t[{"--runs":"runsFile","--plans":"plansFile","--wave-outputs":"waveOutputs"}[s]]=a}else if(s==="--detail")t.detail=Number(e[++i]);else if(s==="--lens")t.lens=e[++i];else if(s==="--explain")t.explain=!0;else if(s==="--show")t.show=e[++i];else if(s==="--count-by"){if(t.countBy=e[++i],!t.countBy||t.countBy.startsWith("-"))throw new Error("--count-by needs a grouping: --count-by kind, --count-by module or --count-by attr:<name>")}else if(s==="--up")t.up=!0;else if(s==="--down")t.down=!0;else if(s==="--node-sizes")t.nodeSizes=e[++i];else if(s==="--layout-engine")t.layoutEngine=e[++i];else if(s==="--base")t.base=e[++i];else if(s==="--head")t.head=e[++i];else if(s==="--include-dependents")t.includeDependents=!0;else if(s==="--cross-root")t.crossRoot=!0;else if(s==="--dependents-of"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--dependents-of needs a member name: --dependents-of <member>");t.dependentsOf=a}else if(s==="--pin"){let a=e[++i];if(!a||a.startsWith("-")||!a.includes("="))throw new Error("--pin needs a member and a release: --pin <member>=<label|digest>");(t.pins??=[]).push(a)}else if(s==="--from-affected")t.fromAffected=e[++i];else if(s==="--gate")t.gate=e[++i];else if(s==="--wave-gate"){if(t.waveGate=e[++i],!t.waveGate||t.waveGate.startsWith("-"))throw new Error("--wave-gate needs a gate name: --wave-gate <name>")}else if(s==="--wave"){let a=e[++i],c=Number(a);if(!Number.isInteger(c)||c<1)throw new Error(`--wave needs a wave number from 1: got "${a??""}"`);t.wave=c}else if(s==="--decide")t.decide=!0;else if(s==="--record-plans")t.recordPlans=!0;else if(s==="--approval-status")t.approvalStatus=!0;else if(s==="--waves-outcome")t.wavesOutcome=!0;else if(s==="--group"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--group needs a job group's name: --group <name>");t.group=a}else if(s==="--share"){let a=e[++i],c=Number(a);if(!Number.isInteger(c)||c<1)throw new Error(`--share needs a share number from 1: got "${a??""}"`);t.share=c}else if(s==="--target"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--target needs an address: --target <component>:<address>, or on pr-plan --target <address>");(t.targets??=[]).push(a)}else if(s==="--refresh")t.refresh=!0;else if(s==="--target-dependents")t.targetDependents=!0;else if(s==="--comment-targets")t.commentTargets=!0;else if(s==="--parallelism"){let a=e[++i],c=Number(a);if(!Number.isInteger(c)||c<1)throw new Error(`--parallelism needs a whole number of 1 or more: got "${a??""}"`);t.parallelism=c}else if(s==="--canary"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--canary needs a component name: --canary <name>[,<name>...]");(t.canary??=[]).push(...a.split(",").map(c=>c.trim()).filter(Boolean))}else if(s==="--pr"){let a=e[++i],c=Number(a);if(!Number.isInteger(c)||c<1)throw new Error(`--pr needs a pull or merge request number: got "${a??""}"`);t.pr=c,(t.prs??=[]).push(c)}else if(s==="--channel"){if(t.channel=e[++i],!t.channel||!/^[A-Za-z][A-Za-z0-9._-]*$/.test(t.channel))throw new Error(`--channel needs a channel name, such as next or hotfix: got "${t.channel??""}"`)}else if(s==="--forge"){if(t.forge=e[++i],!t.forge||t.forge.startsWith("-"))throw new Error("--forge needs a forge: --forge github|gitlab|forgejo")}else if(s==="--require-clouds")t.requireClouds=!0;else if(s==="--require-review")t.requireReview=!0;else if(s==="--list")t.list=!0;else if(s==="--stage"){if(t.lockStage=e[++i],!t.lockStage||t.lockStage.startsWith("-"))throw new Error("--stage needs plan, apply or lock: --stage <stage>")}else if(s==="--alive"){if(t.aliveRun=e[++i],!t.aliveRun||t.aliveRun.startsWith("-"))throw new Error("--alive needs a run id: --alive <run>")}else if(s==="--beat"){if(t.beatRun=e[++i],!t.beatRun||t.beatRun.startsWith("-"))throw new Error("--beat needs a run id: --beat <run> --parent <pid>")}else if(s==="--parent"){let a=Number(e[++i]);if(!Number.isInteger(a)||a<1)throw new Error("--parent needs a process id: --parent <pid>");t.parentPid=a}else if(s==="--run"){if(t.unlockRun=e[++i],!t.unlockRun||t.unlockRun.startsWith("-"))throw new Error("--run needs a run id: --run <id>")}else if(s==="--from-report"){if(t.fromReport=e[++i],!t.fromReport||t.fromReport.startsWith("-"))throw new Error("--from-report needs a report file: --from-report <pr-plan.json>")}else if(s==="--report-url"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--report-url needs a URL: --report-url s3://<bucket>/<prefix>, gs://<bucket>/<prefix>, az://<account>/<container>/<prefix> or file://<directory>");t.reportUrl=a}else if(s==="--result"){if(t.planResult=e[++i],!t.planResult||t.planResult.startsWith("-"))throw new Error("--result needs the plan job's result: --result success|failure|cancelled")}else if(s==="--no-status")t.noStatus=!0;else if(s==="--status-url"){if(t.statusUrl=e[++i],!t.statusUrl||t.statusUrl.startsWith("-"))throw new Error("--status-url needs a URL template: --status-url https://host/reports/{key}")}else if(s==="--override-green")t.overrideGreen=!0;else if(s==="--allow-unsigned")t.allowUnsigned=!0;else if(s==="--require-provenance")t.requireProvenance=!0;else if(s==="--pr-loop")t.prLoop=!0;else if(s==="--green")t.green=!0;else if(s==="--before-merge")t.beforeMerge=!0;else if(s==="--requires"){let a=e[++i];if(a===void 0||a.startsWith("-"))throw new Error("--requires needs a list of checks: --requires approved,mergeable,undiverged,checks");t.requires=a.split(",").map(c=>c.trim()).filter(Boolean)}else if(s==="--respond"){let a=e[++i];if(a===void 0||a.startsWith("-"))throw new Error("--respond needs a list of responses: --respond wave-refused=diff,apply-failed=off,description=check");t.respond=[...t.respond??[],a]}else if(s==="--decide-backend"){let a=e[++i];if(a===void 0||a.startsWith("-"))throw new Error("--decide-backend needs the name of a decide.backends entry");t.decideBackend=a}else if(s==="--decide-model"){let a=e[++i];if(a===void 0||a.startsWith("-"))throw new Error("--decide-model needs a model id");t.decideModel=a}else if(s==="--merge"||s==="--merge-token-env"||s==="--merge-method"){let a=e[++i];if(a===void 0||a.startsWith("-"))throw new Error(`${s} needs a value: --merge manual|auto, --merge-token-env <VAR>, --merge-method merge|squash|rebase`);s==="--merge"?t.merge=a:s==="--merge-token-env"?t.mergeTokenEnv=a:t.mergeMethod=a}else if(s==="--apply-before-merge")t.applyBeforeMerge=!0;else if(s==="--apply-on-merge")t.applyOnMerge=!0;else if(s==="--action-job")t.actionJob=!0;else if(s==="--preview-comment")t.previewComment=!0;else if(s==="--pr-env")t.prEnv=!0;else if(s==="--pr-runner"){let a=e[++i]??"",c=/^(plan|apply|default)=(.+)$/.exec(a);if(!c)throw new Error(`--pr-runner needs <stage>=<label>[,<label>...], the stage plan, apply or default: got "${a}"`);let l=c[2].split(",").map(u=>u.trim()).filter(Boolean);if(l.length===0)throw new Error(`--pr-runner ${c[1]} names no label`);(t.prRunners??={})[c[1]]=l}else if(s==="--pr-variable"||s==="--pr-secret"){let a=e[++i]??"",c=a.indexOf("=");if(c<1)throw new Error(`${s} needs <NAME>=<${s==="--pr-secret"?"secret":"value"}>: got "${a}"`);let l=s==="--pr-secret"?t.prSecrets??={}:t.prVariables??={};l[a.slice(0,c)]=a.slice(c+1)}else if(s==="--pr-build")t.prBuild=!0;else if(s==="--build-command"){let a=e[++i];if(a===void 0||a==="")throw new Error("--build-command needs a shell line: --build-command '<line>'");t.ciBuildCommand=a}else if(s==="--land")t.ciLand=!0;else if(s==="--pr-build-command"){let a=e[++i];if(a===void 0||a==="")throw new Error("--pr-build-command needs a shell line: --pr-build-command '<line>'");t.prBuildCommand=a}else if(s==="--before-script"){let a=e[++i];if(a===void 0||a==="")throw new Error("--before-script needs a shell line: --before-script '<line>'");(t.beforeScript??=[]).push(a)}else if(s==="--resume"){let a=e[i+1];a===void 0||a.startsWith("-")?t.resumeRun=!0:t.resume=e[++i]}else if(s==="--local")t.local=!0;else if(s==="--json")t.json=!0;else if(s==="--progress-json")t.progressJson=!0;else if(s==="--events-json")t.eventsJson=!0;else if(s==="--follow")t.follow=!0;else if(s==="--gated-exit")t.gatedExit=Number(e[++i]);else if(s==="--durable-requests")t.durableRequests=!0;else if(s==="--update-snapshot")t.updateSnapshot=!0;else if(s==="--update-baseline")t.updateBaseline=!0;else if(s==="--deep")t.deep=!0;else if(s==="--at")t.at=e[++i];else if(s==="--capability-view")t.capabilityView=!0;else if(s==="--capabilities")t.capabilities=!0;else if(s==="--snapshot"){if(t.snapshot=e[++i],!t.snapshot||t.snapshot.startsWith("-"))throw new Error("--snapshot needs a snapshot ref: --snapshot latest")}else if(s==="--kind"){if(t.kind=e[++i],!t.kind||t.kind.startsWith("-"))throw new Error("--kind needs a kind file: --kind <path>");(t.kinds??=[]).push(t.kind)}else if(s==="--composites")t.composites=!0;else if(s==="--intent"){let a=e[i+1];if(a!==void 0&&!a.startsWith("-"))t.intent=e[++i];else if(e.includes("--record"))t.intent="";else throw new Error("--intent needs a region: --intent <path[:start-end]|path#symbol|member/node|sha>, or --intent --record <id>")}else if(s==="--follow-squash")t.followSquash=!0;else if(s==="--forge-issues")t.forgeIssues=!0;else if(s==="--record"){if(t.record=e[++i],!t.record||t.record.startsWith("-"))throw new Error("--record needs a record id: --record <id>")}else if(s==="--path"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--path needs a path: --path <path>");(t.paths??=[]).push(a)}else if(s==="--worktree")t.worktree=!0;else if(s==="--max-bytes"){let a=Number(e[++i]);if(!Number.isInteger(a)||a<1)throw new Error("--max-bytes needs a whole number of bytes above 0");t.maxBytes=a}else if(s==="--changes"){if(t.changes=e[++i],!t.changes||t.changes.startsWith("-"))throw new Error("--changes needs a range: --changes <base>..<head>")}else if(s==="--severity"){if(t.severity=e[++i],!t.severity||t.severity.startsWith("-"))throw new Error("--severity needs off, warn or fail")}else if(s==="--current")t.current=!0;else if(s==="--uncommitted")t.uncommitted=!0;else if(s==="--set"){if(t.set=e[++i],!t.set||t.set.startsWith("-")&&t.set!=="-")throw new Error("--set needs a JSON file, or - for standard input: --set <file|->")}else if(s==="--cover"){if(t.cover=e[++i],!t.cover||t.cover.startsWith("-"))throw new Error("--cover needs a PNG, JPEG or WebP file: --cover <image>")}else if(s==="--cover-path"){if(t.coverPath=e[++i],!t.coverPath||t.coverPath.startsWith("-"))throw new Error("--cover-path needs a path from the workspace root: --cover-path <path>")}else if(s==="--records")t.records=!0;else if(s==="--expect"){if(t.expect=e[++i],!t.expect||t.expect.startsWith("-"))throw new Error("--expect needs the record's digest, as records --json prints it: --expect <digest>")}else if(s==="--label"){if(t.label=e[++i],!t.label||t.label.startsWith("-"))throw new Error("--label needs the snapshot's name, such as a turn id: --label <text>")}else if(s==="--branch"){if(t.branch=e[++i],!t.branch||t.branch.startsWith("-"))throw new Error("--branch needs a branch name: --branch <branch>")}else if(s==="--security"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--security needs a group: --security verified-releases|supply-chain|who-ran-it|review-rules|isolated-runners");t.securityGroups=[...t.securityGroups??[],a]}else if(s==="--workflow"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--workflow needs a workflow's name: --workflow <name>");t.ciWorkflows=[...t.ciWorkflows??[],a]}else if(s==="--chant"){if(t.ciChant=e[++i],!t.ciChant||t.ciChant.startsWith("-"))throw new Error('--chant needs the command that runs chant, such as "npx tsx packages/core/src/cli/main.ts": --chant <command>')}else if(s==="--commit"){if(t.commit=e[++i],!t.commit||t.commit.startsWith("-"))throw new Error("--commit needs the commit the job runs at: --commit <sha>")}else if(s==="--pass-env"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--pass-env needs a variable's name, such as AWS_PROFILE: --pass-env <NAME>");(t.passEnv??=[]).push(a)}else if(s==="--secrets"){if(t.ciSecrets=e[++i],!t.ciSecrets||t.ciSecrets.startsWith("-"))throw new Error("--secrets needs the host's secrets file, a dotenv or JSON file only its owner can read: --secrets <file>")}else if(s==="--repo"){if(t.ciRepo=e[++i],!t.ciRepo||!/^[^/\s-][^/\s]*\/[^/\s]+$/.test(t.ciRepo))throw new Error("--repo needs the repository as owner/name: --repo <owner/repo>")}else if(s==="--run-index-limit"){let a=Number(e[++i]);if(!Number.isInteger(a)||a<1)throw new Error("--run-index-limit needs a whole number of runs, 1 or more: --run-index-limit <n>");t.runIndexLimit=a}else if(s==="--max-jobs"){let a=Number(e[++i]);if(!Number.isInteger(a)||a<1)throw new Error("--max-jobs needs a whole number of jobs, 1 or more: --max-jobs <n>");t.maxJobs=a}else if(s==="--author"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--author needs a forge login: --author <login>");(t.ciAuthors??=[]).push(a)}else if(s==="--rerun-failed")t.rerunFailed=!0;else if(s==="--install"){if(t.ciInstall=e[++i],!t.ciInstall||t.ciInstall.startsWith("-"))throw new Error('--install needs the install command, such as "npm install": --install <command>')}else if(s==="--token-secret"){if(t.ciTokenSecret=e[++i],!t.ciTokenSecret||t.ciTokenSecret.startsWith("-"))throw new Error("--token-secret needs a repository secret's name, such as CI_GREEN_TOKEN: --token-secret <NAME>")}else if(s==="--app-id-var"){if(t.ciAppIdVar=e[++i],!t.ciAppIdVar||t.ciAppIdVar.startsWith("-"))throw new Error("--app-id-var needs the Actions variable holding the App's id: --app-id-var <VAR>")}else if(s==="--app-key-secret"){if(t.ciAppKeySecret=e[++i],!t.ciAppKeySecret||t.ciAppKeySecret.startsWith("-"))throw new Error("--app-key-secret needs the secret holding the App's private key: --app-key-secret <NAME>")}else if(s==="--runner-key-secret"){if(t.ciRunnerKeySecret=e[++i],!t.ciRunnerKeySecret||t.ciRunnerKeySecret.startsWith("-"))throw new Error("--runner-key-secret needs the repository secret holding the runner key, such as CHANT_RUNNER_KEY: --runner-key-secret <NAME>")}else if(s==="--verdict"){if(t.verdict=e[++i],!t.verdict||t.verdict.startsWith("-"))throw new Error("--verdict needs agree, dissent or abstain")}else if(s==="--class"){if(t.runnerClass=e[++i],!t.runnerClass||t.runnerClass.startsWith("-"))throw new Error("--class needs runner or service: --class <class>")}else if(s==="--by"){if(t.by=e[++i],!t.by||t.by.startsWith("-"))throw new Error("--by needs the reviewer: --by <principal>");(t.bys??=[]).push(t.by)}else if(s==="--stale-notes")t.staleNotes=!0;else if(s==="--stale")t.stale=!0;else if(s==="--tip"){let a=e[++i];if(!a||!/^[0-9a-f]{40}$/.test(a))throw new Error(`--tip needs the target branch's full commit sha: got "${a??""}"`);t.tip=a}else if(s==="--open")t.open=!0;else if(s==="--inputs"){if(t.inputs=e[++i],!t.inputs||t.inputs.startsWith("-")&&t.inputs!=="-")throw new Error("--inputs needs a JSON file, - for standard input, or the JSON itself: --inputs <file|-|json>")}else if(s==="--candidates"){if(t.candidates=e[++i],!t.candidates||t.candidates.startsWith("-")&&t.candidates!=="-")throw new Error("--candidates needs a JSON file, - for standard input, or the JSON itself: --candidates <file|-|json>")}else if(s==="--response"){if(t.response=e[++i],!t.response||t.response.startsWith("-"))throw new Error("--response needs a JSON file: --response <file>")}else if(s==="--subject"){if(t.subject=e[++i],!t.subject||t.subject.startsWith("-"))throw new Error("--subject needs what the question is about, such as a work item id: --subject <id>")}else if(s==="--store"){let a=e[++i];if(a!=="tree"&&a!=="ledger")throw new Error("--store is tree (the answer kind's directory in the working tree) or ledger (chant/lifecycle): --store <tree|ledger>");t.store=a}else if(s==="--answer"){if(t.answer=e[++i],t.answer===void 0||t.answer==="")throw new Error("--answer needs one of the question's candidates: --answer <value>")}else if(s==="--sign"){let a=e[i+1];t.sign=a!==void 0&&!a.startsWith("-")?e[++i]:!0}else if(s==="--session"){if(t.session=e[++i],!t.session||t.session.startsWith("-"))throw new Error("--session needs a session id: --session <id>")}else if(s==="--prefix"){if(t.prefix=e[++i],!t.prefix||t.prefix.startsWith("-"))throw new Error("--prefix needs an id prefix: --prefix <prefix>")}else if(s==="--key"||s==="--check-id"||s==="--claim"||s==="--environment"||s==="--envelope"||s==="--threshold"){let a=e[++i];if(a===void 0||a.startsWith("-"))throw new Error(`${s} needs a value`);let c={"--key":"key","--check-id":"checkId","--claim":"claim","--environment":"environment","--envelope":"envelope","--threshold":"threshold"}[s];t[c]=a}else if(s==="--require"){if(t.require=e[++i],!t.require||t.require.startsWith("-"))throw new Error("--require needs a provenance level: --require attested")}else if(s==="--ambient")t.ambient=!0;else if(s==="--check-live")t.checkLive=!0;else if(s==="--check-snapshot")t.checkSnapshot=!0;else if(s==="--fail-on-drift")t.failOnDrift=!0;else if(s==="--run-examples")t.runExamples=!0;else if(s==="--pinned-digest")t.pinnedDigest=e[++i];else if(s==="--check")t.check=!0;else if(s==="--bump")t.bump=!0;else if(s==="--component")t.component=e[++i];else if(s==="--digest")t.digest=e[++i],t.digest!==void 0&&(t.digests??=[]).push(t.digest);else if(s==="--release-plan")t.releasePlanFile=e[++i];else if(s==="--release"){if(t.release=e[++i],!t.release||t.release.startsWith("-"))throw new Error("--release needs a release's label or digest: --release <label|digest>")}else if(s==="--build"){if(t.buildCommand=e[++i],!t.buildCommand)throw new Error("--build needs a shell command: --build '<command>'")}else if(s==="--deploy-unchanged")t.deployUnchanged=!0;else if(s==="--artifacts")t.artifacts=!0;else if(s==="--git-sha")t.gitSha=e[++i];else if(s==="--run-id")t.runId=e[++i];else if(s==="--actor")t.actor=e[++i];else if(s==="--approver")t.approver=e[++i];else if(s==="--statement")t.statement=!0;else if(s==="--signature"){if(t.signature=e[++i],!t.signature||t.signature.startsWith("-")&&t.signature!=="-")throw new Error("--signature needs a file holding the signature, or - for stdin: --signature <file|->")}else if(s==="--binding"){if(t.binding=e[++i],!t.binding||t.binding.startsWith("-"))throw new Error("--binding needs the line the signature binds, which does not start with -: --binding <text>")}else if(s==="--relayed-by"){if(t.relayedBy=e[++i],!t.relayedBy||t.relayedBy.startsWith("-"))throw new Error("--relayed-by needs the principal that relayed it: --relayed-by <principal>")}else if(s==="--on"){if(t.on=e[++i],!t.on||t.on.startsWith("-"))throw new Error("--on needs a runtime name: --on <lexicon>")}else if(s==="--compare-to")t.compareTo=e[++i];else if(s==="--no-release-record")t.noReleaseRecord=!0;else if(s==="--no-record")t.noRecord=!0;else if(s==="--fold")t.fold=!0;else if(s==="--no-build")t.noBuild=!0;else if(s==="--no-cache")t.noCache=!0;else if(s==="--no-fold")t.fold=!1;else if(s==="--sandbox")t.sandbox=!0;else if(s==="--fold-rank"){let a=e[i+1];a&&!a.startsWith("-")?(t.foldRankCollapsedFile=a,i++):t.foldRank=!0}else if(s==="--param")(t.param??=[]).push(e[++i]);else if(s==="--lexicon-output")(t.lexiconOutput??=[]).push(e[++i]);else if(s==="--params-file")t.paramsFile=e[++i];else if(s==="--projection")t.projection=e[++i];else if(s==="--interval")t.interval=e[++i];else if(s==="--lease-ttl")t.leaseTtl=e[++i];else if(s==="--steward"){let a=e[i+1];a!==void 0&&!a.startsWith("-")?(t.steward=a,i++):t.steward=""}else if(s==="--once")t.once=!0;else if(s==="--setup-key")t.setupKey=!0;else if(s==="--trust")t.trustKey=!0;else if(s==="--in-place")t.ciInPlace=!0;else if(s==="--require-runner-start")t.requireRunnerStart=!0;else if(s==="--job"){if(t.ciJob=e[++i],!t.ciJob||t.ciJob.startsWith("-"))throw new Error("--job needs the job as JSON or @<file>: --job @job.json")}else if(s==="--no-push")t.noPush=!0;else if(s==="--no-require-review")t.requireReview=!1;else if(s==="--unsigned")t.unsigned=!0;else if(s==="--principal"){if(t.ciPrincipal=e[++i],!t.ciPrincipal||t.ciPrincipal.startsWith("-"))throw new Error("--principal needs the runner's principal: --principal <name>")}else if(s==="--work"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--work needs a work item id: --work <id>");t.work=a,(t.works??=[]).push(a)}else if(s==="--holder"||s==="--ttl"||s==="--token"||s==="--outcome"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error(`${s} needs a value: ${s} <${s.slice(2)}>`);t[s.slice(2)]=a}else if(s==="--input"||s==="--org"||s==="--endpoint"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error(`${s} needs a value: ${s} <${s==="--input"?"file":s.slice(2)}>`);t[s.slice(2)]=a}else if(s==="--signer"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--signer needs a principal: --signer <principal>");t.signer=a}else if(s==="--unit"||s==="--decision"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error(`${s} needs an id: ${s} <id>`);t[s.slice(2)]=a}else if(s==="--note")t.note=e[++i];else if(s==="--reason"){if(t.reason=e[++i],t.reason===void 0||t.reason.startsWith("-"))throw new Error("--reason needs the text of the reason: --reason <text>")}else if(s==="--rule"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--rule needs a rule id: --rule <id>");(t.rules??=[]).push(a)}else if(s==="--expire")t.expire=!0;else if(s==="--role"){let a=e[++i]??"";t.roles=[...t.roles??[],...a.split(",").map(c=>c.trim()).filter(Boolean)]}else if(s==="--agent")t.agent=!0;else if(s==="--allow-code")t.allowCode=!0;else if(s==="--allow-skip")t.allowSkip=!0;else if(s==="--source"){if(t.source=e[++i],!t.source||t.source.startsWith("-"))throw new Error("--source needs a template: --source <repo>[#<member>] for workspace upgrade, or a source for ci tick and ci list: --source checks|runs")}else if(s==="--tags"){if(t.tags=e[++i],!t.tags||t.tags.startsWith("-"))throw new Error("--tags needs a tag glob: --tags 'v*'")}else if(s==="--index"){if(t.index=e[++i],!t.index||t.index.startsWith("-"))throw new Error("--index needs a value: --index <file> for workspace adopt-lineage, --index <scope key>[@<version>] for search and lifecycle diff")}else if(s==="--adopt"){if(t.adopt=e[++i],!t.adopt||t.adopt.startsWith("-"))throw new Error("--adopt needs an adoption file: --adopt <file>")}else if(s==="--adopt-out"){if(t.adoptOut=e[++i],!t.adoptOut||t.adoptOut.startsWith("-"))throw new Error("--adopt-out needs a file: --adopt-out <file>")}else if(s==="--remove")t.remove=!0;else if(s==="--available")t.available=!0;else if(s==="--root-only")t.rootOnly=!0;else if(s==="--forge-repos"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--forge-repos needs a file: --forge-repos <repos.json>");t.forgeRepos=a}else if(s==="--generated")t.generated=!0;else if(s==="--member"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--member needs a member or group name: --member <name>");t.members=[...t.members??[],...a.split(",").map(c=>c.trim()).filter(Boolean)]}else if(s==="--allow-same-origin")t.allowSameOrigin=!0;else if(s==="--plan")t.plan=e[++i];else if(s==="--url")t.url=e[++i];else if(s==="--op")t.op=e[++i];else if(s==="--where"){let a=e[++i];if(a===void 0||a.startsWith("--"))throw new Error("--where needs a clause: --where <field><op><value>");t.where=[...t.where??[],a]}else if(s==="--read"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--read needs a read: --read <state|plan|refresh|live-read|ownership>");t.driftRead=a}else if(s==="--stream")t.stream=!0;else if(s==="--resource"){let a=e[++i];if(!a||a.startsWith("--"))throw new Error("--resource needs an address: --resource <addr>");t.resource=a}else if(s==="--since")t.since=e[++i];else if(s==="--wait")t.ciWait=!0;else if(s==="--retries"){let a=e[++i];if(a===void 0||!/^\d+$/.test(a))throw new Error(`--retries needs a whole number of re-runs: --retries <n>, got ${JSON.stringify(a??"")}`);t.ciRetries=Number(a)}else if(s==="--timeout-minutes"){let a=e[++i],c=a===void 0?NaN:Number(a);if(a===void 0||a.trim()===""||!Number.isFinite(c)||c<=0)throw new Error(`--timeout-minutes needs a number of minutes above 0: --timeout-minutes <n>, got ${JSON.stringify(a??"")}`);t.ciTimeoutMinutes=c}else if(s==="--lane")t.lane=e[++i];else if(s==="--runner")t.quarantineRunner=e[++i];else if(s==="--junit"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--junit needs the JUnit XML file the run wrote: --junit <file>");(t.quarantineJunit??=[]).push(a)}else if(s==="--only")t.quarantineOnly=!0;else if(s==="--phase")t.phase=e[++i];else if(s==="--audit-log"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--audit-log needs the log: --audit-log aws[:<region>]");t.auditLog=a}else if(s==="--limit")t.limit=Number(e[++i]);else{if(s.startsWith("--"))throw new Error(`Unknown flag: ${s}
495
495
  Run "chant --help" to see supported flags.`);if(/^-[A-Za-z]/.test(s))throw new Error(`Unknown flag: ${s}
496
496
  Run "chant --help" to see supported flags.`);r(s)}i++}if(t.promoteTo&&!(t.command==="build"&&t.components&&t.generate))throw new Error("--promote-to needs build --components --generate <lexicon>: it adds a promote job to the generated CI pipeline, and only generate mode emits one.");return t}var Cxe={lc:"lifecycle",sync:"update"};function j6(e,t){let n=Cxe[e.command]??e.command,o=`${n} ${e.path}`,r=t.find(s=>s.name===o);if(r)return{def:r,compound:!0};let i=t.find(s=>s.name===n);return i?{def:i,compound:!1}:null}Qn();function L6(e){return new Promise(t=>{let n=()=>{if(e.writableLength===0||e.writableEnded||e.destroyed){r(),t();return}e.once("drain",n)},o=()=>{r(),t()},r=()=>{e.off("drain",n),e.off("error",o),e.off("close",o)};e.once("error",o),e.once("close",o),n()})}async function T0(e){await L6(process.stdout),await L6(process.stderr),process.exit(e)}I0();import{realpathSync as M6}from"node:fs";import{fileURLToPath as Txe}from"node:url";function F6(e,t){if(!e)return!1;try{return M6(e)===M6(Txe(t))}catch{return!1}}dy();Io();jW();f_();LO();Qn();Ds();import{readFileSync as O0}from"node:fs";import{relative as XRe,resolve as vh}from"node:path";async function exe(e){let t=e.args.noRecord===!0;if(!t&&!Ar())return YRe(e);let n=t?"--no-record":`${gi}=${process.env[gi]}`,o=process.env[gi];t&&(process.env[gi]="1"),GE(),console.error(ur({message:EG(n)}));try{return await YRe(e)}finally{console.error(ur({message:PG(n)})),GE(),t&&(o===void 0?delete process.env[gi]:process.env[gi]=o)}}async function YRe(e){let{args:t}=e,n=t.opsSpec;if(n&&t.recordPlans)try{let i=la(O0(vh(n),"utf-8"),`--spec ${n}`),s=await p_({spec:i});if(t.json)console.log(JSON.stringify(s,null,2));else for(let a of s.waves)console.error(`wave ${a.wave} (${a.name}) at ${s.head.slice(0,12)}: ${a.digest}`);return 0}catch(i){return console.error($e({message:i instanceof Error?i.message:String(i)})),1}if(n&&t.approvalStatus)return Prt(e,n);if(n&&t.wavesOutcome)try{let i=la(O0(vh(n),"utf-8"),`--spec ${n}`),{opWaveOutcomeDir:s}=await Promise.resolve().then(()=>(Zi(),ree)),{earlierWaveOutcomes:a}=await Promise.resolve().then(()=>(Ow(),G7)),{applyOutcomeOf:c}=await Promise.resolve().then(()=>($Re(),xRe)),l=c(a([vh(s(i))],Number.MAX_SAFE_INTEGER).members);if(t.json)console.log(JSON.stringify(l,null,2));else{console.log(l.outcome);let u=Object.entries(l.counts).map(([d,p])=>`${p} ${d}`).join(", ");console.error(`${i.name}: ${l.outcome}${u?` (${u})`:", no wave wrote an outcome"}`)}return 0}catch(i){return console.error($e({message:i instanceof Error?i.message:String(i)})),1}if(!n||t.wave===void 0)return console.error($e({message:"`chant run wave` needs --spec <file> and --wave <k>",hint:"Run it as a generated Op waves pipeline does: chant run wave --spec <file> --wave <k> [--decide | --share <i> | --group <name> [--share <i>]]"})),1;if(t.decide&&(t.share!==void 0||t.group!==void 0))return console.error($e({message:`--decide and --${t.share!==void 0?"share":"group"} are two different jobs; pass one`})),1;let o,r={...t.share!==void 0?{share:t.share}:{},...t.group!==void 0?{group:t.group}:{}};if(t.eventsJson&&t.json)return console.error($e({message:"--events-json and --json both print to stdout",hint:"Pass one. --events-json prints the job's run events; --json prints its result."})),1;try{let i=vh(n);o=la(O0(i,"utf-8"),`--spec ${n}`);let s=t.eventsJson?await(await Promise.resolve().then(()=>(ORe(),ERe))).openCliRunEvents(t,{kind:"op",name:o.name,cwd:process.cwd()}):void 0,a=Tre(),c=await u_({...s?{events:s.emit}:{},...a?.afterPlan?{afterPlan:a.afterPlan}:{},...a?.capabilities?{capabilities:a.capabilities}:{},...a?.hookExec?{hookExec:a.hookExec}:{},spec:o,specFile:XRe(process.cwd(),i),wave:t.wave,...t.decide?{decide:!0}:{},...t.share!==void 0?{share:t.share}:{},...t.group!==void 0?{group:t.group}:{},...t.base?{base:t.base}:{}});return t.json&&console.log(JSON.stringify(c,null,2)),await CO(o,t.wave,{result:c},r),await QRe(o,t.wave,{result:c}),c.exitCode}catch(i){let s=i instanceof Error?i.message:String(i);return console.error($e({message:s})),o&&(await CO(o,t.wave,{error:s},r),await QRe(o,t.wave,{error:s})),1}}async function QRe(e,t,n){try{let{respondOpWave:o,triageOfOpWave:r}=await Promise.resolve().then(()=>(zRe(),URe)),{resolveResponses:i}=await Promise.resolve().then(()=>(C6(),jRe)),s=i(e.respond);if(s["wave-refused"]==="off"&&s["apply-failed"]==="off"||n.result&&n.result.exitCode===0&&!r(e,t,n))return;let{detectForge:a,forgeFromEnv:c}=await Promise.resolve().then(()=>(oc(),ZU)),l=a();if(!l)return;let u;try{u=c(l)}catch{return}let d=process.env.GITHUB_SHA??process.env.CI_COMMIT_SHA;await o(e,t,n,{forge:u,...d?{head:d}:{}})}catch(o){console.error(ur({message:`the wave's responses were not posted: ${o instanceof Error?o.message:String(o)}`}))}}async function Prt(e,t){let{args:n}=e,o=d=>(console.error($e({message:d})),1),{FORGE_KINDS:r,forgeFromEnv:i}=await Promise.resolve().then(()=>(oc(),ZU));if(!n.forge||!r.includes(n.forge))return o(`--approval-status posts on a forge: --forge ${r.join("|")}`);let s,a;try{s=la(O0(vh(t),"utf-8"),`--spec ${t}`),a=i(n.forge)}catch(d){return o(d instanceof Error?d.message:String(d))}let{postApprovalStatus:c,postOpenApprovalStatuses:l}=await Promise.resolve().then(()=>(ZRe(),JRe)),u=XRe(process.cwd(),vh(t));try{if(n.open){let p=n.branch??process.env.CI_COMMIT_BRANCH;if(!p)return o("--approval-status --open posts for the pull requests into a branch: run it in a branch pipeline, or pass --branch <branch>");let f=await l({spec:s,specFile:u,forge:a,branch:p});for(let m of f.warnings)console.error(ur({message:m}));for(let m of f.posted)console.error(`!${m.pr}: ${m.status.state}: ${m.status.description}`);return f.warnings.length>0&&f.posted.length===0?1:0}if(n.pr===void 0||!n.head||!n.base)return o("--approval-status needs the pull request, its head and its base: --pr <n> --head <sha> --base <sha>, or --open");let d=await c({spec:s,specFile:u,forge:a,pr:n.pr,head:n.head,base:n.base});return console.error(`#${n.pr}: ${d.state}: ${d.description}`),0}catch(d){return o(`the approval status was not posted: ${d instanceof Error?d.message:String(d)}`)}}i0();I6();AR();var Krt=[{name:"run wave",handler:exe},{name:"run resume",handler:X4},{name:"approve",handler:Rxe},{name:"workspace points",handler:r6}],Jrt=`
497
497
  chant runtime ${LR} - the wave-job commands of chant, in one file