@intentius/chant 0.124.102 → 0.124.103

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.102 wave-job runtime (#3896): run wave, run resume, approve, workspace points.
2
+ // @intentius/chant 0.124.103 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 JAe=Object.create;var JT=Object.defineProperty;var ZAe=Object.getOwnPropertyDescriptor;var YAe=Object.getOwnPropertyNames;var QAe=Object.getPrototypeOf,XAe=Object.prototype.hasOwnProperty;var $=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(r){throw n=[r],r}};var ve=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(n){throw t=0,n}},me=(e,t)=>{for(var n in t)JT(e,n,{get:t[n],enumerable:!0})},eCe=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of YAe(t))!XAe.call(e,o)&&o!==n&&JT(e,o,{get:()=>t[o],enumerable:!(r=ZAe(t,o))||r.enumerable});return e};var et=(e,t,n)=>(n=e!=null?JAe(QAe(e)):{},eCe(t||!e||!e.__esModule?JT(n,"default",{value:e,enumerable:!0}):n,e));function YT(e,t=new Set){let n=[];for(let r of e)if(r.startsWith("--")&&r.includes("=")){let o=r.indexOf("="),i=r.slice(0,o),s=r.slice(o+1);if(t.has(i))throw new Error(`${r} \u2014 ${i} is a boolean flag and does not take a value. Pass ${i} on its own.`);n.push(i,s)}else n.push(r);return n}var ZT,QT=$(()=>{"use strict";ZT=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 nCe(){return!process.env.NO_COLOR&&process.stdout.isTTY!==!1}function sl(e,t){return nCe()?`${t}${e}${qa.reset}`:e}function be(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(sl(n,qa.cyan)),t.push(" - ")}return t.push(sl("error",qa.red)),t.push(": "),t.push(e.message),e.hint&&(t.push(`
6
6
  `),t.push(sl(e.hint,qa.gray))),t.join("")}function vr(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(sl(n,qa.cyan)),t.push(" - ")}return t.push(sl("warning",qa.yellow)),t.push(": "),t.push(e.message),e.hint&&(t.push(`
7
- `),t.push(sl(e.hint,qa.gray))),t.join("")}function Ey(e){return sl(e,qa.green)}function Wn(e){return sl(e,qa.gray)}var qa,sr=$(()=>{"use strict";qa={red:"\x1B[31m",yellow:"\x1B[33m",green:"\x1B[32m",cyan:"\x1B[36m",gray:"\x1B[90m",reset:"\x1B[0m",bold:"\x1B[1m"}});var f$,eD=$(()=>{"use strict";f$="0.124.102"});function K(e,t,n){function r(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,d=Object.keys(l);for(let u=0;u<d.length;u++){let p=d[u];p in a||(a[p]=l[p].bind(a))}}let o=n?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function s(a){var c;let l=n?.Parent?new i:this;r(l,a),(c=l._zod).deferred??(c.deferred=[]);for(let d of l._zod.deferred)d();return l}return Object.defineProperty(s,"init",{value:r}),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 Sn(e){return e&&Object.assign(Oy,e),Oy}var tD,g$,ps,al,Oy,yf=$(()=>{tD=Object.freeze({status:"aborted"});g$=Symbol("zod_brand"),ps=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},al=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}},Oy={}});var Ee={};me(Ee,{BIGINT_FORMAT_RANGES:()=>uD,Class:()=>rD,NUMBER_FORMAT_RANGES:()=>dD,aborted:()=>ul,allowsEval:()=>sD,assert:()=>cCe,assertEqual:()=>oCe,assertIs:()=>sCe,assertNever:()=>aCe,assertNotEqual:()=>iCe,assignProp:()=>ll,base64ToUint8Array:()=>W3,base64urlToUint8Array:()=>SCe,cached:()=>bf,captureStackTrace:()=>h$,cleanEnum:()=>$Ce,cleanRegex:()=>Cy,clone:()=>Kr,cloneDef:()=>dCe,createTransparentProxy:()=>hCe,defineLazy:()=>ht,esc:()=>m$,escapeRegex:()=>xi,extend:()=>bCe,finalizeIssue:()=>xo,floatSafeRemainder:()=>oD,getElementAtPath:()=>uCe,getEnumValues:()=>Ay,getLengthableOrigin:()=>Ty,getParsedType:()=>mCe,getSizableOrigin:()=>Iy,hexToUint8Array:()=>OCe,isObject:()=>ru,isPlainObject:()=>dl,issue:()=>vf,joinValues:()=>ie,jsonStringifyReplacer:()=>wf,merge:()=>kCe,mergeDefs:()=>Ka,normalizeParams:()=>Oe,nullish:()=>cl,numKeys:()=>gCe,objectClone:()=>lCe,omit:()=>wCe,optionalKeys:()=>lD,parsedType:()=>Se,partial:()=>RCe,pick:()=>yCe,prefixIssues:()=>Qo,primitiveTypes:()=>cD,promiseAllObject:()=>pCe,propertyKeyTypes:()=>_y,randomString:()=>fCe,required:()=>xCe,safeExtend:()=>vCe,shallowClone:()=>aD,slugify:()=>iD,stringifyPrimitive:()=>Re,uint8ArrayToBase64:()=>G3,uint8ArrayToBase64url:()=>ECe,uint8ArrayToHex:()=>PCe,unwrapMessage:()=>Py});function oCe(e){return e}function iCe(e){return e}function sCe(e){}function aCe(e){throw new Error("Unexpected value in exhaustive check")}function cCe(e){}function Ay(e){let t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function ie(e,t="|"){return e.map(n=>Re(n)).join(t)}function wf(e,t){return typeof t=="bigint"?t.toString():t}function bf(e){return{get value(){{let n=e();return Object.defineProperty(this,"value",{value:n}),n}throw new Error("cached value already set")}}}function cl(e){return e==null}function Cy(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function oD(e,t){let n=(e.toString().split(".")[1]||"").length,r=t.toString(),o=(r.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(r)){let c=r.match(/\d?e-(\d?)/);c?.[1]&&(o=Number.parseInt(c[1]))}let i=n>o?n:o,s=Number.parseInt(e.toFixed(i).replace(".","")),a=Number.parseInt(t.toFixed(i).replace(".",""));return s%a/10**i}function ht(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==F3)return r===void 0&&(r=F3,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function lCe(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function ll(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Ka(...e){let t={};for(let n of e){let r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function dCe(e){return Ka(e._zod.def)}function uCe(e,t){return t?t.reduce((n,r)=>n?.[r],e):e}function pCe(e){let t=Object.keys(e),n=t.map(r=>e[r]);return Promise.all(n).then(r=>{let o={};for(let i=0;i<t.length;i++)o[t[i]]=r[i];return o})}function fCe(e=10){let t="abcdefghijklmnopqrstuvwxyz",n="";for(let r=0;r<e;r++)n+=t[Math.floor(Math.random()*t.length)];return n}function m$(e){return JSON.stringify(e)}function iD(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 dl(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 aD(e){return dl(e)?{...e}:Array.isArray(e)?[...e]:e}function gCe(e){let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}function xi(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Kr(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function Oe(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 hCe(e){let t;return new Proxy({},{get(n,r,o){return t??(t=e()),Reflect.get(t,r,o)},set(n,r,o,i){return t??(t=e()),Reflect.set(t,r,o,i)},has(n,r){return t??(t=e()),Reflect.has(t,r)},deleteProperty(n,r){return t??(t=e()),Reflect.deleteProperty(t,r)},ownKeys(n){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,r){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,r)},defineProperty(n,r,o){return t??(t=e()),Reflect.defineProperty(t,r,o)}})}function Re(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function lD(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function yCe(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let i=Ka(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 ll(this,"shape",s),s},checks:[]});return Kr(e,i)}function wCe(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let i=Ka(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 ll(this,"shape",s),s},checks:[]});return Kr(e,i)}function bCe(e,t){if(!dl(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 o=Ka(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return ll(this,"shape",i),i}});return Kr(e,o)}function vCe(e,t){if(!dl(t))throw new Error("Invalid input to safeExtend: expected a plain object");let n=Ka(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t};return ll(this,"shape",r),r}});return Kr(e,n)}function kCe(e,t){let n=Ka(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t._zod.def.shape};return ll(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return Kr(e,n)}function RCe(e,t,n){let o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let s=Ka(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 ll(this,"shape",c),c},checks:[]});return Kr(t,s)}function xCe(e,t,n){let r=Ka(t._zod.def,{get shape(){let o=t._zod.def.shape,i={...o};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:o[s]}))}else for(let s in o)i[s]=new e({type:"nonoptional",innerType:o[s]});return ll(this,"shape",i),i}});return Kr(t,r)}function ul(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 Qo(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Py(e){return typeof e=="string"?e:e?.message}function xo(e,t,n){let r={...e,path:e.path??[]};if(!e.message){let o=Py(e.inst?._zod.def?.error?.(e))??Py(t?.error?.(e))??Py(n.customError?.(e))??Py(n.localeError?.(e))??"Invalid input";r.message=o}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function Iy(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function Ty(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Se(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 vf(...e){let[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function $Ce(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function W3(e){let t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}function G3(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function SCe(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return W3(t+n)}function ECe(e){return G3(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function OCe(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 r=0;r<t.length;r+=2)n[r/2]=Number.parseInt(t.slice(r,r+2),16);return n}function PCe(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var F3,h$,sD,mCe,_y,cD,dD,uD,rD,ze=$(()=>{F3=Symbol("evaluating");h$="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};sD=bf(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});mCe=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}`)}},_y=new Set(["string","number","symbol"]),cD=new Set(["string","number","bigint","boolean","symbol","undefined"]);dD={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]},uD={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};rD=class{constructor(...t){}}});function Ny(e,t=n=>n.message){let n={},r=[];for(let o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function jy(e,t=n=>n.message){let n={_errors:[]},r=o=>{for(let i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(s=>r({issues:s}));else if(i.code==="invalid_key")r({issues:i.issues});else if(i.code==="invalid_element")r({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 r(e),n}function pD(e,t=n=>n.message){let n={errors:[]},r=(o,i=[])=>{var s,a;for(let c of o.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(l=>r({issues:l},c.path));else if(c.code==="invalid_key")r({issues:c.issues},c.path);else if(c.code==="invalid_element")r({issues:c.issues},c.path);else{let l=[...i,...c.path];if(l.length===0){n.errors.push(t(c));continue}let d=n,u=0;for(;u<l.length;){let p=l[u],f=u===l.length-1;typeof p=="string"?(d.properties??(d.properties={}),(s=d.properties)[p]??(s[p]={errors:[]}),d=d.properties[p]):(d.items??(d.items=[]),(a=d.items)[p]??(a[p]={errors:[]}),d=d.items[p]),f&&d.errors.push(t(c)),u++}}};return r(e),n}function U3(e){let t=[],n=e.map(r=>typeof r=="object"?r.key:r);for(let r of n)typeof r=="number"?t.push(`[${r}]`):typeof r=="symbol"?t.push(`[${JSON.stringify(String(r))}]`):/[^\w$]/.test(r)?t.push(`[${JSON.stringify(r)}]`):(t.length&&t.push("."),t.push(r));return t.join("")}function fD(e){let t=[],n=[...e.issues].sort((r,o)=>(r.path??[]).length-(o.path??[]).length);for(let r of n)t.push(`\u2716 ${r.message}`),r.path?.length&&t.push(` \u2192 at ${U3(r.path)}`);return t.join(`
7
+ `),t.push(sl(e.hint,qa.gray))),t.join("")}function Ey(e){return sl(e,qa.green)}function Wn(e){return sl(e,qa.gray)}var qa,sr=$(()=>{"use strict";qa={red:"\x1B[31m",yellow:"\x1B[33m",green:"\x1B[32m",cyan:"\x1B[36m",gray:"\x1B[90m",reset:"\x1B[0m",bold:"\x1B[1m"}});var f$,eD=$(()=>{"use strict";f$="0.124.103"});function K(e,t,n){function r(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,d=Object.keys(l);for(let u=0;u<d.length;u++){let p=d[u];p in a||(a[p]=l[p].bind(a))}}let o=n?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function s(a){var c;let l=n?.Parent?new i:this;r(l,a),(c=l._zod).deferred??(c.deferred=[]);for(let d of l._zod.deferred)d();return l}return Object.defineProperty(s,"init",{value:r}),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 Sn(e){return e&&Object.assign(Oy,e),Oy}var tD,g$,ps,al,Oy,yf=$(()=>{tD=Object.freeze({status:"aborted"});g$=Symbol("zod_brand"),ps=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},al=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}},Oy={}});var Ee={};me(Ee,{BIGINT_FORMAT_RANGES:()=>uD,Class:()=>rD,NUMBER_FORMAT_RANGES:()=>dD,aborted:()=>ul,allowsEval:()=>sD,assert:()=>cCe,assertEqual:()=>oCe,assertIs:()=>sCe,assertNever:()=>aCe,assertNotEqual:()=>iCe,assignProp:()=>ll,base64ToUint8Array:()=>W3,base64urlToUint8Array:()=>SCe,cached:()=>bf,captureStackTrace:()=>h$,cleanEnum:()=>$Ce,cleanRegex:()=>Cy,clone:()=>Kr,cloneDef:()=>dCe,createTransparentProxy:()=>hCe,defineLazy:()=>ht,esc:()=>m$,escapeRegex:()=>xi,extend:()=>bCe,finalizeIssue:()=>xo,floatSafeRemainder:()=>oD,getElementAtPath:()=>uCe,getEnumValues:()=>Ay,getLengthableOrigin:()=>Ty,getParsedType:()=>mCe,getSizableOrigin:()=>Iy,hexToUint8Array:()=>OCe,isObject:()=>ru,isPlainObject:()=>dl,issue:()=>vf,joinValues:()=>ie,jsonStringifyReplacer:()=>wf,merge:()=>kCe,mergeDefs:()=>Ka,normalizeParams:()=>Oe,nullish:()=>cl,numKeys:()=>gCe,objectClone:()=>lCe,omit:()=>wCe,optionalKeys:()=>lD,parsedType:()=>Se,partial:()=>RCe,pick:()=>yCe,prefixIssues:()=>Qo,primitiveTypes:()=>cD,promiseAllObject:()=>pCe,propertyKeyTypes:()=>_y,randomString:()=>fCe,required:()=>xCe,safeExtend:()=>vCe,shallowClone:()=>aD,slugify:()=>iD,stringifyPrimitive:()=>Re,uint8ArrayToBase64:()=>G3,uint8ArrayToBase64url:()=>ECe,uint8ArrayToHex:()=>PCe,unwrapMessage:()=>Py});function oCe(e){return e}function iCe(e){return e}function sCe(e){}function aCe(e){throw new Error("Unexpected value in exhaustive check")}function cCe(e){}function Ay(e){let t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function ie(e,t="|"){return e.map(n=>Re(n)).join(t)}function wf(e,t){return typeof t=="bigint"?t.toString():t}function bf(e){return{get value(){{let n=e();return Object.defineProperty(this,"value",{value:n}),n}throw new Error("cached value already set")}}}function cl(e){return e==null}function Cy(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function oD(e,t){let n=(e.toString().split(".")[1]||"").length,r=t.toString(),o=(r.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(r)){let c=r.match(/\d?e-(\d?)/);c?.[1]&&(o=Number.parseInt(c[1]))}let i=n>o?n:o,s=Number.parseInt(e.toFixed(i).replace(".","")),a=Number.parseInt(t.toFixed(i).replace(".",""));return s%a/10**i}function ht(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==F3)return r===void 0&&(r=F3,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function lCe(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function ll(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Ka(...e){let t={};for(let n of e){let r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function dCe(e){return Ka(e._zod.def)}function uCe(e,t){return t?t.reduce((n,r)=>n?.[r],e):e}function pCe(e){let t=Object.keys(e),n=t.map(r=>e[r]);return Promise.all(n).then(r=>{let o={};for(let i=0;i<t.length;i++)o[t[i]]=r[i];return o})}function fCe(e=10){let t="abcdefghijklmnopqrstuvwxyz",n="";for(let r=0;r<e;r++)n+=t[Math.floor(Math.random()*t.length)];return n}function m$(e){return JSON.stringify(e)}function iD(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 dl(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 aD(e){return dl(e)?{...e}:Array.isArray(e)?[...e]:e}function gCe(e){let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}function xi(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Kr(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function Oe(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 hCe(e){let t;return new Proxy({},{get(n,r,o){return t??(t=e()),Reflect.get(t,r,o)},set(n,r,o,i){return t??(t=e()),Reflect.set(t,r,o,i)},has(n,r){return t??(t=e()),Reflect.has(t,r)},deleteProperty(n,r){return t??(t=e()),Reflect.deleteProperty(t,r)},ownKeys(n){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,r){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,r)},defineProperty(n,r,o){return t??(t=e()),Reflect.defineProperty(t,r,o)}})}function Re(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function lD(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function yCe(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let i=Ka(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 ll(this,"shape",s),s},checks:[]});return Kr(e,i)}function wCe(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let i=Ka(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 ll(this,"shape",s),s},checks:[]});return Kr(e,i)}function bCe(e,t){if(!dl(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 o=Ka(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return ll(this,"shape",i),i}});return Kr(e,o)}function vCe(e,t){if(!dl(t))throw new Error("Invalid input to safeExtend: expected a plain object");let n=Ka(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t};return ll(this,"shape",r),r}});return Kr(e,n)}function kCe(e,t){let n=Ka(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t._zod.def.shape};return ll(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return Kr(e,n)}function RCe(e,t,n){let o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let s=Ka(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 ll(this,"shape",c),c},checks:[]});return Kr(t,s)}function xCe(e,t,n){let r=Ka(t._zod.def,{get shape(){let o=t._zod.def.shape,i={...o};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:o[s]}))}else for(let s in o)i[s]=new e({type:"nonoptional",innerType:o[s]});return ll(this,"shape",i),i}});return Kr(t,r)}function ul(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 Qo(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Py(e){return typeof e=="string"?e:e?.message}function xo(e,t,n){let r={...e,path:e.path??[]};if(!e.message){let o=Py(e.inst?._zod.def?.error?.(e))??Py(t?.error?.(e))??Py(n.customError?.(e))??Py(n.localeError?.(e))??"Invalid input";r.message=o}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function Iy(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function Ty(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Se(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 vf(...e){let[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function $Ce(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function W3(e){let t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}function G3(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function SCe(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return W3(t+n)}function ECe(e){return G3(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function OCe(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 r=0;r<t.length;r+=2)n[r/2]=Number.parseInt(t.slice(r,r+2),16);return n}function PCe(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var F3,h$,sD,mCe,_y,cD,dD,uD,rD,ze=$(()=>{F3=Symbol("evaluating");h$="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};sD=bf(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});mCe=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}`)}},_y=new Set(["string","number","symbol"]),cD=new Set(["string","number","bigint","boolean","symbol","undefined"]);dD={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]},uD={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};rD=class{constructor(...t){}}});function Ny(e,t=n=>n.message){let n={},r=[];for(let o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function jy(e,t=n=>n.message){let n={_errors:[]},r=o=>{for(let i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(s=>r({issues:s}));else if(i.code==="invalid_key")r({issues:i.issues});else if(i.code==="invalid_element")r({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 r(e),n}function pD(e,t=n=>n.message){let n={errors:[]},r=(o,i=[])=>{var s,a;for(let c of o.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(l=>r({issues:l},c.path));else if(c.code==="invalid_key")r({issues:c.issues},c.path);else if(c.code==="invalid_element")r({issues:c.issues},c.path);else{let l=[...i,...c.path];if(l.length===0){n.errors.push(t(c));continue}let d=n,u=0;for(;u<l.length;){let p=l[u],f=u===l.length-1;typeof p=="string"?(d.properties??(d.properties={}),(s=d.properties)[p]??(s[p]={errors:[]}),d=d.properties[p]):(d.items??(d.items=[]),(a=d.items)[p]??(a[p]={errors:[]}),d=d.items[p]),f&&d.errors.push(t(c)),u++}}};return r(e),n}function U3(e){let t=[],n=e.map(r=>typeof r=="object"?r.key:r);for(let r of n)typeof r=="number"?t.push(`[${r}]`):typeof r=="symbol"?t.push(`[${JSON.stringify(String(r))}]`):/[^\w$]/.test(r)?t.push(`[${JSON.stringify(r)}]`):(t.length&&t.push("."),t.push(r));return t.join("")}function fD(e){let t=[],n=[...e.issues].sort((r,o)=>(r.path??[]).length-(o.path??[]).length);for(let r of n)t.push(`\u2716 ${r.message}`),r.path?.length&&t.push(` \u2192 at ${U3(r.path)}`);return t.join(`
8
8
  `)}var B3,Dy,$o,gD=$(()=>{yf();ze();B3=(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,wf,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Dy=K("$ZodError",B3),$o=K("$ZodError",B3,{Parent:Error})});var kf,y$,Rf,w$,xf,mD,$f,hD,b$,CCe,v$,_Ce,k$,ICe,R$,TCe,x$,DCe,$$,NCe,S$,jCe,E$,LCe,yD=$(()=>{yf();gD();ze();kf=e=>(t,n,r,o)=>{let i=r?Object.assign(r,{async:!1}):{async:!1},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new ps;if(s.issues.length){let a=new(o?.Err??e)(s.issues.map(c=>xo(c,i,Sn())));throw h$(a,o?.callee),a}return s.value},y$=kf($o),Rf=e=>async(t,n,r,o)=>{let i=r?Object.assign(r,{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(o?.Err??e)(s.issues.map(c=>xo(c,i,Sn())));throw h$(a,o?.callee),a}return s.value},w$=Rf($o),xf=e=>(t,n,r)=>{let o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new ps;return i.issues.length?{success:!1,error:new(e??Dy)(i.issues.map(s=>xo(s,o,Sn())))}:{success:!0,data:i.value}},mD=xf($o),$f=e=>async(t,n,r)=>{let o=r?Object.assign(r,{async:!0}):{async:!0},i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(s=>xo(s,o,Sn())))}:{success:!0,data:i.value}},hD=$f($o),b$=e=>(t,n,r)=>{let o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return kf(e)(t,n,o)},CCe=b$($o),v$=e=>(t,n,r)=>kf(e)(t,n,r),_Ce=v$($o),k$=e=>async(t,n,r)=>{let o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Rf(e)(t,n,o)},ICe=k$($o),R$=e=>async(t,n,r)=>Rf(e)(t,n,r),TCe=R$($o),x$=e=>(t,n,r)=>{let o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return xf(e)(t,n,o)},DCe=x$($o),$$=e=>(t,n,r)=>xf(e)(t,n,r),NCe=$$($o),S$=e=>async(t,n,r)=>{let o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return $f(e)(t,n,o)},jCe=S$($o),E$=e=>async(t,n,r)=>$f(e)(t,n,r),LCe=E$($o)});var $i={};me($i,{base64:()=>TD,base64url:()=>O$,bigint:()=>FD,boolean:()=>GD,browserEmail:()=>zCe,cidrv4:()=>_D,cidrv6:()=>ID,cuid:()=>wD,cuid2:()=>bD,date:()=>ND,datetime:()=>LD,domain:()=>KCe,duration:()=>$D,e164:()=>DD,email:()=>ED,emoji:()=>OD,extendedDuration:()=>MCe,guid:()=>SD,hex:()=>JCe,hostname:()=>qCe,html5Email:()=>BCe,idnEmail:()=>HCe,integer:()=>WD,ipv4:()=>PD,ipv6:()=>AD,ksuid:()=>RD,lowercase:()=>HD,mac:()=>CD,md5_base64:()=>YCe,md5_base64url:()=>QCe,md5_hex:()=>ZCe,nanoid:()=>xD,null:()=>BD,number:()=>P$,rfc5322Email:()=>UCe,sha1_base64:()=>e_e,sha1_base64url:()=>t_e,sha1_hex:()=>XCe,sha256_base64:()=>r_e,sha256_base64url:()=>o_e,sha256_hex:()=>n_e,sha384_base64:()=>s_e,sha384_base64url:()=>a_e,sha384_hex:()=>i_e,sha512_base64:()=>l_e,sha512_base64url:()=>d_e,sha512_hex:()=>c_e,string:()=>MD,time:()=>jD,ulid:()=>vD,undefined:()=>UD,unicodeEmail:()=>H3,uppercase:()=>zD,uuid:()=>ou,uuid4:()=>FCe,uuid6:()=>WCe,uuid7:()=>GCe,xid:()=>kD});function OD(){return new RegExp(VCe,"u")}function V3(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 jD(e){return new RegExp(`^${V3(e)}$`)}function LD(e){let t=V3({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${t}(?:${n.join("|")})`;return new RegExp(`^${z3}T(?:${r})$`)}function Ly(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function My(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var wD,bD,vD,kD,RD,xD,$D,MCe,SD,ou,FCe,WCe,GCe,ED,BCe,UCe,H3,HCe,zCe,VCe,PD,AD,CD,_D,ID,TD,O$,qCe,KCe,DD,z3,ND,MD,FD,WD,P$,GD,BD,UD,HD,zD,JCe,ZCe,YCe,QCe,XCe,e_e,t_e,n_e,r_e,o_e,i_e,s_e,a_e,c_e,l_e,d_e,A$=$(()=>{ze();wD=/^[cC][^\s-]{8,}$/,bD=/^[0-9a-z]+$/,vD=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,kD=/^[0-9a-vA-V]{20}$/,RD=/^[A-Za-z0-9]{27}$/,xD=/^[a-zA-Z0-9_-]{21}$/,$D=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,MCe=/^[-+]?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)?)??$/,SD=/^([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})$/,ou=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)$/,FCe=ou(4),WCe=ou(6),GCe=ou(7),ED=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,BCe=/^[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])?)*$/,UCe=/^(([^<>()\[\]\\.,;:\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,}))$/,H3=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,HCe=H3,zCe=/^[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])?)*$/,VCe="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";PD=/^(?:(?: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])$/,AD=/^(([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}|:))$/,CD=e=>{let t=xi(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},_D=/^((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])$/,ID=/^(([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])$/,TD=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,O$=/^[A-Za-z0-9_-]*$/,qCe=/^(?=.{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])?)*\.?$/,KCe=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,DD=/^\+[1-9]\d{6,14}$/,z3="(?:(?:\\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])))",ND=new RegExp(`^${z3}$`);MD=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},FD=/^-?\d+n?$/,WD=/^-?\d+$/,P$=/^-?\d+(?:\.\d+)?$/,GD=/^(?:true|false)$/i,BD=/^null$/i,UD=/^undefined$/i,HD=/^[^A-Z]*$/,zD=/^[^a-z]*$/,JCe=/^[0-9a-fA-F]*$/;ZCe=/^[0-9a-fA-F]{32}$/,YCe=Ly(22,"=="),QCe=My(22),XCe=/^[0-9a-fA-F]{40}$/,e_e=Ly(27,"="),t_e=My(27),n_e=/^[0-9a-fA-F]{64}$/,r_e=Ly(43,"="),o_e=My(43),i_e=/^[0-9a-fA-F]{96}$/,s_e=Ly(64,""),a_e=My(64),c_e=/^[0-9a-fA-F]{128}$/,l_e=Ly(86,"=="),d_e=My(86)});function q3(e,t,n){e.issues.length&&t.issues.push(...Qo(n,e.issues))}var nn,K3,C$,_$,VD,qD,KD,JD,ZD,YD,QD,XD,eN,Sf,tN,nN,rN,oN,iN,sN,aN,cN,lN,I$=$(()=>{yf();A$();ze();nn=K("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),K3={number:"number",bigint:"bigint",object:"date"},C$=K("$ZodCheckLessThan",(e,t)=>{nn.init(e,t);let n=K3[typeof t.value];e._zod.onattach.push(r=>{let o=r._zod.bag,i=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),_$=K("$ZodCheckGreaterThan",(e,t)=>{nn.init(e,t);let n=K3[typeof t.value];e._zod.onattach.push(r=>{let o=r._zod.bag,i=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),VD=K("$ZodCheckMultipleOf",(e,t)=>{nn.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.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):oD(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})}}),qD=K("$ZodCheckNumberFormat",(e,t)=>{nn.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),r=n?"int":"number",[o,i]=dD[t.format];e._zod.onattach.push(s=>{let a=s._zod.bag;a.format=t.format,a.minimum=o,a.maximum=i,n&&(a.pattern=WD)}),e._zod.check=s=>{let a=s.value;if(n){if(!Number.isInteger(a)){s.issues.push({expected:r,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:r,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:r,inclusive:!0,continue:!t.abort});return}}a<o&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:o,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})}}),KD=K("$ZodCheckBigIntFormat",(e,t)=>{nn.init(e,t);let[n,r]=uD[t.format];e._zod.onattach.push(o=>{let i=o._zod.bag;i.format=t.format,i.minimum=n,i.maximum=r}),e._zod.check=o=>{let i=o.value;i<n&&o.issues.push({origin:"bigint",input:i,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),i>r&&o.issues.push({origin:"bigint",input:i,code:"too_big",maximum:r,inclusive:!0,inst:e,continue:!t.abort})}}),JD=K("$ZodCheckMaxSize",(e,t)=>{var n;nn.init(e,t),(n=e._zod.def).when??(n.when=r=>{let o=r.value;return!cl(o)&&o.size!==void 0}),e._zod.onattach.push(r=>{let o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{let o=r.value;o.size<=t.maximum||r.issues.push({origin:Iy(o),code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),ZD=K("$ZodCheckMinSize",(e,t)=>{var n;nn.init(e,t),(n=e._zod.def).when??(n.when=r=>{let o=r.value;return!cl(o)&&o.size!==void 0}),e._zod.onattach.push(r=>{let o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{let o=r.value;o.size>=t.minimum||r.issues.push({origin:Iy(o),code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),YD=K("$ZodCheckSizeEquals",(e,t)=>{var n;nn.init(e,t),(n=e._zod.def).when??(n.when=r=>{let o=r.value;return!cl(o)&&o.size!==void 0}),e._zod.onattach.push(r=>{let o=r._zod.bag;o.minimum=t.size,o.maximum=t.size,o.size=t.size}),e._zod.check=r=>{let o=r.value,i=o.size;if(i===t.size)return;let s=i>t.size;r.issues.push({origin:Iy(o),...s?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),QD=K("$ZodCheckMaxLength",(e,t)=>{var n;nn.init(e,t),(n=e._zod.def).when??(n.when=r=>{let o=r.value;return!cl(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{let o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{let o=r.value;if(o.length<=t.maximum)return;let s=Ty(o);r.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),XD=K("$ZodCheckMinLength",(e,t)=>{var n;nn.init(e,t),(n=e._zod.def).when??(n.when=r=>{let o=r.value;return!cl(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{let o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{let o=r.value;if(o.length>=t.minimum)return;let s=Ty(o);r.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),eN=K("$ZodCheckLengthEquals",(e,t)=>{var n;nn.init(e,t),(n=e._zod.def).when??(n.when=r=>{let o=r.value;return!cl(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{let o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{let o=r.value,i=o.length;if(i===t.length)return;let s=Ty(o),a=i>t.length;r.issues.push({origin:s,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Sf=K("$ZodCheckStringFormat",(e,t)=>{var n,r;nn.init(e,t),e._zod.onattach.push(o=>{let i=o._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=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),tN=K("$ZodCheckRegex",(e,t)=>{Sf.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})}}),nN=K("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=HD),Sf.init(e,t)}),rN=K("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=zD),Sf.init(e,t)}),oN=K("$ZodCheckIncludes",(e,t)=>{nn.init(e,t);let n=xi(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{let i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),iN=K("$ZodCheckStartsWith",(e,t)=>{nn.init(e,t);let n=new RegExp(`^${xi(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{let o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),sN=K("$ZodCheckEndsWith",(e,t)=>{nn.init(e,t);let n=new RegExp(`.*${xi(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{let o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}});aN=K("$ZodCheckProperty",(e,t)=>{nn.init(e,t),e._zod.check=n=>{let r=t.schema._zod.run({value:n.value[t.property],issues:[]},{});if(r instanceof Promise)return r.then(o=>q3(o,n,t.property));q3(r,n,t.property)}}),cN=K("$ZodCheckMimeType",(e,t)=>{nn.init(e,t);let n=new Set(t.mime);e._zod.onattach.push(r=>{r._zod.bag.mime=t.mime}),e._zod.check=r=>{n.has(r.value.type)||r.issues.push({code:"invalid_value",values:t.mime,input:r.value.type,inst:e,continue:!t.abort})}}),lN=K("$ZodCheckOverwrite",(e,t)=>{nn.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}})});var Fy,dN=$(()=>{Fy=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 r=t.split(`
9
9
  `).filter(s=>s),o=Math.min(...r.map(s=>s.length-s.trimStart().length)),i=r.map(s=>s.slice(o)).map(s=>" ".repeat(this.indent*2)+s);for(let s of i)this.content.push(s)}compile(){let t=Function,n=this?.args,o=[...(this?.content??[""]).map(i=>` ${i}`)];return new t(...n,o.join(`
10
10
  `))}}});var uN,pN=$(()=>{uN={major:4,minor:3,patch:6}});function DN(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}function aZ(e){if(!O$.test(e))return!1;let t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return DN(n)}function cZ(e,t=null){try{let n=e.split(".");if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let o=JSON.parse(atob(r));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}function Z3(e,t,n){e.issues.length&&t.issues.push(...Qo(n,e.issues)),t.value[n]=e.value}function L$(e,t,n,r,o){if(e.issues.length){if(o&&!(n in r))return;t.issues.push(...Qo(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function lZ(e){let t=Object.keys(e.shape);for(let r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);let n=lD(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function dZ(e,t,n,r,o,i){let s=[],a=o.keySet,c=o.catchall._zod,l=c.def.type,d=c.optout==="optional";for(let u in t){if(a.has(u))continue;if(l==="never"){s.push(u);continue}let p=c.run({value:t[u],issues:[]},r);p instanceof Promise?e.push(p.then(f=>L$(f,n,u,t,d))):L$(p,n,u,t,d)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}function Y3(e,t,n,r){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let o=e.filter(i=>!ul(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(s=>xo(s,r,Sn())))}),t)}function Q3(e,t,n,r){let o=e.filter(i=>i.issues.length===0);return o.length===1?(t.value=o[0].value,t):(o.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(s=>xo(s,r,Sn())))}):t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:[],inclusive:!1}),t)}function fN(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(dl(e)&&dl(t)){let n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),o={...e,...t};for(let i of r){let s=fN(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};o[i]=s.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let o=e[r],i=t[r],s=fN(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function X3(e,t,n){let r=new Map,o;for(let a of t.issues)if(a.code==="unrecognized_keys"){o??(o=a);for(let c of a.keys)r.has(c)||r.set(c,{}),r.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)r.has(c)||r.set(c,{}),r.get(c).r=!0;else e.issues.push(a);let i=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(i.length&&o&&e.issues.push({...o,keys:i}),ul(e))return e;let s=fN(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 T$(e,t,n){e.issues.length&&t.issues.push(...Qo(n,e.issues)),t.value[n]=e.value}function eZ(e,t,n,r,o,i,s){e.issues.length&&(_y.has(typeof r)?n.issues.push(...Qo(r,e.issues)):n.issues.push({code:"invalid_key",origin:"map",input:o,inst:i,issues:e.issues.map(a=>xo(a,s,Sn()))})),t.issues.length&&(_y.has(typeof r)?n.issues.push(...Qo(r,t.issues)):n.issues.push({origin:"map",code:"invalid_element",input:o,inst:i,key:r,issues:t.issues.map(a=>xo(a,s,Sn()))})),n.value.set(e.value,t.value)}function tZ(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}function nZ(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}function rZ(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}function oZ(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 D$(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}function N$(e,t,n){if(e.issues.length)return e.aborted=!0,e;if((n.direction||"forward")==="forward"){let o=t.transform(e.value,e);return o instanceof Promise?o.then(i=>j$(e,i,t.out,n)):j$(e,o,t.out,n)}else{let o=t.reverseTransform(e.value,e);return o instanceof Promise?o.then(i=>j$(e,i,t.in,n)):j$(e,o,t.in,n)}}function j$(e,t,n,r){return e.issues.length?(e.aborted=!0,e):n._zod.run({value:t,issues:e.issues},r)}function iZ(e){return e.value=Object.freeze(e.value),e}function sZ(e,t,n,r){if(!e){let o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(vf(o))}}var rt,iu,Jt,gN,mN,hN,yN,wN,bN,vN,kN,RN,xN,$N,SN,EN,ON,PN,AN,CN,_N,IN,TN,NN,jN,LN,MN,FN,M$,WN,Wy,F$,GN,BN,UN,HN,zN,VN,qN,KN,JN,ZN,uZ,YN,Gy,QN,XN,ej,W$,tj,nj,rj,oj,ij,sj,aj,G$,cj,lj,dj,uj,pj,fj,gj,mj,hj,By,yj,wj,bj,vj,kj,Rj,xj=$(()=>{I$();yf();dN();yD();A$();ze();pN();ze();rt=K("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=uN;let r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(let o of r)for(let i of o._zod.onattach)i(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let o=(s,a,c)=>{let l=ul(s),d;for(let u of a){if(u._zod.def.when){if(!u._zod.def.when(s))continue}else if(l)continue;let p=s.issues.length,f=u._zod.check(s);if(f instanceof Promise&&c?.async===!1)throw new ps;if(d||f instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await f,s.issues.length!==p&&(l||(l=ul(s,p)))});else{if(s.issues.length===p)continue;l||(l=ul(s,p))}}return d?d.then(()=>s):s},i=(s,a,c)=>{if(ul(s))return s.aborted=!0,s;let l=o(a,r,c);if(l instanceof Promise){if(c.async===!1)throw new ps;return l.then(d=>e._zod.parse(d,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(d=>i(d,s,a)):i(l,s,a)}let c=e._zod.parse(s,a);if(c instanceof Promise){if(a.async===!1)throw new ps;return c.then(l=>o(l,r,a))}return o(c,r,a)}}ht(e,"~standard",()=>({validate:o=>{try{let i=mD(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return hD(e,o).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),iu=K("$ZodString",(e,t)=>{rt.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??MD(e._zod.bag),e._zod.parse=(n,r)=>{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}}),Jt=K("$ZodStringFormat",(e,t)=>{Sf.init(e,t),iu.init(e,t)}),gN=K("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=SD),Jt.init(e,t)}),mN=K("$ZodUUID",(e,t)=>{if(t.version){let r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=ou(r))}else t.pattern??(t.pattern=ou());Jt.init(e,t)}),hN=K("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=ED),Jt.init(e,t)}),yN=K("$ZodURL",(e,t)=>{Jt.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),o=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.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(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.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=o.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),wN=K("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=OD()),Jt.init(e,t)}),bN=K("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=xD),Jt.init(e,t)}),vN=K("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=wD),Jt.init(e,t)}),kN=K("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=bD),Jt.init(e,t)}),RN=K("$ZodULID",(e,t)=>{t.pattern??(t.pattern=vD),Jt.init(e,t)}),xN=K("$ZodXID",(e,t)=>{t.pattern??(t.pattern=kD),Jt.init(e,t)}),$N=K("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=RD),Jt.init(e,t)}),SN=K("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=LD(t)),Jt.init(e,t)}),EN=K("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=ND),Jt.init(e,t)}),ON=K("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=jD(t)),Jt.init(e,t)}),PN=K("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=$D),Jt.init(e,t)}),AN=K("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=PD),Jt.init(e,t),e._zod.bag.format="ipv4"}),CN=K("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=AD),Jt.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})}}}),_N=K("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=CD(t.delimiter)),Jt.init(e,t),e._zod.bag.format="mac"}),IN=K("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=_D),Jt.init(e,t)}),TN=K("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=ID),Jt.init(e,t),e._zod.check=n=>{let r=n.value.split("/");try{if(r.length!==2)throw new Error;let[o,i]=r;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://[${o}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});NN=K("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=TD),Jt.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{DN(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});jN=K("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=O$),Jt.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{aZ(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),LN=K("$ZodE164",(e,t)=>{t.pattern??(t.pattern=DD),Jt.init(e,t)});MN=K("$ZodJWT",(e,t)=>{Jt.init(e,t),e._zod.check=n=>{cZ(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),FN=K("$ZodCustomStringFormat",(e,t)=>{Jt.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})}}),M$=K("$ZodNumber",(e,t)=>{rt.init(e,t),e._zod.pattern=e._zod.bag.pattern??P$,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;let i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),n}}),WN=K("$ZodNumberFormat",(e,t)=>{qD.init(e,t),M$.init(e,t)}),Wy=K("$ZodBoolean",(e,t)=>{rt.init(e,t),e._zod.pattern=GD,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),F$=K("$ZodBigInt",(e,t)=>{rt.init(e,t),e._zod.pattern=FD,e._zod.parse=(n,r)=>{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}}),GN=K("$ZodBigIntFormat",(e,t)=>{KD.init(e,t),F$.init(e,t)}),BN=K("$ZodSymbol",(e,t)=>{rt.init(e,t),e._zod.parse=(n,r)=>{let o=n.value;return typeof o=="symbol"||n.issues.push({expected:"symbol",code:"invalid_type",input:o,inst:e}),n}}),UN=K("$ZodUndefined",(e,t)=>{rt.init(e,t),e._zod.pattern=UD,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(n,r)=>{let o=n.value;return typeof o>"u"||n.issues.push({expected:"undefined",code:"invalid_type",input:o,inst:e}),n}}),HN=K("$ZodNull",(e,t)=>{rt.init(e,t),e._zod.pattern=BD,e._zod.values=new Set([null]),e._zod.parse=(n,r)=>{let o=n.value;return o===null||n.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),n}}),zN=K("$ZodAny",(e,t)=>{rt.init(e,t),e._zod.parse=n=>n}),VN=K("$ZodUnknown",(e,t)=>{rt.init(e,t),e._zod.parse=n=>n}),qN=K("$ZodNever",(e,t)=>{rt.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)}),KN=K("$ZodVoid",(e,t)=>{rt.init(e,t),e._zod.parse=(n,r)=>{let o=n.value;return typeof o>"u"||n.issues.push({expected:"void",code:"invalid_type",input:o,inst:e}),n}}),JN=K("$ZodDate",(e,t)=>{rt.init(e,t),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=new Date(n.value)}catch{}let o=n.value,i=o instanceof Date;return i&&!Number.isNaN(o.getTime())||n.issues.push({expected:"date",code:"invalid_type",input:o,...i?{received:"Invalid Date"}:{},inst:e}),n}});ZN=K("$ZodArray",(e,t)=>{rt.init(e,t),e._zod.parse=(n,r)=>{let o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);let i=[];for(let s=0;s<o.length;s++){let a=o[s],c=t.element._zod.run({value:a,issues:[]},r);c instanceof Promise?i.push(c.then(l=>Z3(l,n,s))):Z3(c,n,s)}return i.length?Promise.all(i).then(()=>n):n}});uZ=K("$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 r=bf(()=>lZ(t));ht(e._zod,"propValues",()=>{let a=t.shape,c={};for(let l in a){let d=a[l]._zod;if(d.values){c[l]??(c[l]=new Set);for(let u of d.values)c[l].add(u)}}return c});let o=ru,i=t.catchall,s;e._zod.parse=(a,c)=>{s??(s=r.value);let l=a.value;if(!o(l))return a.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),a;a.value={};let d=[],u=s.shape;for(let p of s.keys){let f=u[p],g=f._zod.optout==="optional",m=f._zod.run({value:l[p],issues:[]},c);m instanceof Promise?d.push(m.then(h=>L$(h,a,p,l,g))):L$(m,a,p,l,g)}return i?dZ(d,l,a,c,r.value,e):d.length?Promise.all(d).then(()=>a):a}}),YN=K("$ZodObjectJIT",(e,t)=>{uZ.init(e,t);let n=e._zod.parse,r=bf(()=>lZ(t)),o=p=>{let f=new Fy(["shape","payload","ctx"]),g=r.value,m=v=>{let k=m$(v);return`shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`};f.write("const input = payload.value;");let h=Object.create(null),w=0;for(let v of g.keys)h[v]=`key_${w++}`;f.write("const newResult = {};");for(let v of g.keys){let k=h[v],x=m$(v),E=p[v]?._zod?.optout==="optional";f.write(`const ${k} = ${m(v)};`),E?f.write(`
@@ -106,7 +106,7 @@ status:${e.status}`,"utf-8")])}function vNe(e,t,n){let r=`the approval of gate $
106
106
  `+I.slice(ue+1):Ne+=I.slice(he),Ne.slice(1)}function Fn(I){let Y="",oe=0;for(let fe=0;fe<I.length;oe>=65536?fe+=2:fe++){oe=Pe(I,fe);let he=A[oe];!he&&se(oe)?(Y+=I[fe],oe>=65536&&(Y+=I[fe+1])):Y+=he||J(oe)}return Y}function yr(I,Y,oe){let fe="",he=I.tag;for(let ke=0,ue=oe.length;ke<ue;ke+=1){let Ae=oe[ke];I.replacer&&(Ae=I.replacer.call(oe,String(ke),Ae)),(V(I,Y,Ae,!1,!1)||typeof Ae>"u"&&V(I,Y,null,!1,!1))&&(fe!==""&&(fe+=","+(I.condenseFlow?"":" ")),fe+=I.dump)}I.tag=he,I.dump="["+fe+"]"}function qr(I,Y,oe,fe){let he="",ke=I.tag;for(let ue=0,Ae=oe.length;ue<Ae;ue+=1){let Ne=oe[ue];I.replacer&&(Ne=I.replacer.call(oe,String(ue),Ne)),(V(I,Y+1,Ne,!0,!0,!1,!0)||typeof Ne>"u"&&V(I,Y+1,null,!0,!0,!1,!0))&&((!fe||he!=="")&&(he+=U(I,Y)),I.dump&&a===I.dump.charCodeAt(0)?he+="-":he+="- ",he+=I.dump)}I.tag=ke,I.dump=he||"[]"}function Ir(I,Y,oe){let fe="",he=I.tag,ke=Object.keys(oe);for(let ue=0,Ae=ke.length;ue<Ae;ue+=1){let Ne="";fe!==""&&(Ne+=", "),I.condenseFlow&&(Ne+='"');let qe=ke[ue],Ze=oe[qe];I.replacer&&(Ze=I.replacer.call(oe,qe,Ze)),V(I,Y,qe,!1,!1)&&(I.dump.length>1024&&(Ne+="? "),Ne+=I.dump+(I.condenseFlow?'"':"")+":"+(I.condenseFlow?"":" "),V(I,Y,Ze,!1,!1)&&(Ne+=I.dump,fe+=Ne))}I.tag=he,I.dump="{"+fe+"}"}function ol(I,Y,oe,fe){let he="",ke=I.tag,ue=Object.keys(oe);if(I.sortKeys===!0)ue.sort();else if(typeof I.sortKeys=="function")ue.sort(I.sortKeys);else if(I.sortKeys)throw new t("sortKeys must be a boolean or a function");for(let Ae=0,Ne=ue.length;Ae<Ne;Ae+=1){let qe="";(!fe||he!=="")&&(qe+=U(I,Y));let Ze=ue[Ae],Xe=oe[Ze];if(I.replacer&&(Xe=I.replacer.call(oe,Ze,Xe)),!V(I,Y+1,Ze,!0,!0,!0))continue;let ut=I.tag!==null&&I.tag!=="?"||I.dump&&I.dump.length>1024;ut&&(I.dump&&a===I.dump.charCodeAt(0)?qe+="?":qe+="? "),qe+=I.dump,ut&&(qe+=U(I,Y)),V(I,Y+1,Xe,!0,ut)&&(I.dump&&a===I.dump.charCodeAt(0)?qe+=":":qe+=": ",qe+=I.dump,he+=qe)}I.tag=ke,I.dump=he||"{}"}function R(I,Y,oe){let fe=oe?I.explicitTypes:I.implicitTypes;for(let he=0,ke=fe.length;he<ke;he+=1){let ue=fe[he];if((ue.instanceOf||ue.predicate)&&(!ue.instanceOf||typeof Y=="object"&&Y instanceof ue.instanceOf)&&(!ue.predicate||ue.predicate(Y))){if(oe?ue.multi&&ue.representName?I.tag=ue.representName(Y):I.tag=ue.tag:I.tag="?",ue.represent){let Ae=I.styleMap[ue.tag]||ue.defaultStyle,Ne;if(r.call(ue.represent)==="[object Function]")Ne=ue.represent(Y,Ae);else if(o.call(ue.represent,Ae))Ne=ue.represent[Ae](Y,Ae);else throw new t("!<"+ue.tag+'> tag resolver accepts not "'+Ae+'" style');I.dump=Ne}return!0}}return!1}function V(I,Y,oe,fe,he,ke,ue){I.tag=null,I.dump=oe,R(I,oe,!1)||R(I,oe,!0);let Ae=r.call(I.dump),Ne=fe;fe&&(fe=I.flowLevel<0||I.flowLevel>Y);let qe=Ae==="[object Object]"||Ae==="[object Array]",Ze,Xe;if(qe&&(Ze=I.duplicates.indexOf(oe),Xe=Ze!==-1),(I.tag!==null&&I.tag!=="?"||Xe||I.indent!==2&&Y>0)&&(he=!1),Xe&&I.usedDuplicates[Ze])I.dump="*ref_"+Ze;else{if(qe&&Xe&&!I.usedDuplicates[Ze]&&(I.usedDuplicates[Ze]=!0),Ae==="[object Object]")fe&&Object.keys(I.dump).length!==0?(ol(I,Y,I.dump,he),Xe&&(I.dump="&ref_"+Ze+I.dump)):(Ir(I,Y,I.dump),Xe&&(I.dump="&ref_"+Ze+" "+I.dump));else if(Ae==="[object Array]")fe&&I.dump.length!==0?(I.noArrayIndent&&!ue&&Y>0?qr(I,Y-1,I.dump,he):qr(I,Y,I.dump,he),Xe&&(I.dump="&ref_"+Ze+I.dump)):(yr(I,Y,I.dump),Xe&&(I.dump="&ref_"+Ze+" "+I.dump));else if(Ae==="[object String]")I.tag!=="?"&&Mt(I,I.dump,Y,ke,Ne);else{if(Ae==="[object Undefined]")return!1;if(I.skipInvalid)return!1;throw new t("unacceptable kind of an object to dump "+Ae)}if(I.tag!==null&&I.tag!=="?"){let ut=encodeURI(I.tag[0]==="!"?I.tag.slice(1):I.tag).replace(/!/g,"%21");I.tag[0]==="!"?ut="!"+ut:ut.slice(0,18)==="tag:yaml.org,2002:"?ut="!!"+ut.slice(18):ut="!<"+ut+">",I.dump=ut+" "+I.dump}}return!0}function re(I,Y){let oe=[],fe=[];de(I,oe,fe);let he=fe.length;for(let ke=0;ke<he;ke+=1)Y.duplicates.push(oe[fe[ke]]);Y.usedDuplicates=new Array(he)}function de(I,Y,oe){if(I!==null&&typeof I=="object"){let fe=Y.indexOf(I);if(fe!==-1)oe.indexOf(fe)===-1&&oe.push(fe);else if(Y.push(I),Array.isArray(I))for(let he=0,ke=I.length;he<ke;he+=1)de(I[he],Y,oe);else{let he=Object.keys(I);for(let ke=0,ue=he.length;ke<ue;ke+=1)de(I[he[ke]],Y,oe)}}}function ne(I,Y){Y=Y||{};let oe=new G(Y);oe.noRefs||re(I,oe);let fe=I;return oe.replacer&&(fe=oe.replacer.call({"":fe},"",fe)),V(oe,0,fe,!0,!0)?oe.dump+`
107
107
  `:""}return vB.dump=ne,vB}function wGe(){if($re)return Lr;$re=1;let e=hGe(),t=yGe();function n(r,o){return function(){throw new Error("Function yaml."+r+" is removed in js-yaml 4. Use yaml."+o+" instead, which is now safe by default.")}}return Lr.Type=io(),Lr.Schema=Sre(),Lr.FAILSAFE_SCHEMA=Are(),Lr.JSON_SCHEMA=Dre(),Lr.CORE_SCHEMA=Nre(),Lr.DEFAULT_SCHEMA=kB(),Lr.load=e.load,Lr.loadAll=e.loadAll,Lr.dump=t.dump,Lr.YAMLException=Rb(),Lr.types={binary:Mre(),float:Tre(),map:Pre(),null:Cre(),pairs:Wre(),set:Gre(),timestamp:jre(),bool:_re(),int:Ire(),merge:Lre(),omap:Fre(),seq:Ore(),str:Ere()},Lr.safeLoad=n("safeLoad","load"),Lr.safeLoadAll=n("safeLoadAll","loadAll"),Lr.safeDump=n("safeDump","dump"),Lr}var Lr,CO,Dl,ere,XG,tre,eB,nre,tB,rre,nB,ore,rB,ire,oB,sre,iB,are,sB,cre,aB,lre,cB,dre,lB,ure,dB,pre,uB,fre,pB,gre,fB,mre,gB,hre,mB,yre,hB,wre,yB,bre,wB,vre,bB,kre,Rre,vB,xre,$re,bGe,ic,ARt,CRt,_Rt,IRt,TRt,DRt,NRt,jRt,LRt,MRt,FRt,WRt,GRt,BRt,_O=$(()=>{Lr={},CO={},Dl={};vB={};bGe=wGe(),ic=gGe(bGe),{Type:ARt,Schema:CRt,FAILSAFE_SCHEMA:_Rt,JSON_SCHEMA:IRt,CORE_SCHEMA:TRt,DEFAULT_SCHEMA:DRt,load:NRt,loadAll:jRt,dump:LRt,YAMLException:MRt,types:FRt,safeLoad:WRt,safeLoadAll:GRt,safeDump:BRt}=ic});import{existsSync as Bre,readFileSync as jO}from"node:fs";import{isAbsolute as TO,join as xB,relative as DO,resolve as NO}from"node:path";function FO(e=[]){let t=new Map;for(let n of[...Ure,...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 Hre(){return FO()}function $B(e,t,n){if("directory"in e.probe)return!0;if("chantProject"in e.probe)return EB(t,n);if("repo"in e.probe)return!0;let{anyFile:r,anyBlock:o,anyJsonKey:i,anyLine:s,anyDocument:a}=e.probe;if(r&&xb(t,n,r).length>0)return!0;if(i)for(let c of xb(t,n,i.in))try{let l=JSON.parse(t.read(c));if(i.pointers.some(d=>zre(l,d)!==void 0))return!0}catch{}if(s){let c=s.starts.map(l=>l.toLowerCase());for(let l of xb(t,n,s.in))try{if(t.read(l).split(/\r?\n/).some(d=>c.some(u=>d.trimStart().toLowerCase().startsWith(u))))return!0}catch{}}if(a)for(let c of xb(t,n,a.in))try{if(xGe(t.read(c)).some(l=>a.match.some(d=>$Ge(l,d))))return!0}catch{}if(o){let c=new RegExp(`^\\s*(?:${o.blocks.map(SB).join("|")})\\s*\\{`,"m");for(let l of xb(t,n,o.in))try{if(c.test(t.read(l)))return!0}catch{}}return!1}function RGe(e){return!("directory"in e)&&!("chantProject"in e)&&!("repo"in e)}function xb(e,t,n){let r=[],o=n.filter(i=>i.includes("*"));for(let i of n)!i.includes("*")&&e.stat(je(t,i))==="file"&&r.push(je(t,i));if(o.length>0){let i=o.map(s=>new RegExp(`^${s.split("*").map(a=>SB(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))&&r.push(je(t,s.name))}return r.sort()}function xGe(e){try{return ic.loadAll(e)}catch{try{return ic.loadAll(e.replace(/(^|[\s:\-[,{])!(?:[A-Za-z][\w]*:?)+/gm,"$1"))}catch{return[]}}}function $Ge(e,t){let n=Object.entries(t);return n.length>0&&n.every(([r,o])=>{let i=zre(e,r);return i===void 0?!1:o.some(s=>new RegExp(`^${s.split("*").map(SB).join(".*")}$`).test(String(i)))})}function zre(e,t){let n=e;for(let r of t.split("/").slice(1)){let o=r.replace(/~1/g,"/").replace(/~0/g,"~");if(n===null||typeof n!="object"||!Object.prototype.hasOwnProperty.call(n,o))return;n=n[o]}return n}function SB(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Vre(e,t,n,r=[]){let o=e.all().filter(s=>s.shape==="member"&&RGe(s.probe)&&!r.includes(s.name)&&$B(s,t,n)).sort((s,a)=>a.precedence-s.precedence||(s.name<a.name?-1:1)),i=o.filter(s=>s.precedence===o[0]?.precedence);return{claims:o,winner:i.length===1?i[0]:void 0,tie:i.length>1?i:[]}}function EB(e,t){let n=je(t,"package.json");if(e.stat(n)==="file")try{let o=JSON.parse(e.read(n));for(let i of["dependencies","devDependencies","peerDependencies"]){let s=o[i];if(s&&typeof s=="object"&&Object.keys(s).some(OGe))return!0}}catch{}let r=(o,i)=>{let s=e.list(o)??[];return s.some(a=>a.type==="file"&&SGe.includes(a.name))?!0:i===EGe?!1:s.some(a=>a.type==="dir"&&!to(a.name)&&r(je(o,a.name),i+1))};return r(t,0)}function OGe(e){return e==="@intentius/chant"||e.startsWith("@intentius/chant-lexicon-")}function PGe(){if(IO)return IO;let e=oc();return IO=new e({allErrors:!0,strict:!0}).compile(OF),IO}function AGe(e,t){let n;try{n=JSON.parse(e)}catch(a){return{kinds:[],problems:[`${t}: the kinds file is not JSON (${a.message})`]}}let r=PGe();if(!r(n)){let a=(r.errors??[]).map(c=>`${t}: ${c.instancePath||"the kinds file"} ${c.message??"is invalid"}`);return{kinds:[],problems:[...new Set(a)]}}let o=[],i=[],s=new Set;for(let a of n.kinds){if(kGe.includes(a.name)){o.push(`${t}: kind ${a.name} is built in and can't be supplied by a package`);continue}if(s.has(a.name)){o.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.drift?{drift:{reader:a.drift.reader,config:structuredClone(a.drift.config??{})}}:{},...a.fields?{fields:structuredClone(a.fields)}:{},...a.reader&&RB.includes(a.reader)?{reader:a.reader}:{},...a.memberFile?{memberFile:{path:a.memberFile.path,schema:a.memberFile.schema}}:{}}),a.reader&&!RB.includes(a.reader)&&o.push(`${t}: kind ${a.name} names link reader ${a.reader}, which this chant does not have (it has ${RB.join(", ")}); the kind is kept, and its members' links are only those their entries state`);for(let c of IGe(a.fields??{}))o.push(`${t}: kind ${a.name} ${c}`)}return{kinds:i,problems:o}}function CGe(e,t=$b){return Bw(e,t)}function OB(e,t){let n=xB(e,"package.json"),r;try{r=JSON.parse(jO(n,"utf-8"))}catch{return{kinds:[],problems:[`${t??e}: no readable package.json in ${e}`],file:void 0}}let o=t??(typeof r.name=="string"?r.name:e),i=CGe(r);if(i===void 0)return{kinds:[],problems:[],file:void 0};if(typeof i!="string")return{kinds:[],problems:[`${o}: ${i.problem}`],file:void 0};let s=NO(e,i),a=DO(e,s);if(a.startsWith("..")||TO(a))return{kinds:[],problems:[`${o}: exports["${$b}"] points outside the package`],file:void 0};let c;try{c=jO(s,"utf-8")}catch{return{kinds:[],problems:[`${o}: exports["${$b}"] names ${i}, which does not exist`],file:s}}let l=AGe(c,o),d=typeof r.name=="string"?r.name:void 0;for(let u of l.kinds){if(u.packageDir=e,u.memberFile){let p=_Ge(u.memberFile,e);p&&l.problems.push(`${o}: kind ${u.name} ${p}; members of the kind fail WSP012 until it is fixed`)}if(u.graph?.reader){let p=NO(e,...u.graph.reader.split("/")),f=DO(e,p);f.startsWith("..")||TO(f)?(l.problems.push(`${o}: kind ${u.name} names graph reader ${u.graph.reader}, which is outside the package; the kind is kept, and workspace graph lists its members with kind-not-run`),delete u.graph):Bre(p)?u.graph.readerFile=p:(l.problems.push(`${o}: kind ${u.name} names graph reader ${u.graph.reader}, which does not exist in the package; the kind is kept, and workspace graph lists its members with kind-not-run`),delete u.graph)}else u.graph?.lexicon&&d!==LO(u.graph.lexicon)&&(l.problems.push(`${o}: kind ${u.name} reads its members with lexicon ${u.graph.lexicon}, which is ${LO(u.graph.lexicon)}, and this package is ${d??"unnamed"}; the kind is kept, and workspace graph lists its members with kind-not-run`),delete u.graph);if(u.drift){let p=NO(e,...u.drift.reader.split("/")),f=DO(e,p);f.startsWith("..")||TO(f)?(l.problems.push(`${o}: kind ${u.name} names drift reader ${u.drift.reader}, which is outside the package; the kind is kept, and workspace drift answers no-drift-read for its members`),delete u.drift):Bre(p)?u.drift.readerFile=p:(l.problems.push(`${o}: kind ${u.name} names drift reader ${u.drift.reader}, which does not exist in the package; the kind is kept, and workspace drift answers no-drift-read for its members`),delete u.drift)}}return{...l,file:s}}function _Ge(e,t){let n=NO(t,...e.schema.split("/"));e.schemaFile=n;let r=DO(t,n);if(r.startsWith("..")||TO(r))return`names member-file schema ${e.schema}, which is outside the package`;let o;try{o=JSON.parse(jO(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(o===null||typeof o!="object"||Array.isArray(o))return`names member-file schema ${e.schema}, which is not a JSON Schema object`;try{let i=oc();e.validate=new i({allErrors:!0,strict:!1}).compile(o)}catch(i){return`names member-file schema ${e.schema}, which does not compile as a draft 2020-12 schema (${i.message})`}}function LO(e){return`@intentius/chant-lexicon-${e}`}function PB(e,t){let n=o=>o.replace(/\{(member|dir|workspace)\}/g,(i,s)=>t[s]),r=o=>typeof o=="string"?n(o):Array.isArray(o)?o.map(r):o!==null&&typeof o=="object"?Object.fromEntries(Object.entries(o).map(([i,s])=>[n(i),r(s)])):o;return r(e)}function AB(e,t,n=bu){if(e.package){let r=ia(e.package,t)??ia(e.package,n);if(!r)return{problem:`pinned package ${e.package} is not installed; install it to read the kinds it supplies`};let o;try{o=JSON.parse(jO(xB(r,"package.json"),"utf-8")).version}catch{o=void 0}return e.version&&o!==e.version?{problem:`${e.package} is pinned at ${e.version}, and ${String(o??"an unknown version")} is installed`}:{dir:r,source:e.package}}if(e.path){let r=xB(t,...e.path.split("/"));if(e.integrity){let o=YX(r,e.integrity,e.path);if(!o.ok)return{problem:o.message}}return{dir:r,source:e.path}}return null}function Iu(e,t){let n=[],r=[],o=new Map,i=new Set;return e.forEach((s,a)=>{let c=AB(s,t);if(c===null)return;if("problem"in c){n.push({pin:a,message:c.problem});return}let{dir:l,source:d}=c,u=OB(l,d);for(let p of u.problems)n.push({pin:a,message:p});for(let p of u.kinds){let f=o.get(p.name);if(f){i.add(p.name),n.push({pin:a,message:`kind ${p.name} is supplied by both ${f} and ${d}; a kind name has one source`});continue}o.set(p.name,d),r.push(p)}}),{registry:FO(r.filter(s=>!i.has(s.name))),problems:n}}function qre(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 r;try{r=new RegExp(e.pattern,"u")}catch{return}if(!r.test(t))return`is ${JSON.stringify(t)}, which does not match ${e.pattern}`}}function IGe(e){let t=[],n=(r,o)=>{if(o.pattern!==void 0)try{new RegExp(o.pattern,"u")}catch{t.push(`declares field ${r} with pattern ${o.pattern}, which is not a regular expression`);return}if(o.default===void 0)return;let i=qre(o,o.default);i&&t.push(`declares field ${r} whose default ${i}`)};for(let[r,o]of Object.entries(e))if(o.type==="object")for(let[i,s]of Object.entries(o.properties))n(`${r}.${i}`,s);else n(r,o);return t}function CB(e,t){if(e===void 0)return{fields:null,problems:[]};let n=e.fields,r=[];if(n===void 0)return t!==null&&r.push({path:"",message:`kind ${e.name} declares no fields, and the entry sets ${Object.keys(t).join(", ")||"an empty fields block"}`}),{fields:null,problems:r};let o=t??{};for(let a of Object.keys(o))a in n||r.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 d=qre(c,l);if(!d)return l;r.push({path:a,message:`field ${a.replace("/",".")} ${d}`})}return c.default??null},s={};for(let[a,c]of Object.entries(n)){if(c.type!=="object"){s[a]=i(a,c,o[a]);continue}let l=o[a],d={};l!==void 0&&(l!==null&&typeof l=="object"&&!Array.isArray(l)?d=l:r.push({path:a,message:`field ${a} is ${JSON.stringify(l)}, and the field is an object`}));for(let u of Object.keys(d))u in c.properties||r.push({path:`${a}/${u}`,message:`kind ${e.name} declares no field ${a}.${u}; ${a} has ${Object.keys(c.properties).join(", ")}`});s[a]=Object.fromEntries(Object.entries(c.properties).map(([u,p])=>[u,i(`${a}/${u}`,p,d[u])]))}return{fields:s,problems:r}}var QRt,$b,RB,MO,sc,vGe,Ure,kGe,SGe,EGe,IO,oi=$(()=>{"use strict";VX();qt();QX();Sl();vb();_O();QRt=OF.$id,$b="./workspace-kinds",RB=["dbt-project","goose-dir","golang-migrate-dir","clickhouse-migrations-dir","flyway-dir"],MO="examples",sc="repo",vGe="design",Ure=[{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:sc,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:vGe,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:MO,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"}],kGe=Ure.map(e=>e.name);SGe=["chant.config.ts","chant.config.json"],EGe=4});function ac(e){return String(e).replace(/~/g,"~0").replace(/\//g,"~1")}function Nl(e,t){let n=[0];for(let h=0;h<e.length;h++)e.charCodeAt(h)===10&&n.push(h+1);let r=h=>{let w=0,b=n.length-1;for(;w<b;){let v=w+b+1>>1;n[v]<=h?w=v:b=v-1}return{line:w+1,column:h-n[w]+1}},o=new Map,i=new Map,s=new Map,a=e.charCodeAt(0)===65279?1:0,c=(h,w=a)=>{throw new WO(h,w)},l=h=>h>=e.length?"the end of the file":`${JSON.stringify(e[h])}`;function d(){for(;;){let h=e[a];if(h===" "||h===" "||h===`
108
108
  `||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]!==`
109
- `;)a++;else{let w=e.indexOf("*/",a+2);w<0&&c("unterminated /* comment"),a=w+2}else return}}function u(){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){d(),o.set(h,a);let w=f(h);return i.set(h,a),w}function f(h){let w=e[a];if(w==="{")return g(h);if(w==="[")return m(h);if(w==='"')return u();for(let[v,k]of[["true",!0],["false",!1],["null",null]])if(e.startsWith(v,a))return a+=v.length,k;let b=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/.exec(e.slice(a,a+64));return b?(a+=b[0].length,Number(b[0])):c(`expected a value, found ${l(a)}`)}function g(h){let w={},b=new Set;if(a++,d(),e[a]==="}")return a++,w;for(;;){d(),e[a]!=='"'&&c(`expected a quoted key, found ${l(a)}`);let v=a,k=u();b.has(k)&&c(`duplicate key ${JSON.stringify(k)}`,v),b.add(k);let x=`${h}/${ac(k)}`;if(s.set(x,v),d(),e[a]!==":"&&c(`expected ":" after key ${JSON.stringify(k)}, found ${l(a)}`),a++,Object.defineProperty(w,k,{value:p(x),enumerable:!0,writable:!0,configurable:!0}),d(),e[a]===","){if(a++,d(),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 m(h){let w=[];if(a++,d(),e[a]==="]")return a++,w;for(;;){if(w.push(p(`${h}/${w.length}`)),d(),e[a]===","){if(a++,d(),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{d(),a>=e.length&&c("the file is empty");let h=p("");return d(),a<e.length&&c(`unexpected ${l(a)} after the value`),{ok:!0,value:h,locate(w,b){if(b&&s.has(w))return r(s.get(w));for(let v=w;;v=v.slice(0,v.lastIndexOf("/"))){let k=o.get(v);if(k!==void 0)return r(k);if(v==="")return r(0)}},span(w){let b=o.get(w),v=i.get(w);if(!(b===void 0||v===void 0))return{key:s.get(w)??null,start:b,end:v}}}}catch(h){if(!(h instanceof WO))throw h;return{ok:!1,message:h.message,location:r(h.offset)}}}var WO,Ig=$(()=>{"use strict";WO=class extends Error{constructor(n,r){super(n);this.offset=r}}});function Kre(){return"0.124.102"}var Jre=$(()=>{"use strict"});function Tg(e=process.env){let t=e.CI?.trim().toLowerCase();return t&&t!=="false"&&t!=="0"?"ledger":void 0}function GO(e){if(e!==void 0)return typeof e=="string"?{name:e}:e}function Tu(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 r=typeof e=="string"?{name:e}:e;if(r===null||typeof r!="object"||Array.isArray(r))return[...n,"`point` is a decision point's name or { name, inputs?, pass?, store? }"];let{name:o,inputs:i,pass:s,store:a,...c}=r;if((typeof o!="string"||!TGe.test(o))&&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 d=Object.keys(i).filter(u=>u in Sb);d.length>0&&n.push(`\`point.inputs\` gives ${d.join(", ")}, which the gate passes itself`)}s!==void 0&&(!Array.isArray(s)||s.length===0||s.some(d=>typeof d!="string"&&typeof d!="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 Du(e,t,n,r={}){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 o={};for(let[i,s]of Object.entries(Sb))t.includes(i)&&n[s]!==null&&(o[i]=n[s]);return{...r,...o}}function Eb(e,t,n){return`gate:${e}/${t}${n?`@${n}`:""}`}function BO(e){if(!e||!e.startsWith("gate:"))return;let t=e.slice(5),n=t.lastIndexOf("@"),r=n>0?t.slice(0,n):t,o=r.indexOf("/");if(!(o<=0||o===r.length-1))return{op:r.slice(0,o),gate:r.slice(o+1),...n>0?{env:t.slice(n+1)}:{}}}var Dg,TGe,Sb,cc=$(()=>{"use strict";Dg=[!0];TGe=/^[a-z][a-z0-9-]*$/;Sb={"gate.component":"component","gate.name":"name","gate.env":"env","gate.planDigest":"planDigest"}});function Di(e){return e===void 0?[]:Array.isArray(e)?[...e]:[e]}function _B(e,t){let n=e.replace(/\\/g,"/").replace(/\/+$/,""),r="";for(let o=0;o<n.length;o++){let i=n[o];i==="*"&&n[o+1]==="*"?n[o+2]==="/"?(r+="(?:.*/)?",o+=2):(r+=".*",o+=1):i==="*"?r+="[^/]*":i==="?"?r+="[^/]":r+=i.replace(/[.+^${}()|[\]\\]/g,"\\$&")}return new RegExp(`^${r}$`).test(t.replace(/\\/g,"/").replace(/\/+$/,""))}function Ng(e,t){return e.filter(n=>n.targets===void 0||n.targets.some(r=>t.some(o=>_B(r,o))))}function Pb(e){return e.reduce((t,n)=>Math.max(t,n.count),1)}function Ni(e,t,n){let r=Array.isArray(e)?e:[e],o=[];return Array.isArray(e)&&e.length===0&&o.push(`\`${t}\` must name at least one rule`),r.forEach((i,s)=>{let a=Array.isArray(e)?`${t}[${s}]`:t;if(typeof i!="object"||i===null||Array.isArray(i)){o.push(`\`${a}\` must be an object`);return}let c=i;(typeof c.count!="number"||!Number.isInteger(c.count)||c.count<1)&&o.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(d=>typeof d!="string"||d===""))&&o.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(d=>typeof d!="string"||d===""))&&o.push(`\`${a}.targets\` must be a non-empty list of globs`),c.notAuthor!==void 0&&typeof c.notAuthor!="boolean"&&o.push(`\`${a}.notAuthor\` must be true or false`),c.notAuthor===!0&&!n.notAuthor&&o.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 d of Object.keys(c))l.has(d)||o.push(`\`${a}.${d}\` is not a quorum field; use targets, count, roles or notAuthor`)}),o}function HO(e,t){return Object.entries(t).filter(([,n])=>n.some(r=>ii(r,e))).map(([n])=>n).sort()}function Ab(e,t){let n=new Set,r=[];for(let s of[...t].sort((a,c)=>Date.parse(a.at)-Date.parse(c.at)))n.has(UO(s.who))||s.judged.excluded!==void 0||e.roles?.length&&!(s.judged.proven&&s.judged.roles.some(a=>e.roles.includes(a)))||(n.add(UO(s.who)),r.push(s));let o=!e.notAuthor||r.some(s=>s.judged.proven&&s.judged.author===!1),i=e.notAuthor===!0&&!o&&r.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:r.map(s=>s.who),met:r.length>=e.count&&o,...i?{authorUnknown:!0}:{}}}function jl(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 r=e.count-e.approvers.length,o=[];r>0&&o.push(`${r} more${e.roles?.length?` from ${e.roles.join(" or ")}`:""}`),e.notAuthor&&o.push(r>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 ${o.join(", ")}${i}`}function Cb(e){return e.filter(t=>!t.met).map(jl).join("; ")}function zO(e){let t=[];for(let n of e.replace(/\r\n/g,`
109
+ `;)a++;else{let w=e.indexOf("*/",a+2);w<0&&c("unterminated /* comment"),a=w+2}else return}}function u(){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){d(),o.set(h,a);let w=f(h);return i.set(h,a),w}function f(h){let w=e[a];if(w==="{")return g(h);if(w==="[")return m(h);if(w==='"')return u();for(let[v,k]of[["true",!0],["false",!1],["null",null]])if(e.startsWith(v,a))return a+=v.length,k;let b=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/.exec(e.slice(a,a+64));return b?(a+=b[0].length,Number(b[0])):c(`expected a value, found ${l(a)}`)}function g(h){let w={},b=new Set;if(a++,d(),e[a]==="}")return a++,w;for(;;){d(),e[a]!=='"'&&c(`expected a quoted key, found ${l(a)}`);let v=a,k=u();b.has(k)&&c(`duplicate key ${JSON.stringify(k)}`,v),b.add(k);let x=`${h}/${ac(k)}`;if(s.set(x,v),d(),e[a]!==":"&&c(`expected ":" after key ${JSON.stringify(k)}, found ${l(a)}`),a++,Object.defineProperty(w,k,{value:p(x),enumerable:!0,writable:!0,configurable:!0}),d(),e[a]===","){if(a++,d(),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 m(h){let w=[];if(a++,d(),e[a]==="]")return a++,w;for(;;){if(w.push(p(`${h}/${w.length}`)),d(),e[a]===","){if(a++,d(),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{d(),a>=e.length&&c("the file is empty");let h=p("");return d(),a<e.length&&c(`unexpected ${l(a)} after the value`),{ok:!0,value:h,locate(w,b){if(b&&s.has(w))return r(s.get(w));for(let v=w;;v=v.slice(0,v.lastIndexOf("/"))){let k=o.get(v);if(k!==void 0)return r(k);if(v==="")return r(0)}},span(w){let b=o.get(w),v=i.get(w);if(!(b===void 0||v===void 0))return{key:s.get(w)??null,start:b,end:v}}}}catch(h){if(!(h instanceof WO))throw h;return{ok:!1,message:h.message,location:r(h.offset)}}}var WO,Ig=$(()=>{"use strict";WO=class extends Error{constructor(n,r){super(n);this.offset=r}}});function Kre(){return"0.124.103"}var Jre=$(()=>{"use strict"});function Tg(e=process.env){let t=e.CI?.trim().toLowerCase();return t&&t!=="false"&&t!=="0"?"ledger":void 0}function GO(e){if(e!==void 0)return typeof e=="string"?{name:e}:e}function Tu(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 r=typeof e=="string"?{name:e}:e;if(r===null||typeof r!="object"||Array.isArray(r))return[...n,"`point` is a decision point's name or { name, inputs?, pass?, store? }"];let{name:o,inputs:i,pass:s,store:a,...c}=r;if((typeof o!="string"||!TGe.test(o))&&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 d=Object.keys(i).filter(u=>u in Sb);d.length>0&&n.push(`\`point.inputs\` gives ${d.join(", ")}, which the gate passes itself`)}s!==void 0&&(!Array.isArray(s)||s.length===0||s.some(d=>typeof d!="string"&&typeof d!="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 Du(e,t,n,r={}){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 o={};for(let[i,s]of Object.entries(Sb))t.includes(i)&&n[s]!==null&&(o[i]=n[s]);return{...r,...o}}function Eb(e,t,n){return`gate:${e}/${t}${n?`@${n}`:""}`}function BO(e){if(!e||!e.startsWith("gate:"))return;let t=e.slice(5),n=t.lastIndexOf("@"),r=n>0?t.slice(0,n):t,o=r.indexOf("/");if(!(o<=0||o===r.length-1))return{op:r.slice(0,o),gate:r.slice(o+1),...n>0?{env:t.slice(n+1)}:{}}}var Dg,TGe,Sb,cc=$(()=>{"use strict";Dg=[!0];TGe=/^[a-z][a-z0-9-]*$/;Sb={"gate.component":"component","gate.name":"name","gate.env":"env","gate.planDigest":"planDigest"}});function Di(e){return e===void 0?[]:Array.isArray(e)?[...e]:[e]}function _B(e,t){let n=e.replace(/\\/g,"/").replace(/\/+$/,""),r="";for(let o=0;o<n.length;o++){let i=n[o];i==="*"&&n[o+1]==="*"?n[o+2]==="/"?(r+="(?:.*/)?",o+=2):(r+=".*",o+=1):i==="*"?r+="[^/]*":i==="?"?r+="[^/]":r+=i.replace(/[.+^${}()|[\]\\]/g,"\\$&")}return new RegExp(`^${r}$`).test(t.replace(/\\/g,"/").replace(/\/+$/,""))}function Ng(e,t){return e.filter(n=>n.targets===void 0||n.targets.some(r=>t.some(o=>_B(r,o))))}function Pb(e){return e.reduce((t,n)=>Math.max(t,n.count),1)}function Ni(e,t,n){let r=Array.isArray(e)?e:[e],o=[];return Array.isArray(e)&&e.length===0&&o.push(`\`${t}\` must name at least one rule`),r.forEach((i,s)=>{let a=Array.isArray(e)?`${t}[${s}]`:t;if(typeof i!="object"||i===null||Array.isArray(i)){o.push(`\`${a}\` must be an object`);return}let c=i;(typeof c.count!="number"||!Number.isInteger(c.count)||c.count<1)&&o.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(d=>typeof d!="string"||d===""))&&o.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(d=>typeof d!="string"||d===""))&&o.push(`\`${a}.targets\` must be a non-empty list of globs`),c.notAuthor!==void 0&&typeof c.notAuthor!="boolean"&&o.push(`\`${a}.notAuthor\` must be true or false`),c.notAuthor===!0&&!n.notAuthor&&o.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 d of Object.keys(c))l.has(d)||o.push(`\`${a}.${d}\` is not a quorum field; use targets, count, roles or notAuthor`)}),o}function HO(e,t){return Object.entries(t).filter(([,n])=>n.some(r=>ii(r,e))).map(([n])=>n).sort()}function Ab(e,t){let n=new Set,r=[];for(let s of[...t].sort((a,c)=>Date.parse(a.at)-Date.parse(c.at)))n.has(UO(s.who))||s.judged.excluded!==void 0||e.roles?.length&&!(s.judged.proven&&s.judged.roles.some(a=>e.roles.includes(a)))||(n.add(UO(s.who)),r.push(s));let o=!e.notAuthor||r.some(s=>s.judged.proven&&s.judged.author===!1),i=e.notAuthor===!0&&!o&&r.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:r.map(s=>s.who),met:r.length>=e.count&&o,...i?{authorUnknown:!0}:{}}}function jl(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 r=e.count-e.approvers.length,o=[];r>0&&o.push(`${r} more${e.roles?.length?` from ${e.roles.join(" or ")}`:""}`),e.notAuthor&&o.push(r>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 ${o.join(", ")}${i}`}function Cb(e){return e.filter(t=>!t.met).map(jl).join("; ")}function zO(e){let t=[];for(let n of e.replace(/\r\n/g,`
110
110
  `).split(`
111
111
  `)){let r=/^requested-by:\s*(\S+)\s*$/i.exec(n.trim());r&&DGe.test(r[1])&&!t.some(o=>ii(o,r[1]))&&t.push(r[1])}return t}function Ob(e){let t=/^(?:github|gitlab|forgejo|gitea|codeberg)(?:@[^:\s]+)?:(.+)$/i.exec(e.trim());return t?[e,t[1]]:[e]}function VO(e,t){let n=Ob(t);return e.find(r=>Ob(r.who).some(o=>n.some(i=>ii(o,i))))?.why}function _b(e){let t=[],n=(r,o)=>{r.trim()&&!t.some(i=>ii(i.who,r))&&t.push({who:r,why:o})};e.author&&n(e.author,`${e.author} opened the change`);for(let r of e.commits??[])for(let o of zO(r.message))n(e.principal?e.principal(o):o,`${o} asked for ${r.sha.slice(0,7)}`);for(let r of e.agents??[])n(r,`${r} is an account an agent acts as`);return t}function jg(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 Ib(e,t=n=>n){let n=[],r=[];for(let o of e){let i=jg(o);if(!i){n.push(o);continue}let s=i.reviewers.map(t);r.push({head:i.head,approvers:s});let{seal:a,...c}=o,l=Object.fromEntries(Object.entries(c).filter(([d])=>!["via","reviewers","head","pr","excluded"].includes(d)));for(let d of s)n.push({...l,resolvedBy:d,approver:{kind:"human"},review:{pr:i.pr??0,head:i.head,approvers:s}})}return{records:n,reviews:r}}function ji(e){let t=(n,r)=>n.some(o=>ii(o,r));return n=>{let r=n.seal!==void 0&&n.seal!==null&&ra(e.signers,n)===null,o=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=r||o||i,c=e.authors!==void 0&&e.authors.some(l=>ii(l,n.resolvedBy))?`${n.resolvedBy} wrote the change`:VO(e.involved??[],n.resolvedBy);return{proven:s,roles:s?HO(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 lc,UO,ii,dc,DGe,si=$(()=>{"use strict";ws();lc=()=>({proven:!1,roles:[]});UO=e=>e.normalize("NFKC").trim().toLowerCase(),ii=(e,t)=>UO(e)===UO(t);dc=e=>(e.roles?.length??0)>0||e.notAuthor===!0,DGe=/^[A-Za-z0-9][A-Za-z0-9._-]*(\[bot\])?$/});function IB(e,t,n){return(e??qO).replaceAll("{gate}",t).replaceAll("{k}",String(n))}function TB(e,t,n,r){let o=[...e].sort((l,d)=>{let u=r(l),p=r(d);return u<p?-1:u>p?1:0}),i=Math.floor(o.length/n),s=o.length%n,a=(t-1)*i+Math.min(t-1,s),c=i+(t<=s?1:0);return o.slice(a,a+c)}var qO,DB=$(()=>{"use strict";qO="{gate}-wave-{k}"});var YO={};me(YO,{WAVE_OUTCOME_VERSION:()=>KO,blockedMembers:()=>JO,blockedWords:()=>ZO,earlierWaveOutcomes:()=>Mg,onlyWaiting:()=>GGe,passesThrough:()=>Ll,readWaveOutcomeFile:()=>LB,runSummary:()=>BGe,settleEarlierWaves:()=>WGe,waveOutcomeFileName:()=>Lg,writeWaveOutcomeFile:()=>jB});import{existsSync as NGe,readdirSync as jGe,readFileSync as Zre,statSync as LGe,writeFileSync as MGe}from"node:fs";import{basename as FGe,join as Yre}from"node:path";function Ll(e){return e!==void 0&&NB.has(e.status)}function JO(e,t,n,r,o){if(o!==void 0)return new Map(e.map(s=>[s,`wave-${o}`]));let i=new Map;for(let s of e){let a=[...t.get(s)??[]].filter(c=>n.has(c)).sort().map(c=>{let l=r.get(c);if(!Ll(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 WGe(e,t,n,r){let o=new Map(r),i=[],s=new Set;for(let a=1;a<t&&a<=e.length;a++){let c=e[a-1],l=c.filter(u=>!o.has(u)),d=JO(l,n,s,o);for(let u of l){let p=d.get(u);p!==void 0?o.set(u,{status:"blocked",by:p}):i.push(u)}for(let u of c)s.add(u)}return{outcomes:o,unsettled:i}}function GGe(e){let t=!1;for(let n of e.values())if(!NB.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 ZO(e){let t=new Map;for(let[n,r]of[...e].sort(Qre))t.set(r,[...t.get(r)??[],n]);return[...t].map(([n,r])=>`${r.join(", ")} (blocked by ${n})`).join("; ")}function BGe(e){let t=new Map;for(let r of e)t.set(r.status,(t.get(r.status)??0)+1);if(![...t.keys()].some(r=>!NB.has(r)))return;let n=[`${t.get("applied")??0} applied`,`${t.get("failed")??0} failed`,`${t.get("blocked")??0} blocked`];for(let r of["waiting","refused","decided","not-applied"])t.get(r)&&n.push(`${t.get(r)} ${r==="decided"?"not reported by their share":r}`);return t.get("unchanged")&&n.push(`${t.get("unchanged")} unchanged`),n.join(", ")}function Lg(e,t={}){let n=t.group!==void 0?`-group-${t.group.replace(/[^A-Za-z0-9._-]/g,"_")}`:"",r=t.share!==void 0?`-share-${t.share}`:"",o=t.apply===!0&&!n&&!r?"-apply":"";return`outcome-wave-${e}${n}${r}${o}.json`}function jB(e,t,n,r,o=new Date().toISOString(),i=!1){let s=Yre(e,Lg(t,n)),a={version:KO,wave:t,at:o,members:Object.fromEntries(Object.entries(r).sort(Qre)),...i?{holds_all:!0}:{}};return MGe(s,JSON.stringify(a,null,2)+`
112
112
  `),s}function Xre(e){let t=[],n=(r,o)=>{let i;try{i=jGe(r)}catch{return}for(let s of i){let a=Yre(r,s),c=!1;try{c=LGe(a).isDirectory()}catch{continue}c?o<4&&n(a,o+1):/^outcome-wave-\d+.*\.json$/.test(s)&&t.push(a)}};for(let r of e)NGe(r)&&n(r,0);return t.sort()}function Mg(e,t){let n=new Map,r=new Map;for(let i of Xre(e)){let s;try{s=JSON.parse(Zre(i,"utf-8"))}catch{continue}let a=s?.members??s?.roots;if(s?.version!==KO||!Number.isInteger(s.wave)||s.wave>=t||typeof s.at!="string"||typeof a!="object"||a===null)continue;for(let[l,d]of Object.entries(a)){let u=n.get(l);u&&(u.at>s.at||u.at===s.at&&d.status==="decided"&&u.status!=="decided")||n.set(l,{...d,wave:s.wave,at:s.at})}let c=r.get(s.wave);(!c||c.at<=s.at)&&r.set(s.wave,{at:s.at,holdsAll:s.holds_all===!0})}let o=[...r].filter(([,i])=>i.holdsAll).map(([i])=>i).sort((i,s)=>i-s);return{members:n,...o.length?{holdsAll:o[0]}:{}}}function LB(e,t){let n;for(let r of Xre(e)){if(FGe(r)!==t)continue;let o;try{o=JSON.parse(Zre(r,"utf-8"))}catch{continue}o?.version!==KO||typeof o.at!="string"||typeof o.members!="object"||o.members===null||(!n||n.at<=o.at)&&(n=o)}return n}var KO,NB,Qre,Ml=$(()=>{"use strict";KO=1,NB=new Set(["applied","unchanged"]);Qre=([e],[t])=>e<t?-1:e>t?1:0});function Tb(e){if(e===void 0)return[];if(e===null||typeof e!="object"||Array.isArray(e))return["`evidence` must be an object"];let t=e,n=[];for(let r of Object.keys(t))r!=="requires"&&n.push(`\`evidence.${r}\` is not a setting; \`evidence\` takes \`requires\``);return t.requires!==void 0&&(!Array.isArray(t.requires)||t.requires.some(r=>typeof r!="string"||!/^[A-Za-z0-9][A-Za-z0-9._:-]*$/.test(r)))&&n.push("`evidence.requires` must be a list of check names (letters, digits, `.`, `_`, `:` and `-`, as `refs` in .chant/trust.json names them)"),n}var QO=$(()=>{"use strict"});function eP(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=[],r=t.kind;(typeof r!="string"||r.trim()==="")&&n.push('`step.kind` must name a capability, such as "terraform-apply"');for(let o of["plan","apply","planWave","applyWave"])e[o]!==void 0&&n.push(`\`step\` and \`${o}\` 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 o of e.waves){o.hooks?.apply?.runBy==="apply"&&n.push(`wave "${o.name}" hands its apply-stage hooks to an apply command, and a \`step\` has none`);for(let i of o.runs??[]){let s=i.input;s!==void 0&&(s===null||typeof s!="object"||Array.isArray(s))&&n.push(`wave "${o.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 "${o.name}" run "${i.target}": \`input\` cannot change the step's kind`)}}return n}function eoe(e){let t=[];for(let[n,r]of[["parallelism",e.parallelism],...e.waves.map(o=>[`wave "${o.name}" parallelism`,o.parallelism])])r!==void 0&&(typeof r!="number"||!Number.isInteger(r)||r<1?t.push(`${n} is ${JSON.stringify(r)}; give a whole number of 1 or more, the most that run at once`):r>1&&e.step===void 0&&t.push(`${n} is ${r}, and runs apply at once only through \`step\`; drop it or give step`));return t}function Wg(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,r]of Object.entries(e))n==="policy"?typeof r!="boolean"&&t.push("`holds.policy` must be true or false"):n==="cost"?t.push(...UGe(r)):t.push(`\`holds.${n}\` is not a setting; the ones there are holds.policy and holds.cost`);return t}function UGe(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(r=>typeof r=="string"&&r!==""))&&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&&!XO.includes(t.format)&&n.push(`\`holds.cost.format\` must be ${XO.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 r of Object.keys(t))["command","approveAbove","format","currency"].includes(r)||n.push(`\`holds.cost.${r}\` is not a setting`);return n}function tP(e,t){let n=e?.policy===!0||t?.policy===!0,r=e!==void 0?e.cost:t?.cost;if(!(!n&&!r))return{...n?{policy:!0}:{},...r?{cost:r}:{}}}var XO,Fg,Db=$(()=>{"use strict";XO=["infracost","chant"],Fg="(monthly cost)"});function MB(e){let t=[],n=(r,o,i)=>{if(r!==void 0&&!(r===!1&&i)){if(r===null||typeof r!="object"||Array.isArray(r)){t.push(`${o} must be { "env"?: "<env>", "component"?: "<name>" }${i?" or false":""}`);return}for(let[s,a]of Object.entries(r))s!=="env"&&s!=="component"?t.push(`${o} has an unknown key "${s}"; it takes env and component`):(typeof a!="string"||a.trim()==="")&&t.push(`${o}.${s} must be a non-empty string`)}};n(e.release,"`release`",!0);for(let r of e.waves)for(let o of r.runs??[])n(o.release,`wave "${r.name}" run "${o.target}": \`release\``,!1);return t}function toe(e,t){return e.replaceAll("{target}",t.target).replaceAll("{op}",t.op).replaceAll("{wave}",t.wave)}function FB(e,t,n){if(!e.step||e.release===!1)return null;let r={target:n.target,op:n.op??e.op,wave:t.name},o=e.release??{},i=n.release?.env??o.env,s=n.release?.component??o.component;return{env:i!==void 0?toe(i,r):e.labels?.Env??t.name,component:s!==void 0?toe(s,r):n.target}}function WB(e,t,n,r){let o=new Map;for(let a of t){let c=o.get(a.releaseDigest);(c===void 0||a.timestamp>c)&&o.set(a.releaseDigest,a.timestamp)}let s=e.filter(a=>a.commit===n.commit).map(a=>({r:a,digest:r(a,n.env,n.component)})).filter(a=>a.digest!==null).sort((a,c)=>(o.get(c.r.releaseDigest)??"").localeCompare(o.get(a.r.releaseDigest)??"")||a.r.releaseDigest.localeCompare(c.r.releaseDigest))[0];return s?{releaseDigest:s.r.releaseDigest,templatesDigest:s.digest}:null}var Nb=$(()=>{"use strict"});function UB(e){let t=[];return typeof e.train=="string"&&zGe.test(e.train)||t.push("train must be a release train's id"),typeof e.run=="string"&&VGe.test(e.run)||t.push("run must be a workspace run's id"),typeof e.env=="string"&&Gg.test(e.env)||t.push("env must be an environment's name"),typeof e.releaseDigest=="string"&&qGe.test(e.releaseDigest)||t.push("releaseDigest must be a release digest"),t}function Fb(e){let n=e.replace(/^https?:\/\//,"").replace(/\.git$/,"").replace(/\/+$/,"").split("/");if(n.length<3||n.some(i=>i===""))throw new jb(`project key "${e}" must be <host>/<owner>/<name>, such as github.com/acme/infra`);let[r,...o]=n;return{key:e,host:r,path:o.join("/"),owner:o.slice(0,-1).join("/"),name:o[o.length-1]}}function coe(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 JGe(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 zB(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,r=[],o;if(typeof n.repo!="string")r.push(`${t}.repo must name the control repo, such as github.com/acme/control`);else try{o=Fb(n.repo).host}catch(i){r.push(`${t}.repo: ${i.message}`)}return typeof n.op=="string"&&Gg.test(n.op)||r.push(`${t}.op must name the Op the control repo runs on this repo's dependents, such as deploy`),n.forge!==void 0&&!roe.includes(n.forge)&&r.push(`${t}.forge must be one of ${roe.join(", ")}`),o!==void 0&&n.forge===void 0&&!coe(o)&&r.push(`${t}.forge is needed: ${n.repo}'s host does not say which forge it is`),n.member!==void 0&&!(typeof n.member=="string"&&Gg.test(n.member))&&r.push(`${t}.member must be this repo's name in the control repo's workspace`),n.tokenSecret!==void 0&&!(typeof n.tokenSecret=="string"&&noe.test(n.tokenSecret))&&r.push(`${t}.tokenSecret must name the secret holding the dispatch token, such as ${GB}`),n.readTokenSecret!==void 0&&!(typeof n.readTokenSecret=="string"&&noe.test(n.readTokenSecret))?r.push(`${t}.readTokenSecret must name the secret holding a read-only token for the control repo, such as ${ooe}`):typeof n.readTokenSecret=="string"&&n.readTokenSecret===(n.tokenSecret??GB)&&r.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"&&HGe.test(n.ref))&&r.push(`${t}.ref must be a branch name`),n.apiBase!==void 0&&!(typeof n.apiBase=="string"&&/^https?:\/\/[^\s'"]+$/.test(n.apiBase))&&r.push(`${t}.apiBase must be an http(s) URL`),r}function loe(e,t){let n=zB(e);if(n.length>0)throw new jb(n.join("; "),n);let r=Fb(e.repo),o=e.forge??coe(r.host),i=e.member??t;if(!Gg.test(i))throw new jb(`control.member: "${i}" is not a name the control repo's workspace can hold; set control.member`);return{repo:e.repo,host:r.host,path:r.path,forge:o,apiBase:(e.apiBase??JGe(o,r.host)).replace(/\/+$/,""),op:e.op,member:i,ref:e.ref??KGe,tokenSecret:e.tokenSecret??GB,readTokenSecret:e.readTokenSecret??ooe}}var Gg,HGe,noe,GB,ooe,Lb,BB,ioe,soe,aoe,zGe,VGe,qGe,Mb,HB,KGe,jb,roe,doe,Bg=$(()=>{"use strict";_o();Gg=/^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/,HGe=/^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/,noe=/^[A-Za-z_][A-Za-z0-9_]{0,127}$/,GB="CHANT_CONTROL_TOKEN",ooe="CHANT_CONTROL_READ_TOKEN",Lb="CHANT_CONTROL_OUTCOME",BB="CHANT_CONTROL_TRAIN",ioe="CHANT_CONTROL_RUN",soe="CHANT_CONTROL_ENV",aoe="CHANT_CONTROL_RELEASE",zGe=/^train-[A-Za-z0-9-]{1,64}$/,VGe=/^ws-[A-Za-z0-9-]{1,64}$/,qGe=/^[a-z0-9]+(-[a-z0-9]+)*:[0-9a-f]{64}$/;Mb=["applied","partial","unchanged","waiting","failed"],HB=["applied","partial"],KGe="main",jb=class extends Error{constructor(n,r=[n]){super(n);this.problems=r;this.name="ControlConfigError"}};roe=["github","gitlab","forgejo"];doe="control-dispatch"});var uP={};me(uP,{CHECK_HOOK_MOMENT:()=>ZGe,CI_CHECK_HOOK_FLOOR:()=>YGe,GATE_APPROVAL_SOURCES:()=>uc,OP_LEDGER_NAME:()=>Vg,OP_WAVES_APPROVAL_STATUS_VAR:()=>lBe,OP_WAVES_CONTROL_FLOOR:()=>QGe,OP_WAVES_CONTROL_JOB:()=>XGe,OP_WAVES_DIGEST_OVER:()=>goe,OP_WAVE_APPLY_HOOKS_RUNNERS:()=>nP,OP_WAVE_DEFAULT_APPLY:()=>iP,OP_WAVE_DEFAULT_GATE_NAME:()=>KB,OP_WAVE_GATE_POLICIES:()=>Hg,OP_WAVE_HOOK_FAILURES:()=>zg,OP_WAVE_HOOK_MOMENTS:()=>Gb,OP_WAVE_JOB_TIMEOUT_MINUTES:()=>foe,PR_LOOP_HOOK_MOMENTS:()=>hoe,assertCheckHooks:()=>yoe,assertOpWaveCloud:()=>JB,assertOpWaveHooks:()=>pc,assertOpWavesSpec:()=>Lu,assertPrLoopHooks:()=>dP,notifyVariables:()=>cX,opWaveApplyHooksRunBy:()=>Hb,opWaveAt:()=>Mu,opWaveBinArgv:()=>qg,opWaveChecksDir:()=>sP,opWaveGateName:()=>Bb,opWaveGroupOf:()=>hBe,opWaveGroupRuns:()=>cP,opWaveGroupsProblem:()=>lP,opWaveHookRuns:()=>Fl,opWaveHooksAt:()=>Ub,opWaveJobArtifactName:()=>sBe,opWaveJobArtifactPaths:()=>iBe,opWaveJobInputsByWave:()=>oBe,opWaveJobTimeout:()=>rBe,opWaveJobs:()=>woe,opWaveOf:()=>yBe,opWaveOutcomeDir:()=>la,opWaveOutcomePath:()=>Nu,opWavePointAt:()=>rP,opWavePointOf:()=>uoe,opWavePointProblems:()=>Wb,opWaveRecordPath:()=>ai,opWaveRunMatches:()=>aP,opWaveShare:()=>zb,opWavesApprovalStatusCommand:()=>uBe,opWavesControlProblems:()=>poe,opWavesControlTarget:()=>eBe,opWavesInvolvedProblems:()=>oP,opWavesLastJobs:()=>nBe,opWavesOutcomeCommand:()=>tBe,opWavesPostsApprovalStatus:()=>dBe,opWavesRecordPlansCommand:()=>cBe,opWavesResumeCommand:()=>aBe,waveApproveTarget:()=>ju});function uoe(e){if(e!==void 0)return typeof e=="string"?{name:e}:e}function Wb(e){if(e!==null&&typeof e=="object"&&!Array.isArray(e)&&"timeout"in e){let{timeout:t,...n}=e,r=Tu(n);return(typeof t!="string"||!/^(\d+(ms|s|m|h|d))+$/.test(t))&&r.push('`point.timeout` is a duration such as "48h"'),r}return Tu(e)}function rP(e,t){let n=e.waves.find(r=>r.name===t);return uoe(n?.point??e.point)}function ju(e,t){return t.length===1?t[0]:e}function poe(e){let t=zB(e,"control");if(t.length>0)return t;let n=e,r=[];typeof n.member=="string"&&Gg.test(n.member)||r.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 o of["sentCheck","markSent"])n[o]!==void 0&&!(typeof n[o]=="string"&&n[o]!==""&&!n[o].includes(`
@@ -532,7 +532,7 @@ Approve this plan for ${h}, ${g}? Type ${h} to approve: `);if(O===null||O.trim()
532
532
  `),r(u?`${Buffer.from(d,"utf8").subarray(0,I3).toString("utf8")}
533
533
  ...
534
534
  `:d),u&&o(`The attachment is longer than ${I3} bytes; the whole is at ${a}/${c} on chant/lifecycle.
535
- `),!0}var bgt,I3,HAe=$(()=>{"use strict";Xr();bgt="0.124.55";I3=64*1024});import{readFileSync as zAe}from"node:fs";import{resolve as Rgt}from"node:path";async function VAe(e,t){let{pushed:n,pushWarning:r}=await gc(...t!==void 0?[{cwd:t}]:[]).catch(o=>{if(o instanceof so)return{pushed:!1,pushWarning:o.message};throw o});return n?{pushed:n,suffix:""}:da(r)?{pushed:n,suffix:` (${Wu})`}:(console.error(vr({message:`The push to the remote did not land: ${r??"no reason given"}`,hint:e})),{pushed:n,suffix:" (local only \u2014 the push did not land)"})}async function qAe(e){let t=e.args.path,n=e.args.extraPositional;if(!t||t==="."||!n)return console.error(be({message:"Usage: chant approve <op> <gate>"})),1;if(e.args.expire){try{await lr()}catch(l){return console.error(be({message:`Cannot expire the gate: ${l instanceof Error?l.message:String(l)}`})),1}let s=new Date().toISOString(),a=Hn((await Or(t)).pending,n);if(!a||tr(a,s))return console.error(vr({message:`Gate "${n}" on "${t}" has no standing pending fact \u2014 nothing to expire`})),0;await dm({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 VAe(`The expiry is recorded locally on ${u$}. Until it reaches the remote, a run in another checkout still sees the old pending fact.`);return console.error(Ey(`Gate "${n}" on "${t}" expired at ${s} \u2014 not approved`+c.suffix)),console.error(Wn(t===im?"The next `chant components fan-out` decides this gate from scratch and records a fresh pending fact.":h_.test(t)?"The next `chant components pr-apply` decides this gate from scratch and records a fresh pending fact.":t===av?`The next \`chant workspace promote ${n}\` decides this gate from scratch and records a fresh pending fact.`:t===sm?`The next \`chant workspace upgrade ${n}\` decides this gate from scratch and records a fresh pending fact.`:t===am?"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===Bl){let{runOverrideApprove:s}=await Promise.resolve().then(()=>(DAe(),TAe));return s(e)}if(e.args.rules!==void 0||e.args.reason!==void 0)return console.error(be({message:`--rule and --reason override a denied plan: chant approve ${Bl} <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(be({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 $gt(t,n,s);return a?(console.log(JSON.stringify(a,null,2)),console.error(Wn(`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 ${Ogt(a.binding)}`:"")+` --at ${a.timestamp} --signature <file>`)),0):1}let r=e.args.plan,o=await Promise.resolve().then(()=>(HAe(),UAe));if(e.args.signature===void 0&&await o.interactiveApproval(e.args)){let s=await o.confirmApproval(t,n,{...r!==void 0?{plan:r}:{},...e.args.env!==void 0?{environment:e.args.env}:{}});if(s.status==="refused")return s.code;s.status==="confirmed"&&(r=s.plan)}let i=await C3(t,n,{actor:e.args.approver??e.args.actor,note:e.args.note,url:e.args.url,plan:r,...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(()=>(vT(),F9));return s(t,n,i.record.environment,i.pushed)}return console.error(Wn("This records the resolution as a fact; it does not itself re-run anything. "+(t===im?`Repeat the \`chant components fan-out\` command and it walks through gate "${n}".`:h_.test(t)?`The pull request's apply (\`chant components pr-apply\`) walks through gate "${n}" when it plans this same digest.`:t===av?`Repeat \`chant workspace promote ${n}\`, and it applies the patch this approval names.`:t===sm?`Repeat \`chant workspace upgrade ${n}\` with the same target, and it applies the patch this approval names.`:t===am?"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 xgt(e,t,n,r){let{readRelease:o,readCuts:i,labelsByDigest:s}=await Promise.resolve().then(()=>(Pc(),Km)),{readRevokedCommits:a,revocationOf:c,revokedRefusal:l}=await Promise.resolve().then(()=>(HI(),k5)),d=await o(n,{cwd:r}).catch(()=>null);if(!d)return console.error(be({message:`Gate "${t}" on "${e}" binds release ${n}, which can't be read from ${u$}, so whether it is revoked is unknown [release-unreadable]`,hint:`Fetch the ledger branch (git fetch origin ${u$}:${u$}) and approve again from the member's directory.`})),!0;let u;try{u=await a(r)}catch(g){return console.error(be({message:`Gate "${t}" on "${e}" binds release ${n}, and the ci tags can't be judged: ${g instanceof Error?g.message:String(g)} [declaration-invalid]`,hint:"Fix ci.green in chant.workspace.json at base; chant workspace check names the problem."})),!0}let p=c(d,u);if(!p)return!1;let f=s((await i({cwd:r}).catch(()=>({cuts:[]}))).cuts).get(n)??null;return console.error(be(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 C3(e,t,n){let r=await KAe(e,t,n,!1);return"statement"in r?{ok:!1}:r}async function $gt(e,t,n){let r=await KAe(e,t,n,!0);return"statement"in r?r.statement:null}async function KAe(e,t,n,r){if(!r&&Gr())return console.error(be({message:`Cannot record the approval of "${t}": ${Fi} is set, so nothing is written to chant/lifecycle`,hint:`Unset ${Fi} to approve the gate.`})),{ok:!1};let o=n.cwd??process.cwd(),i=n.cwd!==void 0?[{cwd:n.cwd}]:[],{ops:s}=await kd(...i),a=Kke([...s.values()].map(U=>U.config),e,t);!a&&!s.has(e)&&e!==im&&e!==sm&&e!==am&&e!==av&&e!==Bl&&e!==Bi&&console.error(vr({message:`Op "${e}" was not found among discovered *.op.ts declarations \u2014 recording the resolution anyway`}));try{await lr(...i)}catch(U){return console.error(be({message:`Cannot record the approval: ${U instanceof Error?U.message:String(U)}`,hint:"The pending fact this answers lives on that branch; appending without it would drop it."})),{ok:!1}}if(a){let U=Hn((await Or(a.op,...i)).pending,a.gate);if(U&&!tr(U,new Date().toISOString()))return console.error(be({message:`Gate "${t}" on "${e}" is now gate "${a.gate}" on "${a.op}", which lists it as an alias, and "${a.gate}" has a standing pending fact`,hint:`Approve that gate instead: chant approve ${a.op} ${a.gate}`})),{ok:!1};console.error(Wn(`Gate "${t}" on "${e}" is an alias of gate "${a.gate}" on "${a.op}": the next run of ${a.op} counts this approval there while the pending fact it answers stands and the plan is the same.`))}let c=n.url??Hl();if(c&&!NP(c))return console.error(be({message:`--url must be an absolute http/https URL (got "${c}")`,hint:"Pass the PR/MR link, or omit --url and put prose in --note."})),{ok:!1};let l=await Or(e,...i),d=U=>U.some(X=>X.gate===t&&X.environment!==void 0)&&n.environment!==void 0?U.filter(X=>X.environment===n.environment):U,u=Hn(d(l.pending),t),p=u?.environment,f;if(n.plan!==void 0){if(!FE(n.plan))return console.error(be({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};f=n.plan}else{if(!u)return console.error(be({message:n.environment!==void 0&&l.pending.some(U=>U.gate===t&&U.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};f=u.planDigest}let g=u?.checkpointDigest!==void 0&&Ke(f,u.planDigest)?u.checkpointDigest:void 0,m=u?.releaseDigest!==void 0&&Ke(f,u.planDigest)?u.releaseDigest:void 0,h=u?.changeSet!==void 0&&Ke(f,u.planDigest)?u.changeSet:void 0;if(u?.releaseDigest!==void 0&&await xgt(e,t,u.releaseDigest,o))return{ok:!1};let w=n.origin??fa(),b=await Or(e,...i),v=Hn(d(b.pending),t);if(Mo(w)&&(v?.neverOverMcp||s.get(e)?.config.neverOverMcp))return console.error(be({message:`Gate "${t}" on "${e}" is never resolved over ${w==="acp"?"ACP":"MCP"}`,hint:`Approvals belong to people: \`chant approve ${e} ${t}\` at a shell.`})),{ok:!1};if(v?.answer)return console.error(be({message:`Gate "${t}" on "${e}" asks decision point ${v.answer.point}, so its answer passes the gate, not an approval`,hint:`Answer the question: \`chant workspace points answer ${v.answer.id} --answer <value> --by <name>\`, then run \`chant run ${e}\` again.`})),{ok:!1};let k=xU(v?.origin,w);if(k&&!n.allowSameOrigin)return console.error(be({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 x=n.relayedBy?.trim();if(n.relayedBy!==void 0&&(!x||/[\r\n]/.test(x)))return console.error(be({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 O=n.actor??(Mo(w)?lv:oC()),E={kind:n.agent||Mo(w)?"agent":"human",...n.roles&&n.roles.length>0?{roles:[...new Set(n.roles)]}:{}},P=await Promise.resolve().then(()=>(np(),E2)),{scopeSource:T}=await Promise.resolve().then(()=>(Ho(),Lv)),S=T(o);try{P.refuseUnidentified(S,[O],n.actor!==void 0?"--actor":"the approver"),x&&P.refuseUnidentified(S,[x],"--relayed-by")}catch(U){if(!(U instanceof P.IdentityError))throw U;return console.error(be({message:`Gate "${t}" on "${e}" was not approved: ${U.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 C=(U,Z)=>(console.error(be({message:`Gate "${t}" on "${e}" was not approved: ${U}`,...Z?{hint:Z}:{}})),{ok:!1});if(n.signature!==void 0&&n.sign!==void 0)return C("--sign signs here and --signature brings a signature made elsewhere; pass one of them");if(n.at!==void 0&&!r&&n.signature===void 0)return C("--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 C("--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(!r&&n.signature===void 0&&n.sign===void 0)return C("--binding is a line the approver's signature covers, so it goes with --statement, --signature or --sign");let U=EAe(n.binding);if(U!==null)return C(`--binding takes one line of printable text, and ${U}`)}let F=new Date().toISOString();if(n.at!==void 0){let U=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(U)||new Date(U).toISOString()!==n.at)return C(`--at takes a UTC time as chant writes one, such as ${F}, not ${JSON.stringify(n.at)}`);if(U>Date.now()+Sgt)return C(`--at ${n.at} is in the future`);if(u&&n.at<u.timestamp)return C(`--at ${n.at} is before the pending fact it answers (${u.timestamp}), and a run counts only approvals newer than that`,`Take a fresh statement: chant approve ${e} ${t} --statement.`);F=n.at}let L={op:e,gate:t,...p!==void 0?{environment:p}:{},...f!==void 0?{planDigest:f}:{},resolvedBy:O,...x?{relayedBy:x}:{},timestamp:F,...g!==void 0?{checkpointDigest:g}:{},...n.binding!==void 0?{binding:n.binding}:{}};if(r){let{CHANT_VERSION:U}=await Promise.resolve().then(()=>(YA(),lle));return{statement:OAe(L,U)}}let A=P.gateAdmissionFrom(S,t);if(A&&n.sign===void 0&&n.signature===void 0)return console.error(be({message:`Gate "${t}" needs a signed approval: chant.workspace.json at base names it in identity.gates`+(A.requirement.class!==null?`, from the class ${A.requirement.class}`:"")+", and this approval is not signed",hint:`chant approve ${e} ${t} --actor <principal> --sign [<key file>], with a key ${S.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 _;if(n.signature!==void 0){let U=Egt(n.signature,L,S.policy,o);if("refused"in U)return C(U.refused);_=U.seal}if(n.sign!==void 0){let{resolveSigningKey:U,sealGateApproval:Z,gateSealVersion:X,SealError:se}=await Promise.resolve().then(()=>(Sh(),$h));try{let Ce=U(n.sign,o);try{let le=X(L);_={...Z(Ce.file,L),...le!==1?{version:le}:{}}}finally{Ce.cleanup()}}catch(Ce){if(!(Ce instanceof se))throw Ce;return console.error(be({message:`Gate "${t}" on "${e}" was not approved: ${Ce.message}`})),{ok:!1}}}if(A){let U=A.refuses({op:e,gate:t,...p!==void 0?{environment:p}:{},...f!==void 0?{planDigest:f}:{},resolvedBy:O,...x?{relayedBy:x}:{},timestamp:F,...g!==void 0?{checkpointDigest:g}:{},...n.binding!==void 0?{binding:n.binding}:{},seal:_});if(U!==null)return console.error(be({message:`Gate "${t}" on "${e}" was not approved: ${U}`,hint:`identity.gates.${t} in chant.workspace.json at base counts only an approval signed by a key ${S.policy.signersPath} lists for the approver`+(A.requirement.class!==null?`, who holds the role of the class ${A.requirement.class}`:"")+"."})),{ok:!1}}let N=v?.approval,q=ji({signers:S.policy,roles:S.policy.roles}),J=q({version:1,op:e,gate:t,...p!==void 0?{environment:p}:{},...f!==void 0?{planDigest:f}:{},resolvedBy:O,...x?{relayedBy:x}:{},timestamp:F,...g!==void 0?{checkpointDigest:g}:{},...n.binding!==void 0?{binding:n.binding}:{},..._?{seal:_}:{}}).roles,M;if(N?.policy)try{let Z=await(n.evaluator??await ZB(N.policy.lexicon)).evaluateGatePolicy(N.policy,YB({op:e,gate:t,resolvedBy:O,approver:E,roles:J,...f!==void 0?{planDigest:f}:{},...N.context?{context:N.context}:{}}));M={policy:N.policy.name,version:N.policy.version,mode:N.mode,contextDigest:Zb(N.context),decision:Z.decision,determining:Z.determining,errors:Z.errors}}catch(U){return console.error(be({message:`Gate "${t}" on "${e}" declares policy "${N.policy.name}", which could not be evaluated: ${U instanceof Error?U.message:String(U)}`,hint:`Install the ${N.policy.lexicon} lexicon in this project, or approve from a checkout that has it.`})),{ok:!1}}let{record:z}=await fv({op:e,gate:t,resolvedBy:O,...x?{relayedBy:x}:{},timestamp:F,..._?{seal:_}:{},approver:E,...M?{policyDecision:M}:{},...n.note?{note:n.note}:{},...c?{url:c}:{},...f!==void 0?{planDigest:f}:{},...g!==void 0?{checkpointDigest:g}:{},...n.binding!==void 0?{binding:n.binding}:{},...p!==void 0?{environment:p}:{},...m!==void 0?{releaseDigest:m}:{},...h!==void 0?{changeSet:h}:{},...u?.gitSha?{gitSha:u.gitSha}:{},...u?.runId?{runId:u.runId}:{},origin:w,...k&&n.allowSameOrigin?{sameOriginOverride:!0}:{}},...i),G=await VAe(`The resolution is recorded locally on ${u$}. Until it reaches the remote, a run in another checkout will not see it.`,n.cwd);console.error(Ey(`Gate "${t}" on "${e}" resolved by ${z.resolvedBy}`+(z.relayedBy?`, relayed by ${z.relayedBy},`:"")+` at ${z.timestamp}`+(z.url?` (${z.url})`:"")+(z.seal?`, signed with ${z.seal.kind===ta?"passkey ":""}${z.seal.key}`:"")+G.suffix)),z.binding!==void 0&&console.error(Wn(`The signature also binds ${JSON.stringify(z.binding)} (--binding).`)),z.planDigest&&console.error(Wn(`This approves the plan ${z.planDigest}`+(z.environment!==void 0?` in environment "${z.environment}"`:"")+(z.releaseDigest!==void 0?` for release ${z.releaseDigest}`:"")+", and only that plan. A run whose fresh plan differs refuses rather than applying it.")),z.checkpointDigest&&console.error(Wn(`The next run resumes at this gate from run ${u?.runId??"(unknown)"}'s checkpoint ${z.checkpointDigest}, after it plans again. A moved plan or another commit starts it at the first phase.`));let B=(E.roles??[]).filter(U=>!J.includes(U));if(B.length>0&&console.error(Wn(`--role ${B.join(", ")} is recorded on the approval and trusted by nothing: a gate's quorum and policy read ${z.resolvedBy}'s roles from .chant/trust.json at base, and only for an approval sealed by a signer listed at base (chant approve --sign).`)),N)for(let U of Pgt(N,z,b.resolutions,v,b.pending,q))console.error(Wn(U));return{ok:!0,record:z,pushed:G.pushed}}function Egt(e,t,n,r){let o;try{o=e==="-"?zAe(0,"utf-8"):zAe(Rgt(r,e),"utf-8")}catch(l){return{refused:`--signature ${e} can't be read: ${l instanceof Error?l.message:String(l)}`}}let i=PAe(o);if("problem"in i)return{refused:`--signature ${e}: ${i.problem}`};let s=i.kind==="ssh"?{signer:t.resolvedBy,key:"",signature:i.signature}:{kind:ta,signer:t.resolvedBy,key:i.assertion.id,signature:i.assertion.signature,clientDataJSON:i.assertion.clientDataJSON,authenticatorData:i.assertion.authenticatorData},a=na(n,t.resolvedBy,s,no(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=$l(t);return{seal:{...s,key:a.key,...c!==1?{version:c}:{}}}}function Ogt(e){return/^[\w@%+=:,./-]+$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}function Pgt(e,t,n,r,o=r?[r]:[],i=lc){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 g of a.errors)s.push(`Policy evaluation error: ${g}`)}let c=r?.timestamp??new Date(0).toISOString(),l=r&&Ke(r.planDigest,t.planDigest)?ad(o,r):c,d=sd([...n,t],t.gate,c,t.planDigest,e,l,i),u=d.counted.map(p=>p.resolvedBy).join(", ")||"none yet";if(Array.isArray(e.quorum))for(let p of d.rules??[])s.push(`Quorum: ${jl(p)}.`);else{let p=Di(e.quorum)[0],f=p?.roles?` with role ${p.roles.join(" or ")}`:"";s.push(`Quorum: ${d.counted.length} of ${d.need} human approval(s)${f} for this plan (${u}).`)}if(!d.counted.includes(t)){let p=Di(e.quorum).flatMap(f=>f.roles??[]);s.push(Dm(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 u$,Sgt,_3=$(()=>{"use strict";Sa();cI();Ul();Pr();Nt();Kg();uo();si();ao();Uk();tt();Yg();ua();ws();AAe();sr();jH();u$="chant/lifecycle";Sgt=300*1e3});QT();var T3=new Set(["--help","--open","--note-commands","--check-job","--ref-gate-status","--locks","--reach","--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","--plan-only","--continue","--no-record","--fold","--no-fold","--no-cache","--discover","--no-build","--sandbox","--yes","--confirm-prod","--once","--rerun-failed","--setup-key","--trust","--unsigned","--in-place","--require-runner-start","--require-clouds","--no-push","--no-forks","--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","--policy-only","--render-spec","--record-plans","--approval-status","--waves-outcome","--loopback","--artifacts","--push","--only","--reset","--one-release"]);function D3(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?YT(e,T3):[...YT(e.slice(0,n),T3),...e.slice(n)];let r=!1,o=s=>{t.command&&(t.positionals??=[]).push(s),t.command?t.path==="."?(t.path=s,t.pathGiven=!0):t.extraPositional?t.extraPositional2=s:t.extraPositional=s:t.command=s},i=0;for(;i<e.length;){let s=e[i];if(r)o(s);else if(s==="--")r=!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==="--reset")t.reset=!0;else if(s==="--chant-version"){let a=e[++i];if(!a||!/^\d+\.\d+\.\d+$/.test(a))throw new Error("--chant-version needs a chant version: --chant-version 0.124.84");t.chantVersion=a}else if(s==="--with"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--with needs a chant package name: --with @intentius/chant-lexicon-<name>");(t.withPackages??=[]).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==="--preset"){if(t.preset=e[++i],!t.preset||t.preset.startsWith("-"))throw new Error("--preset needs a name: --preset pull-request")}else if(s==="--baseline"){if(t.baseline=e[++i],!t.baseline||t.baseline.startsWith("-"))throw new Error("--baseline needs a file: --baseline <report.json>")}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==="--reach")t.lockReach=!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==="--train"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--train needs a train id or digest: --train <id|digest>");t.train=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==="--policy-only")t.policyOnly=!0;else if(s==="--render-spec")t.renderSpec=!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==="--apply-status"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--apply-status needs the status's name: --apply-status <context>");t.applyStatus=a}else if(s==="--of"){let a=e[++i],c=Number(a);if(!Number.isInteger(c)||c<1)throw new Error(`--of needs the number of waves: got "${a??""}"`);t.of=c}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==="--pre"){if(t.pre=e[++i],!t.pre||t.pre.startsWith("-"))throw new Error("--pre needs a prerelease id, such as rc or beta")}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==="--from-job"||s==="--claims"){let a=e[++i];if(a===void 0||a.startsWith("-"))throw new Error(s==="--from-job"?"--from-job needs the job's name: --from-job <job>":"--claims needs a directory: --claims <dir>");s==="--from-job"?t.fromJob=a:t.claims=a}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-forks")t.noForks=!0;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==="--replacement"){if(t.replacement=e[++i],!t.replacement||t.replacement.startsWith("-"))throw new Error("--replacement needs the release to use instead: --replacement <label>")}else if(s==="--forge-release"){let a=e[++i];if(a!=="prerelease"&&a!=="draft"&&a!=="delete")throw new Error(`--forge-release takes prerelease, draft or delete: got "${a??""}"`);t.forgeRelease=a}else if(s==="--allow-unsigned")t.allowUnsigned=!0;else if(s==="--require-provenance")t.requireProvenance=!0;else if(s==="--sigstore")t.sigstore=!0;else if(s==="--assets"){if(t.assets=e[++i],!t.assets||t.assets.startsWith("-"))throw new Error("--assets needs a directory: --assets dist/release")}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(d=>d.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==="--levels"){let a=e[++i];if(a===void 0)throw new Error('--levels needs the levels: --levels auto, --levels minor, or --levels "core=minor web=patch"');t.levels=a}else if(s==="--bump-member"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--bump-member needs a member and a level: --bump-member <member>=major|minor|patch");(t.bumpMember??=[]).push(a)}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"){let a=e[++i];if(a&&/^https?:\/\//.test(a))t.repoUrl=a;else if(t.ciRepo=a,!t.ciRepo||!/^[^/\s-][^/\s]*\/[^/\s]+$/.test(t.ciRepo))throw new Error("--repo needs the repository as owner/name, or for chant notify relay its https clone address: --repo <owner/repo>, --repo <url>")}else if(s==="--token-env"){if(t.tokenEnv=e[++i],!t.tokenEnv||!/^[A-Za-z_][A-Za-z0-9_]*$/.test(t.tokenEnv))throw new Error("--token-env needs a variable's name: --token-env <VAR>")}else if(s==="--host"){if(t.host=e[++i],!t.host||t.host.startsWith("-"))throw new Error("--host needs an address to listen on, such as 0.0.0.0: --host <address>")}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==="--own-jobs"){let a=e[++i];if(a===void 0||a.startsWith("-"))throw new Error("--own-jobs needs the YAML file of your own jobs: --own-jobs <file>");t.ownJobs=a}else if(s==="--keep-own-jobs")t.keepOwnJobs=!0;else if(s==="--run-group"){let a=e[++i];if(a!=="commit"&&a!=="pull-request")throw new Error(`--run-group takes commit or pull-request: got "${a??""}"`);t.runGroup=a}else if(s==="--control"){let a=e[++i];if(a===void 0||a.startsWith("-"))throw new Error("--control needs the control repo, such as github.com/acme/control");t.controlRepo=a}else if(s==="--control-setting"){let a=e[++i]??"",c=/^(op|member|readTokenSecret|tokenSecret|forge|ref|apiBase|sentCheck|markSent)=(.+)$/s.exec(a);if(!c)throw new Error(`--control-setting needs <key>=<value>, the key one of op, member, readTokenSecret, tokenSecret, forge, ref, apiBase, sentCheck, markSent: got "${a}"`);(t.controlSettings??={})[c[1]]=c[2]}else if(s==="--note-commands")t.noteCommands=!0;else if(s==="--check-job")t.checkJob=!0;else if(s==="--ref-gate-status")t.refGateStatus=!0;else if(s==="--evidence-runner-key-secret"){if(t.evidenceRunnerKeySecret=e[++i],!t.evidenceRunnerKeySecret||t.evidenceRunnerKeySecret.startsWith("-"))throw new Error("--evidence-runner-key-secret needs the secret holding the runner key: --evidence-runner-key-secret <NAME>")}else if(s==="--evidence-identity"){if(t.evidenceIdentity=e[++i],t.evidenceIdentity!=="oidc")throw new Error(`--evidence-identity takes oidc, the one identity chant signs keyless with: got "${t.evidenceIdentity??""}"`)}else if(s==="--evidence-audience"){if(t.evidenceAudience=e[++i],!t.evidenceAudience||t.evidenceAudience.startsWith("-"))throw new Error("--evidence-audience needs the OIDC token's audience: --evidence-audience <aud>")}else if(s==="--record-run"){if(t.recordRun=e[++i],!t.recordRun||!/^[A-Za-z0-9][A-Za-z0-9_.-]*$/.test(t.recordRun))throw new Error(`--record-run needs the plan job's name: got "${t.recordRun??""}"`)}else if(s==="--not-affected"){if(i+1>=e.length)throw new Error(`--not-affected needs the re-plan's argument, empty for none: --not-affected "$CHANT_PLAN_ARGUMENT"`);t.notAffected=e[++i]}else if(s==="--context"){let a=e[++i];if(!a||!/^[A-Za-z0-9][A-Za-z0-9_.\/:-]*$/.test(a))throw new Error(`--context needs the plan status's context, letters, digits and _./:-: got "${a??""}"`);t.statusContexts=[...t.statusContexts??[],a]}else if(s==="--plan-job"){if(t.planJob=e[++i],!t.planJob||!/^[A-Za-z0-9_][A-Za-z0-9_-]*$/.test(t.planJob))throw new Error(`--plan-job needs the plan job's name: got "${t.planJob??""}"`)}else if(s==="--evidence-dir"){if(t.evidenceDir=e[++i],!t.evidenceDir||t.evidenceDir.startsWith("-"))throw new Error("--evidence-dir needs the directory the signing job kept: --evidence-dir .chant/evidence/plan")}else if(s==="--summary"){if(t.checkSummary=e[++i],!t.checkSummary||t.checkSummary.startsWith("-"))throw new Error("--summary needs a file to append the check report's section to: --summary <file>")}else if(s==="--locks")t.locks=!0;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==="--ref"||s==="--hook"||s==="--git-dir"||s==="--ledger"){let a=e[++i];if(a===void 0||a.startsWith("-"))throw new Error(`${s} needs a value`);let c={"--ref":"ref","--hook":"hook","--git-dir":"gitDir","--ledger":"ledger"}[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==="--continue")t.continueTrain=!0;else if(s==="--plan-only")t.planOnly=!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==="--discover")t.discover=!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==="--one-release")t.oneRelease=!0;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==="--runs-on"){let a=e[++i],c=a?.indexOf("=")??-1;if(!a||c<1||c===a.length-1)throw new Error("--runs-on needs a member and the cluster resource it runs on: --runs-on <member>=<member>/<address>");t.runsOn={...t.runsOn??{},[a.slice(0,c)]:a.slice(c+1)}}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}
535
+ `),!0}var bgt,I3,HAe=$(()=>{"use strict";Xr();bgt="0.124.55";I3=64*1024});import{readFileSync as zAe}from"node:fs";import{resolve as Rgt}from"node:path";async function VAe(e,t){let{pushed:n,pushWarning:r}=await gc(...t!==void 0?[{cwd:t}]:[]).catch(o=>{if(o instanceof so)return{pushed:!1,pushWarning:o.message};throw o});return n?{pushed:n,suffix:""}:da(r)?{pushed:n,suffix:` (${Wu})`}:(console.error(vr({message:`The push to the remote did not land: ${r??"no reason given"}`,hint:e})),{pushed:n,suffix:" (local only \u2014 the push did not land)"})}async function qAe(e){let t=e.args.path,n=e.args.extraPositional;if(!t||t==="."||!n)return console.error(be({message:"Usage: chant approve <op> <gate>"})),1;if(e.args.expire){try{await lr()}catch(l){return console.error(be({message:`Cannot expire the gate: ${l instanceof Error?l.message:String(l)}`})),1}let s=new Date().toISOString(),a=Hn((await Or(t)).pending,n);if(!a||tr(a,s))return console.error(vr({message:`Gate "${n}" on "${t}" has no standing pending fact \u2014 nothing to expire`})),0;await dm({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 VAe(`The expiry is recorded locally on ${u$}. Until it reaches the remote, a run in another checkout still sees the old pending fact.`);return console.error(Ey(`Gate "${n}" on "${t}" expired at ${s} \u2014 not approved`+c.suffix)),console.error(Wn(t===im?"The next `chant components fan-out` decides this gate from scratch and records a fresh pending fact.":h_.test(t)?"The next `chant components pr-apply` decides this gate from scratch and records a fresh pending fact.":t===av?`The next \`chant workspace promote ${n}\` decides this gate from scratch and records a fresh pending fact.`:t===sm?`The next \`chant workspace upgrade ${n}\` decides this gate from scratch and records a fresh pending fact.`:t===am?"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===Bl){let{runOverrideApprove:s}=await Promise.resolve().then(()=>(DAe(),TAe));return s(e)}if(e.args.rules!==void 0||e.args.reason!==void 0)return console.error(be({message:`--rule and --reason override a denied plan: chant approve ${Bl} <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(be({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 $gt(t,n,s);return a?(console.log(JSON.stringify(a,null,2)),console.error(Wn(`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 ${Ogt(a.binding)}`:"")+` --at ${a.timestamp} --signature <file>`)),0):1}let r=e.args.plan,o=await Promise.resolve().then(()=>(HAe(),UAe));if(e.args.signature===void 0&&await o.interactiveApproval(e.args)){let s=await o.confirmApproval(t,n,{...r!==void 0?{plan:r}:{},...e.args.env!==void 0?{environment:e.args.env}:{}});if(s.status==="refused")return s.code;s.status==="confirmed"&&(r=s.plan)}let i=await C3(t,n,{actor:e.args.approver??e.args.actor,note:e.args.note,url:e.args.url,plan:r,...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(()=>(vT(),F9));return s(t,n,i.record.environment,i.pushed)}return console.error(Wn("This records the resolution as a fact; it does not itself re-run anything. "+(t===im?`Repeat the \`chant components fan-out\` command and it walks through gate "${n}".`:h_.test(t)?`The pull request's apply (\`chant components pr-apply\`) walks through gate "${n}" when it plans this same digest.`:t===av?`Repeat \`chant workspace promote ${n}\`, and it applies the patch this approval names.`:t===sm?`Repeat \`chant workspace upgrade ${n}\` with the same target, and it applies the patch this approval names.`:t===am?"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 xgt(e,t,n,r){let{readRelease:o,readCuts:i,labelsByDigest:s}=await Promise.resolve().then(()=>(Pc(),Km)),{readRevokedCommits:a,revocationOf:c,revokedRefusal:l}=await Promise.resolve().then(()=>(HI(),k5)),d=await o(n,{cwd:r}).catch(()=>null);if(!d)return console.error(be({message:`Gate "${t}" on "${e}" binds release ${n}, which can't be read from ${u$}, so whether it is revoked is unknown [release-unreadable]`,hint:`Fetch the ledger branch (git fetch origin ${u$}:${u$}) and approve again from the member's directory.`})),!0;let u;try{u=await a(r)}catch(g){return console.error(be({message:`Gate "${t}" on "${e}" binds release ${n}, and the ci tags can't be judged: ${g instanceof Error?g.message:String(g)} [declaration-invalid]`,hint:"Fix ci.green in chant.workspace.json at base; chant workspace check names the problem."})),!0}let p=c(d,u);if(!p)return!1;let f=s((await i({cwd:r}).catch(()=>({cuts:[]}))).cuts).get(n)??null;return console.error(be(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 C3(e,t,n){let r=await KAe(e,t,n,!1);return"statement"in r?{ok:!1}:r}async function $gt(e,t,n){let r=await KAe(e,t,n,!0);return"statement"in r?r.statement:null}async function KAe(e,t,n,r){if(!r&&Gr())return console.error(be({message:`Cannot record the approval of "${t}": ${Fi} is set, so nothing is written to chant/lifecycle`,hint:`Unset ${Fi} to approve the gate.`})),{ok:!1};let o=n.cwd??process.cwd(),i=n.cwd!==void 0?[{cwd:n.cwd}]:[],{ops:s}=await kd(...i),a=Kke([...s.values()].map(U=>U.config),e,t);!a&&!s.has(e)&&e!==im&&e!==sm&&e!==am&&e!==av&&e!==Bl&&e!==Bi&&console.error(vr({message:`Op "${e}" was not found among discovered *.op.ts declarations \u2014 recording the resolution anyway`}));try{await lr(...i)}catch(U){return console.error(be({message:`Cannot record the approval: ${U instanceof Error?U.message:String(U)}`,hint:"The pending fact this answers lives on that branch; appending without it would drop it."})),{ok:!1}}if(a){let U=Hn((await Or(a.op,...i)).pending,a.gate);if(U&&!tr(U,new Date().toISOString()))return console.error(be({message:`Gate "${t}" on "${e}" is now gate "${a.gate}" on "${a.op}", which lists it as an alias, and "${a.gate}" has a standing pending fact`,hint:`Approve that gate instead: chant approve ${a.op} ${a.gate}`})),{ok:!1};console.error(Wn(`Gate "${t}" on "${e}" is an alias of gate "${a.gate}" on "${a.op}": the next run of ${a.op} counts this approval there while the pending fact it answers stands and the plan is the same.`))}let c=n.url??Hl();if(c&&!NP(c))return console.error(be({message:`--url must be an absolute http/https URL (got "${c}")`,hint:"Pass the PR/MR link, or omit --url and put prose in --note."})),{ok:!1};let l=await Or(e,...i),d=U=>U.some(X=>X.gate===t&&X.environment!==void 0)&&n.environment!==void 0?U.filter(X=>X.environment===n.environment):U,u=Hn(d(l.pending),t),p=u?.environment,f;if(n.plan!==void 0){if(!FE(n.plan))return console.error(be({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};f=n.plan}else{if(!u)return console.error(be({message:n.environment!==void 0&&l.pending.some(U=>U.gate===t&&U.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};f=u.planDigest}let g=u?.checkpointDigest!==void 0&&Ke(f,u.planDigest)?u.checkpointDigest:void 0,m=u?.releaseDigest!==void 0&&Ke(f,u.planDigest)?u.releaseDigest:void 0,h=u?.changeSet!==void 0&&Ke(f,u.planDigest)?u.changeSet:void 0;if(u?.releaseDigest!==void 0&&await xgt(e,t,u.releaseDigest,o))return{ok:!1};let w=n.origin??fa(),b=await Or(e,...i),v=Hn(d(b.pending),t);if(Mo(w)&&(v?.neverOverMcp||s.get(e)?.config.neverOverMcp))return console.error(be({message:`Gate "${t}" on "${e}" is never resolved over ${w==="acp"?"ACP":"MCP"}`,hint:`Approvals belong to people: \`chant approve ${e} ${t}\` at a shell.`})),{ok:!1};if(v?.answer)return console.error(be({message:`Gate "${t}" on "${e}" asks decision point ${v.answer.point}, so its answer passes the gate, not an approval`,hint:`Answer the question: \`chant workspace points answer ${v.answer.id} --answer <value> --by <name>\`, then run \`chant run ${e}\` again.`})),{ok:!1};let k=xU(v?.origin,w);if(k&&!n.allowSameOrigin)return console.error(be({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 x=n.relayedBy?.trim();if(n.relayedBy!==void 0&&(!x||/[\r\n]/.test(x)))return console.error(be({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 O=n.actor??(Mo(w)?lv:oC()),E={kind:n.agent||Mo(w)?"agent":"human",...n.roles&&n.roles.length>0?{roles:[...new Set(n.roles)]}:{}},P=await Promise.resolve().then(()=>(np(),E2)),{scopeSource:T}=await Promise.resolve().then(()=>(Ho(),Lv)),S=T(o);try{P.refuseUnidentified(S,[O],n.actor!==void 0?"--actor":"the approver"),x&&P.refuseUnidentified(S,[x],"--relayed-by")}catch(U){if(!(U instanceof P.IdentityError))throw U;return console.error(be({message:`Gate "${t}" on "${e}" was not approved: ${U.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 C=(U,Z)=>(console.error(be({message:`Gate "${t}" on "${e}" was not approved: ${U}`,...Z?{hint:Z}:{}})),{ok:!1});if(n.signature!==void 0&&n.sign!==void 0)return C("--sign signs here and --signature brings a signature made elsewhere; pass one of them");if(n.at!==void 0&&!r&&n.signature===void 0)return C("--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 C("--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(!r&&n.signature===void 0&&n.sign===void 0)return C("--binding is a line the approver's signature covers, so it goes with --statement, --signature or --sign");let U=EAe(n.binding);if(U!==null)return C(`--binding takes one line of printable text, and ${U}`)}let F=new Date().toISOString();if(n.at!==void 0){let U=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(U)||new Date(U).toISOString()!==n.at)return C(`--at takes a UTC time as chant writes one, such as ${F}, not ${JSON.stringify(n.at)}`);if(U>Date.now()+Sgt)return C(`--at ${n.at} is in the future`);if(u&&n.at<u.timestamp)return C(`--at ${n.at} is before the pending fact it answers (${u.timestamp}), and a run counts only approvals newer than that`,`Take a fresh statement: chant approve ${e} ${t} --statement.`);F=n.at}let L={op:e,gate:t,...p!==void 0?{environment:p}:{},...f!==void 0?{planDigest:f}:{},resolvedBy:O,...x?{relayedBy:x}:{},timestamp:F,...g!==void 0?{checkpointDigest:g}:{},...n.binding!==void 0?{binding:n.binding}:{}};if(r){let{CHANT_VERSION:U}=await Promise.resolve().then(()=>(YA(),lle));return{statement:OAe(L,U)}}let A=P.gateAdmissionFrom(S,t);if(A&&n.sign===void 0&&n.signature===void 0)return console.error(be({message:`Gate "${t}" needs a signed approval: chant.workspace.json at base names it in identity.gates`+(A.requirement.class!==null?`, from the class ${A.requirement.class}`:"")+", and this approval is not signed",hint:`chant approve ${e} ${t} --actor <principal> --sign [<key file>], with a key ${S.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 _;if(n.signature!==void 0){let U=Egt(n.signature,L,S.policy,o);if("refused"in U)return C(U.refused);_=U.seal}if(n.sign!==void 0){let{resolveSigningKey:U,sealGateApproval:Z,gateSealVersion:X,SealError:se}=await Promise.resolve().then(()=>(Sh(),$h));try{let Ce=U(n.sign,o);try{let le=X(L);_={...Z(Ce.file,L),...le!==1?{version:le}:{}}}finally{Ce.cleanup()}}catch(Ce){if(!(Ce instanceof se))throw Ce;return console.error(be({message:`Gate "${t}" on "${e}" was not approved: ${Ce.message}`})),{ok:!1}}}if(A){let U=A.refuses({op:e,gate:t,...p!==void 0?{environment:p}:{},...f!==void 0?{planDigest:f}:{},resolvedBy:O,...x?{relayedBy:x}:{},timestamp:F,...g!==void 0?{checkpointDigest:g}:{},...n.binding!==void 0?{binding:n.binding}:{},seal:_});if(U!==null)return console.error(be({message:`Gate "${t}" on "${e}" was not approved: ${U}`,hint:`identity.gates.${t} in chant.workspace.json at base counts only an approval signed by a key ${S.policy.signersPath} lists for the approver`+(A.requirement.class!==null?`, who holds the role of the class ${A.requirement.class}`:"")+"."})),{ok:!1}}let N=v?.approval,q=ji({signers:S.policy,roles:S.policy.roles}),J=q({version:1,op:e,gate:t,...p!==void 0?{environment:p}:{},...f!==void 0?{planDigest:f}:{},resolvedBy:O,...x?{relayedBy:x}:{},timestamp:F,...g!==void 0?{checkpointDigest:g}:{},...n.binding!==void 0?{binding:n.binding}:{},..._?{seal:_}:{}}).roles,M;if(N?.policy)try{let Z=await(n.evaluator??await ZB(N.policy.lexicon)).evaluateGatePolicy(N.policy,YB({op:e,gate:t,resolvedBy:O,approver:E,roles:J,...f!==void 0?{planDigest:f}:{},...N.context?{context:N.context}:{}}));M={policy:N.policy.name,version:N.policy.version,mode:N.mode,contextDigest:Zb(N.context),decision:Z.decision,determining:Z.determining,errors:Z.errors}}catch(U){return console.error(be({message:`Gate "${t}" on "${e}" declares policy "${N.policy.name}", which could not be evaluated: ${U instanceof Error?U.message:String(U)}`,hint:`Install the ${N.policy.lexicon} lexicon in this project, or approve from a checkout that has it.`})),{ok:!1}}let{record:z}=await fv({op:e,gate:t,resolvedBy:O,...x?{relayedBy:x}:{},timestamp:F,..._?{seal:_}:{},approver:E,...M?{policyDecision:M}:{},...n.note?{note:n.note}:{},...c?{url:c}:{},...f!==void 0?{planDigest:f}:{},...g!==void 0?{checkpointDigest:g}:{},...n.binding!==void 0?{binding:n.binding}:{},...p!==void 0?{environment:p}:{},...m!==void 0?{releaseDigest:m}:{},...h!==void 0?{changeSet:h}:{},...u?.gitSha?{gitSha:u.gitSha}:{},...u?.runId?{runId:u.runId}:{},origin:w,...k&&n.allowSameOrigin?{sameOriginOverride:!0}:{}},...i),G=await VAe(`The resolution is recorded locally on ${u$}. Until it reaches the remote, a run in another checkout will not see it.`,n.cwd);console.error(Ey(`Gate "${t}" on "${e}" resolved by ${z.resolvedBy}`+(z.relayedBy?`, relayed by ${z.relayedBy},`:"")+` at ${z.timestamp}`+(z.url?` (${z.url})`:"")+(z.seal?`, signed with ${z.seal.kind===ta?"passkey ":""}${z.seal.key}`:"")+G.suffix)),z.binding!==void 0&&console.error(Wn(`The signature also binds ${JSON.stringify(z.binding)} (--binding).`)),z.planDigest&&console.error(Wn(`This approves the plan ${z.planDigest}`+(z.environment!==void 0?` in environment "${z.environment}"`:"")+(z.releaseDigest!==void 0?` for release ${z.releaseDigest}`:"")+", and only that plan. A run whose fresh plan differs refuses rather than applying it.")),z.checkpointDigest&&console.error(Wn(`The next run resumes at this gate from run ${u?.runId??"(unknown)"}'s checkpoint ${z.checkpointDigest}, after it plans again. A moved plan or another commit starts it at the first phase.`));let B=(E.roles??[]).filter(U=>!J.includes(U));if(B.length>0&&console.error(Wn(`--role ${B.join(", ")} is recorded on the approval and trusted by nothing: a gate's quorum and policy read ${z.resolvedBy}'s roles from .chant/trust.json at base, and only for an approval sealed by a signer listed at base (chant approve --sign).`)),N)for(let U of Pgt(N,z,b.resolutions,v,b.pending,q))console.error(Wn(U));return{ok:!0,record:z,pushed:G.pushed}}function Egt(e,t,n,r){let o;try{o=e==="-"?zAe(0,"utf-8"):zAe(Rgt(r,e),"utf-8")}catch(l){return{refused:`--signature ${e} can't be read: ${l instanceof Error?l.message:String(l)}`}}let i=PAe(o);if("problem"in i)return{refused:`--signature ${e}: ${i.problem}`};let s=i.kind==="ssh"?{signer:t.resolvedBy,key:"",signature:i.signature}:{kind:ta,signer:t.resolvedBy,key:i.assertion.id,signature:i.assertion.signature,clientDataJSON:i.assertion.clientDataJSON,authenticatorData:i.assertion.authenticatorData},a=na(n,t.resolvedBy,s,no(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=$l(t);return{seal:{...s,key:a.key,...c!==1?{version:c}:{}}}}function Ogt(e){return/^[\w@%+=:,./-]+$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}function Pgt(e,t,n,r,o=r?[r]:[],i=lc){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 g of a.errors)s.push(`Policy evaluation error: ${g}`)}let c=r?.timestamp??new Date(0).toISOString(),l=r&&Ke(r.planDigest,t.planDigest)?ad(o,r):c,d=sd([...n,t],t.gate,c,t.planDigest,e,l,i),u=d.counted.map(p=>p.resolvedBy).join(", ")||"none yet";if(Array.isArray(e.quorum))for(let p of d.rules??[])s.push(`Quorum: ${jl(p)}.`);else{let p=Di(e.quorum)[0],f=p?.roles?` with role ${p.roles.join(" or ")}`:"";s.push(`Quorum: ${d.counted.length} of ${d.need} human approval(s)${f} for this plan (${u}).`)}if(!d.counted.includes(t)){let p=Di(e.quorum).flatMap(f=>f.roles??[]);s.push(Dm(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 u$,Sgt,_3=$(()=>{"use strict";Sa();cI();Ul();Pr();Nt();Kg();uo();si();ao();Uk();tt();Yg();ua();ws();AAe();sr();jH();u$="chant/lifecycle";Sgt=300*1e3});QT();var T3=new Set(["--help","--open","--note-commands","--check-job","--ref-gate-status","--locks","--reach","--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","--plan-only","--continue","--no-record","--fold","--no-fold","--no-cache","--discover","--no-build","--sandbox","--yes","--confirm-prod","--once","--rerun-failed","--setup-key","--trust","--unsigned","--in-place","--require-runner-start","--require-clouds","--no-push","--doctor","--no-forks","--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","--policy-only","--render-spec","--record-plans","--approval-status","--waves-outcome","--loopback","--artifacts","--push","--only","--reset","--one-release"]);function D3(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?YT(e,T3):[...YT(e.slice(0,n),T3),...e.slice(n)];let r=!1,o=s=>{t.command&&(t.positionals??=[]).push(s),t.command?t.path==="."?(t.path=s,t.pathGiven=!0):t.extraPositional?t.extraPositional2=s:t.extraPositional=s:t.command=s},i=0;for(;i<e.length;){let s=e[i];if(r)o(s);else if(s==="--")r=!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==="--reset")t.reset=!0;else if(s==="--chant-version"){let a=e[++i];if(!a||!/^\d+\.\d+\.\d+$/.test(a))throw new Error("--chant-version needs a chant version: --chant-version 0.124.84");t.chantVersion=a}else if(s==="--with"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--with needs a chant package name: --with @intentius/chant-lexicon-<name>");(t.withPackages??=[]).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==="--preset"){if(t.preset=e[++i],!t.preset||t.preset.startsWith("-"))throw new Error("--preset needs a name: --preset pull-request")}else if(s==="--baseline"){if(t.baseline=e[++i],!t.baseline||t.baseline.startsWith("-"))throw new Error("--baseline needs a file: --baseline <report.json>")}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==="--reach")t.lockReach=!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==="--train"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--train needs a train id or digest: --train <id|digest>");t.train=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==="--policy-only")t.policyOnly=!0;else if(s==="--render-spec")t.renderSpec=!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==="--apply-status"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--apply-status needs the status's name: --apply-status <context>");t.applyStatus=a}else if(s==="--of"){let a=e[++i],c=Number(a);if(!Number.isInteger(c)||c<1)throw new Error(`--of needs the number of waves: got "${a??""}"`);t.of=c}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==="--pre"){if(t.pre=e[++i],!t.pre||t.pre.startsWith("-"))throw new Error("--pre needs a prerelease id, such as rc or beta")}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==="--from-job"||s==="--claims"){let a=e[++i];if(a===void 0||a.startsWith("-"))throw new Error(s==="--from-job"?"--from-job needs the job's name: --from-job <job>":"--claims needs a directory: --claims <dir>");s==="--from-job"?t.fromJob=a:t.claims=a}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-forks")t.noForks=!0;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==="--replacement"){if(t.replacement=e[++i],!t.replacement||t.replacement.startsWith("-"))throw new Error("--replacement needs the release to use instead: --replacement <label>")}else if(s==="--forge-release"){let a=e[++i];if(a!=="prerelease"&&a!=="draft"&&a!=="delete")throw new Error(`--forge-release takes prerelease, draft or delete: got "${a??""}"`);t.forgeRelease=a}else if(s==="--allow-unsigned")t.allowUnsigned=!0;else if(s==="--require-provenance")t.requireProvenance=!0;else if(s==="--sigstore")t.sigstore=!0;else if(s==="--assets"){if(t.assets=e[++i],!t.assets||t.assets.startsWith("-"))throw new Error("--assets needs a directory: --assets dist/release")}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(d=>d.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==="--levels"){let a=e[++i];if(a===void 0)throw new Error('--levels needs the levels: --levels auto, --levels minor, or --levels "core=minor web=patch"');t.levels=a}else if(s==="--bump-member"){let a=e[++i];if(!a||a.startsWith("-"))throw new Error("--bump-member needs a member and a level: --bump-member <member>=major|minor|patch");(t.bumpMember??=[]).push(a)}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"){let a=e[++i];if(a&&/^https?:\/\//.test(a))t.repoUrl=a;else if(t.ciRepo=a,!t.ciRepo||!/^[^/\s-][^/\s]*\/[^/\s]+$/.test(t.ciRepo))throw new Error("--repo needs the repository as owner/name, or for chant notify relay its https clone address: --repo <owner/repo>, --repo <url>")}else if(s==="--token-env"){if(t.tokenEnv=e[++i],!t.tokenEnv||!/^[A-Za-z_][A-Za-z0-9_]*$/.test(t.tokenEnv))throw new Error("--token-env needs a variable's name: --token-env <VAR>")}else if(s==="--host"){if(t.host=e[++i],!t.host||t.host.startsWith("-"))throw new Error("--host needs an address to listen on, such as 0.0.0.0: --host <address>")}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==="--own-jobs"){let a=e[++i];if(a===void 0||a.startsWith("-"))throw new Error("--own-jobs needs the YAML file of your own jobs: --own-jobs <file>");t.ownJobs=a}else if(s==="--keep-own-jobs")t.keepOwnJobs=!0;else if(s==="--run-group"){let a=e[++i];if(a!=="commit"&&a!=="pull-request")throw new Error(`--run-group takes commit or pull-request: got "${a??""}"`);t.runGroup=a}else if(s==="--control"){let a=e[++i];if(a===void 0||a.startsWith("-"))throw new Error("--control needs the control repo, such as github.com/acme/control");t.controlRepo=a}else if(s==="--control-setting"){let a=e[++i]??"",c=/^(op|member|readTokenSecret|tokenSecret|forge|ref|apiBase|sentCheck|markSent)=(.+)$/s.exec(a);if(!c)throw new Error(`--control-setting needs <key>=<value>, the key one of op, member, readTokenSecret, tokenSecret, forge, ref, apiBase, sentCheck, markSent: got "${a}"`);(t.controlSettings??={})[c[1]]=c[2]}else if(s==="--note-commands")t.noteCommands=!0;else if(s==="--check-job")t.checkJob=!0;else if(s==="--ref-gate-status")t.refGateStatus=!0;else if(s==="--evidence-runner-key-secret"){if(t.evidenceRunnerKeySecret=e[++i],!t.evidenceRunnerKeySecret||t.evidenceRunnerKeySecret.startsWith("-"))throw new Error("--evidence-runner-key-secret needs the secret holding the runner key: --evidence-runner-key-secret <NAME>")}else if(s==="--evidence-identity"){if(t.evidenceIdentity=e[++i],t.evidenceIdentity!=="oidc")throw new Error(`--evidence-identity takes oidc, the one identity chant signs keyless with: got "${t.evidenceIdentity??""}"`)}else if(s==="--evidence-audience"){if(t.evidenceAudience=e[++i],!t.evidenceAudience||t.evidenceAudience.startsWith("-"))throw new Error("--evidence-audience needs the OIDC token's audience: --evidence-audience <aud>")}else if(s==="--record-run"){if(t.recordRun=e[++i],!t.recordRun||!/^[A-Za-z0-9][A-Za-z0-9_.-]*$/.test(t.recordRun))throw new Error(`--record-run needs the plan job's name: got "${t.recordRun??""}"`)}else if(s==="--not-affected"){if(i+1>=e.length)throw new Error(`--not-affected needs the re-plan's argument, empty for none: --not-affected "$CHANT_PLAN_ARGUMENT"`);t.notAffected=e[++i]}else if(s==="--context"){let a=e[++i];if(!a||!/^[A-Za-z0-9][A-Za-z0-9_.\/:-]*$/.test(a))throw new Error(`--context needs the plan status's context, letters, digits and _./:-: got "${a??""}"`);t.statusContexts=[...t.statusContexts??[],a]}else if(s==="--plan-job"){if(t.planJob=e[++i],!t.planJob||!/^[A-Za-z0-9_][A-Za-z0-9_-]*$/.test(t.planJob))throw new Error(`--plan-job needs the plan job's name: got "${t.planJob??""}"`)}else if(s==="--evidence-dir"){if(t.evidenceDir=e[++i],!t.evidenceDir||t.evidenceDir.startsWith("-"))throw new Error("--evidence-dir needs the directory the signing job kept: --evidence-dir .chant/evidence/plan")}else if(s==="--summary"){if(t.checkSummary=e[++i],!t.checkSummary||t.checkSummary.startsWith("-"))throw new Error("--summary needs a file to append the check report's section to: --summary <file>")}else if(s==="--locks")t.locks=!0;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==="--ref"||s==="--hook"||s==="--git-dir"||s==="--ledger"){let a=e[++i];if(a===void 0||a.startsWith("-"))throw new Error(`${s} needs a value`);let c={"--ref":"ref","--hook":"hook","--git-dir":"gitDir","--ledger":"ledger"}[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==="--continue")t.continueTrain=!0;else if(s==="--plan-only")t.planOnly=!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==="--discover")t.discover=!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==="--one-release")t.oneRelease=!0;else if(s==="--doctor")t.doctor=!0;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==="--runs-on"){let a=e[++i],c=a?.indexOf("=")??-1;if(!a||c<1||c===a.length-1)throw new Error("--runs-on needs a member and the cluster resource it runs on: --runs-on <member>=<member>/<address>");t.runsOn={...t.runsOn??{},[a.slice(0,c)]:a.slice(c+1)}}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}
536
536
  Run "chant --help" to see supported flags.`);if(/^-[A-Za-z]/.test(s))throw new Error(`Unknown flag: ${s}
537
537
  Run "chant --help" to see supported flags.`);o(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.");if((t.ownJobs!==void 0||t.keepOwnJobs)&&!(t.command==="build"&&t.components&&t.generate))throw new Error(`${t.ownJobs!==void 0?"--own-jobs":"--keep-own-jobs"} needs build --components --generate <forge>: it adds your own jobs to the pipeline file generate mode writes.`);return t}var tCe={lc:"lifecycle",sync:"update"};function N3(e,t){let n=tCe[e.command]??e.command,r=`${n} ${e.path}`,o=t.find(s=>s.name===r);if(o)return{def:o,compound:!0};let i=t.find(s=>s.name===n);return i?{def:i,compound:!1}:null}sr();function j3(e){return new Promise(t=>{let n=()=>{if(e.writableLength===0||e.writableEnded||e.destroyed){o(),t();return}e.once("drain",n)},r=()=>{o(),t()},o=()=>{e.off("drain",n),e.off("error",r),e.off("close",r)};e.once("error",r),e.once("close",r),n()})}async function XT(e){await j3(process.stdout),await j3(process.stderr),process.exit(e)}eD();import{realpathSync as L3}from"node:fs";import{fileURLToPath as rCe}from"node:url";function M3(e,t){if(!e)return!1;try{return L3(e)===L3(rCe(t))}catch{return!1}}mw();ni();O2();SI();ZA();sr();ua();import{readFileSync as KT}from"node:fs";import{relative as A3,resolve as za}from"node:path";tt();var tft="_waves";function nft(e){return`${e}.stops.json`}var SPe=/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/,rft=/^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$/;function oft(e){let t;try{t=JSON.parse(e??"null")}catch{return{version:1,stops:{}}}let n={},r=t&&typeof t=="object"&&t.version===1?t.stops:void 0;if(r&&typeof r=="object")for(let[o,i]of Object.entries(r)){let s=i;!SPe.test(o)||!s||!Number.isInteger(s.through)||s.through<1||typeof s.at!="string"||(n[o]={through:s.through,at:s.at,...typeof s.by=="string"?{by:s.by}:{},...Number.isInteger(s.pr)?{pr:s.pr}:{}})}return{version:1,stops:n}}function ift(e,t){return e!==void 0&&t>e.through}async function sft(e,t,n={}){if(!rft.test(e)||!SPe.test(t))return;await Dn(n);let r=await Tt(tft,nft(e),n);if(r)return oft(await Bt(r,n)).stops[t]}async function EPe(e,t,n={}){let r;try{r=n.sha??await yc(n)}catch{return}let o;try{o=await sft(e,r,n)}catch{return}if(!ift(o,t))return;let i=o.by?`${o.by}'s`:"a",s=o.pr!==void 0?` on pull request ${o.pr}`:"";return`wave ${t} waits: ${i} comment${s} ran ${e} again at ${r.slice(0,12)} through wave ${o.through}; comment the apply again without a wave to run the waves after it`}PA();rp();Xr();async function $Ae(e){let t=e.args.noRecord===!0;if(!t&&!Gr())return RAe(e);let n=t?"--no-record":`${Fi}=${process.env[Fi]}`,r=process.env[Fi];t&&(process.env[Fi]="1"),OP(),console.error(vr({message:aU(n)}));try{return await RAe(e)}finally{console.error(vr({message:lU(n)})),OP(),t&&(r===void 0?delete process.env[Fi]:process.env[Fi]=r)}}async function RAe(e){let{args:t}=e;if(t.merge!==void 0)return sgt(e);if(t.applyStatus!==void 0)return agt(e);let n=t.opsSpec;if(n&&t.recordPlans)try{let a=Ws(KT(za(n),"utf-8"),`--spec ${n}`),c=await $I({spec:a});if(t.json)console.log(JSON.stringify(c,null,2));else for(let l of c.waves)console.error(`wave ${l.wave} (${l.name}) at ${c.head.slice(0,12)}: ${l.digest}`);return 0}catch(a){return console.error(be({message:a instanceof Error?a.message:String(a)})),1}if(n&&t.approvalStatus)return cgt(e,n);if(n&&t.wavesOutcome)try{let a=Ws(KT(za(n),"utf-8"),`--spec ${n}`),{opWaveOutcomeDir:c}=await Promise.resolve().then(()=>(Mr(),uP)),{earlierWaveOutcomes:l}=await Promise.resolve().then(()=>(Ml(),YO)),{applyOutcomeOf:d}=await Promise.resolve().then(()=>(s$(),DT)),{readOpWaveRestNote:u}=await Promise.resolve().then(()=>($y(),a$)),p=u([za(c(a))]);if(p?.next!==void 0)return console.error(`${a.name}: wave ${p.wave} started a follow-on run for wave ${p.next}, so this run's outcome is not the waves'; that run sends it`),0;let{withChainOutcomes:f}=await Promise.resolve().then(()=>($y(),a$)),g=d(f(l([za(c(a))],Number.MAX_SAFE_INTEGER).members,p));if(t.json)console.log(JSON.stringify(g,null,2));else{console.log(g.outcome);let m=Object.entries(g.counts).map(([h,w])=>`${w} ${h}`).join(", ");console.error(`${a.name}: ${g.outcome}${m?` (${m})`:", no wave wrote an outcome"}`)}return 0}catch(a){return console.error(be({message:a instanceof Error?a.message:String(a)})),1}if(!n||t.wave===void 0)return console.error(be({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(be({message:`--decide and --${t.share!==void 0?"share":"group"} are two different jobs; pass one`})),1;if(t.policyOnly&&(t.share!==void 0||t.group!==void 0))return console.error(be({message:`--policy-only runs a wave's policy in its own or its deciding job; a --${t.share!==void 0?"share":"group"} job has none of its own`})),1;let r=t.phase;if(r!==void 0&&!jm.includes(r))return console.error(be({message:`--phase is one of ${jm.join(", ")}: a split wave's plan, gate, apply or record job`,hint:`got ${JSON.stringify(t.phase??"")}`})),1;let o=r==="gate"||r==="record"?Fm().head:void 0,i,s={...t.share!==void 0?{share:t.share}:{},...t.group!==void 0?{group:t.group}:{}};if(t.eventsJson&&t.json)return console.error(be({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 a=za(n),c;if(t.renderSpec){let p=await Promise.resolve().then(()=>(wJ(),pRe)),f=A3(process.cwd(),a),g=p.opWavesSpecCommandFromEnv(),m=p.opWavesSpecRunsAtHead()&&r!=="gate"&&r!=="record",h=p.renderOpWavesJobSpec({specFile:f,base:t.base??"HEAD^1",cwd:process.cwd(),render:p.commandSpecRender(g,f,process.cwd()),fallback:o$,parse:Ws,...m?{runsAtHead:m,headRender:b=>p.commandSpecRender(g,f,process.cwd(),{[p.OP_WAVES_SPEC_BASE_ENV]:b})}:{}});c=h.show,i=h.spec,m&&console.error(`${i.name}: the runs come from the spec rendered at ${h.sha.slice(0,12)}, the applied commit; the rules from the one rendered at base`);let w=p.renderedJobMissing(i,t.wave,s,h.at);if(w)return console.error(`${w}, so this job has nothing to apply`),0}else i=Ws(KT(a,"utf-8"),`--spec ${n}`);if(!t.policyOnly&&(r===void 0||r==="gate")){let p=await EPe(i.name,t.wave,o?{sha:o}:{});if(p)return console.error(p),ge.waiting}let l=t.eventsJson?await(await Promise.resolve().then(()=>(UPe(),BPe))).openCliRunEvents(t,{kind:"op",name:i.name,cwd:process.cwd()}):void 0,d=cle(),u=await RI({...l?{events:l.emit}:{},...d?.afterPlan?{afterPlan:d.afterPlan}:{},...d?.capabilities?{capabilities:d.capabilities}:{},...d?.hookExec?{hookExec:d.hookExec}:{},...d?.runHooks?{runHooks:d.runHooks}:{},...d?.hooks?{inProcessHooks:d.hooks}:{},spec:i,specFile:A3(process.cwd(),a),wave:t.wave,...t.decide?{decide:!0}:{},...t.policyOnly?{policyOnly:!0}:{},...t.share!==void 0?{share:t.share}:{},...t.group!==void 0?{group:t.group}:{},...t.base?{base:t.base}:{},...c?{show:c}:{},...r?{phase:r}:{},...o?{head:o}:{}});return r==="record"&&(u.exitCode=await(await Promise.resolve().then(()=>($y(),a$))).followOnAfterRecord({spec:i,wave:t.wave,exitCode:u.exitCode})),t.json&&console.log(JSON.stringify(u,null,2)),t.policyOnly||r==="plan"||r==="apply"||r==="gate"&&u.exitCode===ge.done||(await RA(i,t.wave,{result:u},s),await xAe(i,t.wave,{result:u})),u.exitCode}catch(a){let c=a instanceof Error?a.message:String(a);return console.error(be({message:c})),i&&r!=="plan"&&r!=="apply"&&(await RA(i,t.wave,{error:c},s),await xAe(i,t.wave,{error:c})),1}}async function sgt(e){let{args:t}=e,n=l=>(console.error(be({message:l})),1);if(t.merge!=="auto"&&t.merge!=="manual")return n("--merge is auto or manual: auto merges the pull request once every wave applied its decided head, manual says it is ready");let r=t.op;if(!r||t.wave===void 0)return n("--merge closes a before-merge run: --op <name> --wave <last wave> --merge auto|manual --forge <kind>");let{FORGE_KINDS:o}=await Promise.resolve().then(()=>(fi(),lh));if(!t.forge||!o.includes(t.forge))return n(`--merge replies on the pull request: --forge ${o.join("|")}`);let i=t.forge,{beforeMergeRunFromEnv:s,isBeforeMergeRun:a}=await Promise.resolve().then(()=>(rp(),uce)),c=s();if(!a(c))return console.error("this run names no decided head: a push applies on its own, so nothing is merged here"),0;try{let{beforeMergeRecordAt:l}=await Promise.resolve().then(()=>(zPe(),HPe)),{beforeMergeDone:d}=await Promise.resolve().then(()=>(KPe(),qPe)),{opWaveOutcomeDir:u}=await Promise.resolve().then(()=>(Mr(),uP)),{earlierWaveOutcomes:p}=await Promise.resolve().then(()=>(Ml(),YO)),{applyOutcomeOf:f}=await Promise.resolve().then(()=>(s$(),DT)),{forgeFromJobEnv:g}=await Promise.resolve().then(()=>(k3(),v3)),{mergeTokenEnv:m}=await Promise.resolve().then(()=>(w3(),VPe)),{releaseTargetLocks:h}=await Promise.resolve().then(()=>(BV(),Qfe)),{PR_APPLY_GATE:w}=await Promise.resolve().then(()=>(Uk(),vq)),{activeProductWords:b}=await Promise.resolve().then(()=>(_o(),wX)),v=c.head?await l(r,c.head):void 0,{readOpWaveRestNote:k,withChainOutcomes:x}=await Promise.resolve().then(()=>($y(),a$)),O=k([za(u({name:r}))]),E=f(x(p([za(u({name:r}))],Number.MAX_SAFE_INTEGER).members,O)),P;if(t.merge==="auto"&&t.mergeTokenEnv){let C=m(t.mergeTokenEnv);if("error"in C)return n(String(C.error));P=g(i,C)}let T=t.gate??w,S=await d({op:r,waves:t.wave,run:c,record:v,outcome:E,...O?.next!==void 0?{followOn:{wave:O.wave,next:O.next,found:O.found}}:{},merge:t.merge,forge:g(i),...P?{merger:P}:{},release:async C=>(await h(T,C)).released,words:b()});return console.error(S.text),S.code}catch(l){return n(l instanceof Error?l.message:String(l))}}async function agt(e){let{args:t}=e,n=s=>(console.error(be({message:s})),1),r=t.op;if(!r||t.wave===void 0||t.of===void 0||!t.at)return n("--apply-status posts one wave's apply status: --op <name> --wave <n> --of <count> --apply-status <context> --at <sha> --forge <kind>");let{FORGE_KINDS:o}=await Promise.resolve().then(()=>(fi(),lh));if(!t.forge||!o.includes(t.forge))return n(`--apply-status posts on a forge: --forge ${o.join("|")}`);let i=t.forge;try{let{postOpWaveApplyStatus:s}=await Promise.resolve().then(()=>(QPe(),YPe)),{opWaveOutcomeDir:a}=await Promise.resolve().then(()=>(Mr(),uP)),{forgeFromJobEnv:c}=await Promise.resolve().then(()=>(k3(),v3)),l=i==="gitlab"&&t.at===process.env.CI_COMMIT_SHA&&/^[0-9]+$/.test(process.env.CI_PIPELINE_ID??"")?Number(process.env.CI_PIPELINE_ID):void 0,d=await s({forge:c(i),dirs:[za(a({name:r}))],wave:t.wave,of:t.of,context:t.applyStatus,at:t.at,...l!==void 0?{pipelineId:l}:{}});return console.error(d),0}catch(s){return n(`the apply status was not posted: ${s instanceof Error?s.message:String(s)}`)}}async function xAe(e,t,n){try{let{respondOpWave:r,triageOfOpWave:o}=await Promise.resolve().then(()=>(mAe(),gAe)),{resolveResponses:i}=await Promise.resolve().then(()=>(O3(),aAe)),s=i(e.respond);if(s["wave-refused"]==="off"&&s["apply-failed"]==="off"||n.result&&n.result.exitCode===0&&!o(e,t,n))return;let{detectForge:a,forgeFromEnv:c}=await Promise.resolve().then(()=>(fi(),lh)),l=a();if(!l)return;let d;try{d=c(l)}catch{return}let u=process.env.GITHUB_SHA??process.env.CI_COMMIT_SHA;await r(e,t,n,{forge:d,...u?{head:u}:{}})}catch(r){console.error(vr({message:`the wave's responses were not posted: ${r instanceof Error?r.message:String(r)}`}))}}async function cgt(e,t){let{args:n}=e,r=u=>(console.error(be({message:u})),1),{FORGE_KINDS:o,forgeFromEnv:i}=await Promise.resolve().then(()=>(fi(),lh));if(!n.forge||!o.includes(n.forge))return r(`--approval-status posts on a forge: --forge ${o.join("|")}`);let s,a;try{s=Ws(KT(za(t),"utf-8"),`--spec ${t}`),a=i(n.forge)}catch(u){return r(u instanceof Error?u.message:String(u))}let{postApprovalStatus:c,postOpenApprovalStatuses:l}=await Promise.resolve().then(()=>(kAe(),vAe)),d=A3(process.cwd(),za(t));try{if(n.open){let p=n.branch??process.env.CI_COMMIT_BRANCH;if(!p)return r("--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:d,forge:a,branch:p});for(let g of f.warnings)console.error(vr({message:g}));for(let g of f.posted)console.error(`!${g.pr}: ${g.status.state}: ${g.status.description}`);return f.warnings.length>0&&f.posted.length===0?1:0}if(n.pr===void 0||!n.head||!n.base)return r("--approval-status needs the pull request, its head and its base: --pr <n> --head <sha> --base <sha>, or --open");let u=await c({spec:s,specFile:d,forge:a,pr:n.pr,head:n.head,base:n.base});return console.error(`#${n.pr}: ${u.state}: ${u.description}`),0}catch(u){return r(`the approval status was not posted: ${u instanceof Error?u.message:String(u)}`)}}vT();_3();t$();var Agt=[{name:"run wave",handler:$Ae},{name:"run resume",handler:M9},{name:"approve",handler:qAe},{name:"workspace points",handler:B9}],Cgt=`
538
538
  chant runtime ${f$} - the wave-job commands of chant, in one file