@intentius/chant 0.124.15 → 0.124.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/commands/check-lexicon-plugin.d.ts.map +1 -1
- package/dist/cli/commands/check-lexicon-plugin.js +2 -1
- package/dist/cli/commands/lint.d.ts.map +1 -1
- package/dist/cli/commands/lint.js +3 -2
- package/dist/cli/flush.d.ts +16 -0
- package/dist/cli/flush.d.ts.map +1 -0
- package/dist/cli/flush.js +42 -0
- package/dist/cli/handlers/approve.d.ts +98 -0
- package/dist/cli/handlers/approve.d.ts.map +1 -0
- package/dist/cli/handlers/approve.js +495 -0
- package/dist/cli/handlers/operator.d.ts +1 -95
- package/dist/cli/handlers/operator.d.ts.map +1 -1
- package/dist/cli/handlers/operator.js +4 -488
- package/dist/cli/handlers/override-approve.js +1 -1
- package/dist/cli/main.d.ts +4 -15
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +4 -1062
- package/dist/cli/parse-args.d.ts +6 -0
- package/dist/cli/parse-args.d.ts.map +1 -0
- package/dist/cli/parse-args.js +1028 -0
- package/dist/components/discover.d.ts.map +1 -1
- package/dist/components/discover.js +2 -1
- package/dist/components/fan-out-record.d.ts +1 -1
- package/dist/components/fan-out-record.d.ts.map +1 -1
- package/dist/components/fan-out-record.js +3 -7
- package/dist/components/fan-out-run.d.ts +5 -3
- package/dist/components/fan-out-run.d.ts.map +1 -1
- package/dist/components/fan-out-run.js +7 -5
- package/dist/config-sandbox.d.ts.map +1 -1
- package/dist/config-sandbox.js +5 -1
- package/dist/discovery/import.d.ts.map +1 -1
- package/dist/discovery/import.js +2 -1
- package/dist/discovery/sandbox/driver.d.ts.map +1 -1
- package/dist/discovery/sandbox/driver.js +8 -3
- package/dist/gated-waves.d.ts +25 -6
- package/dist/gated-waves.d.ts.map +1 -1
- package/dist/gated-waves.js +21 -6
- package/dist/lexicon-module.d.ts.map +1 -1
- package/dist/lexicon-module.js +4 -3
- package/dist/lint/policy-import.d.ts.map +1 -1
- package/dist/lint/policy-import.js +2 -1
- package/dist/lint/rule-loader.d.ts.map +1 -1
- package/dist/lint/rule-loader.js +2 -1
- package/dist/module-interop.d.ts +20 -0
- package/dist/module-interop.d.ts.map +1 -0
- package/dist/module-interop.js +39 -0
- package/dist/op/activities/activity-contracts.d.ts +4 -4
- package/dist/op/discover.d.ts.map +1 -1
- package/dist/op/discover.js +3 -2
- package/dist/op/op-waves-run.d.ts +1 -1
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/op/op-waves-run.js +5 -6
- package/dist/op/op-waves.d.ts.map +1 -1
- package/dist/op/op-waves.js +4 -8
- package/dist/package-version.d.ts +2 -0
- package/dist/package-version.d.ts.map +1 -0
- package/dist/package-version.js +10 -0
- package/dist/wave-engine.d.ts +62 -0
- package/dist/wave-engine.d.ts.map +1 -0
- package/dist/wave-engine.js +59 -0
- package/dist/wave-layout.d.ts +29 -0
- package/dist/wave-layout.d.ts.map +1 -0
- package/dist/wave-layout.js +41 -0
- package/dist/wave-runtime.d.ts +29 -0
- package/dist/wave-runtime.d.ts.map +1 -0
- package/dist/wave-runtime.js +103 -0
- package/dist/wave-runtime.mjs +331 -0
- package/dist/workspace/ajv2020.d.ts +5 -0
- package/dist/workspace/ajv2020.d.ts.map +1 -0
- package/dist/workspace/ajv2020.js +14 -0
- package/dist/workspace/declaration.d.ts.map +1 -1
- package/dist/workspace/declaration.js +4 -8
- package/dist/workspace/kinds.d.ts.map +1 -1
- package/dist/workspace/kinds.js +2 -5
- package/dist/workspace/lineage-migrations.d.ts.map +1 -1
- package/dist/workspace/lineage-migrations.js +2 -1
- package/dist/workspace/points.d.ts.map +1 -1
- package/dist/workspace/points.js +2 -5
- package/dist/workspace/principal-classes.d.ts.map +1 -1
- package/dist/workspace/principal-classes.js +2 -5
- package/package.json +5 -3
- package/src/cli/commands/check-lexicon-plugin.ts +2 -1
- package/src/cli/commands/lint.ts +3 -2
- package/src/cli/compiled-cli.e2e.test.ts +42 -1
- package/src/cli/flush.ts +44 -0
- package/src/cli/handlers/approve.ts +618 -0
- package/src/cli/handlers/operator.ts +10 -608
- package/src/cli/handlers/override-approve.test.ts +1 -1
- package/src/cli/handlers/override-approve.ts +1 -1
- package/src/cli/main.ts +5 -816
- package/src/cli/parse-args.ts +781 -0
- package/src/components/discover.ts +2 -1
- package/src/components/fan-out-record.ts +3 -7
- package/src/components/fan-out-run.ts +7 -5
- package/src/config-sandbox.ts +5 -1
- package/src/discovery/import.ts +2 -1
- package/src/discovery/sandbox/driver.ts +8 -3
- package/src/gate-decision-bundle.test.ts +1 -0
- package/src/gated-waves.ts +28 -6
- package/src/lexicon-module.ts +4 -3
- package/src/lint/policy-import.ts +2 -1
- package/src/lint/rule-loader.ts +2 -1
- package/src/module-interop.test.ts +65 -0
- package/src/module-interop.ts +39 -0
- package/src/op/discover.ts +3 -2
- package/src/op/op-waves-run.ts +5 -6
- package/src/op/op-waves.ts +4 -8
- package/src/package-version.ts +11 -0
- package/src/wave-engine.test.ts +107 -0
- package/src/wave-engine.ts +98 -0
- package/src/wave-layout.ts +44 -0
- package/src/wave-runtime-bundle.test.ts +70 -0
- package/src/wave-runtime.e2e.test.ts +177 -0
- package/src/wave-runtime.ts +104 -0
- package/src/workspace/ajv2020.ts +17 -0
- package/src/workspace/declaration.ts +4 -10
- package/src/workspace/kinds.ts +2 -5
- package/src/workspace/lineage-migrations.ts +2 -1
- package/src/workspace/points.ts +2 -5
- package/src/workspace/principal-classes.ts +2 -5
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// @intentius/chant 0.124.17 wave-job runtime (#3896): run wave, run resume, approve, workspace points.
|
|
3
|
+
import { createRequire as __chantCreateRequire } from "node:module";
|
|
4
|
+
const require = __chantCreateRequire(import.meta.url);
|
|
5
|
+
var qte=Object.create;var tR=Object.defineProperty;var Kte=Object.getOwnPropertyDescriptor;var Jte=Object.getOwnPropertyNames;var Zte=Object.getPrototypeOf,Yte=Object.prototype.hasOwnProperty;var v=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(i){throw n=[i],i}};var ie=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(n){throw t=0,n}},_e=(e,t)=>{for(var n in t)tR(e,n,{get:t[n],enumerable:!0})},Xte=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Jte(t))!Yte.call(e,r)&&r!==n&&tR(e,r,{get:()=>t[r],enumerable:!(i=Kte(t,r))||i.enumerable});return e};var Le=(e,t,n)=>(n=e!=null?qte(Zte(e)):{},Xte(t||!e||!e.__esModule?tR(n,"default",{value:e,enumerable:!0}):n,e));function O1(e,t=new Set){let n=[];for(let i of e)if(i.startsWith("--")&&i.includes("=")){let r=i.indexOf("="),o=i.slice(0,r),s=i.slice(r+1);if(t.has(o))throw new Error(`${i} \u2014 ${o} is a boolean flag and does not take a value. Pass ${o} on its own.`);n.push(o,s)}else n.push(i);return n}var nR,rR=v(()=>{"use strict";nR=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 tne(){return!process.env.NO_COLOR&&process.stdout.isTTY!==!1}function Fs(e,t){return tne()?`${t}${e}${Ko.reset}`:e}function fe(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(Fs(n,Ko.cyan)),t.push(" - ")}return t.push(Fs("error",Ko.red)),t.push(": "),t.push(e.message),e.hint&&(t.push(`
|
|
6
|
+
`),t.push(Fs(e.hint,Ko.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(Fs(n,Ko.cyan)),t.push(" - ")}return t.push(Fs("warning",Ko.yellow)),t.push(": "),t.push(e.message),e.hint&&(t.push(`
|
|
7
|
+
`),t.push(Fs(e.hint,Ko.gray))),t.join("")}function Dp(e){return Fs(e,Ko.green)}function ur(e){return Fs(e,Ko.gray)}var Ko,Kn=v(()=>{"use strict";Ko={red:"\x1B[31m",yellow:"\x1B[33m",green:"\x1B[32m",cyan:"\x1B[36m",gray:"\x1B[90m",reset:"\x1B[0m",bold:"\x1B[1m"}});var Np,Qh=v(()=>{"use strict";Np="0.124.17"});function M(e,t,n){function i(a,l){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:l,constr:s,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,l);let c=s.prototype,u=Object.keys(c);for(let d=0;d<u.length;d++){let p=u[d];p in a||(a[p]=c[p].bind(a))}}let r=n?.Parent??Object;class o extends r{}Object.defineProperty(o,"name",{value:e});function s(a){var l;let c=n?.Parent?new o:this;i(c,a),(l=c._zod).deferred??(l.deferred=[]);for(let u of c._zod.deferred)u();return c}return Object.defineProperty(s,"init",{value:i}),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 Ht(e){return e&&Object.assign(jp,e),jp}var oR,ey,$i,Bs,jp,Gl=v(()=>{oR=Object.freeze({status:"aborted"});ey=Symbol("zod_brand"),$i=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Bs=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}},jp={}});var le={};_e(le,{BIGINT_FORMAT_RANGES:()=>gR,Class:()=>aR,NUMBER_FORMAT_RANGES:()=>mR,aborted:()=>Us,allowsEval:()=>uR,assert:()=>ane,assertEqual:()=>rne,assertIs:()=>one,assertNever:()=>sne,assertNotEqual:()=>ine,assignProp:()=>Ws,base64ToUint8Array:()=>j1,base64urlToUint8Array:()=>Rne,cached:()=>zl,captureStackTrace:()=>ny,cleanEnum:()=>$ne,cleanRegex:()=>Fp,clone:()=>Jn,cloneDef:()=>lne,createTransparentProxy:()=>gne,defineLazy:()=>He,esc:()=>ty,escapeRegex:()=>qr,extend:()=>bne,finalizeIssue:()=>dr,floatSafeRemainder:()=>cR,getElementAtPath:()=>une,getEnumValues:()=>Mp,getLengthableOrigin:()=>Wp,getParsedType:()=>mne,getSizableOrigin:()=>Gp,hexToUint8Array:()=>Ene,isObject:()=>dc,isPlainObject:()=>zs,issue:()=>Ul,joinValues:()=>V,jsonStringifyReplacer:()=>Wl,merge:()=>vne,mergeDefs:()=>Jo,normalizeParams:()=>ue,nullish:()=>Gs,numKeys:()=>fne,objectClone:()=>cne,omit:()=>yne,optionalKeys:()=>fR,parsedType:()=>ce,partial:()=>kne,pick:()=>hne,prefixIssues:()=>Ir,primitiveTypes:()=>pR,promiseAllObject:()=>dne,propertyKeyTypes:()=>Bp,randomString:()=>pne,required:()=>xne,safeExtend:()=>wne,shallowClone:()=>dR,slugify:()=>lR,stringifyPrimitive:()=>se,uint8ArrayToBase64:()=>L1,uint8ArrayToBase64url:()=>Sne,uint8ArrayToHex:()=>Ane,unwrapMessage:()=>Lp});function rne(e){return e}function ine(e){return e}function one(e){}function sne(e){throw new Error("Unexpected value in exhaustive check")}function ane(e){}function Mp(e){let t=Object.values(e).filter(i=>typeof i=="number");return Object.entries(e).filter(([i,r])=>t.indexOf(+i)===-1).map(([i,r])=>r)}function V(e,t="|"){return e.map(n=>se(n)).join(t)}function Wl(e,t){return typeof t=="bigint"?t.toString():t}function zl(e){return{get value(){{let n=e();return Object.defineProperty(this,"value",{value:n}),n}throw new Error("cached value already set")}}}function Gs(e){return e==null}function Fp(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function cR(e,t){let n=(e.toString().split(".")[1]||"").length,i=t.toString(),r=(i.split(".")[1]||"").length;if(r===0&&/\d?e-\d?/.test(i)){let l=i.match(/\d?e-(\d?)/);l?.[1]&&(r=Number.parseInt(l[1]))}let o=n>r?n:r,s=Number.parseInt(e.toFixed(o).replace(".","")),a=Number.parseInt(t.toFixed(o).replace(".",""));return s%a/10**o}function He(e,t,n){let i;Object.defineProperty(e,t,{get(){if(i!==N1)return i===void 0&&(i=N1,i=n()),i},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function cne(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Ws(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Jo(...e){let t={};for(let n of e){let i=Object.getOwnPropertyDescriptors(n);Object.assign(t,i)}return Object.defineProperties({},t)}function lne(e){return Jo(e._zod.def)}function une(e,t){return t?t.reduce((n,i)=>n?.[i],e):e}function dne(e){let t=Object.keys(e),n=t.map(i=>e[i]);return Promise.all(n).then(i=>{let r={};for(let o=0;o<t.length;o++)r[t[o]]=i[o];return r})}function pne(e=10){let t="abcdefghijklmnopqrstuvwxyz",n="";for(let i=0;i<e;i++)n+=t[Math.floor(Math.random()*t.length)];return n}function ty(e){return JSON.stringify(e)}function lR(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function dc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function zs(e){if(dc(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let n=t.prototype;return!(dc(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function dR(e){return zs(e)?{...e}:Array.isArray(e)?[...e]:e}function fne(e){let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}function qr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Jn(e,t,n){let i=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(i._zod.parent=e),i}function ue(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 gne(e){let t;return new Proxy({},{get(n,i,r){return t??(t=e()),Reflect.get(t,i,r)},set(n,i,r,o){return t??(t=e()),Reflect.set(t,i,r,o)},has(n,i){return t??(t=e()),Reflect.has(t,i)},deleteProperty(n,i){return t??(t=e()),Reflect.deleteProperty(t,i)},ownKeys(n){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,i){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,i)},defineProperty(n,i,r){return t??(t=e()),Reflect.defineProperty(t,i,r)}})}function se(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function fR(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function hne(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let o=Jo(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 Ws(this,"shape",s),s},checks:[]});return Jn(e,o)}function yne(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let o=Jo(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 Ws(this,"shape",s),s},checks:[]});return Jn(e,o)}function bne(e,t){if(!zs(t))throw new Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let o=e._zod.def.shape;for(let s in t)if(Object.getOwnPropertyDescriptor(o,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let r=Jo(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t};return Ws(this,"shape",o),o}});return Jn(e,r)}function wne(e,t){if(!zs(t))throw new Error("Invalid input to safeExtend: expected a plain object");let n=Jo(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return Ws(this,"shape",i),i}});return Jn(e,n)}function vne(e,t){let n=Jo(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t._zod.def.shape};return Ws(this,"shape",i),i},get catchall(){return t._zod.def.catchall},checks:[]});return Jn(e,n)}function kne(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let s=Jo(t._zod.def,{get shape(){let a=t._zod.def.shape,l={...a};if(n)for(let c in n){if(!(c in a))throw new Error(`Unrecognized key: "${c}"`);n[c]&&(l[c]=e?new e({type:"optional",innerType:a[c]}):a[c])}else for(let c in a)l[c]=e?new e({type:"optional",innerType:a[c]}):a[c];return Ws(this,"shape",l),l},checks:[]});return Jn(t,s)}function xne(e,t,n){let i=Jo(t._zod.def,{get shape(){let r=t._zod.def.shape,o={...r};if(n)for(let s in n){if(!(s in o))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(o[s]=new e({type:"nonoptional",innerType:r[s]}))}else for(let s in r)o[s]=new e({type:"nonoptional",innerType:r[s]});return Ws(this,"shape",o),o}});return Jn(t,i)}function Us(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 Ir(e,t){return t.map(n=>{var i;return(i=n).path??(i.path=[]),n.path.unshift(e),n})}function Lp(e){return typeof e=="string"?e:e?.message}function dr(e,t,n){let i={...e,path:e.path??[]};if(!e.message){let r=Lp(e.inst?._zod.def?.error?.(e))??Lp(t?.error?.(e))??Lp(n.customError?.(e))??Lp(n.localeError?.(e))??"Invalid input";i.message=r}return delete i.inst,delete i.continue,t?.reportInput||delete i.input,i}function Gp(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function Wp(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function ce(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 Ul(...e){let[t,n,i]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:i}:{...t}}function $ne(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function j1(e){let t=atob(e),n=new Uint8Array(t.length);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return n}function L1(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function Rne(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return j1(t+n)}function Sne(e){return L1(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Ene(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 i=0;i<t.length;i+=2)n[i/2]=Number.parseInt(t.slice(i,i+2),16);return n}function Ane(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var N1,ny,uR,mne,Bp,pR,mR,gR,aR,Ae=v(()=>{N1=Symbol("evaluating");ny="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};uR=zl(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});mne=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}`)}},Bp=new Set(["string","number","symbol"]),pR=new Set(["string","number","bigint","boolean","symbol","undefined"]);mR={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]},gR={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};aR=class{constructor(...t){}}});function Up(e,t=n=>n.message){let n={},i=[];for(let r of e.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(t(r))):i.push(t(r));return{formErrors:i,fieldErrors:n}}function Hp(e,t=n=>n.message){let n={_errors:[]},i=r=>{for(let o of r.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(s=>i({issues:s}));else if(o.code==="invalid_key")i({issues:o.issues});else if(o.code==="invalid_element")i({issues:o.issues});else if(o.path.length===0)n._errors.push(t(o));else{let s=n,a=0;for(;a<o.path.length;){let l=o.path[a];a===o.path.length-1?(s[l]=s[l]||{_errors:[]},s[l]._errors.push(t(o))):s[l]=s[l]||{_errors:[]},s=s[l],a++}}};return i(e),n}function hR(e,t=n=>n.message){let n={errors:[]},i=(r,o=[])=>{var s,a;for(let l of r.issues)if(l.code==="invalid_union"&&l.errors.length)l.errors.map(c=>i({issues:c},l.path));else if(l.code==="invalid_key")i({issues:l.issues},l.path);else if(l.code==="invalid_element")i({issues:l.issues},l.path);else{let c=[...o,...l.path];if(c.length===0){n.errors.push(t(l));continue}let u=n,d=0;for(;d<c.length;){let p=c[d],f=d===c.length-1;typeof p=="string"?(u.properties??(u.properties={}),(s=u.properties)[p]??(s[p]={errors:[]}),u=u.properties[p]):(u.items??(u.items=[]),(a=u.items)[p]??(a[p]={errors:[]}),u=u.items[p]),f&&u.errors.push(t(l)),d++}}};return i(e),n}function F1(e){let t=[],n=e.map(i=>typeof i=="object"?i.key:i);for(let i of n)typeof i=="number"?t.push(`[${i}]`):typeof i=="symbol"?t.push(`[${JSON.stringify(String(i))}]`):/[^\w$]/.test(i)?t.push(`[${JSON.stringify(i)}]`):(t.length&&t.push("."),t.push(i));return t.join("")}function yR(e){let t=[],n=[...e.issues].sort((i,r)=>(i.path??[]).length-(r.path??[]).length);for(let i of n)t.push(`\u2716 ${i.message}`),i.path?.length&&t.push(` \u2192 at ${F1(i.path)}`);return t.join(`
|
|
8
|
+
`)}var M1,zp,pr,bR=v(()=>{Gl();Ae();M1=(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,Wl,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},zp=M("$ZodError",M1),pr=M("$ZodError",M1,{Parent:Error})});var Hl,ry,Vl,iy,ql,wR,Kl,vR,oy,One,sy,Cne,ay,_ne,cy,Ine,ly,Tne,uy,Dne,dy,Nne,py,jne,kR=v(()=>{Gl();bR();Ae();Hl=e=>(t,n,i,r)=>{let o=i?Object.assign(i,{async:!1}):{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new $i;if(s.issues.length){let a=new(r?.Err??e)(s.issues.map(l=>dr(l,o,Ht())));throw ny(a,r?.callee),a}return s.value},ry=Hl(pr),Vl=e=>async(t,n,i,r)=>{let o=i?Object.assign(i,{async:!0}):{async:!0},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let a=new(r?.Err??e)(s.issues.map(l=>dr(l,o,Ht())));throw ny(a,r?.callee),a}return s.value},iy=Vl(pr),ql=e=>(t,n,i)=>{let r=i?{...i,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},r);if(o instanceof Promise)throw new $i;return o.issues.length?{success:!1,error:new(e??zp)(o.issues.map(s=>dr(s,r,Ht())))}:{success:!0,data:o.value}},wR=ql(pr),Kl=e=>async(t,n,i)=>{let r=i?Object.assign(i,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},r);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(s=>dr(s,r,Ht())))}:{success:!0,data:o.value}},vR=Kl(pr),oy=e=>(t,n,i)=>{let r=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return Hl(e)(t,n,r)},One=oy(pr),sy=e=>(t,n,i)=>Hl(e)(t,n,i),Cne=sy(pr),ay=e=>async(t,n,i)=>{let r=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return Vl(e)(t,n,r)},_ne=ay(pr),cy=e=>async(t,n,i)=>Vl(e)(t,n,i),Ine=cy(pr),ly=e=>(t,n,i)=>{let r=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return ql(e)(t,n,r)},Tne=ly(pr),uy=e=>(t,n,i)=>ql(e)(t,n,i),Dne=uy(pr),dy=e=>async(t,n,i)=>{let r=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return Kl(e)(t,n,r)},Nne=dy(pr),py=e=>async(t,n,i)=>Kl(e)(t,n,i),jne=py(pr)});var Kr={};_e(Kr,{base64:()=>LR,base64url:()=>fy,bigint:()=>zR,boolean:()=>HR,browserEmail:()=>Une,cidrv4:()=>NR,cidrv6:()=>jR,cuid:()=>xR,cuid2:()=>$R,date:()=>FR,datetime:()=>GR,domain:()=>qne,duration:()=>PR,e164:()=>MR,email:()=>CR,emoji:()=>_R,extendedDuration:()=>Lne,guid:()=>OR,hex:()=>Kne,hostname:()=>Vne,html5Email:()=>Gne,idnEmail:()=>zne,integer:()=>UR,ipv4:()=>IR,ipv6:()=>TR,ksuid:()=>ER,lowercase:()=>KR,mac:()=>DR,md5_base64:()=>Zne,md5_base64url:()=>Yne,md5_hex:()=>Jne,nanoid:()=>AR,null:()=>VR,number:()=>my,rfc5322Email:()=>Wne,sha1_base64:()=>Qne,sha1_base64url:()=>ere,sha1_hex:()=>Xne,sha256_base64:()=>nre,sha256_base64url:()=>rre,sha256_hex:()=>tre,sha384_base64:()=>ore,sha384_base64url:()=>sre,sha384_hex:()=>ire,sha512_base64:()=>cre,sha512_base64url:()=>lre,sha512_hex:()=>are,string:()=>WR,time:()=>BR,ulid:()=>RR,undefined:()=>qR,unicodeEmail:()=>B1,uppercase:()=>JR,uuid:()=>pc,uuid4:()=>Mne,uuid6:()=>Fne,uuid7:()=>Bne,xid:()=>SR});function _R(){return new RegExp(Hne,"u")}function W1(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 BR(e){return new RegExp(`^${W1(e)}$`)}function GR(e){let t=W1({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let i=`${t}(?:${n.join("|")})`;return new RegExp(`^${G1}T(?:${i})$`)}function Vp(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function qp(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var xR,$R,RR,SR,ER,AR,PR,Lne,OR,pc,Mne,Fne,Bne,CR,Gne,Wne,B1,zne,Une,Hne,IR,TR,DR,NR,jR,LR,fy,Vne,qne,MR,G1,FR,WR,zR,UR,my,HR,VR,qR,KR,JR,Kne,Jne,Zne,Yne,Xne,Qne,ere,tre,nre,rre,ire,ore,sre,are,cre,lre,gy=v(()=>{Ae();xR=/^[cC][^\s-]{8,}$/,$R=/^[0-9a-z]+$/,RR=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,SR=/^[0-9a-vA-V]{20}$/,ER=/^[A-Za-z0-9]{27}$/,AR=/^[a-zA-Z0-9_-]{21}$/,PR=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Lne=/^[-+]?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)?)??$/,OR=/^([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})$/,pc=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)$/,Mne=pc(4),Fne=pc(6),Bne=pc(7),CR=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Gne=/^[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])?)*$/,Wne=/^(([^<>()\[\]\\.,;:\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,}))$/,B1=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,zne=B1,Une=/^[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])?)*$/,Hne="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";IR=/^(?:(?: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])$/,TR=/^(([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}|:))$/,DR=e=>{let t=qr(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},NR=/^((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])$/,jR=/^(([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])$/,LR=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,fy=/^[A-Za-z0-9_-]*$/,Vne=/^(?=.{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])?)*\.?$/,qne=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,MR=/^\+[1-9]\d{6,14}$/,G1="(?:(?:\\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])))",FR=new RegExp(`^${G1}$`);WR=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},zR=/^-?\d+n?$/,UR=/^-?\d+$/,my=/^-?\d+(?:\.\d+)?$/,HR=/^(?:true|false)$/i,VR=/^null$/i,qR=/^undefined$/i,KR=/^[^A-Z]*$/,JR=/^[^a-z]*$/,Kne=/^[0-9a-fA-F]*$/;Jne=/^[0-9a-fA-F]{32}$/,Zne=Vp(22,"=="),Yne=qp(22),Xne=/^[0-9a-fA-F]{40}$/,Qne=Vp(27,"="),ere=qp(27),tre=/^[0-9a-fA-F]{64}$/,nre=Vp(43,"="),rre=qp(43),ire=/^[0-9a-fA-F]{96}$/,ore=Vp(64,""),sre=qp(64),are=/^[0-9a-fA-F]{128}$/,cre=Vp(86,"=="),lre=qp(86)});function z1(e,t,n){e.issues.length&&t.issues.push(...Ir(n,e.issues))}var Et,U1,hy,yy,ZR,YR,XR,QR,eS,tS,nS,rS,iS,Jl,oS,sS,aS,cS,lS,uS,dS,pS,fS,by=v(()=>{Gl();gy();Ae();Et=M("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),U1={number:"number",bigint:"bigint",object:"date"},hy=M("$ZodCheckLessThan",(e,t)=>{Et.init(e,t);let n=U1[typeof t.value];e._zod.onattach.push(i=>{let r=i._zod.bag,o=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<o&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=i=>{(t.inclusive?i.value<=t.value:i.value<t.value)||i.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),yy=M("$ZodCheckGreaterThan",(e,t)=>{Et.init(e,t);let n=U1[typeof t.value];e._zod.onattach.push(i=>{let r=i._zod.bag,o=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=i=>{(t.inclusive?i.value>=t.value:i.value>t.value)||i.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ZR=M("$ZodCheckMultipleOf",(e,t)=>{Et.init(e,t),e._zod.onattach.push(n=>{var i;(i=n._zod.bag).multipleOf??(i.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):cR(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})}}),YR=M("$ZodCheckNumberFormat",(e,t)=>{Et.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),i=n?"int":"number",[r,o]=mR[t.format];e._zod.onattach.push(s=>{let a=s._zod.bag;a.format=t.format,a.minimum=r,a.maximum=o,n&&(a.pattern=UR)}),e._zod.check=s=>{let a=s.value;if(n){if(!Number.isInteger(a)){s.issues.push({expected:i,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:i,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:i,inclusive:!0,continue:!t.abort});return}}a<r&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),a>o&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),XR=M("$ZodCheckBigIntFormat",(e,t)=>{Et.init(e,t);let[n,i]=gR[t.format];e._zod.onattach.push(r=>{let o=r._zod.bag;o.format=t.format,o.minimum=n,o.maximum=i}),e._zod.check=r=>{let o=r.value;o<n&&r.issues.push({origin:"bigint",input:o,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),o>i&&r.issues.push({origin:"bigint",input:o,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),QR=M("$ZodCheckMaxSize",(e,t)=>{var n;Et.init(e,t),(n=e._zod.def).when??(n.when=i=>{let r=i.value;return!Gs(r)&&r.size!==void 0}),e._zod.onattach.push(i=>{let r=i._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(i._zod.bag.maximum=t.maximum)}),e._zod.check=i=>{let r=i.value;r.size<=t.maximum||i.issues.push({origin:Gp(r),code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),eS=M("$ZodCheckMinSize",(e,t)=>{var n;Et.init(e,t),(n=e._zod.def).when??(n.when=i=>{let r=i.value;return!Gs(r)&&r.size!==void 0}),e._zod.onattach.push(i=>{let r=i._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(i._zod.bag.minimum=t.minimum)}),e._zod.check=i=>{let r=i.value;r.size>=t.minimum||i.issues.push({origin:Gp(r),code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),tS=M("$ZodCheckSizeEquals",(e,t)=>{var n;Et.init(e,t),(n=e._zod.def).when??(n.when=i=>{let r=i.value;return!Gs(r)&&r.size!==void 0}),e._zod.onattach.push(i=>{let r=i._zod.bag;r.minimum=t.size,r.maximum=t.size,r.size=t.size}),e._zod.check=i=>{let r=i.value,o=r.size;if(o===t.size)return;let s=o>t.size;i.issues.push({origin:Gp(r),...s?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),nS=M("$ZodCheckMaxLength",(e,t)=>{var n;Et.init(e,t),(n=e._zod.def).when??(n.when=i=>{let r=i.value;return!Gs(r)&&r.length!==void 0}),e._zod.onattach.push(i=>{let r=i._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(i._zod.bag.maximum=t.maximum)}),e._zod.check=i=>{let r=i.value;if(r.length<=t.maximum)return;let s=Wp(r);i.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),rS=M("$ZodCheckMinLength",(e,t)=>{var n;Et.init(e,t),(n=e._zod.def).when??(n.when=i=>{let r=i.value;return!Gs(r)&&r.length!==void 0}),e._zod.onattach.push(i=>{let r=i._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(i._zod.bag.minimum=t.minimum)}),e._zod.check=i=>{let r=i.value;if(r.length>=t.minimum)return;let s=Wp(r);i.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),iS=M("$ZodCheckLengthEquals",(e,t)=>{var n;Et.init(e,t),(n=e._zod.def).when??(n.when=i=>{let r=i.value;return!Gs(r)&&r.length!==void 0}),e._zod.onattach.push(i=>{let r=i._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=i=>{let r=i.value,o=r.length;if(o===t.length)return;let s=Wp(r),a=o>t.length;i.issues.push({origin:s,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),Jl=M("$ZodCheckStringFormat",(e,t)=>{var n,i;Et.init(e,t),e._zod.onattach.push(r=>{let o=r._zod.bag;o.format=t.format,t.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(i=e._zod).check??(i.check=()=>{})}),oS=M("$ZodCheckRegex",(e,t)=>{Jl.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})}}),sS=M("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=KR),Jl.init(e,t)}),aS=M("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=JR),Jl.init(e,t)}),cS=M("$ZodCheckIncludes",(e,t)=>{Et.init(e,t);let n=qr(t.includes),i=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=i,e._zod.onattach.push(r=>{let o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(i)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),lS=M("$ZodCheckStartsWith",(e,t)=>{Et.init(e,t);let n=new RegExp(`^${qr(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(i=>{let r=i._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=i=>{i.value.startsWith(t.prefix)||i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:i.value,inst:e,continue:!t.abort})}}),uS=M("$ZodCheckEndsWith",(e,t)=>{Et.init(e,t);let n=new RegExp(`.*${qr(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(i=>{let r=i._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=i=>{i.value.endsWith(t.suffix)||i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:i.value,inst:e,continue:!t.abort})}});dS=M("$ZodCheckProperty",(e,t)=>{Et.init(e,t),e._zod.check=n=>{let i=t.schema._zod.run({value:n.value[t.property],issues:[]},{});if(i instanceof Promise)return i.then(r=>z1(r,n,t.property));z1(i,n,t.property)}}),pS=M("$ZodCheckMimeType",(e,t)=>{Et.init(e,t);let n=new Set(t.mime);e._zod.onattach.push(i=>{i._zod.bag.mime=t.mime}),e._zod.check=i=>{n.has(i.value.type)||i.issues.push({code:"invalid_value",values:t.mime,input:i.value.type,inst:e,continue:!t.abort})}}),fS=M("$ZodCheckOverwrite",(e,t)=>{Et.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}})});var Kp,mS=v(()=>{Kp=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 i=t.split(`
|
|
9
|
+
`).filter(s=>s),r=Math.min(...i.map(s=>s.length-s.trimStart().length)),o=i.map(s=>s.slice(r)).map(s=>" ".repeat(this.indent*2)+s);for(let s of o)this.content.push(s)}compile(){let t=Function,n=this?.args,r=[...(this?.content??[""]).map(o=>` ${o}`)];return new t(...n,r.join(`
|
|
10
|
+
`))}}});var gS,hS=v(()=>{gS={major:4,minor:3,patch:6}});function MS(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}function rF(e){if(!fy.test(e))return!1;let t=e.replace(/[-_]/g,i=>i==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return MS(n)}function iF(e,t=null){try{let n=e.split(".");if(n.length!==3)return!1;let[i]=n;if(!i)return!1;let r=JSON.parse(atob(i));return!("typ"in r&&r?.typ!=="JWT"||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}}function V1(e,t,n){e.issues.length&&t.issues.push(...Ir(n,e.issues)),t.value[n]=e.value}function $y(e,t,n,i,r){if(e.issues.length){if(r&&!(n in i))return;t.issues.push(...Ir(n,e.issues))}e.value===void 0?n in i&&(t.value[n]=void 0):t.value[n]=e.value}function oF(e){let t=Object.keys(e.shape);for(let i of t)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${i}": expected a Zod schema`);let n=fR(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function sF(e,t,n,i,r,o){let s=[],a=r.keySet,l=r.catchall._zod,c=l.def.type,u=l.optout==="optional";for(let d in t){if(a.has(d))continue;if(c==="never"){s.push(d);continue}let p=l.run({value:t[d],issues:[]},i);p instanceof Promise?e.push(p.then(f=>$y(f,n,d,t,u))):$y(p,n,d,t,u)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:o}),e.length?Promise.all(e).then(()=>n):n}function q1(e,t,n,i){for(let o of e)if(o.issues.length===0)return t.value=o.value,t;let r=e.filter(o=>!Us(o));return r.length===1?(t.value=r[0].value,r[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(o=>o.issues.map(s=>dr(s,i,Ht())))}),t)}function K1(e,t,n,i){let r=e.filter(o=>o.issues.length===0);return r.length===1?(t.value=r[0].value,t):(r.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(o=>o.issues.map(s=>dr(s,i,Ht())))}):t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:[],inclusive:!1}),t)}function yS(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(zs(e)&&zs(t)){let n=Object.keys(t),i=Object.keys(e).filter(o=>n.indexOf(o)!==-1),r={...e,...t};for(let o of i){let s=yS(e[o],t[o]);if(!s.valid)return{valid:!1,mergeErrorPath:[o,...s.mergeErrorPath]};r[o]=s.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let i=0;i<e.length;i++){let r=e[i],o=t[i],s=yS(r,o);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function J1(e,t,n){let i=new Map,r;for(let a of t.issues)if(a.code==="unrecognized_keys"){r??(r=a);for(let l of a.keys)i.has(l)||i.set(l,{}),i.get(l).l=!0}else e.issues.push(a);for(let a of n.issues)if(a.code==="unrecognized_keys")for(let l of a.keys)i.has(l)||i.set(l,{}),i.get(l).r=!0;else e.issues.push(a);let o=[...i].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(o.length&&r&&e.issues.push({...r,keys:o}),Us(e))return e;let s=yS(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 wy(e,t,n){e.issues.length&&t.issues.push(...Ir(n,e.issues)),t.value[n]=e.value}function Z1(e,t,n,i,r,o,s){e.issues.length&&(Bp.has(typeof i)?n.issues.push(...Ir(i,e.issues)):n.issues.push({code:"invalid_key",origin:"map",input:r,inst:o,issues:e.issues.map(a=>dr(a,s,Ht()))})),t.issues.length&&(Bp.has(typeof i)?n.issues.push(...Ir(i,t.issues)):n.issues.push({origin:"map",code:"invalid_element",input:r,inst:o,key:i,issues:t.issues.map(a=>dr(a,s,Ht()))})),n.value.set(e.value,t.value)}function Y1(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}function X1(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}function Q1(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}function eF(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 vy(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}function ky(e,t,n){if(e.issues.length)return e.aborted=!0,e;if((n.direction||"forward")==="forward"){let r=t.transform(e.value,e);return r instanceof Promise?r.then(o=>xy(e,o,t.out,n)):xy(e,r,t.out,n)}else{let r=t.reverseTransform(e.value,e);return r instanceof Promise?r.then(o=>xy(e,o,t.in,n)):xy(e,r,t.in,n)}}function xy(e,t,n,i){return e.issues.length?(e.aborted=!0,e):n._zod.run({value:t,issues:e.issues},i)}function tF(e){return e.value=Object.freeze(e.value),e}function nF(e,t,n,i){if(!e){let r={code:"custom",input:n,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};i._zod.def.params&&(r.params=i._zod.def.params),t.issues.push(Ul(r))}}var Ne,fc,vt,bS,wS,vS,kS,xS,$S,RS,SS,ES,AS,PS,OS,CS,_S,IS,TS,DS,NS,jS,LS,FS,BS,GS,WS,zS,Ry,US,Jp,Sy,HS,VS,qS,KS,JS,ZS,YS,XS,QS,eE,aF,tE,Zp,nE,rE,iE,Ey,oE,sE,aE,cE,lE,uE,dE,Ay,pE,fE,mE,gE,hE,yE,bE,wE,vE,Yp,kE,xE,$E,RE,SE,EE,AE=v(()=>{by();Gl();mS();kR();gy();Ae();hS();Ae();Ne=M("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=gS;let i=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&i.unshift(e);for(let r of i)for(let o of r._zod.onattach)o(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let r=(s,a,l)=>{let c=Us(s),u;for(let d of a){if(d._zod.def.when){if(!d._zod.def.when(s))continue}else if(c)continue;let p=s.issues.length,f=d._zod.check(s);if(f instanceof Promise&&l?.async===!1)throw new $i;if(u||f instanceof Promise)u=(u??Promise.resolve()).then(async()=>{await f,s.issues.length!==p&&(c||(c=Us(s,p)))});else{if(s.issues.length===p)continue;c||(c=Us(s,p))}}return u?u.then(()=>s):s},o=(s,a,l)=>{if(Us(s))return s.aborted=!0,s;let c=r(a,i,l);if(c instanceof Promise){if(l.async===!1)throw new $i;return c.then(u=>e._zod.parse(u,l))}return e._zod.parse(c,l)};e._zod.run=(s,a)=>{if(a.skipChecks)return e._zod.parse(s,a);if(a.direction==="backward"){let c=e._zod.parse({value:s.value,issues:[]},{...a,skipChecks:!0});return c instanceof Promise?c.then(u=>o(u,s,a)):o(c,s,a)}let l=e._zod.parse(s,a);if(l instanceof Promise){if(a.async===!1)throw new $i;return l.then(c=>r(c,i,a))}return r(l,i,a)}}He(e,"~standard",()=>({validate:r=>{try{let o=wR(e,r);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return vR(e,r).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),fc=M("$ZodString",(e,t)=>{Ne.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??WR(e._zod.bag),e._zod.parse=(n,i)=>{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}}),vt=M("$ZodStringFormat",(e,t)=>{Jl.init(e,t),fc.init(e,t)}),bS=M("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=OR),vt.init(e,t)}),wS=M("$ZodUUID",(e,t)=>{if(t.version){let i={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(i===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=pc(i))}else t.pattern??(t.pattern=pc());vt.init(e,t)}),vS=M("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=CR),vt.init(e,t)}),kS=M("$ZodURL",(e,t)=>{vt.init(e,t),e._zod.check=n=>{try{let i=n.value.trim(),r=new URL(i);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(r.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=r.href:n.value=i;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),xS=M("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=_R()),vt.init(e,t)}),$S=M("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=AR),vt.init(e,t)}),RS=M("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=xR),vt.init(e,t)}),SS=M("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=$R),vt.init(e,t)}),ES=M("$ZodULID",(e,t)=>{t.pattern??(t.pattern=RR),vt.init(e,t)}),AS=M("$ZodXID",(e,t)=>{t.pattern??(t.pattern=SR),vt.init(e,t)}),PS=M("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=ER),vt.init(e,t)}),OS=M("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=GR(t)),vt.init(e,t)}),CS=M("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=FR),vt.init(e,t)}),_S=M("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=BR(t)),vt.init(e,t)}),IS=M("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=PR),vt.init(e,t)}),TS=M("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=IR),vt.init(e,t),e._zod.bag.format="ipv4"}),DS=M("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=TR),vt.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})}}}),NS=M("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=DR(t.delimiter)),vt.init(e,t),e._zod.bag.format="mac"}),jS=M("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=NR),vt.init(e,t)}),LS=M("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=jR),vt.init(e,t),e._zod.check=n=>{let i=n.value.split("/");try{if(i.length!==2)throw new Error;let[r,o]=i;if(!o)throw new Error;let s=Number(o);if(`${s}`!==o)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${r}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});FS=M("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=LR),vt.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{MS(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});BS=M("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=fy),vt.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{rF(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),GS=M("$ZodE164",(e,t)=>{t.pattern??(t.pattern=MR),vt.init(e,t)});WS=M("$ZodJWT",(e,t)=>{vt.init(e,t),e._zod.check=n=>{iF(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),zS=M("$ZodCustomStringFormat",(e,t)=>{vt.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})}}),Ry=M("$ZodNumber",(e,t)=>{Ne.init(e,t),e._zod.pattern=e._zod.bag.pattern??my,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let r=n.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;let o=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...o?{received:o}:{}}),n}}),US=M("$ZodNumberFormat",(e,t)=>{YR.init(e,t),Ry.init(e,t)}),Jp=M("$ZodBoolean",(e,t)=>{Ne.init(e,t),e._zod.pattern=HR,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=!!n.value}catch{}let r=n.value;return typeof r=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}}),Sy=M("$ZodBigInt",(e,t)=>{Ne.init(e,t),e._zod.pattern=zR,e._zod.parse=(n,i)=>{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}}),HS=M("$ZodBigIntFormat",(e,t)=>{XR.init(e,t),Sy.init(e,t)}),VS=M("$ZodSymbol",(e,t)=>{Ne.init(e,t),e._zod.parse=(n,i)=>{let r=n.value;return typeof r=="symbol"||n.issues.push({expected:"symbol",code:"invalid_type",input:r,inst:e}),n}}),qS=M("$ZodUndefined",(e,t)=>{Ne.init(e,t),e._zod.pattern=qR,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(n,i)=>{let r=n.value;return typeof r>"u"||n.issues.push({expected:"undefined",code:"invalid_type",input:r,inst:e}),n}}),KS=M("$ZodNull",(e,t)=>{Ne.init(e,t),e._zod.pattern=VR,e._zod.values=new Set([null]),e._zod.parse=(n,i)=>{let r=n.value;return r===null||n.issues.push({expected:"null",code:"invalid_type",input:r,inst:e}),n}}),JS=M("$ZodAny",(e,t)=>{Ne.init(e,t),e._zod.parse=n=>n}),ZS=M("$ZodUnknown",(e,t)=>{Ne.init(e,t),e._zod.parse=n=>n}),YS=M("$ZodNever",(e,t)=>{Ne.init(e,t),e._zod.parse=(n,i)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)}),XS=M("$ZodVoid",(e,t)=>{Ne.init(e,t),e._zod.parse=(n,i)=>{let r=n.value;return typeof r>"u"||n.issues.push({expected:"void",code:"invalid_type",input:r,inst:e}),n}}),QS=M("$ZodDate",(e,t)=>{Ne.init(e,t),e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=new Date(n.value)}catch{}let r=n.value,o=r instanceof Date;return o&&!Number.isNaN(r.getTime())||n.issues.push({expected:"date",code:"invalid_type",input:r,...o?{received:"Invalid Date"}:{},inst:e}),n}});eE=M("$ZodArray",(e,t)=>{Ne.init(e,t),e._zod.parse=(n,i)=>{let r=n.value;if(!Array.isArray(r))return n.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),n;n.value=Array(r.length);let o=[];for(let s=0;s<r.length;s++){let a=r[s],l=t.element._zod.run({value:a,issues:[]},i);l instanceof Promise?o.push(l.then(c=>V1(c,n,s))):V1(l,n,s)}return o.length?Promise.all(o).then(()=>n):n}});aF=M("$ZodObject",(e,t)=>{if(Ne.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let a=t.shape;Object.defineProperty(t,"shape",{get:()=>{let l={...a};return Object.defineProperty(t,"shape",{value:l}),l}})}let i=zl(()=>oF(t));He(e._zod,"propValues",()=>{let a=t.shape,l={};for(let c in a){let u=a[c]._zod;if(u.values){l[c]??(l[c]=new Set);for(let d of u.values)l[c].add(d)}}return l});let r=dc,o=t.catchall,s;e._zod.parse=(a,l)=>{s??(s=i.value);let c=a.value;if(!r(c))return a.issues.push({expected:"object",code:"invalid_type",input:c,inst:e}),a;a.value={};let u=[],d=s.shape;for(let p of s.keys){let f=d[p],g=f._zod.optout==="optional",h=f._zod.run({value:c[p],issues:[]},l);h instanceof Promise?u.push(h.then(b=>$y(b,a,p,c,g))):$y(h,a,p,c,g)}return o?sF(u,c,a,l,i.value,e):u.length?Promise.all(u).then(()=>a):a}}),tE=M("$ZodObjectJIT",(e,t)=>{aF.init(e,t);let n=e._zod.parse,i=zl(()=>oF(t)),r=p=>{let f=new Kp(["shape","payload","ctx"]),g=i.value,h=k=>{let R=ty(k);return`shape[${R}]._zod.run({ value: input[${R}], issues: [] }, ctx)`};f.write("const input = payload.value;");let b=Object.create(null),w=0;for(let k of g.keys)b[k]=`key_${w++}`;f.write("const newResult = {};");for(let k of g.keys){let R=b[k],$=ty(k),T=p[k]?._zod?.optout==="optional";f.write(`const ${R} = ${h(k)};`),T?f.write(`
|
|
11
|
+
if (${R}.issues.length) {
|
|
12
|
+
if (${$} in input) {
|
|
13
|
+
payload.issues = payload.issues.concat(${R}.issues.map(iss => ({
|
|
14
|
+
...iss,
|
|
15
|
+
path: iss.path ? [${$}, ...iss.path] : [${$}]
|
|
16
|
+
})));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (${R}.value === undefined) {
|
|
21
|
+
if (${$} in input) {
|
|
22
|
+
newResult[${$}] = undefined;
|
|
23
|
+
}
|
|
24
|
+
} else {
|
|
25
|
+
newResult[${$}] = ${R}.value;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
`):f.write(`
|
|
29
|
+
if (${R}.issues.length) {
|
|
30
|
+
payload.issues = payload.issues.concat(${R}.issues.map(iss => ({
|
|
31
|
+
...iss,
|
|
32
|
+
path: iss.path ? [${$}, ...iss.path] : [${$}]
|
|
33
|
+
})));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (${R}.value === undefined) {
|
|
37
|
+
if (${$} in input) {
|
|
38
|
+
newResult[${$}] = undefined;
|
|
39
|
+
}
|
|
40
|
+
} else {
|
|
41
|
+
newResult[${$}] = ${R}.value;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
`)}f.write("payload.value = newResult;"),f.write("return payload;");let x=f.compile();return(k,R)=>x(p,k,R)},o,s=dc,a=!jp.jitless,c=a&&uR.value,u=t.catchall,d;e._zod.parse=(p,f)=>{d??(d=i.value);let g=p.value;return s(g)?a&&c&&f?.async===!1&&f.jitless!==!0?(o||(o=r(t.shape)),p=o(p,f),u?sF([],g,p,f,d,e):p):n(p,f):(p.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),p)}});Zp=M("$ZodUnion",(e,t)=>{Ne.init(e,t),He(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),He(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),He(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),He(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){let r=t.options.map(o=>o._zod.pattern);return new RegExp(`^(${r.map(o=>Fp(o.source)).join("|")})$`)}});let n=t.options.length===1,i=t.options[0]._zod.run;e._zod.parse=(r,o)=>{if(n)return i(r,o);let s=!1,a=[];for(let l of t.options){let c=l._zod.run({value:r.value,issues:[]},o);if(c instanceof Promise)a.push(c),s=!0;else{if(c.issues.length===0)return c;a.push(c)}}return s?Promise.all(a).then(l=>q1(l,r,e,o)):q1(a,r,e,o)}});nE=M("$ZodXor",(e,t)=>{Zp.init(e,t),t.inclusive=!1;let n=t.options.length===1,i=t.options[0]._zod.run;e._zod.parse=(r,o)=>{if(n)return i(r,o);let s=!1,a=[];for(let l of t.options){let c=l._zod.run({value:r.value,issues:[]},o);c instanceof Promise?(a.push(c),s=!0):a.push(c)}return s?Promise.all(a).then(l=>K1(l,r,e,o)):K1(a,r,e,o)}}),rE=M("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Zp.init(e,t);let n=e._zod.parse;He(e._zod,"propValues",()=>{let r={};for(let o of t.options){let s=o._zod.propValues;if(!s||Object.keys(s).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(let[a,l]of Object.entries(s)){r[a]||(r[a]=new Set);for(let c of l)r[a].add(c)}}return r});let i=zl(()=>{let r=t.options,o=new Map;for(let s of r){let a=s._zod.propValues?.[t.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(let l of a){if(o.has(l))throw new Error(`Duplicate discriminator value "${String(l)}"`);o.set(l,s)}}return o});e._zod.parse=(r,o)=>{let s=r.value;if(!dc(s))return r.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),r;let a=i.value.get(s?.[t.discriminator]);return a?a._zod.run(r,o):t.unionFallback?n(r,o):(r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:s,path:[t.discriminator],inst:e}),r)}}),iE=M("$ZodIntersection",(e,t)=>{Ne.init(e,t),e._zod.parse=(n,i)=>{let r=n.value,o=t.left._zod.run({value:r,issues:[]},i),s=t.right._zod.run({value:r,issues:[]},i);return o instanceof Promise||s instanceof Promise?Promise.all([o,s]).then(([l,c])=>J1(n,l,c)):J1(n,o,s)}});Ey=M("$ZodTuple",(e,t)=>{Ne.init(e,t);let n=t.items;e._zod.parse=(i,r)=>{let o=i.value;if(!Array.isArray(o))return i.issues.push({input:o,inst:e,expected:"tuple",code:"invalid_type"}),i;i.value=[];let s=[],a=[...n].reverse().findIndex(u=>u._zod.optin!=="optional"),l=a===-1?0:n.length-a;if(!t.rest){let u=o.length>n.length,d=o.length<l-1;if(u||d)return i.issues.push({...u?{code:"too_big",maximum:n.length,inclusive:!0}:{code:"too_small",minimum:n.length},input:o,inst:e,origin:"array"}),i}let c=-1;for(let u of n){if(c++,c>=o.length&&c>=l)continue;let d=u._zod.run({value:o[c],issues:[]},r);d instanceof Promise?s.push(d.then(p=>wy(p,i,c))):wy(d,i,c)}if(t.rest){let u=o.slice(n.length);for(let d of u){c++;let p=t.rest._zod.run({value:d,issues:[]},r);p instanceof Promise?s.push(p.then(f=>wy(f,i,c))):wy(p,i,c)}}return s.length?Promise.all(s).then(()=>i):i}});oE=M("$ZodRecord",(e,t)=>{Ne.init(e,t),e._zod.parse=(n,i)=>{let r=n.value;if(!zs(r))return n.issues.push({expected:"record",code:"invalid_type",input:r,inst:e}),n;let o=[],s=t.keyType._zod.values;if(s){n.value={};let a=new Set;for(let c of s)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){a.add(typeof c=="number"?c.toString():c);let u=t.valueType._zod.run({value:r[c],issues:[]},i);u instanceof Promise?o.push(u.then(d=>{d.issues.length&&n.issues.push(...Ir(c,d.issues)),n.value[c]=d.value})):(u.issues.length&&n.issues.push(...Ir(c,u.issues)),n.value[c]=u.value)}let l;for(let c in r)a.has(c)||(l=l??[],l.push(c));l&&l.length>0&&n.issues.push({code:"unrecognized_keys",input:r,inst:e,keys:l})}else{n.value={};for(let a of Reflect.ownKeys(r)){if(a==="__proto__")continue;let l=t.keyType._zod.run({value:a,issues:[]},i);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&my.test(a)&&l.issues.length){let d=t.keyType._zod.run({value:Number(a),issues:[]},i);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");d.issues.length===0&&(l=d)}if(l.issues.length){t.mode==="loose"?n.value[a]=r[a]:n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(d=>dr(d,i,Ht())),input:a,path:[a],inst:e});continue}let u=t.valueType._zod.run({value:r[a],issues:[]},i);u instanceof Promise?o.push(u.then(d=>{d.issues.length&&n.issues.push(...Ir(a,d.issues)),n.value[l.value]=d.value})):(u.issues.length&&n.issues.push(...Ir(a,u.issues)),n.value[l.value]=u.value)}}return o.length?Promise.all(o).then(()=>n):n}}),sE=M("$ZodMap",(e,t)=>{Ne.init(e,t),e._zod.parse=(n,i)=>{let r=n.value;if(!(r instanceof Map))return n.issues.push({expected:"map",code:"invalid_type",input:r,inst:e}),n;let o=[];n.value=new Map;for(let[s,a]of r){let l=t.keyType._zod.run({value:s,issues:[]},i),c=t.valueType._zod.run({value:a,issues:[]},i);l instanceof Promise||c instanceof Promise?o.push(Promise.all([l,c]).then(([u,d])=>{Z1(u,d,n,s,r,e,i)})):Z1(l,c,n,s,r,e,i)}return o.length?Promise.all(o).then(()=>n):n}});aE=M("$ZodSet",(e,t)=>{Ne.init(e,t),e._zod.parse=(n,i)=>{let r=n.value;if(!(r instanceof Set))return n.issues.push({input:r,inst:e,expected:"set",code:"invalid_type"}),n;let o=[];n.value=new Set;for(let s of r){let a=t.valueType._zod.run({value:s,issues:[]},i);a instanceof Promise?o.push(a.then(l=>Y1(l,n))):Y1(a,n)}return o.length?Promise.all(o).then(()=>n):n}});cE=M("$ZodEnum",(e,t)=>{Ne.init(e,t);let n=Mp(t.entries),i=new Set(n);e._zod.values=i,e._zod.pattern=new RegExp(`^(${n.filter(r=>Bp.has(typeof r)).map(r=>typeof r=="string"?qr(r):r.toString()).join("|")})$`),e._zod.parse=(r,o)=>{let s=r.value;return i.has(s)||r.issues.push({code:"invalid_value",values:n,input:s,inst:e}),r}}),lE=M("$ZodLiteral",(e,t)=>{if(Ne.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");let n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(i=>typeof i=="string"?qr(i):i?qr(i.toString()):String(i)).join("|")})$`),e._zod.parse=(i,r)=>{let o=i.value;return n.has(o)||i.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),i}}),uE=M("$ZodFile",(e,t)=>{Ne.init(e,t),e._zod.parse=(n,i)=>{let r=n.value;return r instanceof File||n.issues.push({expected:"file",code:"invalid_type",input:r,inst:e}),n}}),dE=M("$ZodTransform",(e,t)=>{Ne.init(e,t),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new Bs(e.constructor.name);let r=t.transform(n.value,n);if(i.async)return(r instanceof Promise?r:Promise.resolve(r)).then(s=>(n.value=s,n));if(r instanceof Promise)throw new $i;return n.value=r,n}});Ay=M("$ZodOptional",(e,t)=>{Ne.init(e,t),e._zod.optin="optional",e._zod.optout="optional",He(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),He(e._zod,"pattern",()=>{let n=t.innerType._zod.pattern;return n?new RegExp(`^(${Fp(n.source)})?$`):void 0}),e._zod.parse=(n,i)=>{if(t.innerType._zod.optin==="optional"){let r=t.innerType._zod.run(n,i);return r instanceof Promise?r.then(o=>X1(o,n.value)):X1(r,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,i)}}),pE=M("$ZodExactOptional",(e,t)=>{Ay.init(e,t),He(e._zod,"values",()=>t.innerType._zod.values),He(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,i)=>t.innerType._zod.run(n,i)}),fE=M("$ZodNullable",(e,t)=>{Ne.init(e,t),He(e._zod,"optin",()=>t.innerType._zod.optin),He(e._zod,"optout",()=>t.innerType._zod.optout),He(e._zod,"pattern",()=>{let n=t.innerType._zod.pattern;return n?new RegExp(`^(${Fp(n.source)}|null)$`):void 0}),He(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,i)=>n.value===null?n:t.innerType._zod.run(n,i)}),mE=M("$ZodDefault",(e,t)=>{Ne.init(e,t),e._zod.optin="optional",He(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)return n.value=t.defaultValue,n;let r=t.innerType._zod.run(n,i);return r instanceof Promise?r.then(o=>Q1(o,t)):Q1(r,t)}});gE=M("$ZodPrefault",(e,t)=>{Ne.init(e,t),e._zod.optin="optional",He(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,i)=>(i.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,i))}),hE=M("$ZodNonOptional",(e,t)=>{Ne.init(e,t),He(e._zod,"values",()=>{let n=t.innerType._zod.values;return n?new Set([...n].filter(i=>i!==void 0)):void 0}),e._zod.parse=(n,i)=>{let r=t.innerType._zod.run(n,i);return r instanceof Promise?r.then(o=>eF(o,e)):eF(r,e)}});yE=M("$ZodSuccess",(e,t)=>{Ne.init(e,t),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new Bs("ZodSuccess");let r=t.innerType._zod.run(n,i);return r instanceof Promise?r.then(o=>(n.value=o.issues.length===0,n)):(n.value=r.issues.length===0,n)}}),bE=M("$ZodCatch",(e,t)=>{Ne.init(e,t),He(e._zod,"optin",()=>t.innerType._zod.optin),He(e._zod,"optout",()=>t.innerType._zod.optout),He(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run(n,i);return r instanceof Promise?r.then(o=>(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(s=>dr(s,i,Ht()))},input:n.value}),n.issues=[]),n)):(n.value=r.value,r.issues.length&&(n.value=t.catchValue({...n,error:{issues:r.issues.map(o=>dr(o,i,Ht()))},input:n.value}),n.issues=[]),n)}}),wE=M("$ZodNaN",(e,t)=>{Ne.init(e,t),e._zod.parse=(n,i)=>((typeof n.value!="number"||!Number.isNaN(n.value))&&n.issues.push({input:n.value,inst:e,expected:"nan",code:"invalid_type"}),n)}),vE=M("$ZodPipe",(e,t)=>{Ne.init(e,t),He(e._zod,"values",()=>t.in._zod.values),He(e._zod,"optin",()=>t.in._zod.optin),He(e._zod,"optout",()=>t.out._zod.optout),He(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,i)=>{if(i.direction==="backward"){let o=t.out._zod.run(n,i);return o instanceof Promise?o.then(s=>vy(s,t.in,i)):vy(o,t.in,i)}let r=t.in._zod.run(n,i);return r instanceof Promise?r.then(o=>vy(o,t.out,i)):vy(r,t.out,i)}});Yp=M("$ZodCodec",(e,t)=>{Ne.init(e,t),He(e._zod,"values",()=>t.in._zod.values),He(e._zod,"optin",()=>t.in._zod.optin),He(e._zod,"optout",()=>t.out._zod.optout),He(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,i)=>{if((i.direction||"forward")==="forward"){let o=t.in._zod.run(n,i);return o instanceof Promise?o.then(s=>ky(s,t,i)):ky(o,t,i)}else{let o=t.out._zod.run(n,i);return o instanceof Promise?o.then(s=>ky(s,t,i)):ky(o,t,i)}}});kE=M("$ZodReadonly",(e,t)=>{Ne.init(e,t),He(e._zod,"propValues",()=>t.innerType._zod.propValues),He(e._zod,"values",()=>t.innerType._zod.values),He(e._zod,"optin",()=>t.innerType?._zod?.optin),He(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run(n,i);return r instanceof Promise?r.then(tF):tF(r)}});xE=M("$ZodTemplateLiteral",(e,t)=>{Ne.init(e,t);let n=[];for(let i of t.parts)if(typeof i=="object"&&i!==null){if(!i._zod.pattern)throw new Error(`Invalid template literal part, no pattern found: ${[...i._zod.traits].shift()}`);let r=i._zod.pattern instanceof RegExp?i._zod.pattern.source:i._zod.pattern;if(!r)throw new Error(`Invalid template literal part: ${i._zod.traits}`);let o=r.startsWith("^")?1:0,s=r.endsWith("$")?r.length-1:r.length;n.push(r.slice(o,s))}else if(i===null||pR.has(typeof i))n.push(qr(`${i}`));else throw new Error(`Invalid template literal part: ${i}`);e._zod.pattern=new RegExp(`^${n.join("")}$`),e._zod.parse=(i,r)=>typeof i.value!="string"?(i.issues.push({input:i.value,inst:e,expected:"string",code:"invalid_type"}),i):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(i.value)||i.issues.push({input:i.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),i)}),$E=M("$ZodFunction",(e,t)=>(Ne.init(e,t),e._def=t,e._zod.def=t,e.implement=n=>{if(typeof n!="function")throw new Error("implement() must be called with a function");return function(...i){let r=e._def.input?ry(e._def.input,i):i,o=Reflect.apply(n,this,r);return e._def.output?ry(e._def.output,o):o}},e.implementAsync=n=>{if(typeof n!="function")throw new Error("implementAsync() must be called with a function");return async function(...i){let r=e._def.input?await iy(e._def.input,i):i,o=await Reflect.apply(n,this,r);return e._def.output?await iy(e._def.output,o):o}},e._zod.parse=(n,i)=>typeof n.value!="function"?(n.issues.push({code:"invalid_type",expected:"function",input:n.value,inst:e}),n):(e._def.output&&e._def.output._zod.def.type==="promise"?n.value=e.implementAsync(n.value):n.value=e.implement(n.value),n),e.input=(...n)=>{let i=e.constructor;return Array.isArray(n[0])?new i({type:"function",input:new Ey({type:"tuple",items:n[0],rest:n[1]}),output:e._def.output}):new i({type:"function",input:n[0],output:e._def.output})},e.output=n=>{let i=e.constructor;return new i({type:"function",input:e._def.input,output:n})},e)),RE=M("$ZodPromise",(e,t)=>{Ne.init(e,t),e._zod.parse=(n,i)=>Promise.resolve(n.value).then(r=>t.innerType._zod.run({value:r,issues:[]},i))}),SE=M("$ZodLazy",(e,t)=>{Ne.init(e,t),He(e._zod,"innerType",()=>t.getter()),He(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),He(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),He(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),He(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(n,i)=>e._zod.innerType._zod.run(n,i)}),EE=M("$ZodCustom",(e,t)=>{Et.init(e,t),Ne.init(e,t),e._zod.parse=(n,i)=>n,e._zod.check=n=>{let i=n.value,r=t.fn(i);if(r instanceof Promise)return r.then(o=>nF(o,n,i,e));nF(r,n,i,e)}})});function cF(){return{localeError:dre()}}var dre,lF=v(()=>{Ae();dre=()=>{let e={string:{unit:"\u062D\u0631\u0641",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},file:{unit:"\u0628\u0627\u064A\u062A",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},array:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},set:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"}};function t(r){return e[r]??null}let n={regex:"\u0645\u062F\u062E\u0644",email:"\u0628\u0631\u064A\u062F \u0625\u0644\u0643\u062A\u0631\u0648\u0646\u064A",url:"\u0631\u0627\u0628\u0637",emoji:"\u0625\u064A\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u064A\u062E \u0648\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",date:"\u062A\u0627\u0631\u064A\u062E \u0628\u0645\u0639\u064A\u0627\u0631 ISO",time:"\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",duration:"\u0645\u062F\u0629 \u0628\u0645\u0639\u064A\u0627\u0631 ISO",ipv4:"\u0639\u0646\u0648\u0627\u0646 IPv4",ipv6:"\u0639\u0646\u0648\u0627\u0646 IPv6",cidrv4:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv4",cidrv6:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv6",base64:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64-encoded",base64url:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64url-encoded",json_string:"\u0646\u064E\u0635 \u0639\u0644\u0649 \u0647\u064A\u0626\u0629 JSON",e164:"\u0631\u0642\u0645 \u0647\u0627\u062A\u0641 \u0628\u0645\u0639\u064A\u0627\u0631 E.164",jwt:"JWT",template_literal:"\u0645\u062F\u062E\u0644"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 instanceof ${r.expected}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${a}`:`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${o}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${a}`}case"invalid_value":return r.values.length===1?`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${se(r.values[0])}`:`\u0627\u062E\u062A\u064A\u0627\u0631 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062A\u0648\u0642\u0639 \u0627\u0646\u062A\u0642\u0627\u0621 \u0623\u062D\u062F \u0647\u0630\u0647 \u0627\u0644\u062E\u064A\u0627\u0631\u0627\u062A: ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?` \u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${r.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${o} ${r.maximum.toString()} ${s.unit??"\u0639\u0646\u0635\u0631"}`:`\u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${r.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${o} ${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${r.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${o} ${r.minimum.toString()} ${s.unit}`:`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${r.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${o} ${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0628\u062F\u0623 \u0628\u0640 "${r.prefix}"`:o.format==="ends_with"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0646\u062A\u0647\u064A \u0628\u0640 "${o.suffix}"`:o.format==="includes"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u062A\u0636\u0645\u0651\u064E\u0646 "${o.includes}"`:o.format==="regex"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0637\u0627\u0628\u0642 \u0627\u0644\u0646\u0645\u0637 ${o.pattern}`:`${n[o.format]??r.format} \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644`}case"not_multiple_of":return`\u0631\u0642\u0645 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0645\u0646 \u0645\u0636\u0627\u0639\u0641\u0627\u062A ${r.divisor}`;case"unrecognized_keys":return`\u0645\u0639\u0631\u0641${r.keys.length>1?"\u0627\u062A":""} \u063A\u0631\u064A\u0628${r.keys.length>1?"\u0629":""}: ${V(r.keys,"\u060C ")}`;case"invalid_key":return`\u0645\u0639\u0631\u0641 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${r.origin}`;case"invalid_union":return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644";case"invalid_element":return`\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${r.origin}`;default:return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644"}}}});function uF(){return{localeError:pre()}}var pre,dF=v(()=>{Ae();pre=()=>{let e={string:{unit:"simvol",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"element",verb:"olmal\u0131d\u0131r"},set:{unit:"element",verb:"olmal\u0131d\u0131r"}};function t(r){return e[r]??null}let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n instanceof ${r.expected}, daxil olan ${a}`:`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${o}, daxil olan ${a}`}case"invalid_value":return r.values.length===1?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${se(r.values[0])}`:`Yanl\u0131\u015F se\xE7im: a\u015Fa\u011F\u0131dak\u0131lardan biri olmal\u0131d\u0131r: ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${r.origin??"d\u0259y\u0259r"} ${o}${r.maximum.toString()} ${s.unit??"element"}`:`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${r.origin??"d\u0259y\u0259r"} ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${r.origin} ${o}${r.minimum.toString()} ${s.unit}`:`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${r.origin} ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Yanl\u0131\u015F m\u0259tn: "${o.prefix}" il\u0259 ba\u015Flamal\u0131d\u0131r`:o.format==="ends_with"?`Yanl\u0131\u015F m\u0259tn: "${o.suffix}" il\u0259 bitm\u0259lidir`:o.format==="includes"?`Yanl\u0131\u015F m\u0259tn: "${o.includes}" daxil olmal\u0131d\u0131r`:o.format==="regex"?`Yanl\u0131\u015F m\u0259tn: ${o.pattern} \u015Fablonuna uy\u011Fun olmal\u0131d\u0131r`:`Yanl\u0131\u015F ${n[o.format]??r.format}`}case"not_multiple_of":return`Yanl\u0131\u015F \u0259d\u0259d: ${r.divisor} il\u0259 b\xF6l\xFCn\u0259 bil\u0259n olmal\u0131d\u0131r`;case"unrecognized_keys":return`Tan\u0131nmayan a\xE7ar${r.keys.length>1?"lar":""}: ${V(r.keys,", ")}`;case"invalid_key":return`${r.origin} daxilind\u0259 yanl\u0131\u015F a\xE7ar`;case"invalid_union":return"Yanl\u0131\u015F d\u0259y\u0259r";case"invalid_element":return`${r.origin} daxilind\u0259 yanl\u0131\u015F d\u0259y\u0259r`;default:return"Yanl\u0131\u015F d\u0259y\u0259r"}}}});function pF(e,t,n,i){let r=Math.abs(e),o=r%10,s=r%100;return s>=11&&s<=19?i:o===1?t:o>=2&&o<=4?n:i}function fF(){return{localeError:fre()}}var fre,mF=v(()=>{Ae();fre=()=>{let e={string:{unit:{one:"\u0441\u0456\u043C\u0432\u0430\u043B",few:"\u0441\u0456\u043C\u0432\u0430\u043B\u044B",many:"\u0441\u0456\u043C\u0432\u0430\u043B\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u044B",many:"\u0431\u0430\u0439\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"}};function t(r){return e[r]??null}let n={regex:"\u0443\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0430\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0456 \u0447\u0430\u0441",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0447\u0430\u0441",duration:"ISO \u043F\u0440\u0430\u0446\u044F\u0433\u043B\u0430\u0441\u0446\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0430\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0430\u0441",cidrv4:"IPv4 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",base64:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64",base64url:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64url",json_string:"JSON \u0440\u0430\u0434\u043E\u043A",e164:"\u043D\u0443\u043C\u0430\u0440 E.164",jwt:"JWT",template_literal:"\u0443\u0432\u043E\u0434"},i={nan:"NaN",number:"\u043B\u0456\u043A",array:"\u043C\u0430\u0441\u0456\u045E"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F instanceof ${r.expected}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${a}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F ${o}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${a}`}case"invalid_value":return r.values.length===1?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F ${se(r.values[0])}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0432\u0430\u0440\u044B\u044F\u043D\u0442: \u0447\u0430\u043A\u0430\u045E\u0441\u044F \u0430\u0434\u0437\u0456\u043D \u0437 ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);if(s){let a=Number(r.maximum),l=pF(a,s.unit.one,s.unit.few,s.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${r.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${s.verb} ${o}${r.maximum.toString()} ${l}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${r.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);if(s){let a=Number(r.minimum),l=pF(a,s.unit.one,s.unit.few,s.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${r.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${s.verb} ${o}${r.minimum.toString()} ${l}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${r.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u043F\u0430\u0447\u044B\u043D\u0430\u0446\u0446\u0430 \u0437 "${o.prefix}"`:o.format==="ends_with"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u0430\u043A\u0430\u043D\u0447\u0432\u0430\u0446\u0446\u0430 \u043D\u0430 "${o.suffix}"`:o.format==="includes"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u043C\u044F\u0448\u0447\u0430\u0446\u044C "${o.includes}"`:o.format==="regex"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0430\u0434\u043F\u0430\u0432\u044F\u0434\u0430\u0446\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${o.pattern}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B ${n[o.format]??r.format}`}case"not_multiple_of":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043B\u0456\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0431\u044B\u0446\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${r.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u0430\u0437\u043D\u0430\u043D\u044B ${r.keys.length>1?"\u043A\u043B\u044E\u0447\u044B":"\u043A\u043B\u044E\u0447"}: ${V(r.keys,", ")}`;case"invalid_key":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043A\u043B\u044E\u0447 \u0443 ${r.origin}`;case"invalid_union":return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434";case"invalid_element":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u0430\u0435 \u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435 \u045E ${r.origin}`;default:return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434"}}}});function gF(){return{localeError:mre()}}var mre,hF=v(()=>{Ae();mre=()=>{let e={string:{unit:"\u0441\u0438\u043C\u0432\u043E\u043B\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},file:{unit:"\u0431\u0430\u0439\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},array:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},set:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"}};function t(r){return e[r]??null}let n={regex:"\u0432\u0445\u043E\u0434",email:"\u0438\u043C\u0435\u0439\u043B \u0430\u0434\u0440\u0435\u0441",url:"URL",emoji:"\u0435\u043C\u043E\u0434\u0436\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0432\u0440\u0435\u043C\u0435",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0432\u0440\u0435\u043C\u0435",duration:"ISO \u043F\u0440\u043E\u0434\u044A\u043B\u0436\u0438\u0442\u0435\u043B\u043D\u043E\u0441\u0442",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441",cidrv4:"IPv4 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",base64:"base64-\u043A\u043E\u0434\u0438\u0440\u0430\u043D \u043D\u0438\u0437",base64url:"base64url-\u043A\u043E\u0434\u0438\u0440\u0430\u043D \u043D\u0438\u0437",json_string:"JSON \u043D\u0438\u0437",e164:"E.164 \u043D\u043E\u043C\u0435\u0440",jwt:"JWT",template_literal:"\u0432\u0445\u043E\u0434"},i={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D instanceof ${r.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${a}`:`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${o}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${a}`}case"invalid_value":return r.values.length===1?`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${se(r.values[0])}`:`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430 \u043E\u043F\u0446\u0438\u044F: \u043E\u0447\u0430\u043A\u0432\u0430\u043D\u043E \u0435\u0434\u043D\u043E \u043E\u0442 ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u0422\u0432\u044A\u0440\u0434\u0435 \u0433\u043E\u043B\u044F\u043C\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${r.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${o}${r.maximum.toString()} ${s.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430"}`:`\u0422\u0432\u044A\u0440\u0434\u0435 \u0433\u043E\u043B\u044F\u043C\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${r.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0431\u044A\u0434\u0435 ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${r.origin} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${o}${r.minimum.toString()} ${s.unit}`:`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${r.origin} \u0434\u0430 \u0431\u044A\u0434\u0435 ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;if(o.format==="starts_with")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0437\u0430\u043F\u043E\u0447\u0432\u0430 \u0441 "${o.prefix}"`;if(o.format==="ends_with")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0437\u0430\u0432\u044A\u0440\u0448\u0432\u0430 \u0441 "${o.suffix}"`;if(o.format==="includes")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0432\u043A\u043B\u044E\u0447\u0432\u0430 "${o.includes}"`;if(o.format==="regex")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0441\u044A\u0432\u043F\u0430\u0434\u0430 \u0441 ${o.pattern}`;let s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D";return o.format==="emoji"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),o.format==="datetime"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),o.format==="date"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),o.format==="time"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),o.format==="duration"&&(s="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),`${s} ${n[o.format]??r.format}`}case"not_multiple_of":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E \u0447\u0438\u0441\u043B\u043E: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0431\u044A\u0434\u0435 \u043A\u0440\u0430\u0442\u043D\u043E \u043D\u0430 ${r.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0437\u043F\u043E\u0437\u043D\u0430\u0442${r.keys.length>1?"\u0438":""} \u043A\u043B\u044E\u0447${r.keys.length>1?"\u043E\u0432\u0435":""}: ${V(r.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043A\u043B\u044E\u0447 \u0432 ${r.origin}`;case"invalid_union":return"\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434";case"invalid_element":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430 \u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442 \u0432 ${r.origin}`;default:return"\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434"}}}});function yF(){return{localeError:gre()}}var gre,bF=v(()=>{Ae();gre=()=>{let e={string:{unit:"car\xE0cters",verb:"contenir"},file:{unit:"bytes",verb:"contenir"},array:{unit:"elements",verb:"contenir"},set:{unit:"elements",verb:"contenir"}};function t(r){return e[r]??null}let n={regex:"entrada",email:"adre\xE7a electr\xF2nica",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i hora ISO",date:"data ISO",time:"hora ISO",duration:"durada ISO",ipv4:"adre\xE7a IPv4",ipv6:"adre\xE7a IPv6",cidrv4:"rang IPv4",cidrv6:"rang IPv6",base64:"cadena codificada en base64",base64url:"cadena codificada en base64url",json_string:"cadena JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Tipus inv\xE0lid: s'esperava instanceof ${r.expected}, s'ha rebut ${a}`:`Tipus inv\xE0lid: s'esperava ${o}, s'ha rebut ${a}`}case"invalid_value":return r.values.length===1?`Valor inv\xE0lid: s'esperava ${se(r.values[0])}`:`Opci\xF3 inv\xE0lida: s'esperava una de ${V(r.values," o ")}`;case"too_big":{let o=r.inclusive?"com a m\xE0xim":"menys de",s=t(r.origin);return s?`Massa gran: s'esperava que ${r.origin??"el valor"} contingu\xE9s ${o} ${r.maximum.toString()} ${s.unit??"elements"}`:`Massa gran: s'esperava que ${r.origin??"el valor"} fos ${o} ${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?"com a m\xEDnim":"m\xE9s de",s=t(r.origin);return s?`Massa petit: s'esperava que ${r.origin} contingu\xE9s ${o} ${r.minimum.toString()} ${s.unit}`:`Massa petit: s'esperava que ${r.origin} fos ${o} ${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Format inv\xE0lid: ha de comen\xE7ar amb "${o.prefix}"`:o.format==="ends_with"?`Format inv\xE0lid: ha d'acabar amb "${o.suffix}"`:o.format==="includes"?`Format inv\xE0lid: ha d'incloure "${o.includes}"`:o.format==="regex"?`Format inv\xE0lid: ha de coincidir amb el patr\xF3 ${o.pattern}`:`Format inv\xE0lid per a ${n[o.format]??r.format}`}case"not_multiple_of":return`N\xFAmero inv\xE0lid: ha de ser m\xFAltiple de ${r.divisor}`;case"unrecognized_keys":return`Clau${r.keys.length>1?"s":""} no reconeguda${r.keys.length>1?"s":""}: ${V(r.keys,", ")}`;case"invalid_key":return`Clau inv\xE0lida a ${r.origin}`;case"invalid_union":return"Entrada inv\xE0lida";case"invalid_element":return`Element inv\xE0lid a ${r.origin}`;default:return"Entrada inv\xE0lida"}}}});function wF(){return{localeError:hre()}}var hre,vF=v(()=>{Ae();hre=()=>{let e={string:{unit:"znak\u016F",verb:"m\xEDt"},file:{unit:"bajt\u016F",verb:"m\xEDt"},array:{unit:"prvk\u016F",verb:"m\xEDt"},set:{unit:"prvk\u016F",verb:"m\xEDt"}};function t(r){return e[r]??null}let n={regex:"regul\xE1rn\xED v\xFDraz",email:"e-mailov\xE1 adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"datum a \u010Das ve form\xE1tu ISO",date:"datum ve form\xE1tu ISO",time:"\u010Das ve form\xE1tu ISO",duration:"doba trv\xE1n\xED ISO",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",cidrv4:"rozsah IPv4",cidrv6:"rozsah IPv6",base64:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64",base64url:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64url",json_string:"\u0159et\u011Bzec ve form\xE1tu JSON",e164:"\u010D\xEDslo E.164",jwt:"JWT",template_literal:"vstup"},i={nan:"NaN",number:"\u010D\xEDslo",string:"\u0159et\u011Bzec",function:"funkce",array:"pole"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no instanceof ${r.expected}, obdr\u017Eeno ${a}`:`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${o}, obdr\u017Eeno ${a}`}case"invalid_value":return r.values.length===1?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${se(r.values[0])}`:`Neplatn\xE1 mo\u017Enost: o\u010Dek\xE1v\xE1na jedna z hodnot ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${r.origin??"hodnota"} mus\xED m\xEDt ${o}${r.maximum.toString()} ${s.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${r.origin??"hodnota"} mus\xED b\xFDt ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${r.origin??"hodnota"} mus\xED m\xEDt ${o}${r.minimum.toString()} ${s.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${r.origin??"hodnota"} mus\xED b\xFDt ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED za\u010D\xEDnat na "${o.prefix}"`:o.format==="ends_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED kon\u010Dit na "${o.suffix}"`:o.format==="includes"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED obsahovat "${o.includes}"`:o.format==="regex"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED odpov\xEDdat vzoru ${o.pattern}`:`Neplatn\xFD form\xE1t ${n[o.format]??r.format}`}case"not_multiple_of":return`Neplatn\xE9 \u010D\xEDslo: mus\xED b\xFDt n\xE1sobkem ${r.divisor}`;case"unrecognized_keys":return`Nezn\xE1m\xE9 kl\xED\u010De: ${V(r.keys,", ")}`;case"invalid_key":return`Neplatn\xFD kl\xED\u010D v ${r.origin}`;case"invalid_union":return"Neplatn\xFD vstup";case"invalid_element":return`Neplatn\xE1 hodnota v ${r.origin}`;default:return"Neplatn\xFD vstup"}}}});function kF(){return{localeError:yre()}}var yre,xF=v(()=>{Ae();yre=()=>{let e={string:{unit:"tegn",verb:"havde"},file:{unit:"bytes",verb:"havde"},array:{unit:"elementer",verb:"indeholdt"},set:{unit:"elementer",verb:"indeholdt"}};function t(r){return e[r]??null}let n={regex:"input",email:"e-mailadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkesl\xE6t",date:"ISO-dato",time:"ISO-klokkesl\xE6t",duration:"ISO-varighed",ipv4:"IPv4-omr\xE5de",ipv6:"IPv6-omr\xE5de",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodet streng",base64url:"base64url-kodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"},i={nan:"NaN",string:"streng",number:"tal",boolean:"boolean",array:"liste",object:"objekt",set:"s\xE6t",file:"fil"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Ugyldigt input: forventede instanceof ${r.expected}, fik ${a}`:`Ugyldigt input: forventede ${o}, fik ${a}`}case"invalid_value":return r.values.length===1?`Ugyldig v\xE6rdi: forventede ${se(r.values[0])}`:`Ugyldigt valg: forventede en af f\xF8lgende ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin),a=i[r.origin]??r.origin;return s?`For stor: forventede ${a??"value"} ${s.verb} ${o} ${r.maximum.toString()} ${s.unit??"elementer"}`:`For stor: forventede ${a??"value"} havde ${o} ${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin),a=i[r.origin]??r.origin;return s?`For lille: forventede ${a} ${s.verb} ${o} ${r.minimum.toString()} ${s.unit}`:`For lille: forventede ${a} havde ${o} ${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Ugyldig streng: skal starte med "${o.prefix}"`:o.format==="ends_with"?`Ugyldig streng: skal ende med "${o.suffix}"`:o.format==="includes"?`Ugyldig streng: skal indeholde "${o.includes}"`:o.format==="regex"?`Ugyldig streng: skal matche m\xF8nsteret ${o.pattern}`:`Ugyldig ${n[o.format]??r.format}`}case"not_multiple_of":return`Ugyldigt tal: skal v\xE6re deleligt med ${r.divisor}`;case"unrecognized_keys":return`${r.keys.length>1?"Ukendte n\xF8gler":"Ukendt n\xF8gle"}: ${V(r.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8gle i ${r.origin}`;case"invalid_union":return"Ugyldigt input: matcher ingen af de tilladte typer";case"invalid_element":return`Ugyldig v\xE6rdi i ${r.origin}`;default:return"Ugyldigt input"}}}});function $F(){return{localeError:bre()}}var bre,RF=v(()=>{Ae();bre=()=>{let e={string:{unit:"Zeichen",verb:"zu haben"},file:{unit:"Bytes",verb:"zu haben"},array:{unit:"Elemente",verb:"zu haben"},set:{unit:"Elemente",verb:"zu haben"}};function t(r){return e[r]??null}let n={regex:"Eingabe",email:"E-Mail-Adresse",url:"URL",emoji:"Emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-Datum und -Uhrzeit",date:"ISO-Datum",time:"ISO-Uhrzeit",duration:"ISO-Dauer",ipv4:"IPv4-Adresse",ipv6:"IPv6-Adresse",cidrv4:"IPv4-Bereich",cidrv6:"IPv6-Bereich",base64:"Base64-codierter String",base64url:"Base64-URL-codierter String",json_string:"JSON-String",e164:"E.164-Nummer",jwt:"JWT",template_literal:"Eingabe"},i={nan:"NaN",number:"Zahl",array:"Array"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Ung\xFCltige Eingabe: erwartet instanceof ${r.expected}, erhalten ${a}`:`Ung\xFCltige Eingabe: erwartet ${o}, erhalten ${a}`}case"invalid_value":return r.values.length===1?`Ung\xFCltige Eingabe: erwartet ${se(r.values[0])}`:`Ung\xFCltige Option: erwartet eine von ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`Zu gro\xDF: erwartet, dass ${r.origin??"Wert"} ${o}${r.maximum.toString()} ${s.unit??"Elemente"} hat`:`Zu gro\xDF: erwartet, dass ${r.origin??"Wert"} ${o}${r.maximum.toString()} ist`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`Zu klein: erwartet, dass ${r.origin} ${o}${r.minimum.toString()} ${s.unit} hat`:`Zu klein: erwartet, dass ${r.origin} ${o}${r.minimum.toString()} ist`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Ung\xFCltiger String: muss mit "${o.prefix}" beginnen`:o.format==="ends_with"?`Ung\xFCltiger String: muss mit "${o.suffix}" enden`:o.format==="includes"?`Ung\xFCltiger String: muss "${o.includes}" enthalten`:o.format==="regex"?`Ung\xFCltiger String: muss dem Muster ${o.pattern} entsprechen`:`Ung\xFCltig: ${n[o.format]??r.format}`}case"not_multiple_of":return`Ung\xFCltige Zahl: muss ein Vielfaches von ${r.divisor} sein`;case"unrecognized_keys":return`${r.keys.length>1?"Unbekannte Schl\xFCssel":"Unbekannter Schl\xFCssel"}: ${V(r.keys,", ")}`;case"invalid_key":return`Ung\xFCltiger Schl\xFCssel in ${r.origin}`;case"invalid_union":return"Ung\xFCltige Eingabe";case"invalid_element":return`Ung\xFCltiger Wert in ${r.origin}`;default:return"Ung\xFCltige Eingabe"}}}});function Py(){return{localeError:wre()}}var wre,PE=v(()=>{Ae();wre=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(r){return e[r]??null}let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return`Invalid input: expected ${o}, received ${a}`}case"invalid_value":return r.values.length===1?`Invalid input: expected ${se(r.values[0])}`:`Invalid option: expected one of ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`Too big: expected ${r.origin??"value"} to have ${o}${r.maximum.toString()} ${s.unit??"elements"}`:`Too big: expected ${r.origin??"value"} to be ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`Too small: expected ${r.origin} to have ${o}${r.minimum.toString()} ${s.unit}`:`Too small: expected ${r.origin} to be ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Invalid string: must start with "${o.prefix}"`:o.format==="ends_with"?`Invalid string: must end with "${o.suffix}"`:o.format==="includes"?`Invalid string: must include "${o.includes}"`:o.format==="regex"?`Invalid string: must match pattern ${o.pattern}`:`Invalid ${n[o.format]??r.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${r.divisor}`;case"unrecognized_keys":return`Unrecognized key${r.keys.length>1?"s":""}: ${V(r.keys,", ")}`;case"invalid_key":return`Invalid key in ${r.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${r.origin}`;default:return"Invalid input"}}}});function SF(){return{localeError:vre()}}var vre,EF=v(()=>{Ae();vre=()=>{let e={string:{unit:"karaktrojn",verb:"havi"},file:{unit:"bajtojn",verb:"havi"},array:{unit:"elementojn",verb:"havi"},set:{unit:"elementojn",verb:"havi"}};function t(r){return e[r]??null}let n={regex:"enigo",email:"retadreso",url:"URL",emoji:"emo\u011Dio",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datotempo",date:"ISO-dato",time:"ISO-tempo",duration:"ISO-da\u016Dro",ipv4:"IPv4-adreso",ipv6:"IPv6-adreso",cidrv4:"IPv4-rango",cidrv6:"IPv6-rango",base64:"64-ume kodita karaktraro",base64url:"URL-64-ume kodita karaktraro",json_string:"JSON-karaktraro",e164:"E.164-nombro",jwt:"JWT",template_literal:"enigo"},i={nan:"NaN",number:"nombro",array:"tabelo",null:"senvalora"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Nevalida enigo: atendi\u011Dis instanceof ${r.expected}, ricevi\u011Dis ${a}`:`Nevalida enigo: atendi\u011Dis ${o}, ricevi\u011Dis ${a}`}case"invalid_value":return r.values.length===1?`Nevalida enigo: atendi\u011Dis ${se(r.values[0])}`:`Nevalida opcio: atendi\u011Dis unu el ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`Tro granda: atendi\u011Dis ke ${r.origin??"valoro"} havu ${o}${r.maximum.toString()} ${s.unit??"elementojn"}`:`Tro granda: atendi\u011Dis ke ${r.origin??"valoro"} havu ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`Tro malgranda: atendi\u011Dis ke ${r.origin} havu ${o}${r.minimum.toString()} ${s.unit}`:`Tro malgranda: atendi\u011Dis ke ${r.origin} estu ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Nevalida karaktraro: devas komenci\u011Di per "${o.prefix}"`:o.format==="ends_with"?`Nevalida karaktraro: devas fini\u011Di per "${o.suffix}"`:o.format==="includes"?`Nevalida karaktraro: devas inkluzivi "${o.includes}"`:o.format==="regex"?`Nevalida karaktraro: devas kongrui kun la modelo ${o.pattern}`:`Nevalida ${n[o.format]??r.format}`}case"not_multiple_of":return`Nevalida nombro: devas esti oblo de ${r.divisor}`;case"unrecognized_keys":return`Nekonata${r.keys.length>1?"j":""} \u015Dlosilo${r.keys.length>1?"j":""}: ${V(r.keys,", ")}`;case"invalid_key":return`Nevalida \u015Dlosilo en ${r.origin}`;case"invalid_union":return"Nevalida enigo";case"invalid_element":return`Nevalida valoro en ${r.origin}`;default:return"Nevalida enigo"}}}});function AF(){return{localeError:kre()}}var kre,PF=v(()=>{Ae();kre=()=>{let e={string:{unit:"caracteres",verb:"tener"},file:{unit:"bytes",verb:"tener"},array:{unit:"elementos",verb:"tener"},set:{unit:"elementos",verb:"tener"}};function t(r){return e[r]??null}let n={regex:"entrada",email:"direcci\xF3n de correo electr\xF3nico",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"fecha y hora ISO",date:"fecha ISO",time:"hora ISO",duration:"duraci\xF3n ISO",ipv4:"direcci\xF3n IPv4",ipv6:"direcci\xF3n IPv6",cidrv4:"rango IPv4",cidrv6:"rango IPv6",base64:"cadena codificada en base64",base64url:"URL codificada en base64",json_string:"cadena JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},i={nan:"NaN",string:"texto",number:"n\xFAmero",boolean:"booleano",array:"arreglo",object:"objeto",set:"conjunto",file:"archivo",date:"fecha",bigint:"n\xFAmero grande",symbol:"s\xEDmbolo",undefined:"indefinido",null:"nulo",function:"funci\xF3n",map:"mapa",record:"registro",tuple:"tupla",enum:"enumeraci\xF3n",union:"uni\xF3n",literal:"literal",promise:"promesa",void:"vac\xEDo",never:"nunca",unknown:"desconocido",any:"cualquiera"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Entrada inv\xE1lida: se esperaba instanceof ${r.expected}, recibido ${a}`:`Entrada inv\xE1lida: se esperaba ${o}, recibido ${a}`}case"invalid_value":return r.values.length===1?`Entrada inv\xE1lida: se esperaba ${se(r.values[0])}`:`Opci\xF3n inv\xE1lida: se esperaba una de ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin),a=i[r.origin]??r.origin;return s?`Demasiado grande: se esperaba que ${a??"valor"} tuviera ${o}${r.maximum.toString()} ${s.unit??"elementos"}`:`Demasiado grande: se esperaba que ${a??"valor"} fuera ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin),a=i[r.origin]??r.origin;return s?`Demasiado peque\xF1o: se esperaba que ${a} tuviera ${o}${r.minimum.toString()} ${s.unit}`:`Demasiado peque\xF1o: se esperaba que ${a} fuera ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Cadena inv\xE1lida: debe comenzar con "${o.prefix}"`:o.format==="ends_with"?`Cadena inv\xE1lida: debe terminar en "${o.suffix}"`:o.format==="includes"?`Cadena inv\xE1lida: debe incluir "${o.includes}"`:o.format==="regex"?`Cadena inv\xE1lida: debe coincidir con el patr\xF3n ${o.pattern}`:`Inv\xE1lido ${n[o.format]??r.format}`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: debe ser m\xFAltiplo de ${r.divisor}`;case"unrecognized_keys":return`Llave${r.keys.length>1?"s":""} desconocida${r.keys.length>1?"s":""}: ${V(r.keys,", ")}`;case"invalid_key":return`Llave inv\xE1lida en ${i[r.origin]??r.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido en ${i[r.origin]??r.origin}`;default:return"Entrada inv\xE1lida"}}}});function OF(){return{localeError:xre()}}var xre,CF=v(()=>{Ae();xre=()=>{let e={string:{unit:"\u06A9\u0627\u0631\u0627\u06A9\u062A\u0631",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},file:{unit:"\u0628\u0627\u06CC\u062A",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},array:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},set:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"}};function t(r){return e[r]??null}let n={regex:"\u0648\u0631\u0648\u062F\u06CC",email:"\u0622\u062F\u0631\u0633 \u0627\u06CC\u0645\u06CC\u0644",url:"URL",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u06CC\u062E \u0648 \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",date:"\u062A\u0627\u0631\u06CC\u062E \u0627\u06CC\u0632\u0648",time:"\u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",duration:"\u0645\u062F\u062A \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",ipv4:"IPv4 \u0622\u062F\u0631\u0633",ipv6:"IPv6 \u0622\u062F\u0631\u0633",cidrv4:"IPv4 \u062F\u0627\u0645\u0646\u0647",cidrv6:"IPv6 \u062F\u0627\u0645\u0646\u0647",base64:"base64-encoded \u0631\u0634\u062A\u0647",base64url:"base64url-encoded \u0631\u0634\u062A\u0647",json_string:"JSON \u0631\u0634\u062A\u0647",e164:"E.164 \u0639\u062F\u062F",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u06CC"},i={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0622\u0631\u0627\u06CC\u0647"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A instanceof ${r.expected} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${a} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`:`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${o} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${a} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`}case"invalid_value":return r.values.length===1?`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${se(r.values[0])} \u0645\u06CC\u200C\u0628\u0648\u062F`:`\u06AF\u0632\u06CC\u0646\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A \u06CC\u06A9\u06CC \u0627\u0632 ${V(r.values,"|")} \u0645\u06CC\u200C\u0628\u0648\u062F`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${r.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${o}${r.maximum.toString()} ${s.unit??"\u0639\u0646\u0635\u0631"} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${r.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${o}${r.maximum.toString()} \u0628\u0627\u0634\u062F`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${r.origin} \u0628\u0627\u06CC\u062F ${o}${r.minimum.toString()} ${s.unit} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${r.origin} \u0628\u0627\u06CC\u062F ${o}${r.minimum.toString()} \u0628\u0627\u0634\u062F`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${o.prefix}" \u0634\u0631\u0648\u0639 \u0634\u0648\u062F`:o.format==="ends_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${o.suffix}" \u062A\u0645\u0627\u0645 \u0634\u0648\u062F`:o.format==="includes"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0634\u0627\u0645\u0644 "${o.includes}" \u0628\u0627\u0634\u062F`:o.format==="regex"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC ${o.pattern} \u0645\u0637\u0627\u0628\u0642\u062A \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F`:`${n[o.format]??r.format} \u0646\u0627\u0645\u0639\u062A\u0628\u0631`}case"not_multiple_of":return`\u0639\u062F\u062F \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0645\u0636\u0631\u0628 ${r.divisor} \u0628\u0627\u0634\u062F`;case"unrecognized_keys":return`\u06A9\u0644\u06CC\u062F${r.keys.length>1?"\u0647\u0627\u06CC":""} \u0646\u0627\u0634\u0646\u0627\u0633: ${V(r.keys,", ")}`;case"invalid_key":return`\u06A9\u0644\u06CC\u062F \u0646\u0627\u0634\u0646\u0627\u0633 \u062F\u0631 ${r.origin}`;case"invalid_union":return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631";case"invalid_element":return`\u0645\u0642\u062F\u0627\u0631 \u0646\u0627\u0645\u0639\u062A\u0628\u0631 \u062F\u0631 ${r.origin}`;default:return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631"}}}});function _F(){return{localeError:$re()}}var $re,IF=v(()=>{Ae();$re=()=>{let e={string:{unit:"merkki\xE4",subject:"merkkijonon"},file:{unit:"tavua",subject:"tiedoston"},array:{unit:"alkiota",subject:"listan"},set:{unit:"alkiota",subject:"joukon"},number:{unit:"",subject:"luvun"},bigint:{unit:"",subject:"suuren kokonaisluvun"},int:{unit:"",subject:"kokonaisluvun"},date:{unit:"",subject:"p\xE4iv\xE4m\xE4\xE4r\xE4n"}};function t(r){return e[r]??null}let n={regex:"s\xE4\xE4nn\xF6llinen lauseke",email:"s\xE4hk\xF6postiosoite",url:"URL-osoite",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-aikaleima",date:"ISO-p\xE4iv\xE4m\xE4\xE4r\xE4",time:"ISO-aika",duration:"ISO-kesto",ipv4:"IPv4-osoite",ipv6:"IPv6-osoite",cidrv4:"IPv4-alue",cidrv6:"IPv6-alue",base64:"base64-koodattu merkkijono",base64url:"base64url-koodattu merkkijono",json_string:"JSON-merkkijono",e164:"E.164-luku",jwt:"JWT",template_literal:"templaattimerkkijono"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Virheellinen tyyppi: odotettiin instanceof ${r.expected}, oli ${a}`:`Virheellinen tyyppi: odotettiin ${o}, oli ${a}`}case"invalid_value":return r.values.length===1?`Virheellinen sy\xF6te: t\xE4ytyy olla ${se(r.values[0])}`:`Virheellinen valinta: t\xE4ytyy olla yksi seuraavista: ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`Liian suuri: ${s.subject} t\xE4ytyy olla ${o}${r.maximum.toString()} ${s.unit}`.trim():`Liian suuri: arvon t\xE4ytyy olla ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`Liian pieni: ${s.subject} t\xE4ytyy olla ${o}${r.minimum.toString()} ${s.unit}`.trim():`Liian pieni: arvon t\xE4ytyy olla ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Virheellinen sy\xF6te: t\xE4ytyy alkaa "${o.prefix}"`:o.format==="ends_with"?`Virheellinen sy\xF6te: t\xE4ytyy loppua "${o.suffix}"`:o.format==="includes"?`Virheellinen sy\xF6te: t\xE4ytyy sis\xE4lt\xE4\xE4 "${o.includes}"`:o.format==="regex"?`Virheellinen sy\xF6te: t\xE4ytyy vastata s\xE4\xE4nn\xF6llist\xE4 lauseketta ${o.pattern}`:`Virheellinen ${n[o.format]??r.format}`}case"not_multiple_of":return`Virheellinen luku: t\xE4ytyy olla luvun ${r.divisor} monikerta`;case"unrecognized_keys":return`${r.keys.length>1?"Tuntemattomat avaimet":"Tuntematon avain"}: ${V(r.keys,", ")}`;case"invalid_key":return"Virheellinen avain tietueessa";case"invalid_union":return"Virheellinen unioni";case"invalid_element":return"Virheellinen arvo joukossa";default:return"Virheellinen sy\xF6te"}}}});function TF(){return{localeError:Rre()}}var Rre,DF=v(()=>{Ae();Rre=()=>{let e={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function t(r){return e[r]??null}let n={regex:"entr\xE9e",email:"adresse e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date et heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne encod\xE9e en base64",base64url:"cha\xEEne encod\xE9e en base64url",json_string:"cha\xEEne JSON",e164:"num\xE9ro E.164",jwt:"JWT",template_literal:"entr\xE9e"},i={nan:"NaN",number:"nombre",array:"tableau"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Entr\xE9e invalide : instanceof ${r.expected} attendu, ${a} re\xE7u`:`Entr\xE9e invalide : ${o} attendu, ${a} re\xE7u`}case"invalid_value":return r.values.length===1?`Entr\xE9e invalide : ${se(r.values[0])} attendu`:`Option invalide : une valeur parmi ${V(r.values,"|")} attendue`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`Trop grand : ${r.origin??"valeur"} doit ${s.verb} ${o}${r.maximum.toString()} ${s.unit??"\xE9l\xE9ment(s)"}`:`Trop grand : ${r.origin??"valeur"} doit \xEAtre ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`Trop petit : ${r.origin} doit ${s.verb} ${o}${r.minimum.toString()} ${s.unit}`:`Trop petit : ${r.origin} doit \xEAtre ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Cha\xEEne invalide : doit commencer par "${o.prefix}"`:o.format==="ends_with"?`Cha\xEEne invalide : doit se terminer par "${o.suffix}"`:o.format==="includes"?`Cha\xEEne invalide : doit inclure "${o.includes}"`:o.format==="regex"?`Cha\xEEne invalide : doit correspondre au mod\xE8le ${o.pattern}`:`${n[o.format]??r.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${r.divisor}`;case"unrecognized_keys":return`Cl\xE9${r.keys.length>1?"s":""} non reconnue${r.keys.length>1?"s":""} : ${V(r.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${r.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${r.origin}`;default:return"Entr\xE9e invalide"}}}});function NF(){return{localeError:Sre()}}var Sre,jF=v(()=>{Ae();Sre=()=>{let e={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function t(r){return e[r]??null}let n={regex:"entr\xE9e",email:"adresse courriel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date-heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne encod\xE9e en base64",base64url:"cha\xEEne encod\xE9e en base64url",json_string:"cha\xEEne JSON",e164:"num\xE9ro E.164",jwt:"JWT",template_literal:"entr\xE9e"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Entr\xE9e invalide : attendu instanceof ${r.expected}, re\xE7u ${a}`:`Entr\xE9e invalide : attendu ${o}, re\xE7u ${a}`}case"invalid_value":return r.values.length===1?`Entr\xE9e invalide : attendu ${se(r.values[0])}`:`Option invalide : attendu l'une des valeurs suivantes ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"\u2264":"<",s=t(r.origin);return s?`Trop grand : attendu que ${r.origin??"la valeur"} ait ${o}${r.maximum.toString()} ${s.unit}`:`Trop grand : attendu que ${r.origin??"la valeur"} soit ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?"\u2265":">",s=t(r.origin);return s?`Trop petit : attendu que ${r.origin} ait ${o}${r.minimum.toString()} ${s.unit}`:`Trop petit : attendu que ${r.origin} soit ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Cha\xEEne invalide : doit commencer par "${o.prefix}"`:o.format==="ends_with"?`Cha\xEEne invalide : doit se terminer par "${o.suffix}"`:o.format==="includes"?`Cha\xEEne invalide : doit inclure "${o.includes}"`:o.format==="regex"?`Cha\xEEne invalide : doit correspondre au motif ${o.pattern}`:`${n[o.format]??r.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${r.divisor}`;case"unrecognized_keys":return`Cl\xE9${r.keys.length>1?"s":""} non reconnue${r.keys.length>1?"s":""} : ${V(r.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${r.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${r.origin}`;default:return"Entr\xE9e invalide"}}}});function LF(){return{localeError:Ere()}}var Ere,MF=v(()=>{Ae();Ere=()=>{let e={string:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA",gender:"f"},number:{label:"\u05DE\u05E1\u05E4\u05E8",gender:"m"},boolean:{label:"\u05E2\u05E8\u05DA \u05D1\u05D5\u05DC\u05D9\u05D0\u05E0\u05D9",gender:"m"},bigint:{label:"BigInt",gender:"m"},date:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA",gender:"m"},array:{label:"\u05DE\u05E2\u05E8\u05DA",gender:"m"},object:{label:"\u05D0\u05D5\u05D1\u05D9\u05D9\u05E7\u05D8",gender:"m"},null:{label:"\u05E2\u05E8\u05DA \u05E8\u05D9\u05E7 (null)",gender:"m"},undefined:{label:"\u05E2\u05E8\u05DA \u05DC\u05D0 \u05DE\u05D5\u05D2\u05D3\u05E8 (undefined)",gender:"m"},symbol:{label:"\u05E1\u05D9\u05DE\u05D1\u05D5\u05DC (Symbol)",gender:"m"},function:{label:"\u05E4\u05D5\u05E0\u05E7\u05E6\u05D9\u05D4",gender:"f"},map:{label:"\u05DE\u05E4\u05D4 (Map)",gender:"f"},set:{label:"\u05E7\u05D1\u05D5\u05E6\u05D4 (Set)",gender:"f"},file:{label:"\u05E7\u05D5\u05D1\u05E5",gender:"m"},promise:{label:"Promise",gender:"m"},NaN:{label:"NaN",gender:"m"},unknown:{label:"\u05E2\u05E8\u05DA \u05DC\u05D0 \u05D9\u05D3\u05D5\u05E2",gender:"m"},value:{label:"\u05E2\u05E8\u05DA",gender:"m"}},t={string:{unit:"\u05EA\u05D5\u05D5\u05D9\u05DD",shortLabel:"\u05E7\u05E6\u05E8",longLabel:"\u05D0\u05E8\u05D5\u05DA"},file:{unit:"\u05D1\u05D9\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},array:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},set:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},number:{unit:"",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"}},n=c=>c?e[c]:void 0,i=c=>{let u=n(c);return u?u.label:c??e.unknown.label},r=c=>`\u05D4${i(c)}`,o=c=>(n(c)?.gender??"m")==="f"?"\u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05D9\u05D5\u05EA":"\u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA",s=c=>c?t[c]??null:null,a={regex:{label:"\u05E7\u05DC\u05D8",gender:"m"},email:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05D0\u05D9\u05DE\u05D9\u05D9\u05DC",gender:"f"},url:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05E8\u05E9\u05EA",gender:"f"},emoji:{label:"\u05D0\u05D9\u05DE\u05D5\u05D2'\u05D9",gender:"m"},uuid:{label:"UUID",gender:"m"},nanoid:{label:"nanoid",gender:"m"},guid:{label:"GUID",gender:"m"},cuid:{label:"cuid",gender:"m"},cuid2:{label:"cuid2",gender:"m"},ulid:{label:"ULID",gender:"m"},xid:{label:"XID",gender:"m"},ksuid:{label:"KSUID",gender:"m"},datetime:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA \u05D5\u05D6\u05DE\u05DF ISO",gender:"m"},date:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA ISO",gender:"m"},time:{label:"\u05D6\u05DE\u05DF ISO",gender:"m"},duration:{label:"\u05DE\u05E9\u05DA \u05D6\u05DE\u05DF ISO",gender:"m"},ipv4:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv4",gender:"f"},ipv6:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv6",gender:"f"},cidrv4:{label:"\u05D8\u05D5\u05D5\u05D7 IPv4",gender:"m"},cidrv6:{label:"\u05D8\u05D5\u05D5\u05D7 IPv6",gender:"m"},base64:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64",gender:"f"},base64url:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64 \u05DC\u05DB\u05EA\u05D5\u05D1\u05D5\u05EA \u05E8\u05E9\u05EA",gender:"f"},json_string:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA JSON",gender:"f"},e164:{label:"\u05DE\u05E1\u05E4\u05E8 E.164",gender:"m"},jwt:{label:"JWT",gender:"m"},ends_with:{label:"\u05E7\u05DC\u05D8",gender:"m"},includes:{label:"\u05E7\u05DC\u05D8",gender:"m"},lowercase:{label:"\u05E7\u05DC\u05D8",gender:"m"},starts_with:{label:"\u05E7\u05DC\u05D8",gender:"m"},uppercase:{label:"\u05E7\u05DC\u05D8",gender:"m"}},l={nan:"NaN"};return c=>{switch(c.code){case"invalid_type":{let u=c.expected,d=l[u??""]??i(u),p=ce(c.input),f=l[p]??e[p]?.label??p;return/^[A-Z]/.test(c.expected)?`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA instanceof ${c.expected}, \u05D4\u05EA\u05E7\u05D1\u05DC ${f}`:`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${d}, \u05D4\u05EA\u05E7\u05D1\u05DC ${f}`}case"invalid_value":{if(c.values.length===1)return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05E2\u05E8\u05DA \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA ${se(c.values[0])}`;let u=c.values.map(f=>se(f));if(c.values.length===2)return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${u[0]} \u05D0\u05D5 ${u[1]}`;let d=u[u.length-1];return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${u.slice(0,-1).join(", ")} \u05D0\u05D5 ${d}`}case"too_big":{let u=s(c.origin),d=r(c.origin??"value");if(c.origin==="string")return`${u?.longLabel??"\u05D0\u05E8\u05D5\u05DA"} \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${c.maximum.toString()} ${u?.unit??""} ${c.inclusive?"\u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA":"\u05DC\u05DB\u05DC \u05D4\u05D9\u05D5\u05EA\u05E8"}`.trim();if(c.origin==="number"){let g=c.inclusive?`\u05E7\u05D8\u05DF \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${c.maximum}`:`\u05E7\u05D8\u05DF \u05DE-${c.maximum}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${g}`}if(c.origin==="array"||c.origin==="set"){let g=c.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA",h=c.inclusive?`${c.maximum} ${u?.unit??""} \u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA`:`\u05E4\u05D7\u05D5\u05EA \u05DE-${c.maximum} ${u?.unit??""}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${d} ${g} \u05DC\u05D4\u05DB\u05D9\u05DC ${h}`.trim()}let p=c.inclusive?"<=":"<",f=o(c.origin??"value");return u?.unit?`${u.longLabel} \u05DE\u05D3\u05D9: ${d} ${f} ${p}${c.maximum.toString()} ${u.unit}`:`${u?.longLabel??"\u05D2\u05D3\u05D5\u05DC"} \u05DE\u05D3\u05D9: ${d} ${f} ${p}${c.maximum.toString()}`}case"too_small":{let u=s(c.origin),d=r(c.origin??"value");if(c.origin==="string")return`${u?.shortLabel??"\u05E7\u05E6\u05E8"} \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${c.minimum.toString()} ${u?.unit??""} ${c.inclusive?"\u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8":"\u05DC\u05E4\u05D7\u05D5\u05EA"}`.trim();if(c.origin==="number"){let g=c.inclusive?`\u05D2\u05D3\u05D5\u05DC \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${c.minimum}`:`\u05D2\u05D3\u05D5\u05DC \u05DE-${c.minimum}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${d} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${g}`}if(c.origin==="array"||c.origin==="set"){let g=c.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA";if(c.minimum===1&&c.inclusive){let b=(c.origin==="set","\u05DC\u05E4\u05D7\u05D5\u05EA \u05E4\u05E8\u05D9\u05D8 \u05D0\u05D7\u05D3");return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${d} ${g} \u05DC\u05D4\u05DB\u05D9\u05DC ${b}`}let h=c.inclusive?`${c.minimum} ${u?.unit??""} \u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8`:`\u05D9\u05D5\u05EA\u05E8 \u05DE-${c.minimum} ${u?.unit??""}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${d} ${g} \u05DC\u05D4\u05DB\u05D9\u05DC ${h}`.trim()}let p=c.inclusive?">=":">",f=o(c.origin??"value");return u?.unit?`${u.shortLabel} \u05DE\u05D3\u05D9: ${d} ${f} ${p}${c.minimum.toString()} ${u.unit}`:`${u?.shortLabel??"\u05E7\u05D8\u05DF"} \u05DE\u05D3\u05D9: ${d} ${f} ${p}${c.minimum.toString()}`}case"invalid_format":{let u=c;if(u.format==="starts_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D7\u05D9\u05DC \u05D1 "${u.prefix}"`;if(u.format==="ends_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05E1\u05EA\u05D9\u05D9\u05DD \u05D1 "${u.suffix}"`;if(u.format==="includes")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05DB\u05DC\u05D5\u05DC "${u.includes}"`;if(u.format==="regex")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D0\u05D9\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA ${u.pattern}`;let d=a[u.format],p=d?.label??u.format,g=(d?.gender??"m")==="f"?"\u05EA\u05E7\u05D9\u05E0\u05D4":"\u05EA\u05E7\u05D9\u05DF";return`${p} \u05DC\u05D0 ${g}`}case"not_multiple_of":return`\u05DE\u05E1\u05E4\u05E8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05DE\u05DB\u05E4\u05DC\u05D4 \u05E9\u05DC ${c.divisor}`;case"unrecognized_keys":return`\u05DE\u05E4\u05EA\u05D7${c.keys.length>1?"\u05D5\u05EA":""} \u05DC\u05D0 \u05DE\u05D6\u05D5\u05D4${c.keys.length>1?"\u05D9\u05DD":"\u05D4"}: ${V(c.keys,", ")}`;case"invalid_key":return"\u05E9\u05D3\u05D4 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1\u05D0\u05D5\u05D1\u05D9\u05D9\u05E7\u05D8";case"invalid_union":return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF";case"invalid_element":return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1${r(c.origin??"array")}`;default:return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF"}}}});function FF(){return{localeError:Are()}}var Are,BF=v(()=>{Ae();Are=()=>{let e={string:{unit:"karakter",verb:"legyen"},file:{unit:"byte",verb:"legyen"},array:{unit:"elem",verb:"legyen"},set:{unit:"elem",verb:"legyen"}};function t(r){return e[r]??null}let n={regex:"bemenet",email:"email c\xEDm",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO id\u0151b\xE9lyeg",date:"ISO d\xE1tum",time:"ISO id\u0151",duration:"ISO id\u0151intervallum",ipv4:"IPv4 c\xEDm",ipv6:"IPv6 c\xEDm",cidrv4:"IPv4 tartom\xE1ny",cidrv6:"IPv6 tartom\xE1ny",base64:"base64-k\xF3dolt string",base64url:"base64url-k\xF3dolt string",json_string:"JSON string",e164:"E.164 sz\xE1m",jwt:"JWT",template_literal:"bemenet"},i={nan:"NaN",number:"sz\xE1m",array:"t\xF6mb"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k instanceof ${r.expected}, a kapott \xE9rt\xE9k ${a}`:`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${o}, a kapott \xE9rt\xE9k ${a}`}case"invalid_value":return r.values.length===1?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${se(r.values[0])}`:`\xC9rv\xE9nytelen opci\xF3: valamelyik \xE9rt\xE9k v\xE1rt ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`T\xFAl nagy: ${r.origin??"\xE9rt\xE9k"} m\xE9rete t\xFAl nagy ${o}${r.maximum.toString()} ${s.unit??"elem"}`:`T\xFAl nagy: a bemeneti \xE9rt\xE9k ${r.origin??"\xE9rt\xE9k"} t\xFAl nagy: ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${r.origin} m\xE9rete t\xFAl kicsi ${o}${r.minimum.toString()} ${s.unit}`:`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${r.origin} t\xFAl kicsi ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\xC9rv\xE9nytelen string: "${o.prefix}" \xE9rt\xE9kkel kell kezd\u0151dnie`:o.format==="ends_with"?`\xC9rv\xE9nytelen string: "${o.suffix}" \xE9rt\xE9kkel kell v\xE9gz\u0151dnie`:o.format==="includes"?`\xC9rv\xE9nytelen string: "${o.includes}" \xE9rt\xE9ket kell tartalmaznia`:o.format==="regex"?`\xC9rv\xE9nytelen string: ${o.pattern} mint\xE1nak kell megfelelnie`:`\xC9rv\xE9nytelen ${n[o.format]??r.format}`}case"not_multiple_of":return`\xC9rv\xE9nytelen sz\xE1m: ${r.divisor} t\xF6bbsz\xF6r\xF6s\xE9nek kell lennie`;case"unrecognized_keys":return`Ismeretlen kulcs${r.keys.length>1?"s":""}: ${V(r.keys,", ")}`;case"invalid_key":return`\xC9rv\xE9nytelen kulcs ${r.origin}`;case"invalid_union":return"\xC9rv\xE9nytelen bemenet";case"invalid_element":return`\xC9rv\xE9nytelen \xE9rt\xE9k: ${r.origin}`;default:return"\xC9rv\xE9nytelen bemenet"}}}});function GF(e,t,n){return Math.abs(e)===1?t:n}function Zl(e){if(!e)return"";let t=["\u0561","\u0565","\u0568","\u056B","\u0578","\u0578\u0582","\u0585"],n=e[e.length-1];return e+(t.includes(n)?"\u0576":"\u0568")}function WF(){return{localeError:Pre()}}var Pre,zF=v(()=>{Ae();Pre=()=>{let e={string:{unit:{one:"\u0576\u0577\u0561\u0576",many:"\u0576\u0577\u0561\u0576\u0576\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},file:{unit:{one:"\u0562\u0561\u0575\u0569",many:"\u0562\u0561\u0575\u0569\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},array:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},set:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"}};function t(r){return e[r]??null}let n={regex:"\u0574\u0578\u0582\u057F\u0584",email:"\u0567\u056C. \u0570\u0561\u057D\u0581\u0565",url:"URL",emoji:"\u0567\u0574\u0578\u057B\u056B",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0561\u0574\u057D\u0561\u0569\u056B\u057E \u0587 \u056A\u0561\u0574",date:"ISO \u0561\u0574\u057D\u0561\u0569\u056B\u057E",time:"ISO \u056A\u0561\u0574",duration:"ISO \u057F\u0587\u0578\u0572\u0578\u0582\u0569\u0575\u0578\u0582\u0576",ipv4:"IPv4 \u0570\u0561\u057D\u0581\u0565",ipv6:"IPv6 \u0570\u0561\u057D\u0581\u0565",cidrv4:"IPv4 \u0574\u056B\u057B\u0561\u056F\u0561\u0575\u0584",cidrv6:"IPv6 \u0574\u056B\u057B\u0561\u056F\u0561\u0575\u0584",base64:"base64 \u0571\u0587\u0561\u0579\u0561\u0583\u0578\u057E \u057F\u0578\u0572",base64url:"base64url \u0571\u0587\u0561\u0579\u0561\u0583\u0578\u057E \u057F\u0578\u0572",json_string:"JSON \u057F\u0578\u0572",e164:"E.164 \u0570\u0561\u0574\u0561\u0580",jwt:"JWT",template_literal:"\u0574\u0578\u0582\u057F\u0584"},i={nan:"NaN",number:"\u0569\u056B\u057E",array:"\u0566\u0561\u0576\u0563\u057E\u0561\u056E"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 instanceof ${r.expected}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${a}`:`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 ${o}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${a}`}case"invalid_value":return r.values.length===1?`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 ${se(r.values[1])}`:`\u054D\u056D\u0561\u056C \u057F\u0561\u0580\u0562\u0565\u0580\u0561\u056F\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 \u0570\u0565\u057F\u0587\u0575\u0561\u056C\u0576\u0565\u0580\u056B\u0581 \u0574\u0565\u056F\u0568\u055D ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);if(s){let a=Number(r.maximum),l=GF(a,s.unit.one,s.unit.many);return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0574\u0565\u056E \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${Zl(r.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${o}${r.maximum.toString()} ${l}`}return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0574\u0565\u056E \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${Zl(r.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056C\u056B\u0576\u056B ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);if(s){let a=Number(r.minimum),l=GF(a,s.unit.one,s.unit.many);return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0583\u0578\u0584\u0580 \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${Zl(r.origin)} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${o}${r.minimum.toString()} ${l}`}return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0583\u0578\u0584\u0580 \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${Zl(r.origin)} \u056C\u056B\u0576\u056B ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057D\u056F\u057D\u057E\u056B "${o.prefix}"-\u0578\u057E`:o.format==="ends_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0561\u057E\u0561\u0580\u057F\u057E\u056B "${o.suffix}"-\u0578\u057E`:o.format==="includes"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057A\u0561\u0580\u0578\u0582\u0576\u0561\u056F\u056B "${o.includes}"`:o.format==="regex"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0570\u0561\u0574\u0561\u057A\u0561\u057F\u0561\u057D\u056D\u0561\u0576\u056B ${o.pattern} \u0571\u0587\u0561\u0579\u0561\u0583\u056B\u0576`:`\u054D\u056D\u0561\u056C ${n[o.format]??r.format}`}case"not_multiple_of":return`\u054D\u056D\u0561\u056C \u0569\u056B\u057E\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0562\u0561\u0566\u0574\u0561\u057A\u0561\u057F\u056B\u056F \u056C\u056B\u0576\u056B ${r.divisor}-\u056B`;case"unrecognized_keys":return`\u0549\u0573\u0561\u0576\u0561\u0579\u057E\u0561\u056E \u0562\u0561\u0576\u0561\u056C\u056B${r.keys.length>1?"\u0576\u0565\u0580":""}. ${V(r.keys,", ")}`;case"invalid_key":return`\u054D\u056D\u0561\u056C \u0562\u0561\u0576\u0561\u056C\u056B ${Zl(r.origin)}-\u0578\u0582\u0574`;case"invalid_union":return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574";case"invalid_element":return`\u054D\u056D\u0561\u056C \u0561\u0580\u056A\u0565\u0584 ${Zl(r.origin)}-\u0578\u0582\u0574`;default:return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574"}}}});function UF(){return{localeError:Ore()}}var Ore,HF=v(()=>{Ae();Ore=()=>{let e={string:{unit:"karakter",verb:"memiliki"},file:{unit:"byte",verb:"memiliki"},array:{unit:"item",verb:"memiliki"},set:{unit:"item",verb:"memiliki"}};function t(r){return e[r]??null}let n={regex:"input",email:"alamat email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tanggal dan waktu format ISO",date:"tanggal format ISO",time:"jam format ISO",duration:"durasi format ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"rentang alamat IPv4",cidrv6:"rentang alamat IPv6",base64:"string dengan enkode base64",base64url:"string dengan enkode base64url",json_string:"string JSON",e164:"angka E.164",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Input tidak valid: diharapkan instanceof ${r.expected}, diterima ${a}`:`Input tidak valid: diharapkan ${o}, diterima ${a}`}case"invalid_value":return r.values.length===1?`Input tidak valid: diharapkan ${se(r.values[0])}`:`Pilihan tidak valid: diharapkan salah satu dari ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`Terlalu besar: diharapkan ${r.origin??"value"} memiliki ${o}${r.maximum.toString()} ${s.unit??"elemen"}`:`Terlalu besar: diharapkan ${r.origin??"value"} menjadi ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`Terlalu kecil: diharapkan ${r.origin} memiliki ${o}${r.minimum.toString()} ${s.unit}`:`Terlalu kecil: diharapkan ${r.origin} menjadi ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`String tidak valid: harus dimulai dengan "${o.prefix}"`:o.format==="ends_with"?`String tidak valid: harus berakhir dengan "${o.suffix}"`:o.format==="includes"?`String tidak valid: harus menyertakan "${o.includes}"`:o.format==="regex"?`String tidak valid: harus sesuai pola ${o.pattern}`:`${n[o.format]??r.format} tidak valid`}case"not_multiple_of":return`Angka tidak valid: harus kelipatan dari ${r.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali ${r.keys.length>1?"s":""}: ${V(r.keys,", ")}`;case"invalid_key":return`Kunci tidak valid di ${r.origin}`;case"invalid_union":return"Input tidak valid";case"invalid_element":return`Nilai tidak valid di ${r.origin}`;default:return"Input tidak valid"}}}});function VF(){return{localeError:Cre()}}var Cre,qF=v(()=>{Ae();Cre=()=>{let e={string:{unit:"stafi",verb:"a\xF0 hafa"},file:{unit:"b\xE6ti",verb:"a\xF0 hafa"},array:{unit:"hluti",verb:"a\xF0 hafa"},set:{unit:"hluti",verb:"a\xF0 hafa"}};function t(r){return e[r]??null}let n={regex:"gildi",email:"netfang",url:"vefsl\xF3\xF0",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dagsetning og t\xEDmi",date:"ISO dagsetning",time:"ISO t\xEDmi",duration:"ISO t\xEDmalengd",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded strengur",base64url:"base64url-encoded strengur",json_string:"JSON strengur",e164:"E.164 t\xF6lugildi",jwt:"JWT",template_literal:"gildi"},i={nan:"NaN",number:"n\xFAmer",array:"fylki"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Rangt gildi: \xDE\xFA sl\xF3st inn ${a} \xFEar sem \xE1 a\xF0 vera instanceof ${r.expected}`:`Rangt gildi: \xDE\xFA sl\xF3st inn ${a} \xFEar sem \xE1 a\xF0 vera ${o}`}case"invalid_value":return r.values.length===1?`Rangt gildi: gert r\xE1\xF0 fyrir ${se(r.values[0])}`:`\xD3gilt val: m\xE1 vera eitt af eftirfarandi ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${r.origin??"gildi"} hafi ${o}${r.maximum.toString()} ${s.unit??"hluti"}`:`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${r.origin??"gildi"} s\xE9 ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${r.origin} hafi ${o}${r.minimum.toString()} ${s.unit}`:`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${r.origin} s\xE9 ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 byrja \xE1 "${o.prefix}"`:o.format==="ends_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 enda \xE1 "${o.suffix}"`:o.format==="includes"?`\xD3gildur strengur: ver\xF0ur a\xF0 innihalda "${o.includes}"`:o.format==="regex"?`\xD3gildur strengur: ver\xF0ur a\xF0 fylgja mynstri ${o.pattern}`:`Rangt ${n[o.format]??r.format}`}case"not_multiple_of":return`R\xF6ng tala: ver\xF0ur a\xF0 vera margfeldi af ${r.divisor}`;case"unrecognized_keys":return`\xD3\xFEekkt ${r.keys.length>1?"ir lyklar":"ur lykill"}: ${V(r.keys,", ")}`;case"invalid_key":return`Rangur lykill \xED ${r.origin}`;case"invalid_union":return"Rangt gildi";case"invalid_element":return`Rangt gildi \xED ${r.origin}`;default:return"Rangt gildi"}}}});function KF(){return{localeError:_re()}}var _re,JF=v(()=>{Ae();_re=()=>{let e={string:{unit:"caratteri",verb:"avere"},file:{unit:"byte",verb:"avere"},array:{unit:"elementi",verb:"avere"},set:{unit:"elementi",verb:"avere"}};function t(r){return e[r]??null}let n={regex:"input",email:"indirizzo email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e ora ISO",date:"data ISO",time:"ora ISO",duration:"durata ISO",ipv4:"indirizzo IPv4",ipv6:"indirizzo IPv6",cidrv4:"intervallo IPv4",cidrv6:"intervallo IPv6",base64:"stringa codificata in base64",base64url:"URL codificata in base64",json_string:"stringa JSON",e164:"numero E.164",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"numero",array:"vettore"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Input non valido: atteso instanceof ${r.expected}, ricevuto ${a}`:`Input non valido: atteso ${o}, ricevuto ${a}`}case"invalid_value":return r.values.length===1?`Input non valido: atteso ${se(r.values[0])}`:`Opzione non valida: atteso uno tra ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`Troppo grande: ${r.origin??"valore"} deve avere ${o}${r.maximum.toString()} ${s.unit??"elementi"}`:`Troppo grande: ${r.origin??"valore"} deve essere ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`Troppo piccolo: ${r.origin} deve avere ${o}${r.minimum.toString()} ${s.unit}`:`Troppo piccolo: ${r.origin} deve essere ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Stringa non valida: deve iniziare con "${o.prefix}"`:o.format==="ends_with"?`Stringa non valida: deve terminare con "${o.suffix}"`:o.format==="includes"?`Stringa non valida: deve includere "${o.includes}"`:o.format==="regex"?`Stringa non valida: deve corrispondere al pattern ${o.pattern}`:`Invalid ${n[o.format]??r.format}`}case"not_multiple_of":return`Numero non valido: deve essere un multiplo di ${r.divisor}`;case"unrecognized_keys":return`Chiav${r.keys.length>1?"i":"e"} non riconosciut${r.keys.length>1?"e":"a"}: ${V(r.keys,", ")}`;case"invalid_key":return`Chiave non valida in ${r.origin}`;case"invalid_union":return"Input non valido";case"invalid_element":return`Valore non valido in ${r.origin}`;default:return"Input non valido"}}}});function ZF(){return{localeError:Ire()}}var Ire,YF=v(()=>{Ae();Ire=()=>{let e={string:{unit:"\u6587\u5B57",verb:"\u3067\u3042\u308B"},file:{unit:"\u30D0\u30A4\u30C8",verb:"\u3067\u3042\u308B"},array:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"},set:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"}};function t(r){return e[r]??null}let n={regex:"\u5165\u529B\u5024",email:"\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9",url:"URL",emoji:"\u7D75\u6587\u5B57",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u6642",date:"ISO\u65E5\u4ED8",time:"ISO\u6642\u523B",duration:"ISO\u671F\u9593",ipv4:"IPv4\u30A2\u30C9\u30EC\u30B9",ipv6:"IPv6\u30A2\u30C9\u30EC\u30B9",cidrv4:"IPv4\u7BC4\u56F2",cidrv6:"IPv6\u7BC4\u56F2",base64:"base64\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",base64url:"base64url\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",json_string:"JSON\u6587\u5B57\u5217",e164:"E.164\u756A\u53F7",jwt:"JWT",template_literal:"\u5165\u529B\u5024"},i={nan:"NaN",number:"\u6570\u5024",array:"\u914D\u5217"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u7121\u52B9\u306A\u5165\u529B: instanceof ${r.expected}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${a}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`:`\u7121\u52B9\u306A\u5165\u529B: ${o}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${a}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`}case"invalid_value":return r.values.length===1?`\u7121\u52B9\u306A\u5165\u529B: ${se(r.values[0])}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F`:`\u7121\u52B9\u306A\u9078\u629E: ${V(r.values,"\u3001")}\u306E\u3044\u305A\u308C\u304B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"too_big":{let o=r.inclusive?"\u4EE5\u4E0B\u3067\u3042\u308B":"\u3088\u308A\u5C0F\u3055\u3044",s=t(r.origin);return s?`\u5927\u304D\u3059\u304E\u308B\u5024: ${r.origin??"\u5024"}\u306F${r.maximum.toString()}${s.unit??"\u8981\u7D20"}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5927\u304D\u3059\u304E\u308B\u5024: ${r.origin??"\u5024"}\u306F${r.maximum.toString()}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"too_small":{let o=r.inclusive?"\u4EE5\u4E0A\u3067\u3042\u308B":"\u3088\u308A\u5927\u304D\u3044",s=t(r.origin);return s?`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${r.origin}\u306F${r.minimum.toString()}${s.unit}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${r.origin}\u306F${r.minimum.toString()}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${o.prefix}"\u3067\u59CB\u307E\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:o.format==="ends_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${o.suffix}"\u3067\u7D42\u308F\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:o.format==="includes"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${o.includes}"\u3092\u542B\u3080\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:o.format==="regex"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: \u30D1\u30BF\u30FC\u30F3${o.pattern}\u306B\u4E00\u81F4\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u7121\u52B9\u306A${n[o.format]??r.format}`}case"not_multiple_of":return`\u7121\u52B9\u306A\u6570\u5024: ${r.divisor}\u306E\u500D\u6570\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"unrecognized_keys":return`\u8A8D\u8B58\u3055\u308C\u3066\u3044\u306A\u3044\u30AD\u30FC${r.keys.length>1?"\u7FA4":""}: ${V(r.keys,"\u3001")}`;case"invalid_key":return`${r.origin}\u5185\u306E\u7121\u52B9\u306A\u30AD\u30FC`;case"invalid_union":return"\u7121\u52B9\u306A\u5165\u529B";case"invalid_element":return`${r.origin}\u5185\u306E\u7121\u52B9\u306A\u5024`;default:return"\u7121\u52B9\u306A\u5165\u529B"}}}});function XF(){return{localeError:Tre()}}var Tre,QF=v(()=>{Ae();Tre=()=>{let e={string:{unit:"\u10E1\u10D8\u10DB\u10D1\u10DD\u10DA\u10DD",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},file:{unit:"\u10D1\u10D0\u10D8\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},array:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},set:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"}};function t(r){return e[r]??null}let n={regex:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0",email:"\u10D4\u10DA-\u10E4\u10DD\u10E1\u10E2\u10D8\u10E1 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",url:"URL",emoji:"\u10D4\u10DB\u10DD\u10EF\u10D8",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u10D7\u10D0\u10E0\u10D8\u10E6\u10D8-\u10D3\u10E0\u10DD",date:"\u10D7\u10D0\u10E0\u10D8\u10E6\u10D8",time:"\u10D3\u10E0\u10DD",duration:"\u10EE\u10D0\u10DC\u10D2\u10E0\u10EB\u10DA\u10D8\u10D5\u10DD\u10D1\u10D0",ipv4:"IPv4 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",ipv6:"IPv6 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",cidrv4:"IPv4 \u10D3\u10D8\u10D0\u10DE\u10D0\u10D6\u10DD\u10DC\u10D8",cidrv6:"IPv6 \u10D3\u10D8\u10D0\u10DE\u10D0\u10D6\u10DD\u10DC\u10D8",base64:"base64-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8",base64url:"base64url-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8",json_string:"JSON \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8",e164:"E.164 \u10DC\u10DD\u10DB\u10D4\u10E0\u10D8",jwt:"JWT",template_literal:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"},i={nan:"NaN",number:"\u10E0\u10D8\u10EA\u10EE\u10D5\u10D8",string:"\u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8",boolean:"\u10D1\u10E3\u10DA\u10D4\u10D0\u10DC\u10D8",function:"\u10E4\u10E3\u10DC\u10E5\u10EA\u10D8\u10D0",array:"\u10DB\u10D0\u10E1\u10D8\u10D5\u10D8"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 instanceof ${r.expected}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${a}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${o}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${a}`}case"invalid_value":return r.values.length===1?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${se(r.values[0])}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D0\u10E0\u10D8\u10D0\u10DC\u10E2\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8\u10D0 \u10D4\u10E0\u10D7-\u10D4\u10E0\u10D7\u10D8 ${V(r.values,"|")}-\u10D3\u10D0\u10DC`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${r.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} ${s.verb} ${o}${r.maximum.toString()} ${s.unit}`:`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${r.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} \u10D8\u10E7\u10DD\u10E1 ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10DE\u10D0\u10E2\u10D0\u10E0\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${r.origin} ${s.verb} ${o}${r.minimum.toString()} ${s.unit}`:`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10DE\u10D0\u10E2\u10D0\u10E0\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${r.origin} \u10D8\u10E7\u10DD\u10E1 ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10D8\u10EC\u10E7\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${o.prefix}"-\u10D8\u10D7`:o.format==="ends_with"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10DB\u10D7\u10D0\u10D5\u10E0\u10D3\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${o.suffix}"-\u10D8\u10D7`:o.format==="includes"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1 "${o.includes}"-\u10E1`:o.format==="regex"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E1\u10E2\u10E0\u10D8\u10DC\u10D2\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D4\u10E1\u10D0\u10D1\u10D0\u10DB\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 \u10E8\u10D0\u10D1\u10DA\u10DD\u10DC\u10E1 ${o.pattern}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 ${n[o.format]??r.format}`}case"not_multiple_of":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E0\u10D8\u10EA\u10EE\u10D5\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10D8\u10E7\u10DD\u10E1 ${r.divisor}-\u10D8\u10E1 \u10EF\u10D4\u10E0\u10D0\u10D3\u10D8`;case"unrecognized_keys":return`\u10E3\u10EA\u10DC\u10DD\u10D1\u10D8 \u10D2\u10D0\u10E1\u10D0\u10E6\u10D4\u10D1${r.keys.length>1?"\u10D4\u10D1\u10D8":"\u10D8"}: ${V(r.keys,", ")}`;case"invalid_key":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D2\u10D0\u10E1\u10D0\u10E6\u10D4\u10D1\u10D8 ${r.origin}-\u10E8\u10D8`;case"invalid_union":return"\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0";case"invalid_element":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0 ${r.origin}-\u10E8\u10D8`;default:return"\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"}}}});function Oy(){return{localeError:Dre()}}var Dre,OE=v(()=>{Ae();Dre=()=>{let e={string:{unit:"\u178F\u17BD\u17A2\u1780\u17D2\u179F\u179A",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},file:{unit:"\u1794\u17C3",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},array:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},set:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"}};function t(r){return e[r]??null}let n={regex:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B",email:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793\u17A2\u17CA\u17B8\u1798\u17C2\u179B",url:"URL",emoji:"\u179F\u1789\u17D2\u1789\u17B6\u17A2\u17B6\u179A\u1798\u17D2\u1798\u178E\u17CD",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 \u1793\u17B7\u1784\u1798\u17C9\u17C4\u1784 ISO",date:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 ISO",time:"\u1798\u17C9\u17C4\u1784 ISO",duration:"\u179A\u1799\u17C8\u1796\u17C1\u179B ISO",ipv4:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",ipv6:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",cidrv4:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",cidrv6:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",base64:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64",base64url:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64url",json_string:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A JSON",e164:"\u179B\u17C1\u1781 E.164",jwt:"JWT",template_literal:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B"},i={nan:"NaN",number:"\u179B\u17C1\u1781",array:"\u17A2\u17B6\u179A\u17C1 (Array)",null:"\u1782\u17D2\u1798\u17B6\u1793\u178F\u1798\u17D2\u179B\u17C3 (null)"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A instanceof ${r.expected} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${a}`:`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${o} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${a}`}case"invalid_value":return r.values.length===1?`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${se(r.values[0])}`:`\u1787\u1798\u17D2\u179A\u17BE\u179F\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1787\u17B6\u1798\u17BD\u1799\u1780\u17D2\u1793\u17BB\u1784\u1785\u17C6\u178E\u17C4\u1798 ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${r.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${o} ${r.maximum.toString()} ${s.unit??"\u1792\u17B6\u178F\u17BB"}`:`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${r.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${o} ${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${r.origin} ${o} ${r.minimum.toString()} ${s.unit}`:`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${r.origin} ${o} ${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1785\u17B6\u1794\u17CB\u1795\u17D2\u178F\u17BE\u1798\u178A\u17C4\u1799 "${o.prefix}"`:o.format==="ends_with"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1794\u1789\u17D2\u1785\u1794\u17CB\u178A\u17C4\u1799 "${o.suffix}"`:o.format==="includes"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1798\u17B6\u1793 "${o.includes}"`:o.format==="regex"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1795\u17D2\u1782\u17BC\u1795\u17D2\u1782\u1784\u1793\u17B9\u1784\u1791\u1798\u17D2\u179A\u1784\u17CB\u178A\u17C2\u179B\u1794\u17B6\u1793\u1780\u17C6\u178E\u178F\u17CB ${o.pattern}`:`\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 ${n[o.format]??r.format}`}case"not_multiple_of":return`\u179B\u17C1\u1781\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1787\u17B6\u1796\u17A0\u17BB\u1782\u17BB\u178E\u1793\u17C3 ${r.divisor}`;case"unrecognized_keys":return`\u179A\u1780\u1783\u17BE\u1789\u179F\u17C4\u1798\u17B7\u1793\u179F\u17D2\u1782\u17B6\u179B\u17CB\u17D6 ${V(r.keys,", ")}`;case"invalid_key":return`\u179F\u17C4\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${r.origin}`;case"invalid_union":return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C";case"invalid_element":return`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${r.origin}`;default:return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C"}}}});function eB(){return Oy()}var tB=v(()=>{OE()});function nB(){return{localeError:Nre()}}var Nre,rB=v(()=>{Ae();Nre=()=>{let e={string:{unit:"\uBB38\uC790",verb:"to have"},file:{unit:"\uBC14\uC774\uD2B8",verb:"to have"},array:{unit:"\uAC1C",verb:"to have"},set:{unit:"\uAC1C",verb:"to have"}};function t(r){return e[r]??null}let n={regex:"\uC785\uB825",email:"\uC774\uBA54\uC77C \uC8FC\uC18C",url:"URL",emoji:"\uC774\uBAA8\uC9C0",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \uB0A0\uC9DC\uC2DC\uAC04",date:"ISO \uB0A0\uC9DC",time:"ISO \uC2DC\uAC04",duration:"ISO \uAE30\uAC04",ipv4:"IPv4 \uC8FC\uC18C",ipv6:"IPv6 \uC8FC\uC18C",cidrv4:"IPv4 \uBC94\uC704",cidrv6:"IPv6 \uBC94\uC704",base64:"base64 \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",base64url:"base64url \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",json_string:"JSON \uBB38\uC790\uC5F4",e164:"E.164 \uBC88\uD638",jwt:"JWT",template_literal:"\uC785\uB825"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 instanceof ${r.expected}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${a}\uC785\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 ${o}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${a}\uC785\uB2C8\uB2E4`}case"invalid_value":return r.values.length===1?`\uC798\uBABB\uB41C \uC785\uB825: \uAC12\uC740 ${se(r.values[0])} \uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC635\uC158: ${V(r.values,"\uB610\uB294 ")} \uC911 \uD558\uB098\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"too_big":{let o=r.inclusive?"\uC774\uD558":"\uBBF8\uB9CC",s=o==="\uBBF8\uB9CC"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",a=t(r.origin),l=a?.unit??"\uC694\uC18C";return a?`${r.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${r.maximum.toString()}${l} ${o}${s}`:`${r.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${r.maximum.toString()} ${o}${s}`}case"too_small":{let o=r.inclusive?"\uC774\uC0C1":"\uCD08\uACFC",s=o==="\uC774\uC0C1"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",a=t(r.origin),l=a?.unit??"\uC694\uC18C";return a?`${r.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${r.minimum.toString()}${l} ${o}${s}`:`${r.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${r.minimum.toString()} ${o}${s}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${o.prefix}"(\uC73C)\uB85C \uC2DC\uC791\uD574\uC57C \uD569\uB2C8\uB2E4`:o.format==="ends_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${o.suffix}"(\uC73C)\uB85C \uB05D\uB098\uC57C \uD569\uB2C8\uB2E4`:o.format==="includes"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${o.includes}"\uC744(\uB97C) \uD3EC\uD568\uD574\uC57C \uD569\uB2C8\uB2E4`:o.format==="regex"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: \uC815\uADDC\uC2DD ${o.pattern} \uD328\uD134\uACFC \uC77C\uCE58\uD574\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C ${n[o.format]??r.format}`}case"not_multiple_of":return`\uC798\uBABB\uB41C \uC22B\uC790: ${r.divisor}\uC758 \uBC30\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"unrecognized_keys":return`\uC778\uC2DD\uD560 \uC218 \uC5C6\uB294 \uD0A4: ${V(r.keys,", ")}`;case"invalid_key":return`\uC798\uBABB\uB41C \uD0A4: ${r.origin}`;case"invalid_union":return"\uC798\uBABB\uB41C \uC785\uB825";case"invalid_element":return`\uC798\uBABB\uB41C \uAC12: ${r.origin}`;default:return"\uC798\uBABB\uB41C \uC785\uB825"}}}});function iB(e){let t=Math.abs(e),n=t%10,i=t%100;return i>=11&&i<=19||n===0?"many":n===1?"one":"few"}function oB(){return{localeError:jre()}}var Xp,jre,sB=v(()=>{Ae();Xp=e=>e.charAt(0).toUpperCase()+e.slice(1);jre=()=>{let e={string:{unit:{one:"simbolis",few:"simboliai",many:"simboli\u0173"},verb:{smaller:{inclusive:"turi b\u016Bti ne ilgesn\u0117 kaip",notInclusive:"turi b\u016Bti trumpesn\u0117 kaip"},bigger:{inclusive:"turi b\u016Bti ne trumpesn\u0117 kaip",notInclusive:"turi b\u016Bti ilgesn\u0117 kaip"}}},file:{unit:{one:"baitas",few:"baitai",many:"bait\u0173"},verb:{smaller:{inclusive:"turi b\u016Bti ne didesnis kaip",notInclusive:"turi b\u016Bti ma\u017Eesnis kaip"},bigger:{inclusive:"turi b\u016Bti ne ma\u017Eesnis kaip",notInclusive:"turi b\u016Bti didesnis kaip"}}},array:{unit:{one:"element\u0105",few:"elementus",many:"element\u0173"},verb:{smaller:{inclusive:"turi tur\u0117ti ne daugiau kaip",notInclusive:"turi tur\u0117ti ma\u017Eiau kaip"},bigger:{inclusive:"turi tur\u0117ti ne ma\u017Eiau kaip",notInclusive:"turi tur\u0117ti daugiau kaip"}}},set:{unit:{one:"element\u0105",few:"elementus",many:"element\u0173"},verb:{smaller:{inclusive:"turi tur\u0117ti ne daugiau kaip",notInclusive:"turi tur\u0117ti ma\u017Eiau kaip"},bigger:{inclusive:"turi tur\u0117ti ne ma\u017Eiau kaip",notInclusive:"turi tur\u0117ti daugiau kaip"}}}};function t(r,o,s,a){let l=e[r]??null;return l===null?l:{unit:l.unit[o],verb:l.verb[a][s?"inclusive":"notInclusive"]}}let n={regex:"\u012Fvestis",email:"el. pa\u0161to adresas",url:"URL",emoji:"jaustukas",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO data ir laikas",date:"ISO data",time:"ISO laikas",duration:"ISO trukm\u0117",ipv4:"IPv4 adresas",ipv6:"IPv6 adresas",cidrv4:"IPv4 tinklo prefiksas (CIDR)",cidrv6:"IPv6 tinklo prefiksas (CIDR)",base64:"base64 u\u017Ekoduota eilut\u0117",base64url:"base64url u\u017Ekoduota eilut\u0117",json_string:"JSON eilut\u0117",e164:"E.164 numeris",jwt:"JWT",template_literal:"\u012Fvestis"},i={nan:"NaN",number:"skai\u010Dius",bigint:"sveikasis skai\u010Dius",string:"eilut\u0117",boolean:"login\u0117 reik\u0161m\u0117",undefined:"neapibr\u0117\u017Eta reik\u0161m\u0117",function:"funkcija",symbol:"simbolis",array:"masyvas",object:"objektas",null:"nulin\u0117 reik\u0161m\u0117"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Gautas tipas ${a}, o tik\u0117tasi - instanceof ${r.expected}`:`Gautas tipas ${a}, o tik\u0117tasi - ${o}`}case"invalid_value":return r.values.length===1?`Privalo b\u016Bti ${se(r.values[0])}`:`Privalo b\u016Bti vienas i\u0161 ${V(r.values,"|")} pasirinkim\u0173`;case"too_big":{let o=i[r.origin]??r.origin,s=t(r.origin,iB(Number(r.maximum)),r.inclusive??!1,"smaller");if(s?.verb)return`${Xp(o??r.origin??"reik\u0161m\u0117")} ${s.verb} ${r.maximum.toString()} ${s.unit??"element\u0173"}`;let a=r.inclusive?"ne didesnis kaip":"ma\u017Eesnis kaip";return`${Xp(o??r.origin??"reik\u0161m\u0117")} turi b\u016Bti ${a} ${r.maximum.toString()} ${s?.unit}`}case"too_small":{let o=i[r.origin]??r.origin,s=t(r.origin,iB(Number(r.minimum)),r.inclusive??!1,"bigger");if(s?.verb)return`${Xp(o??r.origin??"reik\u0161m\u0117")} ${s.verb} ${r.minimum.toString()} ${s.unit??"element\u0173"}`;let a=r.inclusive?"ne ma\u017Eesnis kaip":"didesnis kaip";return`${Xp(o??r.origin??"reik\u0161m\u0117")} turi b\u016Bti ${a} ${r.minimum.toString()} ${s?.unit}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Eilut\u0117 privalo prasid\u0117ti "${o.prefix}"`:o.format==="ends_with"?`Eilut\u0117 privalo pasibaigti "${o.suffix}"`:o.format==="includes"?`Eilut\u0117 privalo \u012Ftraukti "${o.includes}"`:o.format==="regex"?`Eilut\u0117 privalo atitikti ${o.pattern}`:`Neteisingas ${n[o.format]??r.format}`}case"not_multiple_of":return`Skai\u010Dius privalo b\u016Bti ${r.divisor} kartotinis.`;case"unrecognized_keys":return`Neatpa\u017Eint${r.keys.length>1?"i":"as"} rakt${r.keys.length>1?"ai":"as"}: ${V(r.keys,", ")}`;case"invalid_key":return"Rastas klaidingas raktas";case"invalid_union":return"Klaidinga \u012Fvestis";case"invalid_element":{let o=i[r.origin]??r.origin;return`${Xp(o??r.origin??"reik\u0161m\u0117")} turi klaiding\u0105 \u012Fvest\u012F`}default:return"Klaidinga \u012Fvestis"}}}});function aB(){return{localeError:Lre()}}var Lre,cB=v(()=>{Ae();Lre=()=>{let e={string:{unit:"\u0437\u043D\u0430\u0446\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},file:{unit:"\u0431\u0430\u0458\u0442\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},array:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},set:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"}};function t(r){return e[r]??null}let n={regex:"\u0432\u043D\u0435\u0441",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u043D\u0430 \u0435-\u043F\u043E\u0448\u0442\u0430",url:"URL",emoji:"\u0435\u043C\u043E\u045F\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0443\u043C \u0438 \u0432\u0440\u0435\u043C\u0435",date:"ISO \u0434\u0430\u0442\u0443\u043C",time:"ISO \u0432\u0440\u0435\u043C\u0435",duration:"ISO \u0432\u0440\u0435\u043C\u0435\u0442\u0440\u0430\u0435\u045A\u0435",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441\u0430",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441\u0430",cidrv4:"IPv4 \u043E\u043F\u0441\u0435\u0433",cidrv6:"IPv6 \u043E\u043F\u0441\u0435\u0433",base64:"base64-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",base64url:"base64url-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",json_string:"JSON \u043D\u0438\u0437\u0430",e164:"E.164 \u0431\u0440\u043E\u0458",jwt:"JWT",template_literal:"\u0432\u043D\u0435\u0441"},i={nan:"NaN",number:"\u0431\u0440\u043E\u0458",array:"\u043D\u0438\u0437\u0430"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 instanceof ${r.expected}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${a}`:`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${o}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${a}`}case"invalid_value":return r.values.length===1?`Invalid input: expected ${se(r.values[0])}`:`\u0413\u0440\u0435\u0448\u0430\u043D\u0430 \u043E\u043F\u0446\u0438\u0458\u0430: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 \u0435\u0434\u043D\u0430 ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${r.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0438\u043C\u0430 ${o}${r.maximum.toString()} ${s.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0438"}`:`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${r.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0431\u0438\u0434\u0435 ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${r.origin} \u0434\u0430 \u0438\u043C\u0430 ${o}${r.minimum.toString()} ${s.unit}`:`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${r.origin} \u0434\u0430 \u0431\u0438\u0434\u0435 ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u043F\u043E\u0447\u043D\u0443\u0432\u0430 \u0441\u043E "${o.prefix}"`:o.format==="ends_with"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u0432\u0440\u0448\u0443\u0432\u0430 \u0441\u043E "${o.suffix}"`:o.format==="includes"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0432\u043A\u043B\u0443\u0447\u0443\u0432\u0430 "${o.includes}"`:o.format==="regex"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u043E\u0434\u0433\u043E\u0430\u0440\u0430 \u043D\u0430 \u043F\u0430\u0442\u0435\u0440\u043D\u043E\u0442 ${o.pattern}`:`Invalid ${n[o.format]??r.format}`}case"not_multiple_of":return`\u0413\u0440\u0435\u0448\u0435\u043D \u0431\u0440\u043E\u0458: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0431\u0438\u0434\u0435 \u0434\u0435\u043B\u0438\u0432 \u0441\u043E ${r.divisor}`;case"unrecognized_keys":return`${r.keys.length>1?"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D\u0438 \u043A\u043B\u0443\u0447\u0435\u0432\u0438":"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D \u043A\u043B\u0443\u0447"}: ${V(r.keys,", ")}`;case"invalid_key":return`\u0413\u0440\u0435\u0448\u0435\u043D \u043A\u043B\u0443\u0447 \u0432\u043E ${r.origin}`;case"invalid_union":return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441";case"invalid_element":return`\u0413\u0440\u0435\u0448\u043D\u0430 \u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442 \u0432\u043E ${r.origin}`;default:return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441"}}}});function lB(){return{localeError:Mre()}}var Mre,uB=v(()=>{Ae();Mre=()=>{let e={string:{unit:"aksara",verb:"mempunyai"},file:{unit:"bait",verb:"mempunyai"},array:{unit:"elemen",verb:"mempunyai"},set:{unit:"elemen",verb:"mempunyai"}};function t(r){return e[r]??null}let n={regex:"input",email:"alamat e-mel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tarikh masa ISO",date:"tarikh ISO",time:"masa ISO",duration:"tempoh ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"julat IPv4",cidrv6:"julat IPv6",base64:"string dikodkan base64",base64url:"string dikodkan base64url",json_string:"string JSON",e164:"nombor E.164",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"nombor"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Input tidak sah: dijangka instanceof ${r.expected}, diterima ${a}`:`Input tidak sah: dijangka ${o}, diterima ${a}`}case"invalid_value":return r.values.length===1?`Input tidak sah: dijangka ${se(r.values[0])}`:`Pilihan tidak sah: dijangka salah satu daripada ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`Terlalu besar: dijangka ${r.origin??"nilai"} ${s.verb} ${o}${r.maximum.toString()} ${s.unit??"elemen"}`:`Terlalu besar: dijangka ${r.origin??"nilai"} adalah ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`Terlalu kecil: dijangka ${r.origin} ${s.verb} ${o}${r.minimum.toString()} ${s.unit}`:`Terlalu kecil: dijangka ${r.origin} adalah ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`String tidak sah: mesti bermula dengan "${o.prefix}"`:o.format==="ends_with"?`String tidak sah: mesti berakhir dengan "${o.suffix}"`:o.format==="includes"?`String tidak sah: mesti mengandungi "${o.includes}"`:o.format==="regex"?`String tidak sah: mesti sepadan dengan corak ${o.pattern}`:`${n[o.format]??r.format} tidak sah`}case"not_multiple_of":return`Nombor tidak sah: perlu gandaan ${r.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali: ${V(r.keys,", ")}`;case"invalid_key":return`Kunci tidak sah dalam ${r.origin}`;case"invalid_union":return"Input tidak sah";case"invalid_element":return`Nilai tidak sah dalam ${r.origin}`;default:return"Input tidak sah"}}}});function dB(){return{localeError:Fre()}}var Fre,pB=v(()=>{Ae();Fre=()=>{let e={string:{unit:"tekens",verb:"heeft"},file:{unit:"bytes",verb:"heeft"},array:{unit:"elementen",verb:"heeft"},set:{unit:"elementen",verb:"heeft"}};function t(r){return e[r]??null}let n={regex:"invoer",email:"emailadres",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum en tijd",date:"ISO datum",time:"ISO tijd",duration:"ISO duur",ipv4:"IPv4-adres",ipv6:"IPv6-adres",cidrv4:"IPv4-bereik",cidrv6:"IPv6-bereik",base64:"base64-gecodeerde tekst",base64url:"base64 URL-gecodeerde tekst",json_string:"JSON string",e164:"E.164-nummer",jwt:"JWT",template_literal:"invoer"},i={nan:"NaN",number:"getal"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Ongeldige invoer: verwacht instanceof ${r.expected}, ontving ${a}`:`Ongeldige invoer: verwacht ${o}, ontving ${a}`}case"invalid_value":return r.values.length===1?`Ongeldige invoer: verwacht ${se(r.values[0])}`:`Ongeldige optie: verwacht \xE9\xE9n van ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin),a=r.origin==="date"?"laat":r.origin==="string"?"lang":"groot";return s?`Te ${a}: verwacht dat ${r.origin??"waarde"} ${o}${r.maximum.toString()} ${s.unit??"elementen"} ${s.verb}`:`Te ${a}: verwacht dat ${r.origin??"waarde"} ${o}${r.maximum.toString()} is`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin),a=r.origin==="date"?"vroeg":r.origin==="string"?"kort":"klein";return s?`Te ${a}: verwacht dat ${r.origin} ${o}${r.minimum.toString()} ${s.unit} ${s.verb}`:`Te ${a}: verwacht dat ${r.origin} ${o}${r.minimum.toString()} is`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Ongeldige tekst: moet met "${o.prefix}" beginnen`:o.format==="ends_with"?`Ongeldige tekst: moet op "${o.suffix}" eindigen`:o.format==="includes"?`Ongeldige tekst: moet "${o.includes}" bevatten`:o.format==="regex"?`Ongeldige tekst: moet overeenkomen met patroon ${o.pattern}`:`Ongeldig: ${n[o.format]??r.format}`}case"not_multiple_of":return`Ongeldig getal: moet een veelvoud van ${r.divisor} zijn`;case"unrecognized_keys":return`Onbekende key${r.keys.length>1?"s":""}: ${V(r.keys,", ")}`;case"invalid_key":return`Ongeldige key in ${r.origin}`;case"invalid_union":return"Ongeldige invoer";case"invalid_element":return`Ongeldige waarde in ${r.origin}`;default:return"Ongeldige invoer"}}}});function fB(){return{localeError:Bre()}}var Bre,mB=v(()=>{Ae();Bre=()=>{let e={string:{unit:"tegn",verb:"\xE5 ha"},file:{unit:"bytes",verb:"\xE5 ha"},array:{unit:"elementer",verb:"\xE5 inneholde"},set:{unit:"elementer",verb:"\xE5 inneholde"}};function t(r){return e[r]??null}let n={regex:"input",email:"e-postadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkeslett",date:"ISO-dato",time:"ISO-klokkeslett",duration:"ISO-varighet",ipv4:"IPv4-omr\xE5de",ipv6:"IPv6-omr\xE5de",cidrv4:"IPv4-spekter",cidrv6:"IPv6-spekter",base64:"base64-enkodet streng",base64url:"base64url-enkodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"tall",array:"liste"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Ugyldig input: forventet instanceof ${r.expected}, fikk ${a}`:`Ugyldig input: forventet ${o}, fikk ${a}`}case"invalid_value":return r.values.length===1?`Ugyldig verdi: forventet ${se(r.values[0])}`:`Ugyldig valg: forventet en av ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`For stor(t): forventet ${r.origin??"value"} til \xE5 ha ${o}${r.maximum.toString()} ${s.unit??"elementer"}`:`For stor(t): forventet ${r.origin??"value"} til \xE5 ha ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`For lite(n): forventet ${r.origin} til \xE5 ha ${o}${r.minimum.toString()} ${s.unit}`:`For lite(n): forventet ${r.origin} til \xE5 ha ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Ugyldig streng: m\xE5 starte med "${o.prefix}"`:o.format==="ends_with"?`Ugyldig streng: m\xE5 ende med "${o.suffix}"`:o.format==="includes"?`Ugyldig streng: m\xE5 inneholde "${o.includes}"`:o.format==="regex"?`Ugyldig streng: m\xE5 matche m\xF8nsteret ${o.pattern}`:`Ugyldig ${n[o.format]??r.format}`}case"not_multiple_of":return`Ugyldig tall: m\xE5 v\xE6re et multiplum av ${r.divisor}`;case"unrecognized_keys":return`${r.keys.length>1?"Ukjente n\xF8kler":"Ukjent n\xF8kkel"}: ${V(r.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8kkel i ${r.origin}`;case"invalid_union":return"Ugyldig input";case"invalid_element":return`Ugyldig verdi i ${r.origin}`;default:return"Ugyldig input"}}}});function gB(){return{localeError:Gre()}}var Gre,hB=v(()=>{Ae();Gre=()=>{let e={string:{unit:"harf",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"unsur",verb:"olmal\u0131d\u0131r"},set:{unit:"unsur",verb:"olmal\u0131d\u0131r"}};function t(r){return e[r]??null}let n={regex:"giren",email:"epostag\xE2h",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO heng\xE2m\u0131",date:"ISO tarihi",time:"ISO zaman\u0131",duration:"ISO m\xFCddeti",ipv4:"IPv4 ni\u015F\xE2n\u0131",ipv6:"IPv6 ni\u015F\xE2n\u0131",cidrv4:"IPv4 menzili",cidrv6:"IPv6 menzili",base64:"base64-\u015Fifreli metin",base64url:"base64url-\u015Fifreli metin",json_string:"JSON metin",e164:"E.164 say\u0131s\u0131",jwt:"JWT",template_literal:"giren"},i={nan:"NaN",number:"numara",array:"saf",null:"gayb"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`F\xE2sit giren: umulan instanceof ${r.expected}, al\u0131nan ${a}`:`F\xE2sit giren: umulan ${o}, al\u0131nan ${a}`}case"invalid_value":return r.values.length===1?`F\xE2sit giren: umulan ${se(r.values[0])}`:`F\xE2sit tercih: m\xFBteberler ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`Fazla b\xFCy\xFCk: ${r.origin??"value"}, ${o}${r.maximum.toString()} ${s.unit??"elements"} sahip olmal\u0131yd\u0131.`:`Fazla b\xFCy\xFCk: ${r.origin??"value"}, ${o}${r.maximum.toString()} olmal\u0131yd\u0131.`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`Fazla k\xFC\xE7\xFCk: ${r.origin}, ${o}${r.minimum.toString()} ${s.unit} sahip olmal\u0131yd\u0131.`:`Fazla k\xFC\xE7\xFCk: ${r.origin}, ${o}${r.minimum.toString()} olmal\u0131yd\u0131.`}case"invalid_format":{let o=r;return o.format==="starts_with"?`F\xE2sit metin: "${o.prefix}" ile ba\u015Flamal\u0131.`:o.format==="ends_with"?`F\xE2sit metin: "${o.suffix}" ile bitmeli.`:o.format==="includes"?`F\xE2sit metin: "${o.includes}" ihtiv\xE2 etmeli.`:o.format==="regex"?`F\xE2sit metin: ${o.pattern} nak\u015F\u0131na uymal\u0131.`:`F\xE2sit ${n[o.format]??r.format}`}case"not_multiple_of":return`F\xE2sit say\u0131: ${r.divisor} kat\u0131 olmal\u0131yd\u0131.`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar ${r.keys.length>1?"s":""}: ${V(r.keys,", ")}`;case"invalid_key":return`${r.origin} i\xE7in tan\u0131nmayan anahtar var.`;case"invalid_union":return"Giren tan\u0131namad\u0131.";case"invalid_element":return`${r.origin} i\xE7in tan\u0131nmayan k\u0131ymet var.`;default:return"K\u0131ymet tan\u0131namad\u0131."}}}});function yB(){return{localeError:Wre()}}var Wre,bB=v(()=>{Ae();Wre=()=>{let e={string:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},file:{unit:"\u0628\u0627\u06CC\u067C\u0633",verb:"\u0648\u0644\u0631\u064A"},array:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},set:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"}};function t(r){return e[r]??null}let n={regex:"\u0648\u0631\u0648\u062F\u064A",email:"\u0628\u0631\u06CC\u069A\u0646\u0627\u0644\u06CC\u06A9",url:"\u06CC\u0648 \u0622\u0631 \u0627\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0646\u06CC\u067C\u0647 \u0627\u0648 \u0648\u062E\u062A",date:"\u0646\u06D0\u067C\u0647",time:"\u0648\u062E\u062A",duration:"\u0645\u0648\u062F\u0647",ipv4:"\u062F IPv4 \u067E\u062A\u0647",ipv6:"\u062F IPv6 \u067E\u062A\u0647",cidrv4:"\u062F IPv4 \u0633\u0627\u062D\u0647",cidrv6:"\u062F IPv6 \u0633\u0627\u062D\u0647",base64:"base64-encoded \u0645\u062A\u0646",base64url:"base64url-encoded \u0645\u062A\u0646",json_string:"JSON \u0645\u062A\u0646",e164:"\u062F E.164 \u0634\u0645\u06D0\u0631\u0647",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u064A"},i={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0627\u0631\u06D0"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F instanceof ${r.expected} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${a} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`:`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${o} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${a} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`}case"invalid_value":return r.values.length===1?`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${se(r.values[0])} \u0648\u0627\u06CC`:`\u0646\u0627\u0633\u0645 \u0627\u0646\u062A\u062E\u0627\u0628: \u0628\u0627\u06CC\u062F \u06CC\u0648 \u0644\u0647 ${V(r.values,"|")} \u0685\u062E\u0647 \u0648\u0627\u06CC`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${r.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${o}${r.maximum.toString()} ${s.unit??"\u0639\u0646\u0635\u0631\u0648\u0646\u0647"} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${r.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${o}${r.maximum.toString()} \u0648\u064A`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${r.origin} \u0628\u0627\u06CC\u062F ${o}${r.minimum.toString()} ${s.unit} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${r.origin} \u0628\u0627\u06CC\u062F ${o}${r.minimum.toString()} \u0648\u064A`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${o.prefix}" \u0633\u0631\u0647 \u067E\u06CC\u0644 \u0634\u064A`:o.format==="ends_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${o.suffix}" \u0633\u0631\u0647 \u067E\u0627\u06CC \u062A\u0647 \u0648\u0631\u0633\u064A\u0696\u064A`:o.format==="includes"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F "${o.includes}" \u0648\u0644\u0631\u064A`:o.format==="regex"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F ${o.pattern} \u0633\u0631\u0647 \u0645\u0637\u0627\u0628\u0642\u062A \u0648\u0644\u0631\u064A`:`${n[o.format]??r.format} \u0646\u0627\u0633\u0645 \u062F\u06CC`}case"not_multiple_of":return`\u0646\u0627\u0633\u0645 \u0639\u062F\u062F: \u0628\u0627\u06CC\u062F \u062F ${r.divisor} \u0645\u0636\u0631\u0628 \u0648\u064A`;case"unrecognized_keys":return`\u0646\u0627\u0633\u0645 ${r.keys.length>1?"\u06A9\u0644\u06CC\u0689\u0648\u0646\u0647":"\u06A9\u0644\u06CC\u0689"}: ${V(r.keys,", ")}`;case"invalid_key":return`\u0646\u0627\u0633\u0645 \u06A9\u0644\u06CC\u0689 \u067E\u0647 ${r.origin} \u06A9\u06D0`;case"invalid_union":return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A";case"invalid_element":return`\u0646\u0627\u0633\u0645 \u0639\u0646\u0635\u0631 \u067E\u0647 ${r.origin} \u06A9\u06D0`;default:return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A"}}}});function wB(){return{localeError:zre()}}var zre,vB=v(()=>{Ae();zre=()=>{let e={string:{unit:"znak\xF3w",verb:"mie\u0107"},file:{unit:"bajt\xF3w",verb:"mie\u0107"},array:{unit:"element\xF3w",verb:"mie\u0107"},set:{unit:"element\xF3w",verb:"mie\u0107"}};function t(r){return e[r]??null}let n={regex:"wyra\u017Cenie",email:"adres email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i godzina w formacie ISO",date:"data w formacie ISO",time:"godzina w formacie ISO",duration:"czas trwania ISO",ipv4:"adres IPv4",ipv6:"adres IPv6",cidrv4:"zakres IPv4",cidrv6:"zakres IPv6",base64:"ci\u0105g znak\xF3w zakodowany w formacie base64",base64url:"ci\u0105g znak\xF3w zakodowany w formacie base64url",json_string:"ci\u0105g znak\xF3w w formacie JSON",e164:"liczba E.164",jwt:"JWT",template_literal:"wej\u015Bcie"},i={nan:"NaN",number:"liczba",array:"tablica"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano instanceof ${r.expected}, otrzymano ${a}`:`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${o}, otrzymano ${a}`}case"invalid_value":return r.values.length===1?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${se(r.values[0])}`:`Nieprawid\u0142owa opcja: oczekiwano jednej z warto\u015Bci ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`Za du\u017Ca warto\u015B\u0107: oczekiwano, \u017Ce ${r.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${o}${r.maximum.toString()} ${s.unit??"element\xF3w"}`:`Zbyt du\u017C(y/a/e): oczekiwano, \u017Ce ${r.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`Za ma\u0142a warto\u015B\u0107: oczekiwano, \u017Ce ${r.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${o}${r.minimum.toString()} ${s.unit??"element\xF3w"}`:`Zbyt ma\u0142(y/a/e): oczekiwano, \u017Ce ${r.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zaczyna\u0107 si\u0119 od "${o.prefix}"`:o.format==="ends_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi ko\u0144czy\u0107 si\u0119 na "${o.suffix}"`:o.format==="includes"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zawiera\u0107 "${o.includes}"`:o.format==="regex"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi odpowiada\u0107 wzorcowi ${o.pattern}`:`Nieprawid\u0142ow(y/a/e) ${n[o.format]??r.format}`}case"not_multiple_of":return`Nieprawid\u0142owa liczba: musi by\u0107 wielokrotno\u015Bci\u0105 ${r.divisor}`;case"unrecognized_keys":return`Nierozpoznane klucze${r.keys.length>1?"s":""}: ${V(r.keys,", ")}`;case"invalid_key":return`Nieprawid\u0142owy klucz w ${r.origin}`;case"invalid_union":return"Nieprawid\u0142owe dane wej\u015Bciowe";case"invalid_element":return`Nieprawid\u0142owa warto\u015B\u0107 w ${r.origin}`;default:return"Nieprawid\u0142owe dane wej\u015Bciowe"}}}});function kB(){return{localeError:Ure()}}var Ure,xB=v(()=>{Ae();Ure=()=>{let e={string:{unit:"caracteres",verb:"ter"},file:{unit:"bytes",verb:"ter"},array:{unit:"itens",verb:"ter"},set:{unit:"itens",verb:"ter"}};function t(r){return e[r]??null}let n={regex:"padr\xE3o",email:"endere\xE7o de e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e hora ISO",date:"data ISO",time:"hora ISO",duration:"dura\xE7\xE3o ISO",ipv4:"endere\xE7o IPv4",ipv6:"endere\xE7o IPv6",cidrv4:"faixa de IPv4",cidrv6:"faixa de IPv6",base64:"texto codificado em base64",base64url:"URL codificada em base64",json_string:"texto JSON",e164:"n\xFAmero E.164",jwt:"JWT",template_literal:"entrada"},i={nan:"NaN",number:"n\xFAmero",null:"nulo"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Tipo inv\xE1lido: esperado instanceof ${r.expected}, recebido ${a}`:`Tipo inv\xE1lido: esperado ${o}, recebido ${a}`}case"invalid_value":return r.values.length===1?`Entrada inv\xE1lida: esperado ${se(r.values[0])}`:`Op\xE7\xE3o inv\xE1lida: esperada uma das ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`Muito grande: esperado que ${r.origin??"valor"} tivesse ${o}${r.maximum.toString()} ${s.unit??"elementos"}`:`Muito grande: esperado que ${r.origin??"valor"} fosse ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`Muito pequeno: esperado que ${r.origin} tivesse ${o}${r.minimum.toString()} ${s.unit}`:`Muito pequeno: esperado que ${r.origin} fosse ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Texto inv\xE1lido: deve come\xE7ar com "${o.prefix}"`:o.format==="ends_with"?`Texto inv\xE1lido: deve terminar com "${o.suffix}"`:o.format==="includes"?`Texto inv\xE1lido: deve incluir "${o.includes}"`:o.format==="regex"?`Texto inv\xE1lido: deve corresponder ao padr\xE3o ${o.pattern}`:`${n[o.format]??r.format} inv\xE1lido`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${r.divisor}`;case"unrecognized_keys":return`Chave${r.keys.length>1?"s":""} desconhecida${r.keys.length>1?"s":""}: ${V(r.keys,", ")}`;case"invalid_key":return`Chave inv\xE1lida em ${r.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido em ${r.origin}`;default:return"Campo inv\xE1lido"}}}});function $B(e,t,n,i){let r=Math.abs(e),o=r%10,s=r%100;return s>=11&&s<=19?i:o===1?t:o>=2&&o<=4?n:i}function RB(){return{localeError:Hre()}}var Hre,SB=v(()=>{Ae();Hre=()=>{let e={string:{unit:{one:"\u0441\u0438\u043C\u0432\u043E\u043B",few:"\u0441\u0438\u043C\u0432\u043E\u043B\u0430",many:"\u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u0430",many:"\u0431\u0430\u0439\u0442"},verb:"\u0438\u043C\u0435\u0442\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"}};function t(r){return e[r]??null}let n={regex:"\u0432\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0435\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0438 \u0432\u0440\u0435\u043C\u044F",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0432\u0440\u0435\u043C\u044F",duration:"ISO \u0434\u043B\u0438\u0442\u0435\u043B\u044C\u043D\u043E\u0441\u0442\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441",cidrv4:"IPv4 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",base64:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64",base64url:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64url",json_string:"JSON \u0441\u0442\u0440\u043E\u043A\u0430",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",jwt:"JWT",template_literal:"\u0432\u0432\u043E\u0434"},i={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0441\u0438\u0432"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C instanceof ${r.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${a}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${o}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${a}`}case"invalid_value":return r.values.length===1?`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${se(r.values[0])}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0430\u0440\u0438\u0430\u043D\u0442: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C \u043E\u0434\u043D\u043E \u0438\u0437 ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);if(s){let a=Number(r.maximum),l=$B(a,s.unit.one,s.unit.few,s.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${r.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${o}${r.maximum.toString()} ${l}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${r.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);if(s){let a=Number(r.minimum),l=$B(a,s.unit.one,s.unit.few,s.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${r.origin} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${o}${r.minimum.toString()} ${l}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${r.origin} \u0431\u0443\u0434\u0435\u0442 ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u043D\u0430\u0447\u0438\u043D\u0430\u0442\u044C\u0441\u044F \u0441 "${o.prefix}"`:o.format==="ends_with"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0437\u0430\u043A\u0430\u043D\u0447\u0438\u0432\u0430\u0442\u044C\u0441\u044F \u043D\u0430 "${o.suffix}"`:o.format==="includes"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u0434\u0435\u0440\u0436\u0430\u0442\u044C "${o.includes}"`:o.format==="regex"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043E\u0432\u0430\u0442\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${o.pattern}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 ${n[o.format]??r.format}`}case"not_multiple_of":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0447\u0438\u0441\u043B\u043E: \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${r.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u043E\u0437\u043D\u0430\u043D\u043D${r.keys.length>1?"\u044B\u0435":"\u044B\u0439"} \u043A\u043B\u044E\u0447${r.keys.length>1?"\u0438":""}: ${V(r.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u043A\u043B\u044E\u0447 \u0432 ${r.origin}`;case"invalid_union":return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435";case"invalid_element":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0432 ${r.origin}`;default:return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435"}}}});function EB(){return{localeError:Vre()}}var Vre,AB=v(()=>{Ae();Vre=()=>{let e={string:{unit:"znakov",verb:"imeti"},file:{unit:"bajtov",verb:"imeti"},array:{unit:"elementov",verb:"imeti"},set:{unit:"elementov",verb:"imeti"}};function t(r){return e[r]??null}let n={regex:"vnos",email:"e-po\u0161tni naslov",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum in \u010Das",date:"ISO datum",time:"ISO \u010Das",duration:"ISO trajanje",ipv4:"IPv4 naslov",ipv6:"IPv6 naslov",cidrv4:"obseg IPv4",cidrv6:"obseg IPv6",base64:"base64 kodiran niz",base64url:"base64url kodiran niz",json_string:"JSON niz",e164:"E.164 \u0161tevilka",jwt:"JWT",template_literal:"vnos"},i={nan:"NaN",number:"\u0161tevilo",array:"tabela"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Neveljaven vnos: pri\u010Dakovano instanceof ${r.expected}, prejeto ${a}`:`Neveljaven vnos: pri\u010Dakovano ${o}, prejeto ${a}`}case"invalid_value":return r.values.length===1?`Neveljaven vnos: pri\u010Dakovano ${se(r.values[0])}`:`Neveljavna mo\u017Enost: pri\u010Dakovano eno izmed ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`Preveliko: pri\u010Dakovano, da bo ${r.origin??"vrednost"} imelo ${o}${r.maximum.toString()} ${s.unit??"elementov"}`:`Preveliko: pri\u010Dakovano, da bo ${r.origin??"vrednost"} ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`Premajhno: pri\u010Dakovano, da bo ${r.origin} imelo ${o}${r.minimum.toString()} ${s.unit}`:`Premajhno: pri\u010Dakovano, da bo ${r.origin} ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Neveljaven niz: mora se za\u010Deti z "${o.prefix}"`:o.format==="ends_with"?`Neveljaven niz: mora se kon\u010Dati z "${o.suffix}"`:o.format==="includes"?`Neveljaven niz: mora vsebovati "${o.includes}"`:o.format==="regex"?`Neveljaven niz: mora ustrezati vzorcu ${o.pattern}`:`Neveljaven ${n[o.format]??r.format}`}case"not_multiple_of":return`Neveljavno \u0161tevilo: mora biti ve\u010Dkratnik ${r.divisor}`;case"unrecognized_keys":return`Neprepoznan${r.keys.length>1?"i klju\u010Di":" klju\u010D"}: ${V(r.keys,", ")}`;case"invalid_key":return`Neveljaven klju\u010D v ${r.origin}`;case"invalid_union":return"Neveljaven vnos";case"invalid_element":return`Neveljavna vrednost v ${r.origin}`;default:return"Neveljaven vnos"}}}});function PB(){return{localeError:qre()}}var qre,OB=v(()=>{Ae();qre=()=>{let e={string:{unit:"tecken",verb:"att ha"},file:{unit:"bytes",verb:"att ha"},array:{unit:"objekt",verb:"att inneh\xE5lla"},set:{unit:"objekt",verb:"att inneh\xE5lla"}};function t(r){return e[r]??null}let n={regex:"regulj\xE4rt uttryck",email:"e-postadress",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datum och tid",date:"ISO-datum",time:"ISO-tid",duration:"ISO-varaktighet",ipv4:"IPv4-intervall",ipv6:"IPv6-intervall",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodad str\xE4ng",base64url:"base64url-kodad str\xE4ng",json_string:"JSON-str\xE4ng",e164:"E.164-nummer",jwt:"JWT",template_literal:"mall-literal"},i={nan:"NaN",number:"antal",array:"lista"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Ogiltig inmatning: f\xF6rv\xE4ntat instanceof ${r.expected}, fick ${a}`:`Ogiltig inmatning: f\xF6rv\xE4ntat ${o}, fick ${a}`}case"invalid_value":return r.values.length===1?`Ogiltig inmatning: f\xF6rv\xE4ntat ${se(r.values[0])}`:`Ogiltigt val: f\xF6rv\xE4ntade en av ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`F\xF6r stor(t): f\xF6rv\xE4ntade ${r.origin??"v\xE4rdet"} att ha ${o}${r.maximum.toString()} ${s.unit??"element"}`:`F\xF6r stor(t): f\xF6rv\xE4ntat ${r.origin??"v\xE4rdet"} att ha ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`F\xF6r lite(t): f\xF6rv\xE4ntade ${r.origin??"v\xE4rdet"} att ha ${o}${r.minimum.toString()} ${s.unit}`:`F\xF6r lite(t): f\xF6rv\xE4ntade ${r.origin??"v\xE4rdet"} att ha ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Ogiltig str\xE4ng: m\xE5ste b\xF6rja med "${o.prefix}"`:o.format==="ends_with"?`Ogiltig str\xE4ng: m\xE5ste sluta med "${o.suffix}"`:o.format==="includes"?`Ogiltig str\xE4ng: m\xE5ste inneh\xE5lla "${o.includes}"`:o.format==="regex"?`Ogiltig str\xE4ng: m\xE5ste matcha m\xF6nstret "${o.pattern}"`:`Ogiltig(t) ${n[o.format]??r.format}`}case"not_multiple_of":return`Ogiltigt tal: m\xE5ste vara en multipel av ${r.divisor}`;case"unrecognized_keys":return`${r.keys.length>1?"Ok\xE4nda nycklar":"Ok\xE4nd nyckel"}: ${V(r.keys,", ")}`;case"invalid_key":return`Ogiltig nyckel i ${r.origin??"v\xE4rdet"}`;case"invalid_union":return"Ogiltig input";case"invalid_element":return`Ogiltigt v\xE4rde i ${r.origin??"v\xE4rdet"}`;default:return"Ogiltig input"}}}});function CB(){return{localeError:Kre()}}var Kre,_B=v(()=>{Ae();Kre=()=>{let e={string:{unit:"\u0B8E\u0BB4\u0BC1\u0BA4\u0BCD\u0BA4\u0BC1\u0B95\u0BCD\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},file:{unit:"\u0BAA\u0BC8\u0B9F\u0BCD\u0B9F\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},array:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},set:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"}};function t(r){return e[r]??null}let n={regex:"\u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1",email:"\u0BAE\u0BBF\u0BA9\u0BCD\u0BA9\u0B9E\u0BCD\u0B9A\u0BB2\u0BCD \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0BA4\u0BC7\u0BA4\u0BBF \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",date:"ISO \u0BA4\u0BC7\u0BA4\u0BBF",time:"ISO \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",duration:"ISO \u0B95\u0BBE\u0BB2 \u0B85\u0BB3\u0BB5\u0BC1",ipv4:"IPv4 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",ipv6:"IPv6 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",cidrv4:"IPv4 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",cidrv6:"IPv6 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",base64:"base64-encoded \u0B9A\u0BB0\u0BAE\u0BCD",base64url:"base64url-encoded \u0B9A\u0BB0\u0BAE\u0BCD",json_string:"JSON \u0B9A\u0BB0\u0BAE\u0BCD",e164:"E.164 \u0B8E\u0BA3\u0BCD",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"\u0B8E\u0BA3\u0BCD",array:"\u0B85\u0BA3\u0BBF",null:"\u0BB5\u0BC6\u0BB1\u0BC1\u0BAE\u0BC8"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 instanceof ${r.expected}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${a}`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${o}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${a}`}case"invalid_value":return r.values.length===1?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${se(r.values[0])}`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0BB0\u0BC1\u0BAA\u0BCD\u0BAA\u0BAE\u0BCD: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${V(r.values,"|")} \u0B87\u0BB2\u0BCD \u0B92\u0BA9\u0BCD\u0BB1\u0BC1`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${r.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${o}${r.maximum.toString()} ${s.unit??"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD"} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${r.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${o}${r.maximum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${r.origin} ${o}${r.minimum.toString()} ${s.unit} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${r.origin} ${o}${r.minimum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${o.prefix}" \u0B87\u0BB2\u0BCD \u0BA4\u0BCA\u0B9F\u0B99\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:o.format==="ends_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${o.suffix}" \u0B87\u0BB2\u0BCD \u0BAE\u0BC1\u0B9F\u0BBF\u0BB5\u0B9F\u0BC8\u0BAF \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:o.format==="includes"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${o.includes}" \u0B90 \u0B89\u0BB3\u0BCD\u0BB3\u0B9F\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:o.format==="regex"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: ${o.pattern} \u0BAE\u0BC1\u0BB1\u0BC8\u0BAA\u0BBE\u0B9F\u0BCD\u0B9F\u0BC1\u0B9F\u0BA9\u0BCD \u0BAA\u0BCA\u0BB0\u0BC1\u0BA8\u0BCD\u0BA4 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 ${n[o.format]??r.format}`}case"not_multiple_of":return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B8E\u0BA3\u0BCD: ${r.divisor} \u0B87\u0BA9\u0BCD \u0BAA\u0BB2\u0BAE\u0BBE\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;case"unrecognized_keys":return`\u0B85\u0B9F\u0BC8\u0BAF\u0BBE\u0BB3\u0BAE\u0BCD \u0BA4\u0BC6\u0BB0\u0BBF\u0BAF\u0BBE\u0BA4 \u0BB5\u0BBF\u0B9A\u0BC8${r.keys.length>1?"\u0B95\u0BB3\u0BCD":""}: ${V(r.keys,", ")}`;case"invalid_key":return`${r.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0B9A\u0BC8`;case"invalid_union":return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1";case"invalid_element":return`${r.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1`;default:return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1"}}}});function IB(){return{localeError:Jre()}}var Jre,TB=v(()=>{Ae();Jre=()=>{let e={string:{unit:"\u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},file:{unit:"\u0E44\u0E1A\u0E15\u0E4C",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},array:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},set:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"}};function t(r){return e[r]??null}let n={regex:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19",email:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48\u0E2D\u0E35\u0E40\u0E21\u0E25",url:"URL",emoji:"\u0E2D\u0E34\u0E42\u0E21\u0E08\u0E34",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",date:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E41\u0E1A\u0E1A ISO",time:"\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",duration:"\u0E0A\u0E48\u0E27\u0E07\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",ipv4:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv4",ipv6:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv6",cidrv4:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv4",cidrv6:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv6",base64:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64",base64url:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64 \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A URL",json_string:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A JSON",e164:"\u0E40\u0E1A\u0E2D\u0E23\u0E4C\u0E42\u0E17\u0E23\u0E28\u0E31\u0E1E\u0E17\u0E4C\u0E23\u0E30\u0E2B\u0E27\u0E48\u0E32\u0E07\u0E1B\u0E23\u0E30\u0E40\u0E17\u0E28 (E.164)",jwt:"\u0E42\u0E17\u0E40\u0E04\u0E19 JWT",template_literal:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19"},i={nan:"NaN",number:"\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02",array:"\u0E2D\u0E32\u0E23\u0E4C\u0E40\u0E23\u0E22\u0E4C (Array)",null:"\u0E44\u0E21\u0E48\u0E21\u0E35\u0E04\u0E48\u0E32 (null)"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 instanceof ${r.expected} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${a}`:`\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${o} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${a}`}case"invalid_value":return r.values.length===1?`\u0E04\u0E48\u0E32\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${se(r.values[0])}`:`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19\u0E2B\u0E19\u0E36\u0E48\u0E07\u0E43\u0E19 ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"\u0E44\u0E21\u0E48\u0E40\u0E01\u0E34\u0E19":"\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32",s=t(r.origin);return s?`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${r.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${r.maximum.toString()} ${s.unit??"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23"}`:`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${r.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?"\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E19\u0E49\u0E2D\u0E22":"\u0E21\u0E32\u0E01\u0E01\u0E27\u0E48\u0E32",s=t(r.origin);return s?`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${r.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${r.minimum.toString()} ${s.unit}`:`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${r.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E02\u0E36\u0E49\u0E19\u0E15\u0E49\u0E19\u0E14\u0E49\u0E27\u0E22 "${o.prefix}"`:o.format==="ends_with"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E25\u0E07\u0E17\u0E49\u0E32\u0E22\u0E14\u0E49\u0E27\u0E22 "${o.suffix}"`:o.format==="includes"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35 "${o.includes}" \u0E2D\u0E22\u0E39\u0E48\u0E43\u0E19\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21`:o.format==="regex"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14 ${o.pattern}`:`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: ${n[o.format]??r.format}`}case"not_multiple_of":return`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E08\u0E33\u0E19\u0E27\u0E19\u0E17\u0E35\u0E48\u0E2B\u0E32\u0E23\u0E14\u0E49\u0E27\u0E22 ${r.divisor} \u0E44\u0E14\u0E49\u0E25\u0E07\u0E15\u0E31\u0E27`;case"unrecognized_keys":return`\u0E1E\u0E1A\u0E04\u0E35\u0E22\u0E4C\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E23\u0E39\u0E49\u0E08\u0E31\u0E01: ${V(r.keys,", ")}`;case"invalid_key":return`\u0E04\u0E35\u0E22\u0E4C\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${r.origin}`;case"invalid_union":return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E22\u0E39\u0E40\u0E19\u0E35\u0E22\u0E19\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E44\u0E27\u0E49";case"invalid_element":return`\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${r.origin}`;default:return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07"}}}});function DB(){return{localeError:Zre()}}var Zre,NB=v(()=>{Ae();Zre=()=>{let e={string:{unit:"karakter",verb:"olmal\u0131"},file:{unit:"bayt",verb:"olmal\u0131"},array:{unit:"\xF6\u011Fe",verb:"olmal\u0131"},set:{unit:"\xF6\u011Fe",verb:"olmal\u0131"}};function t(r){return e[r]??null}let n={regex:"girdi",email:"e-posta adresi",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO tarih ve saat",date:"ISO tarih",time:"ISO saat",duration:"ISO s\xFCre",ipv4:"IPv4 adresi",ipv6:"IPv6 adresi",cidrv4:"IPv4 aral\u0131\u011F\u0131",cidrv6:"IPv6 aral\u0131\u011F\u0131",base64:"base64 ile \u015Fifrelenmi\u015F metin",base64url:"base64url ile \u015Fifrelenmi\u015F metin",json_string:"JSON dizesi",e164:"E.164 say\u0131s\u0131",jwt:"JWT",template_literal:"\u015Eablon dizesi"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Ge\xE7ersiz de\u011Fer: beklenen instanceof ${r.expected}, al\u0131nan ${a}`:`Ge\xE7ersiz de\u011Fer: beklenen ${o}, al\u0131nan ${a}`}case"invalid_value":return r.values.length===1?`Ge\xE7ersiz de\u011Fer: beklenen ${se(r.values[0])}`:`Ge\xE7ersiz se\xE7enek: a\u015Fa\u011F\u0131dakilerden biri olmal\u0131: ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`\xC7ok b\xFCy\xFCk: beklenen ${r.origin??"de\u011Fer"} ${o}${r.maximum.toString()} ${s.unit??"\xF6\u011Fe"}`:`\xC7ok b\xFCy\xFCk: beklenen ${r.origin??"de\u011Fer"} ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`\xC7ok k\xFC\xE7\xFCk: beklenen ${r.origin} ${o}${r.minimum.toString()} ${s.unit}`:`\xC7ok k\xFC\xE7\xFCk: beklenen ${r.origin} ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Ge\xE7ersiz metin: "${o.prefix}" ile ba\u015Flamal\u0131`:o.format==="ends_with"?`Ge\xE7ersiz metin: "${o.suffix}" ile bitmeli`:o.format==="includes"?`Ge\xE7ersiz metin: "${o.includes}" i\xE7ermeli`:o.format==="regex"?`Ge\xE7ersiz metin: ${o.pattern} desenine uymal\u0131`:`Ge\xE7ersiz ${n[o.format]??r.format}`}case"not_multiple_of":return`Ge\xE7ersiz say\u0131: ${r.divisor} ile tam b\xF6l\xFCnebilmeli`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar${r.keys.length>1?"lar":""}: ${V(r.keys,", ")}`;case"invalid_key":return`${r.origin} i\xE7inde ge\xE7ersiz anahtar`;case"invalid_union":return"Ge\xE7ersiz de\u011Fer";case"invalid_element":return`${r.origin} i\xE7inde ge\xE7ersiz de\u011Fer`;default:return"Ge\xE7ersiz de\u011Fer"}}}});function Cy(){return{localeError:Yre()}}var Yre,CE=v(()=>{Ae();Yre=()=>{let e={string:{unit:"\u0441\u0438\u043C\u0432\u043E\u043B\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},file:{unit:"\u0431\u0430\u0439\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},array:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},set:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"}};function t(r){return e[r]??null}let n={regex:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u0435\u043B\u0435\u043A\u0442\u0440\u043E\u043D\u043D\u043E\u0457 \u043F\u043E\u0448\u0442\u0438",url:"URL",emoji:"\u0435\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0434\u0430\u0442\u0430 \u0442\u0430 \u0447\u0430\u0441 ISO",date:"\u0434\u0430\u0442\u0430 ISO",time:"\u0447\u0430\u0441 ISO",duration:"\u0442\u0440\u0438\u0432\u0430\u043B\u0456\u0441\u0442\u044C ISO",ipv4:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv4",ipv6:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv6",cidrv4:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv4",cidrv6:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv6",base64:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64",base64url:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64url",json_string:"\u0440\u044F\u0434\u043E\u043A JSON",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",jwt:"JWT",template_literal:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"},i={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F instanceof ${r.expected}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${a}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${o}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${a}`}case"invalid_value":return r.values.length===1?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${se(r.values[0])}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0430 \u043E\u043F\u0446\u0456\u044F: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F \u043E\u0434\u043D\u0435 \u0437 ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${r.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} ${s.verb} ${o}${r.maximum.toString()} ${s.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432"}`:`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${r.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} \u0431\u0443\u0434\u0435 ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${r.origin} ${s.verb} ${o}${r.minimum.toString()} ${s.unit}`:`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${r.origin} \u0431\u0443\u0434\u0435 ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043F\u043E\u0447\u0438\u043D\u0430\u0442\u0438\u0441\u044F \u0437 "${o.prefix}"`:o.format==="ends_with"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0437\u0430\u043A\u0456\u043D\u0447\u0443\u0432\u0430\u0442\u0438\u0441\u044F \u043D\u0430 "${o.suffix}"`:o.format==="includes"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043C\u0456\u0441\u0442\u0438\u0442\u0438 "${o.includes}"`:o.format==="regex"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0442\u0438 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${o.pattern}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 ${n[o.format]??r.format}`}case"not_multiple_of":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0447\u0438\u0441\u043B\u043E: \u043F\u043E\u0432\u0438\u043D\u043D\u043E \u0431\u0443\u0442\u0438 \u043A\u0440\u0430\u0442\u043D\u0438\u043C ${r.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u043E\u0437\u043F\u0456\u0437\u043D\u0430\u043D\u0438\u0439 \u043A\u043B\u044E\u0447${r.keys.length>1?"\u0456":""}: ${V(r.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u043A\u043B\u044E\u0447 \u0443 ${r.origin}`;case"invalid_union":return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456";case"invalid_element":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F \u0443 ${r.origin}`;default:return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"}}}});function jB(){return Cy()}var LB=v(()=>{CE()});function MB(){return{localeError:Xre()}}var Xre,FB=v(()=>{Ae();Xre=()=>{let e={string:{unit:"\u062D\u0631\u0648\u0641",verb:"\u06C1\u0648\u0646\u0627"},file:{unit:"\u0628\u0627\u0626\u0679\u0633",verb:"\u06C1\u0648\u0646\u0627"},array:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"},set:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"}};function t(r){return e[r]??null}let n={regex:"\u0627\u0646 \u067E\u0679",email:"\u0627\u06CC \u0645\u06CC\u0644 \u0627\u06CC\u0688\u0631\u06CC\u0633",url:"\u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",uuidv4:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 4",uuidv6:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 6",nanoid:"\u0646\u06CC\u0646\u0648 \u0622\u0626\u06CC \u0688\u06CC",guid:"\u062C\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid2:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC 2",ulid:"\u06CC\u0648 \u0627\u06CC\u0644 \u0622\u0626\u06CC \u0688\u06CC",xid:"\u0627\u06CC\u06A9\u0633 \u0622\u0626\u06CC \u0688\u06CC",ksuid:"\u06A9\u06D2 \u0627\u06CC\u0633 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",datetime:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0688\u06CC\u0679 \u0679\u0627\u0626\u0645",date:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u062A\u0627\u0631\u06CC\u062E",time:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0648\u0642\u062A",duration:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0645\u062F\u062A",ipv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0627\u06CC\u0688\u0631\u06CC\u0633",ipv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0627\u06CC\u0688\u0631\u06CC\u0633",cidrv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0631\u06CC\u0646\u062C",cidrv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0631\u06CC\u0646\u062C",base64:"\u0628\u06CC\u0633 64 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",base64url:"\u0628\u06CC\u0633 64 \u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",json_string:"\u062C\u06D2 \u0627\u06CC\u0633 \u0627\u0648 \u0627\u06CC\u0646 \u0633\u0679\u0631\u0646\u06AF",e164:"\u0627\u06CC 164 \u0646\u0645\u0628\u0631",jwt:"\u062C\u06D2 \u0688\u0628\u0644\u06CC\u0648 \u0679\u06CC",template_literal:"\u0627\u0646 \u067E\u0679"},i={nan:"NaN",number:"\u0646\u0645\u0628\u0631",array:"\u0622\u0631\u06D2",null:"\u0646\u0644"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: instanceof ${r.expected} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${a} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`:`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${o} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${a} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`}case"invalid_value":return r.values.length===1?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${se(r.values[0])} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`:`\u063A\u0644\u0637 \u0622\u067E\u0634\u0646: ${V(r.values,"|")} \u0645\u06CC\u06BA \u0633\u06D2 \u0627\u06CC\u06A9 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u0628\u06C1\u062A \u0628\u0691\u0627: ${r.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u06D2 ${o}${r.maximum.toString()} ${s.unit??"\u0639\u0646\u0627\u0635\u0631"} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0628\u0691\u0627: ${r.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u0627 ${o}${r.maximum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${r.origin} \u06A9\u06D2 ${o}${r.minimum.toString()} ${s.unit} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${r.origin} \u06A9\u0627 ${o}${r.minimum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${o.prefix}" \u0633\u06D2 \u0634\u0631\u0648\u0639 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:o.format==="ends_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${o.suffix}" \u067E\u0631 \u062E\u062A\u0645 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:o.format==="includes"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${o.includes}" \u0634\u0627\u0645\u0644 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:o.format==="regex"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: \u067E\u06CC\u0679\u0631\u0646 ${o.pattern} \u0633\u06D2 \u0645\u06CC\u0686 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:`\u063A\u0644\u0637 ${n[o.format]??r.format}`}case"not_multiple_of":return`\u063A\u0644\u0637 \u0646\u0645\u0628\u0631: ${r.divisor} \u06A9\u0627 \u0645\u0636\u0627\u0639\u0641 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;case"unrecognized_keys":return`\u063A\u06CC\u0631 \u062A\u0633\u0644\u06CC\u0645 \u0634\u062F\u06C1 \u06A9\u06CC${r.keys.length>1?"\u0632":""}: ${V(r.keys,"\u060C ")}`;case"invalid_key":return`${r.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u06A9\u06CC`;case"invalid_union":return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679";case"invalid_element":return`${r.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u0648\u06CC\u0644\u06CC\u0648`;default:return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679"}}}});function BB(){return{localeError:Qre()}}var Qre,GB=v(()=>{Ae();Qre=()=>{let e={string:{unit:"belgi",verb:"bo\u2018lishi kerak"},file:{unit:"bayt",verb:"bo\u2018lishi kerak"},array:{unit:"element",verb:"bo\u2018lishi kerak"},set:{unit:"element",verb:"bo\u2018lishi kerak"}};function t(r){return e[r]??null}let n={regex:"kirish",email:"elektron pochta manzili",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO sana va vaqti",date:"ISO sana",time:"ISO vaqt",duration:"ISO davomiylik",ipv4:"IPv4 manzil",ipv6:"IPv6 manzil",mac:"MAC manzil",cidrv4:"IPv4 diapazon",cidrv6:"IPv6 diapazon",base64:"base64 kodlangan satr",base64url:"base64url kodlangan satr",json_string:"JSON satr",e164:"E.164 raqam",jwt:"JWT",template_literal:"kirish"},i={nan:"NaN",number:"raqam",array:"massiv"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`Noto\u2018g\u2018ri kirish: kutilgan instanceof ${r.expected}, qabul qilingan ${a}`:`Noto\u2018g\u2018ri kirish: kutilgan ${o}, qabul qilingan ${a}`}case"invalid_value":return r.values.length===1?`Noto\u2018g\u2018ri kirish: kutilgan ${se(r.values[0])}`:`Noto\u2018g\u2018ri variant: quyidagilardan biri kutilgan ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`Juda katta: kutilgan ${r.origin??"qiymat"} ${o}${r.maximum.toString()} ${s.unit} ${s.verb}`:`Juda katta: kutilgan ${r.origin??"qiymat"} ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`Juda kichik: kutilgan ${r.origin} ${o}${r.minimum.toString()} ${s.unit} ${s.verb}`:`Juda kichik: kutilgan ${r.origin} ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Noto\u2018g\u2018ri satr: "${o.prefix}" bilan boshlanishi kerak`:o.format==="ends_with"?`Noto\u2018g\u2018ri satr: "${o.suffix}" bilan tugashi kerak`:o.format==="includes"?`Noto\u2018g\u2018ri satr: "${o.includes}" ni o\u2018z ichiga olishi kerak`:o.format==="regex"?`Noto\u2018g\u2018ri satr: ${o.pattern} shabloniga mos kelishi kerak`:`Noto\u2018g\u2018ri ${n[o.format]??r.format}`}case"not_multiple_of":return`Noto\u2018g\u2018ri raqam: ${r.divisor} ning karralisi bo\u2018lishi kerak`;case"unrecognized_keys":return`Noma\u2019lum kalit${r.keys.length>1?"lar":""}: ${V(r.keys,", ")}`;case"invalid_key":return`${r.origin} dagi kalit noto\u2018g\u2018ri`;case"invalid_union":return"Noto\u2018g\u2018ri kirish";case"invalid_element":return`${r.origin} da noto\u2018g\u2018ri qiymat`;default:return"Noto\u2018g\u2018ri kirish"}}}});function WB(){return{localeError:eie()}}var eie,zB=v(()=>{Ae();eie=()=>{let e={string:{unit:"k\xFD t\u1EF1",verb:"c\xF3"},file:{unit:"byte",verb:"c\xF3"},array:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"},set:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"}};function t(r){return e[r]??null}let n={regex:"\u0111\u1EA7u v\xE0o",email:"\u0111\u1ECBa ch\u1EC9 email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ng\xE0y gi\u1EDD ISO",date:"ng\xE0y ISO",time:"gi\u1EDD ISO",duration:"kho\u1EA3ng th\u1EDDi gian ISO",ipv4:"\u0111\u1ECBa ch\u1EC9 IPv4",ipv6:"\u0111\u1ECBa ch\u1EC9 IPv6",cidrv4:"d\u1EA3i IPv4",cidrv6:"d\u1EA3i IPv6",base64:"chu\u1ED7i m\xE3 h\xF3a base64",base64url:"chu\u1ED7i m\xE3 h\xF3a base64url",json_string:"chu\u1ED7i JSON",e164:"s\u1ED1 E.164",jwt:"JWT",template_literal:"\u0111\u1EA7u v\xE0o"},i={nan:"NaN",number:"s\u1ED1",array:"m\u1EA3ng"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i instanceof ${r.expected}, nh\u1EADn \u0111\u01B0\u1EE3c ${a}`:`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${o}, nh\u1EADn \u0111\u01B0\u1EE3c ${a}`}case"invalid_value":return r.values.length===1?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${se(r.values[0])}`:`T\xF9y ch\u1ECDn kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i m\u1ED9t trong c\xE1c gi\xE1 tr\u1ECB ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${r.origin??"gi\xE1 tr\u1ECB"} ${s.verb} ${o}${r.maximum.toString()} ${s.unit??"ph\u1EA7n t\u1EED"}`:`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${r.origin??"gi\xE1 tr\u1ECB"} ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${r.origin} ${s.verb} ${o}${r.minimum.toString()} ${s.unit}`:`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${r.origin} ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i b\u1EAFt \u0111\u1EA7u b\u1EB1ng "${o.prefix}"`:o.format==="ends_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i k\u1EBFt th\xFAc b\u1EB1ng "${o.suffix}"`:o.format==="includes"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i bao g\u1ED3m "${o.includes}"`:o.format==="regex"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i kh\u1EDBp v\u1EDBi m\u1EABu ${o.pattern}`:`${n[o.format]??r.format} kh\xF4ng h\u1EE3p l\u1EC7`}case"not_multiple_of":return`S\u1ED1 kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i l\xE0 b\u1ED9i s\u1ED1 c\u1EE7a ${r.divisor}`;case"unrecognized_keys":return`Kh\xF3a kh\xF4ng \u0111\u01B0\u1EE3c nh\u1EADn d\u1EA1ng: ${V(r.keys,", ")}`;case"invalid_key":return`Kh\xF3a kh\xF4ng h\u1EE3p l\u1EC7 trong ${r.origin}`;case"invalid_union":return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7";case"invalid_element":return`Gi\xE1 tr\u1ECB kh\xF4ng h\u1EE3p l\u1EC7 trong ${r.origin}`;default:return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7"}}}});function UB(){return{localeError:tie()}}var tie,HB=v(()=>{Ae();tie=()=>{let e={string:{unit:"\u5B57\u7B26",verb:"\u5305\u542B"},file:{unit:"\u5B57\u8282",verb:"\u5305\u542B"},array:{unit:"\u9879",verb:"\u5305\u542B"},set:{unit:"\u9879",verb:"\u5305\u542B"}};function t(r){return e[r]??null}let n={regex:"\u8F93\u5165",email:"\u7535\u5B50\u90AE\u4EF6",url:"URL",emoji:"\u8868\u60C5\u7B26\u53F7",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u671F\u65F6\u95F4",date:"ISO\u65E5\u671F",time:"ISO\u65F6\u95F4",duration:"ISO\u65F6\u957F",ipv4:"IPv4\u5730\u5740",ipv6:"IPv6\u5730\u5740",cidrv4:"IPv4\u7F51\u6BB5",cidrv6:"IPv6\u7F51\u6BB5",base64:"base64\u7F16\u7801\u5B57\u7B26\u4E32",base64url:"base64url\u7F16\u7801\u5B57\u7B26\u4E32",json_string:"JSON\u5B57\u7B26\u4E32",e164:"E.164\u53F7\u7801",jwt:"JWT",template_literal:"\u8F93\u5165"},i={nan:"NaN",number:"\u6570\u5B57",array:"\u6570\u7EC4",null:"\u7A7A\u503C(null)"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B instanceof ${r.expected}\uFF0C\u5B9E\u9645\u63A5\u6536 ${a}`:`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${o}\uFF0C\u5B9E\u9645\u63A5\u6536 ${a}`}case"invalid_value":return r.values.length===1?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${se(r.values[0])}`:`\u65E0\u6548\u9009\u9879\uFF1A\u671F\u671B\u4EE5\u4E0B\u4E4B\u4E00 ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${r.origin??"\u503C"} ${o}${r.maximum.toString()} ${s.unit??"\u4E2A\u5143\u7D20"}`:`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${r.origin??"\u503C"} ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${r.origin} ${o}${r.minimum.toString()} ${s.unit}`:`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${r.origin} ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${o.prefix}" \u5F00\u5934`:o.format==="ends_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${o.suffix}" \u7ED3\u5C3E`:o.format==="includes"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u5305\u542B "${o.includes}"`:o.format==="regex"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u6EE1\u8DB3\u6B63\u5219\u8868\u8FBE\u5F0F ${o.pattern}`:`\u65E0\u6548${n[o.format]??r.format}`}case"not_multiple_of":return`\u65E0\u6548\u6570\u5B57\uFF1A\u5FC5\u987B\u662F ${r.divisor} \u7684\u500D\u6570`;case"unrecognized_keys":return`\u51FA\u73B0\u672A\u77E5\u7684\u952E(key): ${V(r.keys,", ")}`;case"invalid_key":return`${r.origin} \u4E2D\u7684\u952E(key)\u65E0\u6548`;case"invalid_union":return"\u65E0\u6548\u8F93\u5165";case"invalid_element":return`${r.origin} \u4E2D\u5305\u542B\u65E0\u6548\u503C(value)`;default:return"\u65E0\u6548\u8F93\u5165"}}}});function VB(){return{localeError:nie()}}var nie,qB=v(()=>{Ae();nie=()=>{let e={string:{unit:"\u5B57\u5143",verb:"\u64C1\u6709"},file:{unit:"\u4F4D\u5143\u7D44",verb:"\u64C1\u6709"},array:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"},set:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"}};function t(r){return e[r]??null}let n={regex:"\u8F38\u5165",email:"\u90F5\u4EF6\u5730\u5740",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u65E5\u671F\u6642\u9593",date:"ISO \u65E5\u671F",time:"ISO \u6642\u9593",duration:"ISO \u671F\u9593",ipv4:"IPv4 \u4F4D\u5740",ipv6:"IPv6 \u4F4D\u5740",cidrv4:"IPv4 \u7BC4\u570D",cidrv6:"IPv6 \u7BC4\u570D",base64:"base64 \u7DE8\u78BC\u5B57\u4E32",base64url:"base64url \u7DE8\u78BC\u5B57\u4E32",json_string:"JSON \u5B57\u4E32",e164:"E.164 \u6578\u503C",jwt:"JWT",template_literal:"\u8F38\u5165"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA instanceof ${r.expected}\uFF0C\u4F46\u6536\u5230 ${a}`:`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${o}\uFF0C\u4F46\u6536\u5230 ${a}`}case"invalid_value":return r.values.length===1?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${se(r.values[0])}`:`\u7121\u6548\u7684\u9078\u9805\uFF1A\u9810\u671F\u70BA\u4EE5\u4E0B\u5176\u4E2D\u4E4B\u4E00 ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${r.origin??"\u503C"} \u61C9\u70BA ${o}${r.maximum.toString()} ${s.unit??"\u500B\u5143\u7D20"}`:`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${r.origin??"\u503C"} \u61C9\u70BA ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${r.origin} \u61C9\u70BA ${o}${r.minimum.toString()} ${s.unit}`:`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${r.origin} \u61C9\u70BA ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${o.prefix}" \u958B\u982D`:o.format==="ends_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${o.suffix}" \u7D50\u5C3E`:o.format==="includes"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u5305\u542B "${o.includes}"`:o.format==="regex"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u7B26\u5408\u683C\u5F0F ${o.pattern}`:`\u7121\u6548\u7684 ${n[o.format]??r.format}`}case"not_multiple_of":return`\u7121\u6548\u7684\u6578\u5B57\uFF1A\u5FC5\u9808\u70BA ${r.divisor} \u7684\u500D\u6578`;case"unrecognized_keys":return`\u7121\u6CD5\u8B58\u5225\u7684\u9375\u503C${r.keys.length>1?"\u5011":""}\uFF1A${V(r.keys,"\u3001")}`;case"invalid_key":return`${r.origin} \u4E2D\u6709\u7121\u6548\u7684\u9375\u503C`;case"invalid_union":return"\u7121\u6548\u7684\u8F38\u5165\u503C";case"invalid_element":return`${r.origin} \u4E2D\u6709\u7121\u6548\u7684\u503C`;default:return"\u7121\u6548\u7684\u8F38\u5165\u503C"}}}});function KB(){return{localeError:rie()}}var rie,JB=v(()=>{Ae();rie=()=>{let e={string:{unit:"\xE0mi",verb:"n\xED"},file:{unit:"bytes",verb:"n\xED"},array:{unit:"nkan",verb:"n\xED"},set:{unit:"nkan",verb:"n\xED"}};function t(r){return e[r]??null}let n={regex:"\u1EB9\u0300r\u1ECD \xECb\xE1w\u1ECDl\xE9",email:"\xE0d\xEDr\u1EB9\u0301s\xEC \xECm\u1EB9\u0301l\xEC",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\xE0k\xF3k\xF2 ISO",date:"\u1ECDj\u1ECD\u0301 ISO",time:"\xE0k\xF3k\xF2 ISO",duration:"\xE0k\xF3k\xF2 t\xF3 p\xE9 ISO",ipv4:"\xE0d\xEDr\u1EB9\u0301s\xEC IPv4",ipv6:"\xE0d\xEDr\u1EB9\u0301s\xEC IPv6",cidrv4:"\xE0gb\xE8gb\xE8 IPv4",cidrv6:"\xE0gb\xE8gb\xE8 IPv6",base64:"\u1ECD\u0300r\u1ECD\u0300 t\xED a k\u1ECD\u0301 n\xED base64",base64url:"\u1ECD\u0300r\u1ECD\u0300 base64url",json_string:"\u1ECD\u0300r\u1ECD\u0300 JSON",e164:"n\u1ECD\u0301mb\xE0 E.164",jwt:"JWT",template_literal:"\u1EB9\u0300r\u1ECD \xECb\xE1w\u1ECDl\xE9"},i={nan:"NaN",number:"n\u1ECD\u0301mb\xE0",array:"akop\u1ECD"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,s=ce(r.input),a=i[s]??s;return/^[A-Z]/.test(r.expected)?`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi instanceof ${r.expected}, \xE0m\u1ECD\u0300 a r\xED ${a}`:`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${o}, \xE0m\u1ECD\u0300 a r\xED ${a}`}case"invalid_value":return r.values.length===1?`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${se(r.values[0])}`:`\xC0\u1E63\xE0y\xE0n a\u1E63\xEC\u1E63e: yan \u1ECD\u0300kan l\xE1ra ${V(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",s=t(r.origin);return s?`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${r.origin??"iye"} ${s.verb} ${o}${r.maximum} ${s.unit}`:`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 ${o}${r.maximum}`}case"too_small":{let o=r.inclusive?">=":">",s=t(r.origin);return s?`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${r.origin} ${s.verb} ${o}${r.minimum} ${s.unit}`:`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 ${o}${r.minimum}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\u1EB9\u0300r\u1EB9\u0300 p\u1EB9\u0300l\xFA "${o.prefix}"`:o.format==="ends_with"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 par\xED p\u1EB9\u0300l\xFA "${o.suffix}"`:o.format==="includes"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 n\xED "${o.includes}"`:o.format==="regex"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\xE1 \xE0p\u1EB9\u1EB9r\u1EB9 mu ${o.pattern}`:`A\u1E63\xEC\u1E63e: ${n[o.format]??r.format}`}case"not_multiple_of":return`N\u1ECD\u0301mb\xE0 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 j\u1EB9\u0301 \xE8y\xE0 p\xEDp\xEDn ti ${r.divisor}`;case"unrecognized_keys":return`B\u1ECDt\xECn\xEC \xE0\xECm\u1ECD\u0300: ${V(r.keys,", ")}`;case"invalid_key":return`B\u1ECDt\xECn\xEC a\u1E63\xEC\u1E63e n\xEDn\xFA ${r.origin}`;case"invalid_union":return"\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e";case"invalid_element":return`Iye a\u1E63\xEC\u1E63e n\xEDn\xFA ${r.origin}`;default:return"\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e"}}}});var Qp={};_e(Qp,{ar:()=>cF,az:()=>uF,be:()=>fF,bg:()=>gF,ca:()=>yF,cs:()=>wF,da:()=>kF,de:()=>$F,en:()=>Py,eo:()=>SF,es:()=>AF,fa:()=>OF,fi:()=>_F,fr:()=>TF,frCA:()=>NF,he:()=>LF,hu:()=>FF,hy:()=>WF,id:()=>UF,is:()=>VF,it:()=>KF,ja:()=>ZF,ka:()=>XF,kh:()=>eB,km:()=>Oy,ko:()=>nB,lt:()=>oB,mk:()=>aB,ms:()=>lB,nl:()=>dB,no:()=>fB,ota:()=>gB,pl:()=>wB,ps:()=>yB,pt:()=>kB,ru:()=>RB,sl:()=>EB,sv:()=>PB,ta:()=>CB,th:()=>IB,tr:()=>DB,ua:()=>jB,uk:()=>Cy,ur:()=>MB,uz:()=>BB,vi:()=>WB,yo:()=>KB,zhCN:()=>UB,zhTW:()=>VB});var _E=v(()=>{lF();dF();mF();hF();bF();vF();xF();RF();PE();EF();PF();CF();IF();DF();jF();MF();BF();zF();HF();qF();JF();YF();QF();tB();OE();rB();sB();cB();uB();pB();mB();hB();bB();vB();xB();SB();AB();OB();_B();TB();NB();LB();CE();FB();GB();zB();HB();qB();JB()});function Iy(){return new _y}var ZB,IE,TE,_y,kn,ef=v(()=>{IE=Symbol("ZodOutput"),TE=Symbol("ZodInput"),_y=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){let i=n[0];return this._map.set(t,i),i&&typeof i=="object"&&"id"in i&&this._idmap.set(i.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){let n=t._zod.parent;if(n){let i={...this.get(n)??{}};delete i.id;let r={...i,...this._map.get(t)};return Object.keys(r).length?r:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};(ZB=globalThis).__zod_globalRegistry??(ZB.__zod_globalRegistry=Iy());kn=globalThis.__zod_globalRegistry});function DE(e,t){return new e({type:"string",...ue(t)})}function NE(e,t){return new e({type:"string",coerce:!0,...ue(t)})}function Ty(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...ue(t)})}function tf(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...ue(t)})}function Dy(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...ue(t)})}function Ny(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...ue(t)})}function jy(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...ue(t)})}function Ly(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...ue(t)})}function nf(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...ue(t)})}function My(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...ue(t)})}function Fy(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...ue(t)})}function By(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...ue(t)})}function Gy(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...ue(t)})}function Wy(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...ue(t)})}function zy(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...ue(t)})}function Uy(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...ue(t)})}function Hy(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...ue(t)})}function Vy(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...ue(t)})}function jE(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...ue(t)})}function qy(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ue(t)})}function Ky(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ue(t)})}function Jy(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...ue(t)})}function Zy(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...ue(t)})}function Yy(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...ue(t)})}function Xy(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...ue(t)})}function ME(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...ue(t)})}function FE(e,t){return new e({type:"string",format:"date",check:"string_format",...ue(t)})}function BE(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...ue(t)})}function GE(e,t){return new e({type:"string",format:"duration",check:"string_format",...ue(t)})}function WE(e,t){return new e({type:"number",checks:[],...ue(t)})}function zE(e,t){return new e({type:"number",coerce:!0,checks:[],...ue(t)})}function UE(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...ue(t)})}function HE(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...ue(t)})}function VE(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...ue(t)})}function qE(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...ue(t)})}function KE(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...ue(t)})}function JE(e,t){return new e({type:"boolean",...ue(t)})}function ZE(e,t){return new e({type:"boolean",coerce:!0,...ue(t)})}function YE(e,t){return new e({type:"bigint",...ue(t)})}function XE(e,t){return new e({type:"bigint",coerce:!0,...ue(t)})}function QE(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...ue(t)})}function eA(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...ue(t)})}function tA(e,t){return new e({type:"symbol",...ue(t)})}function nA(e,t){return new e({type:"undefined",...ue(t)})}function rA(e,t){return new e({type:"null",...ue(t)})}function iA(e){return new e({type:"any"})}function oA(e){return new e({type:"unknown"})}function sA(e,t){return new e({type:"never",...ue(t)})}function aA(e,t){return new e({type:"void",...ue(t)})}function cA(e,t){return new e({type:"date",...ue(t)})}function lA(e,t){return new e({type:"date",coerce:!0,...ue(t)})}function uA(e,t){return new e({type:"nan",...ue(t)})}function Yi(e,t){return new hy({check:"less_than",...ue(t),value:e,inclusive:!1})}function Tr(e,t){return new hy({check:"less_than",...ue(t),value:e,inclusive:!0})}function Xi(e,t){return new yy({check:"greater_than",...ue(t),value:e,inclusive:!1})}function Zn(e,t){return new yy({check:"greater_than",...ue(t),value:e,inclusive:!0})}function Qy(e){return Xi(0,e)}function eb(e){return Yi(0,e)}function tb(e){return Tr(0,e)}function nb(e){return Zn(0,e)}function Hs(e,t){return new ZR({check:"multiple_of",...ue(t),value:e})}function Vs(e,t){return new QR({check:"max_size",...ue(t),maximum:e})}function Qi(e,t){return new eS({check:"min_size",...ue(t),minimum:e})}function mc(e,t){return new tS({check:"size_equals",...ue(t),size:e})}function gc(e,t){return new nS({check:"max_length",...ue(t),maximum:e})}function Zo(e,t){return new rS({check:"min_length",...ue(t),minimum:e})}function hc(e,t){return new iS({check:"length_equals",...ue(t),length:e})}function Yl(e,t){return new oS({check:"string_format",format:"regex",...ue(t),pattern:e})}function Xl(e){return new sS({check:"string_format",format:"lowercase",...ue(e)})}function Ql(e){return new aS({check:"string_format",format:"uppercase",...ue(e)})}function eu(e,t){return new cS({check:"string_format",format:"includes",...ue(t),includes:e})}function tu(e,t){return new lS({check:"string_format",format:"starts_with",...ue(t),prefix:e})}function nu(e,t){return new uS({check:"string_format",format:"ends_with",...ue(t),suffix:e})}function rb(e,t,n){return new dS({check:"property",property:e,schema:t,...ue(n)})}function ru(e,t){return new pS({check:"mime_type",mime:e,...ue(t)})}function Ri(e){return new fS({check:"overwrite",tx:e})}function iu(e){return Ri(t=>t.normalize(e))}function ou(){return Ri(e=>e.trim())}function su(){return Ri(e=>e.toLowerCase())}function au(){return Ri(e=>e.toUpperCase())}function cu(){return Ri(e=>lR(e))}function dA(e,t,n){return new e({type:"array",element:t,...ue(n)})}function oie(e,t,n){return new e({type:"union",options:t,...ue(n)})}function sie(e,t,n){return new e({type:"union",options:t,inclusive:!1,...ue(n)})}function aie(e,t,n,i){return new e({type:"union",options:n,discriminator:t,...ue(i)})}function cie(e,t,n){return new e({type:"intersection",left:t,right:n})}function lie(e,t,n,i){let r=n instanceof Ne,o=r?i:n,s=r?n:null;return new e({type:"tuple",items:t,rest:s,...ue(o)})}function uie(e,t,n,i){return new e({type:"record",keyType:t,valueType:n,...ue(i)})}function die(e,t,n,i){return new e({type:"map",keyType:t,valueType:n,...ue(i)})}function pie(e,t,n){return new e({type:"set",valueType:t,...ue(n)})}function fie(e,t,n){let i=Array.isArray(t)?Object.fromEntries(t.map(r=>[r,r])):t;return new e({type:"enum",entries:i,...ue(n)})}function mie(e,t,n){return new e({type:"enum",entries:t,...ue(n)})}function gie(e,t,n){return new e({type:"literal",values:Array.isArray(t)?t:[t],...ue(n)})}function pA(e,t){return new e({type:"file",...ue(t)})}function hie(e,t){return new e({type:"transform",transform:t})}function yie(e,t){return new e({type:"optional",innerType:t})}function bie(e,t){return new e({type:"nullable",innerType:t})}function wie(e,t,n){return new e({type:"default",innerType:t,get defaultValue(){return typeof n=="function"?n():dR(n)}})}function vie(e,t,n){return new e({type:"nonoptional",innerType:t,...ue(n)})}function kie(e,t){return new e({type:"success",innerType:t})}function xie(e,t,n){return new e({type:"catch",innerType:t,catchValue:typeof n=="function"?n:()=>n})}function $ie(e,t,n){return new e({type:"pipe",in:t,out:n})}function Rie(e,t){return new e({type:"readonly",innerType:t})}function Sie(e,t,n){return new e({type:"template_literal",parts:t,...ue(n)})}function Eie(e,t){return new e({type:"lazy",getter:t})}function Aie(e,t){return new e({type:"promise",innerType:t})}function fA(e,t,n){let i=ue(n);return i.abort??(i.abort=!0),new e({type:"custom",check:"custom",fn:t,...i})}function mA(e,t,n){return new e({type:"custom",check:"custom",fn:t,...ue(n)})}function gA(e){let t=YB(n=>(n.addIssue=i=>{if(typeof i=="string")n.issues.push(Ul(i,n.value,t._zod.def));else{let r=i;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=n.value),r.inst??(r.inst=t),r.continue??(r.continue=!t._zod.def.abort),n.issues.push(Ul(r))}},e(n.value,n)));return t}function YB(e,t){let n=new Et({check:"custom",...ue(t)});return n._zod.check=e,n}function hA(e){let t=new Et({check:"describe"});return t._zod.onattach=[n=>{let i=kn.get(n)??{};kn.add(n,{...i,description:e})}],t._zod.check=()=>{},t}function yA(e){let t=new Et({check:"meta"});return t._zod.onattach=[n=>{let i=kn.get(n)??{};kn.add(n,{...i,...e})}],t._zod.check=()=>{},t}function bA(e,t){let n=ue(t),i=n.truthy??["true","1","yes","on","y","enabled"],r=n.falsy??["false","0","no","off","n","disabled"];n.case!=="sensitive"&&(i=i.map(f=>typeof f=="string"?f.toLowerCase():f),r=r.map(f=>typeof f=="string"?f.toLowerCase():f));let o=new Set(i),s=new Set(r),a=e.Codec??Yp,l=e.Boolean??Jp,c=e.String??fc,u=new c({type:"string",error:n.error}),d=new l({type:"boolean",error:n.error}),p=new a({type:"pipe",in:u,out:d,transform:((f,g)=>{let h=f;return n.case!=="sensitive"&&(h=h.toLowerCase()),o.has(h)?!0:s.has(h)?!1:(g.issues.push({code:"invalid_value",expected:"stringbool",values:[...o,...s],input:g.value,inst:p,continue:!1}),{})}),reverseTransform:((f,g)=>f===!0?i[0]||"true":r[0]||"false"),error:n.error});return p}function lu(e,t,n,i={}){let r=ue(i),o={...ue(i),check:"string_format",type:"string",format:t,fn:typeof n=="function"?n:a=>n.test(a),...r};return n instanceof RegExp&&(o.pattern=n),new e(o)}var LE,XB=v(()=>{by();ef();AE();Ae();LE={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6}});function qs(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??kn,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function ht(e,t,n={path:[],schemaPath:[]}){var i;let r=e._zod.def,o=t.seen.get(e);if(o)return o.count++,n.schemaPath.includes(e)&&(o.cycle=n.path),o.schema;let s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s);let a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{let u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,u);else{let p=s.schema,f=t.processors[r.type];if(!f)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);f(e,t,p,u)}let d=e._zod.parent;d&&(s.ref||(s.ref=d),ht(d,t,u),t.seen.get(d).isParent=!0)}let l=t.metadataRegistry.get(e);return l&&Object.assign(s.schema,l),t.io==="input"&&Yn(e)&&(delete s.schema.examples,delete s.schema.default),t.io==="input"&&s.schema._prefault&&((i=s.schema).default??(i.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}function Ks(e,t){let n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=new Map;for(let s of e.seen.entries()){let a=e.metadataRegistry.get(s[0])?.id;if(a){let l=i.get(a);if(l&&l!==s[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(a,s[0])}}let r=s=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(s[0])?.id,p=e.external.uri??(g=>g);if(d)return{ref:p(d)};let f=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=f,{defId:f,ref:`${p("__shared")}#/${a}/${f}`}}if(s[1]===n)return{ref:"#"};let c=`#/${a}/`,u=s[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:c+u}},o=s=>{if(s[1].schema.$ref)return;let a=s[1],{ref:l,defId:c}=r(s);a.def={...a.schema},c&&(a.defId=c);let u=a.schema;for(let d in u)delete u[d];u.$ref=l};if(e.cycles==="throw")for(let s of e.seen.entries()){let a=s[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
45
|
+
|
|
46
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let s of e.seen.entries()){let a=s[1];if(t===s[0]){o(s);continue}if(e.external){let c=e.external.registry.get(s[0])?.id;if(t!==s[0]&&c){o(s);continue}}if(e.metadataRegistry.get(s[0])?.id){o(s);continue}if(a.cycle){o(s);continue}if(a.count>1&&e.reused==="ref"){o(s);continue}}}function Js(e,t){let n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=s=>{let a=e.seen.get(s);if(a.ref===null)return;let l=a.def??a.schema,c={...l},u=a.ref;if(a.ref=null,u){i(u);let p=e.seen.get(u),f=p.schema;if(f.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(l.allOf=l.allOf??[],l.allOf.push(f)):Object.assign(l,f),Object.assign(l,c),s._zod.parent===u)for(let h in l)h==="$ref"||h==="allOf"||h in c||delete l[h];if(f.$ref&&p.def)for(let h in l)h==="$ref"||h==="allOf"||h in p.def&&JSON.stringify(l[h])===JSON.stringify(p.def[h])&&delete l[h]}let d=s._zod.parent;if(d&&d!==u){i(d);let p=e.seen.get(d);if(p?.schema.$ref&&(l.$ref=p.schema.$ref,p.def))for(let f in l)f==="$ref"||f==="allOf"||f in p.def&&JSON.stringify(l[f])===JSON.stringify(p.def[f])&&delete l[f]}e.override({zodSchema:s,jsonSchema:l,path:a.path??[]})};for(let s of[...e.seen.entries()].reverse())i(s[0]);let r={};if(e.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let s=e.external.registry.get(t)?.id;if(!s)throw new Error("Schema is missing an `id` property");r.$id=e.external.uri(s)}Object.assign(r,n.def??n.schema);let o=e.external?.defs??{};for(let s of e.seen.entries()){let a=s[1];a.def&&a.defId&&(o[a.defId]=a.def)}e.external||Object.keys(o).length>0&&(e.target==="draft-2020-12"?r.$defs=o:r.definitions=o);try{let s=JSON.parse(JSON.stringify(r));return Object.defineProperty(s,"~standard",{value:{...t["~standard"],jsonSchema:{input:uu(t,"input",e.processors),output:uu(t,"output",e.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function Yn(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return Yn(i.element,n);if(i.type==="set")return Yn(i.valueType,n);if(i.type==="lazy")return Yn(i.getter(),n);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault")return Yn(i.innerType,n);if(i.type==="intersection")return Yn(i.left,n)||Yn(i.right,n);if(i.type==="record"||i.type==="map")return Yn(i.keyType,n)||Yn(i.valueType,n);if(i.type==="pipe")return Yn(i.in,n)||Yn(i.out,n);if(i.type==="object"){for(let r in i.shape)if(Yn(i.shape[r],n))return!0;return!1}if(i.type==="union"){for(let r of i.options)if(Yn(r,n))return!0;return!1}if(i.type==="tuple"){for(let r of i.items)if(Yn(r,n))return!0;return!!(i.rest&&Yn(i.rest,n))}return!1}var wA,uu,rf=v(()=>{ef();wA=(e,t={})=>n=>{let i=qs({...n,processors:t});return ht(e,i),Ks(i,e),Js(i,e)},uu=(e,t,n={})=>i=>{let{libraryOptions:r,target:o}=i??{},s=qs({...r??{},target:o,io:t,processors:n});return ht(e,s),Ks(s,e),Js(s,e)}});function ab(e,t){if("_idmap"in e){let i=e,r=qs({...t,processors:ib}),o={};for(let l of i._idmap.entries()){let[c,u]=l;ht(u,r)}let s={},a={registry:i,uri:t?.uri,defs:o};r.external=a;for(let l of i._idmap.entries()){let[c,u]=l;Ks(r,u),s[c]=Js(r,u)}if(Object.keys(o).length>0){let l=r.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[l]:o}}return{schemas:s}}let n=qs({...t,processors:ib});return ht(e,n),Ks(n,e),Js(n,e)}var Pie,vA,kA,xA,$A,RA,SA,EA,AA,PA,OA,CA,_A,IA,TA,DA,NA,jA,LA,MA,FA,BA,GA,WA,zA,UA,ob,HA,VA,qA,KA,JA,ZA,YA,XA,QA,eP,tP,sb,nP,ib,of=v(()=>{rf();Ae();Pie={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},vA=(e,t,n,i)=>{let r=n;r.type="string";let{minimum:o,maximum:s,format:a,patterns:l,contentEncoding:c}=e._zod.bag;if(typeof o=="number"&&(r.minLength=o),typeof s=="number"&&(r.maxLength=s),a&&(r.format=Pie[a]??a,r.format===""&&delete r.format,a==="time"&&delete r.format),c&&(r.contentEncoding=c),l&&l.size>0){let u=[...l];u.length===1?r.pattern=u[0].source:u.length>1&&(r.allOf=[...u.map(d=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},kA=(e,t,n,i)=>{let r=n,{minimum:o,maximum:s,format:a,multipleOf:l,exclusiveMaximum:c,exclusiveMinimum:u}=e._zod.bag;typeof a=="string"&&a.includes("int")?r.type="integer":r.type="number",typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(r.minimum=u,r.exclusiveMinimum=!0):r.exclusiveMinimum=u),typeof o=="number"&&(r.minimum=o,typeof u=="number"&&t.target!=="draft-04"&&(u>=o?delete r.minimum:delete r.exclusiveMinimum)),typeof c=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(r.maximum=c,r.exclusiveMaximum=!0):r.exclusiveMaximum=c),typeof s=="number"&&(r.maximum=s,typeof c=="number"&&t.target!=="draft-04"&&(c<=s?delete r.maximum:delete r.exclusiveMaximum)),typeof l=="number"&&(r.multipleOf=l)},xA=(e,t,n,i)=>{n.type="boolean"},$A=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},RA=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},SA=(e,t,n,i)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},EA=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},AA=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},PA=(e,t,n,i)=>{n.not={}},OA=(e,t,n,i)=>{},CA=(e,t,n,i)=>{},_A=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},IA=(e,t,n,i)=>{let r=e._zod.def,o=Mp(r.entries);o.every(s=>typeof s=="number")&&(n.type="number"),o.every(s=>typeof s=="string")&&(n.type="string"),n.enum=o},TA=(e,t,n,i)=>{let r=e._zod.def,o=[];for(let s of r.values)if(s===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof s=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");o.push(Number(s))}else o.push(s);if(o.length!==0)if(o.length===1){let s=o[0];n.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[s]:n.const=s}else o.every(s=>typeof s=="number")&&(n.type="number"),o.every(s=>typeof s=="string")&&(n.type="string"),o.every(s=>typeof s=="boolean")&&(n.type="boolean"),o.every(s=>s===null)&&(n.type="null"),n.enum=o},DA=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},NA=(e,t,n,i)=>{let r=n,o=e._zod.pattern;if(!o)throw new Error("Pattern not found in template literal");r.type="string",r.pattern=o.source},jA=(e,t,n,i)=>{let r=n,o={type:"string",format:"binary",contentEncoding:"binary"},{minimum:s,maximum:a,mime:l}=e._zod.bag;s!==void 0&&(o.minLength=s),a!==void 0&&(o.maxLength=a),l?l.length===1?(o.contentMediaType=l[0],Object.assign(r,o)):(Object.assign(r,o),r.anyOf=l.map(c=>({contentMediaType:c}))):Object.assign(r,o)},LA=(e,t,n,i)=>{n.type="boolean"},MA=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},FA=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},BA=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},GA=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},WA=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},zA=(e,t,n,i)=>{let r=n,o=e._zod.def,{minimum:s,maximum:a}=e._zod.bag;typeof s=="number"&&(r.minItems=s),typeof a=="number"&&(r.maxItems=a),r.type="array",r.items=ht(o.element,t,{...i,path:[...i.path,"items"]})},UA=(e,t,n,i)=>{let r=n,o=e._zod.def;r.type="object",r.properties={};let s=o.shape;for(let c in s)r.properties[c]=ht(s[c],t,{...i,path:[...i.path,"properties",c]});let a=new Set(Object.keys(s)),l=new Set([...a].filter(c=>{let u=o.shape[c]._zod;return t.io==="input"?u.optin===void 0:u.optout===void 0}));l.size>0&&(r.required=Array.from(l)),o.catchall?._zod.def.type==="never"?r.additionalProperties=!1:o.catchall?o.catchall&&(r.additionalProperties=ht(o.catchall,t,{...i,path:[...i.path,"additionalProperties"]})):t.io==="output"&&(r.additionalProperties=!1)},ob=(e,t,n,i)=>{let r=e._zod.def,o=r.inclusive===!1,s=r.options.map((a,l)=>ht(a,t,{...i,path:[...i.path,o?"oneOf":"anyOf",l]}));o?n.oneOf=s:n.anyOf=s},HA=(e,t,n,i)=>{let r=e._zod.def,o=ht(r.left,t,{...i,path:[...i.path,"allOf",0]}),s=ht(r.right,t,{...i,path:[...i.path,"allOf",1]}),a=c=>"allOf"in c&&Object.keys(c).length===1,l=[...a(o)?o.allOf:[o],...a(s)?s.allOf:[s]];n.allOf=l},VA=(e,t,n,i)=>{let r=n,o=e._zod.def;r.type="array";let s=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",l=o.items.map((p,f)=>ht(p,t,{...i,path:[...i.path,s,f]})),c=o.rest?ht(o.rest,t,{...i,path:[...i.path,a,...t.target==="openapi-3.0"?[o.items.length]:[]]}):null;t.target==="draft-2020-12"?(r.prefixItems=l,c&&(r.items=c)):t.target==="openapi-3.0"?(r.items={anyOf:l},c&&r.items.anyOf.push(c),r.minItems=l.length,c||(r.maxItems=l.length)):(r.items=l,c&&(r.additionalItems=c));let{minimum:u,maximum:d}=e._zod.bag;typeof u=="number"&&(r.minItems=u),typeof d=="number"&&(r.maxItems=d)},qA=(e,t,n,i)=>{let r=n,o=e._zod.def;r.type="object";let s=o.keyType,l=s._zod.bag?.patterns;if(o.mode==="loose"&&l&&l.size>0){let u=ht(o.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});r.patternProperties={};for(let d of l)r.patternProperties[d.source]=u}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(r.propertyNames=ht(o.keyType,t,{...i,path:[...i.path,"propertyNames"]})),r.additionalProperties=ht(o.valueType,t,{...i,path:[...i.path,"additionalProperties"]});let c=s._zod.values;if(c){let u=[...c].filter(d=>typeof d=="string"||typeof d=="number");u.length>0&&(r.required=u)}},KA=(e,t,n,i)=>{let r=e._zod.def,o=ht(r.innerType,t,i),s=t.seen.get(e);t.target==="openapi-3.0"?(s.ref=r.innerType,n.nullable=!0):n.anyOf=[o,{type:"null"}]},JA=(e,t,n,i)=>{let r=e._zod.def;ht(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType},ZA=(e,t,n,i)=>{let r=e._zod.def;ht(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType,n.default=JSON.parse(JSON.stringify(r.defaultValue))},YA=(e,t,n,i)=>{let r=e._zod.def;ht(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(r.defaultValue)))},XA=(e,t,n,i)=>{let r=e._zod.def;ht(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType;let s;try{s=r.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=s},QA=(e,t,n,i)=>{let r=e._zod.def,o=t.io==="input"?r.in._zod.def.type==="transform"?r.out:r.in:r.out;ht(o,t,i);let s=t.seen.get(e);s.ref=o},eP=(e,t,n,i)=>{let r=e._zod.def;ht(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType,n.readOnly=!0},tP=(e,t,n,i)=>{let r=e._zod.def;ht(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType},sb=(e,t,n,i)=>{let r=e._zod.def;ht(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType},nP=(e,t,n,i)=>{let r=e._zod.innerType;ht(r,t,i);let o=t.seen.get(e);o.ref=r},ib={string:vA,number:kA,boolean:xA,bigint:$A,symbol:RA,null:SA,undefined:EA,void:AA,never:PA,any:OA,unknown:CA,date:_A,enum:IA,literal:TA,nan:DA,template_literal:NA,file:jA,success:LA,custom:MA,function:FA,transform:BA,map:GA,set:WA,array:zA,object:UA,union:ob,intersection:HA,tuple:VA,record:qA,nullable:KA,nonoptional:JA,default:ZA,prefault:YA,catch:XA,pipe:QA,readonly:eP,promise:tP,optional:sb,lazy:nP}});var cb,QB=v(()=>{of();rf();cb=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let n=t?.target??"draft-2020-12";n==="draft-4"&&(n="draft-04"),n==="draft-7"&&(n="draft-07"),this.ctx=qs({processors:ib,target:n,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,n={path:[],schemaPath:[]}){return ht(t,this.ctx,n)}emit(t,n){n&&(n.cycles&&(this.ctx.cycles=n.cycles),n.reused&&(this.ctx.reused=n.reused),n.external&&(this.ctx.external=n.external)),Ks(this.ctx,t);let i=Js(this.ctx,t),{"~standard":r,...o}=i;return o}}});var eG={};var tG=v(()=>{});var Yo={};_e(Yo,{$ZodAny:()=>JS,$ZodArray:()=>eE,$ZodAsyncError:()=>$i,$ZodBase64:()=>FS,$ZodBase64URL:()=>BS,$ZodBigInt:()=>Sy,$ZodBigIntFormat:()=>HS,$ZodBoolean:()=>Jp,$ZodCIDRv4:()=>jS,$ZodCIDRv6:()=>LS,$ZodCUID:()=>RS,$ZodCUID2:()=>SS,$ZodCatch:()=>bE,$ZodCheck:()=>Et,$ZodCheckBigIntFormat:()=>XR,$ZodCheckEndsWith:()=>uS,$ZodCheckGreaterThan:()=>yy,$ZodCheckIncludes:()=>cS,$ZodCheckLengthEquals:()=>iS,$ZodCheckLessThan:()=>hy,$ZodCheckLowerCase:()=>sS,$ZodCheckMaxLength:()=>nS,$ZodCheckMaxSize:()=>QR,$ZodCheckMimeType:()=>pS,$ZodCheckMinLength:()=>rS,$ZodCheckMinSize:()=>eS,$ZodCheckMultipleOf:()=>ZR,$ZodCheckNumberFormat:()=>YR,$ZodCheckOverwrite:()=>fS,$ZodCheckProperty:()=>dS,$ZodCheckRegex:()=>oS,$ZodCheckSizeEquals:()=>tS,$ZodCheckStartsWith:()=>lS,$ZodCheckStringFormat:()=>Jl,$ZodCheckUpperCase:()=>aS,$ZodCodec:()=>Yp,$ZodCustom:()=>EE,$ZodCustomStringFormat:()=>zS,$ZodDate:()=>QS,$ZodDefault:()=>mE,$ZodDiscriminatedUnion:()=>rE,$ZodE164:()=>GS,$ZodEmail:()=>vS,$ZodEmoji:()=>xS,$ZodEncodeError:()=>Bs,$ZodEnum:()=>cE,$ZodError:()=>zp,$ZodExactOptional:()=>pE,$ZodFile:()=>uE,$ZodFunction:()=>$E,$ZodGUID:()=>bS,$ZodIPv4:()=>TS,$ZodIPv6:()=>DS,$ZodISODate:()=>CS,$ZodISODateTime:()=>OS,$ZodISODuration:()=>IS,$ZodISOTime:()=>_S,$ZodIntersection:()=>iE,$ZodJWT:()=>WS,$ZodKSUID:()=>PS,$ZodLazy:()=>SE,$ZodLiteral:()=>lE,$ZodMAC:()=>NS,$ZodMap:()=>sE,$ZodNaN:()=>wE,$ZodNanoID:()=>$S,$ZodNever:()=>YS,$ZodNonOptional:()=>hE,$ZodNull:()=>KS,$ZodNullable:()=>fE,$ZodNumber:()=>Ry,$ZodNumberFormat:()=>US,$ZodObject:()=>aF,$ZodObjectJIT:()=>tE,$ZodOptional:()=>Ay,$ZodPipe:()=>vE,$ZodPrefault:()=>gE,$ZodPromise:()=>RE,$ZodReadonly:()=>kE,$ZodRealError:()=>pr,$ZodRecord:()=>oE,$ZodRegistry:()=>_y,$ZodSet:()=>aE,$ZodString:()=>fc,$ZodStringFormat:()=>vt,$ZodSuccess:()=>yE,$ZodSymbol:()=>VS,$ZodTemplateLiteral:()=>xE,$ZodTransform:()=>dE,$ZodTuple:()=>Ey,$ZodType:()=>Ne,$ZodULID:()=>ES,$ZodURL:()=>kS,$ZodUUID:()=>wS,$ZodUndefined:()=>qS,$ZodUnion:()=>Zp,$ZodUnknown:()=>ZS,$ZodVoid:()=>XS,$ZodXID:()=>AS,$ZodXor:()=>nE,$brand:()=>ey,$constructor:()=>M,$input:()=>TE,$output:()=>IE,Doc:()=>Kp,JSONSchema:()=>eG,JSONSchemaGenerator:()=>cb,NEVER:()=>oR,TimePrecision:()=>LE,_any:()=>iA,_array:()=>dA,_base64:()=>Jy,_base64url:()=>Zy,_bigint:()=>YE,_boolean:()=>JE,_catch:()=>xie,_check:()=>YB,_cidrv4:()=>qy,_cidrv6:()=>Ky,_coercedBigint:()=>XE,_coercedBoolean:()=>ZE,_coercedDate:()=>lA,_coercedNumber:()=>zE,_coercedString:()=>NE,_cuid:()=>By,_cuid2:()=>Gy,_custom:()=>fA,_date:()=>cA,_decode:()=>sy,_decodeAsync:()=>cy,_default:()=>wie,_discriminatedUnion:()=>aie,_e164:()=>Yy,_email:()=>Ty,_emoji:()=>My,_encode:()=>oy,_encodeAsync:()=>ay,_endsWith:()=>nu,_enum:()=>fie,_file:()=>pA,_float32:()=>HE,_float64:()=>VE,_gt:()=>Xi,_gte:()=>Zn,_guid:()=>tf,_includes:()=>eu,_int:()=>UE,_int32:()=>qE,_int64:()=>QE,_intersection:()=>cie,_ipv4:()=>Hy,_ipv6:()=>Vy,_isoDate:()=>FE,_isoDateTime:()=>ME,_isoDuration:()=>GE,_isoTime:()=>BE,_jwt:()=>Xy,_ksuid:()=>Uy,_lazy:()=>Eie,_length:()=>hc,_literal:()=>gie,_lowercase:()=>Xl,_lt:()=>Yi,_lte:()=>Tr,_mac:()=>jE,_map:()=>die,_max:()=>Tr,_maxLength:()=>gc,_maxSize:()=>Vs,_mime:()=>ru,_min:()=>Zn,_minLength:()=>Zo,_minSize:()=>Qi,_multipleOf:()=>Hs,_nan:()=>uA,_nanoid:()=>Fy,_nativeEnum:()=>mie,_negative:()=>eb,_never:()=>sA,_nonnegative:()=>nb,_nonoptional:()=>vie,_nonpositive:()=>tb,_normalize:()=>iu,_null:()=>rA,_nullable:()=>bie,_number:()=>WE,_optional:()=>yie,_overwrite:()=>Ri,_parse:()=>Hl,_parseAsync:()=>Vl,_pipe:()=>$ie,_positive:()=>Qy,_promise:()=>Aie,_property:()=>rb,_readonly:()=>Rie,_record:()=>uie,_refine:()=>mA,_regex:()=>Yl,_safeDecode:()=>uy,_safeDecodeAsync:()=>py,_safeEncode:()=>ly,_safeEncodeAsync:()=>dy,_safeParse:()=>ql,_safeParseAsync:()=>Kl,_set:()=>pie,_size:()=>mc,_slugify:()=>cu,_startsWith:()=>tu,_string:()=>DE,_stringFormat:()=>lu,_stringbool:()=>bA,_success:()=>kie,_superRefine:()=>gA,_symbol:()=>tA,_templateLiteral:()=>Sie,_toLowerCase:()=>su,_toUpperCase:()=>au,_transform:()=>hie,_trim:()=>ou,_tuple:()=>lie,_uint32:()=>KE,_uint64:()=>eA,_ulid:()=>Wy,_undefined:()=>nA,_union:()=>oie,_unknown:()=>oA,_uppercase:()=>Ql,_url:()=>nf,_uuid:()=>Dy,_uuidv4:()=>Ny,_uuidv6:()=>jy,_uuidv7:()=>Ly,_void:()=>aA,_xid:()=>zy,_xor:()=>sie,clone:()=>Jn,config:()=>Ht,createStandardJSONSchemaMethod:()=>uu,createToJSONSchemaMethod:()=>wA,decode:()=>Cne,decodeAsync:()=>Ine,describe:()=>hA,encode:()=>One,encodeAsync:()=>_ne,extractDefs:()=>Ks,finalize:()=>Js,flattenError:()=>Up,formatError:()=>Hp,globalConfig:()=>jp,globalRegistry:()=>kn,initializeContext:()=>qs,isValidBase64:()=>MS,isValidBase64URL:()=>rF,isValidJWT:()=>iF,locales:()=>Qp,meta:()=>yA,parse:()=>ry,parseAsync:()=>iy,prettifyError:()=>yR,process:()=>ht,regexes:()=>Kr,registry:()=>Iy,safeDecode:()=>Dne,safeDecodeAsync:()=>jne,safeEncode:()=>Tne,safeEncodeAsync:()=>Nne,safeParse:()=>wR,safeParseAsync:()=>vR,toDotPath:()=>F1,toJSONSchema:()=>ab,treeifyError:()=>hR,util:()=>le,version:()=>gS});var fr=v(()=>{Gl();kR();bR();AE();by();hS();Ae();gy();_E();ef();mS();XB();rf();of();QB();tG()});var lb={};_e(lb,{endsWith:()=>nu,gt:()=>Xi,gte:()=>Zn,includes:()=>eu,length:()=>hc,lowercase:()=>Xl,lt:()=>Yi,lte:()=>Tr,maxLength:()=>gc,maxSize:()=>Vs,mime:()=>ru,minLength:()=>Zo,minSize:()=>Qi,multipleOf:()=>Hs,negative:()=>eb,nonnegative:()=>nb,nonpositive:()=>tb,normalize:()=>iu,overwrite:()=>Ri,positive:()=>Qy,property:()=>rb,regex:()=>Yl,size:()=>mc,slugify:()=>cu,startsWith:()=>tu,toLowerCase:()=>su,toUpperCase:()=>au,trim:()=>ou,uppercase:()=>Ql});var ub=v(()=>{fr()});var du={};_e(du,{ZodISODate:()=>pb,ZodISODateTime:()=>db,ZodISODuration:()=>mb,ZodISOTime:()=>fb,date:()=>iP,datetime:()=>rP,duration:()=>sP,time:()=>oP});function rP(e){return ME(db,e)}function iP(e){return FE(pb,e)}function oP(e){return BE(fb,e)}function sP(e){return GE(mb,e)}var db,pb,fb,mb,sf=v(()=>{fr();cf();db=M("ZodISODateTime",(e,t)=>{OS.init(e,t),kt.init(e,t)});pb=M("ZodISODate",(e,t)=>{CS.init(e,t),kt.init(e,t)});fb=M("ZodISOTime",(e,t)=>{_S.init(e,t),kt.init(e,t)});mb=M("ZodISODuration",(e,t)=>{IS.init(e,t),kt.init(e,t)})});var nG,Cie,mr,aP=v(()=>{fr();fr();Ae();nG=(e,t)=>{zp.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Hp(e,n)},flatten:{value:n=>Up(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Wl,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Wl,2)}},isEmpty:{get(){return e.issues.length===0}}})},Cie=M("ZodError",nG),mr=M("ZodError",nG,{Parent:Error})});var cP,lP,uP,dP,pP,fP,mP,gP,hP,yP,bP,wP,vP=v(()=>{fr();aP();cP=Hl(mr),lP=Vl(mr),uP=ql(mr),dP=Kl(mr),pP=oy(mr),fP=sy(mr),mP=ay(mr),gP=cy(mr),hP=ly(mr),yP=uy(mr),bP=dy(mr),wP=py(mr)});var af={};_e(af,{ZodAny:()=>PP,ZodArray:()=>IP,ZodBase64:()=>Cb,ZodBase64URL:()=>_b,ZodBigInt:()=>yu,ZodBigIntFormat:()=>Db,ZodBoolean:()=>hu,ZodCIDRv4:()=>Pb,ZodCIDRv6:()=>Ob,ZodCUID:()=>kb,ZodCUID2:()=>xb,ZodCatch:()=>eO,ZodCodec:()=>Wb,ZodCustom:()=>wf,ZodCustomStringFormat:()=>mu,ZodDate:()=>mf,ZodDefault:()=>KP,ZodDiscriminatedUnion:()=>DP,ZodE164:()=>Ib,ZodEmail:()=>bb,ZodEmoji:()=>wb,ZodEnum:()=>pu,ZodExactOptional:()=>HP,ZodFile:()=>zP,ZodFunction:()=>lO,ZodGUID:()=>lf,ZodIPv4:()=>Eb,ZodIPv6:()=>Ab,ZodIntersection:()=>NP,ZodJWT:()=>Tb,ZodKSUID:()=>Sb,ZodLazy:()=>sO,ZodLiteral:()=>WP,ZodMAC:()=>kP,ZodMap:()=>BP,ZodNaN:()=>nO,ZodNanoID:()=>vb,ZodNever:()=>CP,ZodNonOptional:()=>Bb,ZodNull:()=>EP,ZodNullable:()=>qP,ZodNumber:()=>gu,ZodNumberFormat:()=>bc,ZodObject:()=>hf,ZodOptional:()=>Fb,ZodPipe:()=>Gb,ZodPrefault:()=>ZP,ZodPromise:()=>cO,ZodReadonly:()=>rO,ZodRecord:()=>bf,ZodSet:()=>GP,ZodString:()=>fu,ZodStringFormat:()=>kt,ZodSuccess:()=>QP,ZodSymbol:()=>RP,ZodTemplateLiteral:()=>oO,ZodTransform:()=>UP,ZodTuple:()=>LP,ZodType:()=>Ge,ZodULID:()=>$b,ZodURL:()=>ff,ZodUUID:()=>eo,ZodUndefined:()=>SP,ZodUnion:()=>yf,ZodUnknown:()=>OP,ZodVoid:()=>_P,ZodXID:()=>Rb,ZodXor:()=>TP,_ZodString:()=>yb,_default:()=>JP,_function:()=>cW,any:()=>BG,array:()=>gf,base64:()=>$G,base64url:()=>RG,bigint:()=>NG,boolean:()=>$P,catch:()=>tO,check:()=>lW,cidrv4:()=>kG,cidrv6:()=>xG,codec:()=>oW,cuid:()=>fG,cuid2:()=>mG,custom:()=>uW,date:()=>WG,describe:()=>dW,discriminatedUnion:()=>KG,e164:()=>SG,email:()=>rG,emoji:()=>dG,enum:()=>Lb,exactOptional:()=>VP,file:()=>tW,float32:()=>_G,float64:()=>IG,function:()=>cW,guid:()=>iG,hash:()=>CG,hex:()=>OG,hostname:()=>PG,httpUrl:()=>uG,instanceof:()=>fW,int:()=>hb,int32:()=>TG,int64:()=>jG,intersection:()=>jP,ipv4:()=>bG,ipv6:()=>vG,json:()=>gW,jwt:()=>EG,keyof:()=>zG,ksuid:()=>yG,lazy:()=>aO,literal:()=>eW,looseObject:()=>VG,looseRecord:()=>ZG,mac:()=>wG,map:()=>YG,meta:()=>pW,nan:()=>iW,nanoid:()=>pG,nativeEnum:()=>QG,never:()=>Nb,nonoptional:()=>XP,null:()=>AP,nullable:()=>df,nullish:()=>nW,number:()=>xP,object:()=>UG,optional:()=>uf,partialRecord:()=>JG,pipe:()=>pf,prefault:()=>YP,preprocess:()=>hW,promise:()=>aW,readonly:()=>iO,record:()=>FP,refine:()=>uO,set:()=>XG,strictObject:()=>HG,string:()=>gb,stringFormat:()=>AG,stringbool:()=>mW,success:()=>rW,superRefine:()=>dO,symbol:()=>MG,templateLiteral:()=>sW,transform:()=>Mb,tuple:()=>MP,uint32:()=>DG,uint64:()=>LG,ulid:()=>gG,undefined:()=>FG,union:()=>jb,unknown:()=>yc,url:()=>lG,uuid:()=>oG,uuidv4:()=>sG,uuidv6:()=>aG,uuidv7:()=>cG,void:()=>GG,xid:()=>hG,xor:()=>qG});function gb(e){return DE(fu,e)}function rG(e){return Ty(bb,e)}function iG(e){return tf(lf,e)}function oG(e){return Dy(eo,e)}function sG(e){return Ny(eo,e)}function aG(e){return jy(eo,e)}function cG(e){return Ly(eo,e)}function lG(e){return nf(ff,e)}function uG(e){return nf(ff,{protocol:/^https?$/,hostname:Kr.domain,...le.normalizeParams(e)})}function dG(e){return My(wb,e)}function pG(e){return Fy(vb,e)}function fG(e){return By(kb,e)}function mG(e){return Gy(xb,e)}function gG(e){return Wy($b,e)}function hG(e){return zy(Rb,e)}function yG(e){return Uy(Sb,e)}function bG(e){return Hy(Eb,e)}function wG(e){return jE(kP,e)}function vG(e){return Vy(Ab,e)}function kG(e){return qy(Pb,e)}function xG(e){return Ky(Ob,e)}function $G(e){return Jy(Cb,e)}function RG(e){return Zy(_b,e)}function SG(e){return Yy(Ib,e)}function EG(e){return Xy(Tb,e)}function AG(e,t,n={}){return lu(mu,e,t,n)}function PG(e){return lu(mu,"hostname",Kr.hostname,e)}function OG(e){return lu(mu,"hex",Kr.hex,e)}function CG(e,t){let n=t?.enc??"hex",i=`${e}_${n}`,r=Kr[i];if(!r)throw new Error(`Unrecognized hash format: ${i}`);return lu(mu,i,r,t)}function xP(e){return WE(gu,e)}function hb(e){return UE(bc,e)}function _G(e){return HE(bc,e)}function IG(e){return VE(bc,e)}function TG(e){return qE(bc,e)}function DG(e){return KE(bc,e)}function $P(e){return JE(hu,e)}function NG(e){return YE(yu,e)}function jG(e){return QE(Db,e)}function LG(e){return eA(Db,e)}function MG(e){return tA(RP,e)}function FG(e){return nA(SP,e)}function AP(e){return rA(EP,e)}function BG(){return iA(PP)}function yc(){return oA(OP)}function Nb(e){return sA(CP,e)}function GG(e){return aA(_P,e)}function WG(e){return cA(mf,e)}function gf(e,t){return dA(IP,e,t)}function zG(e){let t=e._zod.def.shape;return Lb(Object.keys(t))}function UG(e,t){let n={type:"object",shape:e??{},...le.normalizeParams(t)};return new hf(n)}function HG(e,t){return new hf({type:"object",shape:e,catchall:Nb(),...le.normalizeParams(t)})}function VG(e,t){return new hf({type:"object",shape:e,catchall:yc(),...le.normalizeParams(t)})}function jb(e,t){return new yf({type:"union",options:e,...le.normalizeParams(t)})}function qG(e,t){return new TP({type:"union",options:e,inclusive:!1,...le.normalizeParams(t)})}function KG(e,t,n){return new DP({type:"union",options:t,discriminator:e,...le.normalizeParams(n)})}function jP(e,t){return new NP({type:"intersection",left:e,right:t})}function MP(e,t,n){let i=t instanceof Ne,r=i?n:t,o=i?t:null;return new LP({type:"tuple",items:e,rest:o,...le.normalizeParams(r)})}function FP(e,t,n){return new bf({type:"record",keyType:e,valueType:t,...le.normalizeParams(n)})}function JG(e,t,n){let i=Jn(e);return i._zod.values=void 0,new bf({type:"record",keyType:i,valueType:t,...le.normalizeParams(n)})}function ZG(e,t,n){return new bf({type:"record",keyType:e,valueType:t,mode:"loose",...le.normalizeParams(n)})}function YG(e,t,n){return new BP({type:"map",keyType:e,valueType:t,...le.normalizeParams(n)})}function XG(e,t){return new GP({type:"set",valueType:e,...le.normalizeParams(t)})}function Lb(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(i=>[i,i])):e;return new pu({type:"enum",entries:n,...le.normalizeParams(t)})}function QG(e,t){return new pu({type:"enum",entries:e,...le.normalizeParams(t)})}function eW(e,t){return new WP({type:"literal",values:Array.isArray(e)?e:[e],...le.normalizeParams(t)})}function tW(e){return pA(zP,e)}function Mb(e){return new UP({type:"transform",transform:e})}function uf(e){return new Fb({type:"optional",innerType:e})}function VP(e){return new HP({type:"optional",innerType:e})}function df(e){return new qP({type:"nullable",innerType:e})}function nW(e){return uf(df(e))}function JP(e,t){return new KP({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():le.shallowClone(t)}})}function YP(e,t){return new ZP({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():le.shallowClone(t)}})}function XP(e,t){return new Bb({type:"nonoptional",innerType:e,...le.normalizeParams(t)})}function rW(e){return new QP({type:"success",innerType:e})}function tO(e,t){return new eO({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}function iW(e){return uA(nO,e)}function pf(e,t){return new Gb({type:"pipe",in:e,out:t})}function oW(e,t,n){return new Wb({type:"pipe",in:e,out:t,transform:n.decode,reverseTransform:n.encode})}function iO(e){return new rO({type:"readonly",innerType:e})}function sW(e,t){return new oO({type:"template_literal",parts:e,...le.normalizeParams(t)})}function aO(e){return new sO({type:"lazy",getter:e})}function aW(e){return new cO({type:"promise",innerType:e})}function cW(e){return new lO({type:"function",input:Array.isArray(e?.input)?MP(e?.input):e?.input??gf(yc()),output:e?.output??yc()})}function lW(e){let t=new Et({check:"custom"});return t._zod.check=e,t}function uW(e,t){return fA(wf,e??(()=>!0),t)}function uO(e,t={}){return mA(wf,e,t)}function dO(e){return gA(e)}function fW(e,t={}){let n=new wf({type:"custom",check:"custom",fn:i=>i instanceof e,abort:!0,...le.normalizeParams(t)});return n._zod.bag.Class=e,n._zod.check=i=>{i.value instanceof e||i.issues.push({code:"invalid_type",expected:e.name,input:i.value,inst:n,path:[...n._zod.def.path??[]]})},n}function gW(e){let t=aO(()=>jb([gb(e),xP(),$P(),AP(),gf(t),FP(gb(),t)]));return t}function hW(e,t){return pf(Mb(e),t)}var Ge,yb,fu,kt,bb,lf,eo,ff,wb,vb,kb,xb,$b,Rb,Sb,Eb,kP,Ab,Pb,Ob,Cb,_b,Ib,Tb,mu,gu,bc,hu,yu,Db,RP,SP,EP,PP,OP,CP,_P,mf,IP,hf,yf,TP,DP,NP,LP,bf,BP,GP,pu,WP,zP,UP,Fb,HP,qP,KP,ZP,Bb,QP,eO,nO,Gb,Wb,rO,oO,sO,cO,lO,wf,dW,pW,mW,cf=v(()=>{fr();fr();of();rf();ub();sf();vP();Ge=M("ZodType",(e,t)=>(Ne.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:uu(e,"input"),output:uu(e,"output")}}),e.toJSONSchema=wA(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(le.mergeDefs(t,{checks:[...t.checks??[],...n.map(i=>typeof i=="function"?{_zod:{check:i,def:{check:"custom"},onattach:[]}}:i)]}),{parent:!0}),e.with=e.check,e.clone=(n,i)=>Jn(e,n,i),e.brand=()=>e,e.register=((n,i)=>(n.add(e,i),e)),e.parse=(n,i)=>cP(e,n,i,{callee:e.parse}),e.safeParse=(n,i)=>uP(e,n,i),e.parseAsync=async(n,i)=>lP(e,n,i,{callee:e.parseAsync}),e.safeParseAsync=async(n,i)=>dP(e,n,i),e.spa=e.safeParseAsync,e.encode=(n,i)=>pP(e,n,i),e.decode=(n,i)=>fP(e,n,i),e.encodeAsync=async(n,i)=>mP(e,n,i),e.decodeAsync=async(n,i)=>gP(e,n,i),e.safeEncode=(n,i)=>hP(e,n,i),e.safeDecode=(n,i)=>yP(e,n,i),e.safeEncodeAsync=async(n,i)=>bP(e,n,i),e.safeDecodeAsync=async(n,i)=>wP(e,n,i),e.refine=(n,i)=>e.check(uO(n,i)),e.superRefine=n=>e.check(dO(n)),e.overwrite=n=>e.check(Ri(n)),e.optional=()=>uf(e),e.exactOptional=()=>VP(e),e.nullable=()=>df(e),e.nullish=()=>uf(df(e)),e.nonoptional=n=>XP(e,n),e.array=()=>gf(e),e.or=n=>jb([e,n]),e.and=n=>jP(e,n),e.transform=n=>pf(e,Mb(n)),e.default=n=>JP(e,n),e.prefault=n=>YP(e,n),e.catch=n=>tO(e,n),e.pipe=n=>pf(e,n),e.readonly=()=>iO(e),e.describe=n=>{let i=e.clone();return kn.add(i,{description:n}),i},Object.defineProperty(e,"description",{get(){return kn.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return kn.get(e);let i=e.clone();return kn.add(i,n[0]),i},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),yb=M("_ZodString",(e,t)=>{fc.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(i,r,o)=>vA(e,i,r,o);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...i)=>e.check(Yl(...i)),e.includes=(...i)=>e.check(eu(...i)),e.startsWith=(...i)=>e.check(tu(...i)),e.endsWith=(...i)=>e.check(nu(...i)),e.min=(...i)=>e.check(Zo(...i)),e.max=(...i)=>e.check(gc(...i)),e.length=(...i)=>e.check(hc(...i)),e.nonempty=(...i)=>e.check(Zo(1,...i)),e.lowercase=i=>e.check(Xl(i)),e.uppercase=i=>e.check(Ql(i)),e.trim=()=>e.check(ou()),e.normalize=(...i)=>e.check(iu(...i)),e.toLowerCase=()=>e.check(su()),e.toUpperCase=()=>e.check(au()),e.slugify=()=>e.check(cu())}),fu=M("ZodString",(e,t)=>{fc.init(e,t),yb.init(e,t),e.email=n=>e.check(Ty(bb,n)),e.url=n=>e.check(nf(ff,n)),e.jwt=n=>e.check(Xy(Tb,n)),e.emoji=n=>e.check(My(wb,n)),e.guid=n=>e.check(tf(lf,n)),e.uuid=n=>e.check(Dy(eo,n)),e.uuidv4=n=>e.check(Ny(eo,n)),e.uuidv6=n=>e.check(jy(eo,n)),e.uuidv7=n=>e.check(Ly(eo,n)),e.nanoid=n=>e.check(Fy(vb,n)),e.guid=n=>e.check(tf(lf,n)),e.cuid=n=>e.check(By(kb,n)),e.cuid2=n=>e.check(Gy(xb,n)),e.ulid=n=>e.check(Wy($b,n)),e.base64=n=>e.check(Jy(Cb,n)),e.base64url=n=>e.check(Zy(_b,n)),e.xid=n=>e.check(zy(Rb,n)),e.ksuid=n=>e.check(Uy(Sb,n)),e.ipv4=n=>e.check(Hy(Eb,n)),e.ipv6=n=>e.check(Vy(Ab,n)),e.cidrv4=n=>e.check(qy(Pb,n)),e.cidrv6=n=>e.check(Ky(Ob,n)),e.e164=n=>e.check(Yy(Ib,n)),e.datetime=n=>e.check(rP(n)),e.date=n=>e.check(iP(n)),e.time=n=>e.check(oP(n)),e.duration=n=>e.check(sP(n))});kt=M("ZodStringFormat",(e,t)=>{vt.init(e,t),yb.init(e,t)}),bb=M("ZodEmail",(e,t)=>{vS.init(e,t),kt.init(e,t)});lf=M("ZodGUID",(e,t)=>{bS.init(e,t),kt.init(e,t)});eo=M("ZodUUID",(e,t)=>{wS.init(e,t),kt.init(e,t)});ff=M("ZodURL",(e,t)=>{kS.init(e,t),kt.init(e,t)});wb=M("ZodEmoji",(e,t)=>{xS.init(e,t),kt.init(e,t)});vb=M("ZodNanoID",(e,t)=>{$S.init(e,t),kt.init(e,t)});kb=M("ZodCUID",(e,t)=>{RS.init(e,t),kt.init(e,t)});xb=M("ZodCUID2",(e,t)=>{SS.init(e,t),kt.init(e,t)});$b=M("ZodULID",(e,t)=>{ES.init(e,t),kt.init(e,t)});Rb=M("ZodXID",(e,t)=>{AS.init(e,t),kt.init(e,t)});Sb=M("ZodKSUID",(e,t)=>{PS.init(e,t),kt.init(e,t)});Eb=M("ZodIPv4",(e,t)=>{TS.init(e,t),kt.init(e,t)});kP=M("ZodMAC",(e,t)=>{NS.init(e,t),kt.init(e,t)});Ab=M("ZodIPv6",(e,t)=>{DS.init(e,t),kt.init(e,t)});Pb=M("ZodCIDRv4",(e,t)=>{jS.init(e,t),kt.init(e,t)});Ob=M("ZodCIDRv6",(e,t)=>{LS.init(e,t),kt.init(e,t)});Cb=M("ZodBase64",(e,t)=>{FS.init(e,t),kt.init(e,t)});_b=M("ZodBase64URL",(e,t)=>{BS.init(e,t),kt.init(e,t)});Ib=M("ZodE164",(e,t)=>{GS.init(e,t),kt.init(e,t)});Tb=M("ZodJWT",(e,t)=>{WS.init(e,t),kt.init(e,t)});mu=M("ZodCustomStringFormat",(e,t)=>{zS.init(e,t),kt.init(e,t)});gu=M("ZodNumber",(e,t)=>{Ry.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(i,r,o)=>kA(e,i,r,o),e.gt=(i,r)=>e.check(Xi(i,r)),e.gte=(i,r)=>e.check(Zn(i,r)),e.min=(i,r)=>e.check(Zn(i,r)),e.lt=(i,r)=>e.check(Yi(i,r)),e.lte=(i,r)=>e.check(Tr(i,r)),e.max=(i,r)=>e.check(Tr(i,r)),e.int=i=>e.check(hb(i)),e.safe=i=>e.check(hb(i)),e.positive=i=>e.check(Xi(0,i)),e.nonnegative=i=>e.check(Zn(0,i)),e.negative=i=>e.check(Yi(0,i)),e.nonpositive=i=>e.check(Tr(0,i)),e.multipleOf=(i,r)=>e.check(Hs(i,r)),e.step=(i,r)=>e.check(Hs(i,r)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});bc=M("ZodNumberFormat",(e,t)=>{US.init(e,t),gu.init(e,t)});hu=M("ZodBoolean",(e,t)=>{Jp.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>xA(e,n,i,r)});yu=M("ZodBigInt",(e,t)=>{Sy.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(i,r,o)=>$A(e,i,r,o),e.gte=(i,r)=>e.check(Zn(i,r)),e.min=(i,r)=>e.check(Zn(i,r)),e.gt=(i,r)=>e.check(Xi(i,r)),e.gte=(i,r)=>e.check(Zn(i,r)),e.min=(i,r)=>e.check(Zn(i,r)),e.lt=(i,r)=>e.check(Yi(i,r)),e.lte=(i,r)=>e.check(Tr(i,r)),e.max=(i,r)=>e.check(Tr(i,r)),e.positive=i=>e.check(Xi(BigInt(0),i)),e.negative=i=>e.check(Yi(BigInt(0),i)),e.nonpositive=i=>e.check(Tr(BigInt(0),i)),e.nonnegative=i=>e.check(Zn(BigInt(0),i)),e.multipleOf=(i,r)=>e.check(Hs(i,r));let n=e._zod.bag;e.minValue=n.minimum??null,e.maxValue=n.maximum??null,e.format=n.format??null});Db=M("ZodBigIntFormat",(e,t)=>{HS.init(e,t),yu.init(e,t)});RP=M("ZodSymbol",(e,t)=>{VS.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>RA(e,n,i,r)});SP=M("ZodUndefined",(e,t)=>{qS.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>EA(e,n,i,r)});EP=M("ZodNull",(e,t)=>{KS.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>SA(e,n,i,r)});PP=M("ZodAny",(e,t)=>{JS.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>OA(e,n,i,r)});OP=M("ZodUnknown",(e,t)=>{ZS.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>CA(e,n,i,r)});CP=M("ZodNever",(e,t)=>{YS.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>PA(e,n,i,r)});_P=M("ZodVoid",(e,t)=>{XS.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>AA(e,n,i,r)});mf=M("ZodDate",(e,t)=>{QS.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(i,r,o)=>_A(e,i,r,o),e.min=(i,r)=>e.check(Zn(i,r)),e.max=(i,r)=>e.check(Tr(i,r));let n=e._zod.bag;e.minDate=n.minimum?new Date(n.minimum):null,e.maxDate=n.maximum?new Date(n.maximum):null});IP=M("ZodArray",(e,t)=>{eE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>zA(e,n,i,r),e.element=t.element,e.min=(n,i)=>e.check(Zo(n,i)),e.nonempty=n=>e.check(Zo(1,n)),e.max=(n,i)=>e.check(gc(n,i)),e.length=(n,i)=>e.check(hc(n,i)),e.unwrap=()=>e.element});hf=M("ZodObject",(e,t)=>{tE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>UA(e,n,i,r),le.defineLazy(e,"shape",()=>t.shape),e.keyof=()=>Lb(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:yc()}),e.loose=()=>e.clone({...e._zod.def,catchall:yc()}),e.strict=()=>e.clone({...e._zod.def,catchall:Nb()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>le.extend(e,n),e.safeExtend=n=>le.safeExtend(e,n),e.merge=n=>le.merge(e,n),e.pick=n=>le.pick(e,n),e.omit=n=>le.omit(e,n),e.partial=(...n)=>le.partial(Fb,e,n[0]),e.required=(...n)=>le.required(Bb,e,n[0])});yf=M("ZodUnion",(e,t)=>{Zp.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>ob(e,n,i,r),e.options=t.options});TP=M("ZodXor",(e,t)=>{yf.init(e,t),nE.init(e,t),e._zod.processJSONSchema=(n,i,r)=>ob(e,n,i,r),e.options=t.options});DP=M("ZodDiscriminatedUnion",(e,t)=>{yf.init(e,t),rE.init(e,t)});NP=M("ZodIntersection",(e,t)=>{iE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>HA(e,n,i,r)});LP=M("ZodTuple",(e,t)=>{Ey.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>VA(e,n,i,r),e.rest=n=>e.clone({...e._zod.def,rest:n})});bf=M("ZodRecord",(e,t)=>{oE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>qA(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType});BP=M("ZodMap",(e,t)=>{sE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>GA(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...n)=>e.check(Qi(...n)),e.nonempty=n=>e.check(Qi(1,n)),e.max=(...n)=>e.check(Vs(...n)),e.size=(...n)=>e.check(mc(...n))});GP=M("ZodSet",(e,t)=>{aE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>WA(e,n,i,r),e.min=(...n)=>e.check(Qi(...n)),e.nonempty=n=>e.check(Qi(1,n)),e.max=(...n)=>e.check(Vs(...n)),e.size=(...n)=>e.check(mc(...n))});pu=M("ZodEnum",(e,t)=>{cE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(i,r,o)=>IA(e,i,r,o),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(i,r)=>{let o={};for(let s of i)if(n.has(s))o[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new pu({...t,checks:[],...le.normalizeParams(r),entries:o})},e.exclude=(i,r)=>{let o={...t.entries};for(let s of i)if(n.has(s))delete o[s];else throw new Error(`Key ${s} not found in enum`);return new pu({...t,checks:[],...le.normalizeParams(r),entries:o})}});WP=M("ZodLiteral",(e,t)=>{lE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>TA(e,n,i,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});zP=M("ZodFile",(e,t)=>{uE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>jA(e,n,i,r),e.min=(n,i)=>e.check(Qi(n,i)),e.max=(n,i)=>e.check(Vs(n,i)),e.mime=(n,i)=>e.check(ru(Array.isArray(n)?n:[n],i))});UP=M("ZodTransform",(e,t)=>{dE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>BA(e,n,i,r),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new Bs(e.constructor.name);n.addIssue=o=>{if(typeof o=="string")n.issues.push(le.issue(o,n.value,t));else{let s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=n.value),s.inst??(s.inst=e),n.issues.push(le.issue(s))}};let r=t.transform(n.value,n);return r instanceof Promise?r.then(o=>(n.value=o,n)):(n.value=r,n)}});Fb=M("ZodOptional",(e,t)=>{Ay.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>sb(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});HP=M("ZodExactOptional",(e,t)=>{pE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>sb(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});qP=M("ZodNullable",(e,t)=>{fE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>KA(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});KP=M("ZodDefault",(e,t)=>{mE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>ZA(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});ZP=M("ZodPrefault",(e,t)=>{gE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>YA(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});Bb=M("ZodNonOptional",(e,t)=>{hE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>JA(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});QP=M("ZodSuccess",(e,t)=>{yE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>LA(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});eO=M("ZodCatch",(e,t)=>{bE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>XA(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});nO=M("ZodNaN",(e,t)=>{wE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>DA(e,n,i,r)});Gb=M("ZodPipe",(e,t)=>{vE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>QA(e,n,i,r),e.in=t.in,e.out=t.out});Wb=M("ZodCodec",(e,t)=>{Gb.init(e,t),Yp.init(e,t)});rO=M("ZodReadonly",(e,t)=>{kE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>eP(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});oO=M("ZodTemplateLiteral",(e,t)=>{xE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>NA(e,n,i,r)});sO=M("ZodLazy",(e,t)=>{SE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>nP(e,n,i,r),e.unwrap=()=>e._zod.def.getter()});cO=M("ZodPromise",(e,t)=>{RE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>tP(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});lO=M("ZodFunction",(e,t)=>{$E.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>FA(e,n,i,r)});wf=M("ZodCustom",(e,t)=>{EE.init(e,t),Ge.init(e,t),e._zod.processJSONSchema=(n,i,r)=>MA(e,n,i,r)});dW=hA,pW=yA;mW=(...e)=>bA({Codec:Wb,Boolean:hu,String:fu},...e)});function Tie(e){Ht({customError:e})}function Die(){return Ht().customError}var Iie,pO,yW=v(()=>{fr();fr();Iie={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};pO||(pO={})});function jie(e,t){let n=e.$schema;return n==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":n==="http://json-schema.org/draft-07/schema#"?"draft-7":n==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function Lie(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let n=e.slice(1).split("/").filter(Boolean);if(n.length===0)return t.rootSchema;let i=t.version==="draft-2020-12"?"$defs":"definitions";if(n[0]===i){let r=n[1];if(!r||!t.defs[r])throw new Error(`Reference not found: ${e}`);return t.defs[r]}throw new Error(`Reference not found: ${e}`)}function bW(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return ge.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let r=e.$ref;if(t.refs.has(r))return t.refs.get(r);if(t.processing.has(r))return ge.lazy(()=>{if(!t.refs.has(r))throw new Error(`Circular reference not resolved: ${r}`);return t.refs.get(r)});t.processing.add(r);let o=Lie(r,t),s=jn(o,t);return t.refs.set(r,s),t.processing.delete(r),s}if(e.enum!==void 0){let r=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&r.length===1&&r[0]===null)return ge.null();if(r.length===0)return ge.never();if(r.length===1)return ge.literal(r[0]);if(r.every(s=>typeof s=="string"))return ge.enum(r);let o=r.map(s=>ge.literal(s));return o.length<2?o[0]:ge.union([o[0],o[1],...o.slice(2)])}if(e.const!==void 0)return ge.literal(e.const);let n=e.type;if(Array.isArray(n)){let r=n.map(o=>{let s={...e,type:o};return bW(s,t)});return r.length===0?ge.never():r.length===1?r[0]:ge.union(r)}if(!n)return ge.any();let i;switch(n){case"string":{let r=ge.string();if(e.format){let o=e.format;o==="email"?r=r.check(ge.email()):o==="uri"||o==="uri-reference"?r=r.check(ge.url()):o==="uuid"||o==="guid"?r=r.check(ge.uuid()):o==="date-time"?r=r.check(ge.iso.datetime()):o==="date"?r=r.check(ge.iso.date()):o==="time"?r=r.check(ge.iso.time()):o==="duration"?r=r.check(ge.iso.duration()):o==="ipv4"?r=r.check(ge.ipv4()):o==="ipv6"?r=r.check(ge.ipv6()):o==="mac"?r=r.check(ge.mac()):o==="cidr"?r=r.check(ge.cidrv4()):o==="cidr-v6"?r=r.check(ge.cidrv6()):o==="base64"?r=r.check(ge.base64()):o==="base64url"?r=r.check(ge.base64url()):o==="e164"?r=r.check(ge.e164()):o==="jwt"?r=r.check(ge.jwt()):o==="emoji"?r=r.check(ge.emoji()):o==="nanoid"?r=r.check(ge.nanoid()):o==="cuid"?r=r.check(ge.cuid()):o==="cuid2"?r=r.check(ge.cuid2()):o==="ulid"?r=r.check(ge.ulid()):o==="xid"?r=r.check(ge.xid()):o==="ksuid"&&(r=r.check(ge.ksuid()))}typeof e.minLength=="number"&&(r=r.min(e.minLength)),typeof e.maxLength=="number"&&(r=r.max(e.maxLength)),e.pattern&&(r=r.regex(new RegExp(e.pattern))),i=r;break}case"number":case"integer":{let r=n==="integer"?ge.number().int():ge.number();typeof e.minimum=="number"&&(r=r.min(e.minimum)),typeof e.maximum=="number"&&(r=r.max(e.maximum)),typeof e.exclusiveMinimum=="number"?r=r.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(r=r.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?r=r.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(r=r.lt(e.maximum)),typeof e.multipleOf=="number"&&(r=r.multipleOf(e.multipleOf)),i=r;break}case"boolean":{i=ge.boolean();break}case"null":{i=ge.null();break}case"object":{let r={},o=e.properties||{},s=new Set(e.required||[]);for(let[l,c]of Object.entries(o)){let u=jn(c,t);r[l]=s.has(l)?u:u.optional()}if(e.propertyNames){let l=jn(e.propertyNames,t),c=e.additionalProperties&&typeof e.additionalProperties=="object"?jn(e.additionalProperties,t):ge.any();if(Object.keys(r).length===0){i=ge.record(l,c);break}let u=ge.object(r).passthrough(),d=ge.looseRecord(l,c);i=ge.intersection(u,d);break}if(e.patternProperties){let l=e.patternProperties,c=Object.keys(l),u=[];for(let p of c){let f=jn(l[p],t),g=ge.string().regex(new RegExp(p));u.push(ge.looseRecord(g,f))}let d=[];if(Object.keys(r).length>0&&d.push(ge.object(r).passthrough()),d.push(...u),d.length===0)i=ge.object({}).passthrough();else if(d.length===1)i=d[0];else{let p=ge.intersection(d[0],d[1]);for(let f=2;f<d.length;f++)p=ge.intersection(p,d[f]);i=p}break}let a=ge.object(r);e.additionalProperties===!1?i=a.strict():typeof e.additionalProperties=="object"?i=a.catchall(jn(e.additionalProperties,t)):i=a.passthrough();break}case"array":{let r=e.prefixItems,o=e.items;if(r&&Array.isArray(r)){let s=r.map(l=>jn(l,t)),a=o&&typeof o=="object"&&!Array.isArray(o)?jn(o,t):void 0;a?i=ge.tuple(s).rest(a):i=ge.tuple(s),typeof e.minItems=="number"&&(i=i.check(ge.minLength(e.minItems))),typeof e.maxItems=="number"&&(i=i.check(ge.maxLength(e.maxItems)))}else if(Array.isArray(o)){let s=o.map(l=>jn(l,t)),a=e.additionalItems&&typeof e.additionalItems=="object"?jn(e.additionalItems,t):void 0;a?i=ge.tuple(s).rest(a):i=ge.tuple(s),typeof e.minItems=="number"&&(i=i.check(ge.minLength(e.minItems))),typeof e.maxItems=="number"&&(i=i.check(ge.maxLength(e.maxItems)))}else if(o!==void 0){let s=jn(o,t),a=ge.array(s);typeof e.minItems=="number"&&(a=a.min(e.minItems)),typeof e.maxItems=="number"&&(a=a.max(e.maxItems)),i=a}else i=ge.array(ge.any());break}default:throw new Error(`Unsupported type: ${n}`)}return e.description&&(i=i.describe(e.description)),e.default!==void 0&&(i=i.default(e.default)),i}function jn(e,t){if(typeof e=="boolean")return e?ge.any():ge.never();let n=bW(e,t),i=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let a=e.anyOf.map(c=>jn(c,t)),l=ge.union(a);n=i?ge.intersection(n,l):l}if(e.oneOf&&Array.isArray(e.oneOf)){let a=e.oneOf.map(c=>jn(c,t)),l=ge.xor(a);n=i?ge.intersection(n,l):l}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)n=i?n:ge.any();else{let a=i?n:jn(e.allOf[0],t),l=i?0:1;for(let c=l;c<e.allOf.length;c++)a=ge.intersection(a,jn(e.allOf[c],t));n=a}e.nullable===!0&&t.version==="openapi-3.0"&&(n=ge.nullable(n)),e.readOnly===!0&&(n=ge.readonly(n));let r={},o=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let a of o)a in e&&(r[a]=e[a]);let s=["contentEncoding","contentMediaType","contentSchema"];for(let a of s)a in e&&(r[a]=e[a]);for(let a of Object.keys(e))Nie.has(a)||(r[a]=e[a]);return Object.keys(r).length>0&&t.registry.add(n,r),n}function wW(e,t){if(typeof e=="boolean")return e?ge.any():ge.never();let n=jie(e,t?.defaultTarget),i=e.$defs||e.definitions||{},r={version:n,defs:i,refs:new Map,processing:new Set,rootSchema:e,registry:t?.registry??kn};return jn(e,r)}var ge,Nie,vW=v(()=>{ef();ub();sf();cf();ge={...af,...lb,iso:du},Nie=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"])});var fO={};_e(fO,{bigint:()=>Gie,boolean:()=>Bie,date:()=>Wie,number:()=>Fie,string:()=>Mie});function Mie(e){return NE(fu,e)}function Fie(e){return zE(gu,e)}function Bie(e){return ZE(hu,e)}function Gie(e){return XE(yu,e)}function Wie(e){return lA(mf,e)}var kW=v(()=>{fr();cf()});var m={};_e(m,{$brand:()=>ey,$input:()=>TE,$output:()=>IE,NEVER:()=>oR,TimePrecision:()=>LE,ZodAny:()=>PP,ZodArray:()=>IP,ZodBase64:()=>Cb,ZodBase64URL:()=>_b,ZodBigInt:()=>yu,ZodBigIntFormat:()=>Db,ZodBoolean:()=>hu,ZodCIDRv4:()=>Pb,ZodCIDRv6:()=>Ob,ZodCUID:()=>kb,ZodCUID2:()=>xb,ZodCatch:()=>eO,ZodCodec:()=>Wb,ZodCustom:()=>wf,ZodCustomStringFormat:()=>mu,ZodDate:()=>mf,ZodDefault:()=>KP,ZodDiscriminatedUnion:()=>DP,ZodE164:()=>Ib,ZodEmail:()=>bb,ZodEmoji:()=>wb,ZodEnum:()=>pu,ZodError:()=>Cie,ZodExactOptional:()=>HP,ZodFile:()=>zP,ZodFirstPartyTypeKind:()=>pO,ZodFunction:()=>lO,ZodGUID:()=>lf,ZodIPv4:()=>Eb,ZodIPv6:()=>Ab,ZodISODate:()=>pb,ZodISODateTime:()=>db,ZodISODuration:()=>mb,ZodISOTime:()=>fb,ZodIntersection:()=>NP,ZodIssueCode:()=>Iie,ZodJWT:()=>Tb,ZodKSUID:()=>Sb,ZodLazy:()=>sO,ZodLiteral:()=>WP,ZodMAC:()=>kP,ZodMap:()=>BP,ZodNaN:()=>nO,ZodNanoID:()=>vb,ZodNever:()=>CP,ZodNonOptional:()=>Bb,ZodNull:()=>EP,ZodNullable:()=>qP,ZodNumber:()=>gu,ZodNumberFormat:()=>bc,ZodObject:()=>hf,ZodOptional:()=>Fb,ZodPipe:()=>Gb,ZodPrefault:()=>ZP,ZodPromise:()=>cO,ZodReadonly:()=>rO,ZodRealError:()=>mr,ZodRecord:()=>bf,ZodSet:()=>GP,ZodString:()=>fu,ZodStringFormat:()=>kt,ZodSuccess:()=>QP,ZodSymbol:()=>RP,ZodTemplateLiteral:()=>oO,ZodTransform:()=>UP,ZodTuple:()=>LP,ZodType:()=>Ge,ZodULID:()=>$b,ZodURL:()=>ff,ZodUUID:()=>eo,ZodUndefined:()=>SP,ZodUnion:()=>yf,ZodUnknown:()=>OP,ZodVoid:()=>_P,ZodXID:()=>Rb,ZodXor:()=>TP,_ZodString:()=>yb,_default:()=>JP,_function:()=>cW,any:()=>BG,array:()=>gf,base64:()=>$G,base64url:()=>RG,bigint:()=>NG,boolean:()=>$P,catch:()=>tO,check:()=>lW,cidrv4:()=>kG,cidrv6:()=>xG,clone:()=>Jn,codec:()=>oW,coerce:()=>fO,config:()=>Ht,core:()=>Yo,cuid:()=>fG,cuid2:()=>mG,custom:()=>uW,date:()=>WG,decode:()=>fP,decodeAsync:()=>gP,describe:()=>dW,discriminatedUnion:()=>KG,e164:()=>SG,email:()=>rG,emoji:()=>dG,encode:()=>pP,encodeAsync:()=>mP,endsWith:()=>nu,enum:()=>Lb,exactOptional:()=>VP,file:()=>tW,flattenError:()=>Up,float32:()=>_G,float64:()=>IG,formatError:()=>Hp,fromJSONSchema:()=>wW,function:()=>cW,getErrorMap:()=>Die,globalRegistry:()=>kn,gt:()=>Xi,gte:()=>Zn,guid:()=>iG,hash:()=>CG,hex:()=>OG,hostname:()=>PG,httpUrl:()=>uG,includes:()=>eu,instanceof:()=>fW,int:()=>hb,int32:()=>TG,int64:()=>jG,intersection:()=>jP,ipv4:()=>bG,ipv6:()=>vG,iso:()=>du,json:()=>gW,jwt:()=>EG,keyof:()=>zG,ksuid:()=>yG,lazy:()=>aO,length:()=>hc,literal:()=>eW,locales:()=>Qp,looseObject:()=>VG,looseRecord:()=>ZG,lowercase:()=>Xl,lt:()=>Yi,lte:()=>Tr,mac:()=>wG,map:()=>YG,maxLength:()=>gc,maxSize:()=>Vs,meta:()=>pW,mime:()=>ru,minLength:()=>Zo,minSize:()=>Qi,multipleOf:()=>Hs,nan:()=>iW,nanoid:()=>pG,nativeEnum:()=>QG,negative:()=>eb,never:()=>Nb,nonnegative:()=>nb,nonoptional:()=>XP,nonpositive:()=>tb,normalize:()=>iu,null:()=>AP,nullable:()=>df,nullish:()=>nW,number:()=>xP,object:()=>UG,optional:()=>uf,overwrite:()=>Ri,parse:()=>cP,parseAsync:()=>lP,partialRecord:()=>JG,pipe:()=>pf,positive:()=>Qy,prefault:()=>YP,preprocess:()=>hW,prettifyError:()=>yR,promise:()=>aW,property:()=>rb,readonly:()=>iO,record:()=>FP,refine:()=>uO,regex:()=>Yl,regexes:()=>Kr,registry:()=>Iy,safeDecode:()=>yP,safeDecodeAsync:()=>wP,safeEncode:()=>hP,safeEncodeAsync:()=>bP,safeParse:()=>uP,safeParseAsync:()=>dP,set:()=>XG,setErrorMap:()=>Tie,size:()=>mc,slugify:()=>cu,startsWith:()=>tu,strictObject:()=>HG,string:()=>gb,stringFormat:()=>AG,stringbool:()=>mW,success:()=>rW,superRefine:()=>dO,symbol:()=>MG,templateLiteral:()=>sW,toJSONSchema:()=>ab,toLowerCase:()=>su,toUpperCase:()=>au,transform:()=>Mb,treeifyError:()=>hR,trim:()=>ou,tuple:()=>MP,uint32:()=>DG,uint64:()=>LG,ulid:()=>gG,undefined:()=>FG,union:()=>jb,unknown:()=>yc,uppercase:()=>Ql,url:()=>lG,util:()=>le,uuid:()=>oG,uuidv4:()=>sG,uuidv6:()=>aG,uuidv7:()=>cG,void:()=>GG,xid:()=>hG,xor:()=>qG});var mO=v(()=>{fr();cf();ub();aP();vP();yW();fr();PE();fr();of();vW();_E();sf();sf();kW();Ht(Py())});var Ln=v(()=>{mO();mO()});function gO(e){let t=0;for(let n=0;n<e.length;n++)t=Math.imul(t,31)+e.charCodeAt(n)|0;return Math.abs(t).toString(16).padStart(8,"0")}function zb(e){return e.replace(/[^a-zA-Z0-9.-]/g,"-")}function xW(e,t){let n=o=>`SPDXRef-Package-${t}${zb(o)}`,i=e.map(o=>({name:o.name,SPDXID:n(o.name),versionInfo:o.version??"NOASSERTION",downloadLocation:o.downloadLocation??"NOASSERTION",filesAnalyzed:!1,licenseConcluded:"NOASSERTION",licenseDeclared:"NOASSERTION",copyrightText:"NOASSERTION",...o.purl?{externalRefs:[{referenceCategory:"PACKAGE-MANAGER",referenceType:"purl",referenceLocator:o.purl}]}:{}})),r=e.flatMap(o=>(o.dependsOn??[]).map(s=>({spdxElementId:n(o.name),relationshipType:"DEPENDS_ON",relatedSpdxElement:n(s)})));return{packages:i,relationships:r}}function zie(e,t=()=>new Date){let n="SPDXRef-DOCUMENT",i=`SPDXRef-Package-${zb(e.subjectName)}`,{packages:r,relationships:o}=xW(e.packages,""),s=[{spdxElementId:n,relationshipType:"DESCRIBES",relatedSpdxElement:i},...o],a=[];(e.subDocuments??[]).forEach((c,u)=>{let d=`SPDXRef-Package-sub${u}-${zb(c.subjectName)}`;a.push({name:c.subjectName,SPDXID:d,versionInfo:c.subjectVersion??"NOASSERTION",downloadLocation:"NOASSERTION",filesAnalyzed:!1,licenseConcluded:"NOASSERTION",licenseDeclared:"NOASSERTION",copyrightText:"NOASSERTION",comment:`subjectId: ${c.subjectId}`}),s.push({spdxElementId:i,relationshipType:"CONTAINS",relatedSpdxElement:d});let{packages:p,relationships:f}=xW(c.packages,`sub${u}-`);a.push(...p),s.push(...p.map(g=>({spdxElementId:d,relationshipType:"CONTAINS",relatedSpdxElement:g.SPDXID})),...f)});let l={spdxVersion:"SPDX-2.3",dataLicense:"CC0-1.0",SPDXID:n,name:e.subjectName,documentNamespace:`https://chant.dev/spdxdocs/${zb(e.subjectName)}-${gO(e.subjectId)}`,creationInfo:{created:t().toISOString(),creators:[`Tool: ${e.generator}`]},packages:[{name:e.subjectName,SPDXID:i,versionInfo:e.subjectVersion??"NOASSERTION",downloadLocation:"NOASSERTION",filesAnalyzed:!1,licenseConcluded:"NOASSERTION",licenseDeclared:"NOASSERTION",copyrightText:"NOASSERTION"},...r,...a],relationships:s};return JSON.stringify(l,null,2)}function $W(e,t){return e.map(n=>({type:n.type==="config"?"application":"library","bom-ref":`${t}${n.name}`,name:n.name,...n.version?{version:n.version}:{},...n.purl?{purl:n.purl}:{}}))}function RW(e,t){return e.filter(n=>(n.dependsOn?.length??0)>0).map(n=>({ref:`${t}${n.name}`,dependsOn:n.dependsOn.map(i=>`${t}${i}`)}))}function Uie(e,t=()=>new Date){let n=`subject:${e.subjectName}`,i=$W(e.packages,""),r=e.subDocuments??[],o=r.map((d,p)=>{let f=`sub${p}:`;return{type:"application","bom-ref":`${f}subject:${d.subjectName}`,name:d.subjectName,...d.subjectVersion?{version:d.subjectVersion}:{},properties:[{name:"chant:subjectId",value:d.subjectId}],components:$W(d.packages,f)}}),s=r.flatMap((d,p)=>{let f=`sub${p}:`;return[{ref:`${f}subject:${d.subjectName}`,dependsOn:d.packages.map(h=>`${f}${h.name}`)},...RW(d.packages,f)]}),a=[...e.packages.map(d=>d.name),...o.map(d=>d["bom-ref"])],l=[{ref:n,dependsOn:a},...RW(e.packages,""),...s],c=r.length>0?[{aggregate:"incomplete",assemblies:[n,...o.map(d=>d["bom-ref"])]}]:void 0,u={bomFormat:"CycloneDX",specVersion:"1.5",serialNumber:`urn:uuid:${Hie(gO(e.subjectId)+gO(e.subjectName))}`,version:1,metadata:{timestamp:t().toISOString(),tools:[{name:e.generator}],component:{type:"application","bom-ref":n,name:e.subjectName,...e.subjectVersion?{version:e.subjectVersion}:{},...o.length>0?{components:o}:{}}},components:i,dependencies:l,...c?{compositions:c}:{}};return JSON.stringify(u,null,2)}function Hie(e){let t=(e+e+e+e).slice(0,32);return`${t.slice(0,8)}-${t.slice(8,12)}-4${t.slice(13,16)}-8${t.slice(17,20)}-${t.slice(20,32)}`}function hO(e,t,n){let i=e==="spdx"?zie(t,n):Uie(t,n);return{format:e,mediaType:to[e],bytes:i}}var Ub=v(()=>{"use strict";Xo()});import{readFileSync as EW,writeFileSync as Vie,mkdirSync as qie}from"node:fs";import{dirname as SW,join as AW}from"node:path";function Kie(e){let t=JSON.parse(e),n=new Map,i=(r,o,s)=>{if(!r)return;let a=`${r}@${o??""}`,l=n.get(a);if(l){s?.length&&(l.dependsOn=[...new Set([...l.dependsOn??[],...s])]);return}n.set(a,{name:r,version:o,type:"npm",purl:o?`pkg:npm/${encodeURIComponent(r)}@${o}`:void 0,dependsOn:s?.length?s:void 0})};if(t.packages)for(let[r,o]of Object.entries(t.packages)){if(r==="")continue;let s=o.name??r.replace(/^.*node_modules\//,"");i(s,o.version,o.dependencies?Object.keys(o.dependencies):void 0)}else if(t.dependencies)for(let[r,o]of Object.entries(t.dependencies))i(r,o.version,o.requires?Object.keys(o.requires):void 0);return[...n.values()].sort((r,o)=>r.name.localeCompare(o.name))}function Jie(e){let t=[],i=e.replace(/<dependencyManagement>[\s\S]*?<\/dependencyManagement>/,"").match(/<dependencies>([\s\S]*?)<\/dependencies>/);if(!i)return t;let r=i[1],o=/<dependency>([\s\S]*?)<\/dependency>/g,s;for(;(s=o.exec(r))!==null;){let a=s[1],l=a.match(/<groupId>([^<]+)<\/groupId>/)?.[1]?.trim(),c=a.match(/<artifactId>([^<]+)<\/artifactId>/)?.[1]?.trim(),u=a.match(/<version>([^<]+)<\/version>/)?.[1]?.trim();if(!l||!c)continue;let d=`${l}:${c}`;t.push({name:d,version:u,type:"maven",purl:u?`pkg:maven/${encodeURIComponent(l)}/${encodeURIComponent(c)}@${u}`:void 0})}return t.sort((a,l)=>a.name.localeCompare(l.name))}function Zie(e){for(let[t,n]of[["npm","package-lock.json"],["maven","pom.xml"]]){let i=AW(e,n);try{return EW(i,"utf-8"),{kind:t,path:i}}catch{continue}}}function Yie(e,t){return AW(e,`sbom.${t}.json`)}function Xie(e={}){let t=e.now??(()=>new Date);function n(i,r,o,s=Jr){let a=Zie(i);if(!a)throw new Error(`no supported lockfile/manifest found under "${i}" (looked for package-lock.json, pom.xml) \u2014 the hermetic lockfile SBOM backend requires a lockfile on disk; use the deep-scan path (#610) for images with no lockfile`);let l=EW(a.path,"utf-8"),c=a.kind==="npm"?Kie(l):Jie(l),u=a.kind==="npm"?"chant-lockfile-sbom/package-lock.json":"chant-lockfile-sbom/pom.xml",d=hO(s,{subjectName:r,subjectId:o??a.path,packages:c,generator:u},t),p=e.outDir??i;return qie(p,{recursive:!0}),Vie(Yie(p,s),d.bytes),{...d,packageCount:c.length,generator:u}}return{async forImage(i){throw new Hb("forImage")},async forJar(i){return n(SW(i.jarPath),i.jarPath,i.digest,i.format)},async forZip(i){return n(SW(i.zipPath),i.zipPath,i.digest,i.format)},async forDir(i){return n(i.path,i.path,void 0,i.format)}}}var PW,yO=v(()=>{"use strict";Ub();Xo();Xo();PW=Xie()});function OW(){return bO||(bO=PW),bO}var to,Jr,Hb,bO,Xo=v(()=>{"use strict";yO();to={spdx:"application/spdx+json",cyclonedx:"application/vnd.cyclonedx+json"},Jr="spdx",Hb=class extends Error{constructor(n){super(`SbomGenerator.${n} has no real implementation configured \u2014 inject a real generator (shelling out to syft/buildx/cyclonedx-maven/cdxgen) or use a mock in tests`);this.method=n;this.name="SbomGeneratorNotImplementedError"}}});import{existsSync as wc}from"fs";import{dirname as vf,join as bu,resolve as CW}from"path";function kf(e){let t=CW(e),n=t;for(;;){let i=bu(n,"chant.config.ts");if(wc(i))return{dir:n,configPath:i};let r=bu(n,"chant.config.json");if(wc(r))return{dir:n,configPath:r};if(wc(bu(n,".git"))||wc(bu(n,"package.json")))return{dir:n};let o=vf(n);if(o===n)return{dir:t};n=o}}function gr(e){let t=CW(e),n;for(let i=t;;i=vf(i)){if(wc(bu(i,".git"))){n=i;break}if(vf(i)===i)break}for(let i=t;;i=vf(i)){let[r,o]=Qie.map(l=>bu(i,l)),s=wc(r),a=wc(o);if(s&&a)return{dir:i,file:r,conflicting:o};if(s)return{dir:i,file:r};if(a)return{dir:i,file:o};if(n===void 0||i===n||vf(i)===i)return}}var Qie,Si=v(()=>{"use strict";Qie=["chant.workspace.json","chant.workspace.jsonc"]});import*as eoe from"node:module";import{dirname as toe,join as XLe,sep as Vb}from"node:path";import{fileURLToPath as noe,pathToFileURL as eMe}from"node:url";function ooe(){return globalThis[ioe]}function Mn(){let e=ooe();if(!e)return!1;if(e.tsx)return!0;e.tsx=!0;let t=roe(import.meta.url);return t("tsx/cjs/api").register(),t("tsx/esm/api").register(),!0}function _W(e){let t=toe(noe(e));if(!e.endsWith(".js"))return t;let n=`${Vb}dist${Vb}`,i=(t+Vb).lastIndexOf(n);return i<0?t:t.slice(0,i)+`${Vb}src`+t.slice(i+n.length-1)}var roe,tMe,ioe,Ei=v(()=>{"use strict";({createRequire:roe,registerHooks:tMe}=eoe),ioe=Symbol.for("chant.compiledCli")});async function IW(e){return Mn(),await import(e)}var TW=v(()=>{"use strict";Ei()});function hr(e){if(e===null||typeof e!="object"||!("default"in e))return e;let t=e.default;if(!soe(t))return e;let n={};for(let i of Object.keys(t))i!=="__esModule"&&(n[i]=t[i]);return n}function soe(e){return e!==null&&(typeof e=="object"||typeof e=="function")&&e.__esModule===!0}var Zs=v(()=>{"use strict"});var DW=ie((sMe,wO)=>{if(typeof wO=="object")throw new Error("esbuild is not part of chant's wave-job runtime (wave-runtime.mjs): this path needs the full @intentius/chant CLI");wO.exports={}});import{existsSync as vO,mkdtempSync as aoe,readFileSync as coe,realpathSync as LW,rmSync as loe,statSync as MW,writeFileSync as uoe}from"node:fs";import{createRequire as doe}from"node:module";import{tmpdir as poe}from"node:os";import{dirname as FW,join as xf,resolve as foe}from"node:path";function hoe(){let e=globalThis;return e.__chantExternalPackagePathCache??=new Map}function yoe(e,t){let n=t;for(;;){let i=xf(n,"node_modules",e);if(vO(i)){let o=xf(i,"package.json");if(!vO(o))return;let s;try{s=JSON.parse(coe(o,"utf-8"))}catch{return}if(typeof s!="object"||s===null||s.exports!==void 0)return;let a=s.main,c=foe(i,typeof a=="string"?a:"index.js");if(!vO(c)||!MW(c).isFile())return;try{return LW(c)}catch{return}}let r=FW(n);if(r===n)return;n=r}}function boe(){let e=[],t=new Map,n=hoe();for(let r of goe)try{let o=n.get(r);if(o===void 0&&!n.has(r)&&(o=yoe(r,NW)??moe.resolve(r,{paths:[NW]}),n.set(r,o)),o===void 0)continue;t.set(r,o),e.push(FW(o))}catch{n.set(r,void 0)}return{plugin:{name:"chant-sandbox-external-trusted-packages",setup(r){for(let[o,s]of t){let a=new RegExp(`^${o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}$`);r.onResolve({filter:a},()=>({path:s,external:!0}))}}},readPaths:e}}async function qb(e){let t=LW(aoe(xf(poe(),"chant-sandbox-"))),n=xf(t,"driver.mts");uoe(n,e,"utf-8");let i=xf(t,"child.mjs"),{plugin:r,readPaths:o}=boe(),s=performance.now();try{await jW.build({entryPoints:[n],outfile:i,bundle:!0,platform:"node",format:"esm",absWorkingDir:t,logLevel:"silent",plugins:[r]})}catch(c){throw loe(t,{recursive:!0,force:!0}),c}let a=performance.now()-s,l=MW(i).size;return{bundlePath:i,bundleDir:t,externalReadPaths:o,durationMs:a,bytes:l}}var jW,NW,moe,goe,kO=v(()=>{"use strict";jW=Le(DW(),1),NW=import.meta.dirname,moe=doe(import.meta.url),goe=["typescript","@cdktn/hcl2json"]});function xO(e){for(let t of Object.keys($f))delete $f[t];Object.assign($f,e)}var $f,Kb=v(()=>{"use strict";$f={}});import{dirname as Jb,join as Ai}from"node:path";function nn(e){return JSON.stringify(e)}function WW(e=[]){return["function send(payload) {",...e.map(t=>` ${t}`),' if (typeof process.send !== "function") {'," console.log(JSON.stringify(payload));"," return Promise.resolve();"," }"," return new Promise((resolve) => {"," const lost = (err) => {",' writeSync(2, "chant: the sandboxed child could not hand its result to the parent: " +',' (err && err.message ? err.message : String(err)) + " (chant#2461)\\n");'," process.exit(1);"," };"," try {"," process.send(payload, (err) => (err ? lost(err) : resolve()));"," } catch (err) {"," lost(err);"," }"," });","}"]}function zW(e){let{files:t,buildRoot:n}=e,i=[`import { collectEntities } from ${nn(woe)};`,`import { resolveAttrRefs } from ${nn(voe)};`,`import { encodeEntitySet } from ${nn(koe)};`,`import { classifyChildError } from ${nn(BW)};`,`import { getProvenance } from ${nn(xoe)};`,`import { setBuildParams } from ${nn(Roe)};`,`import { esModuleNamespace } from ${nn(GW)};`,'import { writeSync } from "node:fs";',"",`const BUILD_ROOT = ${nn(n)};`,"",`setBuildParams(${nn({...$f})});`,"","let importing;","let reported = false;",'process.on("exit", () => {'," if (reported || importing === undefined) return;",` writeSync(2, "chant: this file's module scope never finished evaluating, so the build could not " +`,' "report anything: " + importing + "\\n A top-level `await` that never settles does this. " +',' "Nothing is thrown, so nothing else can name it (chant#2461).\\n");',"});","",...WW(["reported = true;"]),"","function errFile(err) {",' return err && typeof err === "object" && typeof err.file === "string" ? err.file : "";',"}","","async function main() {"," const modules = [];"," const errors = [];"];for(let r of t)i.push(` importing = ${nn(r)};`," try {",` const mod = esModuleNamespace(await import(${nn(r)}));`,` modules.push({ file: ${nn(r)}, exports: mod });`," } catch (err) {",` errors.push(classifyChildError(${nn(r)}, err).toJSON());`," }"," importing = undefined;");return i.push(""," let entities = new Map();"," try {"," entities = collectEntities(modules, BUILD_ROOT);"," } catch (err) {",' errors.push(classifyChildError(errFile(err), err, "resolution").toJSON());'," await send({ entitySet: { entities: [] }, errors, provenanceByName: {} });"," return;"," }",""," const provenanceByName = {};"," for (const [name, entity] of entities) {"," const prov = getProvenance(entity);"," if (prov?.sourceFile) provenanceByName[name] = prov.sourceFile;"," }",""," try {"," resolveAttrRefs(entities);"," } catch (err) {",' errors.push(classifyChildError("", err, "resolution").toJSON());'," }",""," let entitySet;"," try {"," entitySet = encodeEntitySet(entities);"," } catch (err) {",' errors.push(classifyChildError("", err, "resolution").toJSON());'," await send({ entitySet: { entities: [] }, errors, provenanceByName });"," return;"," }"," await send({ entitySet, errors, provenanceByName });","}","","main().catch((err) =>",' send({ entitySet: { entities: [] }, errors: [classifyChildError("", err).toJSON()], provenanceByName: {}, fatal: true }),',");"),i.join(`
|
|
47
|
+
`)}function UW(e){return[`import { classifyChildError } from ${nn(BW)};`,`import { scanConfigWireSafety } from ${nn($oe)};`,`import { esModuleNamespace } from ${nn(GW)};`,'import { writeSync } from "node:fs";',"",...WW(),"","async function main() {"," let namespace;"," try {",` namespace = esModuleNamespace(await import(${nn(e)}));`," } catch (err) {",` await send({ kind: "chant-config", ok: false, error: classifyChildError(${nn(e)}, err).toJSON() });`," return;"," }",""," const selected = namespace.default ?? namespace.config ?? namespace;",""," const offenders = scanConfigWireSafety(selected);"," if (offenders.length > 0) {",' await send({ kind: "chant-config", ok: false, offenders });'," return;"," }",""," let config;"," try {"," config = JSON.parse(JSON.stringify(selected ?? {}));"," } catch (err) {",` await send({ kind: "chant-config", ok: false, error: classifyChildError(${nn(e)}, err, "resolution").toJSON() });`," return;"," }",' await send({ kind: "chant-config", ok: true, config });',"}","","main().catch((err) =>",` send({ kind: "chant-config", ok: false, error: classifyChildError(${nn(e)}, err).toJSON() }),`,");"].join(`
|
|
48
|
+
`)}var Zb,vc,woe,voe,koe,BW,xoe,$oe,hMe,yMe,Roe,GW,$O=v(()=>{"use strict";Kb();Ei();Zb=_W(import.meta.url),vc=Ai(Zb,".."),woe=Ai(vc,"collect.ts"),voe=Ai(vc,"resolve.ts"),koe=Ai(vc,"entity-wire-codec.ts"),BW=Ai(Zb,"child-errors.ts"),xoe=Ai(Jb(vc),"provenance.ts"),$oe=Ai(Zb,"config-wire.ts"),hMe=Ai(Zb,"policy-wire.ts"),yMe=Ai(Jb(vc),"lint","post-synth.ts"),Roe=Ai(Jb(vc),"params.ts"),GW=Ai(Jb(vc),"module-interop.ts")});function HW(e,t){let n=t.map(i=>` ${i.path||"<root>"}: ${i.found}`);return[`Cannot evaluate ${e} inside the --sandbox boundary: it holds values that are not data.`,...n,"Under --sandbox the config is evaluated in an isolated child process and only JSON crosses back, so every value must be a string, number, boolean, null, array or plain object. Move the offending value out of chant.config.ts (lint rule plugins and policy checks are referenced by path, not embedded), or drop --sandbox for this build."].join(`
|
|
49
|
+
`)}var VW=v(()=>{"use strict"});import{fork as Soe}from"node:child_process";function qW(e){let t="";return{push(n){t+=n.toString();let i=t.indexOf(`
|
|
50
|
+
`);for(;i!==-1;)e(t.slice(0,i)),t=t.slice(i+1),i=t.indexOf(`
|
|
51
|
+
`)},flush(){t.length>0&&(e(t),t="")}}}function Eoe(e,t,n,i,r){let o=i.trim(),s=`${e}: child exited before reporting results (code ${t}, signal ${n})`;if(r.length>0){let a=r.map(l=>l&&typeof l=="object"?`{${Object.keys(l).join(", ")}}`:typeof l).join(", ");return`${s}. It sent ${r.length} message(s) the parent did not recognise (${a}), so the payload shape and the parent's check disagree`+(o?`: ${o}`:"")}return o?`${s}: ${o}`:t!==0||n!==null?s:`${s}. It exited cleanly with nothing on stderr, and no message arrived even after its IPC channel closed, so it never sent one: something it awaited never settled. On the run path the usual cause is a project file with a top-level \`await\` that does not settle. Module scope is arbitrary project source, an import of such a file never completes, and a promise that never settles is not a rejection, so the driver's own \`main().catch\` does not see it either. The config driver has nothing to await that can hang, and a failed send exits non-zero with a reason on stderr, so on the config path this has no known cause: please report it with the command that produced it (chant#2461).`}function Poe(e,t,n=Aoe){e.on("exit",(i,r)=>{let o=!1,s,a=()=>{o||(o=!0,s!==void 0&&clearTimeout(s),t(i,r))};if(!e.connected){a();return}e.once("disconnect",a),s=setTimeout(a,n)})}function Yb(e,t){let{bundlePath:n,bundleDir:i,projectRealpath:r,externalReadPaths:o,env:s,timeoutMs:a,label:l,send:c,outputPrefix:u}=e;return new Promise((d,p)=>{let f=[i,r,...o].map(_=>`--allow-fs-read=${_}`),g=Soe(n,[],{execArgv:["--permission",...f],env:s,stdio:["ignore","pipe","pipe","ipc"]}),h=!1,b="",w=[],x=setTimeout(()=>{h||(h=!0,g.kill(),p(new Error(`${l} timed out after ${a}ms`)))},a);c!==void 0&&g.send(c,_=>{h||!_||(h=!0,clearTimeout(x),g.kill(),p(new Error(`${l}: failed to send the child its input: ${_.message}`)))});let k=_=>{process.stderr.write(`${u} ${_}
|
|
52
|
+
`)},R=qW(k),$=qW(k);g.stdout?.on("data",_=>{R.push(_)}),g.stdout?.on("end",()=>R.flush()),g.stderr?.on("data",_=>{b+=_.toString(),$.push(_)}),g.stderr?.on("end",()=>$.flush()),g.on("message",_=>{if(!h){if(!t(_)){w.push(_);return}h=!0,clearTimeout(x),g.kill(),d(_)}}),g.on("error",_=>{h||(h=!0,clearTimeout(x),p(_))}),Poe(g,(_,T)=>{h||(h=!0,clearTimeout(x),p(new Error(Eoe(l,_,T,b,w))))})})}var Aoe,RO=v(()=>{"use strict";Aoe=2e3});var JW={};_e(JW,{evaluateConfigSandboxed:()=>Toe});import{realpathSync as Ooe,rmSync as Coe}from"node:fs";import{resolve as KW}from"node:path";function Ioe(e){return typeof e=="object"&&e!==null&&e.kind==="chant-config"&&typeof e.ok=="boolean"}async function Toe(e,t){let n=UW(e),{bundlePath:i,bundleDir:r,externalReadPaths:o,durationMs:s,bytes:a}=await qb(n);try{let l;try{l=Ooe(KW(t))}catch{l=KW(t)}let c={PATH:process.env.PATH??""},u=process.env[wu];u&&(c[wu]=u);let d=await Yb({bundlePath:i,bundleDir:r,projectRealpath:l,externalReadPaths:o,env:c,timeoutMs:_oe,label:`sandboxed evaluation of ${e}`,outputPrefix:"[sandbox:config]"},Ioe);if(!d.ok)throw d.offenders&&d.offenders.length>0?new Error(HW(e,d.offenders)):new Error(d.error?.message?`Failed to evaluate ${e} inside the --sandbox boundary: ${d.error.message}`:`Failed to evaluate ${e} inside the --sandbox boundary`);return{config:d.config??{},bundleMs:s,bundleBytes:a}}finally{Coe(r,{recursive:!0,force:!0})}}var _oe,ZW=v(()=>{"use strict";kO();$O();VW();RO();vu();_oe=6e4});import{dirname as Doe}from"node:path";function joe(e){let t=hr(e);return t.default??t.config??t}async function YW(e,t=Doe(e)){if(!Noe)return joe(await IW(e));if(SO.has(e))return SO.get(e);let{evaluateConfigSandboxed:n}=await Promise.resolve().then(()=>(ZW(),JW)),{config:i}=await n(e,t);return SO.set(e,i),i}var Noe,SO,EO=v(()=>{"use strict";TW();Zs();Noe=!1,SO=new Map});var nz={};_e(nz,{importLexiconModule:()=>kc,importLexiconPackage:()=>Yr,lexiconDeclarationName:()=>QW,lexiconModulePath:()=>Pi,lexiconModuleRoot:()=>PO,lexiconNames:()=>Zr,lexiconPackagesToInstall:()=>Voe,lexiconSourceLabel:()=>Hoe,packageNameOf:()=>tz,pathLexiconMap:()=>Woe,pathLexiconRoot:()=>Xb,recordedLexiconModules:()=>zoe,registerLexiconDeclarations:()=>Xs,resetLexiconModules:()=>Uoe,resolveFromProject:()=>Qb});import{createRequire as Loe}from"node:module";import{dirname as Moe,isAbsolute as xu,join as Foe,relative as XW,resolve as ku,sep as Boe}from"node:path";import{pathToFileURL as Goe}from"node:url";function QW(e){return typeof e=="string"?e:e.name}function Zr(e){return e?.map(QW)}function AO(e,t){let n=XW(t,e);return n===""||!n.startsWith("..")&&!xu(n)}function Xb(e,t,n="."){let i=xu(e.module)?e.module:ku(t,e.module),r=e.root!==void 0,o=r?xu(e.root)?ku(e.root):ku(t,e.root):Moe(i),s=ku(t),a=ku(t,n),l;return AO(o,s)?AO(a,o)?l=`${o} contains the project's source directory (${a})`:AO(i,o)||(l=`the module ${i} is not inside ${o}`):l=`${o} is outside the project (${s})`,l===void 0?{root:o}:r?{problem:l}:{}}function Xs(e,t,n){let i={};for(let r of e??[]){if(typeof r=="string"){Ys.delete(r),Rf.delete(r);continue}let o=ez(r,t);Ys.set(r.name,o),i[r.name]=o;let{root:s}=Xb(r,t,n);s===void 0?Rf.delete(r.name):Rf.set(r.name,s)}return i}function ez(e,t){return xu(e.module)?e.module:ku(t,e.module)}function Woe(e,t){let n=new Map;for(let i of e)typeof i!="string"&&n.set(i.name,ez(i,t));return n}function zoe(){return new Map(Ys)}function Pi(e){return Ys.get(e)}function PO(e){return Rf.get(e)}function Uoe(){Ys.clear(),Rf.clear()}async function kc(e){let t=Ys.get(e);if(t!==void 0)try{return Mn(),hr(await import(t))}catch(n){throw new Error(`lexicon "${e}" is declared with module ${t}, which could not be loaded: `+(n instanceof Error?n.message:String(n)))}}function Hoe(e,t=process.cwd(),n=Ys){let i=n.get(e);if(i===void 0)return`@intentius/chant-lexicon-${e}`;let r=XW(t,i);return r===""||r.startsWith("..")||xu(r)?i:`./${r.split(Boe).join("/")}`}function Voe(e,t=Ys){return e.filter(n=>!t.has(n)).map(n=>`@intentius/chant-lexicon-${n}`)}function tz(e){if(e.startsWith(".")||xu(e)||e.startsWith("file:"))return;let t=e.split("/");return e.startsWith("@")?t.slice(0,2).join("/"):t[0]}function qoe(e,t){let n=e?.code;if(n!=="ERR_MODULE_NOT_FOUND"&&n!=="MODULE_NOT_FOUND")return!1;let i=e instanceof Error?e.message:String(e);return i.includes(`'${t}'`)||i.includes(`"${t}"`)||i.includes(`${t}/`)}function Qb(e,t=process.cwd()){try{return Loe(Foe(t,"package.json")).resolve(e)}catch{return}}async function Yr(e,t=process.cwd()){try{return Mn(),hr(await import(e))}catch(n){let i=tz(e);if(i===void 0||!qoe(n,i))throw n;let r=Qb(e,t);if(r===void 0)throw n;return hr(await import(Goe(r).href))}}var Ys,Rf,xn=v(()=>{"use strict";Ei();Zs();Ys=new Map,Rf=new Map});var Koe,Joe,Zoe,$u,rz,ew=v(()=>{"use strict";Ln();Koe=m.strictObject({env:m.string().min(1)}),Joe=m.strictObject({capability:m.string().min(1),member:m.string().min(1).optional(),env:m.string().min(1).optional()}),Zoe=m.union([Koe,Joe]),$u=m.strictObject({url:m.string().min(1),key:Zoe.optional(),timeoutMs:m.number().int().positive().optional()}),rz=m.strictObject({backends:m.record(m.string(),$u).optional()})});var iw={};_e(iw,{ChantConfigSchema:()=>Af,DEFAULT_CHANT_CONFIG:()=>TO,InvalidChantConfigError:()=>Ru,environmentEndpoint:()=>lz,environmentName:()=>xc,environmentNames:()=>_O,findProjectConfigPastFragments:()=>Pf,isEnvironmentPattern:()=>Sf,isLintOnlyFragment:()=>nw,isOwnershipParamRef:()=>dz,loadChantConfig:()=>Qs,loadChantConfigUpward:()=>tw,matchesDeclaredEnvironment:()=>Ef,matchesEnvironmentPattern:()=>IO,ownershipEnvDisagreement:()=>ese,resolveAutoReleaseDisabled:()=>tse,resolveDiscoveryGlobs:()=>Su,resolveFoldEnabled:()=>fz,resolveKnowledgeDir:()=>nse,resolveOwnershipEnv:()=>DO,resolveOwnershipMarker:()=>pz,resolveOwnershipStack:()=>rw,resolveSandboxEnabled:()=>mz,resolveSbomFormat:()=>gz,resolveSigningDefaults:()=>hz,resolveVulnPolicy:()=>yz});import{existsSync as iz,readFileSync as az}from"fs";import{dirname as cz,join as OO}from"path";function xc(e){return typeof e=="string"?e:e.name}function _O(e){return e?.map(xc)}function Sf(e){return e.includes("*")}function IO(e,t){let n=e.split("*");if(n.length===1)return e===t;let i=n[0],r=n[n.length-1];if(!t.startsWith(i))return!1;let o=i.length;for(let s=1;s<n.length-1;s++){let a=n[s];if(a==="")continue;let l=t.indexOf(a,o);if(l===-1)return!1;o=l+a.length}return t.length-o>=r.length&&t.endsWith(r)}function Ef(e,t){let n=_O(e)??[];return n.includes(t)?!0:n.some(i=>Sf(i)&&IO(i,t))}function lz(e,t){let n=e?.find(i=>xc(i)===t)??e?.find(i=>Sf(xc(i))&&IO(xc(i),t));return n&&typeof n!="string"?n.endpoint:void 0}async function Qs(e){let t=OO(e,"chant.config.ts");if(iz(t)){let i=await YW(t,e);return{config:sz(i,t),configPath:t}}let n=OO(e,"chant.config.json");if(iz(n)){let{readFileSync:i}=await import("fs"),r=i(n,"utf-8"),o=JSON.parse(r);return{config:sz(o,n),configPath:n}}return{config:TO}}async function tw(e){let{dir:t,configPath:n}=Pf(e);return n&&Qoe(n),Qs(t)}function Pf(e){let{dir:t,configPath:n}=kf(e);for(;n&&nw(n);){let i=cz(t);if(i===t)break;({dir:t,configPath:n}=kf(i))}return{dir:t,configPath:n}}async function Su(e){let{dir:t,configPath:n}=Pf(e);if(!n)return;let i;try{({config:i}=await Qs(t))}catch(s){if(s instanceof Ru&&(s.key==="exclude"||s.key==="include"))throw s;return}let r=i.exclude??[],o=i.include??[];if(!(r.length===0&&o.length===0))return{root:t,exclude:r,include:o}}function nw(e){if(!e.endsWith("chant.config.json"))return!1;try{let t=JSON.parse(az(e,"utf-8"));if(typeof t!="object"||t===null||Array.isArray(t))return!1;let n=Object.keys(t).filter(i=>!uz(i));return n.length>0&&n.every(i=>CO.has(i))}catch{return!1}}function Qoe(e){if(e.endsWith("chant.config.json"))try{let t=JSON.parse(az(e,"utf-8"));if(typeof t!="object"||t===null||Array.isArray(t))return;let n=Object.keys(t).filter(i=>!uz(i));if(n.some(i=>!CO.has(i))&&!n.some(i=>oz.has(i))){let i=n.filter(r=>!CO.has(r));console.error(`warning: ${e} is being used as the project config, but declares no project-level key (${[...oz].slice(0,4).join(", ")}, \u2026). ${i.length===1?"The key":"The keys"} ${i.map(r=>`"${r}"`).join(", ")} stopped the walk to the real one \u2014 any config above this file is being ignored. Prefix a comment key with "_", or move the key to the project config. (chant #1711)`)}}catch{}}function dz(e){return typeof e=="object"&&e!==null&&typeof e.param=="string"}function rw(e){let t=e.ownership;if(!(!t||!t.stack||t.enabled===!1))return t.stack}function DO(e,t){let n=e.ownership?.env;if(!dz(n))return n;let i=n.param,r=e.buildParams?.[i];if(!r)throw new Error(`ownership.env references build parameter "${i}", which chant.config.ts's buildParams does not declare`);let o=t?.find(s=>s.name===i);if(!o)throw new Error(`ownership.env references build parameter "${i}", which resolved to no value for this build \u2014 pass --param ${i}=<value>${r.env?`, set ${r.env}`:""}, or give it a default`);return String(o.value)}function pz(e,t){let n=rw(e);if(n!==void 0)return{stack:n,env:DO(e,t)}}function ese(e,t){let n=e.ownership?.env;if(typeof n!="string"||rw(e)===void 0)return;let i=t?.find(r=>r.name==="env");if(!(!i||String(i.value)===n))return`ownership.env is "${n}" but the env build parameter resolved to ${JSON.stringify(i.value)} (${i.source}) \u2014 the ownership marker and params.env disagree about which environment this build is for. Use ownership: { env: { param: "env" } } so the marker follows the parameter.`}function tse(e,t){return t?!0:e.release?.autoRecord===!1}function fz(e,t){return t!==void 0?t:e.build?.fold!==void 0?e.build.fold:!0}function mz(e,t){return t?!0:e.build?.sandbox===!0}function gz(e,t){return t??e.sbom?.format??Jr}function hz(e){let t=e.signing,n=t?.keyless!==!1;return{keyless:n,...!n&&t?.key?{key:{key:t.key}}:{},identityPolicyDefaults:{expectedIssuer:t?.oidcIssuer,expectedIdentity:t?.identity,identityIsRegexp:t?.identityIsRegexp,key:t?.keyless===!1?t?.key:void 0}}}function yz(e){let t=e.vulnPolicy;if(!t)return{};let n={};return t.failSeverity&&(n.failSeverity=t.failSeverity),t.fixableOnly!==void 0&&(n.fixableOnly=t.fixableOnly),t.warnSeverity&&(n.warnSeverity=t.warnSeverity),t.failOnLicense!==void 0&&(n.failOnLicense=t.failOnLicense),t.failOnUnknownSeverity!==void 0&&(n.failOnUnknownSeverity=t.failOnUnknownSeverity),t.failOnKev!==void 0&&(n.failOnKev=t.failOnKev),t.failEpssAtOrAbove!==void 0&&(n.failEpssAtOrAbove=t.failEpssAtOrAbove),t.warnEpssAtOrAbove!==void 0&&(n.warnEpssAtOrAbove=t.warnEpssAtOrAbove),t.exploitabilityFixableOnly!==void 0&&(n.exploitabilityFixableOnly=t.exploitabilityFixableOnly),t.license&&(n.license=t.license),n}function nse(e,t){return OO(t,e.knowledge?.dir??"knowledge")}function sz(e,t){if(typeof e!="object"||e===null)return TO;let n=Af.safeParse(e);if(!n.success){let a=n.error.issues[0],l=a.path.length>0?a.path.join("."):void 0,c=t?` in ${t}`:"";throw new Ru(`Invalid chant config${c}: ${l?`${l}: `:""}${a.message}`,a.path.length>0?String(a.path[0]):void 0)}let i=e.lexicons,r=t!==void 0?cz(t):process.cwd(),o=e.sourceDir;for(let[a,l]of(i??[]).entries()){if(typeof l=="string"||l.root===void 0)continue;let{problem:c}=Xb(l,r,o);if(c!==void 0){let u=t?` in ${t}`:"";throw new Ru(`Invalid chant config${u}: lexicons.${a}.root: ${c}`,"lexicons")}}let s=Xs(i,r,o);return Object.keys(s).length>0?{...e,lexicons:Zr(i),lexiconModules:s}:e}var Yoe,Xoe,Af,TO,CO,uz,oz,Ru,Kt=v(()=>{"use strict";Ln();Xo();Si();EO();xn();ew();Yoe=m.union([m.string().min(1),m.object({name:m.string().min(1),endpoint:m.string().min(1).optional()})]),Xoe=m.union([m.string().min(1),m.object({name:m.string().min(1),module:m.string().min(1),root:m.string().min(1).optional()}).strict()]),Af=m.object({lexicons:m.array(Xoe).optional(),capabilities:m.array(m.string().min(1)).optional(),environments:m.array(Yoe).optional(),sourceDir:m.string().min(1).optional(),lint:m.record(m.string(),m.unknown()).optional(),ownership:m.object({stack:m.string().min(1).optional(),env:m.union([m.string().min(1),m.object({param:m.string().min(1)})]).optional(),enabled:m.boolean().optional()}).optional(),build:m.object({fold:m.boolean().optional()}).optional(),buildParams:m.record(m.string(),m.object({type:m.enum(["string","number","boolean"]),default:m.union([m.string(),m.number(),m.boolean()]).optional(),enum:m.array(m.union([m.string(),m.number(),m.boolean()])).optional(),env:m.string().min(1).optional(),required:m.boolean().optional(),description:m.string().optional()})).optional(),release:m.object({autoRecord:m.boolean().optional()}).optional(),run:m.object({on:m.string().min(1).optional()}).strict().optional(),sbom:m.object({format:m.enum(["spdx","cyclonedx"]).optional(),enabled:m.boolean().optional()}).optional(),signing:m.object({keyless:m.boolean().optional(),oidcIssuer:m.string().min(1).optional(),identity:m.string().min(1).optional(),identityIsRegexp:m.boolean().optional(),key:m.string().min(1).optional()}).optional(),vulnPolicy:m.object({failSeverity:m.enum(["critical","high","medium","low","negligible","unknown"]).optional(),fixableOnly:m.boolean().optional(),warnSeverity:m.enum(["critical","high","medium","low","negligible","unknown"]).optional(),failOnLicense:m.boolean().optional(),failOnUnknownSeverity:m.boolean().optional(),failOnKev:m.boolean().optional(),failEpssAtOrAbove:m.number().min(0).max(1).optional(),warnEpssAtOrAbove:m.number().min(0).max(1).optional(),exploitabilityFixableOnly:m.boolean().optional(),license:m.object({allow:m.array(m.string()).optional(),deny:m.array(m.string()).optional()}).optional(),scanner:m.enum(["grype","trivy"]).optional(),vexSources:m.array(m.string()).optional()}).optional(),knowledge:m.object({dir:m.string().min(1).optional()}).optional(),codegen:m.object({outDir:m.string().min(1).optional()}).strict().optional(),decide:rz.optional(),exclude:m.array(m.string().min(1)).optional(),include:m.array(m.string().min(1)).optional(),rootOnly:m.boolean().optional()}).passthrough(),TO={};CO=new Set(["$schema","extends","rules","overrides","plugins","policies"]),uz=e=>e.startsWith("_");oz=new Set(Object.keys(Af.shape).filter(e=>e!=="lint"));Ru=class extends Error{constructor(n,i){super(n);this.key=i}}});var wu,vu=v(()=>{"use strict";Kt();wu="CHANT_ENV"});var Of=ie((YMe,xz)=>{"use strict";var bz="[^\\\\/]",rse="(?=.)",wz="[^/]",NO="(?:\\/|$)",vz="(?:^|\\/)",jO=`\\.{1,2}${NO}`,ise="(?!\\.)",ose=`(?!${vz}${jO})`,sse=`(?!\\.{0,1}${NO})`,ase=`(?!${jO})`,cse="[^.\\/]",lse=`${wz}*?`,use="/",kz={DOT_LITERAL:"\\.",PLUS_LITERAL:"\\+",QMARK_LITERAL:"\\?",SLASH_LITERAL:"\\/",ONE_CHAR:rse,QMARK:wz,END_ANCHOR:NO,DOTS_SLASH:jO,NO_DOT:ise,NO_DOTS:ose,NO_DOT_SLASH:sse,NO_DOTS_SLASH:ase,QMARK_NO_DOT:cse,STAR:lse,START_ANCHOR:vz,SEP:use},dse={...kz,SLASH_LITERAL:"[\\\\/]",QMARK:bz,STAR:`${bz}*?`,DOTS_SLASH:"\\.{1,2}(?:[\\\\/]|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|[\\\\/])\\.{1,2}(?:[\\\\/]|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:[\\\\/]|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:[\\\\/]|$))",QMARK_NO_DOT:"[^.\\\\/]",START_ANCHOR:"(?:^|[\\\\/])",END_ANCHOR:"(?:[\\\\/]|$)",SEP:"\\"},pse={__proto__:null,alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};xz.exports={DEFAULT_MAX_EXTGLOB_RECURSION:0,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:pse,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,extglobChars(e){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${e.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(e){return e===!0?dse:kz}}});var Cf=ie(yr=>{"use strict";var{REGEX_BACKSLASH:fse,REGEX_REMOVE_BACKSLASH:mse,REGEX_SPECIAL_CHARS:gse,REGEX_SPECIAL_CHARS_GLOBAL:hse}=Of();yr.isObject=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);yr.hasRegexChars=e=>gse.test(e);yr.isRegexChar=e=>e.length===1&&yr.hasRegexChars(e);yr.escapeRegex=e=>e.replace(hse,"\\$1");yr.toPosixSlashes=e=>e.replace(fse,"/");yr.isWindows=()=>{if(typeof navigator<"u"&&navigator.platform){let e=navigator.platform.toLowerCase();return e==="win32"||e==="windows"}return typeof process<"u"&&process.platform?process.platform==="win32":!1};yr.removeBackslashes=e=>e.replace(mse,t=>t==="\\"?"":t);yr.escapeLast=(e,t,n)=>{let i=e.lastIndexOf(t,n);return i===-1?e:e[i-1]==="\\"?yr.escapeLast(e,t,i-1):`${e.slice(0,i)}\\${e.slice(i)}`};yr.removePrefix=(e,t={})=>{let n=e;return n.startsWith("./")&&(n=n.slice(2),t.prefix="./"),n};yr.wrapOutput=(e,t={},n={})=>{let i=n.contains?"":"^",r=n.contains?"":"$",o=`${i}(?:${e})${r}`;return t.negated===!0&&(o=`(?:^(?!${o}).*$)`),o};yr.basename=(e,{windows:t}={})=>{let n=e.split(t?/[\\/]/:"/"),i=n[n.length-1];return i===""?n[n.length-2]:i}});var Cz=ie((QMe,Oz)=>{"use strict";var $z=Cf(),{CHAR_ASTERISK:LO,CHAR_AT:yse,CHAR_BACKWARD_SLASH:_f,CHAR_COMMA:bse,CHAR_DOT:MO,CHAR_EXCLAMATION_MARK:FO,CHAR_FORWARD_SLASH:Pz,CHAR_LEFT_CURLY_BRACE:BO,CHAR_LEFT_PARENTHESES:GO,CHAR_LEFT_SQUARE_BRACKET:wse,CHAR_PLUS:vse,CHAR_QUESTION_MARK:Rz,CHAR_RIGHT_CURLY_BRACE:kse,CHAR_RIGHT_PARENTHESES:Sz,CHAR_RIGHT_SQUARE_BRACKET:xse}=Of(),Ez=e=>e===Pz||e===_f,Az=e=>{e.isPrefix!==!0&&(e.depth=e.isGlobstar?1/0:1)},$se=(e,t)=>{let n=t||{},i=e.length-1,r=n.parts===!0||n.scanToEnd===!0,o=[],s=[],a=[],l=e,c=-1,u=0,d=0,p=!1,f=!1,g=!1,h=!1,b=!1,w=!1,x=!1,k=!1,R=!1,$=!1,_=0,T,C,K={value:"",depth:0,isGlob:!1},O=()=>c>=i,pe=()=>l.charCodeAt(c+1),F=()=>(T=C,l.charCodeAt(++c));for(;c<i;){C=F();let xe;if(C===_f){x=K.backslashes=!0,C=F(),C===BO&&(w=!0);continue}if(w===!0||C===BO){for(_++;O()!==!0&&(C=F());){if(C===_f){x=K.backslashes=!0,F();continue}if(C===BO){_++;continue}if(w!==!0&&C===MO&&(C=F())===MO){if(p=K.isBrace=!0,g=K.isGlob=!0,$=!0,r===!0)continue;break}if(w!==!0&&C===bse){if(p=K.isBrace=!0,g=K.isGlob=!0,$=!0,r===!0)continue;break}if(C===kse&&(_--,_===0)){w=!1,p=K.isBrace=!0,$=!0;break}}if(r===!0)continue;break}if(C===Pz){if(o.push(c),s.push(K),K={value:"",depth:0,isGlob:!1},$===!0)continue;if(T===MO&&c===u+1){u+=2;continue}d=c+1;continue}if(n.noext!==!0&&(C===vse||C===yse||C===LO||C===Rz||C===FO)===!0&&pe()===GO){if(g=K.isGlob=!0,h=K.isExtglob=!0,$=!0,C===FO&&c===u&&(R=!0),r===!0){for(;O()!==!0&&(C=F());){if(C===_f){x=K.backslashes=!0,C=F();continue}if(C===Sz){g=K.isGlob=!0,$=!0;break}}continue}break}if(C===LO){if(T===LO&&(b=K.isGlobstar=!0),g=K.isGlob=!0,$=!0,r===!0)continue;break}if(C===Rz){if(g=K.isGlob=!0,$=!0,r===!0)continue;break}if(C===wse){for(;O()!==!0&&(xe=F());){if(xe===_f){x=K.backslashes=!0,F();continue}if(xe===xse){f=K.isBracket=!0,g=K.isGlob=!0,$=!0;break}}if(r===!0)continue;break}if(n.nonegate!==!0&&C===FO&&c===u){k=K.negated=!0,u++;continue}if(n.noparen!==!0&&C===GO){if(g=K.isGlob=!0,r===!0){for(;O()!==!0&&(C=F());){if(C===GO){x=K.backslashes=!0,C=F();continue}if(C===Sz){$=!0;break}}continue}break}if(g===!0){if($=!0,r===!0)continue;break}}n.noext===!0&&(h=!1,g=!1);let Q=l,I="",B="";u>0&&(I=l.slice(0,u),l=l.slice(u),d-=u),Q&&g===!0&&d>0?(Q=l.slice(0,d),B=l.slice(d)):g===!0?(Q="",B=l):Q=l,Q&&Q!==""&&Q!=="/"&&Q!==l&&Ez(Q.charCodeAt(Q.length-1))&&(Q=Q.slice(0,-1)),n.unescape===!0&&(B&&(B=$z.removeBackslashes(B)),Q&&x===!0&&(Q=$z.removeBackslashes(Q)));let Z={prefix:I,input:e,start:u,base:Q,glob:B,isBrace:p,isBracket:f,isGlob:g,isExtglob:h,isGlobstar:b,negated:k,negatedExtglob:R};if(n.tokens===!0&&(Z.maxDepth=0,Ez(C)||s.push(K),Z.tokens=s),n.parts===!0||n.tokens===!0){let xe;for(let we=0;we<o.length;we++){let Ct=xe?xe+1:u,at=o[we],$e=e.slice(Ct,at);n.tokens&&(we===0&&u!==0?(s[we].isPrefix=!0,s[we].value=I):s[we].value=$e,Az(s[we]),Z.maxDepth+=s[we].depth),(we!==0||$e!=="")&&a.push($e),xe=at}if(xe&&xe+1<e.length){let we=e.slice(xe+1);a.push(we),n.tokens&&(s[s.length-1].value=we,Az(s[s.length-1]),Z.maxDepth+=s[s.length-1].depth)}Z.slashes=o,Z.parts=a}return Z};Oz.exports=$se});var Nz=ie((e1e,Dz)=>{"use strict";var If=Of(),Dr=Cf(),{MAX_LENGTH:ow,POSIX_REGEX_SOURCE:Rse,REGEX_NON_SPECIAL_CHARS:Sse,REGEX_SPECIAL_CHARS_BACKREF:Ese,REPLACEMENTS:_z}=If,Ase=(e,t)=>{if(typeof t.expandRange=="function")return t.expandRange(...e,t);e.sort();let n=`[${e.join("-")}]`;try{new RegExp(n)}catch{return e.map(r=>Dr.escapeRegex(r)).join("..")}return n},Eu=(e,t)=>`Missing ${e}: "${t}" - use "\\\\${t}" to match literal characters`,Iz=e=>{let t=[],n=0,i=0,r=0,o="",s=!1;for(let a of e){if(s===!0){o+=a,s=!1;continue}if(a==="\\"){o+=a,s=!0;continue}if(a==='"'){r=r===1?0:1,o+=a;continue}if(r===0){if(a==="[")n++;else if(a==="]"&&n>0)n--;else if(n===0){if(a==="(")i++;else if(a===")"&&i>0)i--;else if(a==="|"&&i===0){t.push(o),o="";continue}}}o+=a}return t.push(o),t},Pse=e=>{let t=!1;for(let n of e){if(t===!0){t=!1;continue}if(n==="\\"){t=!0;continue}if(/[?*+@!()[\]{}]/.test(n))return!1}return!0},Tz=e=>{let t=e.trim(),n=!0;for(;n===!0;)n=!1,/^@\([^\\()[\]{}|]+\)$/.test(t)&&(t=t.slice(2,-1),n=!0);if(Pse(t))return t.replace(/\\(.)/g,"$1")},Ose=e=>{let t=e.map(Tz).filter(Boolean);for(let n=0;n<t.length;n++)for(let i=n+1;i<t.length;i++){let r=t[n],o=t[i],s=r[0];if(!(!s||r!==s.repeat(r.length)||o!==s.repeat(o.length))&&(r===o||r.startsWith(o)||o.startsWith(r)))return!0}return!1},WO=(e,t=!0)=>{if(e[0]!=="+"&&e[0]!=="*"||e[1]!=="(")return;let n=0,i=0,r=0,o=!1;for(let s=1;s<e.length;s++){let a=e[s];if(o===!0){o=!1;continue}if(a==="\\"){o=!0;continue}if(a==='"'){r=r===1?0:1;continue}if(r!==1){if(a==="["){n++;continue}if(a==="]"&&n>0){n--;continue}if(!(n>0)){if(a==="("){i++;continue}if(a===")"&&(i--,i===0))return t===!0&&s!==e.length-1?void 0:{type:e[0],body:e.slice(2,s),end:s}}}}},Cse=e=>{let t=0,n=[];for(;t<e.length;){let r=WO(e.slice(t),!1);if(!r||r.type!=="*")return;let o=Iz(r.body).map(a=>a.trim());if(o.length!==1)return;let s=Tz(o[0]);if(!s||s.length!==1)return;n.push(s),t+=r.end+1}return n.length<1?void 0:`${n.length===1?Dr.escapeRegex(n[0]):`[${n.map(r=>Dr.escapeRegex(r)).join("")}]`}*`},_se=e=>{let t=0,n=e.trim(),i=WO(n);for(;i;)t++,n=i.body.trim(),i=WO(n);return t},Ise=(e,t)=>{if(t.maxExtglobRecursion===!1)return{risky:!1};let n=typeof t.maxExtglobRecursion=="number"?t.maxExtglobRecursion:If.DEFAULT_MAX_EXTGLOB_RECURSION,i=Iz(e).map(r=>r.trim());if(i.length>1&&(i.some(r=>r==="")||i.some(r=>/^[*?]+$/.test(r))||Ose(i)))return{risky:!0};for(let r of i){let o=Cse(r);if(o)return{risky:!0,safeOutput:o};if(_se(r)>n)return{risky:!0}}return{risky:!1}},zO=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");e=_z[e]||e;let n={...t},i=typeof n.maxLength=="number"?Math.min(ow,n.maxLength):ow,r=e.length;if(r>i)throw new SyntaxError(`Input length: ${r}, exceeds maximum allowed length: ${i}`);let o={type:"bos",value:"",output:n.prepend||""},s=[o],a=n.capture?"":"?:",l=If.globChars(n.windows),c=If.extglobChars(l),{DOT_LITERAL:u,PLUS_LITERAL:d,SLASH_LITERAL:p,ONE_CHAR:f,DOTS_SLASH:g,NO_DOT:h,NO_DOT_SLASH:b,NO_DOTS_SLASH:w,QMARK:x,QMARK_NO_DOT:k,STAR:R,START_ANCHOR:$}=l,_=ne=>`(${a}(?:(?!${$}${ne.dot?g:u}).)*?)`,T=n.dot?"":h,C=n.dot?x:k,K=n.bash===!0?_(n):R;n.capture&&(K=`(${K})`),typeof n.noext=="boolean"&&(n.noextglob=n.noext);let O={input:e,index:-1,start:0,dot:n.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:s};e=Dr.removePrefix(e,O),r=e.length;let pe=[],F=[],Q=[],I=o,B,Z=()=>O.index===r-1,xe=O.peek=(ne=1)=>e[O.index+ne],we=O.advance=()=>e[++O.index]||"",Ct=()=>e.slice(O.index+1),at=(ne="",Re=0)=>{O.consumed+=ne,O.index+=Re},$e=ne=>{O.output+=ne.output!=null?ne.output:ne.value,at(ne.value)},Te=()=>{let ne=1;for(;xe()==="!"&&(xe(2)!=="("||xe(3)==="?");)we(),O.start++,ne++;return ne%2===0?!1:(O.negated=!0,O.start++,!0)},nt=ne=>{O[ne]++,Q.push(ne)},St=ne=>{O[ne]--,Q.pop()},Ee=ne=>{if(I.type==="globstar"){let Re=O.braces>0&&(ne.type==="comma"||ne.type==="brace"),X=ne.extglob===!0||pe.length&&(ne.type==="pipe"||ne.type==="paren");ne.type!=="slash"&&ne.type!=="paren"&&!Re&&!X&&(O.output=O.output.slice(0,-I.output.length),I.type="star",I.value="*",I.output=K,O.output+=I.output)}if(pe.length&&ne.type!=="paren"&&(pe[pe.length-1].inner+=ne.value),(ne.value||ne.output)&&$e(ne),I&&I.type==="text"&&ne.type==="text"){I.output=(I.output||I.value)+ne.value,I.value+=ne.value;return}ne.prev=I,s.push(ne),I=ne},zt=(ne,Re)=>{let X={...c[Re],conditions:1,inner:""};X.prev=I,X.parens=O.parens,X.output=O.output,X.startIndex=O.index,X.tokensIndex=s.length;let Ce=(n.capture?"(":"")+X.open;nt("parens"),Ee({type:ne,value:Re,output:O.output?"":f}),Ee({type:"paren",extglob:!0,value:we(),output:Ce}),pe.push(X)},Vn=ne=>{let Re=e.slice(ne.startIndex,O.index+1),X=e.slice(ne.startIndex+2,O.index),Ce=Ise(X,n);if((ne.type==="plus"||ne.type==="star")&&Ce.risky){let Je=Ce.safeOutput?(ne.output?"":f)+(n.capture?`(${Ce.safeOutput})`:Ce.safeOutput):void 0,Bt=s[ne.tokensIndex];Bt.type="text",Bt.value=Re,Bt.output=Je||Dr.escapeRegex(Re);for(let W=ne.tokensIndex+1;W<s.length;W++)s[W].value="",s[W].output="",delete s[W].suffix;O.output=ne.output+Bt.output,O.backtrack=!0,Ee({type:"paren",extglob:!0,value:B,output:""}),St("parens");return}let tt=ne.close+(n.capture?")":""),gt;if(ne.type==="negate"){let Je=K;if(ne.inner&&ne.inner.length>1&&ne.inner.includes("/")&&(Je=_(n)),(Je!==K||Z()||/^\)+$/.test(Ct()))&&(tt=ne.close=`)$))${Je}`),ne.inner.includes("*")&&(gt=Ct())&&/^\.[^\\/.]+$/.test(gt)){let Bt=zO(gt,{...t,fastpaths:!1}).output;tt=ne.close=`)${Bt})${Je})`}ne.prev.type==="bos"&&(O.negatedExtglob=!0)}Ee({type:"paren",extglob:!0,value:B,output:tt}),St("parens")};if(n.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(e)){let ne=!1,Re=e.replace(Ese,(X,Ce,tt,gt,Je,Bt)=>gt==="\\"?(ne=!0,X):gt==="?"?Ce?Ce+gt+(Je?x.repeat(Je.length):""):Bt===0?C+(Je?x.repeat(Je.length):""):x.repeat(tt.length):gt==="."?u.repeat(tt.length):gt==="*"?Ce?Ce+gt+(Je?K:""):K:Ce?X:`\\${X}`);return ne===!0&&(n.unescape===!0?Re=Re.replace(/\\/g,""):Re=Re.replace(/\\+/g,X=>X.length%2===0?"\\\\":X?"\\":"")),Re===e&&n.contains===!0?(O.output=e,O):(O.output=Dr.wrapOutput(Re,O,t),O)}for(;!Z();){if(B=we(),B==="\0")continue;if(B==="\\"){let X=xe();if(X==="/"&&n.bash!==!0||X==="."||X===";")continue;if(!X){B+="\\",Ee({type:"text",value:B});continue}let Ce=/^\\+/.exec(Ct()),tt=0;if(Ce&&Ce[0].length>2&&(tt=Ce[0].length,O.index+=tt,tt%2!==0&&(B+="\\")),n.unescape===!0?B=we():B+=we(),O.brackets===0){Ee({type:"text",value:B});continue}}if(O.brackets>0&&(B!=="]"||I.value==="["||I.value==="[^")){if(n.posix!==!1&&B===":"){let X=I.value.slice(1);if(X.includes("[")&&(I.posix=!0,X.includes(":"))){let Ce=I.value.lastIndexOf("["),tt=I.value.slice(0,Ce),gt=I.value.slice(Ce+2),Je=Rse[gt];if(Je){I.value=tt+Je,O.backtrack=!0,we(),!o.output&&s.indexOf(I)===1&&(o.output=f);continue}}}(B==="["&&xe()!==":"||B==="-"&&xe()==="]")&&(B=`\\${B}`),B==="]"&&(I.value==="["||I.value==="[^")&&(B=`\\${B}`),n.posix===!0&&B==="!"&&I.value==="["&&(B="^"),I.value+=B,$e({value:B});continue}if(O.quotes===1&&B!=='"'){B=Dr.escapeRegex(B),I.value+=B,$e({value:B});continue}if(B==='"'){O.quotes=O.quotes===1?0:1,n.keepQuotes===!0&&Ee({type:"text",value:B});continue}if(B==="("){nt("parens"),Ee({type:"paren",value:B});continue}if(B===")"){if(O.parens===0&&n.strictBrackets===!0)throw new SyntaxError(Eu("opening","("));let X=pe[pe.length-1];if(X&&O.parens===X.parens+1){Vn(pe.pop());continue}Ee({type:"paren",value:B,output:O.parens?")":"\\)"}),St("parens");continue}if(B==="["){if(n.nobracket===!0||!Ct().includes("]")){if(n.nobracket!==!0&&n.strictBrackets===!0)throw new SyntaxError(Eu("closing","]"));B=`\\${B}`}else nt("brackets");Ee({type:"bracket",value:B});continue}if(B==="]"){if(n.nobracket===!0||I&&I.type==="bracket"&&I.value.length===1){Ee({type:"text",value:B,output:`\\${B}`});continue}if(O.brackets===0){if(n.strictBrackets===!0)throw new SyntaxError(Eu("opening","["));Ee({type:"text",value:B,output:`\\${B}`});continue}St("brackets");let X=I.value.slice(1);if(I.posix!==!0&&X[0]==="^"&&!X.includes("/")&&(B=`/${B}`),I.value+=B,$e({value:B}),n.literalBrackets===!1||Dr.hasRegexChars(X))continue;let Ce=Dr.escapeRegex(I.value);if(O.output=O.output.slice(0,-I.value.length),n.literalBrackets===!0){O.output+=Ce,I.value=Ce;continue}I.value=`(${a}${Ce}|${I.value})`,O.output+=I.value;continue}if(B==="{"&&n.nobrace!==!0){nt("braces");let X={type:"brace",value:B,output:"(",outputIndex:O.output.length,tokensIndex:O.tokens.length};F.push(X),Ee(X);continue}if(B==="}"){let X=F[F.length-1];if(n.nobrace===!0||!X){Ee({type:"text",value:B,output:B});continue}let Ce=")";if(X.dots===!0){let tt=s.slice(),gt=[];for(let Je=tt.length-1;Je>=0&&(s.pop(),tt[Je].type!=="brace");Je--)tt[Je].type!=="dots"&>.unshift(tt[Je].value);Ce=Ase(gt,n),O.backtrack=!0}if(X.comma!==!0&&X.dots!==!0){let tt=O.output.slice(0,X.outputIndex),gt=O.tokens.slice(X.tokensIndex);X.value=X.output="\\{",B=Ce="\\}",O.output=tt;for(let Je of gt)O.output+=Je.output||Je.value}Ee({type:"brace",value:B,output:Ce}),St("braces"),F.pop();continue}if(B==="|"){pe.length>0&&pe[pe.length-1].conditions++,Ee({type:"text",value:B});continue}if(B===","){let X=B,Ce=F[F.length-1];Ce&&Q[Q.length-1]==="braces"&&(Ce.comma=!0,X="|"),Ee({type:"comma",value:B,output:X});continue}if(B==="/"){if(I.type==="dot"&&O.index===O.start+1){O.start=O.index+1,O.consumed="",O.output="",s.pop(),I=o;continue}Ee({type:"slash",value:B,output:p});continue}if(B==="."){if(O.braces>0&&I.type==="dot"){I.value==="."&&(I.output=u);let X=F[F.length-1];I.type="dots",I.output+=B,I.value+=B,X.dots=!0;continue}if(O.braces+O.parens===0&&I.type!=="bos"&&I.type!=="slash"){Ee({type:"text",value:B,output:u});continue}Ee({type:"dot",value:B,output:u});continue}if(B==="?"){if(!(I&&I.value==="(")&&n.noextglob!==!0&&xe()==="("&&xe(2)!=="?"){zt("qmark",B);continue}if(I&&I.type==="paren"){let Ce=xe(),tt=B;(I.value==="("&&!/[!=<:]/.test(Ce)||Ce==="<"&&!/<([!=]|\w+>)/.test(Ct()))&&(tt=`\\${B}`),Ee({type:"text",value:B,output:tt});continue}if(n.dot!==!0&&(I.type==="slash"||I.type==="bos")){Ee({type:"qmark",value:B,output:k});continue}Ee({type:"qmark",value:B,output:x});continue}if(B==="!"){if(n.noextglob!==!0&&xe()==="("&&(xe(2)!=="?"||!/[!=<:]/.test(xe(3)))){zt("negate",B);continue}if(n.nonegate!==!0&&O.index===0){Te();continue}}if(B==="+"){if(n.noextglob!==!0&&xe()==="("&&xe(2)!=="?"){zt("plus",B);continue}if(I&&I.value==="("||n.regex===!1){Ee({type:"plus",value:B,output:d});continue}if(I&&(I.type==="bracket"||I.type==="paren"||I.type==="brace")||O.parens>0){Ee({type:"plus",value:B});continue}Ee({type:"plus",value:d});continue}if(B==="@"){if(n.noextglob!==!0&&xe()==="("&&xe(2)!=="?"){Ee({type:"at",extglob:!0,value:B,output:""});continue}Ee({type:"text",value:B});continue}if(B!=="*"){(B==="$"||B==="^")&&(B=`\\${B}`);let X=Sse.exec(Ct());X&&(B+=X[0],O.index+=X[0].length),Ee({type:"text",value:B});continue}if(I&&(I.type==="globstar"||I.star===!0)){I.type="star",I.star=!0,I.value+=B,I.output=K,O.backtrack=!0,O.globstar=!0,at(B);continue}let ne=Ct();if(n.noextglob!==!0&&/^\([^?]/.test(ne)){zt("star",B);continue}if(I.type==="star"){if(n.noglobstar===!0){at(B);continue}let X=I.prev,Ce=X.prev,tt=X.type==="slash"||X.type==="bos",gt=Ce&&(Ce.type==="star"||Ce.type==="globstar");if(n.bash===!0&&(!tt||ne[0]&&ne[0]!=="/")){Ee({type:"star",value:B,output:""});continue}let Je=O.braces>0&&(X.type==="comma"||X.type==="brace"),Bt=pe.length&&(X.type==="pipe"||X.type==="paren");if(!tt&&X.type!=="paren"&&!Je&&!Bt){Ee({type:"star",value:B,output:""});continue}for(;ne.slice(0,3)==="/**";){let W=e[O.index+4];if(W&&W!=="/")break;ne=ne.slice(3),at("/**",3)}if(X.type==="bos"&&Z()){I.type="globstar",I.value+=B,I.output=_(n),O.output=I.output,O.globstar=!0,at(B);continue}if(X.type==="slash"&&X.prev.type!=="bos"&&!gt&&Z()){O.output=O.output.slice(0,-(X.output+I.output).length),X.output=`(?:${X.output}`,I.type="globstar",I.output=_(n)+(n.strictSlashes?")":"|$)"),I.value+=B,O.globstar=!0,O.output+=X.output+I.output,at(B);continue}if(X.type==="slash"&&X.prev.type!=="bos"&&ne[0]==="/"){let W=ne[1]!==void 0?"|$":"";O.output=O.output.slice(0,-(X.output+I.output).length),X.output=`(?:${X.output}`,I.type="globstar",I.output=`${_(n)}${p}|${p}${W})`,I.value+=B,O.output+=X.output+I.output,O.globstar=!0,at(B+we()),Ee({type:"slash",value:"/",output:""});continue}if(X.type==="bos"&&ne[0]==="/"){I.type="globstar",I.value+=B,I.output=`(?:^|${p}|${_(n)}${p})`,O.output=I.output,O.globstar=!0,at(B+we()),Ee({type:"slash",value:"/",output:""});continue}O.output=O.output.slice(0,-I.output.length),I.type="globstar",I.output=_(n),I.value+=B,O.output+=I.output,O.globstar=!0,at(B);continue}let Re={type:"star",value:B,output:K};if(n.bash===!0){Re.output=".*?",(I.type==="bos"||I.type==="slash")&&(Re.output=T+Re.output),Ee(Re);continue}if(I&&(I.type==="bracket"||I.type==="paren")&&n.regex===!0){Re.output=B,Ee(Re);continue}(O.index===O.start||I.type==="slash"||I.type==="dot")&&(I.type==="dot"?(O.output+=b,I.output+=b):n.dot===!0?(O.output+=w,I.output+=w):(O.output+=T,I.output+=T),xe()!=="*"&&(O.output+=f,I.output+=f)),Ee(Re)}for(;O.brackets>0;){if(n.strictBrackets===!0)throw new SyntaxError(Eu("closing","]"));O.output=Dr.escapeLast(O.output,"["),St("brackets")}for(;O.parens>0;){if(n.strictBrackets===!0)throw new SyntaxError(Eu("closing",")"));O.output=Dr.escapeLast(O.output,"("),St("parens")}for(;O.braces>0;){if(n.strictBrackets===!0)throw new SyntaxError(Eu("closing","}"));O.output=Dr.escapeLast(O.output,"{"),St("braces")}if(n.strictSlashes!==!0&&(I.type==="star"||I.type==="bracket")&&Ee({type:"maybe_slash",value:"",output:`${p}?`}),O.backtrack===!0){O.output="";for(let ne of O.tokens)O.output+=ne.output!=null?ne.output:ne.value,ne.suffix&&(O.output+=ne.suffix)}return O};zO.fastpaths=(e,t)=>{let n={...t},i=typeof n.maxLength=="number"?Math.min(ow,n.maxLength):ow,r=e.length;if(r>i)throw new SyntaxError(`Input length: ${r}, exceeds maximum allowed length: ${i}`);e=_z[e]||e;let{DOT_LITERAL:o,SLASH_LITERAL:s,ONE_CHAR:a,DOTS_SLASH:l,NO_DOT:c,NO_DOTS:u,NO_DOTS_SLASH:d,STAR:p,START_ANCHOR:f}=If.globChars(n.windows),g=n.dot?u:c,h=n.dot?d:c,b=n.capture?"":"?:",w={negated:!1,prefix:""},x=n.bash===!0?".*?":p;n.capture&&(x=`(${x})`);let k=T=>T.noglobstar===!0?x:`(${b}(?:(?!${f}${T.dot?l:o}).)*?)`,R=T=>{switch(T){case"*":return`${g}${a}${x}`;case".*":return`${o}${a}${x}`;case"*.*":return`${g}${x}${o}${a}${x}`;case"*/*":return`${g}${x}${s}${a}${h}${x}`;case"**":return g+k(n);case"**/*":return`(?:${g}${k(n)}${s})?${h}${a}${x}`;case"**/*.*":return`(?:${g}${k(n)}${s})?${h}${x}${o}${a}${x}`;case"**/.*":return`(?:${g}${k(n)}${s})?${o}${a}${x}`;default:{let C=/^(.*?)\.(\w+)$/.exec(T);if(!C)return;let K=R(C[1]);return K?K+o+C[2]:void 0}}},$=Dr.removePrefix(e,w),_=R($);return _&&n.strictSlashes!==!0&&(_+=`${s}?`),_};Dz.exports=zO});var Mz=ie((t1e,Lz)=>{"use strict";var Tse=Cz(),UO=Nz(),jz=Cf(),Dse=Of(),Nse=e=>e&&typeof e=="object"&&!Array.isArray(e),Jt=(e,t,n=!1)=>{if(Array.isArray(e)){let u=e.map(p=>Jt(p,t,n));return p=>{for(let f of u){let g=f(p);if(g)return g}return!1}}let i=Nse(e)&&e.tokens&&e.input;if(e===""||typeof e!="string"&&!i)throw new TypeError("Expected pattern to be a non-empty string");let r=t||{},o=r.windows,s=i?Jt.compileRe(e,t):Jt.makeRe(e,t,!1,!0),a=s.state;delete s.state;let l=()=>!1;if(r.ignore){let u={...t,ignore:null,onMatch:null,onResult:null};l=Jt(r.ignore,u,n)}let c=(u,d=!1)=>{let{isMatch:p,match:f,output:g}=Jt.test(u,s,t,{glob:e,posix:o}),h={glob:e,state:a,regex:s,posix:o,input:u,output:g,match:f,isMatch:p};return typeof r.onResult=="function"&&r.onResult(h),p===!1?(h.isMatch=!1,d?h:!1):l(u)?(typeof r.onIgnore=="function"&&r.onIgnore(h),h.isMatch=!1,d?h:!1):(typeof r.onMatch=="function"&&r.onMatch(h),d?h:!0)};return n&&(c.state=a),c};Jt.test=(e,t,n,{glob:i,posix:r}={})=>{if(typeof e!="string")throw new TypeError("Expected input to be a string");if(e==="")return{isMatch:!1,output:""};let o=n||{},s=o.format||(r?jz.toPosixSlashes:null),a=e===i,l=a&&s?s(e):e;return a===!1&&(l=s?s(e):e,a=l===i),(a===!1||o.capture===!0)&&(o.matchBase===!0||o.basename===!0?a=Jt.matchBase(e,t,n,r):a=t.exec(l)),{isMatch:!!a,match:a,output:l}};Jt.matchBase=(e,t,n)=>(t instanceof RegExp?t:Jt.makeRe(t,n)).test(jz.basename(e));Jt.isMatch=(e,t,n)=>Jt(t,n)(e);Jt.parse=(e,t)=>Array.isArray(e)?e.map(n=>Jt.parse(n,t)):UO(e,{...t,fastpaths:!1});Jt.scan=(e,t)=>Tse(e,t);Jt.compileRe=(e,t,n=!1,i=!1)=>{if(n===!0)return e.output;let r=t||{},o=r.contains?"":"^",s=r.contains?"":"$",a=`${o}(?:${e.output})${s}`;e&&e.negated===!0&&(a=`^(?!${a}).*$`);let l=Jt.toRegex(a,t);return i===!0&&(l.state=e),l};Jt.makeRe=(e,t={},n=!1,i=!1)=>{if(!e||typeof e!="string")throw new TypeError("Expected a non-empty string");let r={negated:!1,fastpaths:!0};return t.fastpaths!==!1&&(e[0]==="."||e[0]==="*")&&(r.output=UO.fastpaths(e,t)),r.output||(r=UO(e,t)),Jt.compileRe(r,t,n,i)};Jt.toRegex=(e,t)=>{try{let n=t||{};return new RegExp(e,n.flags||(n.nocase?"i":""))}catch(n){if(t&&t.debug===!0)throw n;return/$^/}};Jt.constants=Dse;Lz.exports=Jt});var Tf=ie((n1e,Gz)=>{"use strict";var Fz=Mz(),jse=Cf();function Bz(e,t,n=!1){return t&&(t.windows===null||t.windows===void 0)&&(t={...t,windows:jse.isWindows()}),Fz(e,t,n)}Object.assign(Bz,Fz);Gz.exports=Bz});import{dirname as Lse}from"path";import{fileURLToPath as Mse}from"url";import{createHash as Fse}from"crypto";import{execFile as Bse}from"child_process";function VO(){return sw=new HO,sw}function ot(){return sw||VO()}function qO(e){return Lse(Mse(e))}var Wz,HO,sw,no=v(()=>{"use strict";Wz=Le(Tf(),1),HO=class{constructor(){this.name="node";this.hashAlgorithm="sha256";this.commands={runner:"node",exec:"npx",packCmd:["npm","pack"]}}hash(t){return Fse("sha256").update(t).digest("hex")}globMatch(t,n){return(0,Wz.default)(t)(n)}async spawn(t,n){return new Promise(i=>{let r=Bse(t[0],t.slice(1),{cwd:n?.cwd,maxBuffer:10485760,...n?.env?{env:{...process.env,...n.env}}:{}},(o,s,a)=>{i({stdout:s??"",stderr:a??"",exitCode:o?o.code??1:0})});r.stdin&&(r.stdin.on("error",()=>{}),r.stdin.end(n?.stdin??""))})}}});import{createHmac as Gse,timingSafeEqual as l1e}from"node:crypto";function KO(e=aw){let t=e.toLowerCase();return{signature:`${t}-signature`,timestamp:`${t}-timestamp`,event:`${t}-event`,delivery:`${t}-delivery`}}function JO(e,t,n){return`sha256=${Gse("sha256",e).update(`${String(t)}.${n}`,"utf8").digest("hex")}`}var aw,ZO=v(()=>{"use strict";aw="x-chant"});import{createHash as Wse,randomUUID as zse}from"node:crypto";function Hse(e){let t={};e.CI_JOB_URL?t.url=e.CI_JOB_URL:e.GITHUB_SERVER_URL&&e.GITHUB_REPOSITORY&&e.GITHUB_RUN_ID?t.url=`${e.GITHUB_SERVER_URL}/${e.GITHUB_REPOSITORY}/actions/runs/${e.GITHUB_RUN_ID}`:e.CI_PIPELINE_URL&&(t.url=e.CI_PIPELINE_URL),e.GITLAB_CI==="true"?t.forge="gitlab":e.GITEA_ACTIONS==="true"||e.FORGEJO_ACTIONS==="true"?t.forge="forgejo":e.GITHUB_ACTIONS==="true"&&(t.forge="github");let n=e.GITHUB_REPOSITORY||e.CI_PROJECT_PATH;n&&(t.repository=n);let i=e.GITHUB_SHA||e.CI_COMMIT_SHA;return i&&(t.commit=i),t}function Hz(e,t={}){let n=t.env??process.env,{id:i,project:r,targets:o,run:s,...a}=e,l={...Hse(n),...s??{}},c=r??l.repository??"this project",u=e.digest??e.drift?.fingerprint??l.commit,d=i??(u?Wse("sha256").update(JSON.stringify([e.source,c,e.event,e.wave?.number??null,e.environment??null,u])).digest("hex"):zse());return{schema:Use,id:d,at:(t.now??new Date).toISOString(),...a,project:c,targets:o??[],...Object.keys(l).length>0?{run:l}:{}}}function Vz(e){if(e.summary)return`${e.source}: ${e.summary}`;let t=e.wave?`wave ${e.wave.number}${e.wave.name?` (${e.wave.name})`:""} of ${e.project}`:e.environment?`${e.environment} in ${e.project}`:e.project;return`${e.source}: ${t} ${Vse[e.event]}`}function qz(e){let t=[];return e.approve?.review&&t.push({title:"Review and approve",value:`pull request ${e.approve.review.pr}, then run it again`,link:e.approve.review.url}),e.drift?(e.drift.changed.length>0&&t.push({title:"Drifted",value:e.drift.changed.join(", ")}),e.drift.missing?.length&&t.push({title:"Missing",value:e.drift.missing.join(", ")}),e.drift.failed?.length&&t.push({title:"Not refreshed",value:e.drift.failed.join(", ")})):e.targets.length>0&&t.push({title:"Targets",value:e.targets.join(", ")}),e.digest&&t.push({title:"Digest",value:e.digest}),e.approve&&t.push({title:e.approve.review?"Or approve":"Approve",value:e.approve.command}),e.reason&&t.push({title:"Reason",value:e.reason}),e.run?.url&&t.push({title:"Run",value:e.run.url,link:e.run.url}),e.reportUrl&&t.push({title:"Report",value:e.reportUrl,link:e.reportUrl}),t}function qse(e){let t=[`*${Vz(e)}*`];for(let n of qz(e))n.title==="Review and approve"?t.push(`${n.title}: <${n.link}|pull request ${e.approve.review.pr}>, then run it again`):n.title==="Approve"||n.title==="Or approve"||n.title==="Digest"?t.push(`${n.title}: \`${n.value}\``):n.link?t.push(`${n.title}: <${n.link}>`):t.push(`${n.title}: ${n.value}`);return{text:t.join(`
|
|
53
|
+
`)}}function Kse(e){let t=qz(e),n=[...e.approve?.review?[{type:"Action.OpenUrl",title:"Review and approve",url:e.approve.review.url}]:[],...e.run?.url?[{type:"Action.OpenUrl",title:"Open the run",url:e.run.url}]:[]];return{type:"message",attachments:[{contentType:"application/vnd.microsoft.card.adaptive",contentUrl:null,content:{$schema:"http://adaptivecards.io/schemas/adaptive-card.json",type:"AdaptiveCard",version:"1.4",body:[{type:"TextBlock",text:Vz(e),weight:"Bolder",wrap:!0},{type:"FactSet",facts:t.map(i=>({title:i.title,value:i.link&&i.title==="Review and approve"?`${i.value}: ${i.link}`:i.value}))}],...n.length>0?{actions:n}:{}}}]}}function cw(e,t="notify"){if(typeof e!="object"||e===null||Array.isArray(e))return`${t}: expected { webhook, key, slack, teams, events }`;let n=e;for(let i of Object.keys(n))if(!Uz.includes(i))return`${t}.${i}: unknown setting (expected ${Uz.join(", ")})`;for(let i of["webhook","key","slack","teams"]){let r=n[i];if(r!==void 0&&(typeof r!="string"||!Jse.test(r)))return`${t}.${i}: the name of the environment variable that holds the ${i==="key"?"signing key":"URL"}, never the ${i==="key"?"key":"URL"} itself`}if(n.webhook!==void 0&&n.key===void 0)return`${t}.key: a webhook needs a signing key; name the variable that holds it`;if(n.key!==void 0&&n.webhook===void 0)return`${t}.webhook: a key is for a webhook; name the variable that holds its URL`;if(n.webhook===void 0&&n.slack===void 0&&n.teams===void 0)return`${t}: name a webhook (with its key), a slack or a teams URL variable`;if(n.events!==void 0&&!(Array.isArray(n.events)&&n.events.every(i=>zz.includes(i))))return`${t}.events: a list of ${zz.join(", ")}`}function Zse(e,t,n={}){let i=JSON.stringify(e),r=n.now??Math.floor(Date.now()/1e3),o=KO(n.prefix??aw);return{body:i,headers:{"content-type":"application/json","user-agent":n.userAgent??e.source,[o.event]:e.event,[o.delivery]:e.id,[o.timestamp]:String(r),[o.signature]:JO(t,r,i)}}}function Kz(e,t){let n=e;for(let i of t)i&&(n=n.split(i).join("<url>"));return n.replace(/https?:\/\/\S+/g,"<url>")}async function Yse(e,t,n,i,r){let o="not attempted";for(let s=0;s<i;s++){s>0&&await r(500*s);try{let a=await e(t,{method:"POST",...n,signal:AbortSignal.timeout(1e4)});if(a.ok)return;if(o=`HTTP ${String(a.status)}`,a.status<500)return o}catch(a){o=Kz(a instanceof Error?a.message:String(a),[t])}}return o}async function Jz(e,t,n={}){if(!e||!t)return[];if(e.events&&!e.events.includes(t.event))return[];let i=n.env??process.env,r=n.fetch??((d,p)=>globalThis.fetch(d,p)),o=Math.max(1,n.attempts??3),s=n.sleep??(d=>new Promise(p=>setTimeout(p,d))),a=n.log??(d=>process.stderr.write(d+`
|
|
54
|
+
`)),l=[],c=async(d,p,f)=>{let g;try{let h=i[p];if(!h)g={target:d,ok:!1,detail:`${p} is not set`};else{let b=f();if(typeof b=="string")g={target:d,ok:!1,detail:b};else{let w=await Yse(r,h,b,o,s);g={target:d,ok:w===void 0,detail:w??"delivered"}}}}catch(h){g={target:d,ok:!1,detail:Kz(h instanceof Error?h.message:String(h),[i[p]??""])}}g.ok||a(`notify: the ${t.event} event was not delivered to ${Xse[d]}: ${g.detail}`),l.push(g)},u=d=>({headers:{"content-type":"application/json"},body:JSON.stringify(d)});return e.webhook&&await c("webhook",e.webhook,()=>{let d=e.key?i[e.key]:void 0;return d?Zse(t,d,{...n.now!==void 0?{now:n.now}:{},...n.prefix?{prefix:n.prefix}:{},...n.userAgent?{userAgent:n.userAgent}:{}}):`${e.key??"the key variable"} is not set, and an event is never sent unsigned`}),e.slack&&await c("slack",e.slack,()=>u((n.render?.slack??qse)(t))),e.teams&&await c("teams",e.teams,()=>u((n.render?.teams??Kse)(t))),l}var Use,zz,Vse,Jse,Uz,Xse,lw=v(()=>{"use strict";ZO();ZO();Use="chant.notify/v1",zz=["waiting","refused","failed","drift"];Vse={waiting:"waits for an approval",refused:"was refused",failed:"failed",drift:"drifted"};Jse=/^[A-Za-z_][A-Za-z0-9_]*$/,Uz=["webhook","key","slack","teams","events"];Xse={webhook:"the webhook",slack:"Slack",teams:"Teams"}});function Zz(e,t,n,i={}){let o=e.waves[t-1]?.name,s=`wave ${t}${o?` (${o})`:""} of ${e.name}`;if(n.error!==void 0)return{source:"chant",event:"failed",summary:`${s} failed`,wave:{number:t,...o?{name:o}:{}},targets:[],reason:n.error,exitCode:1};let{result:a}=n,l=a.decision,c={source:"chant",wave:{number:t,...o?{name:o}:{},...l?.gate?{gate:l.gate}:{}},...l?.digest?{digest:l.digest}:{},exitCode:a.exitCode};if(a.exitCode===3){if(!l)return;let u=a.hooks.filter(p=>p.outcome==="held");if(i.share!==void 0&&u.length===0)return;let d=l.review?.pr!==void 0&&l.review.url?{review:{pr:l.review.pr,url:l.review.url}}:{};return{...c,event:"waiting",status:"waiting",summary:`${s} waits for an approval`,targets:l.members.map(p=>p.member),approve:{command:l.approve??`chant approve ${l.op} ${l.gate} --plan ${l.digest}`,...d},...l.heldOn?{reason:`held on ${l.heldOn.op} / ${l.heldOn.gate} by ${l.heldOn.hook}`}:l.heldBy?.length?{reason:`held by ${l.heldBy.join(", ")}`}:l.review?.reason?{reason:l.review.reason}:{}}}if(a.exitCode===8&&l?.refused?.reason==="point")return{...c,event:"refused",status:"point",summary:`${s} refused: decision point ${l.point?.name??""} answered ${JSON.stringify(l.point?.answer?.answer??null)}`,targets:l.refused.runs,...l.refused.message?{reason:l.refused.message}:{}};if(a.exitCode===7&&l?.refused)return{...c,event:"refused",status:l.refused.reason==="override-moved"?"override-moved":"denied",summary:`${s} refused: the policy denied ${l.refused.runs.join(", ")}`,targets:l.refused.runs,reason:l.refused.reason==="override-moved"?"an override stands for an earlier plan or other rules, so it counts for nothing":"the policy denied these runs, and no override counts for them"};if(!(a.exitCode===6&&a.outcome?.outcome==="stood-down")){if(a.exitCode===5&&a.outcome?.outcome==="held"){let u=a.outcome.holder;return{...c,event:"refused",status:"held",summary:`${s} applied nothing: another run${u?` (${u.run})`:""} holds what it changes`,targets:l?.members.map(d=>d.member)??[],reason:a.outcome.reason??`another run${u?`, ${u.run},`:""} holds what the apply changes; apply again once it is done`}}if(a.exitCode===4)return{...c,event:"refused",status:"moved",summary:`${s}${i.share!==void 0?`, share ${i.share},`:""} refused ${a.moved.length} run${a.moved.length===1?"":"s"} whose plan moved since the wave was decided`,targets:a.moved,reason:"their plans moved since the wave was decided, so they were not applied"};if(a.exitCode!==0){let u=a.hooks.filter(d=>d.outcome==="failed").map(d=>`${d.moment} hook ${d.name}${d.target?` (${d.target})`:""}`);return a.failed.length===0&&u.length>0?{...c,event:"failed",status:"failed",summary:`${s} failed: ${u.join(", ")} failed`,targets:[],reason:`${u.join(", ")} exited non-zero`}:{...c,event:"failed",status:"failed",summary:`${s} failed: ${a.failed.length>0?`${a.failed.join(", ")} did not apply`:`exit ${a.exitCode}`}`,targets:a.failed,...a.failed.length>0?{reason:`the apply command failed for ${a.failed.join(", ")}`}:{}}}}}async function uw(e,t,n,i={},r={}){if(!e.notify||cw(e.notify)!==void 0)return[];try{let o=Zz(e,t,n,i);return o?await Jz(e.notify,Hz(o,{...r.env?{env:r.env}:{}}),r):[]}catch(o){return(r.log??(s=>process.stderr.write(s+`
|
|
55
|
+
`)))(`notify: nothing was sent: ${o instanceof Error?o.message:String(o)}`),[]}}var YO=v(()=>{"use strict";lw()});var Xz={};_e(Xz,{DEPRECATED_GATE_KEY_WARNING:()=>Yz,FAN_OUT_GATE_OP:()=>Au,OVERRIDE_GATE_OP:()=>ea,WORKSPACE_UPGRADE_GATE_OP:()=>Pu,gateName:()=>$c,isNeverOverMcpGateOp:()=>XO,opUsesDeprecatedGateKey:()=>eae,usesDeprecatedGateKey:()=>QO});function XO(e){return e===Au||e===Pu||e===ea||Qse.test(e)}function $c(e){return e.gate??e.signalName??""}function QO(e){return e.gate===void 0&&typeof e.signalName=="string"}function eae(e){let t=i=>i.kind==="gate"?QO(i):i.kind==="effect"?i.steps.some(t):!1,n=i=>(i??[]).some(r=>r.steps.some(t));return n(e.phases)||n(e.onFailure)}var Au,Pu,ea,Qse,Yz,Oi=v(()=>{"use strict";Au="fan-out",Pu="workspace-upgrade",ea="policy-override",Qse=/^pr-\d+(?:-[a-z0-9][a-z0-9-]*)?$/;Yz='Gate steps still using "signalName": the key is now "gate" (chant #2202). "signalName" is accepted through 0.59.0 and removed in 0.60.0.'});function Ou(e){return typeof e=="object"&&e!==null&&Ci in e&&e[Ci]===!0}var Ci,Qo=v(()=>{"use strict";Ci=Symbol.for("chant.intrinsic")});var Qz,es,Cu=v(()=>{"use strict";Qo();es=class{constructor(t,n){this[Qz]=!0;this.parent=new WeakRef(t),this.attribute=n}_setLogicalName(t){this.logicalName=t}getLogicalName(){return this.logicalName}toString(){let t=this.logicalName?`${this.logicalName}.${this.attribute}`:`.${this.attribute}`;throw new Error(`A resource attribute reference (${t}) has no string form: it stands for a value the build resolves later, and interpolating it into a plain template literal would produce "[object Object]". Use the lexicon's own intrinsic, whose interior handles references \u2014 \`Sub\`\${\u2026}\`\` for CloudFormation \u2014 or move the reference out of the template.`)}[(Qz=Ci,Symbol.toPrimitive)](){return this.toString()}toJSON(){if(!this.logicalName)throw new Error(`Cannot serialize AttrRef for attribute "${this.attribute}": logical name not set`);return{__attrRef:{entity:this.logicalName,attribute:this.attribute}}}}});function dn(e){return e instanceof es?!0:typeof e=="object"&&e!==null&&"parent"in e&&"attribute"in e&&"_setLogicalName"in e&&typeof e.parent=="object"&&typeof e.attribute=="string"}function pn(e,t){return t&&typeof t=="object"&&!Array.isArray(t)?Object.fromEntries(Object.entries(t).sort(([n],[i])=>n.localeCompare(i))):t}function eU(e){let t=[],n=e;for(let i in n)if(Object.prototype.hasOwnProperty.call(n,i)){let r=n[i];dn(r)&&t.push(i)}return t}var eC,Wt=v(()=>{"use strict";Cu();eC=Symbol.for("chant.logicalName")});function Xr(e){return e!==void 0&&tae.has(e)}function ts(){if(tC!=="cli")return tC;let e=process.env[nae];return e==="mcp"||e==="acp"?e:tC}function tU(e,t){if(Xr(t)&&e===t)return`the gate was reached over ${t} and this resolution arrived over ${t} too, so the same caller wrote both halves`}var tae,dw,tC,nae,Rc=v(()=>{"use strict";tae=new Set(["mcp","acp"]);dw="unattested",tC="cli",nae="CHANT_GATE_ORIGIN"});var nC,nU=v(()=>{nC={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://intentius.io/chant/schemas/workspace/declaration/v1/chant.workspace.schema.json",title:"chant.workspace.json",description:"A workspace declaration, schema 1 (#2524 D1, D2; ws-051). Only this file makes a directory a workspace. It may also be named chant.workspace.jsonc, which allows comments and trailing commas; having both is an error. Unknown fields are refused, except fields whose names start with x-. A field added later within schema 1 is optional, and a declaration that uses one sets minReader to the first chant that knows it, so an older chant says so instead of misreading the file. Uniqueness of names and the placement rules are checked in code, since JSON Schema cannot say them.",type:"object",required:["name","schema","members"],properties:{$schema:{type:"string",description:"An editor hint. chant ignores it."},$comment:{type:"string",description:"A note for people. chant ignores it."},name:{$ref:"#/$defs/name",description:"The workspace's name. With a git revision it identifies the workspace to readers (#2524 D15)."},schema:{const:1,description:"The declaration format version."},minReader:{$ref:"#/$defs/version",description:"The oldest chant that may read this declaration. An older chant refuses it with reader-too-old."},members:{type:"array",description:"Members and example groups, in the order readers list them.",items:{$ref:"#/$defs/entry"}},pins:{type:"array",description:"The toolchain and plugins that read this workspace, pinned (#2524 D3, threat model). Member kinds come only from pinned packages, read as data from their ./workspace-kinds subpath (#2535).",items:{$ref:"#/$defs/pin"}},quorum:{type:"integer",minimum:0,description:"How many agree verdicts besides the decider's a record needs, for every record kind with a reviews list (#2671). chant workspace records reports each record's quorum against it. Two when absent. Added in schema 1 by chant 0.86.0, so a declaration that sets it sets minReader to 0.86.0 or newer. A per-kind quorum comes later (#2650 C14)."},records:{type:"array",description:"The workspace's own record kinds, each a kind file relative to the workspace root (#2680): the kinds whose records belong to no one member, such as a decisions directory at the root. A member names its own in its records. chant workspace ls lists them, and chant workspace records and graph --intent read every declared kind when --kind is not given. Added in schema 1 by chant 0.86.0, so a declaration that uses it sets minReader to 0.86.0 or newer.",items:{$ref:"#/$defs/recordKind"}},hosts:{type:"array",description:"The hosts boxes run on (#2727). A host is one machine reached under one hostname: boxes on it share its ports, its state root and, in a browser, its cookie jar, so chant workspace check compares the boxes on one host and never boxes on different hosts. A member's box block names its host. Added in schema 1 by chant 0.91.0, so a declaration that uses it sets minReader to 0.91.0 or newer.",items:{$ref:"#/$defs/host"}},diagrams:{type:"array",description:"The workspace's own diagram artifacts (#2764): the diagrams that belong to no one member, such as a diagrams directory at the root. A member names its own in its diagrams. chant workspace ls lists every declared diagram, and chant workspace check reports one whose render is stale for its source when the entry records a sourceHash. Added in schema 1 by chant 0.91.0, so a declaration that uses it sets minReader to 0.91.0 or newer.",items:{$ref:"#/$defs/diagram"}},checks:{type:"object",description:"Severity for the declaration checks that allow it, keyed by WSP id (#2535, ws-028): error, warning, info or off. chant workspace check refuses an id it does not know, and one whose severity is fixed.",propertyNames:{pattern:"^WSP[0-9]{3}$"},additionalProperties:{$ref:"#/$defs/severity"}},changes:{type:"object",additionalProperties:!1,description:"The forward coverage check, chant workspace check --changes <base>..<head> (#2773): each path a diff changes is mapped to the current records whose constrains cover it. severity says what a finding does: off reports none, warn (the default) reports them and passes, fail reports them and fails. ignore lists globs over files whose changes need no record, such as lockfiles and generated output. Added in schema 1 by chant 0.92.0, so a declaration that uses it sets minReader to 0.92.0 or newer.",properties:{severity:{enum:["off","warn","fail"],description:"What a change-uncovered or change-out-of-scope finding does. warn when absent."},ignore:{type:"array",description:"Globs over file paths from the workspace root: * and ? within one segment, ** across segments. A changed path one matches is listed as ignored and never reported.",items:{$ref:"#/$defs/fileGlob"}}}},writeScope:{type:"object",propertyNames:{$ref:"#/$defs/className"},additionalProperties:{$ref:"#/$defs/classScope",description:"A domain class a pinned package supplies at its ./workspace-principals subpath (#3080, ws-079): principals holding the role the class names in the trust policy at base, and none of the agent, runner and service roles. A key no pinned package supplies fails chant workspace check with WSP003, and a writer judged human is refused with write-scope-class-unknown, since it may be in that class. Added in schema 1 by chant 0.102.0, so a declaration that uses one sets minReader to 0.102.0 or newer."},description:"Who may write what (#2524 D5, #2548, ws-067): for each principal class, the members whose files it may write and the record kinds it may write, with which verbs. A class is human, agent, runner or service, or a domain class a pinned package supplies (#3080). A class with no entry is not restricted. An agent is always bound to its session's member (agents); its entry can only narrow the record kinds and verbs. chant workspace records new, amend, review and close and the MCP record tools refuse a write outside the writer's scope with write-scope-member or write-scope-kind, and chant workspace check --changes reports each commit that writes outside its author's scope, read from the declaration and the trust policy at the range's base, and a write to a path the class's protected list covers with write-scope-protected (#3146). Added in schema 1 by chant 0.101.0, so a declaration that uses it sets minReader to 0.101.0 or newer.",properties:{human:{$ref:"#/$defs/classScope",description:"Principals holding none of the agent, runner and service roles, and none of the roles a domain class names, in the trust policy at base."},agent:{$ref:"#/$defs/agentScope",description:"An agent session (agents), or a principal holding the agent role in the trust policy at base."},runner:{$ref:"#/$defs/classScope",description:"Principals holding the runner role in the trust policy at base, such as a CI job's signing identity."},service:{$ref:"#/$defs/classScope",description:"Principals holding the service role in the trust policy at base."}}},agents:{type:"array",description:"The agent sessions the workspace declares (#2524 D20, #2548, ws-067, ws-101). Each is bound to the members it names, one with member or several with members: it writes the files of any of them and the records of kinds any of them or the workspace declares, as writeScope.agent allows. A session resumes from chant workspace agent <name> --json, which prints its member, its scope and the spec, read from the repository alone. A write names its session with the CHANT_AGENT environment variable, or a commit with a Chant-Agent trailer. Added in schema 1 by chant 0.101.0, so a declaration that uses it sets minReader to 0.101.0 or newer.",items:{$ref:"#/$defs/agent"}},identity:{type:"object",additionalProperties:!1,description:"Who a person-attributed record or gate approval may name, and which gates need a signed approval (#3163, ws-080). Read from the declaration at base, like writeScope, so a change can't loosen its own rule. A person is named by a forge identity (github:<login>, gitlab:<login>, or <forge>@<host>:<login> for forgejo, gitea or a self-hosted github or gitlab) that the surface which signed them in maps their session to, or by a principal .chant/allowed_signers lists at base. chant never authenticates a person: a forge identity is recorded as the surface gives it, and only a seal verified against the signers at base attests it. Added in schema 1 by chant 0.102.0, so a declaration that uses it sets minReader to 0.102.0 or newer.",properties:{attribution:{enum:["any","identified"],description:"any (the default): a record's by, decided_by, reviewer or answerer and a gate approval's actor may be any name, such as a roster name. identified: each must be a forge identity, a principal the signers file at base lists, or a principal holding the agent, runner or service role at base or listed by a declared agent session; chant workspace records new and review, points answer and chant approve refuse any other name with principal-unidentified."},gates:{type:"object",description:"Gates, by name, that pass only on a signed approval: chant approve --sign with a key the signers file at base lists for the approver. The rule applies to a gate of that name in every member, Op and component. An unsigned approval, or one whose signer is not in class, is recorded nowhere and never counts toward the gate.",propertyNames:{type:"string",minLength:1},additionalProperties:{type:"object",additionalProperties:!1,properties:{class:{$ref:"#/$defs/className",description:"The principal class the signer must be in, read from the role grants at base (#3080, ws-079): human, runner, service, or a domain class a pinned package supplies. A class no pinned package supplies lets no approval through (fail closed). Absent: any signer the signers file lists."}}}}}},ci:{type:"object",additionalProperties:!1,patternProperties:{"^x-":!0},description:"What the workspace's CI decides about its commits (#3573, ws-103). Added in schema 1 by chant 0.108.0, so a declaration that uses it sets minReader to 0.108.0 or newer.",properties:{green:{$ref:"#/$defs/ciGreen"}}}},patternProperties:{"^x-":!0},additionalProperties:!1,$defs:{name:{type:"string",pattern:"^[a-z0-9][a-z0-9-]{0,39}$",description:"Lowercase letters, digits and hyphens, starting with a letter or digit, at most 40 characters. _workspace and _members are reserved; the pattern already rules them out."},kindName:{type:"string",pattern:"^[a-z][a-z0-9-]{0,39}$"},className:{type:"string",pattern:"^(?!x-)[a-z][a-z0-9-]{0,39}$",description:"A principal class: human, agent, runner, service, or a domain class a pinned package supplies (#3080)."},version:{type:"string",pattern:"^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(-[0-9A-Za-z.-]+)?$"},dir:{type:"string",description:'A directory relative to the workspace root, with / separators: "." for the root itself, otherwise no leading /, no . or .. segments and no trailing /.',pattern:"^(\\.|(?!\\.\\.?(/|$))[^/\\\\]+(/(?!\\.\\.?(/|$))[^/\\\\]+)*)$"},glob:{type:"string",description:"A glob over directories, relative to the workspace root: * and ? within one segment, ** across segments, [...] classes. No leading /, no . or .. segments.",pattern:"^(?!\\.\\.?(/|$))[^/\\\\]+(/(?!\\.\\.?(/|$))[^/\\\\]+)*$"},severity:{enum:["error","warning","info","off"]},suppress:{type:"array",description:"Declaration checks suppressed for this entry (#2535). Each names a WSP id and says why. A suppressed finding is still reported, as suppressed, and never fails check.",items:{type:"object",required:["check","because"],properties:{check:{type:"string",pattern:"^WSP[0-9]{3}$"},because:{type:"string",minLength:1}},patternProperties:{"^x-":!0},additionalProperties:!1}},outputName:{type:"string",minLength:1,maxLength:255,pattern:"^[^\\u0000-\\u001f]+$",description:"An output's name, compared exactly."},link:{type:"object",description:"A member link: this member reads output of member (#2539), or sends its telemetry to a pipeline of its collector (#2558).",required:["member","output"],properties:{member:{$ref:"#/$defs/name",description:"The producer: another member of this workspace."},output:{$ref:"#/$defs/outputName",description:"The producer's output, matched exactly. It must be one the producer's kind exposes. For a telemetry link, the id of a pipeline or an exporter in the producer's collector."},kind:{$ref:"#/$defs/kindName",description:"The link kind. output, the default: the consumer reads the named output. telemetry (#2558): the consumer sends its telemetry to the named pipeline or exporter of the producer's collector, and chant workspace graph checks that it exists and, when protocol is given, that it speaks it. A declaration that uses telemetry sets minReader to 0.101.0 or newer."},protocol:{enum:["grpc","http/protobuf","http/json"],description:"For a telemetry link, the OTLP protocol the consumer sends, as OTEL_EXPORTER_OTLP_PROTOCOL names it. Refused on any other kind. Added in schema 1 by chant 0.101.0."}},patternProperties:{"^x-":!0},additionalProperties:!1},entry:{description:"A member, or an example group when kind is examples (ws-051).",type:"object",required:["kind"],properties:{kind:{$ref:"#/$defs/kindName"}},if:{type:"object",properties:{kind:{const:"examples"}},required:["kind"]},then:{$ref:"#/$defs/group"},else:{$ref:"#/$defs/member"}},member:{type:"object",description:"A member (#2524 D2). Its directory leaves the root project, and it gets its own build, lint and ledger.",required:["name","dir","kind"],properties:{name:{$ref:"#/$defs/name",description:"Frozen once the member deploys; a rename is an alias record."},dir:{$ref:"#/$defs/dir"},kind:{$ref:"#/$defs/kindName",description:"How to read the member: chant, workspace, other, or a kind a pinned plugin supplies (#2535)."},roles:{type:"array",description:"Roles the member plays. A role may point at a path inside the member.",items:{oneOf:[{$ref:"#/$defs/kindName"},{type:"object",required:["name"],properties:{name:{$ref:"#/$defs/kindName"},path:{$ref:"#/$defs/dir",description:"Relative to the member's directory."}},patternProperties:{"^x-":!0},additionalProperties:!1}]}},generated:{type:"array",description:"Files in the member's directory that a command writes (#2524 D14, #2541). chant workspace check fails when one differs from what its generator writes, unless the entry is marked handWritten with a reason. The lineage lock classes the same files as generated. skills/*/SKILL.md, which chant update writes, is listed implicitly for a chant member.",items:{$ref:"#/$defs/generatedFile"}},outputs:{type:"array",uniqueItems:!0,description:"The outputs this member exposes as link targets (#2539), for a member whose kind takes them from the entry: other, or a kind a pinned package supplies. A chant member's outputs are read from its source, and a nested workspace exposes none.",items:{$ref:"#/$defs/outputName"}},fields:{$ref:"#/$defs/memberFields"},links:{type:"array",description:"Member links (#2524 D6, #2539): the outputs of other members this member reads. A link is stated once, here on the consumer, and matched exactly against the producer's outputs. chant workspace check resolves it in source.",items:{$ref:"#/$defs/link"}},records:{type:"array",description:"The record kinds this member holds, each a kind file relative to the member's directory (#2680). chant workspace ls lists them, and chant workspace records and graph --intent read every declared kind when --kind is not given. Added in schema 1 by chant 0.86.0, so a declaration that uses it sets minReader to 0.86.0 or newer.",items:{$ref:"#/$defs/recordKind"}},diagrams:{type:"array",description:"The diagram artifacts this member holds (#2764). chant workspace ls lists every declared diagram, and chant workspace check reports one whose render is stale for its source when the entry records a sourceHash. Added in schema 1 by chant 0.91.0, so a declaration that uses it sets minReader to 0.91.0 or newer.",items:{$ref:"#/$defs/diagram"}},box:{$ref:"#/$defs/box"},upstream:{type:"string",minLength:1,description:"Where an embedded member's files come from. Versions live in the lock."},travel:{type:"boolean",description:"Whether the member goes with an export (#2524 D10, #2552). chant workspace export writes only members that set travel to true into the export member, and refuses to name one that does not. Added in schema 1 by chant 0.101.0, so a declaration that uses it sets minReader to 0.101.0 or newer."},because:{type:"string",minLength:1,description:"Why the member is there. Required for kind other."},suppress:{$ref:"#/$defs/suppress"}},patternProperties:{"^x-":!0},additionalProperties:!1,if:{type:"object",properties:{kind:{const:"other"}},required:["kind"]},then:{type:"object",properties:{because:{type:"string"}},required:["because"]}},memberFields:{type:"object",description:"Values for the fields the member's kind declares (#3151), such as an app member's scripts, env and health. Each is a string, integer or boolean, or an object of those for a field the kind declares as an object. chant workspace check fails when the kind declares no such field or a value is of the wrong type (WSP005), and chant workspace status --json prints every field the kind declares with its defaults filled in. Added in schema 1 by chant 0.103.0, so a declaration that uses it sets minReader to 0.103.0 or newer.",propertyNames:{pattern:"^[a-z][A-Za-z0-9]{0,39}$"},additionalProperties:{oneOf:[{type:"string"},{type:"integer"},{type:"boolean"},{type:"object",propertyNames:{pattern:"^[a-z][A-Za-z0-9]{0,39}$"},additionalProperties:{oneOf:[{type:"string"},{type:"integer"},{type:"boolean"}]}}]}},group:{type:"object",description:"An example group (ws-051): every directory the glob matches that holds a chant project is built and linted. A group has no ledger, releases or links, and its matches are never members. A match may sit inside a member's directory; that member leaves it to the group.",required:["name","kind","glob"],properties:{name:{$ref:"#/$defs/name"},kind:{const:"examples"},glob:{oneOf:[{$ref:"#/$defs/glob"},{type:"array",minItems:1,uniqueItems:!0,items:{$ref:"#/$defs/glob"}}]},suppress:{$ref:"#/$defs/suppress"}},patternProperties:{"^x-":!0},additionalProperties:!1},path:{type:"string",description:"A file or directory path with / separators: no leading /, no . or .. segments and no trailing /.",pattern:"^(?!\\.\\.?(/|$))[^/\\\\]+(/(?!\\.\\.?(/|$))[^/\\\\]+)*$"},box:{type:"object",description:"The member is a box, or holds a box's declarations (#2726). A box holds no credential: each capability it needs outside itself is reached through a broker, a runtime such as a lobby or a door, which holds the credential and enforces the scope. chant workspace check fails when a file in the member's directory carries a literal secret (WSP121) and when a capability names no broker (WSP122). chant workspace status --json lists the capabilities, so a broker can read the scopes. Its host, slot, ports, state and cookies state the box's isolation (#2727): chant derives each value from the box's identity, its host, the member's name and its slot, and prints them in chant workspace status --json, so a runtime reads them instead of choosing its own. chant workspace check fails when two boxes on a host resolve to the same value (WSP123) and when a box hard-codes a machine path (WSP124). A member that builds the fountain lexicon's Box declares the callback token fountain gives its persistent sandbox as the capability fountain-callback, brokered by fountain, with scope owner, or chant workspace check fails (WSP125, #2780). Its intent names the decision record that says what the box is for (#2850): chant workspace status --json reports the record's state and answer, and chant workspace check fails when no decision record has the id (WSP126) and warns when the record constrains no member or path of this workspace (WSP127, #2857). Its services list what the box runs under its supervisor (#2880), which the fly lexicon observes, restarts and applies through sprite-env, and which chant workspace status --json prints. Its factory declares what the box builds, how a build is checked, which member declares the builder agents and where a finished build is published (#3146, ws-077), its listing what the box shows of itself (#3146), and its replicate where the box's work in progress is pushed so a lost box loses none of it (#3172, ws-085). Added in schema 1 by chant 0.91.0, so a declaration that uses it sets minReader to 0.91.0 or newer.",properties:{intent:{type:"string",minLength:1,description:"The id of the decision record that says what the box is for (#2850), a record of a declared kind named decision. A new box starts as a question: the record is proposed with a null choice until the person who answers it decides it. The record constrains a member or path of this workspace, with member:<a member's name> or a path: entry at, above or inside a member's directory. It need not be this member: the intent can constrain the app the box runs when that app is another member (#2857). When it constrains this member, chant workspace graph --intent shows it for the box's files. Added by chant 0.94.0, so a declaration that uses it sets minReader to 0.94.0 or newer."},services:{type:"array",description:"The services the box runs under its supervisor, sprite-env on a sprite (#2880). Each name is given once, every needs entry names a service of this list, the needs form no cycle, and at most one service sets httpPort; a declaration that breaks one of these can't be read (declaration-invalid). The fly lexicon's spriteServicesObserve and spriteServiceRestart read the list with box: true, and spriteApplyServices with box: true creates and replaces the services through sprite-env. None when omitted. Added by chant 0.95.0, so a declaration that uses it sets minReader to 0.95.0 or newer.",items:{$ref:"#/$defs/boxService"}},factory:{$ref:"#/$defs/boxFactory"},listing:{$ref:"#/$defs/boxListing"},publisher:{type:"string",minLength:1,pattern:"\\S",description:"The command that publishes the box's work (#3165, ws-088): it applies a built work item to the box's checkout and, when factory.publish names a target, pushes it and opens the pull request, and it sends the records a person kept uncommitted. It is run from the workspace root by chant workspace box publish, split into words as a shell splits plain words (quotes group, a backslash escapes) but never given to a shell, with a JSON request on stdin; box-publish.schema.json says what it reads and prints. An orchestrator such as studio supplies it. chant workspace status --json prints it under the member's box, so a surface offers a publish only when a box names one. Added in schema 1 by chant 0.103.0, so a declaration that uses it sets minReader to 0.103.0 or newer."},replicate:{$ref:"#/$defs/boxReplicate"},ship:{$ref:"#/$defs/boxShip"},capabilities:{type:"array",description:"Each capability the box reaches outside itself, named once. None when omitted.",items:{$ref:"#/$defs/capability"}},host:{$ref:"#/$defs/name",description:"The host the box runs on, one of the top-level hosts (#2727). The box's name is the member's name."},slot:{type:"integer",minimum:0,description:"The box's number on its host (#2727). Its ports come from the slot's block of the host's range."},ports:{type:"object",description:"The ports the box listens on, each a name and its offset in the box's block (#2727). The port is the block's first port plus the offset.",propertyNames:{$ref:"#/$defs/kindName"},additionalProperties:{type:"integer",minimum:0,maximum:65534}},state:{type:"object",description:"State the box keeps outside its checkout, such as hud's identity and database, each a name and a path relative to the box's state directory (#2727). The name is usually the environment variable the runtime sets, such as HUD_IDENTITY_PATH. A path that is absolute, starts with ~ or an environment reference, or has a .. segment is a WSP124 finding.",propertyNames:{type:"string",pattern:"^[A-Za-z_][A-Za-z0-9_-]{0,63}$"},additionalProperties:{type:"string",minLength:1}},cookies:{type:"array",description:"Session cookie names the box's runtimes set, such as hud_session (#2727). A browser scopes a cookie to a host, not a port, so each resolves to <cookie>_<member name>.",uniqueItems:!0,items:{type:"string",pattern:"^[A-Za-z][A-Za-z0-9_-]{0,63}$"}}},dependentRequired:{host:["slot"],slot:["host"],ports:["host"],state:["host"],cookies:["host"]},patternProperties:{"^x-":!0},additionalProperties:!1},boxFactory:{type:"object",description:"What the box builds and how (#3146, ws-077), replacing studio's x-factory. Opt-in: a box block without it declares no factory, and nothing here is required of a workspace that doesn't build with agents (#3174). At most one box block in a declaration declares a factory. builds and builders name declared members, or the declaration can't be read (declaration-invalid). chant workspace status --json and chant workspace graph --json print it under the member's box. The factory need not build an app: builds may name any member kind, such as chant or terraform, and the check may be a plan, a lint or a conformance run. Added in schema 1 by chant 0.102.0, so a declaration that uses it sets minReader to 0.102.0 or newer.",required:["builds"],properties:{builds:{type:"array",minItems:1,uniqueItems:!0,description:"The members the factory builds, each a declared member of any kind. A work item a person asks for here constrains member:<the first>.",items:{$ref:"#/$defs/name"}},check:{description:"The command whose exit code is a build's verdict, run from the workspace root after the work item's own checks: a command, or { run, kind } saying what it is. kind is test when omitted.",oneOf:[{type:"string",minLength:1},{type:"object",required:["run"],properties:{run:{type:"string",minLength:1,description:"The command, run from the workspace root."},kind:{enum:["test","build","lint","plan","conformance"],description:"What the command is: an app's tests, a build, a lint, a lifecycle plan or a conformance run. test when omitted."}},patternProperties:{"^x-":!0},additionalProperties:!1}]},checks:{$ref:"#/$defs/path",description:"The directory, from the workspace root, where a work item's builder writes the check for its item. When omitted the orchestrator chooses, such as <the first member of builds>/checks."},builders:{$ref:"#/$defs/name",description:"The member that declares the builder agents, such as the one whose agents/ holds them. tiers says which of them builds at which tier (#3152)."},tiers:{type:"array",minItems:1,description:"Which builder agent builds at which tier (#3152, ws-094), replacing studio's studio/role and studio/tier Agent metadata. Each entry names a tier, in the vocabulary of the work kind's work.tier.tiers (#3147), and an agent the builders member declares, by its name. An entry with kinds builds only members of those kinds, so an infra builder and an app builder can share a tier; an entry without kinds builds the tier for every other kind. A tier has at most one entry without kinds and at most one per kind, tiers needs builders, and a session names a declared agent session, or the declaration can't be read (declaration-invalid). chant workspace status --json prints builderFor, the agent for each built member and tier. Added in schema 1 by chant 0.103.0, so a declaration that uses it sets minReader to 0.103.0 or newer.",items:{type:"object",required:["tier","agent"],properties:{tier:{$ref:"#/$defs/kindName",description:"The tier, such as small, medium or large: a word of the work kind's work.tier.tiers, which a work item's tier or the slice-tier decision point answers."},agent:{type:"string",minLength:1,pattern:"^[^\\u0000-\\u001f]+$",description:"The builder agent's name, as the builders member declares it (such as an Agent of the fountain lexicon in its agents/)."},kinds:{type:"array",minItems:1,uniqueItems:!0,items:{$ref:"#/$defs/kindName"},description:"The member kinds this agent builds at the tier, such as app or terraform. Without it, every kind no other entry of the tier names."},session:{$ref:"#/$defs/name",description:"The declared agent session (agents) the builder writes as, so its write scope is that session's. Optional: without it the orchestrator chooses."}},patternProperties:{"^x-":!0},additionalProperties:!1}},publish:{type:"object",description:"Where a finished build is published: its branch is pushed and a pull request opened against repo's base. The repo is the record, so an orchestrator reads this instead of being told the target in its environment.",required:["repo"],properties:{forge:{enum:["github"],description:"The forge repo is on. github when omitted."},repo:{type:"string",pattern:"^[A-Za-z0-9][A-Za-z0-9-]{0,38}/[A-Za-z0-9._-]{1,100}$",description:"The repository the pull request is opened on, as owner/name."},base:{type:"string",minLength:1,description:"The branch the pull request targets. The repository's default branch when omitted."},branchPrefix:{type:"string",minLength:1,pattern:"^[A-Za-z0-9._/-]+$",description:"What the published branch's name starts with; the work item's id follows, as in box/ and then box/work-012. chant/work/ when omitted, the work lease's own branch."},head:{type:"string",pattern:"^[A-Za-z0-9][A-Za-z0-9-]{0,38}/[A-Za-z0-9._-]{1,100}$",description:"The repository the branch is pushed to when it isn't repo, as owner/name: a fork, so the pull request comes from <head owner>:<branch>. A runtime that publishes for one contributor's fork supplies that per contributor instead (arugula-salad/studio#242); this names a fork the whole workspace publishes from."}},patternProperties:{"^x-":!0},additionalProperties:!1}},patternProperties:{"^x-":!0},additionalProperties:!1},boxListing:{type:"object",description:"What the box shows of itself on a home site that lists boxes (#3146, #3154): whether it is listed, its title and one line, and a cover image kept as a file in the repo. A box's listing is configuration, so changing it is a reviewed change (ws-074). chant workspace status --json and chant workspace graph --json print it under the member's box, with the cover's sha256. Added in schema 1 by chant 0.102.0, so a declaration that uses it sets minReader to 0.102.0 or newer.",properties:{published:{type:"boolean",description:"Whether the box is listed. true when omitted: a box is listed unless its owner takes it out."},title:{type:"string",maxLength:60,pattern:"^[^\\u0000-\\u001f\\u007f-\\u009f]*$",description:"The box's title, one line of at most 60 characters. Empty when omitted, and a reader then shows a name of its own."},line:{type:"string",maxLength:140,pattern:"^[^\\u0000-\\u001f\\u007f-\\u009f]*$",description:"One line saying what the box is, at most 140 characters. Empty when omitted."},cover:{$ref:"#/$defs/path",description:"A PNG, JPEG or WebP picture of the box, as a file from the workspace root. None when omitted."}},patternProperties:{"^x-":!0},additionalProperties:!1},boxReplicate:{type:"object",description:"Where the box's work in progress is replicated, so a box that is lost, reclaimed or corrupted before anyone commits loses nothing (#3172, ws-085). Work in progress is the work branches (chant/work/...), the kept attempts (refs/chant/kept/..., #3147), the snapshots chant workspace wip save takes of each branch's working tree, uncommitted records included (refs/chant/wip/<branch>), and the ledger branch, chant/lifecycle. chant pushes them to remote under their own names and never forces a push. Opt-in: a box block without it replicates nothing. At most one box block in a declaration declares one, or the declaration can't be read (declaration-invalid). chant workspace status --json prints it under the member's box, with every default filled in, and reports in replication how far each ref is from the remote. Added in schema 1 by chant 0.103.0, so a declaration that uses it sets minReader to 0.103.0 or newer.",properties:{remote:{type:"string",pattern:"^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$",description:"The git remote to push to, by name: the repository's own remote, such as origin, or a mirror the host adds to the box's checkout with its credential, since a box holds none (#2726). origin when omitted."},refs:{type:"array",minItems:1,uniqueItems:!0,description:"What is replicated: work (the branches under chant/work/), kept (the kept attempts under refs/chant/kept/), wip (the snapshots under refs/chant/wip/) and ledger (the chant/lifecycle branch). All four when omitted.",items:{enum:["work","kept","wip","ledger"]}},on:{type:"array",uniqueItems:!0,description:"When chant pushes on its own: save, after each chant workspace wip save, and release, after a work lease is released (chant workspace work release, or a run of an Op under a work lease ending, which is when a kept attempt is written). Both when omitted; an empty list leaves every push to chant workspace wip push. A record write never pushes, because chant's record writes never run git (ws-074).",items:{enum:["save","release"]}},every:{type:"string",pattern:"^[1-9][0-9]*(s|m|h)$",description:"How often the host runs chant workspace wip push on a schedule of its own, such as 10m, beside the pushes on save and release. chant runs no scheduler; it only states the interval. None when omitted."}},patternProperties:{"^x-":!0},additionalProperties:!1},boxShip:{type:"object",description:"How the box ships its staged work to its own site (ws-100): the people working on a box see the working tree at once, everyone else sees the last release, and a person ships. op is the Op in the box member that does it: its own steps commit the staged tree as one commit by the person shipping (named to it in CHANT_SHIP_BY) with a Chant-Record trailer for each work item it lands, then release that commit to the box's site, stopping at gate, and record the release in env's release ledger. chant runs none of it; a surface runs chant run <op> in the member's directory and approves the gate as for any Op. chant workspace status --json prints it under the member's box with the commit the site serves (the latest release in env's ledger) and what is waiting to ship (the files changed between that commit and the working tree, bookkeeping left out). Added in schema 1 by chant 0.104.0, so a declaration that uses it sets minReader to 0.104.0 or newer.",required:["op"],properties:{op:{type:"string",pattern:"^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$",description:"The name of the Op in the box member that ships, as chant run takes it."},gate:{type:"string",pattern:"^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$",description:"The gate the Op stops at for a person's approval. ship when omitted."},env:{type:"string",pattern:"^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$",description:"The environment whose release ledger, under the box member, the Op records each release in. box when omitted."},bookkeeping:{type:"array",uniqueItems:!0,description:"Path prefixes from the workspace root whose changes are bookkeeping, such as the record directories, and never count as waiting to ship. None when omitted.",items:{type:"string",minLength:1,pattern:"^(?!/)(?!.*(^|/)\\.\\.(/|$))[^\\n]+$"}}},patternProperties:{"^x-":!0},additionalProperties:!1},boxService:{type:"object",description:"A service a box runs under its supervisor (#2880).",required:["name","cmd"],properties:{name:{$ref:"#/$defs/kindName",description:"The service's name in the supervisor. Unique within the box."},cmd:{type:"string",minLength:1,description:"The command the supervisor runs (sprite-env services create --cmd). ${HOME} and other ${VAR} references are expanded from the environment of the process that applies the list, so the declaration holds no machine path."},needs:{type:"array",uniqueItems:!0,description:"Names of services of the same box that start before this one (sprite-env services create --needs).",items:{$ref:"#/$defs/kindName"}},httpPort:{$ref:"#/$defs/port",description:"The port the supervisor routes the sprite's URL to (sprite-env services create --http-port). At most one service of a box sets it."},duration:{type:"string",pattern:"^[0-9]+(\\.[0-9]+)?(ms|s|m)$",description:"How long the service must stay up after it is created or started, such as 3s (sprite-env services create --duration)."},health:{type:"string",pattern:"^https?://",description:"A URL that answers 200 while the service works. spriteServicesObserve probes it, and spriteServiceRestart waits for it after a restart. Without it, the supervisor's state decides."},optional:{type:"boolean",description:"True for a service something else creates by name, such as a site a release Op makes: spriteApplyServices creates it only when its only names it, and spriteServicesObserve skips it while the supervisor has no such service."}},patternProperties:{"^x-":!0},additionalProperties:!1},capability:{type:"object",description:"A capability a box needs and does not hold the credential for, such as inference, fountain or a third-party API (#2726).",required:["name"],properties:{name:{$ref:"#/$defs/kindName",description:"The capability, such as inference or fountain. Unique within the box."},broker:{type:"string",minLength:1,description:"What brokers the capability: the runtime that holds the credential and swaps the box's own token for it, such as lobby or door. It may name a member of this workspace, or a runtime outside it. Without it the capability is unbrokered, and chant workspace check fails with WSP122."},scope:{type:"array",uniqueItems:!0,description:"What of the box's own the broker lets it reach, which the broker enforces. For Fountain: agent (start conversations with its own agent), vault (attach its own vault), conversations and sandboxes (its own). The words are the broker's; chant records them.",items:{type:"string",minLength:1,pattern:"^[^\\u0000-\\u001f]+$"}}},patternProperties:{"^x-":!0},additionalProperties:!1},recordKind:{type:"object",description:"A record kind the workspace declares (#2680): a kind file that exports recordKind. chant workspace check fails (WSP115) when the file is missing or does not load as a record kind.",required:["kind"],properties:{kind:{$ref:"#/$defs/path",description:"The kind file, relative to the member's directory, or to the workspace root for the workspace's own records. A path is listed once across the declaration."},name:{$ref:"#/$defs/kindName",description:"The name readers show for the kind. Without it, the kind file's own recordKind.name. Unique across the declaration."}},patternProperties:{"^x-":!0},additionalProperties:!1},diagram:{type:"object",description:"A diagram artifact the workspace declares (#2764): a rendered image with a source, pinned to the renderer that made it. A mermaid or excalidraw diagram may name no render: a reader draws it from its source. chant never runs the renderer.",required:["name","title","renderer"],if:{type:"object",properties:{renderer:{type:"object",properties:{tool:{enum:["mermaid","excalidraw"]}},required:["tool"]}},required:["renderer"]},then:{type:"object",properties:{source:{$ref:"#/$defs/path"}},required:["source"]},else:{type:"object",properties:{render:{$ref:"#/$defs/path"}},required:["render"]},properties:{name:{$ref:"#/$defs/name",description:"Unique across the declaration."},title:{type:"string",minLength:1,description:"Shown above the diagram."},source:{oneOf:[{$ref:"#/$defs/path"},{type:"null"}],description:"The source file, from the workspace root, with / separators. Null for an SVG with no source. Default null."},render:{oneOf:[{$ref:"#/$defs/path"},{type:"null"}],description:"The rendered image, from the workspace root, with / separators. Required for d2 and graphviz. A mermaid or excalidraw diagram needs a source instead and may leave render out or null, from chant 0.96.0: a reader such as hud draws it from the source (an excalidraw diagram may still commit an exported SVG for docs)."},renderer:{$ref:"#/$defs/diagramRenderer"},sourceHash:{type:["string","null"],pattern:"^[0-9a-f]{64}$",description:"sha256 hex of the source's bytes when render was last produced from it, or for a mermaid or excalidraw diagram without a render, when the source was last pinned. chant workspace check compares this against the source in the tree read and reports drift (WSP133) on a mismatch; without it, or without a source, the render is never checked for drift. Default null."}},patternProperties:{"^x-":!0},additionalProperties:!1},diagramRenderer:{type:"object",description:"The renderer a diagram's render was made with. chant records the pin; it never installs or runs the renderer (ws-052).",required:["tool","version"],properties:{tool:{enum:["d2","mermaid","graphviz","excalidraw"]},version:{$ref:"#/$defs/version",description:"The exact release the render was made with, such as 0.9.0. For mermaid or excalidraw, the release of the library a reader draws the source with, such as 11.4.1."},args:{type:"array",description:'Passed before the input and output paths, in order, such as ["--layout=elk", "--theme=0", "--pad=40", "--omit-version"]. Empty when absent.',items:{type:"string"}}},patternProperties:{"^x-":!0},additionalProperties:!1},generatedFile:{type:"object",description:"One generated file of a member (#2524 D14, #2541).",required:["path","generator"],properties:{path:{$ref:"#/$defs/path",description:"The file, relative to the member's directory."},generator:{type:"string",minLength:1,description:"The command line that writes the file, run in the member's directory with the member's own node_modules/.bin first on PATH, such as chant build ci --lexicon github -o ci.yml. When it passes -o or --output with this file's path, chant workspace check --generated points that flag at a temporary file. Otherwise the generator writes in place and check restores the tree afterwards."},sources:{type:"array",description:"The files or directories the generator reads, relative to the workspace root, since a generator often reads other members.",items:{$ref:"#/$defs/path"}},handWritten:{type:"object",description:"The file is kept by hand instead of regenerated. chant workspace check reports it with the reason and never runs its generator, and the lock classes it owned.",required:["because"],properties:{because:{type:"string",minLength:1}},patternProperties:{"^x-":!0},additionalProperties:!1}},patternProperties:{"^x-":!0},additionalProperties:!1},pin:{description:"An npm package at an exact version, or a local plugin by path. integrity is a Subresource Integrity digest.",oneOf:[{type:"object",required:["package","version"],properties:{package:{type:"string",pattern:"^(@[a-z0-9-~][a-z0-9-._~]*/)?[a-z0-9-~][a-z0-9-._~]*$"},version:{$ref:"#/$defs/version"},integrity:{type:"string",pattern:"^sha(256|384|512)-[A-Za-z0-9+/]+={0,2}$"}},patternProperties:{"^x-":!0},additionalProperties:!1},{type:"object",required:["path"],properties:{path:{$ref:"#/$defs/dir"},integrity:{type:"string",pattern:"^sha(256|384|512)-[A-Za-z0-9+/]+={0,2}$"}},patternProperties:{"^x-":!0},additionalProperties:!1}]},host:{type:"object",description:"A host boxes run on (#2727).",required:["name","ports"],properties:{name:{$ref:"#/$defs/name",description:"The host's name, unique among hosts. A box block names it in host."},ports:{type:"object",description:"The TCP ports boxes on this host take theirs from. Slot n owns the block from + n * perBox to from + (n + 1) * perBox - 1, which must end at or before to.",required:["from","to","perBox"],properties:{from:{$ref:"#/$defs/port",description:"The first port of the range."},to:{$ref:"#/$defs/port",description:"The last port of the range, inclusive."},perBox:{type:"integer",minimum:1,maximum:65535,description:"How many ports each box's block holds. A box's port offsets are below it."}},additionalProperties:!1},stateRoot:{type:"string",minLength:1,description:"Where boxes on this host keep state, as an environment reference such as ${XDG_STATE_HOME}/chant/boxes, which the runtime expands on the machine. A box's state directory is <stateRoot>/<member name>. A literal machine path, such as /Users/... or anything under $HOME, is a WSP124 finding. Default ${XDG_STATE_HOME}/chant/boxes."}},patternProperties:{"^x-":!0},additionalProperties:!1},port:{type:"integer",minimum:1,maximum:65535},fileGlob:{type:"string",description:"A glob over file paths, relative to the workspace root: * and ? within one segment, ** across segments, [...] classes and {a,b} alternatives. No leading /, no . or .. segments.",pattern:"^(?!\\.\\.?(/|$))[^/\\\\]+(/(?!\\.\\.?(/|$))[^/\\\\]+)*$"},recordScope:{type:"object",description:"Record kind names, as the kind file's recordKind.name or the name the declaration gives it, each with the verbs the class may write it with: new, amend, review and close (a review session). A kind left out may not be written at all. A record file a commit deletes is never in scope.",propertyNames:{$ref:"#/$defs/kindName"},additionalProperties:{type:"array",uniqueItems:!0,items:{enum:["new","amend","review","close"]}}},protectedPath:{description:"A protected path: a glob from the workspace root, or { path, except } for a JSON file whose listed top-level keys, or the values JSON Pointers name, may still change.",oneOf:[{$ref:"#/$defs/fileGlob"},{type:"object",required:["path"],properties:{path:{$ref:"#/$defs/fileGlob"},except:{type:"array",minItems:1,uniqueItems:!0,description:"What a write may change in the JSON file: a top-level key, or, for an entry starting with /, the values a JSON Pointer matches, where a * token matches every key or array index at its level, such as /members/*/box/listing for every box's listing (#3308). A change anywhere else in the file, or to a file that doesn't parse as a JSON object before and after, is still outside the scope.",items:{type:"string",minLength:1}}},patternProperties:{"^x-":!0},additionalProperties:!1}]},classScope:{type:"object",description:"A principal class's write scope.",properties:{members:{description:"The members whose files the class may write, by name, or * for every path. Without it, every path. A path in no member is in scope only under *.",oneOf:[{const:"*"},{type:"array",uniqueItems:!0,items:{$ref:"#/$defs/name"}}]},protected:{type:"array",description:"Paths the class may not write, even inside a member it may (#3146, ws-077): each a glob from the workspace root, or { path, except } for a JSON file the class may change only in the top-level keys except names. An entry protects the files it matches and everything under a directory it matches. A record file is judged by records, not here. Added in schema 1 by chant 0.102.0, so a declaration that uses it sets minReader to 0.102.0 or newer.",items:{$ref:"#/$defs/protectedPath"}},records:{$ref:"#/$defs/recordScope",description:"The record kinds the class may write, and how. Without it, every kind in reach, with every verb. A kind a member declares is in reach when that member is; the workspace's own kinds always are."}},patternProperties:{"^x-":!0},additionalProperties:!1},agentScope:{type:"object",description:"The agent class's write scope. Its members are always the members its session is bound to, so only the record kinds and the protected paths can be set.",properties:{protected:{type:"array",description:"Paths the class may not write, even inside a member it may (#3146, ws-077): each a glob from the workspace root, or { path, except } for a JSON file the class may change only in the top-level keys except names. An entry protects the files it matches and everything under a directory it matches. A record file is judged by records, not here. Added in schema 1 by chant 0.102.0, so a declaration that uses it sets minReader to 0.102.0 or newer.",items:{$ref:"#/$defs/protectedPath"}},records:{$ref:"#/$defs/recordScope",description:"The record kinds an agent may write, and how. Without it, every kind in reach of its member, with every verb."}},patternProperties:{"^x-":!0},additionalProperties:!1},agent:{type:"object",description:"An agent session (#2548). It names its members with exactly one of member and members (ws-101).",required:["name"],oneOf:[{properties:{member:!0},required:["member"]},{properties:{members:!0},required:["members"]}],properties:{name:{$ref:"#/$defs/name",description:"The session's name, unique among agents: what CHANT_AGENT and a Chant-Agent trailer give."},member:{$ref:"#/$defs/name",description:"The one member the session is bound to. It must be a declared member, not an example group. A session bound to several names them with members instead."},members:{type:"array",minItems:1,uniqueItems:!0,items:{$ref:"#/$defs/name"},description:"The members the session is bound to, when it writes in more than one, such as a factory that builds an app and writes its evidence records in a design member (ws-101, arugula-salad/studio#402). Each must be a declared member, not an example group. The session may write the files of any of them and the records of kinds any of them or the workspace declares, and the write scope is judged against all of them together. Added in schema 1 by chant 0.105.0, so a declaration that uses it sets minReader to 0.105.0 or newer."},principals:{type:"array",uniqueItems:!0,items:{type:"string",minLength:1},description:"Principals that write only as this session: a commit attested by one, or a write whose by names one, is judged as the session. A principal is listed by one session at most."}},patternProperties:{"^x-":!0},additionalProperties:!1},ciGreen:{type:"object",description:"Which commits passed CI (#3573, ws-103). chant ci tick tags each first-parent commit of branch, within window, whose required phases all passed with ci/green/<sha>, and a green commit that later fails a required phase with ci/revoked/<sha>. Both are annotated tags made once and never moved or deleted by chant. chant ci last-green prints the newest commit with a green tag and no revoked tag.",required:["branch","phases","require"],properties:{branch:{type:"string",minLength:1,pattern:"^[^\\s~^:?*\\[\\\\]+$",description:"The branch whose commits are tagged, such as main. Only its first-parent commits count."},window:{type:"string",pattern:"^[1-9][0-9]*(m|h|d)$",description:"How far back a tick looks, by committer time, such as 24h, 90m or 7d. 24h when absent."},phases:{type:"object",minProperties:1,description:"The phases, by name. Each is a list of check-run name patterns, or { runs, skipped }. A pattern matches a check run's whole name, with * standing for any run of characters. A phase passes when every check run its patterns match finished with success, judged by each run's latest attempt.",propertyNames:{$ref:"#/$defs/ciPhaseName"},additionalProperties:{$ref:"#/$defs/ciPhase"}},require:{type:"array",minItems:1,uniqueItems:!0,description:"The phases a commit must pass to be tagged green, by name. Each must be a declared phase.",items:{$ref:"#/$defs/ciPhaseName"}}},patternProperties:{"^x-":!0},additionalProperties:!1},ciPhaseName:{type:"string",pattern:"^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$"},ciPhase:{oneOf:[{$ref:"#/$defs/ciRunPatterns"},{type:"object",required:["runs"],properties:{runs:{$ref:"#/$defs/ciRunPatterns"},skipped:{enum:["pass","fail"],description:"What a check run that finished as skipped counts as. fail (the default): it never passes. pass: it passes, for a job a path filter runs only on some commits."}},patternProperties:{"^x-":!0},additionalProperties:!1}]},ciRunPatterns:{type:"array",minItems:1,uniqueItems:!0,items:{type:"string",minLength:1,description:"A check run's name, such as lint, or a pattern with *, such as e2e (*)."}}}}});var iC={};_e(iC,{gitTop:()=>_u,gitTree:()=>Iu,joinPath:()=>ze,resolveCommit:()=>rC,skippedDir:()=>ns,workingTree:()=>$n});import{execFileSync as oU}from"node:child_process";import{readdirSync as iae,readFileSync as rU,statSync as iU}from"node:fs";import{join as Df}from"node:path";function ze(...e){return e.filter(t=>t!==""&&t!==".").join("/")}function $n(e){return{label:"",stat(t){try{let n=iU(Df(e,t));return n.isDirectory()?"dir":n.isFile()?"file":void 0}catch{return}},list(t){let n;try{n=iae(Df(e,t),{withFileTypes:!0})}catch{return}let i=[];for(let r of n){let o=r.isDirectory()?"dir":r.isFile()?"file":void 0;if(!o&&r.isSymbolicLink())try{let s=iU(Df(e,t,r.name));o=s.isDirectory()?"dir":s.isFile()?"file":void 0}catch{}o&&i.push({name:r.name,type:o})}return i},read(t){return rU(Df(e,t),"utf-8")},bytes(t){return rU(Df(e,t))}}}function pw(e,t){return oU("git",t,{cwd:e,encoding:"utf-8",stdio:["ignore","pipe","pipe"],maxBuffer:512*1024*1024})}function _u(e){try{return pw(e,["rev-parse","--show-toplevel"]).trim()}catch{return}}function rC(e,t){if(!t.startsWith("-"))try{return pw(e,["rev-parse","--verify","--quiet",`${t}^{commit}`]).trim()}catch{return}}function Iu(e,t,n=""){let i=new Map([["","dir"]]),r=new Map([["",[]]]),o=pw(e,["ls-tree","-r","-t","-z","--full-tree",t]);for(let s of o.split("\0")){if(!s)continue;let a=s.indexOf(" "),l=s.slice(0,a).split(" ")[1],c=s.slice(a+1),u;if(n==="")u=c;else if(c.startsWith(`${n}/`))u=c.slice(n.length+1);else continue;let d=l==="tree"?"dir":l==="blob"?"file":void 0;if(!d)continue;i.set(u,d);let p=u.lastIndexOf("/"),f=p<0?"":u.slice(0,p);r.has(f)||r.set(f,[]),r.get(f).push({name:u.slice(p+1),type:d}),d==="dir"&&!r.has(u)&&r.set(u,[])}return{label:` at ${t.slice(0,8)}`,stat:s=>i.get(s),list:s=>i.get(s)==="dir"?[...r.get(s)??[]]:void 0,read(s){if(i.get(s)!=="file")throw new Error(`${s} is not a file${` at ${t.slice(0,8)}`}`);return pw(e,["cat-file","blob",`${t}:${ze(n,s)}`])},bytes(s){if(i.get(s)!=="file")throw new Error(`${s} is not a file${` at ${t.slice(0,8)}`}`);return oU("git",["cat-file","blob",`${t}:${ze(n,s)}`],{cwd:e,stdio:["ignore","pipe","pipe"],maxBuffer:512*1024*1024})}}}function ns(e){return e==="node_modules"||e.startsWith(".")}var Zt=v(()=>{"use strict"});function aU(e,t){let i=t.split("/").map(a=>a==="**"?"**":oae(a)?a:(0,sU.default)(a,{dot:!1})),r=new Set,o=a=>(e.list(a)??[]).filter(l=>l.type==="dir"&&!ns(l.name)).map(l=>l.name),s=(a,l)=>{if(l===i.length){a!==""&&r.add(a);return}let c=i[l];if(c==="**"){s(a,l+1);for(let u of o(a))s(ze(a,u),l);return}if(typeof c=="string"){let u=ze(a,c);e.stat(u)==="dir"&&s(u,l+1);return}for(let u of o(a))c(u)&&s(ze(a,u),l+1)};return s("",0),[...r].sort()}var sU,oae,cU=v(()=>{"use strict";sU=Le(Tf(),1);Zt();oae=e=>!/[*?[\]{}()!+@]/.test(e)});var oC,lU=v(()=>{oC={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://intentius.io/chant/schemas/workspace/kinds/v1/workspace-kinds.schema.json",title:"workspace-kinds.json",description:"Member kinds a plugin supplies (#2524 D3, #2535, ws-031). A package publishes this file as data at its ./workspace-kinds subpath. chant reads it with the file system and never imports the package, so reading kinds never loads a lexicon.",type:"object",required:["schema","kinds"],properties:{$schema:{type:"string",description:"An editor hint. chant ignores it."},$comment:{type:"string",description:"A note for people. chant ignores it."},schema:{const:1,description:"The kinds format version."},kinds:{type:"array",minItems:1,items:{$ref:"#/$defs/kind"}}},patternProperties:{"^x-":!0},additionalProperties:!1,$defs:{kind:{type:"object",required:["name","description","precedence","probe"],properties:{name:{type:"string",pattern:"^[a-z][a-z0-9-]{0,39}$",description:"The kind's name, as a member's kind field names it. chant, workspace, other and examples are built in and can't be supplied."},description:{type:"string",minLength:1,description:"One line saying what the member's directory holds, for listings and error messages."},precedence:{type:"integer",minimum:1,maximum:999,description:"When the probes of several kinds claim one directory, the highest precedence decides. Two claiming kinds with the same highest precedence are a tie, and a tie fails. The built-in chant kind has 500 and workspace has 1000."},probe:{$ref:"#/$defs/probe"},outputs:{type:"array",uniqueItems:!0,description:"The outputs every member of this kind exposes as link targets (#2524 D6, #2539). A member entry of the kind may list more in its own outputs field. Without this field the kind exposes only what each entry lists.",items:{type:"string",minLength:1,maxLength:255,pattern:"^[^\\u0000-\\u001f]+$"}},graph:{$ref:"#/$defs/graph"},fields:{$ref:"#/$defs/fields"}},patternProperties:{"^x-":!0},additionalProperties:!1},probe:{type:"object",description:"What the probe checks in a member's directory. It runs no code. It passes when any of its clauses does, and it needs at least one.",minProperties:1,properties:{anyFile:{type:"array",minItems:1,uniqueItems:!0,description:"The directory passes when a file matching one of these names sits directly in it. A * in a name matches any run of characters, so *.tf matches every Terraform file.",items:{$ref:"#/$defs/fileName"}},anyBlock:{type:"object",description:"The directory passes when a file directly in it, whose name matches one of in, has a line opening an unlabelled block named in blocks: leading space, the name, optional space, then {. No file is parsed.",required:["in","blocks"],properties:{in:{type:"array",minItems:1,uniqueItems:!0,items:{$ref:"#/$defs/fileName"}},blocks:{type:"array",minItems:1,uniqueItems:!0,items:{type:"string",pattern:"^[A-Za-z_][A-Za-z0-9_-]{0,63}$"}}},additionalProperties:!1},anyJsonKey:{type:"object",description:"The directory passes when a file directly in it, whose name matches one of in, parses as JSON and has a value at one of pointers, each a JSON Pointer such as /scripts/start (#3151). A file that is not JSON is no evidence either way. Added by chant 0.103.0.",required:["in","pointers"],properties:{in:{type:"array",minItems:1,uniqueItems:!0,items:{$ref:"#/$defs/fileName"}},pointers:{type:"array",minItems:1,uniqueItems:!0,items:{type:"string",pattern:"^(/[^/]+)+$"}}},additionalProperties:!1}},additionalProperties:!1},fileName:{type:"string",description:"A file name, with no directory part. A * matches any run of characters.",pattern:"^(?!\\.\\.?$)[^/\\\\]+$"},graph:{type:"object",description:"How chant workspace graph reads a member of this kind (#2874). chant writes a reader project of its own outside the workspace, with a chant.config.json that declares lexicon and puts config under that lexicon's key, and runs the member's chant graph there. In every string key and value of config, {member} becomes the member's name, {dir} its absolute directory and {workspace} the absolute workspace root. Without this field a member of the kind is listed with kind-not-run.",required:["lexicon","config"],properties:{lexicon:{type:"string",pattern:"^[a-z][a-z0-9-]{0,39}$",description:"The lexicon that reads the member, by name. The package that supplies the kind must be @intentius/chant-lexicon-<lexicon>, so the lexicon chant loads is the one the declaration pins."},config:{type:"object",description:"The lexicon's config namespace for the reader project, such as terraform's roots. Placeholders are substituted; nothing else is interpreted."}},patternProperties:{"^x-":!0},additionalProperties:!1},fields:{type:"object",description:"The fields a member entry of this kind may set under its own fields block, each with a type and, optionally, a default (#3151). chant workspace check fails a member whose fields name one the kind doesn't declare or give a value of the wrong type (WSP005), and chant workspace status --json prints every declared field with the defaults filled in. Added by chant 0.103.0; an older chant can't read a kinds file that uses it.",minProperties:1,propertyNames:{$ref:"#/$defs/fieldName"},additionalProperties:{oneOf:[{$ref:"#/$defs/scalarField"},{$ref:"#/$defs/objectField"}]}},fieldName:{type:"string",pattern:"^[a-z][A-Za-z0-9]{0,39}$"},scalarField:{type:"object",required:["type","description"],properties:{type:{enum:["string","integer","boolean"]},description:{type:"string",minLength:1},default:{oneOf:[{type:"string"},{type:"integer"},{type:"boolean"}],description:"The value a member that doesn't set the field gets. Its type is the field's. Without it the field reads as null when unset."},pattern:{type:"string",minLength:1,description:"For a string field: a regular expression the value must match."}},additionalProperties:!1},objectField:{type:"object",required:["type","description","properties"],properties:{type:{const:"object"},description:{type:"string",minLength:1},properties:{type:"object",minProperties:1,propertyNames:{$ref:"#/$defs/fieldName"},additionalProperties:{$ref:"#/$defs/scalarField"},description:"The object's own fields, each a string, integer or boolean field. A member sets any of them; the rest take their defaults."}},additionalProperties:!1}}}});import{createHash as sC}from"node:crypto";import{lstatSync as aae,readdirSync as cae,readFileSync as uU}from"node:fs";import{join as dU}from"node:path";function uae(e){let t=lae.exec(e);return t?{algorithm:t[1],digest:t[2]}:void 0}function pU(e,t,n){for(let i of cae(e,{withFileTypes:!0})){let r=t===""?i.name:`${t}/${i.name}`;if(i.isSymbolicLink())throw new Tu(`${r} is a symbolic link, which a pinned plugin may not contain`);i.isDirectory()?dae.has(i.name)||pU(dU(e,i.name),r,n):i.isFile()&&n.push(r)}}function pae(e){let t=[];return pU(e,"",t),t.sort((n,i)=>n<i?-1:n>i?1:0)}function fae(e,t="sha256"){let n;try{n=aae(e)}catch{throw new Tu("it does not exist")}if(n.isSymbolicLink())throw new Tu("it is a symbolic link, which a pinned plugin may not be");if(n.isFile())return{integrity:`${t}-${sC(t).update(uU(e)).digest("base64")}`,files:1};let i=pae(e),r=i.map(o=>`${sC(t).update(uU(dU(e,...o.split("/")))).digest("hex")} ${o}
|
|
56
|
+
`).join("");return{integrity:`${t}-${sC(t).update(r,"utf8").digest("base64")}`,files:i.length}}function fU(e,t,n){let i=uae(t);if(!i)return{ok:!1,message:`${n}: integrity ${JSON.stringify(t)} is not sha256-, sha384- or sha512- and a base64 digest`};let r;try{r=fae(e,i.algorithm).integrity}catch(o){if(!(o instanceof Tu))throw o;return{ok:!1,message:`${n}: can't check its integrity, ${o.message}`}}return r===t?{ok:!0}:{ok:!1,message:`${n}: integrity mismatch, so nothing is read from it. The pin says ${t} and the plugin hashes to ${r}. If the change is intended, run \`chant workspace pin ${n}\` and put the value it prints in the pin; otherwise restore the plugin`}}var lae,dae,Tu,mU=v(()=>{"use strict";lae=/^(sha(?:256|384|512))-([A-Za-z0-9+/]+={0,2})$/;dae=new Set(["node_modules",".git"]),Tu=class extends Error{}});import{createHash as mae,createPublicKey as aC,verify as cC}from"node:crypto";function ro(e){let t=e.relayedBy!==void 0?`
|
|
57
|
+
relayed-by ${e.relayedBy}`:"";return Buffer.from(`${e.op}
|
|
58
|
+
${e.gate}
|
|
59
|
+
${e.environment??""}
|
|
60
|
+
${e.planDigest??""}
|
|
61
|
+
${e.resolvedBy}
|
|
62
|
+
${e.timestamp}${t}`,"utf-8")}function jf(e){let t=0,n=i=>{let r=i??n(4).readUInt32BE(0);if(t+r>e.length)throw new Error("the signature is truncated");return e.subarray(t,t+=r)};return n}function lC(e){return`SHA256:${gw("sha256",e).toString("base64").replace(/=+$/,"")}`}function hae(e){let t=jf(e),n=t().toString();if(n==="ssh-ed25519"||n==="sk-ssh-ed25519@openssh.com"){let i=aC({key:{kty:"OKP",crv:"Ed25519",x:Nf(t())},format:"jwk"});return{type:n,key:i,...n.startsWith("sk-")?{application:t()}:{}}}if(n.startsWith("ecdsa-sha2-")||n==="sk-ecdsa-sha2-nistp256@openssh.com"){let i=gae[t().toString()];if(!i)throw new Error(`unsupported curve in ${n}`);let r=t();if(r[0]!==4||r.length!==1+2*i.size)throw new Error("the ECDSA key is not an uncompressed point");let o=aC({key:{kty:"EC",crv:i.crv,x:Nf(r.subarray(1,1+i.size)),y:Nf(r.subarray(1+i.size))},format:"jwk"});return{type:n,key:o,ecdsa:i,...n.startsWith("sk-")?{application:t()}:{}}}if(n==="ssh-rsa"){let i=hw(t()),r=hw(t());return{type:n,key:aC({key:{kty:"RSA",e:Nf(i),n:Nf(r)},format:"jwk"})}}throw new Error(`unsupported key type ${n}`)}function ta(e,t,n,i){try{let r=/-----BEGIN SSH SIGNATURE-----([^-]*)-----END SSH SIGNATURE-----/.exec(e)?.[1];if(r===void 0)return{ok:!1,reason:"it is not an armored ssh signature"};let o=jf(Buffer.from(r.replace(/\s+/g,""),"base64"));if(o(6).toString()!=="SSHSIG"||o(4).readUInt32BE(0)!==1)return{ok:!1,reason:"it is not an SSHSIG, version 1"};let s=o(),a=o(),l=o(),c=o().toString(),u=o();if(a.toString()!==n)return{ok:!1,reason:`it is signed in the ${a.toString()} namespace, not ${n}`};if(c!=="sha256"&&c!=="sha512")return{ok:!1,reason:`it hashes with ${c}, and only sha256 and sha512 are accepted`};if(!i.some($=>$.equals(s)))return{ok:!1,reason:"signed by a key the policy at base does not list for the approver"};let d=Buffer.concat([Buffer.from("SSHSIG"),fw(a),fw(l),fw(c),fw(gw(c,t))]),{type:p,key:f,ecdsa:g,application:h}=hae(s),b=jf(u),w=b().toString(),x=b(),k=lC(s),R=$=>$?{ok:!0,key:k}:{ok:!1,reason:"the signature does not match the signed fields"};if(p==="ssh-rsa")return w!=="rsa-sha2-256"&&w!=="rsa-sha2-512"?{ok:!1,reason:`an RSA signature of type ${w} is not accepted`}:R(cC(`sha${w.slice(9)}`,d,f,x));if(w!==p)return{ok:!1,reason:`a ${w} signature from a ${p} key`};if(h!==void 0){let $=b(1);if(!($[0]&1))return{ok:!1,reason:"the security key was not touched (the user-presence flag is unset)"};d=Buffer.concat([gw("sha256",h),$,b(4),gw("sha256",d)])}if(g){let $=jf(x),_=hw($(),g.size),T=hw($(),g.size);return R(cC(h!==void 0?"sha256":g.hash,d,{key:f,dsaEncoding:"ieee-p1363"},Buffer.concat([_,T])))}return R(cC(null,d,f,x))}catch(r){return{ok:!1,reason:r instanceof Error?r.message:String(r)}}}function gU(e){try{let t=/-----BEGIN SSH SIGNATURE-----([^-]*)-----END SSH SIGNATURE-----/.exec(e)?.[1];if(t===void 0)return null;let n=jf(Buffer.from(t.replace(/\s+/g,""),"base64"));return n(6).toString()!=="SSHSIG"||n(4).readUInt32BE(0)!==1?null:Buffer.from(n())}catch{return null}}function Lf(e,t){if(e===void 0)return!0;let n=!1;for(let i of e.split(",")){let r=i.startsWith("!"),o=r?i.slice(1):i;if(new RegExp(`^${o.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".")}$`).test(t)){if(r)return!1;n=!0}}return n}function na(e,t){let n=`${e.signersPath} at base`;if(!e.active){let a=e.problems.length>0?`: ${e.problems.join("; ")}`:"";return`the gate is sealed, and there is no signers file (${e.signersPath}) at base ${e.base?.slice(0,12)??""}`.trim()+a}let i=`the approval of gate ${t.gate} by ${t.resolvedBy}`;if(t.seal===void 0||t.seal===null)return`${i} carries no seal`;let r=t.seal;if(typeof r!="object"||Array.isArray(r)||typeof r.signer!="string"||typeof r.signature!="string")return`the seal on ${i} is malformed: it needs signer and signature`;if(mw(r.signer)!==mw(t.resolvedBy))return`the seal on ${i} is by ${r.signer}, and its approver is ${t.resolvedBy||"empty"}`;let o=e.signers.filter(a=>mw(a.principal)===mw(t.resolvedBy)&&Lf(a.namespaces,Rn)).map(a=>Buffer.from(a.key.split(" ")[1]??"","base64"));if(o.length===0)return`${t.resolvedBy} has no key in ${n}, so the seal can't count`;let s=ta(r.signature,ro(t),Rn,o);return s.ok?null:`the seal does not verify for ${t.resolvedBy} against ${n}: ${s.reason}`}var Rn,fw,gw,Nf,hw,gae,mw,ra=v(()=>{"use strict";Rn="chant-gate";fw=e=>{let t=Buffer.from(e),n=Buffer.alloc(4);return n.writeUInt32BE(t.length),Buffer.concat([n,t])},gw=(e,t)=>mae(e).update(t).digest(),Nf=e=>e.toString("base64url"),hw=(e,t)=>{let n=e;for(;n.length>1&&n[0]===0;)n=n.subarray(1);return t===void 0||n.length>=t?n:Buffer.concat([Buffer.alloc(t-n.length),n])};gae={nistp256:{crv:"P-256",size:32,hash:"sha256"},nistp384:{crv:"P-384",size:48,hash:"sha384"},nistp521:{crv:"P-521",size:66,hash:"sha512"}};mw=e=>e.normalize("NFKC").trim().toLowerCase()});function Mf(e,t,n){if(n===null)return[];let i=Du(n);return e.filter(r=>r.role!==null&&(t[r.role]??[]).some(o=>Du(o)===i)).map(r=>r.name)}function Nu(e,t){let{gate:n,signers:i}=e,r=e.class;if(r!==null&&!e.classes.some(l=>l.name===r))return`identity.gates.${n} names the class ${r}, which ${e.unknownClass??"no pinned package supplies"}, so no approval can show it is in that class (known classes: ${e.classes.map(l=>l.name).join(", ")})`;if(!i.active)return`gate ${n} needs a signed approval, and there is no signers file (${i.signersPath}) at base to check one against`;let o=yae(n,i,t);if(o!==null)return o;if(r===null)return null;let s=Mf(e.classes,e.roles,t.resolvedBy);return(r==="human"?s.length===0:s.includes(r))?null:`${t.resolvedBy} is not in the class ${r} that gate ${n} needs: no role grant at base puts them there`}function yae(e,t,n){let i=`the approval of gate ${n.gate} by ${n.resolvedBy}`;if(n.seal===void 0||n.seal===null)return`the approval by ${n.resolvedBy} is not signed; gate ${e} needs chant approve --sign`;let r=n.seal;if(typeof r!="object"||Array.isArray(r)||typeof r.signer!="string"||typeof r.signature!="string")return`the seal on ${i} is malformed: it needs signer and signature`;if(Du(r.signer)!==Du(n.resolvedBy))return`the seal on ${i} is by ${r.signer}, and its approver is ${n.resolvedBy||"empty"}`;let o=`${t.signersPath} at base`,s=t.signers.filter(c=>Du(c.principal)===Du(n.resolvedBy));if(s.length===0)return`${n.resolvedBy} has no key in ${o}, so the seal can't count`;let a=s.filter(c=>Lf(c.namespaces,Rn)).map(c=>Buffer.from(c.key.split(" ")[1]??"","base64")),l=ta(r.signature,ro(n),Rn,a);return l.ok?null:`the seal does not verify for ${n.resolvedBy} against ${o}: ${l.reason}`}var uC,io,Du,Sc=v(()=>{"use strict";ra();uC=["human","agent","runner","service"],io=[{name:"human",description:"a principal holding none of the roles of another class",role:null,source:"core"},{name:"agent",description:"a principal holding the agent role, or a write naming an agent session",role:"agent",source:"core"},{name:"runner",description:"a principal holding the runner role, such as a CI job's signing identity",role:"runner",source:"core"},{name:"service",description:"a principal holding the service role",role:"service",source:"core"}],Du=e=>e.normalize("NFKC").trim().toLowerCase()});import{existsSync as bae,readFileSync as wae,statSync as vae}from"node:fs";import{dirname as hU,join as dC,posix as kae,resolve as xae}from"node:path";function Ff(e){return t=>{try{return wae(dC(e,...t.split("/")),"utf-8")}catch{return}}}function ia(e,t){for(let n=xae(t);;n=hU(n)){let i=dC(n,"node_modules",...e.split("/"));try{if(vae(i).isDirectory()&&bae(dC(i,"package.json")))return i}catch{}if(hU(n)===n)return}}function pC(e,t){let n=e.exports;if(!n||typeof n!="object"||Array.isArray(n))return;let i=n[t];if(i===void 0)return;let r=i;if(r&&typeof r=="object"&&!Array.isArray(r)){let o=r;r=o.default??o.import??o.require}return typeof r!="string"?{problem:`exports["${t}"] must name one file, as a string or a "default" condition`}:!r.startsWith("./")||!r.endsWith(".json")?{problem:`exports["${t}"] is ${r}; it must name a .json file inside the package, since chant reads plugin data as data and never runs a package's code`}:r}function Sae(e,t){let n=[],i=(r,o)=>n.push(`${t}: ${r||"the principals file"} ${o}`);if(!yU(e))return i("","must be object"),n;for(let r of Object.keys(e))bU(r,["$schema","$comment","schema","classes"])&&i("",`must NOT have additional property ${r}`);for(let r of["$schema","$comment"])r in e&&typeof e[r]!="string"&&i(`/${r}`,"must be string");return"schema"in e?e.schema!==1&&i("/schema","must be equal to constant 1"):i("","must have required property 'schema'"),"classes"in e?Array.isArray(e.classes)?(e.classes.length<1&&i("/classes","must NOT have fewer than 1 items"),e.classes.forEach((r,o)=>{let s=`/classes/${o}`;if(!yU(r))return i(s,"must be object");for(let a of Object.keys(r))bU(a,["name","description","role"])&&i(s,`must NOT have additional property ${a}`);for(let a of["name","description","role"])a in r||i(s,`must have required property '${a}'`);"name"in r&&(typeof r.name!="string"||!$ae.test(r.name))&&i(`${s}/name`,"must be a class name"),"description"in r&&(typeof r.description!="string"||[...r.description].length<1)&&i(`${s}/description`,"must be a non-empty string"),"role"in r&&(typeof r.role!="string"||!Rae.test(r.role))&&i(`${s}/role`,"must be a role name")})):i("/classes","must be array"):i("","must have required property 'classes'"),[...new Set(n)]}function fC(e,t){let n=[],i=[],r=new Set,o=new Set;for(let s of e.classes){if(uC.includes(s.name)){n.push(`${t}: class ${s.name} is a core class and can't be supplied by a package`);continue}if(Eae.has(s.role)){n.push(`${t}: class ${s.name} names the role ${s.role}, which puts a principal in the core ${s.role} class`);continue}if(r.has(s.name)){n.push(`${t}: class ${s.name} is listed twice`);continue}if(o.has(s.role)){n.push(`${t}: class ${s.name} names the role ${s.role}, which another class in the file names; a role puts a principal in one class`);continue}r.add(s.name),o.add(s.role),i.push({name:s.name,description:s.description,role:s.role,source:t})}return{classes:i,problems:n}}function mC(e,t){let n;try{n=JSON.parse(e)}catch(r){return{classes:[],problems:[`${t}: the principals file is not JSON (${r.message})`]}}let i=Sae(n,t);return i.length>0?{classes:[],problems:i}:fC(n,t)}function Bf(e,t,n){let i=e("package.json");if(i===void 0)return{classes:[],problems:[`${t}: no readable package.json`]};let r;try{r=JSON.parse(i)}catch{return{classes:[],problems:[`${t}: package.json is not JSON`]}}let o=pC(r,yw);if(o===void 0)return{classes:[],problems:[]};if(typeof o!="string")return{classes:[],problems:[`${t}: ${o.problem}`]};let s=kae.normalize(o.slice(2));if(s.startsWith("../")||s==="..")return{classes:[],problems:[`${t}: exports["${yw}"] points outside the package`]};let a=e(s);return a===void 0?{classes:[],problems:[`${t}: exports["${yw}"] names ${o}, which does not exist`]}:n(a,t)}function bw(e){let t=[],n=[],i=new Map,r=new Map,o=new Set;for(let{pin:s,source:a,read:l}of e){for(let c of l.problems)t.push({pin:s,message:c});for(let c of l.classes){let u=i.get(c.name),d=r.get(c.role);if(u!==void 0||d!==void 0){if(o.add(c.name),u!==void 0)t.push({pin:s,message:`class ${c.name} is supplied by both ${u} and ${a}; a class name has one source`});else{let p=n.find(f=>f.role===c.role);o.add(p.name),t.push({pin:s,message:`class ${c.name} (${a}) names the role ${c.role}, which class ${p.name} (${d}) names; a role puts a principal in one class`})}continue}i.set(c.name,a),r.set(c.role,a),n.push(c)}}return{classes:n.filter(s=>!o.has(s.name)),problems:t}}var yw,$ae,Rae,yU,bU,Eae,ju=v(()=>{"use strict";Sc();yw="./workspace-principals";$ae=/^(?!x-)[a-z][a-z0-9-]{0,39}$/u,Rae=/^[a-z][a-z0-9-]*$/u,yU=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),bU=(e,t)=>!t.includes(e)&&!e.startsWith("x-");Eae=new Set(io.map(e=>e.role).filter(e=>e!==null))});var zf=ie(lt=>{"use strict";Object.defineProperty(lt,"__esModule",{value:!0});lt.regexpCode=lt.getEsmExportName=lt.getProperty=lt.safeStringify=lt.stringify=lt.strConcat=lt.addCodeArg=lt.str=lt._=lt.nil=lt._Code=lt.Name=lt.IDENTIFIER=lt._CodeOrName=void 0;var Gf=class{};lt._CodeOrName=Gf;lt.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Ec=class extends Gf{constructor(t){if(super(),!lt.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};lt.Name=Ec;var Qr=class extends Gf{constructor(t){super(),this._items=typeof t=="string"?[t]:t}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let t=this._items[0];return t===""||t==='""'}get str(){var t;return(t=this._str)!==null&&t!==void 0?t:this._str=this._items.reduce((n,i)=>`${n}${i}`,"")}get names(){var t;return(t=this._names)!==null&&t!==void 0?t:this._names=this._items.reduce((n,i)=>(i instanceof Ec&&(n[i.str]=(n[i.str]||0)+1),n),{})}};lt._Code=Qr;lt.nil=new Qr("");function wU(e,...t){let n=[e[0]],i=0;for(;i<t.length;)hC(n,t[i]),n.push(e[++i]);return new Qr(n)}lt._=wU;var gC=new Qr("+");function vU(e,...t){let n=[Wf(e[0])],i=0;for(;i<t.length;)n.push(gC),hC(n,t[i]),n.push(gC,Wf(e[++i]));return Aae(n),new Qr(n)}lt.str=vU;function hC(e,t){t instanceof Qr?e.push(...t._items):t instanceof Ec?e.push(t):e.push(Cae(t))}lt.addCodeArg=hC;function Aae(e){let t=1;for(;t<e.length-1;){if(e[t]===gC){let n=Pae(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]="+"}t++}}function Pae(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof Ec||e[e.length-1]!=='"'?void 0:typeof t!="string"?`${e.slice(0,-1)}${t}"`:t[0]==='"'?e.slice(0,-1)+t.slice(1):void 0;if(typeof t=="string"&&t[0]==='"'&&!(e instanceof Ec))return`"${e}${t.slice(1)}`}function Oae(e,t){return t.emptyStr()?e:e.emptyStr()?t:vU`${e}${t}`}lt.strConcat=Oae;function Cae(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:Wf(Array.isArray(e)?e.join(","):e)}function _ae(e){return new Qr(Wf(e))}lt.stringify=_ae;function Wf(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}lt.safeStringify=Wf;function Iae(e){return typeof e=="string"&<.IDENTIFIER.test(e)?new Qr(`.${e}`):wU`[${e}]`}lt.getProperty=Iae;function Tae(e){if(typeof e=="string"&<.IDENTIFIER.test(e))return new Qr(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}lt.getEsmExportName=Tae;function Dae(e){return new Qr(e.toString())}lt.regexpCode=Dae});var wC=ie(wr=>{"use strict";Object.defineProperty(wr,"__esModule",{value:!0});wr.ValueScope=wr.ValueScopeName=wr.Scope=wr.varKinds=wr.UsedValueState=void 0;var br=zf(),yC=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}},ww;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"})(ww||(wr.UsedValueState=ww={}));wr.varKinds={const:new br.Name("const"),let:new br.Name("let"),var:new br.Name("var")};var vw=class{constructor({prefixes:t,parent:n}={}){this._names={},this._prefixes=t,this._parent=n}toName(t){return t instanceof br.Name?t:this.name(t)}name(t){return new br.Name(this._newName(t))}_newName(t){let n=this._names[t]||this._nameGroup(t);return`${t}${n.index++}`}_nameGroup(t){var n,i;if(!((i=(n=this._parent)===null||n===void 0?void 0:n._prefixes)===null||i===void 0)&&i.has(t)||this._prefixes&&!this._prefixes.has(t))throw new Error(`CodeGen: prefix "${t}" is not allowed in this scope`);return this._names[t]={prefix:t,index:0}}};wr.Scope=vw;var kw=class extends br.Name{constructor(t,n){super(n),this.prefix=t}setValue(t,{property:n,itemIndex:i}){this.value=t,this.scopePath=(0,br._)`.${new br.Name(n)}[${i}]`}};wr.ValueScopeName=kw;var Nae=(0,br._)`\n`,bC=class extends vw{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?Nae:br.nil}}get(){return this._scope}name(t){return new kw(t,this._newName(t))}value(t,n){var i;if(n.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let r=this.toName(t),{prefix:o}=r,s=(i=n.key)!==null&&i!==void 0?i:n.ref,a=this._values[o];if(a){let u=a.get(s);if(u)return u}else a=this._values[o]=new Map;a.set(s,r);let l=this._scope[o]||(this._scope[o]=[]),c=l.length;return l[c]=n.ref,r.setValue(n,{property:o,itemIndex:c}),r}getValue(t,n){let i=this._values[t];if(i)return i.get(n)}scopeRefs(t,n=this._values){return this._reduceValues(n,i=>{if(i.scopePath===void 0)throw new Error(`CodeGen: name "${i}" has no value`);return(0,br._)`${t}${i.scopePath}`})}scopeCode(t=this._values,n,i){return this._reduceValues(t,r=>{if(r.value===void 0)throw new Error(`CodeGen: name "${r}" has no value`);return r.value.code},n,i)}_reduceValues(t,n,i={},r){let o=br.nil;for(let s in t){let a=t[s];if(!a)continue;let l=i[s]=i[s]||new Map;a.forEach(c=>{if(l.has(c))return;l.set(c,ww.Started);let u=n(c);if(u){let d=this.opts.es5?wr.varKinds.var:wr.varKinds.const;o=(0,br._)`${o}${d} ${c} = ${u};${this.opts._n}`}else if(u=r?.(c))o=(0,br._)`${o}${u}${this.opts._n}`;else throw new yC(c);l.set(c,ww.Completed)})}return o}};wr.ValueScope=bC});var Fe=ie(Ze=>{"use strict";Object.defineProperty(Ze,"__esModule",{value:!0});Ze.or=Ze.and=Ze.not=Ze.CodeGen=Ze.operators=Ze.varKinds=Ze.ValueScopeName=Ze.ValueScope=Ze.Scope=Ze.Name=Ze.regexpCode=Ze.stringify=Ze.getProperty=Ze.nil=Ze.strConcat=Ze.str=Ze._=void 0;var rt=zf(),_i=wC(),oa=zf();Object.defineProperty(Ze,"_",{enumerable:!0,get:function(){return oa._}});Object.defineProperty(Ze,"str",{enumerable:!0,get:function(){return oa.str}});Object.defineProperty(Ze,"strConcat",{enumerable:!0,get:function(){return oa.strConcat}});Object.defineProperty(Ze,"nil",{enumerable:!0,get:function(){return oa.nil}});Object.defineProperty(Ze,"getProperty",{enumerable:!0,get:function(){return oa.getProperty}});Object.defineProperty(Ze,"stringify",{enumerable:!0,get:function(){return oa.stringify}});Object.defineProperty(Ze,"regexpCode",{enumerable:!0,get:function(){return oa.regexpCode}});Object.defineProperty(Ze,"Name",{enumerable:!0,get:function(){return oa.Name}});var Sw=wC();Object.defineProperty(Ze,"Scope",{enumerable:!0,get:function(){return Sw.Scope}});Object.defineProperty(Ze,"ValueScope",{enumerable:!0,get:function(){return Sw.ValueScope}});Object.defineProperty(Ze,"ValueScopeName",{enumerable:!0,get:function(){return Sw.ValueScopeName}});Object.defineProperty(Ze,"varKinds",{enumerable:!0,get:function(){return Sw.varKinds}});Ze.operators={GT:new rt._Code(">"),GTE:new rt._Code(">="),LT:new rt._Code("<"),LTE:new rt._Code("<="),EQ:new rt._Code("==="),NEQ:new rt._Code("!=="),NOT:new rt._Code("!"),OR:new rt._Code("||"),AND:new rt._Code("&&"),ADD:new rt._Code("+")};var rs=class{optimizeNodes(){return this}optimizeNames(t,n){return this}},vC=class extends rs{constructor(t,n,i){super(),this.varKind=t,this.name=n,this.rhs=i}render({es5:t,_n:n}){let i=t?_i.varKinds.var:this.varKind,r=this.rhs===void 0?"":` = ${this.rhs}`;return`${i} ${this.name}${r};`+n}optimizeNames(t,n){if(t[this.name.str])return this.rhs&&(this.rhs=Mu(this.rhs,t,n)),this}get names(){return this.rhs instanceof rt._CodeOrName?this.rhs.names:{}}},xw=class extends rs{constructor(t,n,i){super(),this.lhs=t,this.rhs=n,this.sideEffects=i}render({_n:t}){return`${this.lhs} = ${this.rhs};`+t}optimizeNames(t,n){if(!(this.lhs instanceof rt.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=Mu(this.rhs,t,n),this}get names(){let t=this.lhs instanceof rt.Name?{}:{...this.lhs.names};return Rw(t,this.rhs)}},kC=class extends xw{constructor(t,n,i,r){super(t,i,r),this.op=n}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}},xC=class extends rs{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}},$C=class extends rs{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}},RC=class extends rs{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}},SC=class extends rs{constructor(t){super(),this.code=t}render({_n:t}){return`${this.code};`+t}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(t,n){return this.code=Mu(this.code,t,n),this}get names(){return this.code instanceof rt._CodeOrName?this.code.names:{}}},Uf=class extends rs{constructor(t=[]){super(),this.nodes=t}render(t){return this.nodes.reduce((n,i)=>n+i.render(t),"")}optimizeNodes(){let{nodes:t}=this,n=t.length;for(;n--;){let i=t[n].optimizeNodes();Array.isArray(i)?t.splice(n,1,...i):i?t[n]=i:t.splice(n,1)}return t.length>0?this:void 0}optimizeNames(t,n){let{nodes:i}=this,r=i.length;for(;r--;){let o=i[r];o.optimizeNames(t,n)||(jae(t,o.names),i.splice(r,1))}return i.length>0?this:void 0}get names(){return this.nodes.reduce((t,n)=>Oc(t,n.names),{})}},is=class extends Uf{render(t){return"{"+t._n+super.render(t)+"}"+t._n}},EC=class extends Uf{},Lu=class extends is{};Lu.kind="else";var Ac=class e extends is{constructor(t,n){super(n),this.condition=t}render(t){let n=`if(${this.condition})`+super.render(t);return this.else&&(n+="else "+this.else.render(t)),n}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let i=n.optimizeNodes();n=this.else=Array.isArray(i)?new Lu(i):i}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e(kU(t),n instanceof e?[n]:n.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(t,n){var i;if(this.else=(i=this.else)===null||i===void 0?void 0:i.optimizeNames(t,n),!!(super.optimizeNames(t,n)||this.else))return this.condition=Mu(this.condition,t,n),this}get names(){let t=super.names;return Rw(t,this.condition),this.else&&Oc(t,this.else.names),t}};Ac.kind="if";var Pc=class extends is{};Pc.kind="for";var AC=class extends Pc{constructor(t){super(),this.iteration=t}render(t){return`for(${this.iteration})`+super.render(t)}optimizeNames(t,n){if(super.optimizeNames(t,n))return this.iteration=Mu(this.iteration,t,n),this}get names(){return Oc(super.names,this.iteration.names)}},PC=class extends Pc{constructor(t,n,i,r){super(),this.varKind=t,this.name=n,this.from=i,this.to=r}render(t){let n=t.es5?_i.varKinds.var:this.varKind,{name:i,from:r,to:o}=this;return`for(${n} ${i}=${r}; ${i}<${o}; ${i}++)`+super.render(t)}get names(){let t=Rw(super.names,this.from);return Rw(t,this.to)}},$w=class extends Pc{constructor(t,n,i,r){super(),this.loop=t,this.varKind=n,this.name=i,this.iterable=r}render(t){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(t)}optimizeNames(t,n){if(super.optimizeNames(t,n))return this.iterable=Mu(this.iterable,t,n),this}get names(){return Oc(super.names,this.iterable.names)}},Hf=class extends is{constructor(t,n,i){super(),this.name=t,this.args=n,this.async=i}render(t){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}};Hf.kind="func";var Vf=class extends Uf{render(t){return"return "+super.render(t)}};Vf.kind="return";var OC=class extends is{render(t){let n="try"+super.render(t);return this.catch&&(n+=this.catch.render(t)),this.finally&&(n+=this.finally.render(t)),n}optimizeNodes(){var t,n;return super.optimizeNodes(),(t=this.catch)===null||t===void 0||t.optimizeNodes(),(n=this.finally)===null||n===void 0||n.optimizeNodes(),this}optimizeNames(t,n){var i,r;return super.optimizeNames(t,n),(i=this.catch)===null||i===void 0||i.optimizeNames(t,n),(r=this.finally)===null||r===void 0||r.optimizeNames(t,n),this}get names(){let t=super.names;return this.catch&&Oc(t,this.catch.names),this.finally&&Oc(t,this.finally.names),t}},qf=class extends is{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}};qf.kind="catch";var Kf=class extends is{render(t){return"finally"+super.render(t)}};Kf.kind="finally";var CC=class{constructor(t,n={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...n,_n:n.lines?`
|
|
63
|
+
`:""},this._extScope=t,this._scope=new _i.Scope({parent:t}),this._nodes=[new EC]}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,n){let i=this._extScope.value(t,n);return(this._values[i.prefix]||(this._values[i.prefix]=new Set)).add(i),i}getScopeValue(t,n){return this._extScope.getValue(t,n)}scopeRefs(t){return this._extScope.scopeRefs(t,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(t,n,i,r){let o=this._scope.toName(n);return i!==void 0&&r&&(this._constants[o.str]=i),this._leafNode(new vC(t,o,i)),o}const(t,n,i){return this._def(_i.varKinds.const,t,n,i)}let(t,n,i){return this._def(_i.varKinds.let,t,n,i)}var(t,n,i){return this._def(_i.varKinds.var,t,n,i)}assign(t,n,i){return this._leafNode(new xw(t,n,i))}add(t,n){return this._leafNode(new kC(t,Ze.operators.ADD,n))}code(t){return typeof t=="function"?t():t!==rt.nil&&this._leafNode(new SC(t)),this}object(...t){let n=["{"];for(let[i,r]of t)n.length>1&&n.push(","),n.push(i),(i!==r||this.opts.es5)&&(n.push(":"),(0,rt.addCodeArg)(n,r));return n.push("}"),new rt._Code(n)}if(t,n,i){if(this._blockNode(new Ac(t)),n&&i)this.code(n).else().code(i).endIf();else if(n)this.code(n).endIf();else if(i)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(t){return this._elseNode(new Ac(t))}else(){return this._elseNode(new Lu)}endIf(){return this._endBlockNode(Ac,Lu)}_for(t,n){return this._blockNode(t),n&&this.code(n).endFor(),this}for(t,n){return this._for(new AC(t),n)}forRange(t,n,i,r,o=this.opts.es5?_i.varKinds.var:_i.varKinds.let){let s=this._scope.toName(t);return this._for(new PC(o,s,n,i),()=>r(s))}forOf(t,n,i,r=_i.varKinds.const){let o=this._scope.toName(t);if(this.opts.es5){let s=n instanceof rt.Name?n:this.var("_arr",n);return this.forRange("_i",0,(0,rt._)`${s}.length`,a=>{this.var(o,(0,rt._)`${s}[${a}]`),i(o)})}return this._for(new $w("of",r,o,n),()=>i(o))}forIn(t,n,i,r=this.opts.es5?_i.varKinds.var:_i.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0,rt._)`Object.keys(${n})`,i);let o=this._scope.toName(t);return this._for(new $w("in",r,o,n),()=>i(o))}endFor(){return this._endBlockNode(Pc)}label(t){return this._leafNode(new xC(t))}break(t){return this._leafNode(new $C(t))}return(t){let n=new Vf;if(this._blockNode(n),this.code(t),n.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(Vf)}try(t,n,i){if(!n&&!i)throw new Error('CodeGen: "try" without "catch" and "finally"');let r=new OC;if(this._blockNode(r),this.code(t),n){let o=this.name("e");this._currNode=r.catch=new qf(o),n(o)}return i&&(this._currNode=r.finally=new Kf,this.code(i)),this._endBlockNode(qf,Kf)}throw(t){return this._leafNode(new RC(t))}block(t,n){return this._blockStarts.push(this._nodes.length),t&&this.code(t).endBlock(n),this}endBlock(t){let n=this._blockStarts.pop();if(n===void 0)throw new Error("CodeGen: not in self-balancing block");let i=this._nodes.length-n;if(i<0||t!==void 0&&i!==t)throw new Error(`CodeGen: wrong number of nodes: ${i} vs ${t} expected`);return this._nodes.length=n,this}func(t,n=rt.nil,i,r){return this._blockNode(new Hf(t,n,i)),r&&this.code(r).endFunc(),this}endFunc(){return this._endBlockNode(Hf)}optimize(t=1){for(;t-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(t){return this._currNode.nodes.push(t),this}_blockNode(t){this._currNode.nodes.push(t),this._nodes.push(t)}_endBlockNode(t,n){let i=this._currNode;if(i instanceof t||n&&i instanceof n)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${n?`${t.kind}/${n.kind}`:t.kind}"`)}_elseNode(t){let n=this._currNode;if(!(n instanceof Ac))throw new Error('CodeGen: "else" without "if"');return this._currNode=n.else=t,this}get _root(){return this._nodes[0]}get _currNode(){let t=this._nodes;return t[t.length-1]}set _currNode(t){let n=this._nodes;n[n.length-1]=t}};Ze.CodeGen=CC;function Oc(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function Rw(e,t){return t instanceof rt._CodeOrName?Oc(e,t.names):e}function Mu(e,t,n){if(e instanceof rt.Name)return i(e);if(!r(e))return e;return new rt._Code(e._items.reduce((o,s)=>(s instanceof rt.Name&&(s=i(s)),s instanceof rt._Code?o.push(...s._items):o.push(s),o),[]));function i(o){let s=n[o.str];return s===void 0||t[o.str]!==1?o:(delete t[o.str],s)}function r(o){return o instanceof rt._Code&&o._items.some(s=>s instanceof rt.Name&&t[s.str]===1&&n[s.str]!==void 0)}}function jae(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function kU(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0,rt._)`!${_C(e)}`}Ze.not=kU;var Lae=xU(Ze.operators.AND);function Mae(...e){return e.reduce(Lae)}Ze.and=Mae;var Fae=xU(Ze.operators.OR);function Bae(...e){return e.reduce(Fae)}Ze.or=Bae;function xU(e){return(t,n)=>t===rt.nil?n:n===rt.nil?t:(0,rt._)`${_C(t)} ${e} ${_C(n)}`}function _C(e){return e instanceof rt.Name?e:(0,rt._)`(${e})`}});var Xe=ie(Ye=>{"use strict";Object.defineProperty(Ye,"__esModule",{value:!0});Ye.checkStrictMode=Ye.getErrorPath=Ye.Type=Ye.useFunc=Ye.setEvaluated=Ye.evaluatedPropsToName=Ye.mergeEvaluated=Ye.eachItem=Ye.unescapeJsonPointer=Ye.escapeJsonPointer=Ye.escapeFragment=Ye.unescapeFragment=Ye.schemaRefOrVal=Ye.schemaHasRulesButRef=Ye.schemaHasRules=Ye.checkUnknownRules=Ye.alwaysValidSchema=Ye.toHash=void 0;var At=Fe(),Gae=zf();function Wae(e){let t={};for(let n of e)t[n]=!0;return t}Ye.toHash=Wae;function zae(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(SU(e,t),!EU(t,e.self.RULES.all))}Ye.alwaysValidSchema=zae;function SU(e,t=e.schema){let{opts:n,self:i}=e;if(!n.strictSchema||typeof t=="boolean")return;let r=i.RULES.keywords;for(let o in t)r[o]||OU(e,`unknown keyword: "${o}"`)}Ye.checkUnknownRules=SU;function EU(e,t){if(typeof e=="boolean")return!e;for(let n in e)if(t[n])return!0;return!1}Ye.schemaHasRules=EU;function Uae(e,t){if(typeof e=="boolean")return!e;for(let n in e)if(n!=="$ref"&&t.all[n])return!0;return!1}Ye.schemaHasRulesButRef=Uae;function Hae({topSchemaRef:e,schemaPath:t},n,i,r){if(!r){if(typeof n=="number"||typeof n=="boolean")return n;if(typeof n=="string")return(0,At._)`${n}`}return(0,At._)`${e}${t}${(0,At.getProperty)(i)}`}Ye.schemaRefOrVal=Hae;function Vae(e){return AU(decodeURIComponent(e))}Ye.unescapeFragment=Vae;function qae(e){return encodeURIComponent(TC(e))}Ye.escapeFragment=qae;function TC(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}Ye.escapeJsonPointer=TC;function AU(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}Ye.unescapeJsonPointer=AU;function Kae(e,t){if(Array.isArray(e))for(let n of e)t(n);else t(e)}Ye.eachItem=Kae;function $U({mergeNames:e,mergeToName:t,mergeValues:n,resultToName:i}){return(r,o,s,a)=>{let l=s===void 0?o:s instanceof At.Name?(o instanceof At.Name?e(r,o,s):t(r,o,s),s):o instanceof At.Name?(t(r,s,o),o):n(o,s);return a===At.Name&&!(l instanceof At.Name)?i(r,l):l}}Ye.mergeEvaluated={props:$U({mergeNames:(e,t,n)=>e.if((0,At._)`${n} !== true && ${t} !== undefined`,()=>{e.if((0,At._)`${t} === true`,()=>e.assign(n,!0),()=>e.assign(n,(0,At._)`${n} || {}`).code((0,At._)`Object.assign(${n}, ${t})`))}),mergeToName:(e,t,n)=>e.if((0,At._)`${n} !== true`,()=>{t===!0?e.assign(n,!0):(e.assign(n,(0,At._)`${n} || {}`),DC(e,n,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:PU}),items:$U({mergeNames:(e,t,n)=>e.if((0,At._)`${n} !== true && ${t} !== undefined`,()=>e.assign(n,(0,At._)`${t} === true ? true : ${n} > ${t} ? ${n} : ${t}`)),mergeToName:(e,t,n)=>e.if((0,At._)`${n} !== true`,()=>e.assign(n,t===!0?!0:(0,At._)`${n} > ${t} ? ${n} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function PU(e,t){if(t===!0)return e.var("props",!0);let n=e.var("props",(0,At._)`{}`);return t!==void 0&&DC(e,n,t),n}Ye.evaluatedPropsToName=PU;function DC(e,t,n){Object.keys(n).forEach(i=>e.assign((0,At._)`${t}${(0,At.getProperty)(i)}`,!0))}Ye.setEvaluated=DC;var RU={};function Jae(e,t){return e.scopeValue("func",{ref:t,code:RU[t.code]||(RU[t.code]=new Gae._Code(t.code))})}Ye.useFunc=Jae;var IC;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(IC||(Ye.Type=IC={}));function Zae(e,t,n){if(e instanceof At.Name){let i=t===IC.Num;return n?i?(0,At._)`"[" + ${e} + "]"`:(0,At._)`"['" + ${e} + "']"`:i?(0,At._)`"/" + ${e}`:(0,At._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return n?(0,At.getProperty)(e).toString():"/"+TC(e)}Ye.getErrorPath=Zae;function OU(e,t,n=e.opts.strictSchema){if(n){if(t=`strict mode: ${t}`,n===!0)throw new Error(t);e.self.logger.warn(t)}}Ye.checkStrictMode=OU});var ei=ie(NC=>{"use strict";Object.defineProperty(NC,"__esModule",{value:!0});var Fn=Fe(),Yae={data:new Fn.Name("data"),valCxt:new Fn.Name("valCxt"),instancePath:new Fn.Name("instancePath"),parentData:new Fn.Name("parentData"),parentDataProperty:new Fn.Name("parentDataProperty"),rootData:new Fn.Name("rootData"),dynamicAnchors:new Fn.Name("dynamicAnchors"),vErrors:new Fn.Name("vErrors"),errors:new Fn.Name("errors"),this:new Fn.Name("this"),self:new Fn.Name("self"),scope:new Fn.Name("scope"),json:new Fn.Name("json"),jsonPos:new Fn.Name("jsonPos"),jsonLen:new Fn.Name("jsonLen"),jsonPart:new Fn.Name("jsonPart")};NC.default=Yae});var Jf=ie(Bn=>{"use strict";Object.defineProperty(Bn,"__esModule",{value:!0});Bn.extendErrors=Bn.resetErrorsCount=Bn.reportExtraError=Bn.reportError=Bn.keyword$DataError=Bn.keywordError=void 0;var st=Fe(),Ew=Xe(),Xn=ei();Bn.keywordError={message:({keyword:e})=>(0,st.str)`must pass "${e}" keyword validation`};Bn.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0,st.str)`"${e}" keyword must be ${t} ($data)`:(0,st.str)`"${e}" keyword is invalid ($data)`};function Xae(e,t=Bn.keywordError,n,i){let{it:r}=e,{gen:o,compositeRule:s,allErrors:a}=r,l=IU(e,t,n);i??(s||a)?CU(o,l):_U(r,(0,st._)`[${l}]`)}Bn.reportError=Xae;function Qae(e,t=Bn.keywordError,n){let{it:i}=e,{gen:r,compositeRule:o,allErrors:s}=i,a=IU(e,t,n);CU(r,a),o||s||_U(i,Xn.default.vErrors)}Bn.reportExtraError=Qae;function ece(e,t){e.assign(Xn.default.errors,t),e.if((0,st._)`${Xn.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0,st._)`${Xn.default.vErrors}.length`,t),()=>e.assign(Xn.default.vErrors,null)))}Bn.resetErrorsCount=ece;function tce({gen:e,keyword:t,schemaValue:n,data:i,errsCount:r,it:o}){if(r===void 0)throw new Error("ajv implementation error");let s=e.name("err");e.forRange("i",r,Xn.default.errors,a=>{e.const(s,(0,st._)`${Xn.default.vErrors}[${a}]`),e.if((0,st._)`${s}.instancePath === undefined`,()=>e.assign((0,st._)`${s}.instancePath`,(0,st.strConcat)(Xn.default.instancePath,o.errorPath))),e.assign((0,st._)`${s}.schemaPath`,(0,st.str)`${o.errSchemaPath}/${t}`),o.opts.verbose&&(e.assign((0,st._)`${s}.schema`,n),e.assign((0,st._)`${s}.data`,i))})}Bn.extendErrors=tce;function CU(e,t){let n=e.const("err",t);e.if((0,st._)`${Xn.default.vErrors} === null`,()=>e.assign(Xn.default.vErrors,(0,st._)`[${n}]`),(0,st._)`${Xn.default.vErrors}.push(${n})`),e.code((0,st._)`${Xn.default.errors}++`)}function _U(e,t){let{gen:n,validateName:i,schemaEnv:r}=e;r.$async?n.throw((0,st._)`new ${e.ValidationError}(${t})`):(n.assign((0,st._)`${i}.errors`,t),n.return(!1))}var Cc={keyword:new st.Name("keyword"),schemaPath:new st.Name("schemaPath"),params:new st.Name("params"),propertyName:new st.Name("propertyName"),message:new st.Name("message"),schema:new st.Name("schema"),parentSchema:new st.Name("parentSchema")};function IU(e,t,n){let{createErrors:i}=e.it;return i===!1?(0,st._)`{}`:nce(e,t,n)}function nce(e,t,n={}){let{gen:i,it:r}=e,o=[rce(r,n),ice(e,n)];return oce(e,t,o),i.object(...o)}function rce({errorPath:e},{instancePath:t}){let n=t?(0,st.str)`${e}${(0,Ew.getErrorPath)(t,Ew.Type.Str)}`:e;return[Xn.default.instancePath,(0,st.strConcat)(Xn.default.instancePath,n)]}function ice({keyword:e,it:{errSchemaPath:t}},{schemaPath:n,parentSchema:i}){let r=i?t:(0,st.str)`${t}/${e}`;return n&&(r=(0,st.str)`${r}${(0,Ew.getErrorPath)(n,Ew.Type.Str)}`),[Cc.schemaPath,r]}function oce(e,{params:t,message:n},i){let{keyword:r,data:o,schemaValue:s,it:a}=e,{opts:l,propertyName:c,topSchemaRef:u,schemaPath:d}=a;i.push([Cc.keyword,r],[Cc.params,typeof t=="function"?t(e):t||(0,st._)`{}`]),l.messages&&i.push([Cc.message,typeof n=="function"?n(e):n]),l.verbose&&i.push([Cc.schema,s],[Cc.parentSchema,(0,st._)`${u}${d}`],[Xn.default.data,o]),c&&i.push([Cc.propertyName,c])}});var DU=ie(Fu=>{"use strict";Object.defineProperty(Fu,"__esModule",{value:!0});Fu.boolOrEmptySchema=Fu.topBoolOrEmptySchema=void 0;var sce=Jf(),ace=Fe(),cce=ei(),lce={message:"boolean schema is false"};function uce(e){let{gen:t,schema:n,validateName:i}=e;n===!1?TU(e,!1):typeof n=="object"&&n.$async===!0?t.return(cce.default.data):(t.assign((0,ace._)`${i}.errors`,null),t.return(!0))}Fu.topBoolOrEmptySchema=uce;function dce(e,t){let{gen:n,schema:i}=e;i===!1?(n.var(t,!1),TU(e)):n.var(t,!0)}Fu.boolOrEmptySchema=dce;function TU(e,t){let{gen:n,data:i}=e,r={gen:n,keyword:"false schema",data:i,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,sce.reportError)(r,lce,void 0,t)}});var jC=ie(Bu=>{"use strict";Object.defineProperty(Bu,"__esModule",{value:!0});Bu.getRules=Bu.isJSONType=void 0;var pce=["string","number","integer","boolean","null","object","array"],fce=new Set(pce);function mce(e){return typeof e=="string"&&fce.has(e)}Bu.isJSONType=mce;function gce(){let e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}Bu.getRules=gce});var LC=ie(sa=>{"use strict";Object.defineProperty(sa,"__esModule",{value:!0});sa.shouldUseRule=sa.shouldUseGroup=sa.schemaHasRulesForType=void 0;function hce({schema:e,self:t},n){let i=t.RULES.types[n];return i&&i!==!0&&NU(e,i)}sa.schemaHasRulesForType=hce;function NU(e,t){return t.rules.some(n=>jU(e,n))}sa.shouldUseGroup=NU;function jU(e,t){var n;return e[t.keyword]!==void 0||((n=t.definition.implements)===null||n===void 0?void 0:n.some(i=>e[i]!==void 0))}sa.shouldUseRule=jU});var Zf=ie(Gn=>{"use strict";Object.defineProperty(Gn,"__esModule",{value:!0});Gn.reportTypeError=Gn.checkDataTypes=Gn.checkDataType=Gn.coerceAndCheckDataType=Gn.getJSONTypes=Gn.getSchemaTypes=Gn.DataType=void 0;var yce=jC(),bce=LC(),wce=Jf(),Ue=Fe(),LU=Xe(),Gu;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(Gu||(Gn.DataType=Gu={}));function vce(e){let t=MU(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}Gn.getSchemaTypes=vce;function MU(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(yce.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}Gn.getJSONTypes=MU;function kce(e,t){let{gen:n,data:i,opts:r}=e,o=xce(t,r.coerceTypes),s=t.length>0&&!(o.length===0&&t.length===1&&(0,bce.schemaHasRulesForType)(e,t[0]));if(s){let a=FC(t,i,r.strictNumbers,Gu.Wrong);n.if(a,()=>{o.length?$ce(e,t,o):BC(e)})}return s}Gn.coerceAndCheckDataType=kce;var FU=new Set(["string","number","integer","boolean","null"]);function xce(e,t){return t?e.filter(n=>FU.has(n)||t==="array"&&n==="array"):[]}function $ce(e,t,n){let{gen:i,data:r,opts:o}=e,s=i.let("dataType",(0,Ue._)`typeof ${r}`),a=i.let("coerced",(0,Ue._)`undefined`);o.coerceTypes==="array"&&i.if((0,Ue._)`${s} == 'object' && Array.isArray(${r}) && ${r}.length == 1`,()=>i.assign(r,(0,Ue._)`${r}[0]`).assign(s,(0,Ue._)`typeof ${r}`).if(FC(t,r,o.strictNumbers),()=>i.assign(a,r))),i.if((0,Ue._)`${a} !== undefined`);for(let c of n)(FU.has(c)||c==="array"&&o.coerceTypes==="array")&&l(c);i.else(),BC(e),i.endIf(),i.if((0,Ue._)`${a} !== undefined`,()=>{i.assign(r,a),Rce(e,a)});function l(c){switch(c){case"string":i.elseIf((0,Ue._)`${s} == "number" || ${s} == "boolean"`).assign(a,(0,Ue._)`"" + ${r}`).elseIf((0,Ue._)`${r} === null`).assign(a,(0,Ue._)`""`);return;case"number":i.elseIf((0,Ue._)`${s} == "boolean" || ${r} === null
|
|
64
|
+
|| (${s} == "string" && ${r} && ${r} == +${r})`).assign(a,(0,Ue._)`+${r}`);return;case"integer":i.elseIf((0,Ue._)`${s} === "boolean" || ${r} === null
|
|
65
|
+
|| (${s} === "string" && ${r} && ${r} == +${r} && !(${r} % 1))`).assign(a,(0,Ue._)`+${r}`);return;case"boolean":i.elseIf((0,Ue._)`${r} === "false" || ${r} === 0 || ${r} === null`).assign(a,!1).elseIf((0,Ue._)`${r} === "true" || ${r} === 1`).assign(a,!0);return;case"null":i.elseIf((0,Ue._)`${r} === "" || ${r} === 0 || ${r} === false`),i.assign(a,null);return;case"array":i.elseIf((0,Ue._)`${s} === "string" || ${s} === "number"
|
|
66
|
+
|| ${s} === "boolean" || ${r} === null`).assign(a,(0,Ue._)`[${r}]`)}}}function Rce({gen:e,parentData:t,parentDataProperty:n},i){e.if((0,Ue._)`${t} !== undefined`,()=>e.assign((0,Ue._)`${t}[${n}]`,i))}function MC(e,t,n,i=Gu.Correct){let r=i===Gu.Correct?Ue.operators.EQ:Ue.operators.NEQ,o;switch(e){case"null":return(0,Ue._)`${t} ${r} null`;case"array":o=(0,Ue._)`Array.isArray(${t})`;break;case"object":o=(0,Ue._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":o=s((0,Ue._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":o=s();break;default:return(0,Ue._)`typeof ${t} ${r} ${e}`}return i===Gu.Correct?o:(0,Ue.not)(o);function s(a=Ue.nil){return(0,Ue.and)((0,Ue._)`typeof ${t} == "number"`,a,n?(0,Ue._)`isFinite(${t})`:Ue.nil)}}Gn.checkDataType=MC;function FC(e,t,n,i){if(e.length===1)return MC(e[0],t,n,i);let r,o=(0,LU.toHash)(e);if(o.array&&o.object){let s=(0,Ue._)`typeof ${t} != "object"`;r=o.null?s:(0,Ue._)`!${t} || ${s}`,delete o.null,delete o.array,delete o.object}else r=Ue.nil;o.number&&delete o.integer;for(let s in o)r=(0,Ue.and)(r,MC(s,t,n,i));return r}Gn.checkDataTypes=FC;var Sce={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,Ue._)`{type: ${e}}`:(0,Ue._)`{type: ${t}}`};function BC(e){let t=Ece(e);(0,wce.reportError)(t,Sce)}Gn.reportTypeError=BC;function Ece(e){let{gen:t,data:n,schema:i}=e,r=(0,LU.schemaRefOrVal)(e,i,"type");return{gen:t,keyword:"type",data:n,schema:i.type,schemaCode:r,schemaValue:r,parentSchema:i,params:{},it:e}}});var GU=ie(Aw=>{"use strict";Object.defineProperty(Aw,"__esModule",{value:!0});Aw.assignDefaults=void 0;var Wu=Fe(),Ace=Xe();function Pce(e,t){let{properties:n,items:i}=e.schema;if(t==="object"&&n)for(let r in n)BU(e,r,n[r].default);else t==="array"&&Array.isArray(i)&&i.forEach((r,o)=>BU(e,o,r.default))}Aw.assignDefaults=Pce;function BU(e,t,n){let{gen:i,compositeRule:r,data:o,opts:s}=e;if(n===void 0)return;let a=(0,Wu._)`${o}${(0,Wu.getProperty)(t)}`;if(r){(0,Ace.checkStrictMode)(e,`default is ignored for: ${a}`);return}let l=(0,Wu._)`${a} === undefined`;s.useDefaults==="empty"&&(l=(0,Wu._)`${l} || ${a} === null || ${a} === ""`),i.if(l,(0,Wu._)`${a} = ${(0,Wu.stringify)(n)}`)}});var ti=ie(xt=>{"use strict";Object.defineProperty(xt,"__esModule",{value:!0});xt.validateUnion=xt.validateArray=xt.usePattern=xt.callValidateCode=xt.schemaProperties=xt.allSchemaProperties=xt.noPropertyInData=xt.propertyInData=xt.isOwnProperty=xt.hasPropFunc=xt.reportMissingProp=xt.checkMissingProp=xt.checkReportMissingProp=void 0;var Nt=Fe(),GC=Xe(),aa=ei(),Oce=Xe();function Cce(e,t){let{gen:n,data:i,it:r}=e;n.if(zC(n,i,t,r.opts.ownProperties),()=>{e.setParams({missingProperty:(0,Nt._)`${t}`},!0),e.error()})}xt.checkReportMissingProp=Cce;function _ce({gen:e,data:t,it:{opts:n}},i,r){return(0,Nt.or)(...i.map(o=>(0,Nt.and)(zC(e,t,o,n.ownProperties),(0,Nt._)`${r} = ${o}`)))}xt.checkMissingProp=_ce;function Ice(e,t){e.setParams({missingProperty:t},!0),e.error()}xt.reportMissingProp=Ice;function WU(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Nt._)`Object.prototype.hasOwnProperty`})}xt.hasPropFunc=WU;function WC(e,t,n){return(0,Nt._)`${WU(e)}.call(${t}, ${n})`}xt.isOwnProperty=WC;function Tce(e,t,n,i){let r=(0,Nt._)`${t}${(0,Nt.getProperty)(n)} !== undefined`;return i?(0,Nt._)`${r} && ${WC(e,t,n)}`:r}xt.propertyInData=Tce;function zC(e,t,n,i){let r=(0,Nt._)`${t}${(0,Nt.getProperty)(n)} === undefined`;return i?(0,Nt.or)(r,(0,Nt.not)(WC(e,t,n))):r}xt.noPropertyInData=zC;function zU(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}xt.allSchemaProperties=zU;function Dce(e,t){return zU(t).filter(n=>!(0,GC.alwaysValidSchema)(e,t[n]))}xt.schemaProperties=Dce;function Nce({schemaCode:e,data:t,it:{gen:n,topSchemaRef:i,schemaPath:r,errorPath:o},it:s},a,l,c){let u=c?(0,Nt._)`${e}, ${t}, ${i}${r}`:t,d=[[aa.default.instancePath,(0,Nt.strConcat)(aa.default.instancePath,o)],[aa.default.parentData,s.parentData],[aa.default.parentDataProperty,s.parentDataProperty],[aa.default.rootData,aa.default.rootData]];s.opts.dynamicRef&&d.push([aa.default.dynamicAnchors,aa.default.dynamicAnchors]);let p=(0,Nt._)`${u}, ${n.object(...d)}`;return l!==Nt.nil?(0,Nt._)`${a}.call(${l}, ${p})`:(0,Nt._)`${a}(${p})`}xt.callValidateCode=Nce;var jce=(0,Nt._)`new RegExp`;function Lce({gen:e,it:{opts:t}},n){let i=t.unicodeRegExp?"u":"",{regExp:r}=t.code,o=r(n,i);return e.scopeValue("pattern",{key:o.toString(),ref:o,code:(0,Nt._)`${r.code==="new RegExp"?jce:(0,Oce.useFunc)(e,r)}(${n}, ${i})`})}xt.usePattern=Lce;function Mce(e){let{gen:t,data:n,keyword:i,it:r}=e,o=t.name("valid");if(r.allErrors){let a=t.let("valid",!0);return s(()=>t.assign(a,!1)),a}return t.var(o,!0),s(()=>t.break()),o;function s(a){let l=t.const("len",(0,Nt._)`${n}.length`);t.forRange("i",0,l,c=>{e.subschema({keyword:i,dataProp:c,dataPropType:GC.Type.Num},o),t.if((0,Nt.not)(o),a)})}}xt.validateArray=Mce;function Fce(e){let{gen:t,schema:n,keyword:i,it:r}=e;if(!Array.isArray(n))throw new Error("ajv implementation error");if(n.some(l=>(0,GC.alwaysValidSchema)(r,l))&&!r.opts.unevaluated)return;let s=t.let("valid",!1),a=t.name("_valid");t.block(()=>n.forEach((l,c)=>{let u=e.subschema({keyword:i,schemaProp:c,compositeRule:!0},a);t.assign(s,(0,Nt._)`${s} || ${a}`),e.mergeValidEvaluated(u,a)||t.if((0,Nt.not)(s))})),e.result(s,()=>e.reset(),()=>e.error(!0))}xt.validateUnion=Fce});var VU=ie(oo=>{"use strict";Object.defineProperty(oo,"__esModule",{value:!0});oo.validateKeywordUsage=oo.validSchemaType=oo.funcKeywordCode=oo.macroKeywordCode=void 0;var Qn=Fe(),_c=ei(),Bce=ti(),Gce=Jf();function Wce(e,t){let{gen:n,keyword:i,schema:r,parentSchema:o,it:s}=e,a=t.macro.call(s.self,r,o,s),l=HU(n,i,a);s.opts.validateSchema!==!1&&s.self.validateSchema(a,!0);let c=n.name("valid");e.subschema({schema:a,schemaPath:Qn.nil,errSchemaPath:`${s.errSchemaPath}/${i}`,topSchemaRef:l,compositeRule:!0},c),e.pass(c,()=>e.error(!0))}oo.macroKeywordCode=Wce;function zce(e,t){var n;let{gen:i,keyword:r,schema:o,parentSchema:s,$data:a,it:l}=e;Hce(l,t);let c=!a&&t.compile?t.compile.call(l.self,o,s,l):t.validate,u=HU(i,r,c),d=i.let("valid");e.block$data(d,p),e.ok((n=t.valid)!==null&&n!==void 0?n:d);function p(){if(t.errors===!1)h(),t.modifying&&UU(e),b(()=>e.error());else{let w=t.async?f():g();t.modifying&&UU(e),b(()=>Uce(e,w))}}function f(){let w=i.let("ruleErrs",null);return i.try(()=>h((0,Qn._)`await `),x=>i.assign(d,!1).if((0,Qn._)`${x} instanceof ${l.ValidationError}`,()=>i.assign(w,(0,Qn._)`${x}.errors`),()=>i.throw(x))),w}function g(){let w=(0,Qn._)`${u}.errors`;return i.assign(w,null),h(Qn.nil),w}function h(w=t.async?(0,Qn._)`await `:Qn.nil){let x=l.opts.passContext?_c.default.this:_c.default.self,k=!("compile"in t&&!a||t.schema===!1);i.assign(d,(0,Qn._)`${w}${(0,Bce.callValidateCode)(e,u,x,k)}`,t.modifying)}function b(w){var x;i.if((0,Qn.not)((x=t.valid)!==null&&x!==void 0?x:d),w)}}oo.funcKeywordCode=zce;function UU(e){let{gen:t,data:n,it:i}=e;t.if(i.parentData,()=>t.assign(n,(0,Qn._)`${i.parentData}[${i.parentDataProperty}]`))}function Uce(e,t){let{gen:n}=e;n.if((0,Qn._)`Array.isArray(${t})`,()=>{n.assign(_c.default.vErrors,(0,Qn._)`${_c.default.vErrors} === null ? ${t} : ${_c.default.vErrors}.concat(${t})`).assign(_c.default.errors,(0,Qn._)`${_c.default.vErrors}.length`),(0,Gce.extendErrors)(e)},()=>e.error())}function Hce({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function HU(e,t,n){if(n===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof n=="function"?{ref:n}:{ref:n,code:(0,Qn.stringify)(n)})}function Vce(e,t,n=!1){return!t.length||t.some(i=>i==="array"?Array.isArray(e):i==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==i||n&&typeof e>"u")}oo.validSchemaType=Vce;function qce({schema:e,opts:t,self:n,errSchemaPath:i},r,o){if(Array.isArray(r.keyword)?!r.keyword.includes(o):r.keyword!==o)throw new Error("ajv implementation error");let s=r.dependencies;if(s?.some(a=>!Object.prototype.hasOwnProperty.call(e,a)))throw new Error(`parent schema must have dependencies of ${o}: ${s.join(",")}`);if(r.validateSchema&&!r.validateSchema(e[o])){let l=`keyword "${o}" value is invalid at path "${i}": `+n.errorsText(r.validateSchema.errors);if(t.validateSchema==="log")n.logger.error(l);else throw new Error(l)}}oo.validateKeywordUsage=qce});var KU=ie(ca=>{"use strict";Object.defineProperty(ca,"__esModule",{value:!0});ca.extendSubschemaMode=ca.extendSubschemaData=ca.getSubschema=void 0;var so=Fe(),qU=Xe();function Kce(e,{keyword:t,schemaProp:n,schema:i,schemaPath:r,errSchemaPath:o,topSchemaRef:s}){if(t!==void 0&&i!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){let a=e.schema[t];return n===void 0?{schema:a,schemaPath:(0,so._)`${e.schemaPath}${(0,so.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:a[n],schemaPath:(0,so._)`${e.schemaPath}${(0,so.getProperty)(t)}${(0,so.getProperty)(n)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,qU.escapeFragment)(n)}`}}if(i!==void 0){if(r===void 0||o===void 0||s===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:i,schemaPath:r,topSchemaRef:s,errSchemaPath:o}}throw new Error('either "keyword" or "schema" must be passed')}ca.getSubschema=Kce;function Jce(e,t,{dataProp:n,dataPropType:i,data:r,dataTypes:o,propertyName:s}){if(r!==void 0&&n!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=t;if(n!==void 0){let{errorPath:c,dataPathArr:u,opts:d}=t,p=a.let("data",(0,so._)`${t.data}${(0,so.getProperty)(n)}`,!0);l(p),e.errorPath=(0,so.str)`${c}${(0,qU.getErrorPath)(n,i,d.jsPropertySyntax)}`,e.parentDataProperty=(0,so._)`${n}`,e.dataPathArr=[...u,e.parentDataProperty]}if(r!==void 0){let c=r instanceof so.Name?r:a.let("data",r,!0);l(c),s!==void 0&&(e.propertyName=s)}o&&(e.dataTypes=o);function l(c){e.data=c,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,c]}}ca.extendSubschemaData=Jce;function Zce(e,{jtdDiscriminator:t,jtdMetadata:n,compositeRule:i,createErrors:r,allErrors:o}){i!==void 0&&(e.compositeRule=i),r!==void 0&&(e.createErrors=r),o!==void 0&&(e.allErrors=o),e.jtdDiscriminator=t,e.jtdMetadata=n}ca.extendSubschemaMode=Zce});var UC=ie((iFe,JU)=>{"use strict";JU.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t=="object"&&typeof n=="object"){if(t.constructor!==n.constructor)return!1;var i,r,o;if(Array.isArray(t)){if(i=t.length,i!=n.length)return!1;for(r=i;r--!==0;)if(!e(t[r],n[r]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(o=Object.keys(t),i=o.length,i!==Object.keys(n).length)return!1;for(r=i;r--!==0;)if(!Object.prototype.hasOwnProperty.call(n,o[r]))return!1;for(r=i;r--!==0;){var s=o[r];if(!e(t[s],n[s]))return!1}return!0}return t!==t&&n!==n}});var YU=ie((oFe,ZU)=>{"use strict";var la=ZU.exports=function(e,t,n){typeof t=="function"&&(n=t,t={}),n=t.cb||n;var i=typeof n=="function"?n:n.pre||function(){},r=n.post||function(){};Pw(t,i,r,e,"",e)};la.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};la.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};la.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};la.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function Pw(e,t,n,i,r,o,s,a,l,c){if(i&&typeof i=="object"&&!Array.isArray(i)){t(i,r,o,s,a,l,c);for(var u in i){var d=i[u];if(Array.isArray(d)){if(u in la.arrayKeywords)for(var p=0;p<d.length;p++)Pw(e,t,n,d[p],r+"/"+u+"/"+p,o,r,u,i,p)}else if(u in la.propsKeywords){if(d&&typeof d=="object")for(var f in d)Pw(e,t,n,d[f],r+"/"+u+"/"+Yce(f),o,r,u,i,f)}else(u in la.keywords||e.allKeys&&!(u in la.skipKeywords))&&Pw(e,t,n,d,r+"/"+u,o,r,u,i)}n(i,r,o,s,a,l,c)}}function Yce(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}});var Yf=ie(vr=>{"use strict";Object.defineProperty(vr,"__esModule",{value:!0});vr.getSchemaRefs=vr.resolveUrl=vr.normalizeId=vr._getFullPath=vr.getFullPath=vr.inlineRef=void 0;var Xce=Xe(),Qce=UC(),ele=YU(),tle=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function nle(e,t=!0){return typeof e=="boolean"?!0:t===!0?!HC(e):t?XU(e)<=t:!1}vr.inlineRef=nle;var rle=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function HC(e){for(let t in e){if(rle.has(t))return!0;let n=e[t];if(Array.isArray(n)&&n.some(HC)||typeof n=="object"&&HC(n))return!0}return!1}function XU(e){let t=0;for(let n in e){if(n==="$ref")return 1/0;if(t++,!tle.has(n)&&(typeof e[n]=="object"&&(0,Xce.eachItem)(e[n],i=>t+=XU(i)),t===1/0))return 1/0}return t}function QU(e,t="",n){n!==!1&&(t=zu(t));let i=e.parse(t);return e2(e,i)}vr.getFullPath=QU;function e2(e,t){return e.serialize(t).split("#")[0]+"#"}vr._getFullPath=e2;var ile=/#\/?$/;function zu(e){return e?e.replace(ile,""):""}vr.normalizeId=zu;function ole(e,t,n){return n=zu(n),e.resolve(t,n)}vr.resolveUrl=ole;var sle=/^[a-z_][-a-z0-9._]*$/i;function ale(e,t){if(typeof e=="boolean")return{};let{schemaId:n,uriResolver:i}=this.opts,r=zu(e[n]||t),o={"":r},s=QU(i,r,!1),a={},l=new Set;return ele(e,{allKeys:!0},(d,p,f,g)=>{if(g===void 0)return;let h=s+p,b=o[g];typeof d[n]=="string"&&(b=w.call(this,d[n])),x.call(this,d.$anchor),x.call(this,d.$dynamicAnchor),o[p]=b;function w(k){let R=this.opts.uriResolver.resolve;if(k=zu(b?R(b,k):k),l.has(k))throw u(k);l.add(k);let $=this.refs[k];return typeof $=="string"&&($=this.refs[$]),typeof $=="object"?c(d,$.schema,k):k!==zu(h)&&(k[0]==="#"?(c(d,a[k],k),a[k]=d):this.refs[k]=h),k}function x(k){if(typeof k=="string"){if(!sle.test(k))throw new Error(`invalid anchor "${k}"`);w.call(this,`#${k}`)}}}),a;function c(d,p,f){if(p!==void 0&&!Qce(d,p))throw u(f)}function u(d){return new Error(`reference "${d}" resolves to more than one schema`)}}vr.getSchemaRefs=ale});var Uu=ie(ua=>{"use strict";Object.defineProperty(ua,"__esModule",{value:!0});ua.getData=ua.KeywordCxt=ua.validateFunctionCode=void 0;var o2=DU(),t2=Zf(),qC=LC(),Ow=Zf(),cle=GU(),Qf=VU(),VC=KU(),Pe=Fe(),je=ei(),lle=Yf(),os=Xe(),Xf=Jf();function ule(e){if(c2(e)&&(l2(e),a2(e))){fle(e);return}s2(e,()=>(0,o2.topBoolOrEmptySchema)(e))}ua.validateFunctionCode=ule;function s2({gen:e,validateName:t,schema:n,schemaEnv:i,opts:r},o){r.code.es5?e.func(t,(0,Pe._)`${je.default.data}, ${je.default.valCxt}`,i.$async,()=>{e.code((0,Pe._)`"use strict"; ${n2(n,r)}`),ple(e,r),e.code(o)}):e.func(t,(0,Pe._)`${je.default.data}, ${dle(r)}`,i.$async,()=>e.code(n2(n,r)).code(o))}function dle(e){return(0,Pe._)`{${je.default.instancePath}="", ${je.default.parentData}, ${je.default.parentDataProperty}, ${je.default.rootData}=${je.default.data}${e.dynamicRef?(0,Pe._)`, ${je.default.dynamicAnchors}={}`:Pe.nil}}={}`}function ple(e,t){e.if(je.default.valCxt,()=>{e.var(je.default.instancePath,(0,Pe._)`${je.default.valCxt}.${je.default.instancePath}`),e.var(je.default.parentData,(0,Pe._)`${je.default.valCxt}.${je.default.parentData}`),e.var(je.default.parentDataProperty,(0,Pe._)`${je.default.valCxt}.${je.default.parentDataProperty}`),e.var(je.default.rootData,(0,Pe._)`${je.default.valCxt}.${je.default.rootData}`),t.dynamicRef&&e.var(je.default.dynamicAnchors,(0,Pe._)`${je.default.valCxt}.${je.default.dynamicAnchors}`)},()=>{e.var(je.default.instancePath,(0,Pe._)`""`),e.var(je.default.parentData,(0,Pe._)`undefined`),e.var(je.default.parentDataProperty,(0,Pe._)`undefined`),e.var(je.default.rootData,je.default.data),t.dynamicRef&&e.var(je.default.dynamicAnchors,(0,Pe._)`{}`)})}function fle(e){let{schema:t,opts:n,gen:i}=e;s2(e,()=>{n.$comment&&t.$comment&&d2(e),ble(e),i.let(je.default.vErrors,null),i.let(je.default.errors,0),n.unevaluated&&mle(e),u2(e),kle(e)})}function mle(e){let{gen:t,validateName:n}=e;e.evaluated=t.const("evaluated",(0,Pe._)`${n}.evaluated`),t.if((0,Pe._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,Pe._)`${e.evaluated}.props`,(0,Pe._)`undefined`)),t.if((0,Pe._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,Pe._)`${e.evaluated}.items`,(0,Pe._)`undefined`))}function n2(e,t){let n=typeof e=="object"&&e[t.schemaId];return n&&(t.code.source||t.code.process)?(0,Pe._)`/*# sourceURL=${n} */`:Pe.nil}function gle(e,t){if(c2(e)&&(l2(e),a2(e))){hle(e,t);return}(0,o2.boolOrEmptySchema)(e,t)}function a2({schema:e,self:t}){if(typeof e=="boolean")return!e;for(let n in e)if(t.RULES.all[n])return!0;return!1}function c2(e){return typeof e.schema!="boolean"}function hle(e,t){let{schema:n,gen:i,opts:r}=e;r.$comment&&n.$comment&&d2(e),wle(e),vle(e);let o=i.const("_errs",je.default.errors);u2(e,o),i.var(t,(0,Pe._)`${o} === ${je.default.errors}`)}function l2(e){(0,os.checkUnknownRules)(e),yle(e)}function u2(e,t){if(e.opts.jtd)return r2(e,[],!1,t);let n=(0,t2.getSchemaTypes)(e.schema),i=(0,t2.coerceAndCheckDataType)(e,n);r2(e,n,!i,t)}function yle(e){let{schema:t,errSchemaPath:n,opts:i,self:r}=e;t.$ref&&i.ignoreKeywordsWithRef&&(0,os.schemaHasRulesButRef)(t,r.RULES)&&r.logger.warn(`$ref: keywords ignored in schema at path "${n}"`)}function ble(e){let{schema:t,opts:n}=e;t.default!==void 0&&n.useDefaults&&n.strictSchema&&(0,os.checkStrictMode)(e,"default is ignored in the schema root")}function wle(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,lle.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function vle(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function d2({gen:e,schemaEnv:t,schema:n,errSchemaPath:i,opts:r}){let o=n.$comment;if(r.$comment===!0)e.code((0,Pe._)`${je.default.self}.logger.log(${o})`);else if(typeof r.$comment=="function"){let s=(0,Pe.str)`${i}/$comment`,a=e.scopeValue("root",{ref:t.root});e.code((0,Pe._)`${je.default.self}.opts.$comment(${o}, ${s}, ${a}.schema)`)}}function kle(e){let{gen:t,schemaEnv:n,validateName:i,ValidationError:r,opts:o}=e;n.$async?t.if((0,Pe._)`${je.default.errors} === 0`,()=>t.return(je.default.data),()=>t.throw((0,Pe._)`new ${r}(${je.default.vErrors})`)):(t.assign((0,Pe._)`${i}.errors`,je.default.vErrors),o.unevaluated&&xle(e),t.return((0,Pe._)`${je.default.errors} === 0`))}function xle({gen:e,evaluated:t,props:n,items:i}){n instanceof Pe.Name&&e.assign((0,Pe._)`${t}.props`,n),i instanceof Pe.Name&&e.assign((0,Pe._)`${t}.items`,i)}function r2(e,t,n,i){let{gen:r,schema:o,data:s,allErrors:a,opts:l,self:c}=e,{RULES:u}=c;if(o.$ref&&(l.ignoreKeywordsWithRef||!(0,os.schemaHasRulesButRef)(o,u))){r.block(()=>f2(e,"$ref",u.all.$ref.definition));return}l.jtd||$le(e,t),r.block(()=>{for(let p of u.rules)d(p);d(u.post)});function d(p){(0,qC.shouldUseGroup)(o,p)&&(p.type?(r.if((0,Ow.checkDataType)(p.type,s,l.strictNumbers)),i2(e,p),t.length===1&&t[0]===p.type&&n&&(r.else(),(0,Ow.reportTypeError)(e)),r.endIf()):i2(e,p),a||r.if((0,Pe._)`${je.default.errors} === ${i||0}`))}}function i2(e,t){let{gen:n,schema:i,opts:{useDefaults:r}}=e;r&&(0,cle.assignDefaults)(e,t.type),n.block(()=>{for(let o of t.rules)(0,qC.shouldUseRule)(i,o)&&f2(e,o.keyword,o.definition,t.type)})}function $le(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(Rle(e,t),e.opts.allowUnionTypes||Sle(e,t),Ele(e,e.dataTypes))}function Rle(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(n=>{p2(e.dataTypes,n)||KC(e,`type "${n}" not allowed by context "${e.dataTypes.join(",")}"`)}),Ple(e,t)}}function Sle(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&KC(e,"use allowUnionTypes to allow union type keyword")}function Ele(e,t){let n=e.self.RULES.all;for(let i in n){let r=n[i];if(typeof r=="object"&&(0,qC.shouldUseRule)(e.schema,r)){let{type:o}=r.definition;o.length&&!o.some(s=>Ale(t,s))&&KC(e,`missing type "${o.join(",")}" for keyword "${i}"`)}}}function Ale(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function p2(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function Ple(e,t){let n=[];for(let i of e.dataTypes)p2(t,i)?n.push(i):t.includes("integer")&&i==="number"&&n.push("integer");e.dataTypes=n}function KC(e,t){let n=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${n}" (strictTypes)`,(0,os.checkStrictMode)(e,t,e.opts.strictTypes)}var Cw=class{constructor(t,n,i){if((0,Qf.validateKeywordUsage)(t,n,i),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=i,this.data=t.data,this.schema=t.schema[i],this.$data=n.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,os.schemaRefOrVal)(t,this.schema,i,this.$data),this.schemaType=n.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=n,this.$data)this.schemaCode=t.gen.const("vSchema",m2(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,Qf.validSchemaType)(this.schema,n.schemaType,n.allowUndefined))throw new Error(`${i} value must be ${JSON.stringify(n.schemaType)}`);("code"in n?n.trackErrors:n.errors!==!1)&&(this.errsCount=t.gen.const("_errs",je.default.errors))}result(t,n,i){this.failResult((0,Pe.not)(t),n,i)}failResult(t,n,i){this.gen.if(t),i?i():this.error(),n?(this.gen.else(),n(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,n){this.failResult((0,Pe.not)(t),void 0,n)}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);let{schemaCode:n}=this;this.fail((0,Pe._)`${n} !== undefined && (${(0,Pe.or)(this.invalid$data(),t)})`)}error(t,n,i){if(n){this.setParams(n),this._error(t,i),this.setParams({});return}this._error(t,i)}_error(t,n){(t?Xf.reportExtraError:Xf.reportError)(this,this.def.error,n)}$dataError(){(0,Xf.reportError)(this,this.def.$dataError||Xf.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Xf.resetErrorsCount)(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,n){n?Object.assign(this.params,t):this.params=t}block$data(t,n,i=Pe.nil){this.gen.block(()=>{this.check$data(t,i),n()})}check$data(t=Pe.nil,n=Pe.nil){if(!this.$data)return;let{gen:i,schemaCode:r,schemaType:o,def:s}=this;i.if((0,Pe.or)((0,Pe._)`${r} === undefined`,n)),t!==Pe.nil&&i.assign(t,!0),(o.length||s.validateSchema)&&(i.elseIf(this.invalid$data()),this.$dataError(),t!==Pe.nil&&i.assign(t,!1)),i.else()}invalid$data(){let{gen:t,schemaCode:n,schemaType:i,def:r,it:o}=this;return(0,Pe.or)(s(),a());function s(){if(i.length){if(!(n instanceof Pe.Name))throw new Error("ajv implementation error");let l=Array.isArray(i)?i:[i];return(0,Pe._)`${(0,Ow.checkDataTypes)(l,n,o.opts.strictNumbers,Ow.DataType.Wrong)}`}return Pe.nil}function a(){if(r.validateSchema){let l=t.scopeValue("validate$data",{ref:r.validateSchema});return(0,Pe._)`!${l}(${n})`}return Pe.nil}}subschema(t,n){let i=(0,VC.getSubschema)(this.it,t);(0,VC.extendSubschemaData)(i,this.it,t),(0,VC.extendSubschemaMode)(i,t);let r={...this.it,...i,items:void 0,props:void 0};return gle(r,n),r}mergeEvaluated(t,n){let{it:i,gen:r}=this;i.opts.unevaluated&&(i.props!==!0&&t.props!==void 0&&(i.props=os.mergeEvaluated.props(r,t.props,i.props,n)),i.items!==!0&&t.items!==void 0&&(i.items=os.mergeEvaluated.items(r,t.items,i.items,n)))}mergeValidEvaluated(t,n){let{it:i,gen:r}=this;if(i.opts.unevaluated&&(i.props!==!0||i.items!==!0))return r.if(n,()=>this.mergeEvaluated(t,Pe.Name)),!0}};ua.KeywordCxt=Cw;function f2(e,t,n,i){let r=new Cw(e,n,t);"code"in n?n.code(r,i):r.$data&&n.validate?(0,Qf.funcKeywordCode)(r,n):"macro"in n?(0,Qf.macroKeywordCode)(r,n):(n.compile||n.validate)&&(0,Qf.funcKeywordCode)(r,n)}var Ole=/^\/(?:[^~]|~0|~1)*$/,Cle=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function m2(e,{dataLevel:t,dataNames:n,dataPathArr:i}){let r,o;if(e==="")return je.default.rootData;if(e[0]==="/"){if(!Ole.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);r=e,o=je.default.rootData}else{let c=Cle.exec(e);if(!c)throw new Error(`Invalid JSON-pointer: ${e}`);let u=+c[1];if(r=c[2],r==="#"){if(u>=t)throw new Error(l("property/index",u));return i[t-u]}if(u>t)throw new Error(l("data",u));if(o=n[t-u],!r)return o}let s=o,a=r.split("/");for(let c of a)c&&(o=(0,Pe._)`${o}${(0,Pe.getProperty)((0,os.unescapeJsonPointer)(c))}`,s=(0,Pe._)`${s} && ${o}`);return s;function l(c,u){return`Cannot access ${c} ${u} levels up, current level is ${t}`}}ua.getData=m2});var em=ie(ZC=>{"use strict";Object.defineProperty(ZC,"__esModule",{value:!0});var JC=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};ZC.default=JC});var Hu=ie(QC=>{"use strict";Object.defineProperty(QC,"__esModule",{value:!0});var YC=Yf(),XC=class extends Error{constructor(t,n,i,r){super(r||`can't resolve reference ${i} from id ${n}`),this.missingRef=(0,YC.resolveUrl)(t,n,i),this.missingSchema=(0,YC.normalizeId)((0,YC.getFullPath)(t,this.missingRef))}};QC.default=XC});var tm=ie(ni=>{"use strict";Object.defineProperty(ni,"__esModule",{value:!0});ni.resolveSchema=ni.getCompilingSchema=ni.resolveRef=ni.compileSchema=ni.SchemaEnv=void 0;var Ii=Fe(),_le=em(),Ic=ei(),Ti=Yf(),g2=Xe(),Ile=Uu(),Vu=class{constructor(t){var n;this.refs={},this.dynamicAnchors={};let i;typeof t.schema=="object"&&(i=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(n=t.baseId)!==null&&n!==void 0?n:(0,Ti.normalizeId)(i?.[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=i?.$async,this.refs={}}};ni.SchemaEnv=Vu;function t_(e){let t=h2.call(this,e);if(t)return t;let n=(0,Ti.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:i,lines:r}=this.opts.code,{ownProperties:o}=this.opts,s=new Ii.CodeGen(this.scope,{es5:i,lines:r,ownProperties:o}),a;e.$async&&(a=s.scopeValue("Error",{ref:_le.default,code:(0,Ii._)`require("ajv/dist/runtime/validation_error").default`}));let l=s.scopeName("validate");e.validateName=l;let c={gen:s,allErrors:this.opts.allErrors,data:Ic.default.data,parentData:Ic.default.parentData,parentDataProperty:Ic.default.parentDataProperty,dataNames:[Ic.default.data],dataPathArr:[Ii.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:s.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,Ii.stringify)(e.schema)}:{ref:e.schema}),validateName:l,ValidationError:a,schema:e.schema,schemaEnv:e,rootId:n,baseId:e.baseId||n,schemaPath:Ii.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,Ii._)`""`,opts:this.opts,self:this},u;try{this._compilations.add(e),(0,Ile.validateFunctionCode)(c),s.optimize(this.opts.code.optimize);let d=s.toString();u=`${s.scopeRefs(Ic.default.scope)}return ${d}`,this.opts.code.process&&(u=this.opts.code.process(u,e));let f=new Function(`${Ic.default.self}`,`${Ic.default.scope}`,u)(this,this.scope.get());if(this.scope.value(l,{ref:f}),f.errors=null,f.schema=e.schema,f.schemaEnv=e,e.$async&&(f.$async=!0),this.opts.code.source===!0&&(f.source={validateName:l,validateCode:d,scopeValues:s._values}),this.opts.unevaluated){let{props:g,items:h}=c;f.evaluated={props:g instanceof Ii.Name?void 0:g,items:h instanceof Ii.Name?void 0:h,dynamicProps:g instanceof Ii.Name,dynamicItems:h instanceof Ii.Name},f.source&&(f.source.evaluated=(0,Ii.stringify)(f.evaluated))}return e.validate=f,e}catch(d){throw delete e.validate,delete e.validateName,u&&this.logger.error("Error compiling schema, function code:",u),d}finally{this._compilations.delete(e)}}ni.compileSchema=t_;function Tle(e,t,n){var i;n=(0,Ti.resolveUrl)(this.opts.uriResolver,t,n);let r=e.refs[n];if(r)return r;let o=jle.call(this,e,n);if(o===void 0){let s=(i=e.localRefs)===null||i===void 0?void 0:i[n],{schemaId:a}=this.opts;s&&(o=new Vu({schema:s,schemaId:a,root:e,baseId:t}))}if(o!==void 0)return e.refs[n]=Dle.call(this,o)}ni.resolveRef=Tle;function Dle(e){return(0,Ti.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:t_.call(this,e)}function h2(e){for(let t of this._compilations)if(Nle(t,e))return t}ni.getCompilingSchema=h2;function Nle(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function jle(e,t){let n;for(;typeof(n=this.refs[t])=="string";)t=n;return n||this.schemas[t]||_w.call(this,e,t)}function _w(e,t){let n=this.opts.uriResolver.parse(t),i=(0,Ti._getFullPath)(this.opts.uriResolver,n),r=(0,Ti.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&i===r)return e_.call(this,n,e);let o=(0,Ti.normalizeId)(i),s=this.refs[o]||this.schemas[o];if(typeof s=="string"){let a=_w.call(this,e,s);return typeof a?.schema!="object"?void 0:e_.call(this,n,a)}if(typeof s?.schema=="object"){if(s.validate||t_.call(this,s),o===(0,Ti.normalizeId)(t)){let{schema:a}=s,{schemaId:l}=this.opts,c=a[l];return c&&(r=(0,Ti.resolveUrl)(this.opts.uriResolver,r,c)),new Vu({schema:a,schemaId:l,root:e,baseId:r})}return e_.call(this,n,s)}}ni.resolveSchema=_w;var Lle=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function e_(e,{baseId:t,schema:n,root:i}){var r;if(((r=e.fragment)===null||r===void 0?void 0:r[0])!=="/")return;for(let a of e.fragment.slice(1).split("/")){if(typeof n=="boolean")return;let l=n[(0,g2.unescapeFragment)(a)];if(l===void 0)return;n=l;let c=typeof n=="object"&&n[this.opts.schemaId];!Lle.has(a)&&c&&(t=(0,Ti.resolveUrl)(this.opts.uriResolver,t,c))}let o;if(typeof n!="boolean"&&n.$ref&&!(0,g2.schemaHasRulesButRef)(n,this.RULES)){let a=(0,Ti.resolveUrl)(this.opts.uriResolver,t,n.$ref);o=_w.call(this,i,a)}let{schemaId:s}=this.opts;if(o=o||new Vu({schema:n,schemaId:s,root:i,baseId:t}),o.schema!==o.root.schema)return o}});var y2=ie((dFe,Mle)=>{Mle.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var i_=ie((pFe,$2)=>{"use strict";var Fle=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),w2=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),n_=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),v2=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),Ble=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function r_(e){let t="",n=0,i=0;for(i=0;i<e.length;i++)if(n=e[i].charCodeAt(0),n!==48){if(!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return"";t+=e[i];break}for(i+=1;i<e.length;i++){if(n=e[i].charCodeAt(0),!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return"";t+=e[i]}return t}var Gle=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function b2(e){return e.length=0,!0}function Wle(e,t,n){if(e.length){let i=r_(e);if(i!=="")t.push(i);else return n.error=!0,!1;e.length=0}return!0}function zle(e){let t=0,n={error:!1,address:"",zone:""},i=[],r=[],o=!1,s=!1,a=Wle;for(let l=0;l<e.length;l++){let c=e[l];if(!(c==="["||c==="]"))if(c===":"){if(o===!0&&(s=!0),!a(r,i,n))break;if(++t>7){n.error=!0;break}l>0&&e[l-1]===":"&&(o=!0),i.push(":");continue}else if(c==="%"){if(!a(r,i,n))break;a=b2}else{r.push(c);continue}}return r.length&&(a===b2?n.zone=r.join(""):s?i.push(r.join("")):i.push(r_(r))),n.address=i.join(""),n}function k2(e){if(Ule(e,":")<2)return{host:e,isIPV6:!1};let t=zle(e);if(t.error)return{host:e,isIPV6:!1};{let n=t.address,i=t.address;return t.zone&&(n+="%"+t.zone,i+="%25"+t.zone),{host:n,isIPV6:!0,escapedHost:i}}}function Ule(e,t){let n=0;for(let i=0;i<e.length;i++)e[i]===t&&n++;return n}function Hle(e){let t=e,n=[],i=-1,r=0;for(;r=t.length;){if(r===1){if(t===".")break;if(t==="/"){n.push("/");break}else{n.push(t);break}}else if(r===2){if(t[0]==="."){if(t[1]===".")break;if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&(t[1]==="."||t[1]==="/")){n.push("/");break}}else if(r===3&&t==="/.."){n.length!==0&&n.pop(),n.push("/");break}if(t[0]==="."){if(t[1]==="."){if(t[2]==="/"){t=t.slice(3);continue}}else if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&t[1]==="."){if(t[2]==="/"){t=t.slice(2);continue}else if(t[2]==="."&&t[3]==="/"){t=t.slice(3),n.length!==0&&n.pop();continue}}if((i=t.indexOf("/",1))===-1){n.push(t);break}else n.push(t.slice(0,i)),t=t.slice(i)}return n.join("")}var Vle={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},qle=/[@/?#:]/g,Kle=/[@/?#]/g;function x2(e,t){let n=t?Kle:qle;return n.lastIndex=0,e.replace(n,i=>Vle[i])}function Jle(e,t=!1){if(e.indexOf("%")===-1)return e;let n="";for(let i=0;i<e.length;i++){if(e[i]==="%"&&i+2<e.length){let r=e.slice(i+1,i+3);if(n_(r)){let o=r.toUpperCase(),s=String.fromCharCode(parseInt(o,16));t&&v2(s)?n+=s:n+="%"+o,i+=2;continue}}n+=e[i]}return n}function Zle(e){let t="";for(let n=0;n<e.length;n++){if(e[n]==="%"&&n+2<e.length){let i=e.slice(n+1,n+3);if(n_(i)){let r=i.toUpperCase(),o=String.fromCharCode(parseInt(r,16));o!=="."&&v2(o)?t+=o:t+="%"+r,n+=2;continue}}Ble(e[n])?t+=e[n]:t+=escape(e[n])}return t}function Yle(e){let t="";for(let n=0;n<e.length;n++){if(e[n]==="%"&&n+2<e.length){let i=e.slice(n+1,n+3);if(n_(i)){t+="%"+i.toUpperCase(),n+=2;continue}}t+=escape(e[n])}return t}function Xle(e){let t=[];if(e.userinfo!==void 0&&(t.push(e.userinfo),t.push("@")),e.host!==void 0){let n=unescape(e.host);if(!w2(n)){let i=k2(n);i.isIPV6===!0?n=`[${i.escapedHost}]`:n=x2(n,!1)}t.push(n)}return(typeof e.port=="number"||typeof e.port=="string")&&(t.push(":"),t.push(String(e.port))),t.length?t.join(""):void 0}$2.exports={nonSimpleDomain:Gle,recomposeAuthority:Xle,reescapeHostDelimiters:x2,normalizePercentEncoding:Jle,normalizePathEncoding:Zle,escapePreservingEscapes:Yle,removeDotSegments:Hle,isIPv4:w2,isUUID:Fle,normalizeIPv6:k2,stringArrayToHexStripped:r_}});var P2=ie((fFe,A2)=>{"use strict";var{isUUID:Qle}=i_(),eue=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,tue=["http","https","ws","wss","urn","urn:uuid"];function nue(e){return tue.indexOf(e)!==-1}function o_(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]==="w"||e.scheme[0]==="W")&&(e.scheme[1]==="s"||e.scheme[1]==="S")&&(e.scheme[2]==="s"||e.scheme[2]==="S"):!1}function R2(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function S2(e){let t=String(e.scheme).toLowerCase()==="https";return(e.port===(t?443:80)||e.port==="")&&(e.port=void 0),e.path||(e.path="/"),e}function rue(e){return e.secure=o_(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function iue(e){if((e.port===(o_(e)?443:80)||e.port==="")&&(e.port=void 0),typeof e.secure=="boolean"&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){let[t,n]=e.resourceName.split("?");e.path=t&&t!=="/"?t:void 0,e.query=n,e.resourceName=void 0}return e.fragment=void 0,e}function oue(e,t){if(!e.path)return e.error="URN can not be parsed",e;let n=e.path.match(eue);if(n){let i=t.scheme||e.scheme||"urn";e.nid=n[1].toLowerCase(),e.nss=n[2];let r=`${i}:${t.nid||e.nid}`,o=s_(r);e.path=void 0,o&&(e=o.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e}function sue(e,t){if(e.nid===void 0)throw new Error("URN without nid cannot be serialized");let n=t.scheme||e.scheme||"urn",i=e.nid.toLowerCase(),r=`${n}:${t.nid||i}`,o=s_(r);o&&(e=o.serialize(e,t));let s=e,a=e.nss;return s.path=`${i||t.nid}:${a}`,t.skipEscape=!0,s}function aue(e,t){let n=e;return n.uuid=n.nss,n.nss=void 0,!t.tolerant&&(!n.uuid||!Qle(n.uuid))&&(n.error=n.error||"UUID is not valid."),n}function cue(e){let t=e;return t.nss=(e.uuid||"").toLowerCase(),t}var E2={scheme:"http",domainHost:!0,parse:R2,serialize:S2},lue={scheme:"https",domainHost:E2.domainHost,parse:R2,serialize:S2},Iw={scheme:"ws",domainHost:!0,parse:rue,serialize:iue},uue={scheme:"wss",domainHost:Iw.domainHost,parse:Iw.parse,serialize:Iw.serialize},due={scheme:"urn",parse:oue,serialize:sue,skipNormalize:!0},pue={scheme:"urn:uuid",parse:aue,serialize:cue,skipNormalize:!0},Tw={http:E2,https:lue,ws:Iw,wss:uue,urn:due,"urn:uuid":pue};Object.setPrototypeOf(Tw,null);function s_(e){return e&&(Tw[e]||Tw[e.toLowerCase()])||void 0}A2.exports={wsIsSecure:o_,SCHEMES:Tw,isValidSchemeName:nue,getSchemeHandler:s_}});var D2=ie((mFe,Dw)=>{"use strict";var{normalizeIPv6:fue,removeDotSegments:nm,recomposeAuthority:mue,normalizePercentEncoding:gue,normalizePathEncoding:hue,escapePreservingEscapes:yue,reescapeHostDelimiters:bue,isIPv4:wue,nonSimpleDomain:vue}=i_(),{SCHEMES:kue,getSchemeHandler:C2}=P2();function xue(e,t){return typeof e=="string"?e=Aue(e,t):typeof e=="object"&&(e=qu(Tc(e,t),t)),e}function $ue(e,t,n){let i=n?Object.assign({scheme:"null"},n):{scheme:"null"},r=_2(qu(e,i),qu(t,i),i,!0);return i.skipEscape=!0,Tc(r,i)}function _2(e,t,n,i){let r={};return i||(e=qu(Tc(e,n),n),t=qu(Tc(t,n),n)),n=n||{},!n.tolerant&&t.scheme?(r.scheme=t.scheme,r.userinfo=t.userinfo,r.host=t.host,r.port=t.port,r.path=nm(t.path||""),r.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(r.userinfo=t.userinfo,r.host=t.host,r.port=t.port,r.path=nm(t.path||""),r.query=t.query):(t.path?(t.path[0]==="/"?r.path=nm(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?r.path="/"+t.path:e.path?r.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:r.path=t.path,r.path=nm(r.path)),r.query=t.query):(r.path=e.path,t.query!==void 0?r.query=t.query:r.query=e.query),r.userinfo=e.userinfo,r.host=e.host,r.port=e.port),r.scheme=e.scheme),r.fragment=t.fragment,r}function Rue(e,t,n){let i=O2(e,n),r=O2(t,n);return i!==void 0&&r!==void 0&&i.toLowerCase()===r.toLowerCase()}function Tc(e,t){let n={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},i=Object.assign({},t),r=[],o=C2(i.scheme||n.scheme);o&&o.serialize&&o.serialize(n,i),n.path!==void 0&&(i.skipEscape?n.path=gue(n.path):(n.path=yue(n.path),n.scheme!==void 0&&(n.path=n.path.split("%3A").join(":")))),i.reference!=="suffix"&&n.scheme&&r.push(n.scheme,":");let s=mue(n);if(s!==void 0&&(i.reference!=="suffix"&&r.push("//"),r.push(s),n.path&&n.path[0]!=="/"&&r.push("/")),n.path!==void 0){let a=n.path;!i.absolutePath&&(!o||!o.absolutePath)&&(a=nm(a)),s===void 0&&a[0]==="/"&&a[1]==="/"&&(a="/%2F"+a.slice(2)),r.push(a)}return n.query!==void 0&&r.push("?",n.query),n.fragment!==void 0&&r.push("#",n.fragment),r.join("")}var Sue=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function Eue(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof e.port=="number"&&(e.port<0||e.port>65535))return"URI port is malformed."}function I2(e,t){let n=Object.assign({},t),i={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},r=!1,o=!1;n.reference==="suffix"&&(n.scheme?e=n.scheme+":"+e:e="//"+e);let s=e.match(Sue);if(s){i.scheme=s[1],i.userinfo=s[3],i.host=s[4],i.port=parseInt(s[5],10),i.path=s[6]||"",i.query=s[7],i.fragment=s[8],isNaN(i.port)&&(i.port=s[5]);let a=Eue(i,s);if(a!==void 0&&(i.error=i.error||a,r=!0),i.host)if(wue(i.host)===!1){let u=fue(i.host);i.host=u.host.toLowerCase(),o=u.isIPV6}else o=!0;i.scheme===void 0&&i.userinfo===void 0&&i.host===void 0&&i.port===void 0&&i.query===void 0&&!i.path?i.reference="same-document":i.scheme===void 0?i.reference="relative":i.fragment===void 0?i.reference="absolute":i.reference="uri",n.reference&&n.reference!=="suffix"&&n.reference!==i.reference&&(i.error=i.error||"URI is not a "+n.reference+" reference.");let l=C2(n.scheme||i.scheme);if(!n.unicodeSupport&&(!l||!l.unicodeSupport)&&i.host&&(n.domainHost||l&&l.domainHost)&&o===!1&&vue(i.host))try{i.host=URL.domainToASCII(i.host.toLowerCase())}catch(c){i.error=i.error||"Host's domain name can not be converted to ASCII: "+c}if((!l||l&&!l.skipNormalize)&&(e.indexOf("%")!==-1&&(i.scheme!==void 0&&(i.scheme=unescape(i.scheme)),i.host!==void 0&&(i.host=bue(unescape(i.host),o))),i.path&&(i.path=hue(i.path)),i.fragment))try{i.fragment=encodeURI(decodeURIComponent(i.fragment))}catch{i.error=i.error||"URI malformed"}l&&l.parse&&l.parse(i,n)}else i.error=i.error||"URI can not be parsed.";return{parsed:i,malformedAuthorityOrPort:r}}function qu(e,t){return I2(e,t).parsed}function Aue(e,t){return T2(e,t).normalized}function T2(e,t){let{parsed:n,malformedAuthorityOrPort:i}=I2(e,t);return{normalized:i?e:Tc(n,t),malformedAuthorityOrPort:i}}function O2(e,t){if(typeof e=="string"){let{normalized:n,malformedAuthorityOrPort:i}=T2(e,t);return i?void 0:n}if(typeof e=="object")return Tc(e,t)}var a_={SCHEMES:kue,normalize:xue,resolve:$ue,resolveComponent:_2,equal:Rue,serialize:Tc,parse:qu};Dw.exports=a_;Dw.exports.default=a_;Dw.exports.fastUri=a_});var j2=ie(c_=>{"use strict";Object.defineProperty(c_,"__esModule",{value:!0});var N2=D2();N2.code='require("ajv/dist/runtime/uri").default';c_.default=N2});var d_=ie(Sn=>{"use strict";Object.defineProperty(Sn,"__esModule",{value:!0});Sn.CodeGen=Sn.Name=Sn.nil=Sn.stringify=Sn.str=Sn._=Sn.KeywordCxt=void 0;var Pue=Uu();Object.defineProperty(Sn,"KeywordCxt",{enumerable:!0,get:function(){return Pue.KeywordCxt}});var Ku=Fe();Object.defineProperty(Sn,"_",{enumerable:!0,get:function(){return Ku._}});Object.defineProperty(Sn,"str",{enumerable:!0,get:function(){return Ku.str}});Object.defineProperty(Sn,"stringify",{enumerable:!0,get:function(){return Ku.stringify}});Object.defineProperty(Sn,"nil",{enumerable:!0,get:function(){return Ku.nil}});Object.defineProperty(Sn,"Name",{enumerable:!0,get:function(){return Ku.Name}});Object.defineProperty(Sn,"CodeGen",{enumerable:!0,get:function(){return Ku.CodeGen}});var Oue=em(),G2=Hu(),Cue=jC(),rm=tm(),_ue=Fe(),im=Yf(),Nw=Zf(),u_=Xe(),L2=y2(),Iue=j2(),W2=(e,t)=>new RegExp(e,t);W2.code="new RegExp";var Tue=["removeAdditional","useDefaults","coerceTypes"],Due=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),Nue={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},jue={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},M2=200;function Lue(e){var t,n,i,r,o,s,a,l,c,u,d,p,f,g,h,b,w,x,k,R,$,_,T,C,K;let O=e.strict,pe=(t=e.code)===null||t===void 0?void 0:t.optimize,F=pe===!0||pe===void 0?1:pe||0,Q=(i=(n=e.code)===null||n===void 0?void 0:n.regExp)!==null&&i!==void 0?i:W2,I=(r=e.uriResolver)!==null&&r!==void 0?r:Iue.default;return{strictSchema:(s=(o=e.strictSchema)!==null&&o!==void 0?o:O)!==null&&s!==void 0?s:!0,strictNumbers:(l=(a=e.strictNumbers)!==null&&a!==void 0?a:O)!==null&&l!==void 0?l:!0,strictTypes:(u=(c=e.strictTypes)!==null&&c!==void 0?c:O)!==null&&u!==void 0?u:"log",strictTuples:(p=(d=e.strictTuples)!==null&&d!==void 0?d:O)!==null&&p!==void 0?p:"log",strictRequired:(g=(f=e.strictRequired)!==null&&f!==void 0?f:O)!==null&&g!==void 0?g:!1,code:e.code?{...e.code,optimize:F,regExp:Q}:{optimize:F,regExp:Q},loopRequired:(h=e.loopRequired)!==null&&h!==void 0?h:M2,loopEnum:(b=e.loopEnum)!==null&&b!==void 0?b:M2,meta:(w=e.meta)!==null&&w!==void 0?w:!0,messages:(x=e.messages)!==null&&x!==void 0?x:!0,inlineRefs:(k=e.inlineRefs)!==null&&k!==void 0?k:!0,schemaId:(R=e.schemaId)!==null&&R!==void 0?R:"$id",addUsedSchema:($=e.addUsedSchema)!==null&&$!==void 0?$:!0,validateSchema:(_=e.validateSchema)!==null&&_!==void 0?_:!0,validateFormats:(T=e.validateFormats)!==null&&T!==void 0?T:!0,unicodeRegExp:(C=e.unicodeRegExp)!==null&&C!==void 0?C:!0,int32range:(K=e.int32range)!==null&&K!==void 0?K:!0,uriResolver:I}}var om=class{constructor(t={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,...Lue(t)};let{es5:n,lines:i}=this.opts.code;this.scope=new _ue.ValueScope({scope:{},prefixes:Due,es5:n,lines:i}),this.logger=zue(t.logger);let r=t.validateFormats;t.validateFormats=!1,this.RULES=(0,Cue.getRules)(),F2.call(this,Nue,t,"NOT SUPPORTED"),F2.call(this,jue,t,"DEPRECATED","warn"),this._metaOpts=Gue.call(this),t.formats&&Fue.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&Bue.call(this,t.keywords),typeof t.meta=="object"&&this.addMetaSchema(t.meta),Mue.call(this),t.validateFormats=r}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:t,meta:n,schemaId:i}=this.opts,r=L2;i==="id"&&(r={...L2},r.id=r.$id,delete r.$id),n&&t&&this.addMetaSchema(r,r[i],!1)}defaultMeta(){let{meta:t,schemaId:n}=this.opts;return this.opts.defaultMeta=typeof t=="object"?t[n]||t:void 0}validate(t,n){let i;if(typeof t=="string"){if(i=this.getSchema(t),!i)throw new Error(`no schema with key or ref "${t}"`)}else i=this.compile(t);let r=i(n);return"$async"in i||(this.errors=i.errors),r}compile(t,n){let i=this._addSchema(t,n);return i.validate||this._compileSchemaEnv(i)}compileAsync(t,n){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:i}=this.opts;return r.call(this,t,n);async function r(u,d){await o.call(this,u.$schema);let p=this._addSchema(u,d);return p.validate||s.call(this,p)}async function o(u){u&&!this.getSchema(u)&&await r.call(this,{$ref:u},!0)}async function s(u){try{return this._compileSchemaEnv(u)}catch(d){if(!(d instanceof G2.default))throw d;return a.call(this,d),await l.call(this,d.missingSchema),s.call(this,u)}}function a({missingSchema:u,missingRef:d}){if(this.refs[u])throw new Error(`AnySchema ${u} is loaded but ${d} cannot be resolved`)}async function l(u){let d=await c.call(this,u);this.refs[u]||await o.call(this,d.$schema),this.refs[u]||this.addSchema(d,u,n)}async function c(u){let d=this._loading[u];if(d)return d;try{return await(this._loading[u]=i(u))}finally{delete this._loading[u]}}}addSchema(t,n,i,r=this.opts.validateSchema){if(Array.isArray(t)){for(let s of t)this.addSchema(s,void 0,i,r);return this}let o;if(typeof t=="object"){let{schemaId:s}=this.opts;if(o=t[s],o!==void 0&&typeof o!="string")throw new Error(`schema ${s} must be string`)}return n=(0,im.normalizeId)(n||o),this._checkUnique(n),this.schemas[n]=this._addSchema(t,i,n,r,!0),this}addMetaSchema(t,n,i=this.opts.validateSchema){return this.addSchema(t,n,!0,i),this}validateSchema(t,n){if(typeof t=="boolean")return!0;let i;if(i=t.$schema,i!==void 0&&typeof i!="string")throw new Error("$schema must be a string");if(i=i||this.opts.defaultMeta||this.defaultMeta(),!i)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let r=this.validate(i,t);if(!r&&n){let o="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(o);else throw new Error(o)}return r}getSchema(t){let n;for(;typeof(n=B2.call(this,t))=="string";)t=n;if(n===void 0){let{schemaId:i}=this.opts,r=new rm.SchemaEnv({schema:{},schemaId:i});if(n=rm.resolveSchema.call(this,r,t),!n)return;this.refs[t]=n}return n.validate||this._compileSchemaEnv(n)}removeSchema(t){if(t instanceof RegExp)return this._removeAllSchemas(this.schemas,t),this._removeAllSchemas(this.refs,t),this;switch(typeof t){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let n=B2.call(this,t);return typeof n=="object"&&this._cache.delete(n.schema),delete this.schemas[t],delete this.refs[t],this}case"object":{let n=t;this._cache.delete(n);let i=t[this.opts.schemaId];return i&&(i=(0,im.normalizeId)(i),delete this.schemas[i],delete this.refs[i]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(t){for(let n of t)this.addKeyword(n);return this}addKeyword(t,n){let i;if(typeof t=="string")i=t,typeof n=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),n.keyword=i);else if(typeof t=="object"&&n===void 0){if(n=t,i=n.keyword,Array.isArray(i)&&!i.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(Hue.call(this,i,n),!n)return(0,u_.eachItem)(i,o=>l_.call(this,o)),this;que.call(this,n);let r={...n,type:(0,Nw.getJSONTypes)(n.type),schemaType:(0,Nw.getJSONTypes)(n.schemaType)};return(0,u_.eachItem)(i,r.type.length===0?o=>l_.call(this,o,r):o=>r.type.forEach(s=>l_.call(this,o,r,s))),this}getKeyword(t){let n=this.RULES.all[t];return typeof n=="object"?n.definition:!!n}removeKeyword(t){let{RULES:n}=this;delete n.keywords[t],delete n.all[t];for(let i of n.rules){let r=i.rules.findIndex(o=>o.keyword===t);r>=0&&i.rules.splice(r,1)}return this}addFormat(t,n){return typeof n=="string"&&(n=new RegExp(n)),this.formats[t]=n,this}errorsText(t=this.errors,{separator:n=", ",dataVar:i="data"}={}){return!t||t.length===0?"No errors":t.map(r=>`${i}${r.instancePath} ${r.message}`).reduce((r,o)=>r+n+o)}$dataMetaSchema(t,n){let i=this.RULES.all;t=JSON.parse(JSON.stringify(t));for(let r of n){let o=r.split("/").slice(1),s=t;for(let a of o)s=s[a];for(let a in i){let l=i[a];if(typeof l!="object")continue;let{$data:c}=l.definition,u=s[a];c&&u&&(s[a]=z2(u))}}return t}_removeAllSchemas(t,n){for(let i in t){let r=t[i];(!n||n.test(i))&&(typeof r=="string"?delete t[i]:r&&!r.meta&&(this._cache.delete(r.schema),delete t[i]))}}_addSchema(t,n,i,r=this.opts.validateSchema,o=this.opts.addUsedSchema){let s,{schemaId:a}=this.opts;if(typeof t=="object")s=t[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof t!="boolean")throw new Error("schema must be object or boolean")}let l=this._cache.get(t);if(l!==void 0)return l;i=(0,im.normalizeId)(s||i);let c=im.getSchemaRefs.call(this,t,i);return l=new rm.SchemaEnv({schema:t,schemaId:a,meta:n,baseId:i,localRefs:c}),this._cache.set(l.schema,l),o&&!i.startsWith("#")&&(i&&this._checkUnique(i),this.refs[i]=l),r&&this.validateSchema(t,!0),l}_checkUnique(t){if(this.schemas[t]||this.refs[t])throw new Error(`schema with key or id "${t}" already exists`)}_compileSchemaEnv(t){if(t.meta?this._compileMetaSchema(t):rm.compileSchema.call(this,t),!t.validate)throw new Error("ajv implementation error");return t.validate}_compileMetaSchema(t){let n=this.opts;this.opts=this._metaOpts;try{rm.compileSchema.call(this,t)}finally{this.opts=n}}};om.ValidationError=Oue.default;om.MissingRefError=G2.default;Sn.default=om;function F2(e,t,n,i="error"){for(let r in e){let o=r;o in t&&this.logger[i](`${n}: option ${r}. ${e[o]}`)}}function B2(e){return e=(0,im.normalizeId)(e),this.schemas[e]||this.refs[e]}function Mue(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}function Fue(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function Bue(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let t in e){let n=e[t];n.keyword||(n.keyword=t),this.addKeyword(n)}}function Gue(){let e={...this.opts};for(let t of Tue)delete e[t];return e}var Wue={log(){},warn(){},error(){}};function zue(e){if(e===!1)return Wue;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}var Uue=/^[a-z_$][a-z0-9_$:-]*$/i;function Hue(e,t){let{RULES:n}=this;if((0,u_.eachItem)(e,i=>{if(n.keywords[i])throw new Error(`Keyword ${i} is already defined`);if(!Uue.test(i))throw new Error(`Keyword ${i} has invalid name`)}),!!t&&t.$data&&!("code"in t||"validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function l_(e,t,n){var i;let r=t?.post;if(n&&r)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:o}=this,s=r?o.post:o.rules.find(({type:l})=>l===n);if(s||(s={type:n,rules:[]},o.rules.push(s)),o.keywords[e]=!0,!t)return;let a={keyword:e,definition:{...t,type:(0,Nw.getJSONTypes)(t.type),schemaType:(0,Nw.getJSONTypes)(t.schemaType)}};t.before?Vue.call(this,s,a,t.before):s.rules.push(a),o.all[e]=a,(i=t.implements)===null||i===void 0||i.forEach(l=>this.addKeyword(l))}function Vue(e,t,n){let i=e.rules.findIndex(r=>r.keyword===n);i>=0?e.rules.splice(i,0,t):(e.rules.push(t),this.logger.warn(`rule ${n} is not defined`))}function que(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=z2(t)),e.validateSchema=this.compile(t,!0))}var Kue={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function z2(e){return{anyOf:[e,Kue]}}});var U2=ie(p_=>{"use strict";Object.defineProperty(p_,"__esModule",{value:!0});var Jue={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};p_.default=Jue});var Mw=ie(Dc=>{"use strict";Object.defineProperty(Dc,"__esModule",{value:!0});Dc.callRef=Dc.getValidate=void 0;var Zue=Hu(),H2=ti(),kr=Fe(),Ju=ei(),V2=tm(),jw=Xe(),Yue={keyword:"$ref",schemaType:"string",code(e){let{gen:t,schema:n,it:i}=e,{baseId:r,schemaEnv:o,validateName:s,opts:a,self:l}=i,{root:c}=o;if((n==="#"||n==="#/")&&r===c.baseId)return d();let u=V2.resolveRef.call(l,c,r,n);if(u===void 0)throw new Zue.default(i.opts.uriResolver,r,n);if(u instanceof V2.SchemaEnv)return p(u);return f(u);function d(){if(o===c)return Lw(e,s,o,o.$async);let g=t.scopeValue("root",{ref:c});return Lw(e,(0,kr._)`${g}.validate`,c,c.$async)}function p(g){let h=q2(e,g);Lw(e,h,g,g.$async)}function f(g){let h=t.scopeValue("schema",a.code.source===!0?{ref:g,code:(0,kr.stringify)(g)}:{ref:g}),b=t.name("valid"),w=e.subschema({schema:g,dataTypes:[],schemaPath:kr.nil,topSchemaRef:h,errSchemaPath:n},b);e.mergeEvaluated(w),e.ok(b)}}};function q2(e,t){let{gen:n}=e;return t.validate?n.scopeValue("validate",{ref:t.validate}):(0,kr._)`${n.scopeValue("wrapper",{ref:t})}.validate`}Dc.getValidate=q2;function Lw(e,t,n,i){let{gen:r,it:o}=e,{allErrors:s,schemaEnv:a,opts:l}=o,c=l.passContext?Ju.default.this:kr.nil;i?u():d();function u(){if(!a.$async)throw new Error("async schema referenced by sync schema");let g=r.let("valid");r.try(()=>{r.code((0,kr._)`await ${(0,H2.callValidateCode)(e,t,c)}`),f(t),s||r.assign(g,!0)},h=>{r.if((0,kr._)`!(${h} instanceof ${o.ValidationError})`,()=>r.throw(h)),p(h),s||r.assign(g,!1)}),e.ok(g)}function d(){e.result((0,H2.callValidateCode)(e,t,c),()=>f(t),()=>p(t))}function p(g){let h=(0,kr._)`${g}.errors`;r.assign(Ju.default.vErrors,(0,kr._)`${Ju.default.vErrors} === null ? ${h} : ${Ju.default.vErrors}.concat(${h})`),r.assign(Ju.default.errors,(0,kr._)`${Ju.default.vErrors}.length`)}function f(g){var h;if(!o.opts.unevaluated)return;let b=(h=n?.validate)===null||h===void 0?void 0:h.evaluated;if(o.props!==!0)if(b&&!b.dynamicProps)b.props!==void 0&&(o.props=jw.mergeEvaluated.props(r,b.props,o.props));else{let w=r.var("props",(0,kr._)`${g}.evaluated.props`);o.props=jw.mergeEvaluated.props(r,w,o.props,kr.Name)}if(o.items!==!0)if(b&&!b.dynamicItems)b.items!==void 0&&(o.items=jw.mergeEvaluated.items(r,b.items,o.items));else{let w=r.var("items",(0,kr._)`${g}.evaluated.items`);o.items=jw.mergeEvaluated.items(r,w,o.items,kr.Name)}}}Dc.callRef=Lw;Dc.default=Yue});var m_=ie(f_=>{"use strict";Object.defineProperty(f_,"__esModule",{value:!0});var Xue=U2(),Que=Mw(),ede=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",Xue.default,Que.default];f_.default=ede});var K2=ie(g_=>{"use strict";Object.defineProperty(g_,"__esModule",{value:!0});var Fw=Fe(),da=Fw.operators,Bw={maximum:{okStr:"<=",ok:da.LTE,fail:da.GT},minimum:{okStr:">=",ok:da.GTE,fail:da.LT},exclusiveMaximum:{okStr:"<",ok:da.LT,fail:da.GTE},exclusiveMinimum:{okStr:">",ok:da.GT,fail:da.LTE}},tde={message:({keyword:e,schemaCode:t})=>(0,Fw.str)`must be ${Bw[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,Fw._)`{comparison: ${Bw[e].okStr}, limit: ${t}}`},nde={keyword:Object.keys(Bw),type:"number",schemaType:"number",$data:!0,error:tde,code(e){let{keyword:t,data:n,schemaCode:i}=e;e.fail$data((0,Fw._)`${n} ${Bw[t].fail} ${i} || isNaN(${n})`)}};g_.default=nde});var J2=ie(h_=>{"use strict";Object.defineProperty(h_,"__esModule",{value:!0});var sm=Fe(),rde={message:({schemaCode:e})=>(0,sm.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,sm._)`{multipleOf: ${e}}`},ide={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:rde,code(e){let{gen:t,data:n,schemaCode:i,it:r}=e,o=r.opts.multipleOfPrecision,s=t.let("res"),a=o?(0,sm._)`Math.abs(Math.round(${s}) - ${s}) > 1e-${o}`:(0,sm._)`${s} !== parseInt(${s})`;e.fail$data((0,sm._)`(${i} === 0 || (${s} = ${n}/${i}, ${a}))`)}};h_.default=ide});var Y2=ie(y_=>{"use strict";Object.defineProperty(y_,"__esModule",{value:!0});function Z2(e){let t=e.length,n=0,i=0,r;for(;i<t;)n++,r=e.charCodeAt(i++),r>=55296&&r<=56319&&i<t&&(r=e.charCodeAt(i),(r&64512)===56320&&i++);return n}y_.default=Z2;Z2.code='require("ajv/dist/runtime/ucs2length").default'});var X2=ie(b_=>{"use strict";Object.defineProperty(b_,"__esModule",{value:!0});var Nc=Fe(),ode=Xe(),sde=Y2(),ade={message({keyword:e,schemaCode:t}){let n=e==="maxLength"?"more":"fewer";return(0,Nc.str)`must NOT have ${n} than ${t} characters`},params:({schemaCode:e})=>(0,Nc._)`{limit: ${e}}`},cde={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:ade,code(e){let{keyword:t,data:n,schemaCode:i,it:r}=e,o=t==="maxLength"?Nc.operators.GT:Nc.operators.LT,s=r.opts.unicode===!1?(0,Nc._)`${n}.length`:(0,Nc._)`${(0,ode.useFunc)(e.gen,sde.default)}(${n})`;e.fail$data((0,Nc._)`${s} ${o} ${i}`)}};b_.default=cde});var Q2=ie(w_=>{"use strict";Object.defineProperty(w_,"__esModule",{value:!0});var lde=ti(),ude=Xe(),Zu=Fe(),dde={message:({schemaCode:e})=>(0,Zu.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Zu._)`{pattern: ${e}}`},pde={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:dde,code(e){let{gen:t,data:n,$data:i,schema:r,schemaCode:o,it:s}=e,a=s.opts.unicodeRegExp?"u":"";if(i){let{regExp:l}=s.opts.code,c=l.code==="new RegExp"?(0,Zu._)`new RegExp`:(0,ude.useFunc)(t,l),u=t.let("valid");t.try(()=>t.assign(u,(0,Zu._)`${c}(${o}, ${a}).test(${n})`),()=>t.assign(u,!1)),e.fail$data((0,Zu._)`!${u}`)}else{let l=(0,lde.usePattern)(e,r);e.fail$data((0,Zu._)`!${l}.test(${n})`)}}};w_.default=pde});var eH=ie(v_=>{"use strict";Object.defineProperty(v_,"__esModule",{value:!0});var am=Fe(),fde={message({keyword:e,schemaCode:t}){let n=e==="maxProperties"?"more":"fewer";return(0,am.str)`must NOT have ${n} than ${t} properties`},params:({schemaCode:e})=>(0,am._)`{limit: ${e}}`},mde={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:fde,code(e){let{keyword:t,data:n,schemaCode:i}=e,r=t==="maxProperties"?am.operators.GT:am.operators.LT;e.fail$data((0,am._)`Object.keys(${n}).length ${r} ${i}`)}};v_.default=mde});var tH=ie(k_=>{"use strict";Object.defineProperty(k_,"__esModule",{value:!0});var cm=ti(),lm=Fe(),gde=Xe(),hde={message:({params:{missingProperty:e}})=>(0,lm.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,lm._)`{missingProperty: ${e}}`},yde={keyword:"required",type:"object",schemaType:"array",$data:!0,error:hde,code(e){let{gen:t,schema:n,schemaCode:i,data:r,$data:o,it:s}=e,{opts:a}=s;if(!o&&n.length===0)return;let l=n.length>=a.loopRequired;if(s.allErrors?c():u(),a.strictRequired){let f=e.parentSchema.properties,{definedProperties:g}=e.it;for(let h of n)if(f?.[h]===void 0&&!g.has(h)){let b=s.schemaEnv.baseId+s.errSchemaPath,w=`required property "${h}" is not defined at "${b}" (strictRequired)`;(0,gde.checkStrictMode)(s,w,s.opts.strictRequired)}}function c(){if(l||o)e.block$data(lm.nil,d);else for(let f of n)(0,cm.checkReportMissingProp)(e,f)}function u(){let f=t.let("missing");if(l||o){let g=t.let("valid",!0);e.block$data(g,()=>p(f,g)),e.ok(g)}else t.if((0,cm.checkMissingProp)(e,n,f)),(0,cm.reportMissingProp)(e,f),t.else()}function d(){t.forOf("prop",i,f=>{e.setParams({missingProperty:f}),t.if((0,cm.noPropertyInData)(t,r,f,a.ownProperties),()=>e.error())})}function p(f,g){e.setParams({missingProperty:f}),t.forOf(f,i,()=>{t.assign(g,(0,cm.propertyInData)(t,r,f,a.ownProperties)),t.if((0,lm.not)(g),()=>{e.error(),t.break()})},lm.nil)}}};k_.default=yde});var nH=ie(x_=>{"use strict";Object.defineProperty(x_,"__esModule",{value:!0});var um=Fe(),bde={message({keyword:e,schemaCode:t}){let n=e==="maxItems"?"more":"fewer";return(0,um.str)`must NOT have ${n} than ${t} items`},params:({schemaCode:e})=>(0,um._)`{limit: ${e}}`},wde={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:bde,code(e){let{keyword:t,data:n,schemaCode:i}=e,r=t==="maxItems"?um.operators.GT:um.operators.LT;e.fail$data((0,um._)`${n}.length ${r} ${i}`)}};x_.default=wde});var Gw=ie($_=>{"use strict";Object.defineProperty($_,"__esModule",{value:!0});var rH=UC();rH.code='require("ajv/dist/runtime/equal").default';$_.default=rH});var iH=ie(S_=>{"use strict";Object.defineProperty(S_,"__esModule",{value:!0});var R_=Zf(),En=Fe(),vde=Xe(),kde=Gw(),xde={message:({params:{i:e,j:t}})=>(0,En.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,En._)`{i: ${e}, j: ${t}}`},$de={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:xde,code(e){let{gen:t,data:n,$data:i,schema:r,parentSchema:o,schemaCode:s,it:a}=e;if(!i&&!r)return;let l=t.let("valid"),c=o.items?(0,R_.getSchemaTypes)(o.items):[];e.block$data(l,u,(0,En._)`${s} === false`),e.ok(l);function u(){let g=t.let("i",(0,En._)`${n}.length`),h=t.let("j");e.setParams({i:g,j:h}),t.assign(l,!0),t.if((0,En._)`${g} > 1`,()=>(d()?p:f)(g,h))}function d(){return c.length>0&&!c.some(g=>g==="object"||g==="array")}function p(g,h){let b=t.name("item"),w=(0,R_.checkDataTypes)(c,b,a.opts.strictNumbers,R_.DataType.Wrong),x=t.const("indices",(0,En._)`{}`);t.for((0,En._)`;${g}--;`,()=>{t.let(b,(0,En._)`${n}[${g}]`),t.if(w,(0,En._)`continue`),c.length>1&&t.if((0,En._)`typeof ${b} == "string"`,(0,En._)`${b} += "_"`),t.if((0,En._)`typeof ${x}[${b}] == "number"`,()=>{t.assign(h,(0,En._)`${x}[${b}]`),e.error(),t.assign(l,!1).break()}).code((0,En._)`${x}[${b}] = ${g}`)})}function f(g,h){let b=(0,vde.useFunc)(t,kde.default),w=t.name("outer");t.label(w).for((0,En._)`;${g}--;`,()=>t.for((0,En._)`${h} = ${g}; ${h}--;`,()=>t.if((0,En._)`${b}(${n}[${g}], ${n}[${h}])`,()=>{e.error(),t.assign(l,!1).break(w)})))}}};S_.default=$de});var oH=ie(A_=>{"use strict";Object.defineProperty(A_,"__esModule",{value:!0});var E_=Fe(),Rde=Xe(),Sde=Gw(),Ede={message:"must be equal to constant",params:({schemaCode:e})=>(0,E_._)`{allowedValue: ${e}}`},Ade={keyword:"const",$data:!0,error:Ede,code(e){let{gen:t,data:n,$data:i,schemaCode:r,schema:o}=e;i||o&&typeof o=="object"?e.fail$data((0,E_._)`!${(0,Rde.useFunc)(t,Sde.default)}(${n}, ${r})`):e.fail((0,E_._)`${o} !== ${n}`)}};A_.default=Ade});var sH=ie(P_=>{"use strict";Object.defineProperty(P_,"__esModule",{value:!0});var dm=Fe(),Pde=Xe(),Ode=Gw(),Cde={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,dm._)`{allowedValues: ${e}}`},_de={keyword:"enum",schemaType:"array",$data:!0,error:Cde,code(e){let{gen:t,data:n,$data:i,schema:r,schemaCode:o,it:s}=e;if(!i&&r.length===0)throw new Error("enum must have non-empty array");let a=r.length>=s.opts.loopEnum,l,c=()=>l??(l=(0,Pde.useFunc)(t,Ode.default)),u;if(a||i)u=t.let("valid"),e.block$data(u,d);else{if(!Array.isArray(r))throw new Error("ajv implementation error");let f=t.const("vSchema",o);u=(0,dm.or)(...r.map((g,h)=>p(f,h)))}e.pass(u);function d(){t.assign(u,!1),t.forOf("v",o,f=>t.if((0,dm._)`${c()}(${n}, ${f})`,()=>t.assign(u,!0).break()))}function p(f,g){let h=r[g];return typeof h=="object"&&h!==null?(0,dm._)`${c()}(${n}, ${f}[${g}])`:(0,dm._)`${n} === ${h}`}}};P_.default=_de});var C_=ie(O_=>{"use strict";Object.defineProperty(O_,"__esModule",{value:!0});var Ide=K2(),Tde=J2(),Dde=X2(),Nde=Q2(),jde=eH(),Lde=tH(),Mde=nH(),Fde=iH(),Bde=oH(),Gde=sH(),Wde=[Ide.default,Tde.default,Dde.default,Nde.default,jde.default,Lde.default,Mde.default,Fde.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},Bde.default,Gde.default];O_.default=Wde});var I_=ie(pm=>{"use strict";Object.defineProperty(pm,"__esModule",{value:!0});pm.validateAdditionalItems=void 0;var jc=Fe(),__=Xe(),zde={message:({params:{len:e}})=>(0,jc.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,jc._)`{limit: ${e}}`},Ude={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:zde,code(e){let{parentSchema:t,it:n}=e,{items:i}=t;if(!Array.isArray(i)){(0,__.checkStrictMode)(n,'"additionalItems" is ignored when "items" is not an array of schemas');return}aH(e,i)}};function aH(e,t){let{gen:n,schema:i,data:r,keyword:o,it:s}=e;s.items=!0;let a=n.const("len",(0,jc._)`${r}.length`);if(i===!1)e.setParams({len:t.length}),e.pass((0,jc._)`${a} <= ${t.length}`);else if(typeof i=="object"&&!(0,__.alwaysValidSchema)(s,i)){let c=n.var("valid",(0,jc._)`${a} <= ${t.length}`);n.if((0,jc.not)(c),()=>l(c)),e.ok(c)}function l(c){n.forRange("i",t.length,a,u=>{e.subschema({keyword:o,dataProp:u,dataPropType:__.Type.Num},c),s.allErrors||n.if((0,jc.not)(c),()=>n.break())})}}pm.validateAdditionalItems=aH;pm.default=Ude});var T_=ie(fm=>{"use strict";Object.defineProperty(fm,"__esModule",{value:!0});fm.validateTuple=void 0;var cH=Fe(),Ww=Xe(),Hde=ti(),Vde={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:n}=e;if(Array.isArray(t))return lH(e,"additionalItems",t);n.items=!0,!(0,Ww.alwaysValidSchema)(n,t)&&e.ok((0,Hde.validateArray)(e))}};function lH(e,t,n=e.schema){let{gen:i,parentSchema:r,data:o,keyword:s,it:a}=e;u(r),a.opts.unevaluated&&n.length&&a.items!==!0&&(a.items=Ww.mergeEvaluated.items(i,n.length,a.items));let l=i.name("valid"),c=i.const("len",(0,cH._)`${o}.length`);n.forEach((d,p)=>{(0,Ww.alwaysValidSchema)(a,d)||(i.if((0,cH._)`${c} > ${p}`,()=>e.subschema({keyword:s,schemaProp:p,dataProp:p},l)),e.ok(l))});function u(d){let{opts:p,errSchemaPath:f}=a,g=n.length,h=g===d.minItems&&(g===d.maxItems||d[t]===!1);if(p.strictTuples&&!h){let b=`"${s}" is ${g}-tuple, but minItems or maxItems/${t} are not specified or different at path "${f}"`;(0,Ww.checkStrictMode)(a,b,p.strictTuples)}}}fm.validateTuple=lH;fm.default=Vde});var uH=ie(D_=>{"use strict";Object.defineProperty(D_,"__esModule",{value:!0});var qde=T_(),Kde={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,qde.validateTuple)(e,"items")};D_.default=Kde});var pH=ie(N_=>{"use strict";Object.defineProperty(N_,"__esModule",{value:!0});var dH=Fe(),Jde=Xe(),Zde=ti(),Yde=I_(),Xde={message:({params:{len:e}})=>(0,dH.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,dH._)`{limit: ${e}}`},Qde={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:Xde,code(e){let{schema:t,parentSchema:n,it:i}=e,{prefixItems:r}=n;i.items=!0,!(0,Jde.alwaysValidSchema)(i,t)&&(r?(0,Yde.validateAdditionalItems)(e,r):e.ok((0,Zde.validateArray)(e)))}};N_.default=Qde});var fH=ie(j_=>{"use strict";Object.defineProperty(j_,"__esModule",{value:!0});var ri=Fe(),zw=Xe(),epe={message:({params:{min:e,max:t}})=>t===void 0?(0,ri.str)`must contain at least ${e} valid item(s)`:(0,ri.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,ri._)`{minContains: ${e}}`:(0,ri._)`{minContains: ${e}, maxContains: ${t}}`},tpe={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:epe,code(e){let{gen:t,schema:n,parentSchema:i,data:r,it:o}=e,s,a,{minContains:l,maxContains:c}=i;o.opts.next?(s=l===void 0?1:l,a=c):s=1;let u=t.const("len",(0,ri._)`${r}.length`);if(e.setParams({min:s,max:a}),a===void 0&&s===0){(0,zw.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&s>a){(0,zw.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,zw.alwaysValidSchema)(o,n)){let h=(0,ri._)`${u} >= ${s}`;a!==void 0&&(h=(0,ri._)`${h} && ${u} <= ${a}`),e.pass(h);return}o.items=!0;let d=t.name("valid");a===void 0&&s===1?f(d,()=>t.if(d,()=>t.break())):s===0?(t.let(d,!0),a!==void 0&&t.if((0,ri._)`${r}.length > 0`,p)):(t.let(d,!1),p()),e.result(d,()=>e.reset());function p(){let h=t.name("_valid"),b=t.let("count",0);f(h,()=>t.if(h,()=>g(b)))}function f(h,b){t.forRange("i",0,u,w=>{e.subschema({keyword:"contains",dataProp:w,dataPropType:zw.Type.Num,compositeRule:!0},h),b()})}function g(h){t.code((0,ri._)`${h}++`),a===void 0?t.if((0,ri._)`${h} >= ${s}`,()=>t.assign(d,!0).break()):(t.if((0,ri._)`${h} > ${a}`,()=>t.assign(d,!1).break()),s===1?t.assign(d,!0):t.if((0,ri._)`${h} >= ${s}`,()=>t.assign(d,!0)))}}};j_.default=tpe});var Uw=ie(ao=>{"use strict";Object.defineProperty(ao,"__esModule",{value:!0});ao.validateSchemaDeps=ao.validatePropertyDeps=ao.error=void 0;var L_=Fe(),npe=Xe(),mm=ti();ao.error={message:({params:{property:e,depsCount:t,deps:n}})=>{let i=t===1?"property":"properties";return(0,L_.str)`must have ${i} ${n} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:n,missingProperty:i}})=>(0,L_._)`{property: ${e},
|
|
67
|
+
missingProperty: ${i},
|
|
68
|
+
depsCount: ${t},
|
|
69
|
+
deps: ${n}}`};var rpe={keyword:"dependencies",type:"object",schemaType:"object",error:ao.error,code(e){let[t,n]=ipe(e);mH(e,t),gH(e,n)}};function ipe({schema:e}){let t={},n={};for(let i in e){if(i==="__proto__")continue;let r=Array.isArray(e[i])?t:n;r[i]=e[i]}return[t,n]}function mH(e,t=e.schema){let{gen:n,data:i,it:r}=e;if(Object.keys(t).length===0)return;let o=n.let("missing");for(let s in t){let a=t[s];if(a.length===0)continue;let l=(0,mm.propertyInData)(n,i,s,r.opts.ownProperties);e.setParams({property:s,depsCount:a.length,deps:a.join(", ")}),r.allErrors?n.if(l,()=>{for(let c of a)(0,mm.checkReportMissingProp)(e,c)}):(n.if((0,L_._)`${l} && (${(0,mm.checkMissingProp)(e,a,o)})`),(0,mm.reportMissingProp)(e,o),n.else())}}ao.validatePropertyDeps=mH;function gH(e,t=e.schema){let{gen:n,data:i,keyword:r,it:o}=e,s=n.name("valid");for(let a in t)(0,npe.alwaysValidSchema)(o,t[a])||(n.if((0,mm.propertyInData)(n,i,a,o.opts.ownProperties),()=>{let l=e.subschema({keyword:r,schemaProp:a},s);e.mergeValidEvaluated(l,s)},()=>n.var(s,!0)),e.ok(s))}ao.validateSchemaDeps=gH;ao.default=rpe});var yH=ie(M_=>{"use strict";Object.defineProperty(M_,"__esModule",{value:!0});var hH=Fe(),ope=Xe(),spe={message:"property name must be valid",params:({params:e})=>(0,hH._)`{propertyName: ${e.propertyName}}`},ape={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:spe,code(e){let{gen:t,schema:n,data:i,it:r}=e;if((0,ope.alwaysValidSchema)(r,n))return;let o=t.name("valid");t.forIn("key",i,s=>{e.setParams({propertyName:s}),e.subschema({keyword:"propertyNames",data:s,dataTypes:["string"],propertyName:s,compositeRule:!0},o),t.if((0,hH.not)(o),()=>{e.error(!0),r.allErrors||t.break()})}),e.ok(o)}};M_.default=ape});var B_=ie(F_=>{"use strict";Object.defineProperty(F_,"__esModule",{value:!0});var Hw=ti(),Di=Fe(),cpe=ei(),Vw=Xe(),lpe={message:"must NOT have additional properties",params:({params:e})=>(0,Di._)`{additionalProperty: ${e.additionalProperty}}`},upe={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:lpe,code(e){let{gen:t,schema:n,parentSchema:i,data:r,errsCount:o,it:s}=e;if(!o)throw new Error("ajv implementation error");let{allErrors:a,opts:l}=s;if(s.props=!0,l.removeAdditional!=="all"&&(0,Vw.alwaysValidSchema)(s,n))return;let c=(0,Hw.allSchemaProperties)(i.properties),u=(0,Hw.allSchemaProperties)(i.patternProperties);d(),e.ok((0,Di._)`${o} === ${cpe.default.errors}`);function d(){t.forIn("key",r,b=>{!c.length&&!u.length?g(b):t.if(p(b),()=>g(b))})}function p(b){let w;if(c.length>8){let x=(0,Vw.schemaRefOrVal)(s,i.properties,"properties");w=(0,Hw.isOwnProperty)(t,x,b)}else c.length?w=(0,Di.or)(...c.map(x=>(0,Di._)`${b} === ${x}`)):w=Di.nil;return u.length&&(w=(0,Di.or)(w,...u.map(x=>(0,Di._)`${(0,Hw.usePattern)(e,x)}.test(${b})`))),(0,Di.not)(w)}function f(b){t.code((0,Di._)`delete ${r}[${b}]`)}function g(b){if(l.removeAdditional==="all"||l.removeAdditional&&n===!1){f(b);return}if(n===!1){e.setParams({additionalProperty:b}),e.error(),a||t.break();return}if(typeof n=="object"&&!(0,Vw.alwaysValidSchema)(s,n)){let w=t.name("valid");l.removeAdditional==="failing"?(h(b,w,!1),t.if((0,Di.not)(w),()=>{e.reset(),f(b)})):(h(b,w),a||t.if((0,Di.not)(w),()=>t.break()))}}function h(b,w,x){let k={keyword:"additionalProperties",dataProp:b,dataPropType:Vw.Type.Str};x===!1&&Object.assign(k,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(k,w)}}};F_.default=upe});var vH=ie(W_=>{"use strict";Object.defineProperty(W_,"__esModule",{value:!0});var dpe=Uu(),bH=ti(),G_=Xe(),wH=B_(),ppe={keyword:"properties",type:"object",schemaType:"object",code(e){let{gen:t,schema:n,parentSchema:i,data:r,it:o}=e;o.opts.removeAdditional==="all"&&i.additionalProperties===void 0&&wH.default.code(new dpe.KeywordCxt(o,wH.default,"additionalProperties"));let s=(0,bH.allSchemaProperties)(n);for(let d of s)o.definedProperties.add(d);o.opts.unevaluated&&s.length&&o.props!==!0&&(o.props=G_.mergeEvaluated.props(t,(0,G_.toHash)(s),o.props));let a=s.filter(d=>!(0,G_.alwaysValidSchema)(o,n[d]));if(a.length===0)return;let l=t.name("valid");for(let d of a)c(d)?u(d):(t.if((0,bH.propertyInData)(t,r,d,o.opts.ownProperties)),u(d),o.allErrors||t.else().var(l,!0),t.endIf()),e.it.definedProperties.add(d),e.ok(l);function c(d){return o.opts.useDefaults&&!o.compositeRule&&n[d].default!==void 0}function u(d){e.subschema({keyword:"properties",schemaProp:d,dataProp:d},l)}}};W_.default=ppe});var RH=ie(z_=>{"use strict";Object.defineProperty(z_,"__esModule",{value:!0});var kH=ti(),qw=Fe(),xH=Xe(),$H=Xe(),fpe={keyword:"patternProperties",type:"object",schemaType:"object",code(e){let{gen:t,schema:n,data:i,parentSchema:r,it:o}=e,{opts:s}=o,a=(0,kH.allSchemaProperties)(n),l=a.filter(h=>(0,xH.alwaysValidSchema)(o,n[h]));if(a.length===0||l.length===a.length&&(!o.opts.unevaluated||o.props===!0))return;let c=s.strictSchema&&!s.allowMatchingProperties&&r.properties,u=t.name("valid");o.props!==!0&&!(o.props instanceof qw.Name)&&(o.props=(0,$H.evaluatedPropsToName)(t,o.props));let{props:d}=o;p();function p(){for(let h of a)c&&f(h),o.allErrors?g(h):(t.var(u,!0),g(h),t.if(u))}function f(h){for(let b in c)new RegExp(h).test(b)&&(0,xH.checkStrictMode)(o,`property ${b} matches pattern ${h} (use allowMatchingProperties)`)}function g(h){t.forIn("key",i,b=>{t.if((0,qw._)`${(0,kH.usePattern)(e,h)}.test(${b})`,()=>{let w=l.includes(h);w||e.subschema({keyword:"patternProperties",schemaProp:h,dataProp:b,dataPropType:$H.Type.Str},u),o.opts.unevaluated&&d!==!0?t.assign((0,qw._)`${d}[${b}]`,!0):!w&&!o.allErrors&&t.if((0,qw.not)(u),()=>t.break())})})}}};z_.default=fpe});var SH=ie(U_=>{"use strict";Object.defineProperty(U_,"__esModule",{value:!0});var mpe=Xe(),gpe={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){let{gen:t,schema:n,it:i}=e;if((0,mpe.alwaysValidSchema)(i,n)){e.fail();return}let r=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},r),e.failResult(r,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};U_.default=gpe});var EH=ie(H_=>{"use strict";Object.defineProperty(H_,"__esModule",{value:!0});var hpe=ti(),ype={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:hpe.validateUnion,error:{message:"must match a schema in anyOf"}};H_.default=ype});var AH=ie(V_=>{"use strict";Object.defineProperty(V_,"__esModule",{value:!0});var Kw=Fe(),bpe=Xe(),wpe={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,Kw._)`{passingSchemas: ${e.passing}}`},vpe={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:wpe,code(e){let{gen:t,schema:n,parentSchema:i,it:r}=e;if(!Array.isArray(n))throw new Error("ajv implementation error");if(r.opts.discriminator&&i.discriminator)return;let o=n,s=t.let("valid",!1),a=t.let("passing",null),l=t.name("_valid");e.setParams({passing:a}),t.block(c),e.result(s,()=>e.reset(),()=>e.error(!0));function c(){o.forEach((u,d)=>{let p;(0,bpe.alwaysValidSchema)(r,u)?t.var(l,!0):p=e.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},l),d>0&&t.if((0,Kw._)`${l} && ${s}`).assign(s,!1).assign(a,(0,Kw._)`[${a}, ${d}]`).else(),t.if(l,()=>{t.assign(s,!0),t.assign(a,d),p&&e.mergeEvaluated(p,Kw.Name)})})}}};V_.default=vpe});var PH=ie(q_=>{"use strict";Object.defineProperty(q_,"__esModule",{value:!0});var kpe=Xe(),xpe={keyword:"allOf",schemaType:"array",code(e){let{gen:t,schema:n,it:i}=e;if(!Array.isArray(n))throw new Error("ajv implementation error");let r=t.name("valid");n.forEach((o,s)=>{if((0,kpe.alwaysValidSchema)(i,o))return;let a=e.subschema({keyword:"allOf",schemaProp:s},r);e.ok(r),e.mergeEvaluated(a)})}};q_.default=xpe});var _H=ie(K_=>{"use strict";Object.defineProperty(K_,"__esModule",{value:!0});var Jw=Fe(),CH=Xe(),$pe={message:({params:e})=>(0,Jw.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,Jw._)`{failingKeyword: ${e.ifClause}}`},Rpe={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:$pe,code(e){let{gen:t,parentSchema:n,it:i}=e;n.then===void 0&&n.else===void 0&&(0,CH.checkStrictMode)(i,'"if" without "then" and "else" is ignored');let r=OH(i,"then"),o=OH(i,"else");if(!r&&!o)return;let s=t.let("valid",!0),a=t.name("_valid");if(l(),e.reset(),r&&o){let u=t.let("ifClause");e.setParams({ifClause:u}),t.if(a,c("then",u),c("else",u))}else r?t.if(a,c("then")):t.if((0,Jw.not)(a),c("else"));e.pass(s,()=>e.error(!0));function l(){let u=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);e.mergeEvaluated(u)}function c(u,d){return()=>{let p=e.subschema({keyword:u},a);t.assign(s,a),e.mergeValidEvaluated(p,s),d?t.assign(d,(0,Jw._)`${u}`):e.setParams({ifClause:u})}}}};function OH(e,t){let n=e.schema[t];return n!==void 0&&!(0,CH.alwaysValidSchema)(e,n)}K_.default=Rpe});var IH=ie(J_=>{"use strict";Object.defineProperty(J_,"__esModule",{value:!0});var Spe=Xe(),Epe={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:n}){t.if===void 0&&(0,Spe.checkStrictMode)(n,`"${e}" without "if" is ignored`)}};J_.default=Epe});var Y_=ie(Z_=>{"use strict";Object.defineProperty(Z_,"__esModule",{value:!0});var Ape=I_(),Ppe=uH(),Ope=T_(),Cpe=pH(),_pe=fH(),Ipe=Uw(),Tpe=yH(),Dpe=B_(),Npe=vH(),jpe=RH(),Lpe=SH(),Mpe=EH(),Fpe=AH(),Bpe=PH(),Gpe=_H(),Wpe=IH();function zpe(e=!1){let t=[Lpe.default,Mpe.default,Fpe.default,Bpe.default,Gpe.default,Wpe.default,Tpe.default,Dpe.default,Ipe.default,Npe.default,jpe.default];return e?t.push(Ppe.default,Cpe.default):t.push(Ape.default,Ope.default),t.push(_pe.default),t}Z_.default=zpe});var Q_=ie(gm=>{"use strict";Object.defineProperty(gm,"__esModule",{value:!0});gm.dynamicAnchor=void 0;var X_=Fe(),Upe=ei(),TH=tm(),Hpe=Mw(),Vpe={keyword:"$dynamicAnchor",schemaType:"string",code:e=>DH(e,e.schema)};function DH(e,t){let{gen:n,it:i}=e;i.schemaEnv.root.dynamicAnchors[t]=!0;let r=(0,X_._)`${Upe.default.dynamicAnchors}${(0,X_.getProperty)(t)}`,o=i.errSchemaPath==="#"?i.validateName:qpe(e);n.if((0,X_._)`!${r}`,()=>n.assign(r,o))}gm.dynamicAnchor=DH;function qpe(e){let{schemaEnv:t,schema:n,self:i}=e.it,{root:r,baseId:o,localRefs:s,meta:a}=t.root,{schemaId:l}=i.opts,c=new TH.SchemaEnv({schema:n,schemaId:l,root:r,baseId:o,localRefs:s,meta:a});return TH.compileSchema.call(i,c),(0,Hpe.getValidate)(e,c)}gm.default=Vpe});var e0=ie(hm=>{"use strict";Object.defineProperty(hm,"__esModule",{value:!0});hm.dynamicRef=void 0;var NH=Fe(),Kpe=ei(),jH=Mw(),Jpe={keyword:"$dynamicRef",schemaType:"string",code:e=>LH(e,e.schema)};function LH(e,t){let{gen:n,keyword:i,it:r}=e;if(t[0]!=="#")throw new Error(`"${i}" only supports hash fragment reference`);let o=t.slice(1);if(r.allErrors)s();else{let l=n.let("valid",!1);s(l),e.ok(l)}function s(l){if(r.schemaEnv.root.dynamicAnchors[o]){let c=n.let("_v",(0,NH._)`${Kpe.default.dynamicAnchors}${(0,NH.getProperty)(o)}`);n.if(c,a(c,l),a(r.validateName,l))}else a(r.validateName,l)()}function a(l,c){return c?()=>n.block(()=>{(0,jH.callRef)(e,l),n.let(c,!0)}):()=>(0,jH.callRef)(e,l)}}hm.dynamicRef=LH;hm.default=Jpe});var MH=ie(t0=>{"use strict";Object.defineProperty(t0,"__esModule",{value:!0});var Zpe=Q_(),Ype=Xe(),Xpe={keyword:"$recursiveAnchor",schemaType:"boolean",code(e){e.schema?(0,Zpe.dynamicAnchor)(e,""):(0,Ype.checkStrictMode)(e.it,"$recursiveAnchor: false is ignored")}};t0.default=Xpe});var FH=ie(n0=>{"use strict";Object.defineProperty(n0,"__esModule",{value:!0});var Qpe=e0(),efe={keyword:"$recursiveRef",schemaType:"string",code:e=>(0,Qpe.dynamicRef)(e,e.schema)};n0.default=efe});var BH=ie(r0=>{"use strict";Object.defineProperty(r0,"__esModule",{value:!0});var tfe=Q_(),nfe=e0(),rfe=MH(),ife=FH(),ofe=[tfe.default,nfe.default,rfe.default,ife.default];r0.default=ofe});var WH=ie(i0=>{"use strict";Object.defineProperty(i0,"__esModule",{value:!0});var GH=Uw(),sfe={keyword:"dependentRequired",type:"object",schemaType:"object",error:GH.error,code:e=>(0,GH.validatePropertyDeps)(e)};i0.default=sfe});var zH=ie(o0=>{"use strict";Object.defineProperty(o0,"__esModule",{value:!0});var afe=Uw(),cfe={keyword:"dependentSchemas",type:"object",schemaType:"object",code:e=>(0,afe.validateSchemaDeps)(e)};o0.default=cfe});var UH=ie(s0=>{"use strict";Object.defineProperty(s0,"__esModule",{value:!0});var lfe=Xe(),ufe={keyword:["maxContains","minContains"],type:"array",schemaType:"number",code({keyword:e,parentSchema:t,it:n}){t.contains===void 0&&(0,lfe.checkStrictMode)(n,`"${e}" without "contains" is ignored`)}};s0.default=ufe});var HH=ie(a0=>{"use strict";Object.defineProperty(a0,"__esModule",{value:!0});var dfe=WH(),pfe=zH(),ffe=UH(),mfe=[dfe.default,pfe.default,ffe.default];a0.default=mfe});var qH=ie(c0=>{"use strict";Object.defineProperty(c0,"__esModule",{value:!0});var pa=Fe(),VH=Xe(),gfe=ei(),hfe={message:"must NOT have unevaluated properties",params:({params:e})=>(0,pa._)`{unevaluatedProperty: ${e.unevaluatedProperty}}`},yfe={keyword:"unevaluatedProperties",type:"object",schemaType:["boolean","object"],trackErrors:!0,error:hfe,code(e){let{gen:t,schema:n,data:i,errsCount:r,it:o}=e;if(!r)throw new Error("ajv implementation error");let{allErrors:s,props:a}=o;a instanceof pa.Name?t.if((0,pa._)`${a} !== true`,()=>t.forIn("key",i,d=>t.if(c(a,d),()=>l(d)))):a!==!0&&t.forIn("key",i,d=>a===void 0?l(d):t.if(u(a,d),()=>l(d))),o.props=!0,e.ok((0,pa._)`${r} === ${gfe.default.errors}`);function l(d){if(n===!1){e.setParams({unevaluatedProperty:d}),e.error(),s||t.break();return}if(!(0,VH.alwaysValidSchema)(o,n)){let p=t.name("valid");e.subschema({keyword:"unevaluatedProperties",dataProp:d,dataPropType:VH.Type.Str},p),s||t.if((0,pa.not)(p),()=>t.break())}}function c(d,p){return(0,pa._)`!${d} || !${d}[${p}]`}function u(d,p){let f=[];for(let g in d)d[g]===!0&&f.push((0,pa._)`${p} !== ${g}`);return(0,pa.and)(...f)}}};c0.default=yfe});var JH=ie(l0=>{"use strict";Object.defineProperty(l0,"__esModule",{value:!0});var Lc=Fe(),KH=Xe(),bfe={message:({params:{len:e}})=>(0,Lc.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,Lc._)`{limit: ${e}}`},wfe={keyword:"unevaluatedItems",type:"array",schemaType:["boolean","object"],error:bfe,code(e){let{gen:t,schema:n,data:i,it:r}=e,o=r.items||0;if(o===!0)return;let s=t.const("len",(0,Lc._)`${i}.length`);if(n===!1)e.setParams({len:o}),e.fail((0,Lc._)`${s} > ${o}`);else if(typeof n=="object"&&!(0,KH.alwaysValidSchema)(r,n)){let l=t.var("valid",(0,Lc._)`${s} <= ${o}`);t.if((0,Lc.not)(l),()=>a(l,o)),e.ok(l)}r.items=!0;function a(l,c){t.forRange("i",c,s,u=>{e.subschema({keyword:"unevaluatedItems",dataProp:u,dataPropType:KH.Type.Num},l),r.allErrors||t.if((0,Lc.not)(l),()=>t.break())})}}};l0.default=wfe});var ZH=ie(u0=>{"use strict";Object.defineProperty(u0,"__esModule",{value:!0});var vfe=qH(),kfe=JH(),xfe=[vfe.default,kfe.default];u0.default=xfe});var YH=ie(d0=>{"use strict";Object.defineProperty(d0,"__esModule",{value:!0});var Yt=Fe(),$fe={message:({schemaCode:e})=>(0,Yt.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,Yt._)`{format: ${e}}`},Rfe={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:$fe,code(e,t){let{gen:n,data:i,$data:r,schema:o,schemaCode:s,it:a}=e,{opts:l,errSchemaPath:c,schemaEnv:u,self:d}=a;if(!l.validateFormats)return;r?p():f();function p(){let g=n.scopeValue("formats",{ref:d.formats,code:l.code.formats}),h=n.const("fDef",(0,Yt._)`${g}[${s}]`),b=n.let("fType"),w=n.let("format");n.if((0,Yt._)`typeof ${h} == "object" && !(${h} instanceof RegExp)`,()=>n.assign(b,(0,Yt._)`${h}.type || "string"`).assign(w,(0,Yt._)`${h}.validate`),()=>n.assign(b,(0,Yt._)`"string"`).assign(w,h)),e.fail$data((0,Yt.or)(x(),k()));function x(){return l.strictSchema===!1?Yt.nil:(0,Yt._)`${s} && !${w}`}function k(){let R=u.$async?(0,Yt._)`(${h}.async ? await ${w}(${i}) : ${w}(${i}))`:(0,Yt._)`${w}(${i})`,$=(0,Yt._)`(typeof ${w} == "function" ? ${R} : ${w}.test(${i}))`;return(0,Yt._)`${w} && ${w} !== true && ${b} === ${t} && !${$}`}}function f(){let g=d.formats[o];if(!g){x();return}if(g===!0)return;let[h,b,w]=k(g);h===t&&e.pass(R());function x(){if(l.strictSchema===!1){d.logger.warn($());return}throw new Error($());function $(){return`unknown format "${o}" ignored in schema at path "${c}"`}}function k($){let _=$ instanceof RegExp?(0,Yt.regexpCode)($):l.code.formats?(0,Yt._)`${l.code.formats}${(0,Yt.getProperty)(o)}`:void 0,T=n.scopeValue("formats",{key:o,ref:$,code:_});return typeof $=="object"&&!($ instanceof RegExp)?[$.type||"string",$.validate,(0,Yt._)`${T}.validate`]:["string",$,T]}function R(){if(typeof g=="object"&&!(g instanceof RegExp)&&g.async){if(!u.$async)throw new Error("async format in sync schema");return(0,Yt._)`await ${w}(${i})`}return typeof b=="function"?(0,Yt._)`${w}(${i})`:(0,Yt._)`${w}.test(${i})`}}}};d0.default=Rfe});var f0=ie(p0=>{"use strict";Object.defineProperty(p0,"__esModule",{value:!0});var Sfe=YH(),Efe=[Sfe.default];p0.default=Efe});var m0=ie(Yu=>{"use strict";Object.defineProperty(Yu,"__esModule",{value:!0});Yu.contentVocabulary=Yu.metadataVocabulary=void 0;Yu.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Yu.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var QH=ie(g0=>{"use strict";Object.defineProperty(g0,"__esModule",{value:!0});var Afe=m_(),Pfe=C_(),Ofe=Y_(),Cfe=BH(),_fe=HH(),Ife=ZH(),Tfe=f0(),XH=m0(),Dfe=[Cfe.default,Afe.default,Pfe.default,(0,Ofe.default)(!0),Tfe.default,XH.metadataVocabulary,XH.contentVocabulary,_fe.default,Ife.default];g0.default=Dfe});var tV=ie(Zw=>{"use strict";Object.defineProperty(Zw,"__esModule",{value:!0});Zw.DiscrError=void 0;var eV;(function(e){e.Tag="tag",e.Mapping="mapping"})(eV||(Zw.DiscrError=eV={}))});var b0=ie(y0=>{"use strict";Object.defineProperty(y0,"__esModule",{value:!0});var Xu=Fe(),h0=tV(),nV=tm(),Nfe=Hu(),jfe=Xe(),Lfe={message:({params:{discrError:e,tagName:t}})=>e===h0.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:n}})=>(0,Xu._)`{error: ${e}, tag: ${n}, tagValue: ${t}}`},Mfe={keyword:"discriminator",type:"object",schemaType:"object",error:Lfe,code(e){let{gen:t,data:n,schema:i,parentSchema:r,it:o}=e,{oneOf:s}=r;if(!o.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=i.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(i.mapping)throw new Error("discriminator: mapping is not supported");if(!s)throw new Error("discriminator: requires oneOf keyword");let l=t.let("valid",!1),c=t.const("tag",(0,Xu._)`${n}${(0,Xu.getProperty)(a)}`);t.if((0,Xu._)`typeof ${c} == "string"`,()=>u(),()=>e.error(!1,{discrError:h0.DiscrError.Tag,tag:c,tagName:a})),e.ok(l);function u(){let f=p();t.if(!1);for(let g in f)t.elseIf((0,Xu._)`${c} === ${g}`),t.assign(l,d(f[g]));t.else(),e.error(!1,{discrError:h0.DiscrError.Mapping,tag:c,tagName:a}),t.endIf()}function d(f){let g=t.name("valid"),h=e.subschema({keyword:"oneOf",schemaProp:f},g);return e.mergeEvaluated(h,Xu.Name),g}function p(){var f;let g={},h=w(r),b=!0;for(let R=0;R<s.length;R++){let $=s[R];if($?.$ref&&!(0,jfe.schemaHasRulesButRef)($,o.self.RULES)){let T=$.$ref;if($=nV.resolveRef.call(o.self,o.schemaEnv.root,o.baseId,T),$ instanceof nV.SchemaEnv&&($=$.schema),$===void 0)throw new Nfe.default(o.opts.uriResolver,o.baseId,T)}let _=(f=$?.properties)===null||f===void 0?void 0:f[a];if(typeof _!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);b=b&&(h||w($)),x(_,R)}if(!b)throw new Error(`discriminator: "${a}" must be required`);return g;function w({required:R}){return Array.isArray(R)&&R.includes(a)}function x(R,$){if(R.const)k(R.const,$);else if(R.enum)for(let _ of R.enum)k(_,$);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function k(R,$){if(typeof R!="string"||R in g)throw new Error(`discriminator: "${a}" values must be unique strings`);g[R]=$}}}};y0.default=Mfe});var rV=ie((mBe,Ffe)=>{Ffe.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/schema",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/core":!0,"https://json-schema.org/draft/2020-12/vocab/applicator":!0,"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0,"https://json-schema.org/draft/2020-12/vocab/validation":!0,"https://json-schema.org/draft/2020-12/vocab/meta-data":!0,"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0,"https://json-schema.org/draft/2020-12/vocab/content":!0},$dynamicAnchor:"meta",title:"Core and Validation specifications meta-schema",allOf:[{$ref:"meta/core"},{$ref:"meta/applicator"},{$ref:"meta/unevaluated"},{$ref:"meta/validation"},{$ref:"meta/meta-data"},{$ref:"meta/format-annotation"},{$ref:"meta/content"}],type:["object","boolean"],$comment:"This meta-schema also defines keywords that have appeared in previous drafts in order to prevent incompatible extensions as they remain in common use.",properties:{definitions:{$comment:'"definitions" has been replaced by "$defs".',type:"object",additionalProperties:{$dynamicRef:"#meta"},deprecated:!0,default:{}},dependencies:{$comment:'"dependencies" has been split and replaced by "dependentSchemas" and "dependentRequired" in order to serve their differing semantics.',type:"object",additionalProperties:{anyOf:[{$dynamicRef:"#meta"},{$ref:"meta/validation#/$defs/stringArray"}]},deprecated:!0,default:{}},$recursiveAnchor:{$comment:'"$recursiveAnchor" has been replaced by "$dynamicAnchor".',$ref:"meta/core#/$defs/anchorString",deprecated:!0},$recursiveRef:{$comment:'"$recursiveRef" has been replaced by "$dynamicRef".',$ref:"meta/core#/$defs/uriReferenceString",deprecated:!0}}}});var iV=ie((gBe,Bfe)=>{Bfe.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/applicator",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/applicator":!0},$dynamicAnchor:"meta",title:"Applicator vocabulary meta-schema",type:["object","boolean"],properties:{prefixItems:{$ref:"#/$defs/schemaArray"},items:{$dynamicRef:"#meta"},contains:{$dynamicRef:"#meta"},additionalProperties:{$dynamicRef:"#meta"},properties:{type:"object",additionalProperties:{$dynamicRef:"#meta"},default:{}},patternProperties:{type:"object",additionalProperties:{$dynamicRef:"#meta"},propertyNames:{format:"regex"},default:{}},dependentSchemas:{type:"object",additionalProperties:{$dynamicRef:"#meta"},default:{}},propertyNames:{$dynamicRef:"#meta"},if:{$dynamicRef:"#meta"},then:{$dynamicRef:"#meta"},else:{$dynamicRef:"#meta"},allOf:{$ref:"#/$defs/schemaArray"},anyOf:{$ref:"#/$defs/schemaArray"},oneOf:{$ref:"#/$defs/schemaArray"},not:{$dynamicRef:"#meta"}},$defs:{schemaArray:{type:"array",minItems:1,items:{$dynamicRef:"#meta"}}}}});var oV=ie((hBe,Gfe)=>{Gfe.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/unevaluated",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0},$dynamicAnchor:"meta",title:"Unevaluated applicator vocabulary meta-schema",type:["object","boolean"],properties:{unevaluatedItems:{$dynamicRef:"#meta"},unevaluatedProperties:{$dynamicRef:"#meta"}}}});var sV=ie((yBe,Wfe)=>{Wfe.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/content",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/content":!0},$dynamicAnchor:"meta",title:"Content vocabulary meta-schema",type:["object","boolean"],properties:{contentEncoding:{type:"string"},contentMediaType:{type:"string"},contentSchema:{$dynamicRef:"#meta"}}}});var aV=ie((bBe,zfe)=>{zfe.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/core",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/core":!0},$dynamicAnchor:"meta",title:"Core vocabulary meta-schema",type:["object","boolean"],properties:{$id:{$ref:"#/$defs/uriReferenceString",$comment:"Non-empty fragments not allowed.",pattern:"^[^#]*#?$"},$schema:{$ref:"#/$defs/uriString"},$ref:{$ref:"#/$defs/uriReferenceString"},$anchor:{$ref:"#/$defs/anchorString"},$dynamicRef:{$ref:"#/$defs/uriReferenceString"},$dynamicAnchor:{$ref:"#/$defs/anchorString"},$vocabulary:{type:"object",propertyNames:{$ref:"#/$defs/uriString"},additionalProperties:{type:"boolean"}},$comment:{type:"string"},$defs:{type:"object",additionalProperties:{$dynamicRef:"#meta"}}},$defs:{anchorString:{type:"string",pattern:"^[A-Za-z_][-A-Za-z0-9._]*$"},uriString:{type:"string",format:"uri"},uriReferenceString:{type:"string",format:"uri-reference"}}}});var cV=ie((wBe,Ufe)=>{Ufe.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/format-annotation",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0},$dynamicAnchor:"meta",title:"Format vocabulary meta-schema for annotation results",type:["object","boolean"],properties:{format:{type:"string"}}}});var lV=ie((vBe,Hfe)=>{Hfe.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/meta-data",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/meta-data":!0},$dynamicAnchor:"meta",title:"Meta-data vocabulary meta-schema",type:["object","boolean"],properties:{title:{type:"string"},description:{type:"string"},default:!0,deprecated:{type:"boolean",default:!1},readOnly:{type:"boolean",default:!1},writeOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0}}}});var uV=ie((kBe,Vfe)=>{Vfe.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/validation",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/validation":!0},$dynamicAnchor:"meta",title:"Validation vocabulary meta-schema",type:["object","boolean"],properties:{type:{anyOf:[{$ref:"#/$defs/simpleTypes"},{type:"array",items:{$ref:"#/$defs/simpleTypes"},minItems:1,uniqueItems:!0}]},const:!0,enum:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/$defs/nonNegativeInteger"},minLength:{$ref:"#/$defs/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},maxItems:{$ref:"#/$defs/nonNegativeInteger"},minItems:{$ref:"#/$defs/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},maxContains:{$ref:"#/$defs/nonNegativeInteger"},minContains:{$ref:"#/$defs/nonNegativeInteger",default:1},maxProperties:{$ref:"#/$defs/nonNegativeInteger"},minProperties:{$ref:"#/$defs/nonNegativeIntegerDefault0"},required:{$ref:"#/$defs/stringArray"},dependentRequired:{type:"object",additionalProperties:{$ref:"#/$defs/stringArray"}}},$defs:{nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{$ref:"#/$defs/nonNegativeInteger",default:0},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}}}});var dV=ie(w0=>{"use strict";Object.defineProperty(w0,"__esModule",{value:!0});var qfe=rV(),Kfe=iV(),Jfe=oV(),Zfe=sV(),Yfe=aV(),Xfe=cV(),Qfe=lV(),eme=uV(),tme=["/properties"];function nme(e){return[qfe,Kfe,Jfe,Zfe,Yfe,t(this,Xfe),Qfe,t(this,eme)].forEach(n=>this.addMetaSchema(n,void 0,!1)),this;function t(n,i){return e?n.$dataMetaSchema(i,tme):i}}w0.default=nme});var pV=ie((jt,k0)=>{"use strict";Object.defineProperty(jt,"__esModule",{value:!0});jt.MissingRefError=jt.ValidationError=jt.CodeGen=jt.Name=jt.nil=jt.stringify=jt.str=jt._=jt.KeywordCxt=jt.Ajv2020=void 0;var rme=d_(),ime=QH(),ome=b0(),sme=dV(),v0="https://json-schema.org/draft/2020-12/schema",Qu=class extends rme.default{constructor(t={}){super({...t,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),ime.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(ome.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:t,meta:n}=this.opts;n&&(sme.default.call(this,t),this.refs["http://json-schema.org/schema"]=v0)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(v0)?v0:void 0)}};jt.Ajv2020=Qu;k0.exports=jt=Qu;k0.exports.Ajv2020=Qu;Object.defineProperty(jt,"__esModule",{value:!0});jt.default=Qu;var ame=Uu();Object.defineProperty(jt,"KeywordCxt",{enumerable:!0,get:function(){return ame.KeywordCxt}});var ed=Fe();Object.defineProperty(jt,"_",{enumerable:!0,get:function(){return ed._}});Object.defineProperty(jt,"str",{enumerable:!0,get:function(){return ed.str}});Object.defineProperty(jt,"stringify",{enumerable:!0,get:function(){return ed.stringify}});Object.defineProperty(jt,"nil",{enumerable:!0,get:function(){return ed.nil}});Object.defineProperty(jt,"Name",{enumerable:!0,get:function(){return ed.Name}});Object.defineProperty(jt,"CodeGen",{enumerable:!0,get:function(){return ed.CodeGen}});var cme=em();Object.defineProperty(jt,"ValidationError",{enumerable:!0,get:function(){return cme.default}});var lme=Hu();Object.defineProperty(jt,"MissingRefError",{enumerable:!0,get:function(){return lme.default}})});function fa(){let e=pV();return e.default??e}var ym=v(()=>{"use strict"});import{readFileSync as $0}from"node:fs";import{isAbsolute as ume,join as R0,relative as dme,resolve as pme}from"node:path";function mV(e=[]){let t=new Map;for(let n of[...fV,...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 gV(){return mV()}function hV(e,t,n){if("directory"in e.probe)return!0;if("chantProject"in e.probe)return E0(t,n);let{anyFile:i,anyBlock:r,anyJsonKey:o}=e.probe;if(i&&x0(t,n,i).length>0)return!0;if(o)for(let s of x0(t,n,o.in))try{let a=JSON.parse(t.read(s));if(o.pointers.some(l=>gme(a,l)!==void 0))return!0}catch{}if(r){let s=new RegExp(`^\\s*(?:${r.blocks.map(yV).join("|")})\\s*\\{`,"m");for(let a of x0(t,n,r.in))try{if(s.test(t.read(a)))return!0}catch{}}return!1}function x0(e,t,n){let i=[],r=n.filter(o=>o.includes("*"));for(let o of n)!o.includes("*")&&e.stat(ze(t,o))==="file"&&i.push(ze(t,o));if(r.length>0){let o=r.map(s=>new RegExp(`^${s.split("*").map(yV).join("[^/]*")}$`));for(let s of e.list(t)??[])s.type==="file"&&o.some(a=>a.test(s.name))&&i.push(ze(t,s.name))}return i.sort()}function gme(e,t){let n=e;for(let i of t.split("/").slice(1)){let r=i.replace(/~1/g,"/").replace(/~0/g,"~");if(n===null||typeof n!="object"||!Object.prototype.hasOwnProperty.call(n,r))return;n=n[r]}return n}function yV(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function E0(e,t){let n=ze(t,"package.json");if(e.stat(n)==="file")try{let r=JSON.parse(e.read(n));for(let o of["dependencies","devDependencies","peerDependencies"]){let s=r[o];if(s&&typeof s=="object"&&Object.keys(s).some(bme))return!0}}catch{}let i=(r,o)=>{let s=e.list(r)??[];return s.some(a=>a.type==="file"&&hme.includes(a.name))?!0:o===yme?!1:s.some(a=>a.type==="dir"&&!ns(a.name)&&i(ze(r,a.name),o+1))};return i(t,0)}function bme(e){return e==="@intentius/chant"||e.startsWith("@intentius/chant-lexicon-")}function wme(){if(Yw)return Yw;let e=fa();return Yw=new e({allErrors:!0,strict:!0}).compile(oC),Yw}function vme(e,t){let n;try{n=JSON.parse(e)}catch(a){return{kinds:[],problems:[`${t}: the kinds file is not JSON (${a.message})`]}}let i=wme();if(!i(n)){let a=(i.errors??[]).map(l=>`${t}: ${l.instancePath||"the kinds file"} ${l.message??"is invalid"}`);return{kinds:[],problems:[...new Set(a)]}}let r=[],o=[],s=new Set;for(let a of n.kinds){if(mme.includes(a.name)){r.push(`${t}: kind ${a.name} is built in and can't be supplied by a package`);continue}if(s.has(a.name)){r.push(`${t}: kind ${a.name} is listed twice`);continue}s.add(a.name),o.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]}}:{}},precedence:a.precedence,shape:"member",outputs:{from:"declared",names:[...a.outputs??[]]},source:t,...a.graph?{graph:{lexicon:a.graph.lexicon,config:structuredClone(a.graph.config)}}:{},...a.fields?{fields:structuredClone(a.fields)}:{}});for(let l of Rme(a.fields??{}))r.push(`${t}: kind ${a.name} ${l}`)}return{kinds:o,problems:r}}function kme(e,t=S0){return pC(e,t)}function xme(e,t){let n=R0(e,"package.json"),i;try{i=JSON.parse($0(n,"utf-8"))}catch{return{kinds:[],problems:[`${t??e}: no readable package.json in ${e}`],file:void 0}}let r=t??(typeof i.name=="string"?i.name:e),o=kme(i);if(o===void 0)return{kinds:[],problems:[],file:void 0};if(typeof o!="string")return{kinds:[],problems:[`${r}: ${o.problem}`],file:void 0};let s=pme(e,o),a=dme(e,s);if(a.startsWith("..")||ume(a))return{kinds:[],problems:[`${r}: exports["${S0}"] points outside the package`],file:void 0};let l;try{l=$0(s,"utf-8")}catch{return{kinds:[],problems:[`${r}: exports["${S0}"] names ${o}, which does not exist`],file:s}}let c=vme(l,r),u=typeof i.name=="string"?i.name:void 0;for(let d of c.kinds)d.packageDir=e,d.graph&&u!==Xw(d.graph.lexicon)&&(c.problems.push(`${r}: kind ${d.name} reads its members with lexicon ${d.graph.lexicon}, which is ${Xw(d.graph.lexicon)}, and this package is ${u??"unnamed"}; the kind is kept, and workspace graph lists its members with kind-not-run`),delete d.graph);return{...c,file:s}}function Xw(e){return`@intentius/chant-lexicon-${e}`}function bV(e,t){let n=r=>r.replace(/\{(member|dir|workspace)\}/g,(o,s)=>t[s]),i=r=>typeof r=="string"?n(r):Array.isArray(r)?r.map(i):r!==null&&typeof r=="object"?Object.fromEntries(Object.entries(r).map(([o,s])=>[n(o),i(s)])):r;return i(e)}function A0(e,t){if(e.package){let n=ia(e.package,t);if(!n)return{problem:`pinned package ${e.package} is not installed; install it to read the kinds it supplies`};let i;try{i=JSON.parse($0(R0(n,"package.json"),"utf-8")).version}catch{i=void 0}return e.version&&i!==e.version?{problem:`${e.package} is pinned at ${e.version}, and ${String(i??"an unknown version")} is installed`}:{dir:n,source:e.package}}if(e.path){let n=R0(t,...e.path.split("/"));if(e.integrity){let i=fU(n,e.integrity,e.path);if(!i.ok)return{problem:i.message}}return{dir:n,source:e.path}}return null}function ma(e,t){let n=[],i=[],r=new Map,o=new Set;return e.forEach((s,a)=>{let l=A0(s,t);if(l===null)return;if("problem"in l){n.push({pin:a,message:l.problem});return}let{dir:c,source:u}=l,d=xme(c,u);for(let p of d.problems)n.push({pin:a,message:p});for(let p of d.kinds){let f=r.get(p.name);if(f){o.add(p.name),n.push({pin:a,message:`kind ${p.name} is supplied by both ${f} and ${u}; a kind name has one source`});continue}r.set(p.name,u),i.push(p)}}),{registry:mV(i.filter(s=>!o.has(s.name))),problems:n}}function $me(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 i;try{i=new RegExp(e.pattern,"u")}catch{return}if(!i.test(t))return`is ${JSON.stringify(t)}, which does not match ${e.pattern}`}}function Rme(e){let t=[],n=(i,r)=>{if(r.pattern!==void 0)try{new RegExp(r.pattern,"u")}catch{t.push(`declares field ${i} with pattern ${r.pattern}, which is not a regular expression`);return}if(r.default===void 0)return;let o=$me(r,r.default);o&&t.push(`declares field ${i} whose default ${o}`)};for(let[i,r]of Object.entries(e))if(r.type==="object")for(let[o,s]of Object.entries(r.properties))n(`${i}.${o}`,s);else n(i,r);return t}var _Be,S0,Qw,fme,fV,mme,hme,yme,Yw,co=v(()=>{"use strict";lU();Zt();mU();ju();ym();_Be=oC.$id,S0="./workspace-kinds",Qw="examples",fme="design",fV=[{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:"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:fme,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:Qw,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"}],mme=fV.map(e=>e.name);hme=["chant.config.ts","chant.config.json"],yme=4});function td(e){return String(e).replace(/~/g,"~0").replace(/\//g,"~1")}function ga(e,t){let n=[0];for(let b=0;b<e.length;b++)e.charCodeAt(b)===10&&n.push(b+1);let i=b=>{let w=0,x=n.length-1;for(;w<x;){let k=w+x+1>>1;n[k]<=b?w=k:x=k-1}return{line:w+1,column:b-n[w]+1}},r=new Map,o=new Map,s=new Map,a=e.charCodeAt(0)===65279?1:0,l=(b,w=a)=>{throw new ev(b,w)},c=b=>b>=e.length?"the end of the file":`${JSON.stringify(e[b])}`;function u(){for(;;){let b=e[a];if(b===" "||b===" "||b===`
|
|
70
|
+
`||b==="\r")a++;else if(b==="/"&&(e[a+1]==="/"||e[a+1]==="*"))if(t.jsonc||l("comments are only allowed in chant.workspace.jsonc"),e[a+1]==="/")for(;a<e.length&&e[a]!==`
|
|
71
|
+
`;)a++;else{let w=e.indexOf("*/",a+2);w<0&&l("unterminated /* comment"),a=w+2}else return}}function d(){let b=a;for(a++;;){a>=e.length&&l("unterminated string",b);let w=e.charCodeAt(a);if(w===34)break;w<32&&l("control character in a string; escape it",a),a+=w===92?2:1}a++;try{return JSON.parse(e.slice(b,a))}catch{return l("invalid escape in a string",b)}}function p(b){u(),r.set(b,a);let w=f(b);return o.set(b,a),w}function f(b){let w=e[a];if(w==="{")return g(b);if(w==="[")return h(b);if(w==='"')return d();for(let[k,R]of[["true",!0],["false",!1],["null",null]])if(e.startsWith(k,a))return a+=k.length,R;let x=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/.exec(e.slice(a,a+64));return x?(a+=x[0].length,Number(x[0])):l(`expected a value, found ${c(a)}`)}function g(b){let w={},x=new Set;if(a++,u(),e[a]==="}")return a++,w;for(;;){u(),e[a]!=='"'&&l(`expected a quoted key, found ${c(a)}`);let k=a,R=d();x.has(R)&&l(`duplicate key ${JSON.stringify(R)}`,k),x.add(R);let $=`${b}/${td(R)}`;if(s.set($,k),u(),e[a]!==":"&&l(`expected ":" after key ${JSON.stringify(R)}, found ${c(a)}`),a++,Object.defineProperty(w,R,{value:p($),enumerable:!0,writable:!0,configurable:!0}),u(),e[a]===","){if(a++,u(),e[a]==="}")return t.jsonc||l("trailing comma; only chant.workspace.jsonc allows one"),a++,w;continue}if(e[a]==="}")return a++,w;l(`expected "," or "}", found ${c(a)}`)}}function h(b){let w=[];if(a++,u(),e[a]==="]")return a++,w;for(;;){if(w.push(p(`${b}/${w.length}`)),u(),e[a]===","){if(a++,u(),e[a]==="]")return t.jsonc||l("trailing comma; only chant.workspace.jsonc allows one"),a++,w;continue}if(e[a]==="]")return a++,w;l(`expected "," or "]", found ${c(a)}`)}}try{u(),a>=e.length&&l("the file is empty");let b=p("");return u(),a<e.length&&l(`unexpected ${c(a)} after the value`),{ok:!0,value:b,locate(w,x){if(x&&s.has(w))return i(s.get(w));for(let k=w;;k=k.slice(0,k.lastIndexOf("/"))){let R=r.get(k);if(R!==void 0)return i(R);if(k==="")return i(0)}},span(w){let x=r.get(w),k=o.get(w);if(!(x===void 0||k===void 0))return{key:s.get(w)??null,start:x,end:k}}}}catch(b){if(!(b instanceof ev))throw b;return{ok:!1,message:b.message,location:i(b.offset)}}}var ev,nd=v(()=>{"use strict";ev=class extends Error{constructor(n,i){super(n);this.offset=i}}});function wV(){return"0.124.17"}var vV=v(()=>{"use strict"});var T0={};_e(T0,{CHANT_PACKAGE:()=>id,DECLARATION_FILES:()=>rd,DECLARATION_SCHEMA_ID:()=>Sme,DECLARATION_SCHEMA_VERSION:()=>Eme,DEFAULT_CI_WINDOW:()=>SV,DEFAULT_PUBLISH_BRANCH_PREFIX:()=>OV,DEFAULT_REPLICATE_REMOTE:()=>PV,DEFAULT_SHIP_ENV:()=>AV,DEFAULT_SHIP_GATE:()=>EV,DEFAULT_STATE_ROOT:()=>CV,DIAGRAM_TOOLS:()=>Cme,FACTORY_CHECK_KINDS:()=>_me,NAME_PATTERN:()=>Ame,PRINCIPAL_CLASSES:()=>Pme,REPLICATE_REF_CLASSES:()=>P0,REPLICATE_TRIGGERS:()=>O0,RESERVED_NAMES:()=>RV,WORKSPACE_ERROR_CODES:()=>lo,WRITE_VERBS:()=>Ome,WorkspaceReadError:()=>ve,boxServicesProblem:()=>NV,compareVersions:()=>_V,declaredDiagrams:()=>_0,declaredRecordKinds:()=>Ni,extensionsAt:()=>bm,findDeclarationDir:()=>I0,isInside:()=>xr,ownerOf:()=>jV,parseDeclaration:()=>TV,pinnedChant:()=>nv,readDeclaration:()=>Lt,readerVersion:()=>Xt,resolveGroups:()=>ha,rootExclusions:()=>rv});function Xt(){return kV??=wV(),kV}function _V(e,t){let n=C0.exec(e),i=C0.exec(t);if(!n||!i)throw new Error(`not a version: ${n?t:e}`);for(let r=1;r<=3;r++){let o=Number(n[r])-Number(i[r]);if(o!==0)return o}return n[4]===i[4]?0:n[4]===void 0?1:i[4]===void 0||n[4]<i[4]?-1:1}function Ime(){if(tv)return tv;let e=fa();return tv=new e({allErrors:!0,strict:!0}).compile(nC),tv}function Tme(e,t){let n=/#\/\$defs\/([A-Za-z]+)\//.exec(e.schemaPath)?.[1];if(e.keyword==="pattern"){let i=JSON.stringify(t);return n==="name"&&typeof t=="string"&&RV.includes(t)?`${i} is reserved; pick another name`:n==="name"?`${i} is not a valid name: use lowercase letters, digits and hyphens, starting with a letter or digit, at most 40 characters`:n==="kindName"?`${i} is not a valid kind or role name`:n==="dir"?`${i} is not a directory inside the workspace: use a relative path with / separators, and no . or .. segments`:n==="path"?`${i} is not a path inside the member or workspace: use a relative path with / separators, and no . or .. segments`:n==="glob"?`${i} is not a glob inside the workspace: use a relative pattern with / separators, and no . or .. segments`:n==="version"?`${i} is not a version such as 1.2.3`:`${i} is not allowed here`}if(e.keyword==="additionalProperties")return`unknown field ${JSON.stringify(e.params.additionalProperty)}; only fields named x-... may be added`;if(e.keyword==="required"){let i=String(e.params.missingProperty);return i==="because"&&e.instancePath.endsWith("/handWritten")?'a hand-written generated file needs "because", saying why it is kept by hand':i==="because"?'a member of kind other needs "because", saying why it is there':`missing required field ${JSON.stringify(i)}`}return e.keyword==="const"&&e.instancePath==="/schema"?"schema must be 1, the only declaration format this chant reads":e.message??"is invalid"}function IV(e,t){let n=e;for(let i of t.split("/").slice(1)){let r=i.replace(/~1/g,"/").replace(/~0/g,"~");if(n===null||typeof n!="object")return;n=n[r]}return n}function nv(e){if(!Array.isArray(e.pins))return;let t=e.pins.findIndex(n=>n!==null&&typeof n=="object"&&n.package===id&&typeof n.version=="string");return t<0?void 0:{version:e.pins[t].version,index:t}}function TV(e,t,n=Xt(),i={}){let r=ga(e,{jsonc:t.endsWith(".jsonc")});if(!r.ok)throw new ve("declaration-unparseable",r.message,{file:t,...r.location});let o=(F,Q=!1)=>({file:t,...r.locate(F,Q)}),s=r.value;if(s===null||typeof s!="object"||Array.isArray(s))throw new ve("declaration-invalid","the declaration must be a JSON object",o(""));let a=s,l=i.rootChant?nv(a):void 0;if(l&&l.version!==n)throw new ve("root-chant-required",`this declaration pins ${id} ${l.version}, and this is chant ${n}; the root's chant reads it, so install ${id}@${l.version} at the workspace root`,o(`/pins/${l.index}/version`));if(typeof a.minReader=="string"&&C0.test(a.minReader)&&_V(n,a.minReader)<0)throw new ve("reader-too-old",`this declaration needs chant ${a.minReader} or newer to read it, and this is chant ${n}`,o("/minReader"));let c=Ime();if(!c(s)){let F=(c.errors??[]).filter(we=>!Dme.has(we.keyword));F.sort((we,Ct)=>Ct.instancePath.split("/").length-we.instancePath.split("/").length);let Q=F[0]??c.errors[0],I=Q.keyword==="additionalProperties",B=I?`${Q.instancePath}/${td(String(Q.params.additionalProperty))}`:Q.instancePath,Z=Q.instancePath===""?"":` (at ${Q.instancePath})`,xe=F.length>1?`; ${F.length-1} more problem${F.length>2?"s":""} after this one`:"";throw new ve("declaration-invalid",`${Tme(Q,IV(s,Q.instancePath))}${Z}${xe}`,o(B,I))}let u=a.members.map((F,Q)=>{let I=`/members/${Q}`,B=(F.suppress??[]).map(Te=>({check:Te.check,because:Te.because}));if(F.kind===Qw){let Te=F.glob;return{type:"group",name:F.name,kind:Qw,globs:typeof Te=="string"?[Te]:[...Te],suppress:B,pointer:I,globLocation:r.locate(`${I}/glob`)}}let Z=(F.roles??[]).map(Te=>typeof Te=="string"?{name:Te,path:null}:{name:Te.name,path:Te.path??null}),xe=(F.generated??[]).map((Te,nt)=>({path:Te.path,generator:Te.generator,sources:[...Te.sources??[]],handWritten:Te.handWritten?{because:Te.handWritten.because}:null,pointer:`${I}/generated/${nt}`})),we=(F.links??[]).map((Te,nt)=>({member:Te.member,output:Te.output,kind:Te.kind??null,protocol:Te.protocol??null,pointer:`${I}/links/${nt}`})),Ct=xV(F.records,F.dir,F.name,`${I}/records`),at=$V(F.diagrams,F.name,`${I}/diagrams`),$e=Bme(F.box,`${I}/box`);return{type:"member",name:F.name,dir:F.dir,kind:F.kind,roles:Z,generated:xe,outputs:F.outputs===void 0?null:[...F.outputs],fields:F.fields===void 0?null:structuredClone(F.fields),links:we,records:Ct,diagrams:at,box:$e,upstream:F.upstream??null,because:F.because??null,travel:F.travel===!0,suppress:B,pointer:I}}),d=new Map;for(let F of u){let Q=d.get(F.name);if(Q)throw new ve("declaration-invalid",`the name ${JSON.stringify(F.name)} is already used by the entry at ${Q.pointer}`,o(`${F.pointer}/name`));d.set(F.name,F)}let p=u.filter(F=>F.type==="member"),f=new Map;for(let F of p){let Q=f.get(F.dir);if(Q)throw new ve("placement-invalid",`member ${F.name} has the same directory as member ${Q.name} (${F.dir})`,o(`${F.pointer}/dir`));f.set(F.dir,F)}for(let F of p){let Q=p.find(I=>I!==F&&I.dir!=="."&&xr(F.dir,I.dir));if(Q)throw new ve("placement-invalid",`member ${F.name} (${F.dir}) sits inside member ${Q.name} (${Q.dir}); only the root member "." may contain other members`,o(`${F.pointer}/dir`))}for(let F of p){let Q=new Map;for(let I of F.generated){let B=Q.get(I.path);if(B)throw new ve("declaration-invalid",`member ${F.name} lists the generated file ${I.path} twice; the first is at ${B.pointer}`,o(`${I.pointer}/path`));Q.set(I.path,I);let Z=F.dir==="."?I.path:`${F.dir}/${I.path}`,xe=p.find(we=>we!==F&&we.dir!=="."&&xr(we.dir,F.dir)&&xr(Z,we.dir));if(xe)throw new ve("placement-invalid",`member ${F.name} lists the generated file ${I.path}, which sits inside member ${xe.name} (${xe.dir}); list it there`,o(`${I.pointer}/path`))}}let g=xV(a.records,".",null,"/records"),h=new Map,b=new Map;for(let F of[...g,...p.flatMap(Q=>Q.records)]){let Q=h.get(F.path);if(Q)throw new ve("declaration-invalid",`the record kind ${F.path} is already declared at ${Q.pointer}`,o(`${F.pointer}/kind`));if(h.set(F.path,F),F.name===null)continue;let I=b.get(F.name);if(I)throw new ve("declaration-invalid",`the record kind name ${JSON.stringify(F.name)} is already given at ${I.pointer}`,o(`${F.pointer}/name`));b.set(F.name,F)}for(let F of p){let Q=new Map;for(let B of F.box?.capabilities??[]){let Z=Q.get(B.name);if(Z)throw new ve("declaration-invalid",`member ${F.name}'s box lists the capability ${B.name} twice; the first is at ${Z.pointer}`,o(`${B.pointer}/name`));Q.set(B.name,B)}let I=F.box?NV(F.name,F.box.services):null;if(I)throw new ve("declaration-invalid",I.message,o(I.pointer))}let w=Gme(p);if(w)throw new ve("declaration-invalid",w.message,o(w.pointer));let x=p.filter(F=>F.box?.replicate);if(x.length>1)throw new ve("declaration-invalid",`members ${x[0].name} and ${x[1].name} both declare replicate in their box block; a checkout's work in progress goes to one remote, so a workspace has one replicate policy`,o(x[1].box.replicate.pointer));let k=$V(a.diagrams,null,"/diagrams"),R=new Map;for(let F of[...k,...p.flatMap(Q=>Q.diagrams)]){let Q=R.get(F.name);if(Q)throw new ve("declaration-invalid",`the diagram name ${JSON.stringify(F.name)} is already used by the diagram at ${Q.pointer}`,o(`${F.pointer}/name`));R.set(F.name,F)}let $=Ume(a,p,o),_=Nme(a.writeScope,p,o),T=Mme(a.agents,p,o),C=Wme(p,T);if(C)throw new ve("declaration-invalid",C.message,o(C.pointer));let K=Lme(a.ci,o),O=(a.pins??[]).map(F=>({package:F.package??null,version:F.version??null,path:F.path??null,integrity:F.integrity??null})),pe={name:a.name,schema:a.schema,minReader:a.minReader??null,entries:u,members:p,groups:u.filter(F=>F.type==="group"),pins:O,checks:{...a.checks??{}},quorum:typeof a.quorum=="number"?a.quorum:null,records:g,diagrams:k,hosts:$,changes:Fme(a.changes),writeScope:_,agents:T,identity:jme(a.identity),ci:K,file:t};return DV.set(pe,s),pe}function bm(e,t){let n=IV(DV.get(e),t);return n===null||typeof n!="object"||Array.isArray(n)?{}:Object.fromEntries(Object.entries(n).filter(([i])=>i.startsWith("x-")))}function Nme(e,t,n){if(e===void 0)return null;let i=e,r={};for(let[o,s]of Object.entries(i)){let a=`/writeScope/${o}`,l=s.members===void 0||s.members==="*"?null:[...s.members];for(let[d,p]of(l??[]).entries())if(!t.some(f=>f.name===p))throw new ve("declaration-invalid",`writeScope.${o} names the member ${JSON.stringify(p)}, which the declaration does not declare; declared members: ${t.map(f=>f.name).join(", ")||"none"}`,n(`${a}/members/${d}`));let c=s.records===void 0?null:Object.fromEntries(Object.entries(s.records).map(([d,p])=>[d,[...p]])),u=(s.protected??[]).map(d=>typeof d=="string"?{path:d,except:[]}:{path:d.path,except:[...d.except??[]]});r[o]={members:l,records:c,protected:u,pointer:a}}return r}function jme(e){if(e===void 0)return null;let t=e,n={};for(let[i,r]of Object.entries(t.gates??{}))n[i]={gate:i,class:r.class??null,pointer:`/identity/gates/${i.replace(/~/g,"~0").replace(/\//g,"~1")}`};return{attribution:t.attribution??"any",gates:n}}function Lme(e,t){if(e===void 0)return null;let n=e;if(n.green===void 0)return{green:null};let i=n.green,r=Object.entries(i.phases).map(([o,s])=>({name:o,runs:[...Array.isArray(s)?s:s.runs],skipped:Array.isArray(s)?"fail":s.skipped??"fail",pointer:`/ci/green/phases/${td(o)}`}));for(let[o,s]of i.require.entries())if(!r.some(a=>a.name===s))throw new ve("declaration-invalid",`ci.green.require names the phase ${JSON.stringify(s)}, which ci.green.phases does not declare; declared phases: ${r.map(a=>a.name).join(", ")}`,t(`/ci/green/require/${o}`));return{green:{branch:i.branch,window:i.window??SV,phases:r,require:[...i.require],pointer:"/ci/green"}}}function Mme(e,t,n){let i=(e??[]).map((s,a)=>{let l=s.members!==void 0?[...s.members]:[s.member];return{name:s.name,members:l,member:l[0],principals:[...s.principals??[]],pointer:`/agents/${a}`,listed:s.members!==void 0}}),r=new Map,o=new Map;for(let{listed:s,...a}of i){let l=r.get(a.name);if(l)throw new ve("declaration-invalid",`the agent name ${JSON.stringify(a.name)} is already used by the agent at ${l.pointer}`,n(`${a.pointer}/name`));r.set(a.name,a);for(let[c,u]of a.members.entries())if(!t.some(d=>d.name===u))throw new ve("declaration-invalid",`agent ${a.name} is bound to ${JSON.stringify(u)}, which is not a declared member; an agent session is bound to members, not an example group`,n(s?`${a.pointer}/members/${c}`:`${a.pointer}/member`));for(let[c,u]of a.principals.entries()){let d=o.get(u);if(d)throw new ve("declaration-invalid",`the principal ${JSON.stringify(u)} is already listed by agent ${d.name}`,n(`${a.pointer}/principals/${c}`));o.set(u,a)}}return[...r.values()]}function Fme(e){return e===void 0?null:{severity:e.severity??"warn",ignore:[...e.ignore??[]]}}function xV(e,t,n,i){return(e??[]).map((r,o)=>({kind:r.kind,path:t==="."?r.kind:`${t}/${r.kind}`,name:r.name??null,member:n,pointer:`${i}/${o}`}))}function $V(e,t,n){return(e??[]).map((i,r)=>({name:i.name,title:i.title,source:i.source??null,render:i.render??null,renderer:{tool:i.renderer.tool,version:i.renderer.version,args:[...i.renderer.args??[]]},sourceHash:i.sourceHash??null,member:t,pointer:`${n}/${r}`}))}function Bme(e,t){if(e===void 0)return null;let n=e,i=n.factory,r=n.listing,o=n.replicate;return{capabilities:(n.capabilities??[]).map((s,a)=>({name:s.name,broker:s.broker??null,scope:[...s.scope??[]],pointer:`${t}/capabilities/${a}`})),isolation:n.host===void 0?null:{host:n.host,slot:n.slot,ports:{...n.ports??{}},state:{...n.state??{}},cookies:[...n.cookies??[]]},intent:n.intent??null,services:(n.services??[]).map((s,a)=>({name:s.name,cmd:s.cmd,needs:[...s.needs??[]],httpPort:s.httpPort??null,duration:s.duration??null,health:s.health??null,optional:s.optional??!1,pointer:`${t}/services/${a}`})),factory:i===void 0?null:{builds:[...i.builds],check:i.check===void 0?null:typeof i.check=="string"?{run:i.check,kind:"test"}:{run:i.check.run,kind:i.check.kind??"test"},checks:i.checks??null,builders:i.builders??null,tiers:(i.tiers??[]).map(s=>({tier:s.tier,agent:s.agent,kinds:s.kinds===void 0?null:[...s.kinds],session:s.session??null})),publish:i.publish===void 0?null:{forge:i.publish.forge??"github",repo:i.publish.repo,base:i.publish.base??null,branchPrefix:i.publish.branchPrefix??OV,head:i.publish.head??null},pointer:`${t}/factory`},listing:r===void 0?null:{published:r.published??!0,title:r.title??"",line:r.line??"",cover:r.cover??null},publisher:n.publisher??null,ship:n.ship===void 0?null:{op:n.ship.op,gate:n.ship.gate??EV,env:n.ship.env??AV,bookkeeping:(n.ship.bookkeeping??[]).map(s=>s.replace(/^\.\//,"").replace(/\/+$/,"")),pointer:`${t}/ship`},replicate:o===void 0?null:{remote:o.remote??PV,refs:P0.filter(s=>(o.refs??P0).includes(s)),on:O0.filter(s=>(o.on??O0).includes(s)),every:o.every??null,pointer:`${t}/replicate`},pointer:t}}function Gme(e){let t=e.filter(s=>s.box?.factory);if(t.length>1)return{message:`members ${t[0].name} and ${t[1].name} both declare a factory in their box block; a workspace has one factory, so an orchestrator reads one`,pointer:t[1].box.factory.pointer};let n=t[0]?.box?.factory;if(!n)return null;let i=()=>e.map(s=>s.name).join(", "),r=n.builds.findIndex(s=>!e.some(a=>a.name===s));if(r>=0)return{message:`the factory builds ${JSON.stringify(n.builds[r])}, which is not a declared member; declared members: ${i()}`,pointer:`${n.pointer}/builds/${r}`};if(n.builders!==null&&!e.some(s=>s.name===n.builders))return{message:`the factory's builders names ${JSON.stringify(n.builders)}, which is not a declared member; declared members: ${i()}`,pointer:`${n.pointer}/builders`};if(n.tiers.length>0&&n.builders===null)return{message:"the factory declares tiers and no builders; tiers name agents the builders member declares, so name it",pointer:`${n.pointer}/tiers`};let o=new Map;for(let[s,a]of n.tiers.entries())for(let l of a.kinds??[null]){let c=`${a.tier}\0${l??""}`,u=o.get(c);if(u!==void 0){let d=l===null?"with no kinds":`for kind ${l}`;return{message:`tiers/${u} and tiers/${s} both name a builder at tier ${a.tier} ${d}; a tier has one builder per kind, so one entry answers it`,pointer:`${n.pointer}/tiers/${s}`}}o.set(c,s)}return null}function Wme(e,t){let n=e.find(i=>i.box?.factory)?.box?.factory;if(!n)return null;for(let[i,r]of n.tiers.entries())if(r.session!==null&&!t.some(o=>o.name===r.session)){let o=t.map(s=>s.name).join(", ")||"none";return{message:`tiers/${i} names the session ${JSON.stringify(r.session)}, which is not a declared agent session; declared sessions: ${o}`,pointer:`${n.pointer}/tiers/${i}/session`}}return null}function NV(e,t){let n=new Map;for(let o of t){let s=n.get(o.name);if(s)return{message:`member ${e}'s box declares the service ${o.name} twice; the first is at ${s.pointer}`,pointer:`${o.pointer}/name`};n.set(o.name,o)}let i;for(let o of t)if(o.httpPort!==null){if(i)return{message:`member ${e}'s box gives both ${i.name} (port ${i.httpPort}) and ${o.name} (port ${o.httpPort}) an httpPort, and the supervisor routes the sprite's URL to one service`,pointer:`${o.pointer}/httpPort`};i=o}for(let o of t){let s=o.needs.findIndex(a=>!n.has(a));if(s>=0){let a=t.map(l=>l.name).join(", ");return{message:`member ${e}'s box service ${o.name} needs ${JSON.stringify(o.needs[s])}, which the block does not declare; declared services: ${a}`,pointer:`${o.pointer}/needs/${s}`}}}let r=zme(t);if(r){let o=n.get(r[0]);return{message:`member ${e}'s box services need each other in a cycle: ${r.join(" -> ")}`,pointer:`${o.pointer}/needs`}}return null}function zme(e){let t=new Map(e.map(r=>[r.name,r])),n=new Map,i=(r,o)=>{let s=n.get(r);if(s==="done")return null;if(s==="visiting")return[...o.slice(o.indexOf(r)),r];n.set(r,"visiting");for(let a of t.get(r)?.needs??[]){let l=i(a,[...o,r]);if(l)return l}return n.set(r,"done"),null};for(let r of e){let o=i(r.name,[]);if(o)return o}return null}function Ume(e,t,n){let i=(e.hosts??[]).map((s,a)=>({name:s.name,ports:{...s.ports},stateRoot:s.stateRoot??null,pointer:`/hosts/${a}`})),r=(s,a)=>new ve("declaration-invalid",s,n(a)),o=new Map;for(let s of i){let a=o.get(s.name);if(a)throw r(`the host name ${JSON.stringify(s.name)} is already used by the host at ${a.pointer}`,`${s.pointer}/name`);if(o.set(s.name,s),s.ports.from>s.ports.to)throw r(`host ${s.name}'s port range starts at ${s.ports.from}, after its end ${s.ports.to}`,`${s.pointer}/ports`)}for(let s of t){let a=s.box?.isolation;if(!a)continue;let l=s.box.pointer,c=o.get(a.host);if(!c){let g=i.map(h=>h.name).join(", ")||"none are declared";throw r(`member ${s.name}'s box names the host ${JSON.stringify(a.host)}, which hosts does not declare; declared hosts: ${g}`,`${l}/host`)}let{from:u,to:d,perBox:p}=c.ports,f=u+(a.slot+1)*p-1;if(f>d){let g=Math.floor((d-u+1)/p);throw r(`member ${s.name}'s box has slot ${a.slot} on host ${c.name}, which needs ports ${u+a.slot*p} to ${f}, past the end of the host's range (${d}); the range holds ${g} slot${g===1?"":"s"}`,`${l}/slot`)}for(let[g,h]of Object.entries(a.ports))if(h>=p)throw r(`member ${s.name}'s box gives port ${g} offset ${h}, and host ${c.name} gives each box ${p} port${p===1?"":"s"} (offsets 0 to ${p-1})`,`${l}/ports/${td(g)}`)}return i}function Ni(e){return[...e.records,...e.members.flatMap(t=>t.records)]}function _0(e){return[...e.diagrams,...e.members.flatMap(t=>t.diagrams)]}function xr(e,t){return t==="."?!0:e===t||e.startsWith(`${t}/`)}function Lt(e,t="",n={}){let i=rd.map(r=>ze(t,r)).filter(r=>e.stat(r)==="file");if(i.length===0)throw new ve("declaration-missing",`no ${rd.join(" or ")} in ${t||"the workspace root"}${e.label}`);if(i.length>1)throw new ve("declaration-ambiguous",`both ${i.join(" and ")} exist${e.label}; keep one of them`,{file:i[1],line:1,column:1});return TV(e.read(i[0]),i[0],Xt(),n)}function I0(e,t){for(let n=t;;n=n.includes("/")?n.slice(0,n.lastIndexOf("/")):""){if(rd.some(i=>e.stat(ze(n,i))==="file"))return n;if(n==="")return}}function ha(e,t){let n=o=>({file:e.file,...o.globLocation}),i=new Map,r=[];for(let o of e.groups){let s=[...new Set(o.globs.flatMap(c=>aU(t,c)))].sort(),a=[],l=[];for(let c of s){if(!E0(t,c)){l.push(c);continue}let u=p=>new ve("placement-invalid",`group ${o.name} matches ${c}, ${p}`,n(o));for(let p of e.members)if(p.dir!=="."){if(p.dir===c)throw u(`which is member ${p.name}'s directory; a match is never a member`);if(xr(p.dir,c))throw u(`which contains member ${p.name} (${p.dir})`);if(p.kind==="workspace"&&xr(c,p.dir))throw u(`which sits inside the nested workspace ${p.name}; that workspace declares its own examples`)}let d=i.get(c);if(d)throw u(`which group ${d.name} also matches`);i.set(c,o),a.push(c)}r.push({group:o,matches:a,skipped:l})}return r}function jV(e,t,n){for(let r of t){let o=r.matches.find(s=>xr(n,s));if(o)return{group:r.group,match:o}}let i;for(let r of e.members)xr(n,r.dir)&&(!i||i.dir==="."||r.dir!=="."&&r.dir.length>i.dir.length)&&(i=r);return i?{member:i}:void 0}function rv(e,t){let n=[];for(let i of e.members)i.dir!=="."&&n.push({dir:i.dir,owner:i.name});for(let i of t)for(let r of i.matches)e.members.some(o=>o.dir!=="."&&xr(r,o.dir))||n.push({dir:r,owner:i.group.name});return n.sort((i,r)=>i.dir<r.dir?-1:i.dir>r.dir?1:0)}var Sme,rd,Eme,RV,Ame,lo,ve,Pme,Ome,SV,Cme,EV,AV,P0,O0,PV,_me,OV,CV,id,kV,C0,tv,Dme,DV,_t=v(()=>{"use strict";nU();cU();co();nd();Zt();ym();vV();Sme=nC.$id,rd=["chant.workspace.json","chant.workspace.jsonc"],Eme=1,RV=["_workspace","_members"],Ame=/^[a-z0-9][a-z0-9-]{0,39}$/,lo=["declaration-missing","declaration-ambiguous","declaration-unparseable","declaration-invalid","placement-invalid","reader-too-old","root-chant-required","not-a-git-repository","revision-unknown"],ve=class extends Error{constructor(n,i,r){super(i);this.code=n;this.location=r;this.name="WorkspaceReadError"}describe(){let n=this.location;return n?`${n.file}:${n.line}:${n.column}: ${this.message}`:this.message}},Pme=["human","agent","runner","service"],Ome=["new","amend","review","close"],SV="24h",Cme=["d2","mermaid","graphviz","excalidraw"],EV="ship",AV="box",P0=["work","kept","wip","ledger"],O0=["save","release"],PV="origin",_me=["test","build","lint","plan","conformance"],OV="chant/work/",CV="${XDG_STATE_HOME}/chant/boxes",id="@intentius/chant";C0=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?$/;Dme=new Set(["if","then","else","oneOf","anyOf"]);DV=new WeakMap});import{existsSync as Hme}from"node:fs";import{dirname as Vme,join as qme,relative as Kme,resolve as Jme,sep as Zme}from"node:path";function j0(e){return e.map(t=>`${LV}/${t}/`).join("")}function ii(e){let t=Jme(e),n=D0.get(t);return n||(n=Xme(t),D0.set(t,n),n.catch(()=>D0.delete(t))),n}function Yme(e,t){let n=Kme(e,t);return n===""?"":n.split(Zme).join("/")}async function Xme(e){let t=gr(e);return t?FV(t.dir,e):MV}async function FV(e,t){let{readDeclaration:n,resolveGroups:i,ownerOf:r,WorkspaceReadError:o}=await Promise.resolve().then(()=>(_t(),T0)),{workingTree:s}=await Promise.resolve().then(()=>(Zt(),iC)),a;try{let d=s(e),p=n(d),f=r(p,i(p,d),Yme(e,t));a=f&&"member"in f&&f.member.dir!=="."?[f.member.name]:[]}catch(d){throw d instanceof o?new N0(`cannot place this project's lifecycle ledger: ${d.describe()}. A project inside a workspace writes under ${LV}/<member>/ on chant/lifecycle, and chant does not guess the member. Fix the declaration and retry.`):d}let l=MV,c=Vme(e);if(c!==e&&!Hme(qme(e,".git"))){let d=gr(c);d&&(l=await FV(d.dir,e))}let u=[...l.members,...a];return{members:u,prefix:j0(u)}}var LV,MV,N0,D0,ya=v(()=>{"use strict";Si();LV="_members",MV={members:[],prefix:""};N0=class extends Error{constructor(t){super(t),this.name="MemberLedgerError"}},D0=new Map});function L0(e){return e===od}var od,iv=v(()=>{"use strict";od="recorded locally (no remote for chant/lifecycle)"});var H0={};_e(H0,{LifecycleLedgerUnreadableError:()=>wm,RefCASConflictError:()=>Vt,StaleLifecycleBranchError:()=>sd,StaleLockError:()=>Mc,appendReleaseRecordLine:()=>VV,deleteRefCAS:()=>ld,describeLifecyclePush:()=>z0,fetchLifecycle:()=>ZV,fetchLifecycleStatus:()=>wa,fetchRef:()=>lge,fetchRefInto:()=>eq,fetchRefIntoStatus:()=>sv,getHeadCommit:()=>av,getRemoteLifecycleBranchSha:()=>JV,gitLedgerReadPort:()=>pge,ledgerDir:()=>oi,listFilesInDir:()=>Bc,listLedgerEnvironments:()=>KV,listLedgerTrees:()=>W0,listSnapshots:()=>oge,pushLifecycle:()=>Gc,pushLifecycleReport:()=>ba,pushLifecycleStatus:()=>ad,pushRef:()=>cge,pushRefStatus:()=>vm,readBlobBySha:()=>fn,readBlobFromPath:()=>rn,readEnvironmentSnapshots:()=>ige,readPathSha:()=>$r,readRefSha:()=>Wc,readReleaseLedgerLines:()=>qV,readSnapshot:()=>HV,readSnapshotAt:()=>rge,requireLifecycleLedger:()=>si,snapshotStorageKey:()=>zV,updateRefCAS:()=>cd,writeBlob:()=>U0,writeBlobToPath:()=>An,writeLedgerFiles:()=>G0,writeSnapshot:()=>UV});async function oi(e,t){return`${await Qme(t)}${e}`}async function Qme(e){return e?.ledgerPrefix!==void 0?e.ledgerPrefix:e?.member!==void 0?j0((typeof e.member=="string"?[e.member]:[...e.member]).filter(t=>t!==".")):(await ii(e?.cwd??process.cwd())).prefix}async function nge(e){let t=ot();if((await t.spawn(["git","var","GIT_COMMITTER_IDENT"],{cwd:e,env:ji})).exitCode===0)return[];let i=[];for(let[r,o,s]of[["user.name","CHANT_LIFECYCLE_COMMITTER_NAME",ege],["user.email","CHANT_LIFECYCLE_COMMITTER_EMAIL",tge]]){let a=await t.spawn(["git","config","--get",r],{cwd:e,env:ji});a.exitCode===0&&a.stdout.trim()!==""||i.push("-c",`${r}=${process.env[o]?.trim()||s}`)}return i}function M0(e,t,n){return new Error(`cannot write ${t} on the ${yt} branch: ${e} failed: ${(n??"").trim()}`)}async function An(e,t,n,i,r){let o=await oi(e,r);return G0([{path:`${o}/${t}`,content:n,...r?.expectPriorPathSha!==void 0?{expectPriorSha:r.expectPriorPathSha}:{}}],i,r)}async function G0(e,t,n){let i=ot(),r=n?.cwd;if(e.length===0)throw new Error("writeLedgerFiles needs at least one file");let o=e[0].path;for(let u of e){let d=u.path.split("/");if(d.length<2||d.some(p=>p===""))throw new Error(`cannot write ${u.path} on the ${yt} branch: a ledger path is <dir>/<file>`)}let s=[];for(let u of e){let d=await i.spawn(["git","hash-object","-w","--stdin"],{cwd:r,stdin:u.content});if(d.exitCode!==0)throw M0("git hash-object",u.path,d.stderr);s.push({path:u.path,sha:d.stdout.trim()})}let a=await nge(r);await Fc(r)===null&&await si({...r?{cwd:r}:{}});let l=new Map(e.map(u=>[u.path,u.expectPriorSha])),c;for(let u=1;u<=WV;u++){let d=await Fc(r),p=new Map,f=async R=>{let $=p.get(R);return $||($=d?await uge(d,R,r):new Map,p.set(R,$)),$};for(let R of s){let{dir:$,name:_}=BV(R.path),T=(await f($)).get(_),C=T?.type==="blob"?T.sha:null,K=l.get(R.path);if(K!==void 0&&C!==K)throw c??new Vt(`refs/heads/${yt}`,K,"target path changed concurrently");l.set(R.path,C)}for(let R of s){let{dir:$,name:_}=BV(R.path);(await f($)).set(_,{mode:"100644",type:"blob",sha:R.sha});for(let T=$;T!=="";T=F0(T))await f(F0(T))}let g=[...p.keys()].sort((R,$)=>GV($)-GV(R)||(R<$?-1:1)),h="";for(let R of g){let $=[...p.get(R)].map(([C,K])=>`${K.mode} ${K.type} ${K.sha} ${C}`).join(`
|
|
72
|
+
`),_=await i.spawn(["git","mktree"],{cwd:r,stdin:`${$}
|
|
73
|
+
`});if(_.exitCode!==0)throw M0(`git mktree (${R===""?"root":R})`,o,_.stderr);let T=_.stdout.trim();R===""?h=T:p.get(F0(R)).set(dge(R),{mode:"040000",type:"tree",sha:T})}let b=d,w=b?["-p",b]:[],x=await i.spawn(["git",...a,"commit-tree",...w,"-m",t,h],{cwd:r});if(x.exitCode!==0)throw M0("git commit-tree",o,x.stderr);let k=x.stdout.trim();try{return await cd(`refs/heads/${yt}`,k,b,{cwd:r}),k}catch(R){if(!(R instanceof Vt))throw R;c=R}}throw c}async function rn(e,t,n){let i=ot(),r=await oi(e,n),o=await i.spawn(["git","show",`${yt}:${r}/${t}`],{cwd:n?.cwd});return o.exitCode!==0?null:o.stdout}async function $r(e,t,n){let i=ot(),r=await oi(e,n),o=await i.spawn(["git","rev-parse","--verify",`${yt}:${r}/${t}`],{cwd:n?.cwd});return o.exitCode!==0?null:o.stdout.trim()||null}function zV(e,t){return t?`${t}__${e}`:e}async function UV(e,t,n,i){return An(e,`${t}.json`,n,"State snapshot",i)}async function HV(e,t,n){return rn(e,`${t}.json`,n)}async function rge(e,t,n,i){let r=ot(),o=await oi(e,i),s=await r.spawn(["git","show",`${n}:${o}/${t}.json`],{cwd:i?.cwd});return s.exitCode!==0?null:s.stdout}async function VV(e,t,n){let i="releases.jsonl",r;for(let o=1;o<=WV;o++)try{let s=await $r(e,i,n),a=s?await fn(s,n):null,l=`${a?`${a.replace(/\n$/,"")}
|
|
74
|
+
`:""}${t}
|
|
75
|
+
`;return await An(e,i,l,"Release record",{...n,expectPriorPathSha:s})}catch(s){if(!(s instanceof Vt))throw s;r=s}throw r}async function qV(e,t){let n=await rn(e,"releases.jsonl",t);return n?n.split(`
|
|
76
|
+
`).map(i=>i.trim()).filter(Boolean):[]}async function KV(e){let t=[];for(let n of await W0(e))await rn(n,"releases.jsonl",e)&&t.push(n);return t.sort()}async function W0(e){if(!await Fc(e?.cwd))return[];let n=ot(),i=await oi("",e),r=await n.spawn(["git","ls-tree","--full-tree",i===""?yt:`${yt}:${i}`],{cwd:e?.cwd});if(r.exitCode!==0)return[];let o=[];for(let s of r.stdout.trim().split(`
|
|
77
|
+
`).filter(Boolean)){let a=s.match(/^(\d+)\s+(\w+)\s+([0-9a-f]+)\t(.+)$/);a&&a[2]==="tree"&&o.push(a[4])}return o}async function Bc(e,t){if(!await Fc(t?.cwd))return[];let i=ot(),r=await oi(e,t),o=await i.spawn(["git","ls-tree","--full-tree","--name-only",`${yt}:${r}/`],{cwd:t?.cwd});return o.exitCode!==0?[]:o.stdout.trim().split(`
|
|
78
|
+
`).filter(Boolean)}async function ige(e,t){let n=ot(),i=new Map,r=await oi(e,t),o=await n.spawn(["git","ls-tree","--full-tree","--name-only",`${yt}:${r}/`],{cwd:t?.cwd});if(o.exitCode!==0)return i;let s=o.stdout.trim().split(`
|
|
79
|
+
`).filter(Boolean);for(let a of s)if(a.endsWith(".json")){let l=a.replace(/\.json$/,""),c=await HV(e,l,t);c&&i.set(l,c)}return i}async function oge(e){let t=ot(),n=await oi("",e),i=await t.spawn(["git","log","--format=%H %aI %s",yt,...n===""?[]:["--",`:(top)${n}`]],{cwd:e?.cwd});return i.exitCode!==0?[]:i.stdout.trim().split(`
|
|
80
|
+
`).filter(Boolean).map(r=>{let[o,s,...a]=r.split(" ");return{commit:o,date:s,message:a.join(" ")}})}async function JV(e,t){let n=ot(),i=`refs/remotes/${e}/${yt}`,r=await n.spawn(["git","rev-parse","--verify",i],{cwd:t?.cwd});return r.exitCode!==0?null:r.stdout.trim()||null}async function B0(e,t,n){await ot().spawn(["git","update-ref",`refs/remotes/${e}/${yt}`,t],{cwd:n,env:ji})}async function ad(e){let t=ot(),n=e?.cwd,i=await XV(n);if(i===null)return{status:"no-remote"};if("failed"in i)return{status:"failed",remote:"(unknown)",stderr:i.stderr};let{remote:r}=i,o=await JV(r,e),s=`refs/heads/${yt}:${o??""}`,a=await Fc(n),l=await t.spawn(["git","push",`--force-with-lease=${s}`,r,`${yt}:${yt}`],{cwd:n,env:ji});if(l.exitCode!==0){let c=(l.stderr??"").trim();return c.includes("stale info")||c.includes("rejected")||c.includes("non-fast-forward")?{status:"stale",remote:r,expected:o,stderr:c}:{status:"failed",remote:r,stderr:c}}return a&&await B0(r,a,n),{status:"pushed",remote:r,commit:a??""}}async function Gc(e){let t=await ad(e);if(t.status==="stale")throw new sd(t.expected,t.stderr);return t.status==="pushed"}function z0(e){let t=n=>n?`; git said: ${n.split(`
|
|
81
|
+
`).find(i=>i.trim())??n}`:"";switch(e.status){case"pushed":return null;case"no-remote":return`this repository has no remote, so ${yt} stays local`;case"stale":return`"${e.remote}" holds ${yt} commits this checkout has not fetched, so the push was refused; fetch ${yt} and write again${t(e.stderr)}`;case"failed":return`the push of ${yt} to "${e.remote}" failed${t(e.stderr)}`}}async function ba(e){try{let t=await ad(e);switch(t.status){case"pushed":return{pushed:!0};case"no-remote":return{pushed:!1,pushWarning:od};case"stale":return{pushed:!1,pushWarning:new sd(t.expected,t.stderr).message};case"failed":return{pushed:!1,pushWarning:z0(t)??"the push did not land"}}}catch(t){return{pushed:!1,pushWarning:t instanceof Error?t.message:String(t)}}}async function ZV(e){return(await wa(e)).status==="fetched"}async function XV(e){let n=await ot().spawn(["git","remote"],{cwd:e,env:ji});if(n.exitCode!==0)return{failed:!0,stderr:(n.stderr??"").trim()};let i=n.stdout.trim().split(`
|
|
82
|
+
`).map(r=>r.trim()).filter(Boolean);return i.length===0?null:{remote:i.includes("origin")?"origin":i[0]}}async function wa(e){let t=ot(),n=e?.cwd,i=await XV(n);if(i===null)return{status:"no-remote"};if("failed"in i)return{status:"unreachable",remote:"(unknown)",stderr:i.stderr};let{remote:r}=i,o=await t.spawn(["git","fetch",r,`${yt}:${yt}`],{cwd:n,env:ji});if(o.exitCode===0){let u=await Fc(n);return u&&await B0(r,u,n),{status:"fetched"}}let s=(o.stderr??"").trim();if(YV.test(s))return{status:"absent",remote:r};if(!sge.test(s))return{status:"unreachable",remote:r,stderr:s};let a=await t.spawn(["git","fetch","--force",r,`${yt}:${ov}`],{cwd:n,env:ji});if(a.exitCode!==0)return{status:"unreachable",remote:r,stderr:(a.stderr??"").trim()||s};let l=await t.spawn(["git","merge-base","--is-ancestor",ov,`refs/heads/${yt}`],{cwd:n,env:ji}),c=l.exitCode===0?(await t.spawn(["git","rev-parse","--verify",ov],{cwd:n,env:ji})).stdout.trim():"";return await t.spawn(["git","update-ref","-d",ov],{cwd:n,env:ji}),l.exitCode===0?(c&&await B0(r,c,n),{status:"ahead",remote:r}):{status:"diverged",remote:r,stderr:s}}async function si(e){let t=await Fc(e?.cwd)!==null,n=await wa(e);if(n.status==="diverged")throw new wm("diverged",n.remote,n.stderr,`has diverged from the copy on "${n.remote}" \u2014 neither contains the other`);if(n.status==="unreachable"&&!t)throw new wm("unreachable",n.remote,n.stderr,`is not in this checkout and could not be fetched from "${n.remote}"`)}async function Wc(e,t){let i=await ot().spawn(["git","rev-parse","--verify",e],{cwd:t?.cwd});return i.exitCode!==0?null:i.stdout.trim()||null}async function QV(e,t,n,i){let r=n.match(age);return r?new Mc(e,r[1],n):await Wc(e,i)!==t?new Vt(e,t,n):new Error(`git update-ref failed for ref "${e}": ${n.trim()}`)}async function cd(e,t,n,i){let o=await ot().spawn(["git","update-ref",e,t,n??""],{cwd:i?.cwd});if(o.exitCode!==0)throw await QV(e,n,o.stderr??"",i)}async function ld(e,t,n){let r=await ot().spawn(["git","update-ref","-d",e,t],{cwd:n?.cwd});if(r.exitCode!==0)throw await QV(e,t,r.stderr??"",n)}async function U0(e,t){let i=await ot().spawn(["git","hash-object","-w","--stdin"],{cwd:t?.cwd,stdin:e});if(i.exitCode!==0)throw new Error(`git hash-object failed: ${i.stderr}`);return i.stdout.trim()}async function fn(e,t){let i=await ot().spawn(["git","cat-file","blob",e],{cwd:t?.cwd});return i.exitCode!==0?null:i.stdout}async function cge(e,t){return await vm(e,t)==="pushed"}async function vm(e,t){let n=ot(),i=await n.spawn(["git","remote"],{cwd:t?.cwd});if(i.exitCode!==0||!i.stdout.trim())return"no-remote";let r=i.stdout.trim().split(`
|
|
83
|
+
`)[0],o;if(t?.expect!==void 0)o=t.expect;else{let u=`refs/remotes/${r}/${e.replace(/^refs\//,"")}`,d=await n.spawn(["git","rev-parse","--verify",u],{cwd:t?.cwd});o=d.exitCode===0?d.stdout.trim():null}let s=`${e}:${o??""}`,a=await Wc(e,t);if(a===null&&o===null)return"pushed";let l=a===null?`:${e}`:`${e}:${e}`;return(await n.spawn(["git","push",`--force-with-lease=${s}`,r,l],{cwd:t?.cwd})).exitCode===0?"pushed":"rejected"}async function eq(e,t,n){return await sv(e,t,n)==="fetched"}async function sv(e,t,n){let i=ot(),r=await i.spawn(["git","remote"],{cwd:n?.cwd});if(r.exitCode!==0||!r.stdout.trim())return"no-remote";let o=r.stdout.trim().split(`
|
|
84
|
+
`)[0],s=await i.spawn(["git","fetch",o,`+${e}:${t}`],{cwd:n?.cwd,env:ji});return s.exitCode===0?"fetched":YV.test(s.stderr??"")?"missing":"failed"}async function lge(e,t){return eq(e,e,t)}async function av(e){let n=await ot().spawn(["git","rev-parse","HEAD"],{cwd:e?.cwd});if(n.exitCode!==0)throw new Error(`git rev-parse HEAD failed: ${n.stderr}`);return n.stdout.trim()}async function Fc(e){let n=await ot().spawn(["git","rev-parse","--verify",`refs/heads/${yt}`],{cwd:e});return n.exitCode!==0?null:n.stdout.trim()}async function uge(e,t,n){let i=ot(),r=new Map,o=await i.spawn(["git","ls-tree","--full-tree",t===""?e:`${e}:${t}/`],{cwd:n});if(o.exitCode!==0)return r;for(let s of o.stdout.split(`
|
|
85
|
+
`)){let a=s.match(/^(\d+)\s+(\w+)\s+([0-9a-f]+)\t(.+)$/);a&&r.set(a[4],{mode:a[1],type:a[2],sha:a[3]})}return r}function BV(e){let t=e.lastIndexOf("/");return{dir:e.slice(0,t),name:e.slice(t+1)}}function F0(e){let t=e.lastIndexOf("/");return t<0?"":e.slice(0,t)}function dge(e){return e.slice(e.lastIndexOf("/")+1)}function GV(e){return e===""?0:e.split("/").length}function pge(e){return{read:(t,n)=>rn(t,n,e),list:t=>Bc(t,e),trees:()=>W0(e)}}var yt,ege,tge,WV,sd,YV,sge,ji,ov,wm,Vt,Mc,age,$t=v(()=>{"use strict";no();ya();iv();yt="chant/lifecycle";ege="chant",tge="chant@localhost";WV=5;sd=class extends Error{constructor(t,n){super(`chant/lifecycle remote branch has moved since this run started \u2014 another snapshot was pushed concurrently. git stderr: ${n.trim()}`),this.name="StaleLifecycleBranchError",this.expected=t}};YV=/couldn't find remote ref|no such ref was fetched/i,sge=/non-fast-forward|rejected/i,ji={LC_ALL:"C",LANGUAGE:""};ov="refs/chant/lifecycle-probe";wm=class extends Error{constructor(n,i,r,o){super(`the ${yt} ledger branch ${o}, so what is on it cannot be read. Refusing rather than treating an unreadable ledger as an empty one.`+(n==="diverged"?`
|
|
86
|
+
Two histories claim to be the ledger; appending to either one drops the other's facts. Inspect both before doing anything else:
|
|
87
|
+
git fetch ${i} ${yt}:refs/chant/remote-ledger
|
|
88
|
+
git log --oneline ${yt} refs/chant/remote-ledger`:`
|
|
89
|
+
Fetch it and retry: git fetch ${i} ${yt}:${yt}`)+(r?`
|
|
90
|
+
git said: ${r.split(`
|
|
91
|
+
`)[0]}`:""));this.reason=n;this.remote=i;this.stderr=r;this.name="LifecycleLedgerUnreadableError"}};Vt=class extends Error{constructor(n,i,r){super(`ref "${n}" moved concurrently \u2014 expected ${i??"(ref must not exist)"}, but another writer updated it first. git stderr: ${r.trim()}`);this.ref=n;this.expected=i;this.name="RefCASConflictError"}},Mc=class extends Error{constructor(n,i,r){super(`ref "${n}" has a stale lock file at ${i} \u2014 a previous git process (e.g. a killed \`chant operator\`) was interrupted mid-write and left it behind. Fix: remove it (\`rm ${i}\`) and retry. git stderr: ${r.trim()}`);this.ref=n;this.lockPath=i;this.name="StaleLockError"}},age=/Unable to create '([^']+)':\s*File exists/});function ss(e=process.env){let t=/^(\d+)\/(merge|head)$/.exec(e.GITHUB_REF_NAME??"")?.[1];if(t&&e.GITHUB_REPOSITORY)return`${(e.GITHUB_SERVER_URL??"https://github.com").replace(/\/$/,"")}/${e.GITHUB_REPOSITORY}/pull/${t}`;if(e.CI_MERGE_REQUEST_PROJECT_URL&&e.CI_MERGE_REQUEST_IID)return`${e.CI_MERGE_REQUEST_PROJECT_URL.replace(/\/$/,"")}/-/merge_requests/${e.CI_MERGE_REQUEST_IID}`}function cv(e){try{let t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}var ud,V0=v(()=>{"use strict";ud="48h"});import{createHash as tq}from"node:crypto";function Nr(e){return`sha256:${tq("sha256").update(e,"utf8").digest("hex")}`}function dd(e){return tq("sha256").update(e).digest("hex")}var as=v(()=>{"use strict"});function km(e){return"props"in e}function qt(e){return typeof e!="object"||e===null?!1:e[Li]===!0?!0:mge(e)}function mge(e){for(let t of Object.getOwnPropertySymbols(e)){let n=Object.getOwnPropertyDescriptor(e,t);if(!(n===void 0||n.enumerable||n.value!==!0)&&t.description?.endsWith(fge)===!0)return!0}return!1}var Li,fge,Pn=v(()=>{"use strict";Li=Symbol.for("chant.declarable");fge=".declarable"});function K0(e){return typeof e=="object"&&e!==null&&nq in e&&e[nq]===!0}function rq(e){let t=new Map,n=new Map;for(let[i,r]of e)K0(r)?n.set(i,r):t.set(i,r);return{applyBound:t,receipts:n}}function Rr(e){let t=q0(e,"$",new Set);if(t===void 0)throw new Error("canonicalJson: value at $ is not representable in JSON");return t}function q0(e,t,n){if(e!==null&&(typeof e=="object"||typeof e=="function")){let r=e.toJSON;typeof r=="function"&&(e=r.call(e))}if(e===void 0)return;if(e===null)return"null";switch(typeof e){case"boolean":return e?"true":"false";case"number":if(!Number.isFinite(e))throw new Error(`canonicalJson: non-finite number at ${t}`);return String(e);case"string":return JSON.stringify(e);case"bigint":throw new Error(`canonicalJson: bigint at ${t} is not representable in JSON`);case"function":case"symbol":throw new Error(`canonicalJson: ${typeof e} at ${t} is not representable in JSON`)}let i=e;if(n.has(i))throw new Error(`canonicalJson: circular structure at ${t}`);n.add(i);try{if(Array.isArray(i))return`[${i.map((a,l)=>q0(a,`${t}[${l}]`,n)??"null").join(",")}]`;let r=Object.keys(i).sort(),o=[];for(let s of r){let a=q0(i[s],`${t}.${s}`,n);a!==void 0&&o.push(`${JSON.stringify(s)}:${a}`)}return`{${o.join(",")}}`}finally{n.delete(i)}}var nq,er=v(()=>{"use strict";as();Pn();Qo();nq=Symbol.for("chant.effect-receipt")});function pd(e,t){return Z0+Nr(Rr({kind:e,subject:t})).slice(gge.length)}function Y0(e){return typeof e=="string"&&J0.test(e)}function mt(e,t){if(e===t)return!0;if(e===void 0||t===void 0)return!1;let n=J0.exec(e),i=J0.exec(t);return n!==null&&i!==null&&n[1]===i[1]}var Z0,gge,J0,On=v(()=>{"use strict";er();as();Z0="jcs1-sha256:",gge="sha256:",J0=/^(?:jcs1-)?sha256:([0-9a-f]{64})$/});function Wn(e,t){return new Date(e.expiresAt).getTime()<=new Date(t).getTime()}function Cn(e,t){let n;for(let i of e)i.gate===t&&(!n||new Date(i.timestamp).getTime()>=new Date(n.timestamp).getTime())&&(n=i);return n}function fd(e,t,n){let i=new Date(n).getTime(),r;for(let o of e)o.gate===t&&(new Date(o.timestamp).getTime()<i||(!r||new Date(o.timestamp).getTime()>=new Date(r.timestamp).getTime())&&(r=o));return r}function jr(e,t,n,i){if(i===void 0){let a=fd(e,t,n);return a?{resolution:a}:{}}let r=new Date(n).getTime(),o,s;for(let a of e){if(a.gate!==t||new Date(a.timestamp).getTime()<r)continue;let l=c=>!c||new Date(a.timestamp).getTime()>=new Date(c.timestamp).getTime();mt(a.planDigest,i)?l(o)&&(o=a):l(s)&&(s=a)}return o?{resolution:o}:s?{mismatched:s}:{}}var zc=v(()=>{"use strict";On()});var oq={};_e(oq,{DEFAULT_GATE_EXPIRY:()=>ud,GATES_DIR:()=>uv,appendGateResolution:()=>$m,appendPendingGate:()=>md,gateLedgerPath:()=>yge,isApprovalUrl:()=>cv,isPendingGateExpired:()=>Wn,latestPendingGate:()=>Cn,latestResolutionForPlan:()=>jr,latestResolutionSince:()=>fd,parseGateLedger:()=>X0,readGateLedger:()=>Lr,readGateResolutions:()=>bge,resolveApprovalUrl:()=>ss});function lv(e){return`${e}.jsonl`}function yge(e,t=""){return`${t}${xm}/${lv(e)}`}async function $m(e,t){let n={version:1,...e};return{commit:await iq(n,"Gate resolution record",t),record:n}}async function md(e,t){let n={version:1,kind:"pending",origin:ts(),...XO(e.op)?{neverOverMcp:!0}:{},...e};return{commit:await iq(n,"Pending gate record",t),record:n}}async function iq(e,t,n){let i=JSON.stringify(e,pn),r;for(let o=1;o<=hge;o++)try{let s=await $r(xm,lv(e.op),n),a=s?await fn(s,n):null,l=`${a?`${a.replace(/\n$/,"")}
|
|
92
|
+
`:""}${i}
|
|
93
|
+
`;return await An(xm,lv(e.op),l,t,{...n,expectPriorPathSha:s})}catch(s){if(!(s instanceof Vt))throw s;r=s}throw r}async function Lr(e,t){let n=await rn(xm,lv(e),t);return n?X0(n):{resolutions:[],pending:[],malformed:0}}function X0(e){let t=e.split(`
|
|
94
|
+
`).map(o=>o.trim()).filter(Boolean),n=[],i=[],r=0;for(let o of t)try{let s=JSON.parse(o);if(!(s.version===1&&typeof s.op=="string"&&typeof s.gate=="string"&&typeof s.timestamp=="string")){r++;continue}let l=s.planDigest;if(l!==void 0&&typeof l!="string"){r++;continue}let c=s.environment;if(c!==void 0&&typeof c!="string"){r++;continue}if(s.kind==="pending"){if(typeof s.expiresAt!="string"){r++;continue}let u=s,d=s.wave;d!==void 0&&!(d&&typeof d=="object"&&typeof d.number=="number"&&typeof d.name=="string")&&delete u.wave;let p=s.heldBy;p!==void 0&&!(p&&typeof p=="object"&&typeof p.hook=="string"&&typeof p.moment=="string")&&delete u.heldBy,i.push(u);continue}if(typeof s.resolvedBy!="string"){r++;continue}n.push(s)}catch{r++}return{resolutions:n,pending:i,malformed:r}}async function bge(e,t){let{resolutions:n,malformed:i}=await Lr(e,t);return{records:n,malformed:i}}var xm,uv,hge,Mi=v(()=>{"use strict";Oi();Wt();Rc();$t();V0();zc();xm="_gates",uv=xm,hge=5});function Uc(e){return{dir:`_gates/${e}`,file:"applied.jsonl"}}function pv(e){let t=[];for(let n of e.split(`
|
|
95
|
+
`).map(i=>i.trim()).filter(Boolean)){let i;try{i=JSON.parse(n)}catch{continue}i?.version===1&&i.kind==="applied"&&typeof i.op=="string"&&typeof i.gate=="string"&&typeof i.planDigest=="string"&&typeof i.approvedAt=="string"&&typeof i.timestamp=="string"&&t.push({approvedBy:"",...i})}return t}function sq(e){let t=[],n=[];for(let i of e.split(`
|
|
96
|
+
`).map(r=>r.trim()).filter(Boolean)){let r;try{r=JSON.parse(i)}catch{continue}r?.version!==1||typeof r.gate!="string"||typeof r.planDigest!="string"||typeof r.timestamp!="string"||((r.kind==="applied"||r.kind==="changes")&&typeof r.approvedAt=="string"?t.push({op:"",approvedBy:"",...r}):r.kind==="finished"&&typeof r.applied=="string"&&(r.result==="applied"||r.result==="failed")&&n.push({op:"",...r}))}return{applied:t,finished:n}}function aq(e,t){return e.find(n=>n.gate===t.gate&&mt(n.planDigest,t.planDigest)&&dv(n.applied)===dv(t.timestamp))}function Mr(e,t){let n=t.planDigest;return n===void 0?!1:e.some(i=>i.gate===t.gate&&mt(i.planDigest,n)&&(t.timestamp!==void 0&&dv(i.approvedAt)>=dv(t.timestamp)||t.review?.head!==void 0&&i.review?.head===t.review.head))}function cq(e,t){return e.map((n,i)=>({ref:`${t??`_gates/${n.op}/applied.jsonl`}#${i+1}`,at:n.timestamp,gate:n.gate,op:n.op,digest:n.planDigest,approval:"required",detail:{approvedAt:n.approvedAt,approvedBy:n.approvedBy,...n.wave?{wave:n.wave}:{},...n.review?{review:n.review}:{},...n.runId?{runId:n.runId}:{},...n.commit?{commit:n.commit}:{}}}))}var dv,Hc=v(()=>{"use strict";On();dv=e=>new Date(e).getTime()});var uo=v(()=>{"use strict"});function Fi(e){let t={ms:1,s:1e3,m:6e4,h:36e5,d:864e5},n=0,i=!1;for(let r of e.matchAll(/(\d+)(ms|s|m|h|d)/g))n+=Number(r[1])*t[r[2]],i=!0;if(!i)throw new Error(`unparseable duration: "${e}"`);return n}var cs=v(()=>{"use strict"});var fv,lq,vGe,gd=v(()=>{"use strict";cs();fv={fastIdempotent:{timeout:"5m",retry:{maximumAttempts:3,initialInterval:"5s",backoffCoefficient:2}},longInfra:{timeout:"20m",retry:{maximumAttempts:3,initialInterval:"30s",backoffCoefficient:2}},k8sWait:{timeout:"15m",retry:{maximumAttempts:3,initialInterval:"10s",backoffCoefficient:2,nonRetryableErrorTypes:["ReadinessFailedError"]}},atMostOnce:{timeout:"20m",retry:{maximumAttempts:1}},humanGate:{timeout:"48h",retry:{maximumAttempts:1}},argoSync:{timeout:"30m",retry:{maximumAttempts:5,initialInterval:"10s",backoffCoefficient:2,maximumInterval:"1m",nonRetryableErrorTypes:["ArgoSyncFailedError"]}},policyCheck:{timeout:"5m",retry:{maximumAttempts:1}}},lq=Object.keys(fv),vGe=6*36e5});function Pt(e,t,n,i){return{[vge]:!0,name:e,args:t,...n?{returns:n}:{},...i?.entities&&i.entities.length>0?{entities:i.entities}:{}}}var vge,Rm=v(()=>{"use strict";uo();gd();vge=Symbol.for("chant.op.activityContract")});var Bi=v(()=>{"use strict";uo();Rm()});var mv=v(()=>{"use strict"});import{createHash as xge}from"node:crypto";function Sm(e){return`sha256:${xge("sha256").update(JSON.stringify(e??{},$ge)).digest("hex")}`}function $ge(e,t){return t&&typeof t=="object"&&!Array.isArray(t)?Object.fromEntries(Object.entries(t).sort(([n],[i])=>n<i?-1:n>i?1:0)):t}async function Q0(e){let t=Pi(e)??`@intentius/chant-lexicon-${e}/gate-policy`,n;try{n=await Yr(t)}catch(i){throw new Error(`the gate's policy is evaluated by ${t}, which could not be loaded: `+(i instanceof Error?i.message:String(i)))}if(typeof n.evaluateGatePolicy!="function")throw new Error(`${t} exports no evaluateGatePolicy function`);return n}function eI(e){return{principal:{kind:e.approver.kind,name:e.resolvedBy,roles:e.approver.roles??[]},action:"PassGate",resource:{op:e.op,gate:e.gate},context:{...e.context??{},...e.planDigest!==void 0?{planDigest:e.planDigest}:{}}}}var Em=v(()=>{"use strict";xn();Bi();mv()});function va(e=process.env){if(e.GITLAB_CI==="true")return!e.CI_API_V4_URL||!e.CI_PROJECT_ID||!e.CI_PIPELINE_ID||!e.CI_JOB_ID?void 0:{forge:"gitlab",api:hv(e.CI_API_V4_URL),repo:e.CI_PROJECT_ID,run:e.CI_PIPELINE_ID,job:e.CI_JOB_ID,...e.CI_JOB_NAME?{jobName:e.CI_JOB_NAME}:{},...e.CI_JOB_URL?{url:e.CI_JOB_URL}:{}};if(e.GITHUB_ACTIONS!=="true"||!e.GITHUB_REPOSITORY||!e.GITHUB_RUN_ID)return;let t=e.FORGEJO_ACTIONS==="true"||e.GITEA_ACTIONS==="true",n=e.GITHUB_SERVER_URL?hv(e.GITHUB_SERVER_URL):void 0,i=n?`${n}/${e.GITHUB_REPOSITORY}/actions/runs/${e.GITHUB_RUN_ID}`:void 0;if(t){let o=Rge(e),s=e.GITHUB_API_URL??(n?`${n}/api/v1`:void 0);return!s||!o||!e.GITHUB_REF_NAME?void 0:{forge:"forgejo",api:hv(s),repo:e.GITHUB_REPOSITORY,run:e.GITHUB_RUN_ID,workflow:o,ref:e.GITHUB_REF_NAME,...i?{url:i}:{}}}let r=Number(e.GITHUB_RUN_ATTEMPT);return{forge:"github",api:hv(e.GITHUB_API_URL??"https://api.github.com"),repo:e.GITHUB_REPOSITORY,run:e.GITHUB_RUN_ID,...Number.isInteger(r)&&r>0?{attempt:r}:{},...i?{url:i}:{}}}function Rge(e){let t=e.GITHUB_WORKFLOW_REF?.split("@")[0]?.split("/").pop();if(t&&/\.ya?ml$/.test(t))return t;let n=e.GITHUB_WORKFLOW;return n&&/\.ya?ml$/.test(n)?n.split("/").pop():void 0}function Vc(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.api!="string"||typeof t.repo!="string"||typeof t.run!="string"?!1:t.forge==="github"?!0:t.forge==="gitlab"?typeof t.job=="string":t.forge==="forgejo"?typeof t.workflow=="string"&&typeof t.ref=="string":!1}var hv,yd=v(()=>{"use strict";hv=e=>e.replace(/\/+$/,"")});var tI,pq=v(()=>{tI={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://intentius.io/chant/schemas/workspace/principals/v1/workspace-principals.schema.json",title:"workspace-principals.json",description:"Principal classes a plugin supplies (#2524 D5, #3080, ws-079). A package publishes this file as data at its ./workspace-principals subpath, beside ./workspace-kinds. chant reads it with the file system and never imports the package. A class is a name for the principals holding one role in the trust policy at base; the declaration's writeScope may then give it an entry.",type:"object",required:["schema","classes"],properties:{$schema:{type:"string",description:"An editor hint. chant ignores it."},$comment:{type:"string",description:"A note for people. chant ignores it."},schema:{const:1,description:"The principal classes format version."},classes:{type:"array",minItems:1,items:{$ref:"#/$defs/class"}}},patternProperties:{"^x-":!0},additionalProperties:!1,$defs:{class:{type:"object",required:["name","description","role"],properties:{name:{type:"string",pattern:"^(?!x-)[a-z][a-z0-9-]{0,39}$",description:"The class's name, as a key of the declaration's writeScope names it. human, agent, runner and service are the core classes and can't be supplied."},description:{type:"string",minLength:1,description:"One line saying who is in the class, for listings and error messages."},role:{type:"string",pattern:"^[a-z][a-z0-9-]*$",description:"The role whose grant in the trust policy at base (.chant/trust.json roles) puts a principal in this class. The agent, runner and service roles belong to the core classes and can't be named here. One role puts a principal in one class."}},patternProperties:{"^x-":!0},additionalProperties:!1}}}});function fq(e=[]){let t=[...io,...e],n=new Map(t.map(i=>[i.name,i]));return{get:i=>n.get(i),names:()=>t.map(i=>i.name),all:()=>t}}function ka(){return fq()}function Am(e){return e.roles}function Pm(e,t,n){return Mf(e.all(),Am(t),n)}function mq(e,t,n=ka()){return Pm(n,e,t)[0]??"human"}function Ege(){if(yv)return yv;let e=fa();return yv=new e({allErrors:!0,strict:!0}).compile(tI),yv}function Age(e,t){let n;try{n=JSON.parse(e)}catch(r){return{classes:[],problems:[`${t}: the principals file is not JSON (${r.message})`]}}let i=Ege();if(!i(n)){let r=(i.errors??[]).map(o=>`${t}: ${o.instancePath||"the principals file"} ${o.message??"is invalid"}`);return{classes:[],problems:[...new Set(r)]}}return fC(n,t)}function Pge(e,t){return n=>{let i=ze(t,n);if(e.stat(i)==="file")try{return e.read(i)}catch{return}}}function Oge(e,t){return Bf(e,t,Age)}function gq(e,t,n={}){let i=[],r=[];e.forEach((s,a)=>{let l,c;if(s.path&&n.tree)l=Pge(n.tree,s.path),c=s.path;else{let u=A0(s,t);if(u===null)return;if("problem"in u){i.push({pin:a,message:u.problem});return}l=Ff(u.dir),c=u.source}r.push({pin:a,source:c,read:Oge(l,c)})});let o=bw(r);return{registry:fq(o.classes),problems:[...i,...o.problems].sort((s,a)=>s.pin-a.pin)}}function nI(e,t){return Object.keys(e??{}).filter(n=>t.get(n)===void 0)}var HGe,yv,rI=v(()=>{"use strict";ju();co();pq();Zt();Sc();ym();ju();Sc();ju();HGe=tI.$id});function Cge(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Om(){if(hq)return xa;hq=1;function e(s){return typeof s>"u"||s===null}function t(s){return typeof s=="object"&&s!==null}function n(s){return Array.isArray(s)?s:e(s)?[]:[s]}function i(s,a){if(a){let l=Object.keys(a);for(let c=0,u=l.length;c<u;c+=1){let d=l[c];s[d]=a[d]}}return s}function r(s,a){let l="";for(let c=0;c<a;c+=1)l+=s;return l}function o(s){return s===0&&Number.NEGATIVE_INFINITY===1/s}return xa.isNothing=e,xa.isObject=t,xa.toArray=n,xa.repeat=r,xa.isNegativeZero=o,xa.extend=i,xa}function Cm(){if(yq)return iI;yq=1;function e(n,i){let r="",o=n.reason||"(unknown reason)";return n.mark?(n.mark.name&&(r+='in "'+n.mark.name+'" '),r+="("+(n.mark.line+1)+":"+(n.mark.column+1)+")",!i&&n.mark.snippet&&(r+=`
|
|
97
|
+
|
|
98
|
+
`+n.mark.snippet),o+" "+r):o}function t(n,i){Error.call(this),this.name="YAMLException",this.reason=n,this.mark=i,this.message=e(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t.prototype.toString=function(i){return this.name+": "+e(this,i)},iI=t,iI}function _ge(){if(bq)return oI;bq=1;let e=Om();function t(r,o,s,a,l){let c="",u="",d=Math.floor(l/2)-1;return a-o>d&&(c=" ... ",o=a-d+c.length),s-a>d&&(u=" ...",s=a+d-u.length),{str:c+r.slice(o,s).replace(/\t/g,"\u2192")+u,pos:a-o+c.length}}function n(r,o){return e.repeat(" ",o-r.length)+r}function i(r,o){if(o=Object.create(o||null),!r.buffer)return null;o.maxLength||(o.maxLength=79),typeof o.indent!="number"&&(o.indent=1),typeof o.linesBefore!="number"&&(o.linesBefore=3),typeof o.linesAfter!="number"&&(o.linesAfter=2);let s=/\r?\n|\r|\0/g,a=[0],l=[],c,u=-1;for(;c=s.exec(r.buffer);)l.push(c.index),a.push(c.index+c[0].length),r.position<=c.index&&u<0&&(u=a.length-2);u<0&&(u=a.length-1);let d="",p=Math.min(r.line+o.linesAfter,l.length).toString().length,f=o.maxLength-(o.indent+p+3);for(let h=1;h<=o.linesBefore&&!(u-h<0);h++){let b=t(r.buffer,a[u-h],l[u-h],r.position-(a[u]-a[u-h]),f);d=e.repeat(" ",o.indent)+n((r.line-h+1).toString(),p)+" | "+b.str+`
|
|
99
|
+
`+d}let g=t(r.buffer,a[u],l[u],r.position,f);d+=e.repeat(" ",o.indent)+n((r.line+1).toString(),p)+" | "+g.str+`
|
|
100
|
+
`,d+=e.repeat("-",o.indent+p+3+g.pos)+`^
|
|
101
|
+
`;for(let h=1;h<=o.linesAfter&&!(u+h>=l.length);h++){let b=t(r.buffer,a[u+h],l[u+h],r.position-(a[u]-a[u+h]),f);d+=e.repeat(" ",o.indent)+n((r.line+h+1).toString(),p)+" | "+b.str+`
|
|
102
|
+
`}return d.replace(/\n$/,"")}return oI=i,oI}function tr(){if(wq)return sI;wq=1;let e=Cm(),t=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],n=["scalar","sequence","mapping"];function i(o){let s={};return o!==null&&Object.keys(o).forEach(function(a){o[a].forEach(function(l){s[String(l)]=a})}),s}function r(o,s){if(s=s||{},Object.keys(s).forEach(function(a){if(t.indexOf(a)===-1)throw new e('Unknown option "'+a+'" is met in definition of "'+o+'" YAML type.')}),this.options=s,this.tag=o,this.kind=s.kind||null,this.resolve=s.resolve||function(){return!0},this.construct=s.construct||function(a){return a},this.instanceOf=s.instanceOf||null,this.predicate=s.predicate||null,this.represent=s.represent||null,this.representName=s.representName||null,this.defaultStyle=s.defaultStyle||null,this.multi=s.multi||!1,this.styleAliases=i(s.styleAliases||null),n.indexOf(this.kind)===-1)throw new e('Unknown kind "'+this.kind+'" is specified for "'+o+'" YAML type.')}return sI=r,sI}function Gq(){if(vq)return aI;vq=1;let e=Cm(),t=tr();function n(o,s){let a=[];return o[s].forEach(function(l){let c=a.length;a.forEach(function(u,d){u.tag===l.tag&&u.kind===l.kind&&u.multi===l.multi&&(c=d)}),a[c]=l}),a}function i(){let o={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function s(a){a.multi?(o.multi[a.kind].push(a),o.multi.fallback.push(a)):o[a.kind][a.tag]=o.fallback[a.tag]=a}for(let a=0,l=arguments.length;a<l;a+=1)arguments[a].forEach(s);return o}function r(o){return this.extend(o)}return r.prototype.extend=function(s){let a=[],l=[];if(s instanceof t)l.push(s);else if(Array.isArray(s))l=l.concat(s);else if(s&&(Array.isArray(s.implicit)||Array.isArray(s.explicit)))s.implicit&&(a=a.concat(s.implicit)),s.explicit&&(l=l.concat(s.explicit));else throw new e("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");a.forEach(function(u){if(!(u instanceof t))throw new e("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(u.loadKind&&u.loadKind!=="scalar")throw new e("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(u.multi)throw new e("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),l.forEach(function(u){if(!(u instanceof t))throw new e("Specified list of YAML types (or a single Type object) contains a non-Type object.")});let c=Object.create(r.prototype);return c.implicit=(this.implicit||[]).concat(a),c.explicit=(this.explicit||[]).concat(l),c.compiledImplicit=n(c,"implicit"),c.compiledExplicit=n(c,"explicit"),c.compiledTypeMap=i(c.compiledImplicit,c.compiledExplicit),c},aI=r,aI}function Wq(){if(kq)return cI;kq=1;let e=tr();return cI=new e("tag:yaml.org,2002:str",{kind:"scalar",construct:function(t){return t!==null?t:""}}),cI}function zq(){if(xq)return lI;xq=1;let e=tr();return lI=new e("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(t){return t!==null?t:[]}}),lI}function Uq(){if($q)return uI;$q=1;let e=tr();return uI=new e("tag:yaml.org,2002:map",{kind:"mapping",construct:function(t){return t!==null?t:{}}}),uI}function Hq(){if(Rq)return dI;Rq=1;let e=Gq();return dI=new e({explicit:[Wq(),zq(),Uq()]}),dI}function Vq(){if(Sq)return pI;Sq=1;let e=tr();function t(r){if(r===null)return!0;let o=r.length;return o===1&&r==="~"||o===4&&(r==="null"||r==="Null"||r==="NULL")}function n(){return null}function i(r){return r===null}return pI=new e("tag:yaml.org,2002:null",{kind:"scalar",resolve:t,construct:n,predicate:i,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"}),pI}function qq(){if(Eq)return fI;Eq=1;let e=tr();function t(r){if(r===null)return!1;let o=r.length;return o===4&&(r==="true"||r==="True"||r==="TRUE")||o===5&&(r==="false"||r==="False"||r==="FALSE")}function n(r){return r==="true"||r==="True"||r==="TRUE"}function i(r){return Object.prototype.toString.call(r)==="[object Boolean]"}return fI=new e("tag:yaml.org,2002:bool",{kind:"scalar",resolve:t,construct:n,predicate:i,represent:{lowercase:function(r){return r?"true":"false"},uppercase:function(r){return r?"TRUE":"FALSE"},camelcase:function(r){return r?"True":"False"}},defaultStyle:"lowercase"}),fI}function Kq(){if(Aq)return mI;Aq=1;let e=Om(),t=tr();function n(c){return c>=48&&c<=57||c>=65&&c<=70||c>=97&&c<=102}function i(c){return c>=48&&c<=55}function r(c){return c>=48&&c<=57}function o(c){if(c===null)return!1;let u=c.length,d=0,p=!1;if(!u)return!1;let f=c[d];if((f==="-"||f==="+")&&(f=c[++d]),f==="0"){if(d+1===u)return!0;if(f=c[++d],f==="b"){for(d++;d<u;d++){if(f=c[d],f!=="0"&&f!=="1")return!1;p=!0}return p&&isFinite(s(c))}if(f==="x"){for(d++;d<u;d++){if(!n(c.charCodeAt(d)))return!1;p=!0}return p&&isFinite(s(c))}if(f==="o"){for(d++;d<u;d++){if(!i(c.charCodeAt(d)))return!1;p=!0}return p&&isFinite(s(c))}}for(;d<u;d++){if(!r(c.charCodeAt(d)))return!1;p=!0}return p?isFinite(s(c)):!1}function s(c){let u=c,d=1,p=u[0];if((p==="-"||p==="+")&&(p==="-"&&(d=-1),u=u.slice(1),p=u[0]),u==="0")return 0;if(p==="0"){if(u[1]==="b")return d*parseInt(u.slice(2),2);if(u[1]==="x")return d*parseInt(u.slice(2),16);if(u[1]==="o")return d*parseInt(u.slice(2),8)}return d*parseInt(u,10)}function a(c){return s(c)}function l(c){return Object.prototype.toString.call(c)==="[object Number]"&&c%1===0&&!e.isNegativeZero(c)}return mI=new t("tag:yaml.org,2002:int",{kind:"scalar",resolve:o,construct:a,predicate:l,represent:{binary:function(c){return c>=0?"0b"+c.toString(2):"-0b"+c.toString(2).slice(1)},octal:function(c){return c>=0?"0o"+c.toString(8):"-0o"+c.toString(8).slice(1)},decimal:function(c){return c.toString(10)},hexadecimal:function(c){return c>=0?"0x"+c.toString(16).toUpperCase():"-0x"+c.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),mI}function Jq(){if(Pq)return gI;Pq=1;let e=Om(),t=tr(),n=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),i=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function r(c){return c===null||!n.test(c)?!1:isFinite(parseFloat(c,10))?!0:i.test(c)}function o(c){let u=c.toLowerCase(),d=u[0]==="-"?-1:1;return"+-".indexOf(u[0])>=0&&(u=u.slice(1)),u===".inf"?d===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:u===".nan"?NaN:d*parseFloat(u,10)}let s=/^[-+]?[0-9]+e/;function a(c,u){if(isNaN(c))switch(u){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===c)switch(u){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===c)switch(u){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(e.isNegativeZero(c))return"-0.0";let d=c.toString(10);return s.test(d)?d.replace("e",".e"):d}function l(c){return Object.prototype.toString.call(c)==="[object Number]"&&(c%1!==0||e.isNegativeZero(c))}return gI=new t("tag:yaml.org,2002:float",{kind:"scalar",resolve:r,construct:o,predicate:l,represent:a,defaultStyle:"lowercase"}),gI}function Zq(){return Oq||(Oq=1,hI=Hq().extend({implicit:[Vq(),qq(),Kq(),Jq()]})),hI}function Yq(){return Cq||(Cq=1,yI=Zq()),yI}function Xq(){if(_q)return bI;_q=1;let e=tr(),t=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),n=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function i(s){return s===null?!1:t.exec(s)!==null||n.exec(s)!==null}function r(s){let a=0,l=null,c=t.exec(s);if(c===null&&(c=n.exec(s)),c===null)throw new Error("Date resolve error");let u=+c[1],d=+c[2]-1,p=+c[3];if(!c[4])return new Date(Date.UTC(u,d,p));let f=+c[4],g=+c[5],h=+c[6];if(c[7]){for(a=c[7].slice(0,3);a.length<3;)a+="0";a=+a}if(c[9]){let w=+c[10],x=+(c[11]||0);l=(w*60+x)*6e4,c[9]==="-"&&(l=-l)}let b=new Date(Date.UTC(u,d,p,f,g,h,a));return l&&b.setTime(b.getTime()-l),b}function o(s){return s.toISOString()}return bI=new e("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:i,construct:r,instanceOf:Date,represent:o}),bI}function Qq(){if(Iq)return wI;Iq=1;let e=tr();function t(n){return n==="<<"||n===null}return wI=new e("tag:yaml.org,2002:merge",{kind:"scalar",resolve:t}),wI}function eK(){if(Tq)return vI;Tq=1;let e=tr(),t=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
103
|
+
\r`;function n(s){if(s===null)return!1;let a=0,l=s.length,c=t;for(let u=0;u<l;u++){let d=c.indexOf(s.charAt(u));if(!(d>64)){if(d<0)return!1;a+=6}}return a%8===0}function i(s){let a=s.replace(/[\r\n=]/g,""),l=a.length,c=t,u=0,d=[];for(let f=0;f<l;f++)f%4===0&&f&&(d.push(u>>16&255),d.push(u>>8&255),d.push(u&255)),u=u<<6|c.indexOf(a.charAt(f));let p=l%4*6;return p===0?(d.push(u>>16&255),d.push(u>>8&255),d.push(u&255)):p===18?(d.push(u>>10&255),d.push(u>>2&255)):p===12&&d.push(u>>4&255),new Uint8Array(d)}function r(s){let a="",l=0,c=s.length,u=t;for(let p=0;p<c;p++)p%3===0&&p&&(a+=u[l>>18&63],a+=u[l>>12&63],a+=u[l>>6&63],a+=u[l&63]),l=(l<<8)+s[p];let d=c%3;return d===0?(a+=u[l>>18&63],a+=u[l>>12&63],a+=u[l>>6&63],a+=u[l&63]):d===2?(a+=u[l>>10&63],a+=u[l>>4&63],a+=u[l<<2&63],a+=u[64]):d===1&&(a+=u[l>>2&63],a+=u[l<<4&63],a+=u[64],a+=u[64]),a}function o(s){return Object.prototype.toString.call(s)==="[object Uint8Array]"}return vI=new e("tag:yaml.org,2002:binary",{kind:"scalar",resolve:n,construct:i,predicate:o,represent:r}),vI}function tK(){if(Dq)return kI;Dq=1;let e=tr(),t=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function i(o){if(o===null)return!0;let s={},a=o;for(let l=0,c=a.length;l<c;l+=1){let u=a[l],d=!1;if(n.call(u)!=="[object Object]")return!1;let p;for(p in u)if(t.call(u,p))if(!d)d=!0;else return!1;if(!d||t.call(s,p))return!1;Object.defineProperty(s,p,{value:!0})}return!0}function r(o){return o!==null?o:[]}return kI=new e("tag:yaml.org,2002:omap",{kind:"sequence",resolve:i,construct:r}),kI}function nK(){if(Nq)return xI;Nq=1;let e=tr(),t=Object.prototype.toString;function n(r){if(r===null)return!0;let o=r,s=new Array(o.length);for(let a=0,l=o.length;a<l;a+=1){let c=o[a];if(t.call(c)!=="[object Object]")return!1;let u=Object.keys(c);if(u.length!==1)return!1;s[a]=[u[0],c[u[0]]]}return!0}function i(r){if(r===null)return[];let o=r,s=new Array(o.length);for(let a=0,l=o.length;a<l;a+=1){let c=o[a],u=Object.keys(c);s[a]=[u[0],c[u[0]]]}return s}return xI=new e("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:n,construct:i}),xI}function rK(){if(jq)return $I;jq=1;let e=tr(),t=Object.prototype.hasOwnProperty;function n(r){if(r===null)return!0;let o=r;for(let s in o)if(t.call(o,s)&&o[s]!==null)return!1;return!0}function i(r){return r!==null?r:{}}return $I=new e("tag:yaml.org,2002:set",{kind:"mapping",resolve:n,construct:i}),$I}function EI(){return Lq||(Lq=1,RI=Yq().extend({implicit:[Xq(),Qq()],explicit:[eK(),tK(),nK(),rK()]})),RI}function Ige(){if(Mq)return bv;Mq=1;let e=Om(),t=Cm(),n=_ge(),i=EI(),r=Object.prototype.hasOwnProperty,o=1,s=2,a=3,l=4,c=1,u=2,d=3,p=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,f=/[\x85\u2028\u2029]/,g=/[,\[\]{}]/,h=/^(?:!|!!|![0-9A-Za-z-]+!)$/,b=/^(?:!|[^,\[\]{}])(?:%[0-9a-f]{2}|[0-9a-z\-#;/?:@&=+$,_.!~*'()\[\]])*$/i;function w(y){return Object.prototype.toString.call(y)}function x(y){return y===10||y===13}function k(y){return y===9||y===32}function R(y){return y===9||y===32||y===10||y===13}function $(y){return y===44||y===91||y===93||y===123||y===125}function _(y){if(y>=48&&y<=57)return y-48;let N=y|32;return N>=97&&N<=102?N-97+10:-1}function T(y){return y===120?2:y===117?4:y===85?8:0}function C(y){return y>=48&&y<=57?y-48:-1}function K(y){switch(y){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return`
|
|
104
|
+
`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"\x85";case 95:return"\xA0";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function O(y){return y<=65535?String.fromCharCode(y):String.fromCharCode((y-65536>>10)+55296,(y-65536&1023)+56320)}function pe(y,N,q){N==="__proto__"?Object.defineProperty(y,N,{configurable:!0,enumerable:!0,writable:!0,value:q}):y[N]=q}let F=new Array(256),Q=new Array(256);for(let y=0;y<256;y++)F[y]=K(y)?1:0,Q[y]=K(y);function I(y,N){this.input=y,this.filename=N.filename||null,this.schema=N.schema||i,this.onWarning=N.onWarning||null,this.legacy=N.legacy||!1,this.json=N.json||!1,this.listener=N.listener||null,this.maxDepth=typeof N.maxDepth=="number"?N.maxDepth:100,this.maxTotalMergeKeys=typeof N.maxTotalMergeKeys=="number"?N.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=y.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function B(y,N){let q={name:y.filename,buffer:y.input.slice(0,-1),position:y.position,line:y.line,column:y.position-y.lineStart};return q.snippet=n(q),new t(N,q)}function Z(y,N){throw B(y,N)}function xe(y,N){y.onWarning&&y.onWarning.call(null,B(y,N))}function we(y,N,q){let Y=y.anchorMapTransactions;if(Y.length!==0){let z=Y[Y.length-1];r.call(z,N)||(z[N]={existed:r.call(y.anchorMap,N),value:y.anchorMap[N]})}y.anchorMap[N]=q}function Ct(y){y.anchorMapTransactions.push(Object.create(null))}function at(y){let N=y.anchorMapTransactions.pop(),q=y.anchorMapTransactions;if(q.length===0)return;let Y=q[q.length-1],z=Object.keys(N);for(let E=0,G=z.length;E<G;E+=1){let H=z[E];r.call(Y,H)||(Y[H]=N[H])}}function $e(y){let N=y.anchorMapTransactions.pop(),q=Object.keys(N);for(let Y=q.length-1;Y>=0;Y-=1){let z=N[q[Y]];z.existed?y.anchorMap[q[Y]]=z.value:delete y.anchorMap[q[Y]]}}function Te(y){return{position:y.position,line:y.line,lineStart:y.lineStart,lineIndent:y.lineIndent,firstTabInLine:y.firstTabInLine,tag:y.tag,anchor:y.anchor,kind:y.kind,result:y.result}}function nt(y,N){y.position=N.position,y.line=N.line,y.lineStart=N.lineStart,y.lineIndent=N.lineIndent,y.firstTabInLine=N.firstTabInLine,y.tag=N.tag,y.anchor=N.anchor,y.kind=N.kind,y.result=N.result}let St={YAML:function(N,q,Y){N.version!==null&&Z(N,"duplication of %YAML directive"),Y.length!==1&&Z(N,"YAML directive accepts exactly one argument");let z=/^([0-9]+)\.([0-9]+)$/.exec(Y[0]);z===null&&Z(N,"ill-formed argument of the YAML directive");let E=parseInt(z[1],10),G=parseInt(z[2],10);E!==1&&Z(N,"unacceptable YAML version of the document"),N.version=Y[0],N.checkLineBreaks=G<2,G!==1&&G!==2&&xe(N,"unsupported YAML version of the document")},TAG:function(N,q,Y){let z;Y.length!==2&&Z(N,"TAG directive accepts exactly two arguments");let E=Y[0];z=Y[1],h.test(E)||Z(N,"ill-formed tag handle (first argument) of the TAG directive"),r.call(N.tagMap,E)&&Z(N,'there is a previously declared suffix for "'+E+'" tag handle'),b.test(z)||Z(N,"ill-formed tag prefix (second argument) of the TAG directive");try{z=decodeURIComponent(z)}catch{Z(N,"tag prefix is malformed: "+z)}N.tagMap[E]=z}};function Ee(y,N,q,Y){if(N<q){let z=y.input.slice(N,q);if(Y)for(let E=0,G=z.length;E<G;E+=1){let H=z.charCodeAt(E);H===9||H>=32&&H<=1114111||Z(y,"expected valid JSON character")}else p.test(z)&&Z(y,"the stream contains non-printable characters");y.result+=z}}function zt(y){y.totalMergeKeys++,y.maxTotalMergeKeys!==-1&&y.totalMergeKeys>y.maxTotalMergeKeys&&Z(y,"merge keys exceeded maxTotalMergeKeys ("+y.maxTotalMergeKeys+")")}function Vn(y,N,q,Y){e.isObject(q)||Z(y,"cannot merge mappings; the provided source object is unacceptable"),zt(y);let z=Object.keys(q);for(let E=0,G=z.length;E<G;E+=1){let H=z[E];zt(y),r.call(N,H)||(pe(N,H,q[H]),Y[H]=!0)}}function ne(y,N,q,Y,z,E,G,H,ee){if(Array.isArray(z)){z=Array.prototype.slice.call(z);for(let te=0,oe=z.length;te<oe;te+=1)Array.isArray(z[te])&&Z(y,"nested arrays are not supported inside keys"),typeof z=="object"&&w(z[te])==="[object Object]"&&(z[te]="[object Object]")}if(typeof z=="object"&&w(z)==="[object Object]"&&(z="[object Object]"),z=String(z),N===null&&(N={}),Y==="tag:yaml.org,2002:merge")if(Array.isArray(E)){E.length>100&&Z(y,"abnormal merge sequence size");for(let te=0,oe=E.length;te<oe;te+=1)Vn(y,N,E[te],q)}else Vn(y,N,E,q);else!y.json&&!r.call(q,z)&&r.call(N,z)&&(y.line=G||y.line,y.lineStart=H||y.lineStart,y.position=ee||y.position,Z(y,"duplicated mapping key")),pe(N,z,E),delete q[z];return N}function Re(y){let N=y.input.charCodeAt(y.position);N===10?y.position++:N===13?(y.position++,y.input.charCodeAt(y.position)===10&&y.position++):Z(y,"a line break is expected"),y.line+=1,y.lineStart=y.position,y.firstTabInLine=-1}function X(y,N,q){let Y=0,z=y.input.charCodeAt(y.position);for(;z!==0;){for(;k(z);)z===9&&y.firstTabInLine===-1&&(y.firstTabInLine=y.position),z=y.input.charCodeAt(++y.position);if(N&&z===35)do z=y.input.charCodeAt(++y.position);while(z!==10&&z!==13&&z!==0);if(x(z))for(Re(y),z=y.input.charCodeAt(y.position),Y++,y.lineIndent=0;z===32;)y.lineIndent++,z=y.input.charCodeAt(++y.position);else break}return q!==-1&&Y!==0&&y.lineIndent<q&&xe(y,"deficient indentation"),Y}function Ce(y){let N=y.position,q=y.input.charCodeAt(N);return!!((q===45||q===46)&&q===y.input.charCodeAt(N+1)&&q===y.input.charCodeAt(N+2)&&(N+=3,q=y.input.charCodeAt(N),q===0||R(q)))}function tt(y,N){N===1?y.result+=" ":N>1&&(y.result+=e.repeat(`
|
|
105
|
+
`,N-1))}function gt(y,N,q){let Y,z,E,G,H,ee,te=y.kind,oe=y.result,S=y.input.charCodeAt(y.position);if(R(S)||$(S)||S===35||S===38||S===42||S===33||S===124||S===62||S===39||S===34||S===37||S===64||S===96)return!1;if(S===63||S===45){let A=y.input.charCodeAt(y.position+1);if(R(A)||q&&$(A))return!1}for(y.kind="scalar",y.result="",Y=z=y.position,E=!1;S!==0;){if(S===58){let A=y.input.charCodeAt(y.position+1);if(R(A)||q&&$(A))break}else if(S===35){let A=y.input.charCodeAt(y.position-1);if(R(A))break}else{if(y.position===y.lineStart&&Ce(y)||q&&$(S))break;if(x(S))if(G=y.line,H=y.lineStart,ee=y.lineIndent,X(y,!1,-1),y.lineIndent>=N){E=!0,S=y.input.charCodeAt(y.position);continue}else{y.position=z,y.line=G,y.lineStart=H,y.lineIndent=ee;break}}E&&(Ee(y,Y,z,!1),tt(y,y.line-G),Y=z=y.position,E=!1),k(S)||(z=y.position+1),S=y.input.charCodeAt(++y.position)}return Ee(y,Y,z,!1),y.result?!0:(y.kind=te,y.result=oe,!1)}function Je(y,N){let q,Y,z=y.input.charCodeAt(y.position);if(z!==39)return!1;for(y.kind="scalar",y.result="",y.position++,q=Y=y.position;(z=y.input.charCodeAt(y.position))!==0;)if(z===39)if(Ee(y,q,y.position,!0),z=y.input.charCodeAt(++y.position),z===39)q=y.position,y.position++,Y=y.position;else return!0;else x(z)?(Ee(y,q,Y,!0),tt(y,X(y,!1,N)),q=Y=y.position):y.position===y.lineStart&&Ce(y)?Z(y,"unexpected end of the document within a single quoted scalar"):(y.position++,k(z)||(Y=y.position));Z(y,"unexpected end of the stream within a single quoted scalar")}function Bt(y,N){let q,Y,z,E=y.input.charCodeAt(y.position);if(E!==34)return!1;for(y.kind="scalar",y.result="",y.position++,q=Y=y.position;(E=y.input.charCodeAt(y.position))!==0;){if(E===34)return Ee(y,q,y.position,!0),y.position++,!0;if(E===92){if(Ee(y,q,y.position,!0),E=y.input.charCodeAt(++y.position),x(E))X(y,!1,N);else if(E<256&&F[E])y.result+=Q[E],y.position++;else if((z=T(E))>0){let G=z,H=0;for(;G>0;G--)E=y.input.charCodeAt(++y.position),(z=_(E))>=0?H=(H<<4)+z:Z(y,"expected hexadecimal character");y.result+=O(H),y.position++}else Z(y,"unknown escape sequence");q=Y=y.position}else x(E)?(Ee(y,q,Y,!0),tt(y,X(y,!1,N)),q=Y=y.position):y.position===y.lineStart&&Ce(y)?Z(y,"unexpected end of the document within a double quoted scalar"):(y.position++,k(E)||(Y=y.position))}Z(y,"unexpected end of the stream within a double quoted scalar")}function W(y,N){let q=!0,Y,z,E,G=y.tag,H,ee=y.anchor,te,oe,S,A,P=Object.create(null),j,U,L,re=y.input.charCodeAt(y.position);if(re===91)te=93,A=!1,H=[];else if(re===123)te=125,A=!0,H={};else return!1;for(y.anchor!==null&&we(y,y.anchor,H),re=y.input.charCodeAt(++y.position);re!==0;){if(X(y,!0,N),re=y.input.charCodeAt(y.position),re===te)return y.position++,y.tag=G,y.anchor=ee,y.kind=A?"mapping":"sequence",y.result=H,!0;if(q?re===44&&Z(y,"expected the node content, but found ','"):Z(y,"missed comma between flow collection entries"),U=j=L=null,oe=S=!1,re===63){let me=y.input.charCodeAt(y.position+1);R(me)&&(oe=S=!0,y.position++,X(y,!0,N))}Y=y.line,z=y.lineStart,E=y.position,qn(y,N,o,!1,!0),U=y.tag,j=y.result,X(y,!0,N),re=y.input.charCodeAt(y.position),(S||y.line===Y)&&re===58&&(oe=!0,re=y.input.charCodeAt(++y.position),X(y,!0,N),qn(y,N,o,!1,!0),L=y.result),A?ne(y,H,P,U,j,L,Y,z,E):oe?H.push(ne(y,null,P,U,j,L,Y,z,E)):H.push(j),X(y,!0,N),re=y.input.charCodeAt(y.position),re===44?(q=!0,re=y.input.charCodeAt(++y.position)):q=!1}Z(y,"unexpected end of the stream within a flow collection")}function de(y,N){let q,Y=c,z=!1,E=!1,G=N,H=0,ee=!1,te,oe=y.input.charCodeAt(y.position);if(oe===124)q=!1;else if(oe===62)q=!0;else return!1;for(y.kind="scalar",y.result="";oe!==0;)if(oe=y.input.charCodeAt(++y.position),oe===43||oe===45)c===Y?Y=oe===43?d:u:Z(y,"repeat of a chomping mode identifier");else if((te=C(oe))>=0)te===0?Z(y,"bad explicit indentation width of a block scalar; it cannot be less than one"):E?Z(y,"repeat of an indentation width identifier"):(G=N+te-1,E=!0);else break;if(k(oe)){do oe=y.input.charCodeAt(++y.position);while(k(oe));if(oe===35)do oe=y.input.charCodeAt(++y.position);while(!x(oe)&&oe!==0)}for(;oe!==0;){for(Re(y),y.lineIndent=0,oe=y.input.charCodeAt(y.position);(!E||y.lineIndent<G)&&oe===32;)y.lineIndent++,oe=y.input.charCodeAt(++y.position);if(!E&&y.lineIndent>G&&(G=y.lineIndent),x(oe)){H++;continue}if(!E&&G===0&&Z(y,"missing indentation for block scalar"),y.lineIndent<G){Y===d?y.result+=e.repeat(`
|
|
106
|
+
`,z?1+H:H):Y===c&&z&&(y.result+=`
|
|
107
|
+
`);break}q?k(oe)?(ee=!0,y.result+=e.repeat(`
|
|
108
|
+
`,z?1+H:H)):ee?(ee=!1,y.result+=e.repeat(`
|
|
109
|
+
`,H+1)):H===0?z&&(y.result+=" "):y.result+=e.repeat(`
|
|
110
|
+
`,H):y.result+=e.repeat(`
|
|
111
|
+
`,z?1+H:H),z=!0,E=!0,H=0;let S=y.position;for(;!x(oe)&&oe!==0;)oe=y.input.charCodeAt(++y.position);Ee(y,S,y.position,!1)}return!0}function Oe(y,N){let q=y.tag,Y=y.anchor,z=[],E=!1;if(y.firstTabInLine!==-1)return!1;y.anchor!==null&&we(y,y.anchor,z);let G=y.input.charCodeAt(y.position);for(;G!==0&&(y.firstTabInLine!==-1&&(y.position=y.firstTabInLine,Z(y,"tab characters must not be used in indentation")),G===45);){let H=y.input.charCodeAt(y.position+1);if(!R(H))break;if(E=!0,y.position++,X(y,!0,-1)&&y.lineIndent<=N){z.push(null),G=y.input.charCodeAt(y.position);continue}let ee=y.line;if(qn(y,N,a,!1,!0),z.push(y.result),X(y,!0,-1),G=y.input.charCodeAt(y.position),(y.line===ee||y.lineIndent>N)&&G!==0)Z(y,"bad indentation of a sequence entry");else if(y.lineIndent<N)break}return E?(y.tag=q,y.anchor=Y,y.kind="sequence",y.result=z,!0):!1}function pt(y,N,q){let Y,z,E,G,H=y.tag,ee=y.anchor,te={},oe=Object.create(null),S=null,A=null,P=null,j=!1,U=!1;if(y.firstTabInLine!==-1)return!1;y.anchor!==null&&we(y,y.anchor,te);let L=y.input.charCodeAt(y.position);for(;L!==0;){!j&&y.firstTabInLine!==-1&&(y.position=y.firstTabInLine,Z(y,"tab characters must not be used in indentation"));let re=y.input.charCodeAt(y.position+1),me=y.line;if((L===63||L===58)&&R(re))L===63?(j&&(ne(y,te,oe,S,A,null,z,E,G),S=A=P=null),U=!0,j=!0,Y=!0):j?(j=!1,Y=!0):Z(y,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),y.position+=1,L=re;else{if(z=y.line,E=y.lineStart,G=y.position,!qn(y,q,s,!1,!0))break;if(y.line===me){for(L=y.input.charCodeAt(y.position);k(L);)L=y.input.charCodeAt(++y.position);if(L===58)L=y.input.charCodeAt(++y.position),R(L)||Z(y,"a whitespace character is expected after the key-value separator within a block mapping"),j&&(ne(y,te,oe,S,A,null,z,E,G),S=A=P=null),U=!0,j=!1,Y=!1,S=y.tag,A=y.result;else if(U)Z(y,"can not read an implicit mapping pair; a colon is missed");else return y.tag=H,y.anchor=ee,!0}else if(U)Z(y,"can not read a block mapping entry; a multiline key may not be an implicit key");else return y.tag=H,y.anchor=ee,!0}if((y.line===me||y.lineIndent>N)&&(j&&(z=y.line,E=y.lineStart,G=y.position),qn(y,N,l,!0,Y)&&(j?A=y.result:P=y.result),j||(ne(y,te,oe,S,A,P,z,E,G),S=A=P=null),X(y,!0,-1),L=y.input.charCodeAt(y.position)),(y.line===me||y.lineIndent>N)&&L!==0)Z(y,"bad indentation of a mapping entry");else if(y.lineIndent<N)break}return j&&ne(y,te,oe,S,A,null,z,E,G),U&&(y.tag=H,y.anchor=ee,y.kind="mapping",y.result=te),U}function et(y){let N=!1,q=!1,Y,z,E=y.input.charCodeAt(y.position);if(E!==33)return!1;y.tag!==null&&Z(y,"duplication of a tag property"),E=y.input.charCodeAt(++y.position),E===60?(N=!0,E=y.input.charCodeAt(++y.position)):E===33?(q=!0,Y="!!",E=y.input.charCodeAt(++y.position)):Y="!";let G=y.position;if(N){do E=y.input.charCodeAt(++y.position);while(E!==0&&E!==62);y.position<y.length?(z=y.input.slice(G,y.position),E=y.input.charCodeAt(++y.position)):Z(y,"unexpected end of the stream within a verbatim tag")}else{for(;E!==0&&!R(E);)E===33&&(q?Z(y,"tag suffix cannot contain exclamation marks"):(Y=y.input.slice(G-1,y.position+1),h.test(Y)||Z(y,"named tag handle cannot contain such characters"),q=!0,G=y.position+1)),E=y.input.charCodeAt(++y.position);z=y.input.slice(G,y.position),g.test(z)&&Z(y,"tag suffix cannot contain flow indicator characters")}z&&!b.test(z)&&Z(y,"tag name cannot contain such characters: "+z);try{z=decodeURIComponent(z)}catch{Z(y,"tag name is malformed: "+z)}return N?y.tag=z:r.call(y.tagMap,Y)?y.tag=y.tagMap[Y]+z:Y==="!"?y.tag="!"+z:Y==="!!"?y.tag="tag:yaml.org,2002:"+z:Z(y,'undeclared tag handle "'+Y+'"'),!0}function Ut(y){let N=y.input.charCodeAt(y.position);if(N!==38)return!1;y.anchor!==null&&Z(y,"duplication of an anchor property"),N=y.input.charCodeAt(++y.position);let q=y.position;for(;N!==0&&!R(N)&&!$(N);)N=y.input.charCodeAt(++y.position);return y.position===q&&Z(y,"name of an anchor node must contain at least one character"),y.anchor=y.input.slice(q,y.position),!0}function Tt(y){let N=y.input.charCodeAt(y.position);if(N!==42)return!1;N=y.input.charCodeAt(++y.position);let q=y.position;for(;N!==0&&!R(N)&&!$(N);)N=y.input.charCodeAt(++y.position);y.position===q&&Z(y,"name of an alias node must contain at least one character");let Y=y.input.slice(q,y.position);return r.call(y.anchorMap,Y)||Z(y,'unidentified alias "'+Y+'"'),y.result=y.anchorMap[Y],X(y,!0,-1),!0}function wt(y,N,q,Y){let z=Te(y);return Ct(y),nt(y,N),y.tag=null,y.anchor=null,y.kind=null,y.result=null,pt(y,q,Y)&&y.kind==="mapping"?(at(y),!0):($e(y),nt(y,z),!1)}function qn(y,N,q,Y,z){let E,G,H=1,ee=!1,te=!1,oe=null,S,A,P;y.depth>=y.maxDepth&&Z(y,"nesting exceeded maxDepth ("+y.maxDepth+")"),y.depth+=1,y.listener!==null&&y.listener("open",y),y.tag=null,y.anchor=null,y.kind=null,y.result=null;let j=E=G=l===q||a===q;if(Y&&X(y,!0,-1)&&(ee=!0,y.lineIndent>N?H=1:y.lineIndent===N?H=0:y.lineIndent<N&&(H=-1)),H===1)for(;;){let U=y.input.charCodeAt(y.position),L=Te(y);if(ee&&(U===33&&y.tag!==null||U===38&&y.anchor!==null)||!et(y)&&!Ut(y))break;oe===null&&(oe=L),X(y,!0,-1)?(ee=!0,G=j,y.lineIndent>N?H=1:y.lineIndent===N?H=0:y.lineIndent<N&&(H=-1)):G=!1}if(G&&(G=ee||z),H===1||l===q)if(o===q||s===q?A=N:A=N+1,P=y.position-y.lineStart,H===1)if(G&&(Oe(y,P)||pt(y,P,A))||W(y,A))te=!0;else{let U=y.input.charCodeAt(y.position);oe!==null&&j&&!G&&U!==124&&U!==62&&wt(y,oe,oe.position-oe.lineStart,A)||E&&de(y,A)||Je(y,A)||Bt(y,A)?te=!0:Tt(y)?(te=!0,(y.tag!==null||y.anchor!==null)&&Z(y,"alias node should not have any properties")):gt(y,A,o===q)&&(te=!0,y.tag===null&&(y.tag="?")),y.anchor!==null&&we(y,y.anchor,y.result)}else H===0&&(te=G&&Oe(y,P));if(y.tag===null)y.anchor!==null&&we(y,y.anchor,y.result);else if(y.tag==="?"){y.result!==null&&y.kind!=="scalar"&&Z(y,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+y.kind+'"');for(let U=0,L=y.implicitTypes.length;U<L;U+=1)if(S=y.implicitTypes[U],S.resolve(y.result)){y.result=S.construct(y.result),y.tag=S.tag,y.anchor!==null&&we(y,y.anchor,y.result);break}}else if(y.tag!=="!"){if(r.call(y.typeMap[y.kind||"fallback"],y.tag))S=y.typeMap[y.kind||"fallback"][y.tag];else{S=null;let U=y.typeMap.multi[y.kind||"fallback"];for(let L=0,re=U.length;L<re;L+=1)if(y.tag.slice(0,U[L].tag.length)===U[L].tag){S=U[L];break}}S||Z(y,"unknown tag !<"+y.tag+">"),y.result!==null&&S.kind!==y.kind&&Z(y,"unacceptable node kind for !<"+y.tag+'> tag; it should be "'+S.kind+'", not "'+y.kind+'"'),S.resolve(y.result,y.tag)?(y.result=S.construct(y.result,y.tag),y.anchor!==null&&we(y,y.anchor,y.result)):Z(y,"cannot resolve a node with !<"+y.tag+"> explicit tag")}return y.listener!==null&&y.listener("close",y),y.depth-=1,y.tag!==null||y.anchor!==null||te}function Pr(y){let N=y.position,q=!1,Y;for(y.version=null,y.checkLineBreaks=y.legacy,y.tagMap=Object.create(null),y.anchorMap=Object.create(null);(Y=y.input.charCodeAt(y.position))!==0&&(X(y,!0,-1),Y=y.input.charCodeAt(y.position),!(y.lineIndent>0||Y!==37));){q=!0,Y=y.input.charCodeAt(++y.position);let z=y.position;for(;Y!==0&&!R(Y);)Y=y.input.charCodeAt(++y.position);let E=y.input.slice(z,y.position),G=[];for(E.length<1&&Z(y,"directive name must not be less than one character in length");Y!==0;){for(;k(Y);)Y=y.input.charCodeAt(++y.position);if(Y===35){do Y=y.input.charCodeAt(++y.position);while(Y!==0&&!x(Y));break}if(x(Y))break;for(z=y.position;Y!==0&&!R(Y);)Y=y.input.charCodeAt(++y.position);G.push(y.input.slice(z,y.position))}Y!==0&&Re(y),r.call(St,E)?St[E](y,E,G):xe(y,'unknown document directive "'+E+'"')}if(X(y,!0,-1),y.lineIndent===0&&y.input.charCodeAt(y.position)===45&&y.input.charCodeAt(y.position+1)===45&&y.input.charCodeAt(y.position+2)===45?(y.position+=3,X(y,!0,-1)):q&&Z(y,"directives end mark is expected"),qn(y,y.lineIndent-1,l,!1,!0),X(y,!0,-1),y.checkLineBreaks&&f.test(y.input.slice(N,y.position))&&xe(y,"non-ASCII line breaks are interpreted as content"),y.documents.push(y.result),y.position===y.lineStart&&Ce(y)){y.input.charCodeAt(y.position)===46&&(y.position+=3,X(y,!0,-1));return}y.position<y.length-1&&Z(y,"end of the stream or a document separator is expected")}function Or(y,N){y=String(y),N=N||{},y.length!==0&&(y.charCodeAt(y.length-1)!==10&&y.charCodeAt(y.length-1)!==13&&(y+=`
|
|
112
|
+
`),y.charCodeAt(0)===65279&&(y=y.slice(1)));let q=new I(y,N),Y=y.indexOf("\0");for(Y!==-1&&(q.position=Y,Z(q,"null byte is not allowed in input")),q.input+="\0";q.input.charCodeAt(q.position)===32;)q.lineIndent+=1,q.position+=1;for(;q.position<q.length-1;)Pr(q);return q.documents}function ki(y,N,q){N!==null&&typeof N=="object"&&typeof q>"u"&&(q=N,N=null);let Y=Or(y,q);if(typeof N!="function")return Y;for(let z=0,E=Y.length;z<E;z+=1)N(Y[z])}function Vo(y,N){let q=Or(y,N);if(q.length!==0){if(q.length===1)return q[0];throw new t("expected a single document in the stream, but found more")}}return bv.loadAll=ki,bv.load=Vo,bv}function Tge(){if(Fq)return SI;Fq=1;let e=Om(),t=Cm(),n=EI(),i=Object.prototype.toString,r=Object.prototype.hasOwnProperty,o=65279,s=9,a=10,l=13,c=32,u=33,d=34,p=35,f=37,g=38,h=39,b=42,w=44,x=45,k=58,R=61,$=62,_=63,T=64,C=91,K=93,O=96,pe=123,F=124,Q=125,I={};I[0]="\\0",I[7]="\\a",I[8]="\\b",I[9]="\\t",I[10]="\\n",I[11]="\\v",I[12]="\\f",I[13]="\\r",I[27]="\\e",I[34]='\\"',I[92]="\\\\",I[133]="\\N",I[160]="\\_",I[8232]="\\L",I[8233]="\\P";let B=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],Z=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function xe(E,G){if(G===null)return{};let H={},ee=Object.keys(G);for(let te=0,oe=ee.length;te<oe;te+=1){let S=ee[te],A=String(G[S]);S.slice(0,2)==="!!"&&(S="tag:yaml.org,2002:"+S.slice(2));let P=E.compiledTypeMap.fallback[S];P&&r.call(P.styleAliases,A)&&(A=P.styleAliases[A]),H[S]=A}return H}function we(E){let G,H,ee=E.toString(16).toUpperCase();if(E<=255)G="x",H=2;else if(E<=65535)G="u",H=4;else if(E<=4294967295)G="U",H=8;else throw new t("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+G+e.repeat("0",H-ee.length)+ee}let Ct=1,at=2;function $e(E){this.schema=E.schema||n,this.indent=Math.max(1,E.indent||2),this.noArrayIndent=E.noArrayIndent||!1,this.skipInvalid=E.skipInvalid||!1,this.flowLevel=e.isNothing(E.flowLevel)?-1:E.flowLevel,this.styleMap=xe(this.schema,E.styles||null),this.sortKeys=E.sortKeys||!1,this.lineWidth=E.lineWidth||80,this.noRefs=E.noRefs||!1,this.noCompatMode=E.noCompatMode||!1,this.condenseFlow=E.condenseFlow||!1,this.quotingType=E.quotingType==='"'?at:Ct,this.forceQuotes=E.forceQuotes||!1,this.replacer=typeof E.replacer=="function"?E.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function Te(E,G){let H=e.repeat(" ",G),ee=0,te="",oe=E.length;for(;ee<oe;){let S,A=E.indexOf(`
|
|
113
|
+
`,ee);A===-1?(S=E.slice(ee),ee=oe):(S=E.slice(ee,A+1),ee=A+1),S.length&&S!==`
|
|
114
|
+
`&&(te+=H),te+=S}return te}function nt(E,G){return`
|
|
115
|
+
`+e.repeat(" ",E.indent*G)}function St(E,G){for(let H=0,ee=E.implicitTypes.length;H<ee;H+=1)if(E.implicitTypes[H].resolve(G))return!0;return!1}function Ee(E){return E===c||E===s}function zt(E){return E>=32&&E<=126||E>=161&&E<=55295&&E!==8232&&E!==8233||E>=57344&&E<=65533&&E!==o||E>=65536&&E<=1114111}function Vn(E){return zt(E)&&E!==o&&E!==l&&E!==a}function ne(E,G,H){let ee=Vn(E),te=ee&&!Ee(E);return(H?ee:ee&&E!==w&&E!==C&&E!==K&&E!==pe&&E!==Q)&&E!==p&&!(G===k&&!te)||Vn(G)&&!Ee(G)&&E===p||G===k&&te}function Re(E){return zt(E)&&E!==o&&!Ee(E)&&E!==x&&E!==_&&E!==k&&E!==w&&E!==C&&E!==K&&E!==pe&&E!==Q&&E!==p&&E!==g&&E!==b&&E!==u&&E!==F&&E!==R&&E!==$&&E!==h&&E!==d&&E!==f&&E!==T&&E!==O}function X(E){return!Ee(E)&&E!==k}function Ce(E,G){let H=E.charCodeAt(G),ee;return H>=55296&&H<=56319&&G+1<E.length&&(ee=E.charCodeAt(G+1),ee>=56320&&ee<=57343)?(H-55296)*1024+ee-56320+65536:H}function tt(E){return/^\n* /.test(E)}let gt=1,Je=2,Bt=3,W=4,de=5;function Oe(E,G,H,ee,te,oe,S,A){let P,j=0,U=null,L=!1,re=!1,me=ee!==-1,Be=-1,Gt=Re(Ce(E,0))&&X(Ce(E,E.length-1));if(G||S)for(P=0;P<E.length;j>=65536?P+=2:P++){if(j=Ce(E,P),!zt(j))return de;Gt=Gt&&ne(j,U,A),U=j}else{for(P=0;P<E.length;j>=65536?P+=2:P++){if(j=Ce(E,P),j===a)L=!0,me&&(re=re||P-Be-1>ee&&E[Be+1]!==" ",Be=P);else if(!zt(j))return de;Gt=Gt&&ne(j,U,A),U=j}re=re||me&&P-Be-1>ee&&E[Be+1]!==" "}return!L&&!re?Gt&&!S&&!te(E)?gt:oe===at?de:Je:H>9&&tt(E)?de:S?oe===at?de:Je:re?W:Bt}function pt(E,G,H,ee,te){E.dump=(function(){if(G.length===0)return E.quotingType===at?'""':"''";if(!E.noCompatMode&&(B.indexOf(G)!==-1||Z.test(G)))return E.quotingType===at?'"'+G+'"':"'"+G+"'";let oe=E.indent*Math.max(1,H),S=E.lineWidth===-1?-1:Math.max(Math.min(E.lineWidth,40),E.lineWidth-oe),A=ee||E.flowLevel>-1&&H>=E.flowLevel;function P(j){return St(E,j)}switch(Oe(G,A,E.indent,S,P,E.quotingType,E.forceQuotes&&!ee,te)){case gt:return G;case Je:return"'"+G.replace(/'/g,"''")+"'";case Bt:return"|"+et(G,E.indent)+Ut(Te(G,oe));case W:return">"+et(G,E.indent)+Ut(Te(Tt(G,S),oe));case de:return'"'+qn(G)+'"';default:throw new t("impossible error: invalid scalar style")}})()}function et(E,G){let H=tt(E)?String(G):"",ee=E[E.length-1]===`
|
|
116
|
+
`,oe=ee&&(E[E.length-2]===`
|
|
117
|
+
`||E===`
|
|
118
|
+
`)?"+":ee?"":"-";return H+oe+`
|
|
119
|
+
`}function Ut(E){return E[E.length-1]===`
|
|
120
|
+
`?E.slice(0,-1):E}function Tt(E,G){let H=/(\n+)([^\n]*)/g,ee=(function(){let A=E.indexOf(`
|
|
121
|
+
`);return A=A!==-1?A:E.length,H.lastIndex=A,wt(E.slice(0,A),G)})(),te=E[0]===`
|
|
122
|
+
`||E[0]===" ",oe,S;for(;S=H.exec(E);){let A=S[1],P=S[2];oe=P[0]===" ",ee+=A+(!te&&!oe&&P!==""?`
|
|
123
|
+
`:"")+wt(P,G),te=oe}return ee}function wt(E,G){if(E===""||E[0]===" ")return E;let H=/ [^ ]/g,ee,te=0,oe,S=0,A=0,P="";for(;ee=H.exec(E);)A=ee.index,A-te>G&&(oe=S>te?S:A,P+=`
|
|
124
|
+
`+E.slice(te,oe),te=oe+1),S=A;return P+=`
|
|
125
|
+
`,E.length-te>G&&S>te?P+=E.slice(te,S)+`
|
|
126
|
+
`+E.slice(S+1):P+=E.slice(te),P.slice(1)}function qn(E){let G="",H=0;for(let ee=0;ee<E.length;H>=65536?ee+=2:ee++){H=Ce(E,ee);let te=I[H];!te&&zt(H)?(G+=E[ee],H>=65536&&(G+=E[ee+1])):G+=te||we(H)}return G}function Pr(E,G,H){let ee="",te=E.tag;for(let oe=0,S=H.length;oe<S;oe+=1){let A=H[oe];E.replacer&&(A=E.replacer.call(H,String(oe),A)),(N(E,G,A,!1,!1)||typeof A>"u"&&N(E,G,null,!1,!1))&&(ee!==""&&(ee+=","+(E.condenseFlow?"":" ")),ee+=E.dump)}E.tag=te,E.dump="["+ee+"]"}function Or(E,G,H,ee){let te="",oe=E.tag;for(let S=0,A=H.length;S<A;S+=1){let P=H[S];E.replacer&&(P=E.replacer.call(H,String(S),P)),(N(E,G+1,P,!0,!0,!1,!0)||typeof P>"u"&&N(E,G+1,null,!0,!0,!1,!0))&&((!ee||te!=="")&&(te+=nt(E,G)),E.dump&&a===E.dump.charCodeAt(0)?te+="-":te+="- ",te+=E.dump)}E.tag=oe,E.dump=te||"[]"}function ki(E,G,H){let ee="",te=E.tag,oe=Object.keys(H);for(let S=0,A=oe.length;S<A;S+=1){let P="";ee!==""&&(P+=", "),E.condenseFlow&&(P+='"');let j=oe[S],U=H[j];E.replacer&&(U=E.replacer.call(H,j,U)),N(E,G,j,!1,!1)&&(E.dump.length>1024&&(P+="? "),P+=E.dump+(E.condenseFlow?'"':"")+":"+(E.condenseFlow?"":" "),N(E,G,U,!1,!1)&&(P+=E.dump,ee+=P))}E.tag=te,E.dump="{"+ee+"}"}function Vo(E,G,H,ee){let te="",oe=E.tag,S=Object.keys(H);if(E.sortKeys===!0)S.sort();else if(typeof E.sortKeys=="function")S.sort(E.sortKeys);else if(E.sortKeys)throw new t("sortKeys must be a boolean or a function");for(let A=0,P=S.length;A<P;A+=1){let j="";(!ee||te!=="")&&(j+=nt(E,G));let U=S[A],L=H[U];if(E.replacer&&(L=E.replacer.call(H,U,L)),!N(E,G+1,U,!0,!0,!0))continue;let re=E.tag!==null&&E.tag!=="?"||E.dump&&E.dump.length>1024;re&&(E.dump&&a===E.dump.charCodeAt(0)?j+="?":j+="? "),j+=E.dump,re&&(j+=nt(E,G)),N(E,G+1,L,!0,re)&&(E.dump&&a===E.dump.charCodeAt(0)?j+=":":j+=": ",j+=E.dump,te+=j)}E.tag=oe,E.dump=te||"{}"}function y(E,G,H){let ee=H?E.explicitTypes:E.implicitTypes;for(let te=0,oe=ee.length;te<oe;te+=1){let S=ee[te];if((S.instanceOf||S.predicate)&&(!S.instanceOf||typeof G=="object"&&G instanceof S.instanceOf)&&(!S.predicate||S.predicate(G))){if(H?S.multi&&S.representName?E.tag=S.representName(G):E.tag=S.tag:E.tag="?",S.represent){let A=E.styleMap[S.tag]||S.defaultStyle,P;if(i.call(S.represent)==="[object Function]")P=S.represent(G,A);else if(r.call(S.represent,A))P=S.represent[A](G,A);else throw new t("!<"+S.tag+'> tag resolver accepts not "'+A+'" style');E.dump=P}return!0}}return!1}function N(E,G,H,ee,te,oe,S){E.tag=null,E.dump=H,y(E,H,!1)||y(E,H,!0);let A=i.call(E.dump),P=ee;ee&&(ee=E.flowLevel<0||E.flowLevel>G);let j=A==="[object Object]"||A==="[object Array]",U,L;if(j&&(U=E.duplicates.indexOf(H),L=U!==-1),(E.tag!==null&&E.tag!=="?"||L||E.indent!==2&&G>0)&&(te=!1),L&&E.usedDuplicates[U])E.dump="*ref_"+U;else{if(j&&L&&!E.usedDuplicates[U]&&(E.usedDuplicates[U]=!0),A==="[object Object]")ee&&Object.keys(E.dump).length!==0?(Vo(E,G,E.dump,te),L&&(E.dump="&ref_"+U+E.dump)):(ki(E,G,E.dump),L&&(E.dump="&ref_"+U+" "+E.dump));else if(A==="[object Array]")ee&&E.dump.length!==0?(E.noArrayIndent&&!S&&G>0?Or(E,G-1,E.dump,te):Or(E,G,E.dump,te),L&&(E.dump="&ref_"+U+E.dump)):(Pr(E,G,E.dump),L&&(E.dump="&ref_"+U+" "+E.dump));else if(A==="[object String]")E.tag!=="?"&&pt(E,E.dump,G,oe,P);else{if(A==="[object Undefined]")return!1;if(E.skipInvalid)return!1;throw new t("unacceptable kind of an object to dump "+A)}if(E.tag!==null&&E.tag!=="?"){let re=encodeURI(E.tag[0]==="!"?E.tag.slice(1):E.tag).replace(/!/g,"%21");E.tag[0]==="!"?re="!"+re:re.slice(0,18)==="tag:yaml.org,2002:"?re="!!"+re.slice(18):re="!<"+re+">",E.dump=re+" "+E.dump}}return!0}function q(E,G){let H=[],ee=[];Y(E,H,ee);let te=ee.length;for(let oe=0;oe<te;oe+=1)G.duplicates.push(H[ee[oe]]);G.usedDuplicates=new Array(te)}function Y(E,G,H){if(E!==null&&typeof E=="object"){let ee=G.indexOf(E);if(ee!==-1)H.indexOf(ee)===-1&&H.push(ee);else if(G.push(E),Array.isArray(E))for(let te=0,oe=E.length;te<oe;te+=1)Y(E[te],G,H);else{let te=Object.keys(E);for(let oe=0,S=te.length;oe<S;oe+=1)Y(E[te[oe]],G,H)}}}function z(E,G){G=G||{};let H=new $e(G);H.noRefs||q(E,H);let ee=E;return H.replacer&&(ee=H.replacer.call({"":ee},"",ee)),N(H,0,ee,!0,!0)?H.dump+`
|
|
127
|
+
`:""}return SI.dump=z,SI}function Dge(){if(Bq)return zn;Bq=1;let e=Ige(),t=Tge();function n(i,r){return function(){throw new Error("Function yaml."+i+" is removed in js-yaml 4. Use yaml."+r+" instead, which is now safe by default.")}}return zn.Type=tr(),zn.Schema=Gq(),zn.FAILSAFE_SCHEMA=Hq(),zn.JSON_SCHEMA=Zq(),zn.CORE_SCHEMA=Yq(),zn.DEFAULT_SCHEMA=EI(),zn.load=e.load,zn.loadAll=e.loadAll,zn.dump=t.dump,zn.YAMLException=Cm(),zn.types={binary:eK(),float:Jq(),map:Uq(),null:Vq(),pairs:nK(),set:rK(),timestamp:Xq(),bool:qq(),int:Kq(),merge:Qq(),omap:tK(),seq:zq(),str:Wq()},zn.safeLoad=n("safeLoad","load"),zn.safeLoadAll=n("safeLoadAll","loadAll"),zn.safeDump=n("safeDump","dump"),zn}var zn,bv,xa,hq,iI,yq,oI,bq,sI,wq,aI,vq,cI,kq,lI,xq,uI,$q,dI,Rq,pI,Sq,fI,Eq,mI,Aq,gI,Pq,hI,Oq,yI,Cq,bI,_q,wI,Iq,vI,Tq,kI,Dq,xI,Nq,$I,jq,RI,Lq,Mq,SI,Fq,Bq,Nge,bd,ZGe,YGe,XGe,QGe,eWe,tWe,nWe,rWe,iWe,oWe,sWe,aWe,cWe,lWe,AI=v(()=>{zn={},bv={},xa={};SI={};Nge=Dge(),bd=Cge(Nge),{Type:ZGe,Schema:YGe,FAILSAFE_SCHEMA:XGe,JSON_SCHEMA:QGe,CORE_SCHEMA:eWe,DEFAULT_SCHEMA:tWe,load:nWe,loadAll:rWe,dump:iWe,YAMLException:oWe,types:sWe,safeLoad:aWe,safeLoadAll:cWe,safeDump:lWe}=bd});function _n(e){return typeof e=="string"&&Lge.test(e)}function _m(e,t){let n=e?.[t];if(!Array.isArray(n))return[];let i=[];for(let r of n){if(r===null||typeof r!="object"||Array.isArray(r))continue;let{path:o,sha256:s}=r;_n(o)&&typeof s=="string"&&Mge.test(s)&&i.push({path:o,sha256:s})}return i}function PI(e,t){if(e.stat(t)!=="file")return;let n=e.bytes?e.bytes(t):Buffer.from(e.read(t),"utf-8");return dd(n)}function iK(e,t){let n=[],i=[];for(let r of e){let o=PI(t,r.path)??null,s=o===null?"missing":o===r.sha256?"pinned":"drifted";n.push({...r,actual:o,state:s}),s==="missing"?i.push({code:"asset-missing",message:`evidence pins ${r.path}, which does not exist`}):s==="drifted"&&i.push({code:"asset-drift",message:`${r.path} changed since it was pinned: sha256 ${r.sha256.slice(0,12)} is pinned, the file${t.label} hashes to ${o.slice(0,12)}`})}return{assets:n,warnings:i}}function Fr(e,t){let n=null;for(let i of t)(i.dir==="."||e===i.dir||e.startsWith(`${i.dir}/`))&&(!n||n.dir==="."||i.dir.length>n.dir.length)&&(n=i);return n?.name??null}function ls(e,t){return t===e||t.startsWith(`${e}/`)}function oK(e,t,n,i,r){let o=[];for(let s of t){if(s.id===null||s.supersededBy!==null)continue;let a={origin:"declared",resolves:"source",recordKind:e,record:s.id,recordPath:s.path};for(let c of s.assets)o.push({kind:"asset",...a,target:c.path,member:Fr(c.path,r),status:c.state,reason:c.state==="missing"?`${c.path} does not exist${i.label}`:c.state==="drifted"?`${c.path} changed since ${s.id} pinned it`:c.state==="stale"?`${c.path} has not changed since a record ${s.id} supersedes pinned it`:null,sha256:c.sha256,actual:c.actual});let l=n?s.data?.[n]:void 0;if(Array.isArray(l)){for(let c of l)if(typeof c=="string"){if(c.startsWith("member:")){let u=c.slice(7),d=r.some(p=>p.name===u);o.push({kind:"constrains",...a,target:c,member:d?u:null,status:d?"resolved":"missing",reason:d?null:`${u} is not a member of this workspace`})}else if(c.startsWith("path:")){let u=c.slice(5);if(!_n(u))continue;let d=i.stat(u)!==void 0;o.push({kind:"constrains",...a,target:c,member:Fr(u,r),status:d?"resolved":"missing",reason:d?null:`${u} does not exist${i.label}`})}}}}return o}var jge,Lge,Mge,po=v(()=>{"use strict";as();jge=String.raw`(?!/)(?!(?:[^/]*/)*\.{1,2}(?:/|$))(?!.*//)[^\\\u0000-\u001f]*[^/\\\u0000-\u001f]`,Lge=new RegExp(`^${jge}$`,"u"),Mge=/^[0-9a-f]{64}$/});function wv(e,t,n="markdown-front-matter"){return wd(e,t,n)}function sK(e,t,n,i){let r=e.session;if(!r)return;let o=new Set(e.closedStates),s=new Set((i??[]).flatMap(l=>l.records.map(c=>c.id)).filter(l=>l!==null)),a=new Map;for(let{s:l,reviewsField:c}of(i??[]).flatMap(u=>u.records.map(d=>({s:d,reviewsField:u.reviews})))){if(l.id===null)continue;let u=l.data?.[c];Array.isArray(u)&&u.forEach((d,p)=>{if(d===null||typeof d!="object")return;let f=d;if(typeof f.session!="string")return;let g=a.get(f.session)??[];g.push({id:l.id,path:l.path,index:p,reviewer:typeof f.reviewer=="string"?f.reviewer:null,verdict:typeof f.verdict=="string"?f.verdict:null}),a.set(f.session,g)})}for(let l of t){if(l.citedBy=l.id===null?[]:a.get(l.id)??[],l.data===null)continue;if(l.state!==null&&o.has(l.state)){let u=l.data[r.seal],d=n.get(l.path);if(typeof u=="string"&&d!==void 0){let p=wv(d,r.seal,e.format);p!==u&&l.reasons.push({code:"session-seal-mismatch",message:/^[0-9a-f]{64}$/.test(u)?`${r.seal} is ${u}, a seal by the text rule chant used before #2546, and the session seals to ${p} now: seal it again by hand, since a closed session is never rewritten by chant`:`${r.seal} is ${u}, but the session seals to ${p}: the session changed after it closed`})}}if(i===null)continue;let c=l.data[r.verdicts];Array.isArray(c)&&c.forEach((u,d)=>{if(u===null||typeof u!="object")return;let p=u.record;typeof p=="string"&&!s.has(p)&&l.reasons.push({code:"session-verdict-unknown-record",message:`${r.verdicts}[${d}] names ${p}, which no ${Im(r).join(" or ")} record has`})})}}var OI=v(()=>{"use strict";mn()});import{readFileSync as Fge}from"node:fs";import{homedir as Bge}from"node:os";import{isAbsolute as Gge,join as Wge,resolve as zge}from"node:path";import{fileURLToPath as Uge}from"node:url";function lK(e,t){let n=e?.[t];return n!==null&&typeof n=="object"&&!Array.isArray(n)?n:void 0}function uK(e,t){let n=cK.safeParse(e);return n.success?[]:n.error.issues.map(i=>`/${[t,...i.path].join("/")} ${i.message}`)}function Vge(e,t){if(e.path!==void 0){let n=e.path;return n==="~"||n.startsWith("~/")?Wge(Bge(),n.slice(1)):Gge(n)?n:zge(t,n)}if(e.uri!==void 0&&e.uri.startsWith("file:"))try{return Uge(e.uri)}catch{return}}function dK(e,t,n){let i=cK.shape.transcript.safeParse(e.transcript);if(!i.success||i.data===void 0)return;let r=i.data,o=Vge(r,n);if(o===void 0)return;let s;try{s=Fge(o)}catch{return}let a=dd(s);if(a===r.sha256)return;let l=r.path??r.uri;return`${t}.transcript ${l} is pinned at sha256 ${r.sha256.slice(0,12)}, and the file here hashes to ${a.slice(0,12)}: it is not the transcript the record means`}var Hge,fo,aK,cK,pK=v(()=>{"use strict";Ln();as();Hge=["cli","mcp","harvest"],fo=m.string().min(1),aK=m.string().regex(/^[0-9a-f]{64}$/,"must be the lowercase hex SHA-256 of the transcript's bytes"),cK=m.object({via:m.enum(Hge).optional(),client:m.object({name:fo,version:fo.optional(),title:fo.optional()}).strict().optional(),harness:fo.optional(),model:fo.optional(),session:m.union([fo,m.null(),m.object({id:fo.optional(),record:fo.optional()}).strict().refine(e=>e.id!==void 0||e.record!==void 0,{message:"names neither the harness's session id nor a chant session record"})]).optional(),turns:m.object({from:m.number().int().min(0),to:m.number().int().min(0)}).strict().refine(e=>e.to>=e.from,{message:"ends before it starts"}).optional(),transcript:m.union([m.object({path:fo,sha256:aK}).strict(),m.object({uri:fo,sha256:aK}).strict()]).optional()})});var mK=ie(CI=>{"use strict";Object.defineProperty(CI,"__esModule",{value:!0});var qge=m_(),Kge=C_(),Jge=Y_(),Zge=f0(),fK=m0(),Yge=[qge.default,Kge.default,(0,Jge.default)(),Zge.default,fK.metadataVocabulary,fK.contentVocabulary];CI.default=Yge});var gK=ie(($We,Xge)=>{Xge.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0}});var yK=ie((Mt,_I)=>{"use strict";Object.defineProperty(Mt,"__esModule",{value:!0});Mt.MissingRefError=Mt.ValidationError=Mt.CodeGen=Mt.Name=Mt.nil=Mt.stringify=Mt.str=Mt._=Mt.KeywordCxt=Mt.Ajv=void 0;var Qge=d_(),ehe=mK(),the=b0(),hK=gK(),nhe=["/properties"],vv="http://json-schema.org/draft-07/schema",vd=class extends Qge.default{_addVocabularies(){super._addVocabularies(),ehe.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(the.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(hK,nhe):hK;this.addMetaSchema(t,vv,!1),this.refs["http://json-schema.org/schema"]=vv}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(vv)?vv:void 0)}};Mt.Ajv=vd;_I.exports=Mt=vd;_I.exports.Ajv=vd;Object.defineProperty(Mt,"__esModule",{value:!0});Mt.default=vd;var rhe=Uu();Object.defineProperty(Mt,"KeywordCxt",{enumerable:!0,get:function(){return rhe.KeywordCxt}});var kd=Fe();Object.defineProperty(Mt,"_",{enumerable:!0,get:function(){return kd._}});Object.defineProperty(Mt,"str",{enumerable:!0,get:function(){return kd.str}});Object.defineProperty(Mt,"stringify",{enumerable:!0,get:function(){return kd.stringify}});Object.defineProperty(Mt,"nil",{enumerable:!0,get:function(){return kd.nil}});Object.defineProperty(Mt,"Name",{enumerable:!0,get:function(){return kd.Name}});Object.defineProperty(Mt,"CodeGen",{enumerable:!0,get:function(){return kd.CodeGen}});var ihe=em();Object.defineProperty(Mt,"ValidationError",{enumerable:!0,get:function(){return ihe.default}});var ohe=Hu();Object.defineProperty(Mt,"MissingRefError",{enumerable:!0,get:function(){return ohe.default}})});var TI={};_e(TI,{EVIDENCE_RESULTS:()=>ahe,VERIFICATION_TYPES:()=>wK,WORK_WARNING_CODES:()=>II,acceptanceCriteria:()=>vK,applyWork:()=>che,idList:()=>Sr,isDecided:()=>qc,workAcceptance:()=>kK,workAnswers:()=>she});import{dirname as bK}from"node:path";function she(e,t){let n=new Map;for(let i of t)n.set(i,[]);for(let i of e)if(!(i.id===null||i.data===null))for(let r of Sr(i.data,"constrains")){let o=n.get(r);if(!o||o.some(a=>a.id===i.id))continue;let s=i.data.answer;o.push({id:i.id,point:typeof i.data.point=="string"?i.data.point:null,state:i.state,answer:typeof s=="string"||typeof s=="boolean"?s:null,answeredBy:Sr(i.data,"answered_by")})}return n}function vK(e,t){let n=e?.[t];return Array.isArray(n)?n.filter(i=>i!==null&&typeof i=="object"&&typeof i.id=="string"&&typeof i.text=="string"&&wK.includes(i.verification)):[]}function kK(e,t,n){if(!Array.isArray(e?.[t.field]))return{acceptance:null,selfVerified:[]};let i=vK(e,t.field),r=typeof e?.[t.implementer]=="string"?cn(e[t.implementer]):null,o=Array.isArray(e?.[n])?e[n]:[],s=[],a=i.map(l=>{let c=!1;for(let u of o){if(u===null||typeof u!="object")continue;let d=u;if(!(d.criterion!==l.id||d.result!=="pass"||d.verification!==l.verification)){if(l.verification==="manual"){if(typeof d.by!="string")continue;if(r!==null&&cn(d.by)===r){s.includes(l.id)||s.push(l.id);continue}}c=!0}}return{id:l.id,verification:l.verification,met:c}});return{acceptance:{met:a.filter(l=>l.met).length,total:a.length,criteria:a},selfVerified:s}}function Sr(e,t){let n=e?.[t];return Array.isArray(n)?n.filter(i=>typeof i=="string"):[]}function qc(e,t){return t===null?!1:e.approval?(e.approval[t]??0)>0:(e.closedStates??[]).includes(t)}async function che(e,t,n){let{kind:i}=e,r=i.work,o=await gn(r.decisions,bK(e.file)),s=await $a(o,{root:n.root,source:n.source}),a=new Map;for(let f of s.records)f.id!==null&&!a.has(f.id)&&a.set(f.id,f);let l=new Map;for(let f of t)f.id!==null&&!l.has(f.id)&&l.set(f.id,f);let c=new Set(i.closedStates),u;if(r.contract){let f=await gn(r.contract.kind,bK(e.file)),g=await $a(f,{root:n.root,source:n.source}),h=new Map;for(let b of g.records)b.id!==null&&!h.has(b.id)&&h.set(b.id,b);u={kind:f,byId:h}}let d=new Set;for(let f of l.keys()){let g=new Set,h=[...Sr(l.get(f).data,r.needs)];for(;h.length>0;){let b=h.pop();if(b===f){d.add(f);break}g.has(b)||(g.add(b),h.push(...Sr(l.get(b)?.data??null,r.needs)))}}let p=new Map;for(let f of t){if(f.data===null)continue;let g=Sr(f.data,r.needs),h=Sr(f.data,r.implements);f.blockedBy=g.filter(R=>l.get(R)?.state!==r.done).map(R=>({id:R,state:l.get(R)?.state??null})),f.implements=h.map(R=>({id:R,state:a.get(R)?.state??null})),f.ready=f.state===r.open&&f.blockedBy.length===0&&f.reasons.length===0&&f.supersededBy===null&&!(f.id!==null&&d.has(f.id)),f.warnings=f.warnings.filter(R=>R.code!=="record-no-evidence");let b=g.filter(R=>!l.has(R));b.length>0&&f.warnings.push({code:"work-needs-unknown",message:`needs ${b.join(", ")}, which no work record has, so the item stays blocked`});let w=h.filter(R=>!a.has(R));w.length>0&&f.warnings.push({code:"work-implements-unknown",message:`implements ${w.join(", ")}, which no decision in ${r.decisions} has`}),f.id!==null&&d.has(f.id)&&f.warnings.push({code:"work-needs-cycle",message:`${f.id} needs itself through its needs links, so it can never be ready`});let x=f.implements.filter(R=>R.state!==null&&!qc(o.kind,R.state));x.length>0&&f.warnings.push({code:"work-implements-undecided",message:`implements ${x.map(R=>`${R.id}, which is ${R.state}`).join("; ")}: the work may carry out a choice nobody has made`});let k=i.pins?f.data[i.pins.field]:void 0;if(f.state===r.done&&i.pins&&!(Array.isArray(k)&&k.length>0)&&f.warnings.push({code:"work-done-unpinned",message:`${f.id??f.path} is ${r.done} and ${i.pins.field} is empty or missing: nothing shows the work was done`}),r.acceptance&&i.pins){let{acceptance:R,selfVerified:$}=kK(f.data,r.acceptance,i.pins.field);f.acceptance=R,$.length>0&&f.warnings.push({code:"work-acceptance-self-verified",message:`the manual verdict on ${$.join(", ")} is by ${String(f.data[r.acceptance.implementer])}, the implementer, so it does not count: a manual verdict comes from someone else`});let _=R?.criteria.filter(T=>!T.met)??[];f.state===r.done&&_.length>0&&f.warnings.push({code:"work-acceptance-unmet",message:`${f.id??f.path} is ${r.done}, and no passing evidence meets ${_.map(T=>`${T.id} (${T.verification})`).join(", ")}`})}if(u&&r.contract){let R=f.data[r.contract.field];if(typeof R=="string"&&R!==""){let $=u.byId.get(R);f.contract={id:R,state:$?.state??null},$?qc(u.kind.kind,$.state)||f.warnings.push({code:"work-contract-undecided",message:`names the contract ${R}, which is ${$.state??"in no state"}: the work may build a contract nobody approved`}):f.warnings.push({code:"work-contract-unknown",message:`names the contract ${R}, which no record in ${r.contract.kind} has`})}else f.contract=null}if(r.tier){let R=f.data[r.tier.field];typeof R=="string"&&!r.tier.tiers.includes(R)&&f.warnings.push({code:"work-tier-unknown",message:`names the builder tier ${R}, which the kind's tiers (${r.tier.tiers.join(", ")}) do not list`})}if(f.state!==null&&c.has(f.state)&&typeof f.data[r.closedOn]!="string"&&f.warnings.push({code:"work-closed-without-date",message:`${f.id??f.path} is ${f.state} and has no ${r.closedOn}`}),f.id!==null&&l.get(f.id)===f)for(let R of h){let $=p.get(R)??[];$.some(_=>_.id===f.id)||$.push({id:f.id,state:f.state}),p.set(R,$)}}return{decisions:s.records.filter(f=>f.id!==null&&a.get(f.id)===f).map(f=>({id:f.id,path:f.path,state:f.state,supersededBy:f.supersededBy,implementedBy:p.get(f.id)??[]}))}}var II,wK,ahe,xd=v(()=>{"use strict";mn();II=["work-needs-unknown","work-implements-unknown","work-needs-cycle","work-implements-undecided","work-done-unpinned","work-closed-without-date","work-done-gap-open","work-acceptance-unmet","work-acceptance-self-verified","work-contract-unknown","work-contract-undecided","work-tier-unknown"];wK=["unit","integration","e2e","runtime","manual"],ahe=["pass","fail"]});var DI,xK=v(()=>{DI={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://intentius.io/chant/schemas/workspace/decision-points/v1/decision-points.schema.json",title:"Decision points",description:"A workspace's decision points (ws-058, #2738): the recurring questions it asks of its own graph, declared as data in a JSON file that an answer record kind names in `answers.points`. Each point is a typed question (`noul`, `choice` with 2 to 255 options, or `score` with 2 to 10 ordered levels, the question types of the POST /v1/systemone wire format, #2491), the inputs it reads, each named as a read-contract output, and an ordered chain of deciders: `table` rows, `model` deciders with a backend, a pinned model id and a threshold, and a `quorum` of people, always last. What JSON Schema cannot say is checked in code (`points.ts`): an input's output is one the read contract has, a table row tests declared inputs and answers a candidate, a field belongs to its decider's kind, a model id is pinned rather than an alias, and the chain ends in its one quorum. A point declared `adhoc` (#3403) leaves out its question's criteria: the question's text and candidates come with each ask (`points ask --candidates`), and its chain is one quorum. Unknown fields are refused, except fields whose names start with x-.",type:"object",required:["points"],properties:{$schema:{type:"string"},points:{type:"object",minProperties:1,propertyNames:{pattern:"^[a-z][a-z0-9-]*$"},additionalProperties:{$ref:"#/$defs/point"}}},patternProperties:{"^x-":!0},additionalProperties:!1,$defs:{text:{type:"string",minLength:1},point:{type:"object",required:["title","question","inputs","deciders"],properties:{title:{$ref:"#/$defs/text"},adhoc:{type:"boolean",description:"An ad-hoc point (#3403): the question declares its type and what the asks are for, and no criteria. Each ask gives the question's text and its candidates, and the answer record keeps them, so people's answer is checked against them. Its chain is one quorum."},question:{$ref:"#/$defs/question"},inputs:{type:"object",description:"The state the deciders see, input name to description. A name is a read-contract output (record, decision, work-item, finding, region, commit, node, member, gate, release, environment, component, ask), optionally followed by dotted field names, such as work-item.fits_small: a field of that output, or a value the caller derives from it. The caller supplies the values; a table row can only test these names.",minProperties:1,propertyNames:{pattern:"^[A-Za-z_][A-Za-z0-9_-]*(\\.[A-Za-z_][A-Za-z0-9_]*)*$"},additionalProperties:{type:"string"}},deciders:{type:"array",minItems:1,items:{$ref:"#/$defs/decider"}}},patternProperties:{"^x-":!0},additionalProperties:!1,if:{properties:{adhoc:{const:!0}},required:["adhoc"]},then:{properties:{question:{not:{required:["criteria"]}}}},else:{properties:{question:{required:["criteria"]}}}},question:{type:"object",required:["type","instructions"],properties:{type:{enum:["noul","choice","score"]},instructions:{$ref:"#/$defs/text"},criteria:{description:"The candidates. noul: {true, false} descriptions. choice: option to description, 2 to 255 options. score: 2 to 10 ordered levels.",type:["object","array"]}},additionalProperties:!1,allOf:[{if:{properties:{type:{const:"noul"}}},then:{properties:{criteria:{type:"object",required:["true","false"],properties:{true:{type:"string"},false:{type:"string"}},additionalProperties:!1}}}},{if:{properties:{type:{const:"choice"}}},then:{properties:{criteria:{type:"object",minProperties:2,maxProperties:255,additionalProperties:{type:"string"}}}}},{if:{properties:{type:{const:"score"}}},then:{properties:{criteria:{type:"array",minItems:2,maxItems:10,uniqueItems:!0,items:{$ref:"#/$defs/text"}}}}}]},scalar:{type:["string","number","boolean","null"]},condition:{description:"A value the input must equal, or one comparison.",oneOf:[{$ref:"#/$defs/scalar"},{type:"object",minProperties:1,maxProperties:1,properties:{eq:{$ref:"#/$defs/scalar"},ne:{$ref:"#/$defs/scalar"},lt:{type:"number"},lte:{type:"number"},gt:{type:"number"},gte:{type:"number"},in:{type:"array",items:{$ref:"#/$defs/scalar"}}},additionalProperties:!1}]},row:{type:"object",required:["when","answer"],properties:{when:{type:"object",description:"Every named input must meet its condition. An empty object matches every state.",additionalProperties:{$ref:"#/$defs/condition"}},answer:{type:["string","boolean"]},note:{type:"string"}},additionalProperties:!1},decider:{type:"object",required:["kind"],properties:{kind:{enum:["table","model","quorum"]},rows:{type:"array",minItems:1,items:{$ref:"#/$defs/row"}},backend:{type:"string",pattern:"^[a-z][a-z0-9-]*$",description:"model: which backend answers, such as systemone (any server with the POST /v1/systemone wire format). chant never calls it: the decide Op activity or a runtime's decider does."},model:{type:"string",minLength:1,description:"model: the pinned model id the backend is asked for, such as jev-1.13.0. An alias such as jev-latest is refused."},threshold:{type:"number",exclusiveMinimum:0,maximum:1,description:"model: the least confidence that makes the answer a proposal. Below it the answer is not observed and the next decider is asked."},unreachable:{enum:["escalate","fail"],description:"model: what happens when the backend can't be reached or gives no usable answer: escalate to the next decider (the default), or fail the ask and write nothing."},count:{type:"integer",minimum:1,description:"quorum: how many distinct people must answer."},roles:{type:"array",minItems:1,items:{$ref:"#/$defs/text"},description:"quorum: the trust policy roles whose holders count."},note:{type:"string"}},additionalProperties:!1,allOf:[{if:{properties:{kind:{const:"table"}}},then:{required:["rows"]}},{if:{properties:{kind:{const:"model"}}},then:{required:["backend","model","threshold"]}},{if:{properties:{kind:{const:"quorum"}}},then:{required:["count"]}}]}}}});var TK={};_e(TK,{ANSWER_WARNING_CODES:()=>khe,DECISION_POINTS_SCHEMA_ID:()=>ghe,DeciderFailed:()=>$d,POINT_INPUT_OUTPUTS:()=>SK,POINT_INPUT_OUTPUT_NAMES:()=>jI,PointsError:()=>Kc,answerId:()=>FI,answerReason:()=>CK,applyAnswers:()=>xhe,askedOf:()=>Nm,askedQuestion:()=>Sd,candidates:()=>mo,canonical:()=>Dm,inputOutput:()=>Jc,inputsHash:()=>LI,matches:()=>OK,observe:()=>IK,parseAsked:()=>MI,parsePoints:()=>AK,pointOf:()=>Rd,pointVersion:()=>Ra,pointsFileOf:()=>Ad,quorumOf:()=>Ed,readPointsThrough:()=>Pd,runChain:()=>BI,schemaProblems:()=>EK,wireQuestion:()=>_K});import{createHash as uhe}from"node:crypto";import{dirname as dhe,posix as NI,relative as phe,resolve as fhe,sep as mhe}from"node:path";function Jc(e){let t=e.indexOf(".");return t<0?e:e.slice(0,t)}function mo(e){return e.type==="noul"?[!0,!1]:e.type==="choice"?Object.keys(e.criteria??{}):[...e.criteria??[]]}function yhe(e){let t=[];for(let[n,i]of Object.entries(e)){let r=(...l)=>["points",n,...l].join("."),o=Object.keys(i.inputs);for(let l of o){let c=Jc(l);jI.includes(c)||t.push({field:r("inputs",l),message:`names ${JSON.stringify(c)}, which is not a read-contract output; an input is one of ${jI.join(", ")}, optionally with dotted field names`})}i.adhoc&&(i.deciders.length!==1||i.deciders[0].kind!=="quorum")&&t.push({field:r("deciders"),message:"is an ad-hoc point's chain, and an ad-hoc point is decided by people alone: its chain is one quorum, since no table row or model can know candidates that come with the ask"});let s=mo(i.question),a=i.deciders.length-1;i.deciders.forEach((l,c)=>{let u=l;for(let[d,p]of Object.entries($K))if(d!==l.kind)for(let f of p)u[f]!==void 0&&!$K[l.kind].includes(f)&&t.push({field:r("deciders",c,f),message:`is only for a ${d} decider, and this one is a ${l.kind}`});l.kind==="quorum"&&c!==a&&t.push({field:r("deciders",c),message:"is a quorum, and a quorum is the last decider: nobody is asked after people"}),l.kind==="model"&&hhe.test(l.model)&&t.push({field:r("deciders",c,"model"),message:`${JSON.stringify(l.model)} is an alias, and an alias moves when a new release ships: pin a versioned model id`}),l.kind==="table"&&l.rows.forEach((d,p)=>{s.includes(d.answer)||t.push({field:r("deciders",c,"rows",p,"answer"),message:`must be one of ${s.map(f=>JSON.stringify(f)).join(", ")}, not ${JSON.stringify(d.answer)}`});for(let f of Object.keys(d.when))o.includes(f)||t.push({field:r("deciders",c,"rows",p,"when",f),message:`is not one of this point's inputs (${o.join(", ")})`})})}),i.deciders[a]?.kind!=="quorum"&&t.push({field:r("deciders"),message:"must end in a quorum: when no table row or model answers, people do"})}return t}function bhe(){if(kv)return kv;let e=fa();return kv=new e({allErrors:!0,strict:!1}).compile(DI),kv}function EK(e){let t=bhe();if(t(e))return[];let n=new Set,i=[];for(let r of t.errors??[]){if(whe.has(r.keyword))continue;let o=r.instancePath.split("/").slice(1).map(c=>c.replace(/~1/g,"/").replace(/~0/g,"~")),s=o.length?o.join("."):null,a=r.keyword==="additionalProperties"?`has an unknown field ${JSON.stringify(r.params.additionalProperty)}; only fields named x-... may be added`:r.keyword==="required"?`is missing ${JSON.stringify(r.params.missingProperty)}`:r.keyword==="propertyNames"?`has a name that is not allowed: ${JSON.stringify(r.params.propertyName)}`:r.keyword==="not"?"has criteria, and an ad-hoc point's candidates come with each ask (#3403): leave criteria out":r.message??"is invalid",l=`${s}\0${a}`;n.has(l)||(n.add(l),i.push({field:s,message:a}))}return i}function AK(e,t){let n;try{n=JSON.parse(e)}catch(s){throw new Kc(t,[{field:null,message:`is not JSON: ${s instanceof Error?s.message:String(s)}`}])}let i=EK(n);if(i.length>0)throw new Kc(t,i);let r=n.points,o=yhe(r);if(o.length>0)throw new Kc(t,o);return r}function Rd(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function Dm(e){if(Array.isArray(e))return`[${e.map(Dm).join(",")}]`;if(e!==null&&typeof e=="object"){let t=e;return`{${Object.keys(t).sort().filter(n=>t[n]!==void 0).map(n=>`${JSON.stringify(n)}:${Dm(t[n])}`).join(",")}}`}return JSON.stringify(e)}function Sd(e,t){return t?{type:e.question.type,instructions:t.question,criteria:t.criteria}:e.question}function MI(e,t){if(t===null||typeof t!="object"||Array.isArray(t))return{problems:["the candidates must be a JSON object with question and criteria"]};let n=t,i=[],r=Object.keys(n).filter(l=>l!=="question"&&l!=="criteria");r.length>0&&i.push(`the candidates take question and criteria, not ${r.join(", ")}`),RK(n.question)||i.push("question must be the question's text");let o=n.criteria,s=e.question.type;if(s==="score")(!Array.isArray(o)||o.length<2||o.length>10||!o.every(RK)||new Set(o).size!==o.length)&&i.push("criteria must be 2 to 10 distinct levels, in order, for a score question");else if(o===null||typeof o!="object"||Array.isArray(o))i.push(`criteria must be an object of ${s==="noul"?"true and false":"options"}, each with what it means`);else{let l=Object.entries(o);if(l.every(([c,u])=>c!==""&&typeof u=="string")||i.push("each criterion must be a non-empty name with what it means as a string"),s==="noul"){let c=l.map(([u])=>u).sort();(c.length!==2||c[0]!=="false"||c[1]!=="true")&&i.push("criteria must describe true and false, and nothing else, for a noul question")}else(l.length<2||l.length>255)&&i.push("criteria must give 2 to 255 options for a choice question")}if(i.length>0)return{problems:i};let a=Array.isArray(o)?[...o]:{...o};return{asked:{question:n.question.trim(),criteria:a}}}function Nm(e){let t=e.asked;if(t===null||typeof t!="object"||Array.isArray(t)||typeof t.question!="string")return;let n=t.criteria;if(Array.isArray(n))return{question:t.question,criteria:n.filter(i=>typeof i=="string")};if(n!==null&&typeof n=="object")return{question:t.question,criteria:Object.fromEntries(Object.entries(n).filter(([,i])=>typeof i=="string"))}}function Ed(e){let t=e.deciders[e.deciders.length-1];return t?.kind==="quorum"?{count:t.count,...t.roles?{roles:t.roles}:{}}:{count:1}}function vhe(e,t){if(e===null||typeof e!="object")return t===e;let[[n,i]]=Object.entries(e),r=typeof t=="number";switch(n){case"eq":return t===i;case"ne":return t!==i;case"lt":return r&&t<i;case"lte":return r&&t<=i;case"gt":return r&&t>i;case"gte":return r&&t>=i;case"in":return i.includes(t);default:return!1}}function CK(e){let t=e?.reason;if(typeof t!="string")return;let n=t.trim();return n===""?void 0:n}function _K(e){return{type:e.type,instructions:e.instructions,criteria:e.criteria??{}}}function IK(e,t,n){let i=mo(e);if(!t||t.type==="unsupported")return{observed:!1,reason:"the backend does not support this question type"};if(e.type==="noul"){let c=Number(t.noul);if(!(c>=0&&c<=1))return{observed:!1,reason:"the answer carries no probability"};let u={true:Tm(c),false:Tm(1-c)},d=Tm(Math.max(c,1-c));return c>=n?{observed:!0,answer:!0,probabilities:u,confidence:d}:1-c>=n?{observed:!0,answer:!1,probabilities:u,confidence:d}:{observed:!1,answer:c>=.5,probabilities:u,confidence:d,reason:`confidence ${d} is below the threshold ${n}`}}let r=t,o=Object.fromEntries(Object.entries(r.probabilities??{}).map(([c,u])=>[c,Number(u)]).filter(([,c])=>Number.isFinite(c)&&c>=0&&c<=1).map(([c,u])=>[c,Tm(u)])),s=e.type==="choice"?r.choice:Object.entries(o).sort((c,u)=>u[1]-c[1])[0]?.[0],a=Number(r.confidence),l=Tm(r.confidence!==void 0&&Number.isFinite(a)?a:Math.max(0,...Object.values(o)));return typeof s!="string"||!i.includes(s)?{observed:!1,answer:typeof s=="string"?s:null,probabilities:o,confidence:l,reason:`the answer ${JSON.stringify(s??null)} is not a candidate`}:l>=n?{observed:!0,answer:s,probabilities:o,confidence:l}:{observed:!1,answer:s,probabilities:o,confidence:l,reason:`confidence ${l} is below the threshold ${n}`}}async function BI(e,t,n,i){let r=[];for(let o of t.deciders)if(o.kind==="table"){let s=o.rows.findIndex(a=>OK(a.when,n));if(s>=0)return{status:"answered",answer:o.rows[s].answer,decider:{kind:"table",row:s},...o.rows[s].note?{note:o.rows[s].note}:{},escalations:r};r.push({kind:"table",reason:"no row matches these inputs"})}else if(o.kind==="model"){if(!i){r.push({kind:"model",backend:o.backend,model:o.model,threshold:o.threshold,reason:"not asked: no model backend was given to this ask"});continue}let s;try{s=await i({point:e,backend:o.backend,model:o.model,question:_K(t.question),state:n})}catch(c){let u=`${o.backend} could not answer: ${c instanceof Error?c.message:String(c)}`;if(o.unreachable==="fail")throw new $d(`${e}: ${u}, and the point fails closed (unreachable: "fail")`);r.push({kind:"model",backend:o.backend,model:o.model,threshold:o.threshold,reason:`not observed: ${u}`});continue}if(s.model!==o.model){r.push({kind:"model",backend:o.backend,model:s.model,threshold:o.threshold,reason:`not observed: ${s.model} answered, and the point pins ${o.model}`});continue}let a=IK(t.question,s.answer,o.threshold),l=CK(s.answer);if(a.observed)return{status:"proposed",answer:a.answer,decider:{kind:"model",backend:o.backend,model:s.model},probabilities:a.probabilities,confidence:a.confidence,threshold:o.threshold,...l!==void 0?{reason:l}:{},escalations:r};r.push({kind:"model",backend:o.backend,model:s.model,answer:a.answer??null,...a.probabilities?{probabilities:a.probabilities}:{},...a.confidence!==void 0?{confidence:a.confidence}:{},threshold:o.threshold,reason:`not observed: ${a.reason}`,...l!==void 0?{model_reason:l}:{}})}else return{status:"escalated",decider:{kind:"quorum",count:o.count,...o.roles?{roles:o.roles}:{}},escalations:r};return{status:"escalated",decider:{kind:"quorum",count:1},escalations:r}}function Ad(e,t){let n=fhe(dhe(e.file),e.kind.answers.points);return phe(t,n).split(mhe).join(NI.sep)}function Pd(e,t){if(!e.list(NI.dirname(t))?.includes(NI.basename(t)))return{error:`the points file ${t} does not exist${e.label}`,problems:[{field:null,message:`does not exist${e.label}`}]};let i;try{i=e.read(t)}catch(r){return{error:`the points file ${t} can't be read: ${r instanceof Error?r.message:String(r)}`,problems:[{field:null,message:"can't be read"}]}}try{return{points:AK(i,t)}}catch(r){if(r instanceof Kc)return{error:`the points file is not valid: ${r.message}`,problems:r.problems};throw r}}function xhe(e,t,n){let i=Ad(e,n.root),r=Pd(n.source,i);for(let o of t){if(o.data===null)continue;if("error"in r){o.warnings.push({code:"answer-points-unreadable",message:r.error});continue}let s=o.data.point;if(typeof s!="string")continue;let a=Rd(r.points,s);if(!a){o.warnings.push({code:"answer-point-unknown",message:`answers ${s}, which ${i} does not declare`});continue}typeof o.data.point_version=="string"&&o.data.point_version!==Ra(a)&&o.warnings.push({code:"answer-point-changed",message:`answers ${s} as it was declared at ${o.data.point_version.slice(0,12)}, and ${i} declares it at ${Ra(a).slice(0,12)} now: ask again for the question as it stands`})}}var ghe,SK,jI,Kc,$K,hhe,kv,whe,PK,Ra,LI,RK,FI,OK,Tm,$d,khe,jm=v(()=>{"use strict";xK();ym();ghe=DI.$id,SK={record:{schema:"records",def:"record",description:"a record of any kind, as records --json lists it"},decision:{schema:"records",def:"record",description:"a decision record, as records --json lists it"},"work-item":{schema:"records",def:"record",description:"a work item record, as records --json lists it (#2683)"},finding:{schema:"intent",def:"finding",description:"a finding of graph --intent, or of check --changes (#2794)"},region:{schema:"intent",def:"region",description:"the region an intent graph covers"},commit:{schema:"intent",def:"commit",description:"a commit in an intent graph's window"},node:{schema:"intent",def:"node",description:"any node of an intent graph, by its id and kind: a commit, decision, unit, artifact or the region itself, as an intent walk asks of it (#3351)"},ask:{schema:"points",def:"question",description:"an ad-hoc question as its asker knows it (#3403): the asker's own id for the ask, such as hud's request id for an agent's question, and who asked"},member:{schema:"ls",def:"member",description:"a member, as ls lists it"},gate:{schema:"status",def:"gate",description:"a gate, as status lists it"},release:{schema:"status",def:"release",description:"a release, as status lists it; a release plan's fields until the lifecycle ledger lists plans (#2717)"},environment:{schema:"status",def:"environment",description:"an environment, as status lists it"},component:{schema:"composites",def:"component",description:"a component, as graph --composites lists it"}},jI=Object.keys(SK);Kc=class extends Error{constructor(n,i){super(`${n}: ${i.map(r=>r.field?`${r.field} ${r.message}`:r.message).join("; ")}`);this.file=n;this.problems=i;this.name="PointsError"}};$K={table:["rows"],model:["backend","model","threshold","unreachable"],quorum:["count","roles"]},hhe=/(^|[-_./])(latest|preview|stable|current)$/i;whe=new Set(["if","then","else","oneOf","anyOf","allOf"]);PK=e=>uhe("sha256").update(e,"utf8").digest("hex"),Ra=e=>PK(Dm(e)),LI=(e,t,n,i)=>PK(Dm({point:e,version:t,inputs:n,asked:i}));RK=e=>typeof e=="string"&&e.trim()!=="";FI=(e,t)=>`${e}-${t.slice(0,12)}`;OK=(e,t)=>Object.entries(e).every(([n,i])=>Object.prototype.hasOwnProperty.call(t,n)&&vhe(i,t[n]));Tm=e=>Math.round(e*1e6)/1e6;$d=class extends Error{constructor(t){super(t),this.name="DeciderFailed"}};khe=["answer-points-unreadable","answer-point-unknown","answer-point-changed"]});import{createHash as $he}from"node:crypto";import{readFileSync as Rhe,statSync as She}from"node:fs";import{dirname as xv,posix as Ehe,relative as Ahe,resolve as Lm,sep as DK}from"node:path";function Zc(e){if(!e.reviews)return null;let t=[e.reviews.field,on];return e.reviews.ratified!==void 0&&e.stateField!==void 0&&t.push(e.stateField),e.seal!==void 0&&t.push(e.seal.field),t}function Im(e){return"kinds"in e.subjects?e.subjects.kinds:[e.subjects.kind]}async function Rv(e,t,n){if(!e.kind.session)return;let i=[];for(let r of Im(e.kind.session)){let o=await gn(Lm(xv(e.file),r),t);i.push({kind:r,records:(await $a(o,{root:t,source:n})).records,reviews:o.kind.reviews?.field??"reviews"})}return i}async function GI(e){let t=`record-kind:${e}`;Xs([{name:t,module:e}],xv(e));try{let n=await kc(t);if(!n)throw new Error(`${e} was not registered`);return n}finally{Xs([t],xv(e))}}async function gn(e,t=process.cwd()){let n=Lm(t,e),i;try{She(n),i=await GI(n)}catch(c){throw new Ve("kind-unreadable",`kind file ${e} could not be loaded: ${Mm(c)}`)}let r=Che.safeParse(i.recordKind);if(!r.success){let c=i.recordKind===void 0?"it has no recordKind export":r.error.issues.map(u=>`${u.path.join(".")||"recordKind"}: ${u.message}`).join("; ");throw new Ve("kind-invalid",`kind file ${e} is not a record kind: ${c}`)}let o=r.data,s=xv(n),a=NK(o,s,e,o.schema),l=(o.schema.refs??[]).map(c=>NK(o,s,e,c));return{kind:o,file:n,dir:Lm(s,o.location.dir),schema:a,refs:l}}function NK(e,t,n,i){let r;try{r=JSON.parse(Rhe(Lm(t,i.path),"utf-8"))}catch(o){throw new Ve("schema-unreadable",`schema ${i.path} named by ${n} could not be read: ${Mm(o)}`)}if(r===null||typeof r!="object"||r.$id!==i.id)throw new Ve("schema-id-mismatch",`kind ${e.name} names schema ${i.id}, but ${i.path} has $id ${JSON.stringify(r?.$id)}`);return r}function us(e){let n=e.replace(/\r\n?/g,`
|
|
128
|
+
`).match(/^---\n([\s\S]*?)\n---(?:\n|$)/);if(!n)return{ok:!1,message:"no front matter: the file must start with a --- line and close it with another"};let i;try{i=bd.load(n[1],{schema:bd.JSON_SCHEMA})}catch(o){return{ok:!1,message:`front matter is not valid YAML: ${Mm(o).split(`
|
|
129
|
+
`)[0]}`}}if(i===null||typeof i!="object"||Array.isArray(i))return{ok:!1,message:"front matter must be a mapping"};let r=$v(i,"",new Set);return r?{ok:!1,message:r}:{ok:!0,value:i}}function MK(e){let t;try{t=JSON.parse(e)}catch(r){return{ok:!1,message:`not valid JSON: ${Mm(r).split(`
|
|
130
|
+
`)[0]}`}}if(t===null||typeof t!="object"||Array.isArray(t))return{ok:!1,message:"a JSON record must be one object at the top level"};let n=FK(e);if(n.duplicate)return{ok:!1,message:`${n.duplicate.at||"/"}: member name ${JSON.stringify(n.duplicate.name)} repeats, which I-JSON refuses`};let i=$v(t,"",new Set);return i?{ok:!1,message:i}:{ok:!0,value:t}}function Sv(e,t){return e==="json"?MK(t):us(t)}function FK(e){let t=[],n=[],i,r=-1,o=a=>{n.length===1&&i&&(t.push({...i,end:a}),i=void 0)},s=0;for(;s<e.length;){let a=e[s];if(a==='"'){let l=s+1;for(;e[l]!=='"';)l+=e[l]==="\\"?2:1;let c=e.slice(s,l+1),u=l+1;for(;u<e.length&&/[ \t\n\r]/.test(e[u]);)u++;let d=n[n.length-1];if(e[u]===":"&&d?.names){let p=JSON.parse(c);if(d.names.has(p))return{members:t,duplicate:{name:p,at:d.path}};d.names.add(p),d.key=p,n.length===1&&(i={name:p,start:s}),s=u+1;continue}o(l+1),s=l+1;continue}if(a==="{"||a==="["){let l=n[n.length-1],c=l?`${l.path}/${l.names?l.key:l.index}`:"";n.push({names:a==="{"?new Set:null,path:c,index:0}),s++;continue}if(a==="}"||a==="]"){n.pop(),o(s+1),s++;continue}if(a===","){let l=n[n.length-1];l&&!l.names&&l.index++,s++;continue}if(/[ \t\n\r:]/.test(a)){s++;continue}for(r=s;s<e.length&&!/[ \t\n\r,\]}]/.test(e[s]);)s++;r<s&&o(s)}return{members:t}}function $v(e,t,n){if(!(e===null||typeof e=="string"||typeof e=="boolean")){if(typeof e=="number")return Number.isFinite(e)?void 0:`${t||"/"}: ${e} is not a JSON number`;if(typeof e!="object")return`${t||"/"}: a ${typeof e} is not a JSON value`;if(n.has(e))return`${t||"/"}: YAML aliases are not allowed`;if(n.add(e),Array.isArray(e)){for(let i=0;i<e.length;i++){let r=$v(e[i],`${t}/${i}`,n);if(r)return r}return}if(Object.getPrototypeOf(e)!==Object.prototype)return`${t||"/"}: not a plain mapping`;for(let[i,r]of Object.entries(e)){let o=$v(r,`${t}/${i}`,n);if(o)return o}}}function Yc(e,t="reviews",n="markdown-front-matter"){let i=e.replace(/\r\n?/g,`
|
|
131
|
+
`),r=t===null?[]:typeof t=="string"?[t]:t,o=n==="json"?r.reduce(Ihe,i):The(i,r);return $he("sha256").update(o,"utf8").digest("hex")}function wd(e,t,n="markdown-front-matter"){let i=e.replace(/\r\n?/g,`
|
|
132
|
+
`),r=Sv(n,i);if(!r.ok)return null;let o={...r.value};delete o[t];let s=n==="json"?o:{body:WI(i),core:o};return Nr(Rr(s))}function WI(e){let t=e.replace(/\r\n?/g,`
|
|
133
|
+
`),n=t.match(/^---\n[\s\S]*?\n---(?:\n|$)/);return n?t.slice(n[0].length):""}function Ihe(e,t){if(!MK(e).ok)return e;let{members:i}=FK(e),r=i.findIndex(l=>l.name===t);if(r<0)return e;let o=i[r],s=o.start;for(;s>0&&/[ \t\n]/.test(e[s-1]);)s--;let a=o.end;if(r+1<i.length){let l=a;for(;/[ \t\n]/.test(e[l]);)l++;a=l+1}else if(r>0){let l=s-1;for(;l>0&&e[l]!==",";)l--;for(;l>0&&/[ \t\n]/.test(e[l-1]);)l--;s=l}return e.slice(0,s)+e.slice(a)}function The(e,t){if(t.length===0)return e;let n=e.split(`
|
|
134
|
+
`);if(n[0]!=="---")return e;let i=n.indexOf("---",1);if(i<0)return e;let r=t.map(a=>a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).map(a=>`${a}|"${a}"|'${a}'`),o=new RegExp(`^(?:${r.join("|")})[ \\t]*:(?:[ \\t]|$)`),s=[];for(let a=0;a<n.length;a++){if(a>0&&a<i&&o.test(n[a])){for(;a+1<i&&/^(?:$|[ \t#-])/.test(n[a+1]);)a++;continue}s.push(n[a])}return s.join(`
|
|
135
|
+
`)}function cn(e){return e.normalize("NFKC").trim().toLowerCase()}function Dhe(e,t){return t.seal===void 0||t.seal===null?{attested:e?!1:null,code:"seal-missing",message:`the verdict by ${t.reviewer} carries no seal`}:{attested:null,code:"seal-unverifiable",message:`the seal by ${t.reviewer} was not checked`}}function Ev(e,t,n){if(!e.reviews||t.data===null)return null;let i=t.data[e.reviews.field],r=t.data[e.reviews.decider],o=typeof r=="string"?cn(r):null,s=t.id!==void 0?t.id:e.idField!==void 0?t.data[e.idField]:null,a=typeof s=="string"?s:null,l=[],c=[];(Array.isArray(i)?i:[]).forEach((g,h)=>{if(g===null||typeof g!="object")return;let b=g;if(typeof b.reviewer!="string"||typeof b.verdict!="string"||!Nhe.has(b.verdict))return;let w=typeof b.digest=="string"?b.digest:null,x={record:a,reviewer:b.reviewer,verdict:b.verdict,on:b.on,digest:w,seal:b.seal},{attested:k,...R}=n.verifySeal?n.verifySeal(x):Dhe(n.attestation,x),$={index:h,principal:cn(b.reviewer),reviewer:b.reviewer,verdict:b.verdict,digest:w,attested:k,attestation:R};$.principal===o?$.reason={code:"review-decider",message:`${$.reviewer} decided this record, and the quorum counts verdicts besides the decider's`}:n.agents.has($.principal)?$.reason={code:"review-agent",message:`${$.reviewer} holds the agent role in the trust policy at base, and an agent's verdict does not count`}:$.digest!==null&&$.digest!==t.digest?$.reason={code:"review-older-digest",message:`${$.reviewer} judged the text at digest ${$.digest.slice(0,12)}, and the record's text is now at ${t.digest.slice(0,12)}`}:n.attestation&&k!==!0&&($.reason={code:"review-unattested",message:`an attestation policy is active at base, and ${R.message}`}),l.push($),$.verdict==="dissent"&&b.addressed_by==null&&b.withdrawn_on==null&&c.push({index:h,principal:$.principal,reviewer:$.reviewer,note:typeof b.note=="string"?b.note:null,...typeof b.proposes=="string"?{proposes:b.proposes}:{}})});let u=new Map;for(let g of l)g.reason||u.set(g.principal,g);for(let g of l){if(g.reason||u.get(g.principal)===g)continue;let h=u.get(g.principal);g.reason={code:"review-duplicate",message:`the later verdict by ${JSON.stringify(h.reviewer)} (entry ${h.index}) replaces this one, and a principal counts once`}}let d=l.filter(g=>!g.reason),p=d.filter(g=>g.verdict==="agree").length,f=p>=n.need;return{need:n.need,needFrom:n.needFrom,agreed:p,counted:d,notCounted:l.filter(g=>g.reason),openConcerns:c,met:f,metWithObjections:f&&c.length>0}}function jhe(e){let t=[],n=new Map;for(let i of e){let r=i.keyword==="if"?i.params?.failingKeyword:void 0,o=r?i.parentSchema?.[r]?.description:void 0;if(!r||typeof o!="string")continue;let s=i.data!==null&&typeof i.data=="object"?i.data:{};n.set(i,o.replace(/\{([A-Za-z0-9_]+)\}/g,(a,l)=>typeof s[l]=="string"?s[l]:a)),t.push(`${i.schemaPath.replace(/\/if$/,"")}/${r}/`)}return e.filter(i=>n.has(i)||!t.some(r=>i.schemaPath.startsWith(r))).map(i=>`${i.instancePath||"/"} ${n.get(i)??i.message??"is invalid"}`)}async function Lhe(e,t=[]){let n=await Promise.resolve().then(()=>Le(yK(),1)),i=n.default.default??n.default,r;try{let o=new i({allErrors:!0,strict:!1,verbose:!0});for(let s of t)o.addSchema(s);r=o.compile(e)}catch(o){throw new Ve("schema-invalid",`the kind's schema does not compile: ${Mm(o)}`)}return o=>r(o)?{ok:!0}:{ok:!1,errors:jhe(r.errors??[])}}function zI(e,t){if(!e.supersedes||t===null)return[];let{field:n,key:i}=e.supersedes,r=t[n];return i===void 0&&typeof r=="string"?[r]:Array.isArray(r)?(i===void 0?r:r.map(s=>s!==null&&typeof s=="object"?s[i]:void 0)).filter(s=>typeof s=="string"):[]}function Mhe(e,t){if(!e.remediates||t===null)return[];let{field:n,key:i}=e.remediates,r=t[n];return i===void 0&&typeof r=="string"?[r]:Array.isArray(r)?(i===void 0?r:r.map(s=>s!==null&&typeof s=="object"?s[i]:void 0)).filter(s=>typeof s=="string"):[]}function Fhe(e){let t=e.slice(e.lastIndexOf("/")+1),n=t.indexOf(".");return n<0?t:t.slice(0,n)}async function $a(e,t){let{kind:n}=e,i=Bhe(Ahe(t.root,e.dir))||".",r=t.source.list(i);if(r===void 0)throw new Ve("location-missing",`records directory ${i} does not exist${t.source.label}`);let o=new RegExp(n.location.match),s=await Lhe(e.schema,e.refs),a=t.workspaceRoot??".",l=a==="."?t.root:Lm(t.root,...a.split("/")),c=[],u=new Map;for(let w of r.filter(x=>o.test(x)).sort()){let x=i==="."?w:`${i}/${w}`,k=t.source.read(x),R={id:null,path:x,state:null,valid:!0,reasons:[],supersededBy:null,remediatedBy:[],data:null,assets:[],warnings:[],digest:Yc(k,Zc(n),n.format)};c.push(R),n.session&&u.set(x,k);let $=Sv(n.format,k);if(!$.ok){R.reasons.push({code:"record-unparseable",message:$.message});continue}if(R.data=$.value,n.idFrom==="sha256"){R.id=dd(t.source.bytes(x));let C=Fhe(x);if(C!==R.id){let K=a==="."?x:x.startsWith(`${a}/`)?x.slice(a.length+1):x;jK.test(C)&&R.assets.push({path:K,sha256:C,actual:R.id,state:"drifted"}),R.warnings.push({code:"asset-drift",message:jK.test(C)?`${K} is named for sha256 ${C.slice(0,12)}, and its bytes${t.source.label} hash to ${R.id.slice(0,12)}`:`${K} is content-addressed, and its name claims no sha256: its bytes${t.source.label} hash to ${R.id.slice(0,12)}`})}}else{let C=$.value[n.idField];typeof C=="string"&&(R.id=C)}let _=n.stateField===void 0?void 0:$.value[n.stateField];typeof _=="string"&&(R.state=_);let T=s($.value);if(T.ok||R.reasons.push({code:"record-schema-invalid",message:T.errors.join("; ")}),n.source){let C=lK($.value,n.source.field);if(C){let K=uK(C,n.source.field);K.length>0&&R.reasons.push({code:"record-schema-invalid",message:K.join("; ")});let O=dK(C,n.source.field,l);O&&R.warnings.push({code:"source-transcript-drift",message:O})}}if(n.seal&&!n.session&&R.state!==null&&(n.closedStates??[]).includes(R.state)){let C=$.value[n.seal.field],K=typeof C=="string"?wd(k,n.seal.field,n.format):null;typeof C=="string"&&K!==C&&R.reasons.push({code:"record-seal-mismatch",message:`${n.seal.field} is ${C}, but the record seals to ${K}: it changed after it closed`})}if(n.pins){let C=$.value[n.pins.field];if(Array.isArray(C)&&C.length===0&&R.warnings.push({code:"record-no-evidence",message:`${n.pins.field} is empty: the record cites nothing and pins no file`}),t.assets){let K=iK(_m($.value,n.pins.field),t.assets);R.assets.push(...K.assets),R.warnings.push(...K.warnings)}}if(n.reviews){let C=$.value[n.reviews.field],K=(Array.isArray(C)?C:[]).filter(O=>O!==null&&typeof O=="object"&&!Array.isArray(O)&&O.digest===void 0).map(O=>typeof O.reviewer=="string"?O.reviewer:"an unnamed reviewer");K.length>0&&R.warnings.push({code:"review-undigested",message:`the ${K.length===1?"verdict":"verdicts"} by ${K.join(", ")} name no digest: ${K.length===1?"it counts":"they count"}, and an amendment will not stop ${K.length===1?"it":"them"} counting`})}}let d=new Map;for(let w of c){if(w.id===null)continue;let x=d.get(w.id);x?w.reasons.push({code:"record-id-duplicate",message:`id ${w.id} is already used by ${x.path}`}):d.set(w.id,w)}let p=new Set(n.closedStates??[]),f=w=>w===null?0:n.approval?.[w]??0,g=(w,x)=>n.approval?f(w.state)>0&&f(w.state)>=f(x.state):w.state!==null&&p.has(w.state);for(let w of c)for(let x of zI(n,w.data)){let k=d.get(x);if(!k){w.reasons.push({code:"record-supersedes-unknown",message:`supersedes ${x}, which no record has`});continue}if(k!==w){if(!g(w,k)){n.approval&&w.warnings.push({code:"record-supersedes-pending",message:`supersedes ${x}, which is ${k.state??"stateless"}; a ${w.state??"stateless"} record can't supersede it, so the link takes effect once this record is approved at least as strongly`});continue}if(k.supersededBy!==null&&k.supersededBy!==w.id){w.reasons.push({code:"record-supersedes-conflict",message:`supersedes ${x}, which ${k.supersededBy} already supersedes`});continue}k.supersededBy=w.id}}for(let w of c)for(let x of Mhe(n,w.data)){let k=d.get(x);if(!k){w.reasons.push({code:"record-remediates-unknown",message:`remediates ${x}, which no record has`});continue}if(k!==w){if(k.state===null||!p.has(k.state)){w.reasons.push({code:"record-remediates-not-closed",message:`remediates ${x}, which is ${k.state??"stateless"}, not closed; a record still open is amended instead`});continue}w.id!==null&&!k.remediatedBy.includes(w.id)&&k.remediatedBy.push(w.id)}}for(let w of c)for(let x of w.assets){if(x.state!=="pinned")continue;let k=c.find(_=>_.supersededBy!==null&&_.supersededBy===w.id&&_.assets.some(T=>T.path===x.path&&T.sha256===x.sha256));if(!k)continue;let R=t.history?.fileChanged(x.path)??null,$=t.history?t.history.recorded(w.path):null;R!==null&&$!==null&&R>$||(x.state="stale",w.warnings.push({code:"asset-stale",message:`${x.path} is pinned at the hash ${k.id} pinned, and it has not changed since: ${w.id} supersedes ${k.id}, and the artifact did not follow`}))}sK(n,c,u,t.subjects??null);let h=n.work?await(await Promise.resolve().then(()=>(xd(),TI))).applyWork(e,c,t):void 0;n.answers&&(await Promise.resolve().then(()=>(jm(),TK))).applyAnswers(e,c,t);for(let w of c)w.valid=w.reasons.length===0;let b=t.current?c.filter(w=>w.supersededBy===null):c;return{records:b,summary:{total:b.length,valid:b.filter(w=>w.valid).length,invalid:b.filter(w=>!w.valid).length,superseded:c.filter(w=>w.supersededBy!==null).length},...h?{decisions:h.decisions}:{}}}function Mm(e){return e instanceof Error?e.message:String(e)}function Bhe(e){return DK==="/"?e:e.split(DK).join(Ehe.sep)}var Sa,on,LK,Ve,Phe,Ohe,Che,_he,BK,Nhe,jK,mn=v(()=>{"use strict";as();er();AI();Ln();xn();po();OI();pK();Sa=["record-unparseable","record-schema-invalid","record-id-duplicate","record-supersedes-unknown","record-supersedes-conflict","record-remediates-unknown","record-remediates-not-closed","record-seal-mismatch","session-seal-mismatch","session-verdict-unknown-record"],on="seal";LK=["kind-unreadable","kind-invalid","schema-unreadable","schema-id-mismatch","schema-invalid","location-missing","not-a-git-repository","revision-unknown"],Ve=class extends Error{constructor(n,i){super(i);this.code=n;this.name="RecordReadError"}},Phe=/^[a-z][a-z0-9-]*$/,Ohe=["markdown-front-matter","json"],Che=m.object({name:m.string().regex(Phe),location:m.object({dir:m.string().min(1),match:m.string().min(1)}).strict(),format:m.enum(Ohe),schema:m.object({id:m.string().min(1),path:m.string().min(1),refs:m.array(m.object({id:m.string().min(1),path:m.string().min(1)}).strict()).optional()}).strict(),idField:m.string().min(1).optional(),idFrom:m.literal("sha256").optional(),stateField:m.string().min(1).optional(),states:m.array(m.string().min(1)).min(1).optional(),closedStates:m.array(m.string().min(1)).optional(),supersedes:m.object({field:m.string().min(1),key:m.string().min(1).optional()}).strict().optional(),remediates:m.object({field:m.string().min(1),key:m.string().min(1).optional()}).strict().optional(),approval:m.record(m.string(),m.number().int().min(0)).optional(),pins:m.object({field:m.string().min(1)}).strict().optional(),constrains:m.object({field:m.string().min(1)}).strict().optional(),outOfScope:m.object({field:m.string().min(1)}).strict().optional(),reviews:m.object({field:m.string().min(1),decider:m.string().min(1),ratified:m.string().min(1).optional()}).strict().optional(),proposedBy:m.object({field:m.string().min(1)}).strict().optional(),source:m.object({field:m.string().min(1)}).strict().optional(),session:m.object({verdicts:m.string().min(1),seal:m.string().min(1),subjects:m.union([m.object({kind:m.string().min(1)}).strict(),m.object({kinds:m.array(m.string().min(1)).min(1)}).strict().refine(e=>new Set(e.kinds).size===e.kinds.length,{message:"session.subjects.kinds lists each kind file once",path:["kinds"]})]),openedRev:m.string().min(1).optional(),closedRev:m.string().min(1).optional(),closedOn:m.string().min(1).optional()}).strict().optional(),work:m.object({needs:m.string().min(1),implements:m.string().min(1),decisions:m.string().min(1),open:m.string().min(1),done:m.string().min(1),closedOn:m.string().min(1),acceptance:m.object({field:m.string().min(1),implementer:m.string().min(1)}).strict().optional(),contract:m.object({field:m.string().min(1),kind:m.string().min(1)}).strict().optional(),tier:m.object({field:m.string().min(1),tiers:m.array(m.string().min(1)).min(1),limits:m.record(m.string().min(1),m.object({criteria:m.number().int().min(0).optional(),files:m.number().int().min(0).optional(),words:m.number().int().min(0).optional()}).strict()).optional()}).strict().refine(e=>new Set(e.tiers).size===e.tiers.length,{message:"work.tier.tiers lists each tier once",path:["tiers"]}).optional(),attempts:m.object({field:m.string().min(1),max:m.number().int().min(1)}).strict().optional(),answers:m.string().min(1).optional()}).strict().optional(),answers:m.object({points:m.string().min(1)}).strict().optional(),seal:m.object({field:m.string().min(1)}).strict().optional(),spec:m.boolean().optional()}).strict().refine(e=>e.states!==void 0||e.seal===void 0,{message:"a kind without states cannot have seal: a record is sealed when it enters a closed state",path:["seal"]}).refine(e=>e.seal===void 0||e.session===void 0||e.seal.field===e.session.seal,{message:"seal.field and session.seal name the field that holds a closed session's seal, and must be the same",path:["seal"]}).refine(e=>e.idField===void 0!=(e.idFrom===void 0),{message:"a kind names its id with exactly one of idField and idFrom",path:["idField"]}).refine(e=>new Set([e.stateField===void 0,e.states===void 0,e.closedStates===void 0]).size===1,{message:"stateField, states and closedStates are given together or not at all",path:["states"]}).refine(e=>e.states!==void 0||e.supersedes===void 0,{message:"a kind without states cannot have supersedes: a link takes effect only from a closed or ranked state",path:["supersedes"]}).refine(e=>e.states!==void 0||e.remediates===void 0,{message:"a kind without states cannot have remediates: a link only ever targets a record in a closed state",path:["remediates"]}).refine(e=>e.states!==void 0||e.session===void 0,{message:"a session kind must have states: a session is sealed when it reaches a closed state",path:["session"]}).refine(e=>e.states!==void 0||e.approval===void 0,{message:"a kind without states cannot have approval ranks",path:["approval"]}).refine(e=>e.states!==void 0||e.proposedBy===void 0,{message:"a kind without states cannot have proposedBy: there is no first state for a record to open in",path:["proposedBy"]}).refine(e=>e.reviews?.ratified===void 0||(e.states??[]).includes(e.reviews.ratified),{message:"reviews.ratified must be one of states: it names the state a record enters once its quorum is met",path:["reviews","ratified"]}).refine(e=>(e.closedStates??[]).every(t=>(e.states??[]).includes(t)),{message:"every closed state must be listed in states",path:["closedStates"]}).refine(e=>Object.keys(e.approval??{}).every(t=>(e.states??[]).includes(t)),{message:"every state approval ranks must be listed in states",path:["approval"]}).refine(e=>!e.work||e.states!==void 0&&e.states.includes(e.work.open)&&e.states.includes(e.work.done),{message:"a work kind must have states, and its work open and done states must be listed in them",path:["work"]}).refine(e=>!e.work?.acceptance||e.pins!==void 0,{message:"a work kind with acceptance criteria must have pins: a criterion is met by the evidence in its pins field",path:["work","acceptance"]}).refine(e=>!e.answers||e.format==="markdown-front-matter"&&e.idField==="id"&&e.stateField==="state"&&_he.every(t=>e.states?.includes(t))&&(e.closedStates??[]).includes("answered"),{message:'an answer kind is markdown-front-matter with idField "id", stateField "state", the states escalated, proposed and answered, and answered closed',path:["answers"]}),_he=["escalated","proposed","answered"];BK=2;Nhe=new Set(["agree","dissent","abstain"]);jK=/^[0-9a-f]{64}$/});import{execFileSync as WK}from"node:child_process";import{readdirSync as Ghe,readFileSync as GK}from"node:fs";import{join as UI}from"node:path";function Od(e){return{label:"",list(t){try{return Ghe(UI(e,t),{withFileTypes:!0}).filter(n=>n.isFile()).map(n=>n.name)}catch{return}},read(t){return GK(UI(e,t),"utf-8")},bytes(t){return GK(UI(e,t))}}}function Av(e,t,n){return WK("git",t,{cwd:e,encoding:"utf-8",input:n,stdio:["pipe","pipe","pipe"],maxBuffer:256*1024*1024})}function Un(e){try{return Av(e,["rev-parse","--show-toplevel"]).trim()}catch{return}}function Xc(e,t){if(t.startsWith("-"))throw new Ve("revision-unknown",`--at ${t} is not a revision`);try{return Av(e,["rev-parse","--verify","--quiet",`${t}^{commit}`]).trim()}catch{throw new Ve("revision-unknown",`--at ${t} names no commit in this repository`)}}function Ea(e,t){let n=new Map,i=r=>{let o=n.get(r);if(o===void 0)throw new Error(`${r} was not listed at ${t}`);return o};return{label:` at ${t.slice(0,8)}`,list(r){let o=r==="."?`${t}^{tree}`:`${t}:${r}`;try{if(Av(e,["cat-file","-t",o]).trim()!=="tree")return}catch{return}let s=Av(e,["ls-tree","-z",o]).split("\0").filter(Boolean).map(a=>{let l=a.indexOf(" "),[,c,u]=a.slice(0,l).split(" ");return{type:c,oid:u,name:a.slice(l+1)}}).filter(a=>a.type==="blob");if(s.length>0){let a=Buffer.from(WK("git",["cat-file","--batch"],{cwd:e,input:s.map(c=>c.oid).join(`
|
|
136
|
+
`)+`
|
|
137
|
+
`,maxBuffer:268435456})),l=0;for(let c of s){let u=a.indexOf(10,l),d=Number(a.subarray(l,u).toString("utf-8").split(" ")[2]),p=u+1;n.set(r==="."?c.name:`${r}/${c.name}`,a.subarray(p,p+d)),l=p+d+1}}return s.map(a=>a.name)},read(r){return i(r).toString("utf-8")},bytes:i}}var go=v(()=>{"use strict";mn()});import{posix as Whe}from"node:path";function zhe(e){let t=[],n="",i=!1,r=!1;for(let o of e)o==='"'?(i=!i,n+=o,r=!0):!i&&(o===" "||o===" ")?(r&&t.push(n),n="",r=!1):(n+=o,r=!0);return r&&t.push(n),t}function Uhe(e){let t=new Map,n="",i=!1,r=()=>{if(!n)return;let o=n.indexOf("="),s=(o<0?n:n.slice(0,o)).toLowerCase(),a=o<0?"":n.slice(o+1).replace(/^"|"$/g,"");t.set(s,a),n=""};for(let o of e)o==='"'&&(i=!i),o===","&&!i?r():n+=o;return r(),t}function ds(e){let t=[],n=[],i=e.replace(/\r\n?/g,`
|
|
138
|
+
`).split(`
|
|
139
|
+
`);for(let r=0;r<i.length;r++){let o=r+1,s=i[r].trim();if(!s||s.startsWith("#"))continue;let a=zhe(s);if(a.length<3){n.push({line:o,reason:"expected principals, optional options, a key type and a key"});continue}let[l,c]=a,u=!zK.has(c),d=u?a[2]:c,p=u?a[3]:a[2];if(!zK.has(d)||!p||!/^[A-Za-z0-9+/]+={0,2}$/.test(p)){n.push({line:o,reason:`no supported public key (${d??"none"})`});continue}let f=u?Uhe(c):new Map,g=["valid-after","valid-before"].filter(x=>f.has(x));if(g.length>0){n.push({line:o,reason:`${g.join(" and ")} is checked against the commit's own date, which its author sets; revoke a key by removing it`});continue}if(f.has("cert-authority")){n.push({line:o,reason:"cert-authority keys are not supported: a certificate's validity is a date the signer controls"});continue}let h=[...f.keys()].filter(x=>x!=="namespaces");if(h.length>0){n.push({line:o,reason:`unknown option ${h.join(", ")}`});continue}let b=l.replace(/^"|"$/g,"").split(",").filter(Boolean),w=b.find(x=>/[*?!]/.test(x));if(w!==void 0||b.length===0){n.push({line:o,reason:`principal ${JSON.stringify(w??l)} is a pattern; name one signer exactly`});continue}for(let x of b)t.push({principal:x,key:`${d} ${p}`,namespaces:f.get("namespaces"),line:o})}return{signers:t,excluded:n}}function Pv(e){return e.map(t=>`${JSON.stringify(t.principal)}${t.namespaces!==void 0?` namespaces=${JSON.stringify(t.namespaces)}`:""} ${t.key}`).join(`
|
|
140
|
+
`)+`
|
|
141
|
+
`}function qhe(e){return typeof e=="string"&&e.length>0&&!e.startsWith("/")&&!e.includes("\\")&&Whe.normalize(e)===e&&!e.split("/").includes("..")}function Ov(e){if(!Cd(e))return["/: expected an object"];let t=[],n=(i,r,o)=>{r||t.push(`${i}: ${o}`)};return n("/",Fm(e,["schema","signers","roles","adopted","runners","admitted"]),"unknown key"),n("schema",e.schema===1,"expected 1"),n("signers",Aa(e.signers,qhe),"a path inside the repository, with / separators and no .."),n("roles",Aa(e.roles,i=>Cd(i)&&Object.entries(i).every(([r,o])=>/^[a-z][a-z0-9-]*$/.test(r)&&Array.isArray(o)&&o.every(HI))),"role names to lists of principals"),n("adopted",Aa(e.adopted,i=>Array.isArray(i)&&i.every(r=>Cd(r)&&Fm(r,["from","to","note"])&&Aa(r.from,o=>typeof o=="string"&&UK.test(o))&&typeof r.to=="string"&&UK.test(r.to)&&Aa(r.note,o=>typeof o=="string"))),"commit ranges of full commit ids"),n("runners",Aa(e.runners,i=>Array.isArray(i)&&i.every(r=>Cd(r)&&Fm(r,["principal","class","key"])&&HI(r.principal)&&(r.class==="runner"||r.class==="service")&&typeof r.key=="string"&&Hhe.test(r.key))),"runner keys: a principal, a class and an ssh-ed25519 key"),n("admitted",Aa(e.admitted,i=>Array.isArray(i)&&i.every(r=>Cd(r)&&Fm(r,["return","signers","note"])&&typeof r.return=="string"&&/^ret-[0-9a-f]{12}$/.test(r.return)&&Aa(r.note,o=>typeof o=="string")&&Array.isArray(r.signers)&&r.signers.length>0&&r.signers.every(o=>Cd(o)&&Fm(o,["principal","key"])&&HI(o.principal)&&typeof o.key=="string"&&Vhe.test(o.key)))),"admitted signers, by return id"),t}var nr,Br,zK,Cd,UK,Hhe,Vhe,Fm,Aa,HI,_d=v(()=>{"use strict";nr=".chant/trust.json",Br=".chant/allowed_signers",zK=new Set(["ssh-ed25519","ssh-rsa","ecdsa-sha2-nistp256","ecdsa-sha2-nistp384","ecdsa-sha2-nistp521","sk-ssh-ed25519@openssh.com","sk-ecdsa-sha2-nistp256@openssh.com"]);Cd=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),UK=/^[0-9a-f]{40}([0-9a-f]{24})?$/,Hhe=/^ssh-ed25519 [A-Za-z0-9+/]+={0,2}$/,Vhe=/^(ssh-ed25519|ssh-rsa|ecdsa-sha2-nistp(256|384|521)|sk-ssh-ed25519@openssh\.com|sk-ecdsa-sha2-nistp256@openssh\.com) [A-Za-z0-9+/]+={0,2}$/;Fm=(e,t)=>Object.keys(e).every(n=>t.includes(n)),Aa=(e,t)=>e===void 0||t(e),HI=e=>typeof e=="string"&&e.length>0});import{posix as VI}from"node:path";function ps(e,t=[]){return{base:e,signersPath:Br,active:!1,signers:[],excluded:[],roles:{},adopted:[],runners:[],excludedRunners:[],admitted:{},problems:t}}function Cv(e,t){let n={schema:1},i=VK(e,nr);if(i!==void 0){let p;try{p=JSON.parse(i)}catch(g){return ps(t,[`${nr} is not JSON: ${g instanceof Error?g.message:String(g)}`])}let f=Jhe.safeParse(p);if(!f.success){let g=f.error.issues.map(h=>`${h.path.join(".")||"/"}: ${h.message}`).join("; ");return ps(t,[`${nr} is invalid: ${g}`])}n=f.data}let r=n.signers??Br,o=VK(e,r),s=o===void 0?{signers:[],excluded:[]}:ds(o),a=new Set(s.signers.map(p=>p.key)),l=new Set(s.signers.map(p=>p.principal)),c=[],u=[],d=n.runners??[];for(let p of d)a.has(p.key)||l.has(p.principal)?u.push({principal:p.principal,reason:`${r} lists this ${a.has(p.key)?"key":"principal"}; runner keys belong to a service or CI identity, never to a signer`}):d.filter(f=>f.key===p.key||f.principal===p.principal).length>1?u.push({principal:p.principal,reason:"another runner entry has the same key or principal; each runner is one principal with one key"}):c.push(p);return{base:t,signersPath:r,active:o!==void 0,signers:s.signers,excluded:s.excluded,roles:n.roles??{},adopted:n.adopted??[],runners:c,excludedRunners:u,admitted:Zhe(n),problems:[]}}function Zhe(e){let t={};for(let n of e.admitted??[])t[n.return]=[...t[n.return]??[],...n.signers.map(i=>({principal:i.principal,key:i.key,line:0}))];return t}function _v(e,t){return{...e,signers:[...e.signers,...e.admitted[t]??[]],returnedFrom:t}}function VK(e,t){let n=VI.dirname(t),i=e.list(n);if(!(!i||!i.includes(VI.basename(t))))return e.read(t)}var HK,Khe,Jhe,fs=v(()=>{"use strict";Ln();_d();_d();HK=m.string().regex(/^[0-9a-f]{40}([0-9a-f]{24})?$/,"a full commit id"),Khe=m.string().min(1).refine(e=>!e.startsWith("/")&&!e.includes("\\")&&VI.normalize(e)===e&&!e.split("/").includes(".."),{message:"a path inside the repository, with / separators and no .."}),Jhe=m.object({schema:m.literal(1),signers:Khe.optional(),roles:m.record(m.string().regex(/^[a-z][a-z0-9-]*$/),m.array(m.string().min(1))).optional(),adopted:m.array(m.object({from:HK.optional(),to:HK,note:m.string().optional()}).strict()).optional(),runners:m.array(m.object({principal:m.string().min(1),class:m.enum(["runner","service"]),key:m.string().regex(/^ssh-ed25519 [A-Za-z0-9+/]+={0,2}$/,"an ssh-ed25519 public key, with no comment")}).strict()).optional(),admitted:m.array(m.object({return:m.string().regex(/^ret-[0-9a-f]{12}$/,"a return id, ret-<12 hex>"),signers:m.array(m.object({principal:m.string().min(1),key:m.string().regex(/^(ssh-ed25519|ssh-rsa|ecdsa-sha2-nistp(256|384|521)|sk-ssh-ed25519@openssh\.com|sk-ecdsa-sha2-nistp256@openssh\.com) [A-Za-z0-9+/]+={0,2}$/,"an ssh public key, with no comment")}).strict()).min(1),note:m.string().optional()}).strict()).optional()}).strict()});var QK={};_e(QK,{splitSignedCommit:()=>Gm,sshCommitAttestor:()=>Qhe,sshKeygen:()=>Pa,sshSignatureIntact:()=>Iv,sshSignatureKey:()=>KI,verifySshSignature:()=>Td});import{execFileSync as JK,spawnSync as Yhe}from"node:child_process";import{mkdtempSync as ZK,rmSync as YK,writeFileSync as qI}from"node:fs";import{tmpdir as XK}from"node:os";import{join as Bm}from"node:path";function Gm(e,t="gpgsig"){let n=e.indexOf(`
|
|
142
|
+
|
|
143
|
+
`),i=n<0?e.length:n,r=e.subarray(0,i).toString("latin1").split(`
|
|
144
|
+
`),o=[],s=[],a=!1;for(let c of r){if(a&&c.startsWith(" ")){s.push(c.slice(1));continue}if(a=!1,s.length===0&&c.startsWith(`${t} `)){a=!0,s.push(c.slice(t.length+1));continue}o.push(c)}return{payload:Buffer.concat([Buffer.from(o.join(`
|
|
145
|
+
`),"latin1"),e.subarray(i)]),signature:s.length>0?s.join(`
|
|
146
|
+
`)+`
|
|
147
|
+
`:void 0}}function Xhe(e){try{return JK("git",["rev-parse","--show-object-format"],{cwd:e,encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim()}catch{return"sha1"}}function Pa(e,t){let n=Yhe("ssh-keygen",e,{input:t,encoding:"buffer",timeout:3e4}),i=n.error?.code==="ENOENT";return{status:n.status,stdout:n.stdout?.toString("utf-8")??"",stderr:n.stderr?.toString("utf-8")??"",missing:i}}function Td(e,t,n,i){if(e.length===0)return{ok:!1,missing:!1,reason:"the policy lists no usable signer"};let r=ZK(Bm(XK(),"chant-trust-"));try{let o=Bm(r,"allowed_signers"),s=Bm(r,"signature");qI(o,Pv(e)),qI(s,n);let a=Pa(["-Y","find-principals","-f",o,"-s",s]);if(a.missing)return{ok:!1,missing:!0,reason:"ssh-keygen is not installed here"};let l=a.status===0?a.stdout.split(`
|
|
148
|
+
`).map(c=>c.trim()).filter(Boolean):[];if(l.length===0)return{ok:!1,missing:!1,reason:"signed by a key the policy at base does not list"};for(let c of l){let u=Pa(["-Y","verify","-f",o,"-I",c,"-n",i,"-s",s],t);if(u.status===0){let d=/key (SHA256:[A-Za-z0-9+/=]+)/.exec(u.stdout+u.stderr)?.[1];return{ok:!0,principal:c,...d?{key:d}:{}}}}return{ok:!1,missing:!1,reason:`the signature does not verify in the ${i} namespace for a key the policy lists`}}finally{YK(r,{recursive:!0,force:!0})}}function KK(e,t,n){let{payload:i,signature:r}=Gm(e,t);if(!r)return{level:"unattested",attestor:Id,reason:"the commit is not signed"};if(!r.startsWith("-----BEGIN SSH SIGNATURE-----")){let s=r.startsWith("-----BEGIN PGP SIGNATURE-----")?"an OpenPGP":"a non-ssh";return{level:"attested-unverifiable-here",attestor:Id,reason:`the commit carries ${s} signature, which this attestor does not check`}}let o=Td(n,i,r,"git");return o.ok?{level:"attested",attestor:Id,principal:o.principal,...o.key?{key:o.key}:{},reason:`signed by ${o.principal}`}:o.missing?{level:"attested-unverifiable-here",attestor:Id,reason:o.reason}:{level:"unattested",attestor:Id,reason:o.reason}}function KI(e){let t=e.replace(/-----BEGIN SSH SIGNATURE-----/,"").replace(/-----END SSH SIGNATURE-----/,"").replace(/\s+/g,""),n;try{n=Buffer.from(t,"base64")}catch{return}if(n.length<14||n.subarray(0,6).toString("latin1")!=="SSHSIG")return;let i=n.readUInt32BE(10),r=n.subarray(14,14+i);if(r.length!==i||i<4)return;let o=r.readUInt32BE(0),s=r.subarray(4,4+o).toString("latin1");if(/^[a-z0-9@.-]+$/.test(s))return`${s} ${r.toString("base64")}`}function Iv(e,t,n){let i=ZK(Bm(XK(),"chant-intact-"));try{let r=Bm(i,"signature");qI(r,t);let o=Pa(["-Y","check-novalidate","-n",n,"-s",r],e);return o.missing?null:o.status!==0?!1:/key (SHA256:[A-Za-z0-9+/=]+)/.exec(o.stdout+o.stderr)?.[1]??""}finally{YK(i,{recursive:!0,force:!0})}}var Id,qK,Qhe,Wm=v(()=>{"use strict";fs();Id="ssh-commit";qK=new Map;Qhe={name:Id,attestCommit(e,t){let n=e.policy.signers,i=`${e.repo}\0${t}\0${Pv(n)}`,r=qK.get(i);if(r)return r;let o=JK("git",["cat-file","commit",t],{cwd:e.repo,maxBuffer:64*1024*1024}),s=KK(o,Xhe(e.repo)==="sha256"?"gpgsig-sha256":"gpgsig",n);return qK.set(i,s),s},attestRaw(e,t){let n=/^tree ([0-9a-f]+)$/m.exec(t.subarray(0,200).toString("latin1"))?.[1];return KK(t,n?.length===64?"gpgsig-sha256":"gpgsig",e.policy.signers)}}});var e6={};_e(e6,{PROVENANCE_LEVELS:()=>eye,activeAttestors:()=>zm,attestCommit:()=>Dv,attestRawCommit:()=>JI,registerAttestor:()=>tye,resetAttestors:()=>nye});function tye(e){Tv.some(t=>t.name===e.name)||Tv.push(e)}function nye(){Tv.length=0}function Dv(e,t,n){let i;for(let r of n){let o=r.attestCommit(e,t);if(o.level==="attested")return o;(!i||i.level==="unattested"&&o.level==="attested-unverifiable-here")&&(i=o)}return i??{level:"unattested",attestor:"none",reason:"no attestor is registered"}}function JI(e,t,n){return Dv(e,"",n.filter(i=>i.attestRaw).map(i=>({name:i.name,attestCommit:r=>i.attestRaw(r,t)})))}async function zm(){let{sshCommitAttestor:e}=await Promise.resolve().then(()=>(Wm(),QK));return[e,...Tv.filter(t=>t.name!==e.name)]}var eye,Tv,Dd=v(()=>{"use strict";Rc();eye=["attested","attested-unverifiable-here","adopted",dw],Tv=[]});import{createHash as rye,createPrivateKey as cze,createPublicKey as lze,sign as uze,verify as dze}from"node:crypto";function t6(e){let t=Buffer.from(e.trim().split(/\s+/)[1]??"","base64");return`SHA256:${rye("sha256").update(t).digest("base64").replace(/=+$/,"")}`}var Nv=v(()=>{"use strict"});import{createHash as iye}from"node:crypto";import{execFileSync as r6}from"node:child_process";import{posix as ZI}from"node:path";function sye(e){return ZI.join(ZI.dirname(e),`${ZI.basename(e)}.rotation.json`)}function aye(e){return`sha256:${iye("sha256").update(e.replace(/\r\n?/g,`
|
|
149
|
+
`),"utf8").digest("hex")}`}function lye(e,t){return Buffer.from(Rr({type:"chant-signer-set",version:e.version,previous:e.previous,signers:t,threshold:e.threshold}),"utf8")}function uye(e,t,n){if(t.signers===void 0)return{code:"signers-removed",reason:"the signers file was removed"};let i=aye(t.signers),r;if(t.rotation!==void 0){let d;try{d=JSON.parse(t.rotation)}catch(f){return{code:"rotation-unparseable",reason:`the rotation file is not JSON: ${f instanceof Error?f.message:String(f)}`}}let p=cye.safeParse(d);if(!p.success)return{code:"rotation-invalid",reason:`the rotation file is invalid: ${p.error.issues.map(f=>`${f.path.join(".")||"/"}: ${f.message}`).join("; ")}`};r=p.data}let o=ds(t.signers),s=r?.threshold??1,a=dye(o.signers);if(s>a)return{code:"rotation-threshold-unsatisfiable",reason:`the threshold is ${s}, and the set has ${a} distinct signer${a===1?"":"s"} to meet it`};if(!e)return r&&(r.version!==1||r.previous!==null)?{code:"rotation-first-version",reason:`a first signer set must be version 1 with no previous digest, not version ${r.version}`}:{version:1,commit:n,digest:i,threshold:s,signers:o.signers,excluded:o.excluded,signedBy:[]};if(i===e.digest&&s===e.threshold)return e;if(!r)return{code:"rotation-missing",reason:`the signer set changed from version ${e.version} with no rotation file signed by the set before it`};if(r.version!==e.version+1)return{code:"rotation-version-skew",reason:`the rotation says version ${r.version}; the next version is ${e.version+1}`};if(r.previous!==e.digest)return{code:"rotation-previous-mismatch",reason:`the rotation names previous ${r.previous}, but version ${e.version} is ${e.digest}`};let l=lye(r,i),c=new Set,u=[];for(let d of r.signatures){if(u.includes(d.principal))continue;let p=e.signers.filter(h=>h.principal===d.principal),f=Td(p,l,d.signature,oye);if(!f.ok)continue;let g=f.key??(p.length===1?t6(p[0].key):`principal:${f.principal}`);c.has(g)||(c.add(g),u.push(f.principal))}return c.size<e.threshold?{code:"rotation-threshold-not-met",reason:`version ${r.version} is signed by ${c.size} of the ${e.threshold} signers of version ${e.version} it needs${u.length?` (${u.join(", ")})`:""}`}:{version:r.version,commit:n,digest:i,threshold:s,signers:o.signers,excluded:o.excluded,signedBy:u}}function dye(e){let t=new Map;for(let o of e){let s=t.get(o.principal)??new Set;s.add(o.key),t.set(o.principal,s)}let n=new Map,i=(o,s)=>{for(let a of t.get(o)??[]){if(s.has(a))continue;s.add(a);let l=n.get(a);if(l===void 0||i(l,s))return n.set(a,o),!0}return!1},r=0;for(let o of t.keys())i(o,new Set)&&r++;return r}function YI(e,t){return r6("git",t,{cwd:e,encoding:"utf-8",stdio:["ignore","pipe","pipe"],maxBuffer:256*1024*1024})}function n6(e,t,n){try{return YI(e,["cat-file","blob",`${t}:${n}`])}catch{return}}function i6(e,t,n){let i=[n,sye(n)],r=YI(e,["--literal-pathspecs","log","--first-parent","--reverse","--format=%H",t,"--",...i]).split(`
|
|
150
|
+
`).filter(Boolean),o=[],s;for(let a of r){let l={signers:n6(e,a,i[0]),rotation:n6(e,a,i[1])};if(l.signers===void 0){s&&o.push({version:0,commit:a,digest:"",threshold:0,signers:[],excluded:[],signedBy:[]}),s=void 0;continue}let c=uye(s,l,a);if("code"in c)return{versions:o,broken:{commit:a,code:c.code,reason:c.reason}};c!==s&&o.push(c),s=c}return{versions:o}}var oye,cye,jv,o6=v(()=>{"use strict";Ln();er();Nv();fs();Wm();oye="chant-signers";cye=m.object({schema:m.literal(1),version:m.number().int().min(1),previous:m.string().regex(/^sha256:[0-9a-f]{64}$/).nullable(),threshold:m.number().int().min(1),signatures:m.array(m.object({principal:m.string().min(1),signature:m.string().min(1)}).strict())}).strict();jv=class{constructor(t,n,i){this.repo=t;this.base=n;this.history=i;this.index=new Map;this.memo=new Map}isAncestor(t,n){try{return r6("git",["merge-base","--is-ancestor",t,n],{cwd:this.repo,stdio:"ignore"}),!0}catch{return!1}}firstParents(){return this.line||(this.line=YI(this.repo,["rev-list","--first-parent",this.base]).split(`
|
|
151
|
+
`).filter(Boolean),this.line.forEach((t,n)=>this.index.set(t,n))),this.line}versionFor(t){let n=this.memo.get(t);if(n!==void 0)return n;let i=this.lookup(t);return this.memo.set(t,i),i}lookup(t){if(this.history.broken)return null;let n=this.history.versions.at(-1)??null;if(!this.isAncestor(t,this.base))return n;let i=this.firstParents(),r=0,o=i.length-1,s=0;for(;r<=o;){let c=r+o>>1;this.isAncestor(t,i[c])?(s=c,r=c+1):o=c-1}let a=null,l=1/0;for(let c of this.history.versions){let u=c.commit?this.index.get(c.commit):void 0;u===void 0||u<=s||u<l&&(a=c,l=u)}return a}}});import{execFileSync as l6}from"node:child_process";function XI(e,t){return l6("git",t,{cwd:e,encoding:"utf-8",stdio:["ignore","pipe","pipe"],maxBuffer:256*1024*1024})}function s6(e,t){try{return XI(e,["rev-parse","--verify","--quiet",`${t}^{commit}`]).trim()||void 0}catch{return}}function Gr(e,t){if(t!==void 0){let n=t.startsWith("-")?void 0:s6(e,t);return n?{commit:n,from:"flag"}:{commit:null,from:null,problem:`--base ${t} names no commit in this repository`}}for(let[n,i]of[["refs/remotes/origin/HEAD","origin/HEAD"],["refs/heads/main","main"],["refs/heads/master","master"]]){let r=s6(e,n);if(r)return{commit:r,from:i}}return{commit:null,from:null,problem:"no base revision: pass --base <rev> (there is no origin/HEAD, main or master)"}}function ai(e,t){if(!t.commit)return ps(null,t.problem?[t.problem]:[]);let n=Cv(Ea(e,t.commit),t.commit);if(!n.active||n.problems.length>0)return n;let i=i6(e,t.commit,n.signersPath);if(i.broken){let o=i.broken.commit?` at ${i.broken.commit.slice(0,8)}`:"";return{...n,problems:[`the signer history of ${n.signersPath} is broken${o}: ${i.broken.reason}`]}}let r=new jv(e,t.commit,i);return{...n,signersAt:o=>r.versionFor(o)}}function pye(e,t,n){let i=new Map;if(n.length===0)return i;let r=XI(e,["--literal-pathspecs","log","-c","--name-only","--no-renames","--format=%x00%H",t,"--",...n]),o=new Set(n),s="";for(let a of r.split(`
|
|
152
|
+
`))a.startsWith("\0")?s=a.slice(1).trim():a&&o.has(a)&&!i.has(a)&&i.set(a,s);return i}function fye(e,t){if(t.length===0)return new Set;let n=XI(e,["--literal-pathspecs","status","--porcelain=v1","-z","--untracked-files=all","--",...t]),i=new Set,r=n.split("\0");for(let o=0;o<r.length;o++){let s=r[o];s.length<4||(i.add(s.slice(3)),(s[0]==="R"||s[0]==="C")&&o++)}return i}function a6(e,t,n){try{return l6("git",["merge-base","--is-ancestor",t,n],{cwd:e,stdio:"ignore"}),!0}catch{return!1}}function c6(e,t,n){return t.adopted.some(i=>a6(e,n,i.to)&&(i.from===void 0||!a6(e,n,i.from)))}function Um(e,t,n,i){let r=t;if(t.signersAt){let s=t.signersAt(n);if(r={...t,signers:s?.signers??[]},!s||s.version===0){let a="no signer set was in effect where this commit entered the base's history";return c6(e,t,n)?{level:"adopted",commit:n,reason:`in a commit range the policy at base adopts; ${a}`}:{level:"unattested",commit:n,reason:a}}}let o=Dv({repo:e,policy:r},n,i);return o.level==="unattested"&&c6(e,t,n)?{level:"adopted",commit:n,attestor:o.attestor,reason:`in a commit range the policy at base adopts; ${o.reason}`}:{level:o.level,commit:n,attestor:o.attestor,...o.principal?{principal:o.principal}:{},...o.key?{key:o.key}:{},reason:o.reason}}function u6(e){let t=new Map,n=o=>{for(let s of e.paths)t.set(s,{level:"unattested",commit:null,reason:o});return t};if(!e.repo)return n("not in a git repository");if(e.policy.problems.length>0)return n(e.policy.problems.join("; "));if(!e.policy.active)return n(`no signers file (${e.policy.signersPath}) at base ${e.policy.base?.slice(0,8)}; attestation is off`);let i=e.at===null?fye(e.repo,e.paths):new Set,r=pye(e.repo,e.at??"HEAD",e.paths.filter(o=>!i.has(o)));for(let o of e.paths){if(i.has(o)){t.set(o,{level:"unattested",commit:null,reason:"the working tree has uncommitted changes to this file"});continue}let s=r.get(o);if(!s){t.set(o,{level:"unattested",commit:null,reason:"no commit holds this file"});continue}let a=Um(e.repo,e.policy,s,e.attestors);t.set(o,e.revisit?.(o,a)??a)}return t}var Qc=v(()=>{"use strict";go();Dd();fs();o6()});function Lv(e,t){if(typeof e!="string")return!1;let n=e.match(gye);return!!n&&(t===void 0||n[1]===t)}var mye,Pze,gye,QI=v(()=>{"use strict";mye={"declaration-missing":"No chant.workspace.json or .jsonc between the directory and the git root.","declaration-ambiguous":"Both chant.workspace.json and chant.workspace.jsonc exist.","declaration-unparseable":"The declaration is not valid JSON, or not valid JSONC for .jsonc.","declaration-invalid":"The declaration does not match its schema, repeats a name, or --member names no entry.","placement-invalid":"A member or group match breaks a placement rule.","reader-too-old":"The declaration's minReader is newer than the chant reading it.","root-chant-required":"The declaration pins a chant version other than the reader's, and that chant is not installed at the workspace root.","not-a-git-repository":"--at, or a ledger read, needs a git repository and there is none.","revision-unknown":"--at names no commit.","live-at-revision":"graph was given --live and --at: a live read is of the account now, not of a revision.","environment-invalid":"An environment name that can't name a ledger directory.","dir-missing":"The member's directory does not exist.","unknown-kind":"No built-in kind or pinned package supplies the member's kind.","kind-probe-failed":"The member's directory is not what its kind reads.","no-matches":"An example group matches no directory holding a chant project.","kind-not-run":"The member's kind is one the per-member commands don't run, such as other.","command-failed":"The member's own command exited with a failure, or the lexicon that reads the member through its kind's graph block isn't installed where the workspace resolves its pin.","output-unreadable":"The member's command printed something that isn't the document asked for.","ir-version-unsupported":"The member's IR has a version this chant can't read.","ledger-unreadable":"Reading the ledger failed, so nothing from it is listed.","ledger-malformed":"Some lines of the ledger aren't release records; the rest are listed.","gates-no-ledger":"The checkout has no chant/lifecycle branch, so there is no gate ledger to read.","gates-no-gate-ledger":"The branch has no gate ledger for the member: no run of it has reached a gate.","gates-ledger-unreadable":"Reading the member's gate ledger failed, so no gate is listed.","stewards-unreadable":"An *.op.ts file could not be imported, so a steward it declares may be missing.","stewards-conflict":"A steward was dropped: its name, or an Op it lists, belongs to another steward.","steward-runs-unreadable":"Reading an Op's run ledger, or a ConvergeOp's converge ledger, failed, so its last run or last tick is null.","record-unparseable":"No front matter, a YAML error or a value outside the JSON subset of YAML, or for a JSON kind a file that is not one object or repeats a member name.","record-schema-invalid":"The record's front matter, or its JSON object, does not match the kind's schema.","record-id-duplicate":"Another record earlier in path order has the same id.","record-supersedes-unknown":"A supersedes link names an id no record has.","record-supersedes-conflict":"A second closed record supersedes a record another one already superseded.","record-remediates-unknown":"A remediates link names an id no record has.","record-remediates-not-closed":"A remediates link names a record that isn't closed; a record still open is amended instead.","record-seal-mismatch":"A closed record's seal is not the whole-file seal of its text now: the record changed after it closed.","session-seal-mismatch":"A closed session's seal is not the whole-file seal of its text now: the session changed after it closed, or was sealed by the rule before #2546.","session-verdict-unknown-record":"A session's verdict names a record that none of the session kind's subject records has.","asset-drift":"A file the record pins by hash has changed: its bytes no longer hash to the pinned sha256.","asset-missing":"A file the record pins by hash does not exist in the tree read.","asset-stale":"A file the record pins is unchanged at the hash a record it supersedes pinned: the decision changed and the artifact did not follow.","record-supersedes-pending":"A supersedes link from a record whose state is weaker than the record it names, so the link has no effect yet.","record-no-evidence":"The record's evidence list is empty: it cites nothing and pins no file. Information for a reviewer, never an error.","review-undigested":"A verdict names no digest of the text it judged. It still counts, and an amendment does not stop it counting.","source-transcript-drift":"The record's source block pins a transcript by hash, the file it names can be read here, and its bytes hash to something else: it is not the transcript the record means.","work-needs-unknown":"A work record's needs list names a work id no record has, so the item stays blocked.","work-implements-unknown":"A work record's implements list names a decision id no decision has.","work-needs-cycle":"A work record needs itself through its needs links, so it can never be ready.","work-implements-undecided":"A work record implements a decision whose state is not approved, such as proposed.","work-done-unpinned":"A work record is done and its evidence list is empty: nothing shows the work was done.","work-closed-without-date":"A work record is done or dropped and has no closing date.","work-done-gap-open":"A work record is done, and the finding it came from still fires on its region. graph --intent raises it, and records does by walking that region.","work-acceptance-unmet":"A work record is done, and one of its acceptance criteria has no passing evidence of the verification it expects. check fails on it (WSP117).","work-acceptance-self-verified":"A passing manual verdict on a work record's criterion names the record's implementer, so it does not count: a manual verdict comes from someone else.","work-contract-unknown":"A work record names a contract that no record of its kind's contract kind has.","work-contract-undecided":"A work record names a contract whose state is not approved, such as a draft.","work-tier-unknown":"A work record names a builder tier that its kind's work.tier.tiers does not list.","answer-points-unreadable":"The points file the answer kind names can't be read, or is not valid.","answer-point-unknown":"The answer's point is not declared in the points file the answer kind names.","answer-point-changed":"The point's declaration changed since the question was asked, so the answer is to an older version of the question.","review-decider":"The verdict is the decider's own, and the quorum counts verdicts besides the decider's.","review-agent":"The reviewer holds the agent role in the trust policy at base.","review-duplicate":"A later verdict by the same principal replaces this one. Names are compared after NFKC, trimming and lower-casing.","review-older-digest":"The verdict names a digest other than the record's text now: the record changed after the verdict.","review-unattested":"An attestation policy is active at base, and the verdict carries no seal that verifies for its reviewer.","seal-missing":"The verdict, or the record, carries no seal.","seal-signer-unlisted":"The reviewer, or the record's author, has no key in the signers file at base, so the seal can't count.","seal-signature-invalid":"The seal is malformed, names a signer other than the reviewer or author, or its signature does not verify over the verdict or record.","seal-unverifiable":"Nothing here can say whose seal it is: there is no signers file at base, ssh-keygen is not installed, or the record came back in a return sealed by a signer no admission lists yet.","record-unattested":"A signers file is active at base, and the record names an author whose seal does not verify: it has none, the author has no key in the file, or the signature fails.","kind-unreadable":"The record kind file is missing or could not be imported.","kind-invalid":"The record kind file exports no recordKind, or its shape is wrong.","schema-unreadable":"The schema file the record kind names is missing or is not JSON.","schema-id-mismatch":"The schema's $id differs from the id the record kind names.","schema-invalid":"The record schema itself does not compile.","location-missing":"The records directory does not exist, in the tree or at the revision.","write-usage-invalid":"The command line lacks a value the write needs, or gives one it does not take.","write-input-invalid":"The fields given with --from or --set can't be read, are not JSON, or are not a JSON object.","record-not-found":"No record of the kind has the id given.","record-id-taken":"The id given for a new record is already used, by a record or a file name.","record-id-unallocatable":"No id was given and none can be allocated: the records share no single prefix and --prefix names none.","record-path-unmatched":"The file name made from the record's id and title does not match the kind's location.","record-closed":"The record is in a closed state, so nothing in it changes; a new record supersedes it instead.","amend-id-immutable":"An amendment changes the record's id, and ids are never renumbered.","amend-supersede-instead":"The record is approved, and the amendment changes a field the approval rule does not let change in place; a new record supersedes it instead.","review-unsupported":"The kind's schema has no reviews field, so its records take no review.","review-note-required":"A dissent was given with no note: a dissent needs a reason.","review-sign-failed":"--sign was given and no seal could be made: the key can't be read or used, git names no ssh signing key, or ssh-keygen is not installed.","record-state-not-initial":"A record written through chant serve mcp gives a state other than the kind's first: a new record opens proposed, and a person moves it on.","source-harvest-not-proposed":"A harvested record (source.via harvest) was written in a state other than the kind's first: a harvest proposes, and a person decides.","ratify-quorum-not-met":"The write puts a record in its kind's ratified state (reviews.ratified), and the record's quorum is not met: too few agreeing verdicts count.","record-sign-failed":"--sign was given and no author seal could be made: the record names no author, the key can't be read or used, git names no ssh signing key, or ssh-keygen is not installed.","record-conflict":"--expect named a digest the record no longer has: another write changed it after the caller read it. The refusal names the digest it has now; re-read the record and write again.","write-lock-timeout":"Another write held the working tree's write lock for longer than the write waits (CHANT_WRITE_LOCK_WAIT_MS); the refusal names the holder. Run the write again.","write-lock-not-held":"CHANT_WRITE_LOCK names a batch's lock token that no longer holds the working tree's write lock: the batch released it, or it expired and another writer took it.","write-scope-member":"The write is to a file, or to a record kind, of a member outside the writer's scope: an agent session writes only the members it is bound to, and writeScope.<class>.members leaves the member out.","write-scope-kind":"The write is to a record kind writeScope.<class>.records does not list, with a verb it does not list for the kind, or deletes a record.","write-scope-protected":"The write is to a file writeScope.<class>.protected lists, or one under a directory it lists, outside the top-level keys or JSON Pointers the entry's except allows (#3146, #3308).","write-scope-class-unknown":"The declaration's writeScope at base names a principal class no pinned package supplies, and the writer is judged human, so it may be in that class; the write is refused until the package is installed at the pinned version or the entry removed (#3080).","agent-unknown":"CHANT_AGENT, or a commit's Chant-Agent trailer, names an agent session the declaration at base does not declare.","principal-unidentified":"chant.workspace.json at base sets identity.attribution to identified, and the write names a person by a bare name: --by, an author field or a decision point's answerer must be a forge identity (github:<login>, gitlab:<login>, <forge>@<host>:<login>), a principal the signers file at base lists, or an agent, runner or service principal (#3163).","session-unknown":"--session names no session of a session kind whose subjects are the record's kind.","session-not-open":"--session names a session in a closed state, which takes no more verdicts.","points-undeclared":"No record kind with an answers block is declared, or given with --kind, so there is no points file to ask.","points-invalid":"The points file an answer kind names can't be read, or does not match decision-points.schema.json and the rules checked in code.","point-unknown":"No points file declares the point asked, or the one an answer names.","point-inputs-invalid":"The inputs given to an ask are not a JSON object of the point's declared inputs.","point-decider-failed":"A model decider that fails closed (unreachable: fail) could not answer, so the ask wrote nothing.","answer-not-candidate":"The people's answer is not one of the question's candidates.","quorum-not-met":"Too few of the people who answered count toward the point's quorum: distinct, not holding the agent role, not the steward that asked, and holding one of its roles when it names any. Nobody named over MCP or ACP counts (#3817).","answer-in-steward-turn":"The answer was given during a steward's turn, or by a process it started: a steward never answers a decision point, and a person answers it through hud or at a shell.","answer-never-over-mcp":"The answer or retraction came over MCP or ACP, or from a process a session on one started, and the question constrains a gate that is never resolved there: a person answers it at a shell or through hud (#3817).","answer-not-answered":"points retract names a question that has no answer to retract: it is escalated or proposed, and people answer it instead (#3351).","answer-field-unsupported":"The answer kind's copy of point-answer.schema.json predates a field the write needs, a note, a relay, a retraction or an ad-hoc question's asked: copy the schema anew to turn it on (#3351, #3402, #3403).","point-candidates-invalid":"points ask names an ad-hoc point without --candidates, a declared point with them, or candidates that are not a question and criteria of the point's question type (#3403).","since-rev-unknown":"--since names no commit, or a session with no opening revision and no commit that added it.","since-session-unknown":"--since has the shape of a session id and names no commit, and no session the kind or the declaration reads has that id.","since-session-open":"--since names a session that is still open, so the comparison runs to the working tree.","intent-region-invalid":"The region's path, or its line range, does not exist in the tree read.","intent-record-unknown":"graph --intent --record names an id that no record of a decision kind read has.","intent-symbol-unsupported":"The region names a symbol, path#symbol, in a file no symbol resolver reads; a line range still works.","intent-symbol-unknown":"The region names a symbol the file does not declare in the tree read.","intent-symbol-ambiguous":"The region names a symbol that matches more than one declaration in the file; its qualified name picks one.","intent-history-shallow":"The repository is a shallow clone, so the region's history stops at the clone's boundary.","intent-plugin-failed":"A kind file's commitJoins, which joins commits to units, contracts and evidence, failed for a commit.","squash-unfollowed":"A squash commit's pull request ref (refs/pull/<n>/head) is not in the clone and could not be fetched from origin, so its original commits are not followed; the read keeps its answer without them.","intent-commit-undecided":"A commit changed the region when no decision constrained it at path granularity.","intent-commit-bare":"A commit names no unit, carries no record through its Chant-Record or Chant-Lease trailer, and has no pull request and no decision covering the region at its time.","intent-pin-drifted":"A decision's pinned artifact no longer hashes to the pin.","intent-pin-missing":"A decision's pinned artifact does not exist in the tree read.","intent-pin-stale":"A current decision pins an artifact at the hash a record it supersedes pinned, and the artifact has not changed since: the decision moved on and the artifact did not.","intent-artifact-unpinned":"An artifact decisions in the graph pinned, which no current decision pins.","intent-decision-superseded-live":"Every decision constraining the region is superseded.","intent-decision-provisional":"The current decisions constraining the region are all in states their kind does not close, such as decided.","intent-decision-contested":"A current decision constraining the region has an open concern: a dissent neither addressed nor withdrawn.","intent-constraint-coarse":"The region is constrained only through its member, not by path.","intent-constraint-lost":"A decision's path constraint names a path that does not exist in the tree read.","intent-evidence-unpinned":"A decision's evidence has no hash: a URL, or a path with no sha256.","intent-trailer-unverified":"A commit carries a trailer a plugin says claims authorship, and the commit is not attested.","intent-region-unconstrained":"No decision constrains the region at any granularity.","intent-decision-unimplemented":"A decided decision constrains the region, no work item that is not dropped implements it, and no commit falls in its window.","intent-work-blocked":"A work item constraining the region has commits in its window while a work item it needs is not done.","intent-work-open-decided-code":"Commits in the region are a decision's own work while the work item implementing that decision is still open.","intent-commit-join-conflict":"A commit joined to an agent run by its Chant-Run trailer or the run's record has the patch-id of a commit another run recorded, so it is not joined to that run by content.","intent-why-no-decision":"No current decision governs the region at any granularity, and none is carried out by the commits or runs that made its current lines.","intent-why-no-run":"None of the region's current lines was made by a commit an agent run is joined to.","intent-why-uncommitted":"Some of the region's lines are not committed yet.","intent-why-run-ambiguous":"Some lines come from a commit several agent runs made, and no run's recorded hunks say which wrote them.","change-uncovered":"A path the diff changes is covered by no current decided record and no open work item, by path or by its member.","change-out-of-scope":"A record in hand for the change, such as the work item it is for or a decision that item implements, lists a path the diff changes in its out_of_scope.","patch-path-invalid":"workspace patch --path names a path that is not relative and inside the workspace.","composites-no-chant-member":"No member of kind chant was read, so nothing declares a composite instance or a component.","composites-none-declared":"The members read declare no composite instance.","composites-no-component":"The members read declare no component, so no composite instance has one.","runtimes-config-unreadable":"The member's chant.config.ts could not be read, so only the built-in local runtime is listed, and no environment from the config.","runtimes-lexicon-unreadable":"A lexicon the member's config lists could not be loaded, so it is not listed as a runtime.","environments-none-declared":"The member's chant.config.ts declares no environments, so only local and the environments in its ledger are listed.","environments-ledger-undeclared":"The member's ledger has releases in an environment its config's environments don't cover, so chant run --env would refuse it and it is not listed.","environments-ledger-unreadable":"The chant/lifecycle branch exists and the member's ledger environments could not be listed.","environments-component-undeclared":"A component declares an environment its member's chant.config.ts environments don't cover, so chant run --env would refuse it and it is not listed (#3153).","diagram-source-missing":"A declared diagram's source file does not exist in the tree read.","diagram-render-missing":"A declared diagram's render file does not exist in the tree read.","diagram-render-drift":"A declared diagram records a sourceHash, and the source's bytes now hash to something else: the render is stale for its source.","box-credential-declared":"A file in a box member's directory carries a literal secret: a credential's shape, or a literal where a credential goes. A variable or secret-manager reference is not one.","box-capability-unbrokered":"A capability in a member's box block names no broker, so the box would hold its credential.","box-fountain-callback-undeclared":"A box member builds a fountain Box, whose persistent sandbox fountain gives a callback token scoped to its owner, and the member's box block does not declare the fountain-callback capability brokered by fountain with scope owner.","box-intent-unknown":"A box block names an intent, and no record of a declared kind named decision has that id.","box-intent-unconstrained":"The decision record a box names as its intent constrains no member or path of this workspace: no member: entry for a declared member and no path: entry at, above or inside one's directory.","box-none":"No member's box block declares services, so the workspace has no box for a host to plant.","box-several":"More than one member's box block declares services, and a planted workspace runs one box.","work-kind-missing":"No work kind to find the item in: --kind names a kind with no work block, or the declaration names no work kind.","work-kind-ambiguous":"More than one declared work kind has a record with the id, so --kind must name one.","work-item-unknown":"No work record has the id, so there is nothing to lease.","work-item-closed":"A claim on a work item in a closed state, such as done or dropped: there is no work left to claim.","work-criterion-unknown":"The work record lists no acceptance criterion with the id the evidence names, or its kind has no acceptance criteria.","lease-held":"Someone holds a live lease on the work item: another worker, or, for a claim, the same one.","lease-not-held":"Nobody holds a live lease on the work item: it expired, was released or was never claimed.","lease-token-mismatch":"The live lease on the work item carries another fencing token than the one given.","lease-race":"Another writer changed the lease between this command's read and its write.","lease-push-rejected":"The remote refused the lease push: another clone claimed the item first, or the remote could not be reached.","run-exists":"runs start or runs record was given a run id the ledger already has.","run-unknown":"runs end names a run the ledger has no start for.","run-ended":"runs end names a run whose end is already recorded.","runs-no-ledger":"The checkout has no chant/lifecycle branch, so there are no agent runs to read.","runs-ledger-malformed":"Some lines of the agent run ledger aren't run events; the rest are read.","run-not-ended":"runs sign or runs statement names a run with no end recorded. A statement is signed over the run's whole record.","run-statement-invalid":"The envelope's payload is not an in-toto Statement v1 with chant's agent-run predicate, or has a field the predicate does not define.","run-statement-signer-mismatch":"The statement names a signer other than the runner whose key signed it.","run-statement-mismatch":"A listed runner key signed the statement, and it does not match the run's record: another run, a record that hashes differently, or another unit, harness, model, provider or principal.","listing-member-unknown":"box listing set names a member the declaration does not declare.","listing-box-missing":"box listing set names a member whose entry declares no box block, so it has no listing.","listing-cover-invalid":"The cover can't be read, is not a PNG, JPEG or WebP picture, is larger than 5 MiB, has a path outside the workspace, or has an extension other than its picture format's.","member-exists":"member add names a member the declaration already has, with an entry other than the one given.","member-unknown":"member remove names a member the declaration does not declare.","factory-member-unknown":"box factory set names a member the declaration does not declare.","factory-box-missing":"box factory set names a member whose entry declares no box block, so it has no factory.","publish-member-unknown":"box publish names a member the declaration does not declare.","publish-none":"box publish names a member whose box block names no publisher, or which declares no box block.","publish-refused":"The box's publisher refused (it exited 2): nothing was published, and its message says why.","publish-failed":"The box's publisher could not be run, failed (a nonzero exit other than 2) or ran out of time; its message says what it had done.","publish-answer-invalid":"The box's publisher exited 0 and printed no JSON object, or one box-publish.schema.json does not allow.","publish-unrecorded":"The commit the publisher named is not in the repository, or lacks the apply record of ws-075: Chant-Applied-By naming --by, Chant-Applied-At, Chant-Applied-Commit and a Chant-Record for the item, or a Chant-Record for each record sent.","wip-no-branch":"HEAD is detached, or names a branch with no commit yet, so there is no branch to keep work in progress for.","wip-none":"wip restore was given no snapshot, and the branch has none under refs/chant/wip/<branch>.","wip-snapshot-unknown":"wip restore names something that is not a work-in-progress snapshot chant took.","wip-branch-other":"wip restore names a snapshot taken on another branch than the one checked out.","wip-race":"Another writer moved refs/chant/wip/<branch> between this command's read and its write.","wip-policy-none":"wip push or wip fetch was run, and no box block declares replicate, so there is no remote.","wip-remote-unknown":"The replicate policy names a git remote the checkout does not have; the host adds it, with its credential, before chant pushes.","ci-green-undeclared":"The declaration has no ci.green block, so chant does not know which check runs make a commit green.","ci-branch-unknown":"The checkout has no ref for the branch ci.green names: neither the remote-tracking branch nor a local one.","box-isolation-collision":"Two boxes on one host resolve to the same port, state path or cookie name, or two ports in one box share an offset.","box-isolation-literal":"A host's stateRoot or a box's state entry is a literal machine path instead of one derived from an environment reference and the box's name.","signers-file-missing":"There is no signers file at the base revision, so there is no signer history to read.","signers-removed":"The signers file was removed. Commits merged before the removal keep the set they were judged by; nothing after it verifies.","rotation-unparseable":"The rotation file beside the signers file is not JSON.","rotation-invalid":"The rotation file does not match its shape: schema 1, a version, the previous set's digest, a threshold and signatures.","rotation-first-version":"The first signer set's rotation file names a version other than 1, or a previous digest.","rotation-missing":"The signer set or its threshold changed and no rotation file signed by the set before it came with the change.","rotation-version-skew":"The rotation names a version other than the one after the set it replaces, as a replayed or skipped rotation does.","rotation-previous-mismatch":"The rotation names a previous digest other than the set it replaces, as a rollback to an older set does.","rotation-threshold-unsatisfiable":"The new threshold is more than the number of distinct signers in the new set, so no later rotation could meet it.","rotation-threshold-not-met":"Fewer distinct signers of the set before signed the rotation, in the chant-signers namespace, than that set's threshold.","trust-policy-unreadable":"The trust policy at base can't be read, or its signer history is broken, so no runner key is trusted.","envelope-unreadable":"The --envelope file can't be read, or is not JSON.","envelope-invalid":"The file is not a DSSE envelope: payloadType, payload in canonical base64, and signatures with keyid and sig.","envelope-untrusted":"No signature in the envelope verifies against a runner key the policy at base lists.","evidence-payload-type":"The envelope's payload type is not application/vnd.in-toto+json.","evidence-statement-invalid":"The payload is not an in-toto Statement v1 with chant's runner-evidence predicate, or has a field the predicate does not define.","evidence-runner-mismatch":"The statement names a runner other than the one whose key signed it.","runner-key-invalid":"The key given to evidence sign or runs sign is not an Ed25519 private key in PEM.","runner-key-is-signer":"The key given to evidence sign or runs sign is a person's key in the signers file. Evidence and run statements are signed by a service or CI identity.","runner-key-unlisted":"The policy at base lists no runner with the key given to evidence sign or runs sign.","lock-invalid":"The lineage lock can't be read.","manual-step-open":"A scope in the lineage lock has an open manual step."},Pze=Object.keys(mye),gye=/^plugin:([^:\s]+):([a-z0-9]+(?:-[a-z0-9]+)*)$/});function d6(e){let t=e.commitJoins,n=e.commitJoinsName;if(t===void 0)return n===void 0?void 0:"commitJoinsName: a kind file with no commitJoins has no findings to name";if(n!==void 0&&(typeof n!="string"||!yye.test(n)))return"commitJoinsName: a string with no colon or space, the <name> of plugin:<name>:<code>";let i=n===void 0?{}:{name:n};if(typeof t=="function")return{form:"function",join:t,...i};let r=hye.safeParse(t);return r.success?{form:"data",data:r.data,...i}:r.error.issues.map(o=>`commitJoins${o.path.length?`.${o.path.join(".")}`:""}: ${o.message}`).join("; ")}function Fv(e,t){let n=t.toLowerCase(),i=[];for(let[r,o]of Object.entries(e))if(r.toLowerCase()===n)for(let s of o){let a=s.trim();a&&!i.includes(a)&&i.push(a)}return i}function Oa(e,t){return Fv(e,t)[0]}function tT(e,t){let n=t.toLowerCase();return Object.keys(e).some(i=>i.toLowerCase()===n)}function bye(e,t,n){if(!e)return{};let i=n.read(e.split("{id}").join(t));if(i===void 0)return{};let r;try{r=JSON.parse(i)}catch{throw new Error(`${e.split("{id}").join(t)} is not JSON`)}if(r===null||typeof r!="object"||Array.isArray(r))return{};let{id:o,...s}=r;return s}function wye(e,t,n){let i={},r=(a,l)=>({...bye(e.records?.[a],l,n),id:l});for(let a of["unit","contract"]){let l=e.trailers[a],c=l?Oa(t.trailers,l):void 0;c&&(i[a]=r(a,c))}let o=e.trailers.evidence?Fv(t.trailers,e.trailers.evidence):[];o.length>0&&(i.evidence=o.map(a=>r("evidence",a)));let s=(e.authorship??[]).filter(a=>tT(t.trailers,a));return s.length>0&&(i.authorship=s),i}function Nd(e){let t=e?.decisions;return Array.isArray(t)?t.filter(n=>typeof n=="string"&&n!==""):[]}async function Bv(e,t,n,i){if(e.form==="data")return wye(e.data,t,n);let r=await e.join(t,n);if(r==null)return{};if(typeof r!="object")throw new Error("commitJoins returned something that is not an object");let o=(c,u)=>{if(c!=null){if(typeof c!="object"||Array.isArray(c)||typeof c.id!="string"||c.id==="")throw new Error(`commitJoins returned a ${u} with no string id`);return c}},s={},a=o(r.unit,"unit"),l=o(r.contract,"contract");if(a&&(s.unit=a),l&&(s.contract=l),r.evidence!==void 0&&r.evidence!==null){let c=Array.isArray(r.evidence)?r.evidence:[r.evidence];s.evidence=c.map(u=>o(u,"evidence")).filter(Boolean)}if(r.authorship!==void 0){if(!Array.isArray(r.authorship)||!r.authorship.every(c=>typeof c=="string"))throw new Error("commitJoins returned authorship that is not a list of trailer keys");s.authorship=r.authorship}if(r.findings!==void 0&&r.findings!==null){if(!Array.isArray(r.findings))throw new Error("commitJoins returned findings that are not a list");s.findings=r.findings.map(c=>{if(c===null||typeof c!="object"||Array.isArray(c))throw new Error("commitJoins returned a finding that is not an object");let{code:u,message:d,refs:p}=c;if(!Lv(u,i))throw new Error(`commitJoins returned the finding code ${JSON.stringify(u)}, and a plugin's codes are plugin:${i}:<code>, with <code> in lower case words joined by dashes`);if(typeof d!="string"||d==="")throw new Error(`commitJoins returned the finding ${u} with no message`);if(p!==void 0&&(!Array.isArray(p)||!p.every(f=>typeof f=="string")))throw new Error(`commitJoins returned the finding ${u} with refs that are not a list of strings`);return{code:u,message:d,refs:p??[]}})}return s}var Mv,eT,hye,yye,Gv=v(()=>{"use strict";Ln();QI();Mv=m.string().regex(/^[A-Za-z0-9][A-Za-z0-9-]*$/,"a trailer key holds letters, digits and dashes"),eT=m.string().min(1).refine(e=>e.includes("{id}")&&!e.startsWith("/")&&!e.split("/").includes(".."),"a record path is relative to the workspace root and holds {id}"),hye=m.object({trailers:m.object({unit:Mv.optional(),contract:Mv.optional(),evidence:Mv.optional()}).strict(),records:m.object({unit:eT.optional(),contract:eT.optional(),evidence:eT.optional()}).strict().optional(),authorship:m.array(Mv).optional()}).strict(),yye=/^[^:\s]+$/});function nT(e){let t=e.indexOf(":");if(t<=0)return;let n=e.slice(0,t).trim(),i=e.slice(t+1).trim();return Sye.test(n)&&Eye.test(i)?{kind:n,id:i}:void 0}function f6(e){let t=[];for(let r of Fv(e,kye)){let o=nT(r);o&&!t.some(s=>s.kind===o.kind&&s.id===o.id)&&t.push(o)}let n=Oa(e,xye)??null,i=Oa(e,Rye)??null;return{agent:Oa(e,Hm)??null,lease:Oa(e,vye)??null,run:Oa(e,p6)??null,records:t,applied:n===null?null:{by:n,at:Oa(e,$ye)??null,commit:i!==null&&Aye.test(i)?i:null}}}var Hm,vye,p6,kye,xye,$ye,Rye,Sye,Eye,Aye,Wv=v(()=>{"use strict";Gv();Hm="Chant-Agent",vye="Chant-Lease",p6="Chant-Run",kye="Chant-Record",xye="Chant-Applied-By",$ye="Chant-Applied-At",Rye="Chant-Applied-Commit",Sye=/^[a-z][a-z0-9-]*$/,Eye=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/,Aye=/^[0-9a-f]{40,64}$/});import{spawn as Pye}from"node:child_process";import{existsSync as Oye,readFileSync as Cye,realpathSync as m6}from"node:fs";import{join as rT,relative as g6,resolve as _ye}from"node:path";function Qt(e,t){let n=_u(e);if(t!==void 0){if(!n)throw new ve("not-a-git-repository","--at reads git objects, and this directory is not in a git repository");let o=rC(n,t);if(!o)throw new ve("revision-unknown",`--at ${t} names no commit in this repository`);let s=Iu(n,o),a=h6(g6(n,m6(_ye(e)))),l=I0(s,a.startsWith("..")?"":a);if(l===void 0)throw new ve("declaration-missing",`no chant.workspace.json or .jsonc between ${a||"."} and the git root at ${o.slice(0,8)}`);return{tree:l===""?s:Iu(n,o,l),root:l===""?".":l,rootOnDisk:rT(n,...l.split("/")),at:o,top:n}}let i=gr(e);if(!i)throw new ve("declaration-missing",n?"no chant.workspace.json or .jsonc between this directory and the git root; chant workspace init proposes one":"no chant.workspace.json or .jsonc in this directory; chant workspace init proposes one");let r=n?h6(g6(n,m6(i.dir))):i.dir;return{tree:$n(i.dir),root:r===""?".":r,rootOnDisk:i.dir,at:null,top:n}}function Iye(e,t){let n=ia(id,e);if(!n)return;let i;try{i=JSON.parse(Cye(rT(n,"package.json"),"utf-8"))}catch{return}if(i.version!==t)return;let r=typeof i.bin=="string"?i.bin:i.bin?.chant;if(typeof r!="string")return;let o=rT(n,r);return Oye(o)?o:void 0}function Tye(e){let t=rd.find(r=>e.tree.stat(r)==="file");if(!t)return;let n;try{n=e.tree.read(t)}catch{return}let i=ga(n,{jsonc:t.endsWith(".jsonc")});if(!(!i.ok||i.value===null||typeof i.value!="object"||Array.isArray(i.value)))return nv(i.value)?.version}async function zv(e,t,n=process.argv.slice(2)){if(process.env[y6])return;let i;try{i=Qt(e,t)}catch{return}let r=Tye(i);if(r===void 0||r===Xt())return;let o=Iye(i.rootOnDisk,r);if(o)return new Promise(s=>{let a=Pye(o,n,{stdio:"inherit",env:{...process.env,[y6]:r}});a.on("error",l=>{process.stderr.write(`could not start the root's chant ${r} at ${o}: ${l.message}
|
|
153
|
+
`),s(1)}),a.on("close",l=>s(l??1))})}var h6,y6,ci=v(()=>{"use strict";Si();_t();nd();co();Zt();h6=e=>e.split("\\").join("/");y6="CHANT_WORKSPACE_ROOT_CHANT"});var C6={};_e(C6,{AGENT_ENV:()=>iT,AGENT_TRAILER:()=>Hm,SCOPE_FINDING_CODES:()=>jye,WRITE_SCOPE_CODES:()=>_a,WriteScopeError:()=>ms,checkWriteScope:()=>Fye,classesOf:()=>Pm,declaredSessions:()=>cT,judgePath:()=>P6,judgeRecord:()=>aT,onlyKeysChanged:()=>A6,principalClass:()=>$6,protectedEntry:()=>S6,refuseRecordWrite:()=>lT,resolveWriter:()=>oT,roleGrants:()=>Am,scopeOf:()=>qv,scopeSource:()=>ho,scopedKind:()=>O6,unknownClassVerdict:()=>sT});import{execFileSync as Dye}from"node:child_process";import{posix as b6,relative as w6,sep as v6}from"node:path";import{isDeepStrictEqual as Nye}from"node:util";function $6(e,t,n=ka()){return mq(e,t,n)}function oT(e,t,n,i=ka()){let r=n.principal??null,o=e?.agents??[];if(n.agent!==void 0&&n.agent!==null){let s=o.find(a=>a.name===n.agent);if(!s){let a=o.map(l=>l.name).join(", ");throw new ms("agent-unknown",e===null?`agent session ${JSON.stringify(n.agent)} is not declared: there is no workspace declaration`:`agent session ${JSON.stringify(n.agent)} is not declared: the declaration's agents ${a?`are ${a}`:"list none"}`)}return{principal:r,class:"agent",agent:s}}if(r!==null){let s=cn(r),a=o.find(l=>l.principals.some(c=>cn(c)===s));if(a)return{principal:r,class:"agent",agent:a}}return{principal:r,class:$6(t,r,i),agent:null}}function sT(e,t,n){if(t.class!=="human")return Ca;let i=nI(e?.writeScope??null,n);if(i.length===0)return Ca;let r=i.map(o=>`writeScope.${o}`).join(", ");return{ok:!1,code:"write-scope-class-unknown",message:`${el(t)} may be in ${i.length===1?"a class":"classes"} no pinned package supplies (${r}), so its scope can't be told; install the package that supplies ${i.length===1?"it":"them"} at the pinned version, or remove the entry (known classes: ${n.names().join(", ")})`}}function qv(e,t){let n=e?.writeScope?.[t.class];return t.class==="agent"?{members:null,records:n?.records??null,protected:n?.protected??[],pointer:n?.pointer??"/agents"}:n??null}function el(e){if(e.agent){let n=e.agent.members;return`agent session ${e.agent.name}, bound to ${n.length===1?"member":"members"} ${n.join(", ")},`}let t=e.principal!==null?`${e.principal} (${e.class})`:`a ${e.class} writer`;return e.class==="agent"?`${t}, which no agent session lists,`:t}function R6(e,t,n){return e.class==="agent"?n!==null&&(e.agent?.members.includes(n)??!1):t.members===null||n!==null&&t.members.includes(n)}function aT(e,t,n,i){let r=qv(e,t);if(r===null)return Ca;if(!(n.declared&&n.member===null?!0:R6(t,r,n.member))){let l=n.member===null?"in no member":`of member ${n.member}`;return{ok:!1,code:"write-scope-member",message:`${el(t)} may not write ${n.name} records, which are ${l}: ${t.class==="agent"?"an agent session writes only the members it is bound to":`writeScope.${t.class}.members leaves it out`}`}}if(i==="delete")return{ok:!1,code:"write-scope-kind",message:`${el(t)} may not delete a ${n.name} record: a record is never deleted, and a new one supersedes it`};if(r.records===null)return Ca;let a=[n.name,...n.declaredName!==null&&n.declaredName!==n.name?[n.declaredName]:[]].flatMap(l=>r.records[l]??[]);return a.includes(i)?Ca:{ok:!1,code:"write-scope-kind",message:a.length===0?`${el(t)} may not write ${n.name} records: writeScope.${t.class}.records does not list the kind`:`${el(t)} may ${[...new Set(a)].join(", ")} ${n.name} records, and not ${i} them (writeScope.${t.class}.records)`}}function S6(e,t){if(e.length===0)return null;let n=t.split("/"),i=n.map((r,o)=>n.slice(0,o+1).join("/"));for(let r of e){let o=(0,x6.default)(r.path,{dot:!0});if(i.some(s=>o(s)))return r}return null}function E6(e,t){if(t.length===0||e===null||typeof e!="object")return;let[n,...i]=t,r=e,o=n==="*"?Object.keys(r):Object.prototype.hasOwnProperty.call(r,n)?[n]:[];for(let s of o)i.length>0?E6(r[s],i):Array.isArray(e)?e[Number(s)]=Lye:delete r[s]}function A6(e,t,n){if(e===null||t===null||n.length===0)return!1;let i=s=>{let a=ga(s,{jsonc:!0});if(!a.ok)return null;let l=a.value;if(l===null||typeof l!="object"||Array.isArray(l))return null;let c=structuredClone(l);for(let u of n)u.startsWith("/")?E6(c,u.slice(1).split("/").map(d=>d.replace(/~1/g,"/").replace(/~0/g,"~"))):delete c[u];return c},r=i(e),o=i(t);return r!==null&&o!==null&&Nye(r,o)}function P6(e,t,n,i){let r=qv(e,t);if(r===null)return Ca;let o=Fr(n,e?.members??[]);if(!R6(t,r,o)){let l=o===null?"is in no member":`is in member ${o}`;return{ok:!1,code:"write-scope-member",message:`${el(t)} may not write ${n}, which ${l}: ${t.class==="agent"?"an agent session writes only the members it is bound to":`writeScope.${t.class}.members leaves it out`}`}}let s=S6(r.protected,n);if(s===null||s.except.length>0&&i&&A6(i.before(),i.after(),s.except))return Ca;let a=s.except.length>0?`, outside what its except allows (${s.except.join(", ")})`:"";return{ok:!1,code:"write-scope-protected",message:`${el(t)} may not write ${n}${a}: writeScope.${t.class}.protected lists ${s.path}`}}function Hv(e,t){try{let n=Qt(e,t);return{declaration:Lt(n.tree),rootOnDisk:n.rootOnDisk,root:n.root,tree:n.tree}}catch(n){if(n instanceof ve)return null;throw n}}function ho(e,t){let n=Un(e),i=n?Gr(n,t):null,r=n&&i?ai(n,i):ps(null),o=a=>{let{tree:l,...c}=a;return{...c,classes:gq(a.declaration.pins,a.rootOnDisk,{tree:l}).registry}};if(i?.commit){let a=Hv(e,i.commit);if(a)return{...o(a),from:"base",policy:r}}let s=Hv(e);return s?{...o(s),from:"working-tree",policy:r}:{declaration:null,from:null,rootOnDisk:null,root:null,policy:r,classes:ka()}}function O6(e,t,n,i){let r=e.declaration;if(!r||e.rootOnDisk===null)return{name:t,declaredName:null,member:null,declared:!1};let o=k6(w6(e.rootOnDisk,n)),s=[...r.records,...r.members.flatMap(l=>l.records)].find(l=>l.path===o);if(s)return{name:t,declaredName:s.name,member:s.member,declared:!0};let a=k6(w6(e.rootOnDisk,i));return{name:t,declaredName:null,member:a.startsWith("..")?null:Fr(a===""?".":a,r.members),declared:!1}}function cT(e){let t=Un(e),n=t?Gr(t):null;if(n?.commit){let r=Hv(e,n.commit);if(r)return{agents:r.declaration.agents,from:"base"}}let i=Hv(e);return i?{agents:i.declaration.agents,from:"working-tree"}:null}function lT(e,t){let n=ho(e);if(n.declaration===null&&(t.agent===void 0||t.agent===null))return n;let i=oT(n.declaration,n.policy,{agent:t.agent,principal:t.principal},n.classes),r=sT(n.declaration,i,n.classes);if(!r.ok)throw new ms(r.code,r.message);let o=aT(n.declaration,i,O6(n,t.kindName,t.kindFile,t.recordsDir),t.verb);if(!o.ok)throw new ms(o.code,o.message);return n}function Uv(e,t){return Dye("git",t,{cwd:e,encoding:"utf-8",stdio:["ignore","pipe","pipe"],maxBuffer:512*1024*1024})}function Vv(e,t,n){try{return Uv(e,["show",`${t}:${n}`])}catch{return null}}function Mye(e,t,n,i){if(i.format!=="markdown-front-matter")return"amend";let r=Vv(e,`${t}^`,n),o=Vv(e,t,n);if(r===null||o===null)return"amend";let s=us(r),a=us(o);if(!s.ok||!a.ok)return"amend";let c=[...new Set([...Object.keys(s.value),...Object.keys(a.value)])].filter(u=>JSON.stringify(s.value[u])!==JSON.stringify(a.value[u]));if(i.session){let u=a.value[i.session.stateField];return typeof u=="string"&&i.session.closed.includes(u)&&s.value[i.session.stateField]!==u?"close":c.every(d=>i.reviewFields.includes(d)||i.session.fills.includes(d))?"review":"amend"}return c.length>0&&c.every(u=>i.reviewFields.includes(u))?"review":"amend"}async function Fye(e){let{top:t,base:n,head:i,prefix:r,declaration:o}=e,s=e.classes??ka();if(o.writeScope===null&&o.agents.length===0)return null;let a=ai(t,{commit:n,from:"flag"}),{activeAttestors:l}=await Promise.resolve().then(()=>(Dd(),e6)),c=await l(),u=g=>o.writeScope?.[g]!==void 0||g==="agent"&&o.agents.length>0,d=[...s.names().filter(u),...nI(o.writeScope,s)],p={base:n,restricted:d,agents:o.agents.map(g=>g.name),commits:[],findings:[]},f=Uv(t,["rev-list","--reverse","--no-merges",`${n}..${i}`]).split(`
|
|
154
|
+
`).filter(Boolean);for(let g of f){let[h,b,w]=Uv(t,["log","-1",`--format=%s%x00%ae%x00%(trailers:key=${Hm},valueonly,separator=%x01)`,g]).split("\0"),x=(w??"").split("").map(O=>O.trim()).filter(Boolean)[0]??null,k=a.active?Um(t,a,g,c):null,R=k?.level==="attested"&&k.principal!==void 0,$=R?k.principal:b.trim(),_=Uv(t,["diff-tree","--no-commit-id","-r","--name-status","--no-renames","-z",g]).split("\0").filter(Boolean),T=[];for(let O=0;O+1<_.length;O+=2){let pe=_[O+1];r!==""&&!pe.startsWith(`${r}/`)||T.push({status:_[O],path:pe})}let C;try{C=oT(o,a,{agent:x,principal:$},s)}catch(O){if(!(O instanceof ms))throw O;p.commits.push({commit:g,subject:h,principal:$,attested:R,class:"agent",agent:x,paths:T.length}),p.findings.push({id:`finding:${O.code}:${g}`,code:O.code,commit:g,path:null,principal:$,class:"agent",agent:x,verb:null,message:`${g.slice(0,8)} has ${Hm}: ${x}: ${O.message}`});continue}p.commits.push({commit:g,subject:h,principal:$,attested:R,class:C.class,agent:C.agent?.name??null,paths:T.length});let K=sT(o,C,s);if(!K.ok){p.findings.push({id:`finding:${K.code}:${g}`,code:K.code,commit:g,path:null,principal:$,class:C.class,agent:null,verb:null,message:`${g.slice(0,8)}: ${K.message}`});continue}if(qv(o,C)!==null)for(let O of T){let pe=r===""?O.path:O.path.slice(r.length+1),F=e.kinds.find(B=>b6.dirname(O.path)===B.dir&&B.match.test(b6.basename(O.path))),Q=null,I;F?(Q=O.status==="A"?"new":O.status==="D"?"delete":Mye(t,g,O.path,F),I=aT(o,C,F.scoped,Q)):I=P6(o,C,pe,{before:()=>O.status==="A"?null:Vv(t,`${g}^`,O.path),after:()=>O.status==="D"?null:Vv(t,g,O.path)}),!I.ok&&p.findings.push({id:`finding:${I.code}:${g}:${pe}`,code:I.code,commit:g,path:pe,principal:$,class:C.class,agent:C.agent?.name??null,verb:Q,message:`${g.slice(0,8)} ${O.status==="D"?"deletes":O.status==="A"?"adds":"changes"} ${pe}: ${I.message}`})}}return p}var x6,iT,_a,jye,ms,Ca,Lye,k6,gs=v(()=>{"use strict";x6=Le(Tf(),1);_t();rI();nd();po();go();mn();fs();Qc();Wv();ci();iT="CHANT_AGENT",_a=["write-scope-member","write-scope-kind","write-scope-class-unknown","agent-unknown"],jye=[..._a,"write-scope-protected"];ms=class extends Error{constructor(n,i){super(i);this.code=n;this.name="WriteScopeError"}};Ca={ok:!0};Lye=Symbol("except");k6=e=>v6==="/"?e:e.split(v6).join("/")});var dT={};_e(dT,{FORGES:()=>I6,IDENTITY_CODES:()=>tl,IdentityError:()=>hs,forgePrincipal:()=>Gye,gateAdmission:()=>zye,gateAdmissionFrom:()=>uT,identify:()=>N6,parseForgeIdentity:()=>D6,refuseUnidentified:()=>ys});function D6(e){let t=Bye.exec(cn(e));if(!t)return null;let n=t[1],i=t[2]??T6[n];return i===null?null:{forge:n,host:i,login:t[3]}}function Gye(e){return e.host===T6[e.forge]?`${e.forge}:${e.login}`:`${e.forge}@${e.host}:${e.login}`}function N6(e,t,n=null){let i=cn(e),r=D6(e);return t.active&&t.signers.some(s=>cn(s.principal)===i)?{principal:e,form:"signer",forge:r}:r?{principal:e,form:"forge",forge:r}:(n?.agents??[]).some(s=>s.principals.some(a=>cn(a)===i))||Pm(ka(),t,e).some(s=>Wye.has(s))?{principal:e,form:"role",forge:null}:{principal:e,form:"name",forge:null}}function ys(e,t,n,i={}){if(e.declaration?.identity?.attribution==="identified"&&!(i.agent!==void 0&&i.agent!==null&&e.declaration.agents.some(r=>r.name===i.agent))){for(let r of t)if(N6(r,e.policy,e.declaration).form==="name")throw new hs(`${n} ${JSON.stringify(r)} names no identity the workspace can check: chant.workspace.json at base sets identity.attribution to identified, so a person is named by a forge identity (github:<login>, gitlab:<login>, or <forge>@<host>:<login>) or by a principal ${e.policy.signersPath} lists at base`)}}function uT(e,t){let n=e.declaration?.identity?.gates[t];if(!n)return null;let{policy:i,classes:r}=e,o={gate:t,class:n.class,signers:i,roles:Am(i),classes:r.all()};return{requirement:n,refuses:s=>Nu(o,s)}}function zye(e,t,n){return uT(ho(e,n),t)}var I6,T6,_6,Bye,Wye,tl,hs,nl=v(()=>{"use strict";Sc();rI();mn();gs();I6=["github","gitlab","forgejo","gitea"],T6={github:"github.com",gitlab:"gitlab.com",forgejo:null,gitea:null},_6="[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?",Bye=new RegExp(`^(${I6.join("|")})(?:@(${_6}(?:\\.${_6})+))?:([a-z0-9](?:[a-z0-9._-]{0,98}[a-z0-9_])?)$`);Wye=new Set(["agent","runner","service"]);tl=["principal-unidentified"],hs=class extends Error{constructor(n){super(n);this.code="principal-unidentified";this.name="IdentityError"}}});function bs(e){return{async read(t){await si(e);let{resolutions:n,pending:i}=await Lr(t,e);return{resolutions:n,pending:i}},async approvalRule(t,n){let{gateAdmission:i}=await Promise.resolve().then(()=>(nl(),dT));return i(e?.cwd??process.cwd(),t,n?.base)},async appendResolution(t){let{record:n}=await $m(t,e);return{record:n,...await ba(e)}},async appendPending(t){let{record:n}=await md(t,e);return{record:n,...await ba(e)}},async readApplied(t){await si(e);let{dir:n,file:i}=Uc(t),r=await rn(n,i,e);return r?pv(r):[]},async appendApplied(t){let{dir:n,file:i}=Uc(t.op),r=JSON.stringify(t,pn),o;for(let s=1;s<=5;s++)try{let a=await $r(n,i,e),l=a?await fn(a,e):null;return await An(n,i,l?`${l.replace(/\n$/,"")}
|
|
155
|
+
${r}
|
|
156
|
+
`:`${r}
|
|
157
|
+
`,`Applied under ${t.gate}`,{...e,expectPriorPathSha:a}),ba(e)}catch(a){if(!(a instanceof Vt))throw a;o=a}throw o}}}function Kv(e){return e.approver?e.approver:{kind:Xr(e.origin)?"agent":"human"}}function rl(e,t,n,i,r,o=n){let s=new Date(n).getTime(),a=Math.min(s,new Date(o).getTime()),l=h=>new Date(h.timestamp).getTime(),c=r.quorum?.roles,u=Sm(r.context),d=new Map,p,f;for(let h of e){if(h.gate!==t||l(h)<a)continue;if(i!==void 0&&!mt(h.planDigest,i)){l(h)>=s&&(!f||l(h)>=l(f))&&(f=h);continue}let b=h.policyDecision;l(h)>=s&&r.mode==="enforce"&&r.policy&&b?.decision==="allow"&&b.mode==="enforce"&&b.version===r.policy.version&&b.contextDigest===u&&(!p||l(h)>=l(p))&&(p=h);let x=Kv(h);if(x.kind!=="human"||c&&!(x.roles??[]).some(R=>c.includes(R)))continue;let k=d.get(h.resolvedBy);(!k||l(h)>=l(k))&&d.set(h.resolvedBy,h)}return{counted:[...d.values()].sort((h,b)=>l(h)-l(b)),need:r.quorum?.count??1,...p?{permit:p}:{},...f?{mismatched:f}:{}}}function il(e,t){let n=a=>new Date(a.timestamp).getTime(),i=a=>a.approval?.policy?.version,r=a=>mt(a.planDigest,t.planDigest)&&i(a)===i(t),o=e.filter(a=>a!==t&&a.gate===t.gate&&a.environment===t.environment&&n(a)<=n(t)).sort((a,l)=>n(l)-n(a)),s=t;for(let a of o){if(!r(a)||Wn(a,s.timestamp))break;s=a}return s.timestamp}function Hye(e,t){return JSON.stringify(e??null,pn)===JSON.stringify(t??null,pn)}async function ol(e,t){let n=t.now??new Date().toISOString(),i=await e.read(t.op),r=t.environment,o=r===void 0?i.pending:i.pending.filter(R=>R.environment===r),s=await e.approvalRule?.(t.gate)??null,a=Cn(o,t.gate),l=a?.timestamp??Vye,c=[],u=(r===void 0?i.resolutions:i.resolutions.filter(R=>R.environment===void 0||R.environment===r)).filter(R=>t.spent===void 0||R.gate!==t.gate||!Mr(t.spent,R)).filter(R=>{if(s===null||R.gate!==t.gate)return!0;let $=s.refuses(R);return $===null?!0:(mt(R.planDigest,t.planDigest)&&new Date(R.timestamp).getTime()>=new Date(l).getTime()&&c.push({resolution:R,reason:$}),!1)});c.sort((R,$)=>new Date(R.resolution.timestamp).getTime()-new Date($.resolution.timestamp).getTime());let d,p;if(t.approval){let R=a&&mt(a.planDigest,t.planDigest)&&a.approval?.policy?.version===t.approval.policy?.version?il(o,a):l,$=rl(u,t.gate,l,t.planDigest,t.approval,R);if($.permit)return{satisfied:!0,resolution:$.permit,via:"policy",approvals:$.counted};if($.counted.length>=$.need)return{satisfied:!0,resolution:$.counted[$.counted.length-1],via:"quorum",approvals:$.counted};d=$.mismatched,p={approvers:$.counted.map(_=>_.resolvedBy),need:$.need}}else{let R=jr(u,t.gate,l,t.planDigest);if(R.resolution)return{satisfied:!0,resolution:R.resolution};d=R.mismatched}let f=d?{...d.planDigest!==void 0?{approved:d.planDigest}:{},planned:t.planDigest,resolvedBy:d.resolvedBy,timestamp:d.timestamp,...r!==void 0?{environment:r}:{}}:void 0,g={...f?{mismatch:f}:{},...p?{quorum:p}:{},...c.length>0?{refused:c}:{}};if(a&&!Wn(a,n)&&mt(a.planDigest,t.planDigest)&&Hye(a.approval,t.approval))return{satisfied:!1,pending:a,recorded:!1,...g};let h=ss(),b=va(),{record:w,pushed:x,pushWarning:k}=await e.appendPending({...t.fields,op:t.op,gate:t.gate,timestamp:n,expiresAt:new Date(new Date(n).getTime()+Fi(t.timeout??"48h")).toISOString(),...t.description?{description:t.description}:{},...t.runId?{runId:t.runId}:{},...h?{url:h}:{},...b?{resume:b}:{},...t.planDigest!==void 0?{planDigest:t.planDigest}:{},...r!==void 0?{environment:r}:{},...t.approval?{approval:t.approval}:{},...t.neverOverMcp?{neverOverMcp:!0}:{}});return{satisfied:!1,pending:w,recorded:!0,pushed:x,...k?{pushWarning:k}:{},...g}}function jd(e,t,n,i,r=!1){return`chant approve ${e} ${t}`+(n===void 0?"":` --env ${n}`)+(i===void 0?"":` --plan ${i}`)+(r?" --sign":"")}var Vye,Gi=v(()=>{"use strict";Mi();On();Rc();Hc();Wt();Em();$t();cs();yd();Vye=new Date(0).toISOString()});function pT(e,t,n){return(e??Jv).replaceAll("{gate}",t).replaceAll("{k}",String(n))}function fT(e,t,n,i){let r=[...e].sort((c,u)=>{let d=i(c),p=i(u);return d<p?-1:d>p?1:0}),o=Math.floor(r.length/n),s=r.length%n,a=(t-1)*o+Math.min(t-1,s),l=o+(t<=s?1:0);return r.slice(a,a+l)}var Jv,mT=v(()=>{"use strict";Jv="{gate}-wave-{k}"});function j6(e){let t=e.filter(n=>n.provisional!==!0).map(n=>({member:n.member,planDigest:n.planDigest})).sort((n,i)=>qye(n.member,i.member));for(let n=1;n<t.length;n++)if(t[n-1].member===t[n].member)throw new Error(`the change set names member ${t[n].member} twice`);return pd("change-set",t)}var qye,gT=v(()=>{"use strict";On();qye=(e,t)=>e<t?-1:e>t?1:0});function yT(e){let t=e.filter(n=>n.provisional===!0).map(n=>n.member);if(t.length>0)throw new hT([...new Set(t)].sort());return j6(e)}function bT(e,t={}){let n=t.over==="changing"?e.filter(i=>i.empty!==!0):[];return[...n.length>0?n:e,...t.extras??[]]}var hT,wT=v(()=>{"use strict";gT();hT=class extends Error{constructor(n){super(`a wave cannot be gated on a provisional plan: ${n.join(", ")} planned before what it reads applied. Plan it again in its own wave, after its upstream applied`);this.members=n;this.name="ProvisionalWaveMemberError"}}});import{dirname as Kye}from"node:path";import{mkdirSync as Jye,renameSync as Zye,writeFileSync as Yye}from"node:fs";function L6(e,t){return ol(e,{op:t.op,gate:t.gate,planDigest:t.digest,description:t.description,...t.timeout?{timeout:t.timeout}:{},...t.now!==void 0?{now:t.now}:{},...t.spent?{spent:t.spent}:{},...t.fields?{fields:t.fields}:{},...t.neverOverMcp?{neverOverMcp:!0}:{}})}function M6(e,t){Jye(Kye(e),{recursive:!0});let n=`${e}.${process.pid}.tmp`;Yye(n,JSON.stringify(t,null,2)+`
|
|
158
|
+
`),Zye(n,e)}var F6=v(()=>{"use strict";Gi();mT();wT()});function Ld(e=process.env){let t=e.CI?.trim().toLowerCase();return t&&t!=="false"&&t!=="0"?"ledger":void 0}function Zv(e){if(e!==void 0)return typeof e=="string"?{name:e}:e}function sl(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 i=typeof e=="string"?{name:e}:e;if(i===null||typeof i!="object"||Array.isArray(i))return[...n,"`point` is a decision point's name or { name, inputs?, pass?, store? }"];let{name:r,inputs:o,pass:s,store:a,...l}=i;if((typeof r!="string"||!Xye.test(r))&&n.push("`point.name` is a decision point's name: lower case letters, digits and hyphens, starting with a letter"),o!==void 0&&(o===null||typeof o!="object"||Array.isArray(o))&&n.push("`point.inputs` is an object of input name to value"),o&&typeof o=="object"){let u=Object.keys(o).filter(d=>d in Vm);u.length>0&&n.push(`\`point.inputs\` gives ${u.join(", ")}, which the gate passes itself`)}s!==void 0&&(!Array.isArray(s)||s.length===0||s.some(u=>typeof u!="string"&&typeof u!="boolean"))&&n.push("`point.pass` is a non-empty list of the answers that pass the gate"),a!==void 0&&a!=="tree"&&a!=="ledger"&&n.push("`point.store` is tree or ledger: where the question is held");let c=Object.keys(l);return c.length>0&&n.push(`\`point\` takes name, inputs, pass and store, not ${c.join(", ")}`),n}function al(e,t,n,i={}){if(n.planDigest!==null&&!t.includes("gate.planDigest"))throw new Error(`gate "${n.name}" binds a plan and asks decision point ${e}, which does not declare the input gate.planDigest: declare it in the points file, so each plan is its own question and an answer for one plan never passes another`);let r={};for(let[o,s]of Object.entries(Vm))t.includes(o)&&n[s]!==null&&(r[o]=n[s]);return{...i,...r}}function qm(e,t,n){return`gate:${e}/${t}${n?`@${n}`:""}`}function Yv(e){if(!e||!e.startsWith("gate:"))return;let t=e.slice(5),n=t.lastIndexOf("@"),i=n>0?t.slice(0,n):t,r=i.indexOf("/");if(!(r<=0||r===i.length-1))return{op:i.slice(0,r),gate:i.slice(r+1),...n>0?{env:t.slice(n+1)}:{}}}var Md,Xye,Vm,ws=v(()=>{"use strict";Md=[!0];Xye=/^[a-z][a-z0-9-]*$/;Vm={"gate.component":"component","gate.name":"name","gate.env":"env","gate.planDigest":"planDigest"}});function Qye(e){if(e!==void 0)return typeof e=="string"?{name:e}:e}function Xv(e){if(e!==null&&typeof e=="object"&&!Array.isArray(e)&&"timeout"in e){let{timeout:t,...n}=e,i=sl(n);return(typeof t!="string"||!/^(\d+(ms|s|m|h|d))+$/.test(t))&&i.push('`point.timeout` is a duration such as "48h"'),i}return sl(e)}function kT(e,t){let n=e.waves.find(i=>i.name===t);return Qye(n?.point??e.point)}function xT(e,t){return pT(e.gateName,e.gate??e.name,t)}function ek(e,t){return`.chant/op-waves/${e.name}/wave-${t}.json`}function Zm(e){let t=`Op waves "${e.name}"`;if(!G6.test(e.name))throw new Error(`${t}: the name must be lowercase letters, digits, "-" and "_"`);if(!e.op)throw new Error(`${t} names no \`op\`. Name the Op a run runs when it names none.`);if(e.plan!==void 0&&e.planWave!==void 0)throw new Error(`${t} has both \`plan\` and \`planWave\`. A wave is planned one run at a time or all at once; give one.`);if(e.apply!==void 0&&e.applyWave!==void 0)throw new Error(`${t} has both \`apply\` and \`applyWave\`. A wave is applied one run at a time or all at once; give one.`);if(e.planWave!==void 0){if(Km(t,"planWave",e.planWave),!e.planWave.some(i=>i.includes("{plans}")))throw new Error(`${t}: the \`planWave\` command never names {plans}, the file it writes each run's plan digest to.`)}else{if(!Array.isArray(e.plan)||e.plan.length===0)throw new Error(`${t} has no \`plan\` command. Each wave plans its runs to bind its gate to their plan digests; give \`plan\` or \`planWave\`.`);if(Km(t,"plan",e.plan),!e.plan.some(i=>i.includes("{plan}")))throw new Error(`${t}: the \`plan\` command never names {plan}, the file it writes the plan digest to.`)}if(e.apply!==void 0&&Km(t,"apply",e.apply),e.applyWave!==void 0&&(Km(t,"applyWave",e.applyWave),!e.applyWave.some(i=>i.includes("{runs}"))))throw new Error(`${t}: the \`applyWave\` command never names {runs}, the file listing the approved runs it applies.`);if(Fd(t,e.hooks),e.waves.length===0)throw new Error(`${t} has no waves.`);if(e.resume!==void 0&&(typeof e.resume.schedule!="string"||e.resume.schedule.trim().split(/\s+/).length!==5))throw new Error(`${t}: resume.schedule must be a five-field cron expression, such as "*/10 * * * *".`);if(e.approvals!==void 0){let i=e.approvals;if(i===null||typeof i!="object"||Array.isArray(i))throw new Error(`${t}: \`approvals\` must be { "spend"?: true | false }.`);for(let[r,o]of Object.entries(i)){if(r!=="spend")throw new Error(`${t}: approvals.${r} is not a setting; the one there is approvals.spend.`);if(typeof o!="boolean")throw new Error(`${t}: approvals.spend must be true or false.`)}}if(e.gateName!==void 0){if(typeof e.gateName!="string"||!e.gateName.includes("{k}")||/\s/.test(e.gateName))throw new Error(`${t}: gateName must be a pattern with {k}, the wave's number, and no spaces, such as "${W6}" or "wave-{k}".`);let i=e.gateName.replaceAll("{gate}","").replaceAll("{k}","").match(/\{[^}]*\}/);if(i)throw new Error(`${t}: gateName names ${i[0]}; the pattern fills in {gate} and {k} only.`)}if(e.digest!==void 0){let i=e.digest;if(i===null||typeof i!="object"||Array.isArray(i))throw new Error(`${t}: \`digest\` must be { "over"?: "all" | "changing" }.`);for(let[r,o]of Object.entries(i)){if(r!=="over")throw new Error(`${t}: digest.${r} is not a setting; the one there is digest.over.`);if(!ebe.includes(o))throw new Error(`${t}: digest.over is ${JSON.stringify(o)}; use "all" or "changing".`)}}if(e.override!==void 0){let i=e.override;if(i===null||typeof i!="object"||Array.isArray(i))throw new Error(`${t}: \`override\` must be { "overriders"?: "<file at base>" }.`);for(let[r,o]of Object.entries(i)){if(r!=="overriders")throw new Error(`${t}: override.${r} is not a setting; the one there is override.overriders.`);if(typeof o!="string"||o.trim()==="")throw new Error(`${t}: override.overriders must be a path, such as ".chant/overriders".`)}}if(e.point!==void 0){let i=Xv(e.point);if(i.length>0)throw new Error(`${t}: ${i.join("; ")}.`)}if(e.neverOverMcp!==void 0&&typeof e.neverOverMcp!="boolean")throw new Error(`${t}: neverOverMcp must be true or false.`);if(e.notify!==void 0){let i=cw(e.notify,"notify");if(i)throw new Error(`${t}: ${i}`)}let n=new Set;for(let i of e.waves){if(!G6.test(i.name))throw new Error(`${t}: wave "${i.name}" must be named with lowercase letters, digits, "-" and "_"`);if(n.has(i.name))throw new Error(`${t} names wave "${i.name}" twice.`);if(n.add(i.name),i.gate!==void 0&&!Jm.includes(i.gate))throw new Error(`${t}: wave "${i.name}" has gate "${i.gate}"; use ${Jm.join(", ")}.`);if(i.approval!==void 0&&!Ia.includes(i.approval))throw new Error(`${t}: wave "${i.name}" has approval "${i.approval}"; use ${Ia.join(", ")}.`);if(Fd(`${t}, wave "${i.name}"`,i.hooks),i.point!==void 0){let s=Xv(i.point);if(s.length>0)throw new Error(`${t}: wave "${i.name}": ${s.join("; ")}.`)}if(i.discover!==void 0&&typeof i.discover!="boolean")throw new Error(`${t}: wave "${i.name}" has discover ${JSON.stringify(i.discover)}; use true or false.`);if(i.rest!==void 0&&typeof i.rest!="boolean")throw new Error(`${t}: wave "${i.name}" has rest ${JSON.stringify(i.rest)}; use true or false.`);if(i.discover){if(e.planWave===void 0)throw new Error(`${t}: wave "${i.name}" discovers its runs, which only \`planWave\` can report. Give planWave.`);if((i.runs??[]).length>0)throw new Error(`${t}: wave "${i.name}" discovers its runs, so it lists none.`)}if(i.rest){if(!i.discover)throw new Error(`${t}: wave "${i.name}" has rest, which follows the waves planWave discovers; set discover too.`);if(i!==e.waves[e.waves.length-1])throw new Error(`${t}: wave "${i.name}" has rest, which only the last wave can have.`);if((i.shares??1)>1)throw new Error(`${t}: wave "${i.name}" has rest and shares; the waves after it run in its one job, so it cannot be split.`)}if(i.discover){let s=i.shares??1;if(!Number.isInteger(s)||s<1)throw new Error(`${t}: wave "${i.name}" has shares ${i.shares}; use a whole number from 1.`);continue}if(!Array.isArray(i.runs)||i.runs.length===0)throw new Error(`${t}: wave "${i.name}" has no runs.`);let r=new Set;for(let s of i.runs){if(!s.target)throw new Error(`${t}: wave "${i.name}" has a run with no target.`);if(r.has(s.target))throw new Error(`${t}: wave "${i.name}" names target "${s.target}" twice.`);r.add(s.target)}let o=i.shares??1;if(!Number.isInteger(o)||o<1)throw new Error(`${t}: wave "${i.name}" has shares ${i.shares}; use a whole number from 1.`);if(o>i.runs.length)throw new Error(`${t}: wave "${i.name}" has ${o} shares for ${i.runs.length} runs, so a share would apply nothing.`)}}function Km(e,t,n){if(!Array.isArray(n)||n.length===0||!n.every(i=>typeof i=="string")||n[0]==="")throw new Error(`${e}: \`${t}\` must be a command as argv, a non-empty array of strings.`)}function Fd(e,t){if(t!==void 0){if(t===null||typeof t!="object"||Array.isArray(t))throw new Error(`${e}: \`hooks\` must be { "before"?: { "plan"?, "apply"? }, "after"?: { "plan"?, "apply"? } }.`);for(let[n,i]of Object.entries(t)){if(n==="apply"){let r=i?.runBy;if(i===null||typeof i!="object"||Array.isArray(i)||Object.keys(i).some(o=>o!=="runBy"))throw new Error(`${e}: hooks.apply must be { "runBy"?: "chant" | "apply" }.`);if(r!==void 0&&!vT.includes(r))throw new Error(`${e}: hooks.apply.runBy is ${JSON.stringify(r)}; use ${vT.map(o=>`"${o}"`).join(" or ")}.`);continue}if(n!=="before"&&n!=="after")throw new Error(`${e}: hooks.${n} is not a moment; use hooks.before or hooks.after (or hooks.apply.runBy).`);if(i===null||typeof i!="object"||Array.isArray(i))throw new Error(`${e}: hooks.${n} must be { "plan"?: [...], "apply"?: [...] }.`);for(let[r,o]of Object.entries(i)){let s=`hooks.${n}.${r}`;if(r==="gate"&&n==="before")throw new Error(`${e}: ${s} is not a moment; a hook runs after the gate (hooks.after.gate), or before the plan or the apply.`);if(r!=="plan"&&r!=="apply"&&r!=="gate")throw new Error(`${e}: ${s} is not a stage; a hook runs before or after plan or apply, or after the gate.`);if(!Array.isArray(o))throw new Error(`${e}: ${s} must be a list of hooks.`);o.forEach((a,l)=>{let c=`${s}[${l}]${a&&typeof a=="object"&&typeof a.name=="string"?` (${a.name})`:""}`;if(!a||typeof a!="object")throw new Error(`${e}: ${c} must be { "command": [...], "onFailure"?, "perRun"? }.`);if(Km(e,`${c}.command`,a.command),a.onFailure!==void 0&&!B6.includes(a.onFailure))throw new Error(`${e}: ${c} has onFailure "${a.onFailure}"; use ${B6.join(" or ")}.`);if(a.onFailure==="approve"&&n==="after"&&r==="apply")throw new Error(`${e}: ${c} has onFailure "approve", but after the apply there is nothing left to hold. Use "fail".`);if(a.onFailure==="approve"&&r==="gate")throw new Error(`${e}: ${c} has onFailure "approve", but the gate has already decided when it runs. Use "fail", or hold the wave from an after.plan hook.`);if(a.perRun!==void 0&&typeof a.perRun!="boolean")throw new Error(`${e}: ${c}.perRun must be true or false.`);if(a.perRun){if(n==="before"&&r==="plan"&&a.command.some(u=>u.includes("{plan}")))throw new Error(`${e}: ${c} runs before the plan, so it has no {plan} yet.`)}else{let u=a.command.find(d=>d.includes("{target}")||d.includes("{plan}"));if(u)throw new Error(`${e}: ${c} runs once for the wave, so it has no {target} or {plan} ("${u}"). Set "perRun": true, or read the runs from {runs}.`)}})}}}}function tk(e,t){let n=e.waves.find(r=>r.name===t),i=(r,o)=>{let[s,a]=o.split("-");return r?.[s]?.[a]??[]};return Object.fromEntries(Qv.map(r=>[r,[...i(e.hooks,r),...i(n?.hooks,r)]]))}function nk(e,t){return e.waves.find(i=>i.name===t)?.hooks?.apply?.runBy??e.hooks?.apply?.runBy??"chant"}function RT(e,t,n){return fT(e,t,n,i=>i.target)}var Jm,Ia,B6,Qv,vT,ebe,W6,$T,G6,Bd=v(()=>{"use strict";ws();lw();mT();lw();Jm=["always","on-destructive","never"],Ia=["ledger","pr-review","sealed"];B6=["fail","approve"],Qv=["before-plan","after-plan","after-gate","before-apply","after-apply"],vT=["chant","apply"],ebe=["all","changing"],W6=Jv;$T=["chant","run","{op}","--env","{target}"];G6=/^[a-z0-9][a-z0-9_-]*$/});import{readFileSync as tbe}from"node:fs";function V6(e,t){let n=rbe[e==="gitlab"?"gitlab":"github"][t];if(n===void 0)throw new Error(`a commit status state is one of ${nbe.join(", ")}, not ${JSON.stringify(t)}`);return n}function q6(e){if(e instanceof rr&&ibe.has(e.status)){let t=e.detail;try{let n=JSON.parse(e.detail),i=n.message??n.error;typeof i=="string"&&(t=i)}catch{}return{merged:!1,reason:t.slice(0,300)||`the forge refused the merge (${e.status})`}}throw e}function Xm(e,t,n){let i=t.toLowerCase(),r=n.toLowerCase();return i===obe[e]?`${e}:${r}`:`${e}@${i}:${r}`}function K6(e,t,n){let i=e.replace(/\/+$/,""),r=async(o,s,a)=>{let l=`${i}${s}`,c=await n(l,{method:o,headers:{...t,...a!==void 0?{"Content-Type":"application/json"}:{}},...a!==void 0?{body:JSON.stringify(a)}:{}}),u=await c.text();if(!c.ok)throw new rr(o,l,c.status,u);return u?JSON.parse(u):null};return{call:r,async list(o,s,a){let l=[];for(let c=1;c<=50;c++){let u=o.includes("?")?"&":"?",d=await r("GET",`${o}${u}${s(c)}`);if(!Array.isArray(d)||(l.push(...d),d.length<a))break}return l}}}function Z6(e,t,n,i){if(!t)throw new Error(`the ${e} needs a marker to be found again`);if(!J6(n,t,i))throw new Error(`the ${e} body ${i==="anywhere"?"does not carry":"does not start with"} its marker ${JSON.stringify(t)}, so the next run could not find it`)}async function Y6(e,t,n,i){if(!n)throw new Error("the comment needs a marker to be found");return(await e.comments(t)).filter(ST(n,i)).sort((r,o)=>r.id-o.id)[0]}async function U6(e,t,n,i,r,o){o&&Z6("comment",n,i,r.match);let s=await Y6(e,t,n,r);if(!s){let c=await e.addComment(t,i);return{action:"created",id:c?.id??0,...c?.url?{url:c.url}:{}}}if(s.body===i)return{action:"unchanged",id:s.id,...s.url?{url:s.url}:{}};let l=(await e.editComment(t,s.id,i))?.url??s.url;return{action:"updated",id:s.id,...l?{url:l}:{}}}async function H6(e,t,n,i,r){n&&r&&Z6("issue",t,n.body,i.match);let o=(await e.openIssues(t)).filter(ST(t,i)).sort((l,c)=>l.id-c.id)[0],s=l=>l?{number:l.id,...l.url?{url:l.url}:{},...l.created?{created:l.created}:{}}:{};if(n===null)return o?i.closeOnClear?(await e.closeIssue(o.id,i.clearComment),{action:"closed",...s(o)}):{action:"left",...s(o)}:{action:"none"};if(!o)return{action:"opened",...s(await e.openIssue(n.title,n.body))};if(abe({title:o.title??"",body:o.body},n,i.sameWhen))return{action:"unchanged",...s(o)};let a=await e.editIssue(o.id,n.title,n.body);return{action:"updated",...s(o),...a?.url?{url:a.url}:{}}}function abe(e,t,n){return typeof n=="function"?n(e,t):e.title!==t.title?!1:typeof n=="string"&&n!==""?e.body.includes(n):e.body===t.body}function X6(e){return{async addComment(t,n){let i=await e.addComment(t,n);return{id:i?.id??0,...i?.url?{url:i.url}:{}}},async findIssue(t,n={}){if(!t)throw new Error("the issue needs a marker to be found");let i=(await e.openIssues(t)).filter(ST(t,n)).sort((r,o)=>r.id-o.id)[0];return i?{number:i.id,title:i.title??"",body:i.body,...i.created?{created:i.created}:{},...i.url?{url:i.url}:{}}:void 0},async findComment(t,n,i={}){let r=await Y6(e,t,n,i);return r?{id:r.id,body:r.body,...r.url?{url:r.url}:{}}:void 0},upsertComment:(t,n,i,r={})=>U6(e,t,n,i,r,!0),upsertNote:async(t,n,i)=>(await U6(e,t,n,i,{},!1)).url,trackIssue:(t,n,i={})=>H6(e,t,n,i,!0),upsertIssue:async(t,n,i)=>(await H6(e,t,{title:n,body:i},{},!1)).url}}function Q6(e,t){let n=(t.host??"github.com").toLowerCase(),i=K6(t.apiBase,e==="github"?{...t.token?{Authorization:`Bearer ${t.token}`}:{},Accept:"application/vnd.github+json"}:{...t.token?{Authorization:`token ${t.token}`}:{},Accept:"application/json"},t.fetch??globalThis.fetch),r=`/repos/${t.repo}`,o=e==="github"?100:50,s=p=>e==="github"?`per_page=100&page=${p}`:`limit=50&page=${p}`,a=p=>{if(!qe(p))return;let f=yo(p.number)??yo(p.id);if(f===void 0)return;let g=z6(p),h=ut(p.html_url),b=ut(p.created_at);return{id:f,body:ut(p.body)??"",...b?{created:b}:{},...ut(p.title)!==void 0?{title:ut(p.title)}:{},...g?{author:g}:{},...h?{url:h}:{}}},l=p=>p.map(a).filter(f=>f!==void 0),c=p=>{if(!qe(p))return;let f=yo(p.number),g=qe(p.head)?ut(p.head.ref):void 0;if(f===void 0)return;let h=qe(p.base)?ut(p.base.ref):void 0,b=ut(p.html_url);return{number:f,title:ut(p.title)??"",body:ut(p.body)??"",head:g??"",...h?{base:h}:{},...b?{url:b}:{}}},u=(p,f)=>{if(!qe(p)||!qe(p.head)||p.head.ref!==f)return!1;let g=qe(p.head.repo)?ut(p.head.repo.full_name):void 0;return g===void 0||g.toLowerCase()===t.repo.toLowerCase()},d={comments:async p=>l(await i.list(`${r}/issues/${p}/comments`,s,o)),addComment:async(p,f)=>a(await i.call("POST",`${r}/issues/${p}/comments`,{body:f})),editComment:async(p,f,g)=>a(await i.call("PATCH",`${r}/issues/comments/${f}`,{body:g})),openIssues:async()=>l((await i.list(`${r}/issues?state=open`,s,o)).filter(p=>qe(p)&&!qe(p.pull_request))),openIssue:async(p,f)=>a(await i.call("POST",`${r}/issues`,{title:p,body:f})),editIssue:async(p,f,g)=>a(await i.call("PATCH",`${r}/issues/${p}`,{title:f,body:g})),async closeIssue(p,f){f&&await i.call("POST",`${r}/issues/${p}/comments`,{body:f}),await i.call("PATCH",`${r}/issues/${p}`,{state:"closed"})}};return{kind:e,host:n,...t.runUrl?{runUrl:t.runUrl}:{},principalOf:p=>Xm(e,n,p),...X6(d),async setStatus(p,f){await i.call("POST",`${r}/statuses/${p}`,{state:V6(e,f.state),context:f.context,description:f.description.slice(0,cbe),...f.url?{target_url:f.url}:{}})},async approvers(p){let f=await i.list(`${r}/pulls/${p}/reviews`,s,o),g=new Map;for(let h of f){let b=z6(h);if(!b||!qe(h)||typeof h.state!="string")continue;let w=h.dismissed===!0?"DISMISSED":h.state.toUpperCase();w==="COMMENTED"||w==="COMMENT"||w==="PENDING"||g.set(b,w)}return[...g].filter(([,h])=>h==="APPROVED").map(([h])=>h).sort()},async pullRequestFor(p){if(e==="forgejo")try{let w=await i.call("GET",`${r}/commits/${p}/pull`);return qe(w)&&typeof w.number=="number"?w.number:null}catch(w){if(w instanceof rr&&w.status===404)return null;throw w}let f=await i.call("GET",`${r}/commits/${p}/pulls`);if(!Array.isArray(f))return null;let g=f.filter(w=>qe(w)&&w.merged_at),b=g.find(w=>qe(w)&&w.merge_commit_sha===p)??g[0];return b&&typeof b.number=="number"?b.number:null},async openPullRequest(p){let f=p.base??await e4(i,r,"default_branch"),g=p.draft&&e==="forgejo"?`WIP: ${p.title}`:p.title,h=await i.call("POST",`${r}/pulls`,{title:g,body:p.body,head:p.head,base:f,...p.draft&&e==="github"?{draft:!0}:{}});return c(h)??{number:0,title:g,body:p.body,head:p.head,base:f}},async findPullRequest(p){let f=t.repo.split("/")[0],g=e==="github"?`?state=open&head=${encodeURIComponent(`${f}:${p}`)}`:"?state=open",h;try{h=await i.list(`${r}/pulls${g}`,s,o)}catch(w){if(e!=="forgejo"||!(w instanceof rr)||w.status!==404)throw w;await i.call("GET",r);return}return h.filter(w=>u(w,p)).map(c).filter(w=>w!==void 0).sort((w,x)=>w.number-x.number)[0]},async editPullRequest(p,f){return c(await i.call("PATCH",`${r}/pulls/${p}`,{...f.title!==void 0?{title:f.title}:{},...f.body!==void 0?{body:f.body}:{}}))},async addLabels(p,f){f.length!==0&&await i.call("POST",`${r}/issues/${p}/labels`,{labels:[...f]})},async mergePullRequest(p,f){let g=f.method??"merge",h;try{h=e==="github"?await i.call("PUT",`${r}/pulls/${p}/merge`,{sha:f.sha,merge_method:g,...f.title!==void 0?{commit_title:f.title}:{},...f.message!==void 0?{commit_message:f.message}:{}}):await i.call("POST",`${r}/pulls/${p}/merge`,{Do:g,head_commit_id:f.sha,...f.title!==void 0?{MergeTitleField:f.title}:{},...f.message!==void 0?{MergeMessageField:f.message}:{},...f.deleteBranch?{delete_branch_after_merge:!0}:{}})}catch(x){return q6(x)}if(qe(h)&&h.merged===!1)return{merged:!1,reason:ut(h.message)??"the forge did not merge it"};let b=await i.call("GET",`${r}/pulls/${p}`).catch(()=>{}),w=(qe(h)?ut(h.sha):void 0)??(qe(b)?ut(b.merge_commit_sha):void 0);if(e==="github"&&f.deleteBranch&&qe(b)&&qe(b.head)&&ut(b.head.ref)&&u(b,ut(b.head.ref))){let x=ut(b.head.ref).split("/").map(encodeURIComponent).join("/");await i.call("DELETE",`${r}/git/refs/heads/${x}`).catch(()=>{})}return{merged:!0,...w?{sha:w}:{}}}}}async function e4(e,t,n){let i=await e.call("GET",t),r=qe(i)?ut(i[n]):void 0;if(!r)throw new Error(`${t} names no default branch to open the pull request against; pass base`);return r}function ET(e){return Q6("github",e)}function AT(e){return Q6("forgejo",e)}function ube(e){let t=(e.host??"gitlab.com").toLowerCase(),n=K6(e.apiBase,e.token?{[e.tokenHeader??"PRIVATE-TOKEN"]:e.token}:{},e.fetch??globalThis.fetch),i=`/projects/${encodeURIComponent(decodeURIComponent(e.project))}`,r=d=>`per_page=100&page=${d}`,o=d=>qe(d.author)?ut(d.author.username):void 0,s=d=>{if(!qe(d))return;let p=yo(d.id);if(p===void 0)return;let f=o(d);return{id:p,body:ut(d.body)??"",...f?{author:f}:{}}},a=d=>{if(!qe(d))return;let p=yo(d.iid);if(p===void 0)return;let f=o(d),g=ut(d.web_url),h=ut(d.created_at);return{id:p,body:ut(d.description)??"",...h?{created:h}:{},...ut(d.title)!==void 0?{title:ut(d.title)}:{},...f?{author:f}:{},...g?{url:g}:{}}},l=`${i}/merge_requests`,c=d=>{if(!qe(d))return;let p=yo(d.iid);if(p===void 0)return;let f=ut(d.target_branch),g=ut(d.web_url);return{number:p,title:ut(d.title)??"",body:ut(d.description)??"",head:ut(d.source_branch)??"",...f?{base:f}:{},...g?{url:g}:{}}},u={comments:async d=>(await n.list(`${l}/${d}/notes`,r,100)).filter(p=>!(qe(p)&&p.system===!0)).map(s).filter(p=>p!==void 0),addComment:async(d,p)=>s(await n.call("POST",`${l}/${d}/notes`,{body:p})),editComment:async(d,p,f)=>s(await n.call("PUT",`${l}/${d}/notes/${p}`,{body:f})),openIssues:async d=>(await n.list(`${i}/issues?state=opened&search=${encodeURIComponent(d)}&in=description`,r,100)).map(a).filter(p=>p!==void 0),openIssue:async(d,p)=>a(await n.call("POST",`${i}/issues`,{title:d,description:p})),editIssue:async(d,p,f)=>a(await n.call("PUT",`${i}/issues/${d}`,{title:p,description:f})),async closeIssue(d,p){p&&await n.call("POST",`${i}/issues/${d}/notes`,{body:p}),await n.call("PUT",`${i}/issues/${d}`,{state_event:"close"})}};return{kind:"gitlab",host:t,...e.runUrl?{runUrl:e.runUrl}:{},principalOf:d=>Xm("gitlab",t,d),...X6(u),async setStatus(d,p){try{await n.call("POST",`${i}/statuses/${d}`,{state:V6("gitlab",p.state),name:p.context,description:p.description.slice(0,lbe),...p.url?{target_url:p.url}:{},...p.pipelineId!==void 0?{pipeline_id:p.pipelineId}:{}})}catch(f){if(f instanceof rr&&f.status===400&&/cannot transition status/i.test(f.message))return;throw f}},async approvers(d){let p=await n.call("GET",`${i}/merge_requests/${d}/approvals`),g=(qe(p)&&Array.isArray(p.approved_by)?p.approved_by:[]).map(h=>qe(h)&&qe(h.user)&&typeof h.user.username=="string"?h.user.username:void 0).filter(h=>h!==void 0);return[...new Set(g)].sort()},async pullRequestFor(d){let p=await n.call("GET",`${i}/repository/commits/${d}/merge_requests`);if(!Array.isArray(p))return null;let f=p.find(g=>qe(g)&&g.state==="merged"&&(g.merge_commit_sha===d||g.squash_commit_sha===d))??p.find(g=>qe(g)&&g.state==="merged");return qe(f)&&typeof f.iid=="number"?f.iid:null},async openPullRequest(d){let p=d.base??await e4(n,i,"default_branch"),f=d.draft?`Draft: ${d.title}`:d.title,g=await n.call("POST",l,{source_branch:d.head,target_branch:p,title:f,description:d.body});return c(g)??{number:0,title:f,body:d.body,head:d.head,base:p}},async findPullRequest(d){return(await n.list(`${l}?state=opened&source_branch=${encodeURIComponent(d)}`,r,100)).filter(f=>qe(f)&&f.source_branch===d&&(f.source_project_id===void 0||f.source_project_id===f.project_id)).map(c).filter(f=>f!==void 0).sort((f,g)=>f.number-g.number)[0]},async editPullRequest(d,p){return c(await n.call("PUT",`${l}/${d}`,{...p.title!==void 0?{title:p.title}:{},...p.body!==void 0?{description:p.body}:{}}))},async addLabels(d,p){p.length!==0&&await n.call("PUT",`${l}/${d}`,{add_labels:p.join(",")})},async mergePullRequest(d,p){let f=p.method??"merge";if(f==="rebase")throw new Error("GitLab has no one-call rebase merge; use method merge or squash");let g=p.title!==void 0?p.message?`${p.title}
|
|
159
|
+
|
|
160
|
+
${p.message}`:p.title:p.message,h;try{h=await n.call("PUT",`${l}/${d}/merge`,{sha:p.sha,...f==="squash"?{squash:!0,...g!==void 0?{squash_commit_message:g}:{}}:{},...g!==void 0?{merge_commit_message:g}:{},...p.deleteBranch?{should_remove_source_branch:!0}:{}})}catch(w){return q6(w)}let b=qe(h)?ut(h.merge_commit_sha)??ut(h.squash_commit_sha):void 0;return qe(h)&&h.state!==void 0&&h.state!=="merged"?{merged:!1,reason:`the merge request is ${String(h.state)}`}:{merged:!0,...b?{sha:b}:{}}}}}function Qm(e=process.env){if(ik(e.GITLAB_CI))return"gitlab";if(ik(e.FORGEJO_ACTIONS)||ik(e.GITEA_ACTIONS))return"forgejo";if(ik(e.GITHUB_ACTIONS))return/\/api\/v1\/?$/.test(e.GITHUB_API_URL??"")?"forgejo":"github"}function dbe(e,t){let n={};if(qe(e)){let i=qe(e.pull_request)?e.pull_request:void 0,r=qe(e.issue)?e.issue:void 0,o=yo(i?.number)??(r&&qe(r.pull_request)?yo(r.number):void 0)??(i?yo(e.number):void 0);o!==void 0&&o>0&&(n.pr=o);let s=i&&qe(i.head)?ut(i.head.sha):void 0;s&&(n.sha=s)}if(n.pr===void 0){let i=/^refs\/pull\/(\d+)\/(?:merge|head)$/.exec(t??"");i&&(n.pr=Number(i[1]))}return n}function t4(e=process.env,t={}){let n=t.kind??Qm(e);if(!n)throw new Ym(void 0,[]);let i=(...$)=>$.map(_=>e[_]?.trim()).find(_=>_!==void 0&&_!==""),r=t.tokenEnv?[t.tokenEnv]:PT[n],o=r.find($=>e[$]?.trim()),s=o?e[o].trim():void 0,a=[],l=`a token (${r.join(", ")})`;if(n==="gitlab"){let $=i("CI_SERVER_URL")?.replace(/\/+$/,""),_=i("CI_API_V4_URL")?.replace(/\/+$/,"")??($?`${$}/api/v4`:void 0),T=i("CI_MERGE_REQUEST_PROJECT_ID","CI_PROJECT_ID","CI_MERGE_REQUEST_PROJECT_PATH","CI_PROJECT_PATH"),C=yo(i("CI_MERGE_REQUEST_IID"));if(_||a.push("CI_API_V4_URL"),T||a.push("CI_PROJECT_ID"),t.requirePr&&!C&&a.push("CI_MERGE_REQUEST_IID (a merge request pipeline)"),s||a.push(l),a.length>0)throw new Ym(n,a);let K=i("CI_MERGE_REQUEST_SOURCE_BRANCH_SHA","CI_COMMIT_SHA"),O=i("CI_PIPELINE_URL");return{kind:n,apiBase:_,repo:T,host:i("CI_SERVER_HOST")?.toLowerCase()??rk($)??rk(_)??"gitlab.com",token:s,tokenSource:o,tokenHeader:o==="CI_JOB_TOKEN"?"JOB-TOKEN":"PRIVATE-TOKEN",...C?{pr:C}:{},...K?{sha:K}:{},...O?{runUrl:O}:{}}}let c=n==="forgejo",u=$=>c?i(`FORGEJO_${$}`,`GITHUB_${$}`):i(`GITHUB_${$}`),d=u("REPOSITORY"),p=u("SERVER_URL")?.replace(/\/+$/,""),f=u("API_URL")?.replace(/\/+$/,"")??(c?p?`${p}/api/v1`:void 0:"https://api.github.com"),g,h=u("EVENT_PATH");if(h)try{g=JSON.parse((t.readFile??($=>tbe($,"utf8")))(h))}catch{g=void 0}let{pr:b,sha:w}=dbe(g,u("REF"));if(d||a.push(c?"FORGEJO_REPOSITORY or GITHUB_REPOSITORY":"GITHUB_REPOSITORY"),f||a.push("GITHUB_SERVER_URL or GITHUB_API_URL"),t.requirePr&&!b&&a.push("a pull request (a pull_request event, or refs/pull/<n>/ in GITHUB_REF)"),s||a.push(l),a.length>0)throw new Ym(n,a);let x=w??u("SHA"),k=u("RUN_ID"),R=p&&k?`${p}/${d}/actions/runs/${k}`:void 0;return{kind:n,apiBase:f,repo:d,host:rk(p)??(c?rk(f):"github.com"),token:s,tokenSource:o,...b?{pr:b}:{},...x?{sha:x}:{},...R?{runUrl:R}:{}}}function n4(e,t){let n=t?{fetch:t}:{},i=e.runUrl?{runUrl:e.runUrl}:{};if(e.kind==="gitlab")return ube({apiBase:e.apiBase,project:e.repo,token:e.token,host:e.host,...e.tokenHeader?{tokenHeader:e.tokenHeader}:{},...i,...n});let r={apiBase:e.apiBase,repo:e.repo,token:e.token,host:e.host,...i,...n};return e.kind==="forgejo"?AT(r):ET(r)}var nbe,rbe,ibe,rr,obe,qe,z6,ut,yo,J6,sbe,ST,cbe,lbe,Ym,rk,ik,PT,eg=v(()=>{"use strict";nbe=["pending","running","success","failed","failure","canceled","error"],rbe={github:{pending:"pending",running:"pending",success:"success",failed:"failure",failure:"failure",canceled:"error",error:"error"},gitlab:{pending:"pending",running:"running",success:"success",failed:"failed",failure:"failed",canceled:"canceled",error:"failed"}};ibe=new Set([405,406,409,422]);rr=class extends Error{constructor(n,i,r,o){super(`${n} ${i} answered ${r}${o?`: ${o.slice(0,300)}`:""}`);this.method=n;this.url=i;this.status=r;this.detail=o;this.name="ForgeApiError"}},obe={github:"github.com",gitlab:"gitlab.com",forgejo:null};qe=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),z6=e=>qe(e)&&qe(e.user)&&typeof e.user.login=="string"?e.user.login:void 0,ut=e=>typeof e=="string"?e:void 0,yo=e=>typeof e=="number"?e:typeof e=="string"&&/^\d+$/.test(e)?Number(e):void 0,J6=(e,t,n)=>n==="anywhere"?e.includes(t):e.startsWith(t),sbe=(e,t)=>{if(e===void 0||e==="")return!0;let n=(typeof e=="string"?[e]:e).map(i=>i.toLowerCase());return t!==void 0&&n.includes(t.toLowerCase())},ST=(e,t)=>n=>J6(n.body,e,t.match)&&sbe(t.author,n.author);cbe=140,lbe=255;Ym=class extends Error{constructor(n,i){super(n?`--forge ${n} needs ${i.join(", ")} in the environment`:"the forge is not known: this is not a GitHub Actions, GitLab CI or Forgejo Actions job, so name the forge");this.kind=n;this.missing=i;this.name="ForgeEnvironmentError"}},rk=e=>{if(e)try{return new URL(e).host.toLowerCase()}catch{return}},ik=e=>e==="true"||e==="1";PT={github:["CHANT_GITHUB_TOKEN","GH_TOKEN","GITHUB_TOKEN"],forgejo:["CHANT_FORGEJO_TOKEN","FORGEJO_TOKEN","GH_TOKEN","GITHUB_TOKEN"],gitlab:["CHANT_GITLAB_TOKEN","GITLAB_TOKEN","CI_JOB_TOKEN"]}});var o4={};_e(o4,{HEAD_PLANS_DIR:()=>tg,headPlansPath:()=>ng,listWavePlanSpecs:()=>mbe,parseHeadPlans:()=>OT,readAllHeadPlans:()=>r4,readHeadPlanDigests:()=>fbe,readHeadPlans:()=>pbe,waveDigests:()=>i4});function ng(e,t){return{dir:`${tg}/${e}`,file:`${t}.json`}}function OT(e){if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}if(t===null||typeof t!="object")return null;let n=t;if(n.version!==1||typeof n.name!="string"||typeof n.head!="string"||typeof n.timestamp!="string"||!Array.isArray(n.waves))return null;let i=[];for(let r of n.waves){if(r===null||typeof r!="object")return null;let{wave:o,name:s,digest:a}=r;if(typeof o!="number"||typeof s!="string"||typeof a!="string")return null;i.push({wave:o,name:s,digest:a})}return{version:1,name:n.name,head:n.head,timestamp:n.timestamp,waves:i}}async function pbe(e,t,n){let{dir:i,file:r}=ng(t,n);return OT(await e.read(i,r))}async function r4(e,t){let n=new Map,{dir:i}=ng(t,"");for(let r of(await e.list(i)).sort()){if(!r.endsWith(".json"))continue;let o=OT(await e.read(i,r));o&&n.set(r.slice(0,-5),o)}return n}function i4(e){return new Map(e.waves.map(t=>[t.wave,t.digest]))}async function fbe(e,t){let n=new Map;for(let[i,r]of await r4(e,t))n.set(i,i4(r));return n}async function mbe(e){return(await e.list(tg)).sort()}var tg,CT=v(()=>{"use strict";tg="_wave-plans"});var rg={};_e(rg,{GATE_APPROVAL_SOURCES:()=>Ia,HEAD_PLANS_DIR:()=>tg,bothRules:()=>bbe,forgejoReviews:()=>d4,githubReviews:()=>u4,gitlabReviews:()=>p4,headPlansPath:()=>ng,pullRequestHeadFromEnv:()=>vbe,reviewSourceFromEnv:()=>wbe,sealedApprovalRule:()=>ybe,trustPolicyAt:()=>hbe});import{readFileSync as gbe}from"node:fs";function hbe(e,t){return Cv(Ea(e,t),t)}function ybe(e,t){return{requirement:{gate:e,class:null},refuses(n){return na(t,n)}}}function bbe(e,t){return e?t?{requirement:e.requirement,refuses:n=>e.refuses(n)??t.refuses(n)}:e:t}function c4(e,t,n){return async i=>{let r=`${a4(e)}${i}`,o=await n(r,{method:"GET",headers:t}),s=await o.text();if(!o.ok)throw new rr("GET",r,o.status,s);return s?JSON.parse(s):null}}function l4(e,t){let n=c4(t.apiBase,e==="github"?{Authorization:`Bearer ${t.token}`,Accept:"application/vnd.github+json"}:{Authorization:`token ${t.token}`,Accept:"application/json"},t.fetch??globalThis.fetch),i=`/repos/${t.repo}`,r=l=>Xm(e,t.host,l),o=e==="github"?"per_page=100":"limit=50";async function s(l){if(e==="forgejo")try{let p=await n(`${i}/commits/${l}/pull`);return hn(p)&&typeof p.number=="number"?p.number:null}catch(p){if(p instanceof rr&&p.status===404)return null;throw p}let c=await n(`${i}/commits/${l}/pulls`);if(!Array.isArray(c))return null;let u=c.filter(p=>hn(p)&&p.merged_at),d=u.find(p=>hn(p)&&p.merge_commit_sha===l)??u[0];return d&&typeof d.number=="number"?d.number:null}async function a(l){let c=await n(`${i}/collaborators/${encodeURIComponent(l)}/permission`);return hn(c)&&["admin","maintain","write","owner"].includes(String(c.role_name??c.permission))}return{kind:e,async mergedReview(l){let c=await s(l);if(c===null)return null;let u=await n(`${i}/pulls/${c}`);if(!hn(u)||!hn(u.user)||!hn(u.head))throw new Error(`pull request #${c} came back without its author or head`);let d=String(u.user.login),p=String(u.head.sha),f=await n(`${i}/pulls/${c}/reviews?${o}`),g=new Map;for(let x of Array.isArray(f)?f:[]){if(!hn(x)||!hn(x.user)||typeof x.state!="string")continue;let k=x.state.toUpperCase();k==="COMMENTED"||k==="COMMENT"||k==="PENDING"||g.set(String(x.user.login),x)}let h=[],b=[],w=!1;for(let[x,k]of g){let R=k.dismissed===!0?"DISMISSED":String(k.state).toUpperCase();if(x.toLowerCase()===d.toLowerCase()){R==="APPROVED"&&b.push(`${r(x)} is the author, whose own review never counts`);continue}let $=e==="forgejo"?k.official===!0:await a(x);if(R==="REQUEST_CHANGES"||R==="CHANGES_REQUESTED"){$&&(w=!0),b.push(`${r(x)} requests changes`);continue}R==="APPROVED"&&($?k.commit_id!==p||k.stale===!0?b.push(`${r(x)} approved ${String(k.commit_id??"another commit").slice(0,12)}, not the head ${p.slice(0,12)}`):h.push(r(x)):b.push(`${r(x)} approved without write access${e==="forgejo"?" (the review is not official)":""}`))}return{pr:c,...typeof u.html_url=="string"?{url:u.html_url}:{},author:r(d),head:p,approvers:w?[]:h.sort(),refused:b}}}}function u4(e){return l4("github",e)}function d4(e){return l4("forgejo",e)}function p4(e){let t=c4(e.apiBase,{"PRIVATE-TOKEN":e.token},e.fetch??globalThis.fetch),n=`/projects/${encodeURIComponent(decodeURIComponent(e.repo))}`,i=r=>Xm("gitlab",e.host,r);return{kind:"gitlab",async mergedReview(r){let o=await t(`${n}/repository/commits/${r}/merge_requests`),s=Array.isArray(o)?o.find(b=>hn(b)&&b.state==="merged"&&(b.merge_commit_sha===r||b.squash_commit_sha===r))??o.find(b=>hn(b)&&b.state==="merged"):void 0;if(!hn(s)||typeof s.iid!="number")return null;let a=s.iid,l=hn(s.author)?String(s.author.username):"",c=String(s.sha),u=await t(`${n}/approvals`),d=hn(u)&&u.reset_approvals_on_push===!0,p=await t(`${n}/merge_requests/${a}/approvals`),f=hn(p)&&Array.isArray(p.approved_by)?p.approved_by:[],g=[],h=[];for(let b of f){let w=hn(b)&&hn(b.user)?b.user:void 0;if(!w||typeof w.username!="string")continue;let x=w.username;if(x.toLowerCase()===l.toLowerCase()){h.push(`${i(x)} is the author, whose own approval never counts`);continue}if(!d){h.push(`${i(x)}'s approval names no commit, and the project keeps approvals after a new push (turn on "Remove all approvals when commits are added")`);continue}let k=await t(`${n}/members/all/${String(w.id)}`).catch(R=>{if(R instanceof rr&&R.status===404)return null;throw R});if(!hn(k)||typeof k.access_level!="number"||k.access_level<30){h.push(`${i(x)} approved without the Developer role`);continue}g.push(i(x))}return{pr:a,...typeof s.web_url=="string"?{url:s.web_url}:{},author:i(l),head:c,approvers:g.sort(),refused:h}}}}function wbe(e=process.env,t){let n=t?{fetch:t}:{};if(e.GITLAB_CI==="true"){let a=e.CHANT_FORGE_TOKEN??e.GITLAB_TOKEN;if(!e.CI_API_V4_URL||!e.CI_PROJECT_ID||!a)throw new Error("a pr-review gate on GitLab needs CI_API_V4_URL, CI_PROJECT_ID and CHANT_FORGE_TOKEN (a token with read_api)");return p4({apiBase:e.CI_API_V4_URL,repo:e.CI_PROJECT_ID,token:a,host:e.CI_SERVER_HOST??s4(e.CI_SERVER_URL,"gitlab.com"),...n})}let i=e.CHANT_FORGE_TOKEN??e.GITHUB_TOKEN??e.GH_TOKEN;if(!e.GITHUB_REPOSITORY||!i)throw new Error("a pr-review gate needs GITHUB_REPOSITORY and a token (GITHUB_TOKEN with pull-requests: read, or CHANT_FORGE_TOKEN)");let r=e.FORGEJO_ACTIONS==="true"||e.GITEA_ACTIONS==="true",o=s4(e.GITHUB_SERVER_URL,"github.com"),s={apiBase:e.GITHUB_API_URL??(r?`${a4(e.GITHUB_SERVER_URL??"")}/api/v1`:"https://api.github.com"),repo:e.GITHUB_REPOSITORY,token:i,host:o,...n};return r?d4(s):u4(s)}function vbe(e=process.env){if(e.GITLAB_CI==="true")return e.CI_MERGE_REQUEST_IID&&(e.CI_MERGE_REQUEST_SOURCE_BRANCH_SHA||e.CI_COMMIT_SHA)||void 0;if(e.GITHUB_EVENT_PATH)try{let n=JSON.parse(gbe(e.GITHUB_EVENT_PATH,"utf-8")).pull_request?.head?.sha;return typeof n=="string"&&n!==""?n:void 0}catch{return}}var hn,a4,s4,ig=v(()=>{"use strict";ra();fs();go();eg();Bd();CT();hn=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),a4=e=>e.replace(/\/+$/,"");s4=(e,t)=>{try{return e?new URL(e).host.toLowerCase():t}catch{return t}}});var DT={};_e(DT,{OVERRIDERS_PATH:()=>Gd,OVERRIDE_APPLIED:()=>m4,OVERRIDE_LEDGER:()=>$be,OVERRIDE_OP:()=>In,appliedOverride:()=>Sbe,decideOverride:()=>Rbe,overrideAuditApplies:()=>Ebe,overrideCommand:()=>ok,overrideDigest:()=>_T,overridePending:()=>g4,overrideRefusal:()=>y4,overridersAt:()=>IT,parseAppliedOverrides:()=>TT,parseOverriders:()=>h4,recordedDenials:()=>sk,sortedRules:()=>Ta});import{createHash as kbe}from"node:crypto";import{spawnSync as xbe}from"node:child_process";function Ta(e){return[...new Set(e.map(t=>t.trim()).filter(Boolean))].sort()}function _T(e,t,n){let i=[In,e,t,...Ta(n)].join(`
|
|
161
|
+
`);return`sha256:${kbe("sha256").update(i).digest("hex")}`}function ok(e,t,n=!1){return`chant approve ${In} ${e} ${Ta(t).map(i=>`--rule ${i}`).join(" ")} --reason "<why>"${n?" --sign":""}`}function g4(e){let t=Ta(e.rules);return{version:1,kind:"pending",op:In,gate:e.subject,timestamp:e.timestamp,expiresAt:e.expiresAt,planDigest:_T(e.subject,e.planDigest,t),plan:e.planDigest,rules:t,description:e.description??`the policy denied this plan (${t.join(", ")})`,...e.runId?{runId:e.runId}:{},...e.url?{url:e.url}:{}}}function sk(e){let t=new Map;for(let n of e){if(n.op!==In||!n.planDigest)continue;let i=t.get(n.gate);(!i||bo(n.timestamp)>=bo(i.timestamp))&&t.set(n.gate,n)}return[...t.values()].map(n=>{let i=n;return{...n,plan:typeof i.plan=="string"?i.plan:"",rules:Array.isArray(i.rules)?Ta(i.rules.filter(r=>typeof r=="string")):[]}}).sort((n,i)=>n.gate<i.gate?-1:n.gate>i.gate?1:0)}function h4(e){let t=[];for(let n of e.split(`
|
|
162
|
+
`)){let i=n.replace(/#.*$/,"").trim();i&&!t.includes(i)&&t.push(i)}return t}function IT(e,t,n=Gd){let i=xbe("git",["cat-file","blob",`${t}:${n}`],{cwd:e,encoding:"utf-8"});return i.status!==0?{base:t,path:n,active:!1,principals:[]}:{base:t,path:n,active:!0,principals:h4(i.stdout)}}function TT(e){let t=[];for(let n of e.split(`
|
|
163
|
+
`).map(i=>i.trim()).filter(Boolean))try{let i=JSON.parse(n);i.version===1&&i.kind==="applied"&&typeof i.op=="string"&&typeof i.gate=="string"&&typeof i.planDigest=="string"&&typeof i.approvedAt=="string"&&t.push(i)}catch{continue}return t}function y4(e,t){let n=t;if(n.via!==void 0)return`the override line was written by a job (via ${String(n.via)}), and an override is a person's`;if(t.review!==void 0)return`the override line came from the review of #${t.review.pr}, and an override is a person's own line`;if(t.approver?.kind==="agent")return`the override by ${t.resolvedBy} was recorded by an agent, and an override is a person's`;let i=`${e.overridersPath??Gd} at base`;if(!e.overriders.map(f4).includes(f4(t.resolvedBy)))return`${t.resolvedBy} is not listed in ${i}${e.overriders.length?` (${e.overriders.join(", ")})`:", which lists nobody"}`;if(!t.note?.trim())return`the override by ${t.resolvedBy} gives no reason`;if(e.mode==="sealed"){let r=e.signers??{base:null,signersPath:Br,active:!1,signers:[],problems:["no signers were read for this sealed override"]};return na(r,t)}return null}function Rbe(e){let t=Ta(e.rules),n=_T(e.subject,e.planDigest,t),i=e.ledger.pending.filter(h=>h.op===In),r=Cn(i,e.subject),o=r?bo(r.timestamp):0,s=(e.applied??[]).filter(h=>h.op===In&&h.gate===e.subject),a=h=>h.planDigest===void 0?void 0:s.find(b=>mt(b.planDigest,h.planDigest)&&bo(b.approvedAt)>=bo(h.timestamp)),l=(h,b)=>!b||bo(h.timestamp)>=bo(b.timestamp),c,u,d,p=[];for(let h of e.ledger.resolutions){if(h.op!==In||h.gate!==e.subject||bo(h.timestamp)<o)continue;let b=y4(e,h),w=a(h);if(mt(h.planDigest,n))b!==null?p.push(b):w?p.push(`the override by ${h.resolvedBy} at ${h.timestamp} is spent: a run applied under it at ${w.timestamp}`):l(h,c)&&(c=h);else{if(b!==null)continue;w?l(h,d)&&(d=h):l(h,u)&&(u=h)}}if(c)return{status:"overridden",digest:n,override:{subject:e.subject,by:c.resolvedBy,at:c.timestamp,reason:c.note.trim(),rules:t,planDigest:e.planDigest,digest:n,sealed:e.mode==="sealed",resolution:c}};let f=e.now??new Date().toISOString(),g=r&&bo(r.expiresAt)>bo(f)&&mt(r.planDigest,n)?sk([r])[0]:void 0;return u?{status:"moved",digest:n,by:u.resolvedBy,was:u.planDigest,refusals:p,...g?{standing:g}:{}}:{status:"none",digest:n,refusals:p,...g?{standing:g}:{},...d?{spent:{digest:d.planDigest,by:d.resolvedBy,at:d.timestamp}}:{}}}function Sbe(e,t){return{version:1,kind:"applied",op:In,gate:e.subject,planDigest:e.digest,approvedAt:e.at,approvedBy:e.by,timestamp:t.timestamp,...t.runId?{runId:t.runId}:{},...t.commit?{commit:t.commit}:{}}}function Ebe(e,t=m4){return e.map((n,i)=>({ref:`${t}:${i+1}`,at:n.timestamp,gate:n.gate,op:n.op,approval:"not-required",overrides:[{gate:n.gate,digest:n.planDigest}],detail:{approvedBy:n.approvedBy,approvedAt:n.approvedAt,...n.runId?{runId:n.runId}:{},...n.commit?{commit:n.commit}:{}}}))}var In,$be,m4,Gd,bo,f4,og=v(()=>{"use strict";Oi();zc();On();ra();_d();In=ea,$be=`_gates/${In}.jsonl`,m4=`_gates/${In}/applied.jsonl`,Gd=".chant/overriders";bo=e=>new Date(e).getTime();f4=e=>e.normalize("NFKC").trim().toLowerCase()});var NT={};_e(NT,{CORE_CLASSES:()=>io,DEFAULT_SIGNERS_PATH:()=>Br,GATE_APPROVAL_SOURCES:()=>Ia,GATE_SEAL_NAMESPACE:()=>Rn,TRUST_CONFIG_PATH:()=>nr,admitApprover:()=>Nu,appliedGateApplies:()=>cq,appliedGatePath:()=>Uc,baseCommit:()=>Cbe,decideGateApproval:()=>Mbe,gateSealPayload:()=>ro,gateSealRefusal:()=>na,gateSignersAt:()=>_be,grantedClasses:()=>Mf,identityGateAdmissionAt:()=>Nbe,identityGatesAt:()=>Ibe,isApprovalSpent:()=>Mr,isPendingGateExpired:()=>Wn,latestPendingGate:()=>Cn,latestResolutionForPlan:()=>jr,latestResolutionSince:()=>fd,parseAllowedSigners:()=>ds,parseAppliedGateLines:()=>pv,reviewApproval:()=>jbe,sshKeyFingerprint:()=>lC,trustConfigProblems:()=>Ov,verifySshSignatureWith:()=>ta});import{spawnSync as Abe}from"node:child_process";import{readFileSync as Pbe}from"node:fs";import{join as Obe,posix as b4}from"node:path";function sg(e,t){return Abe("git",t,{cwd:e,encoding:"utf-8"})}function ak(e,t,n){let i=sg(e,["cat-file","blob",`${t}:${n}`]);return i.status===0?i.stdout:void 0}function Cbe(e){let t=sg(e,["rev-parse","--verify","-q","HEAD^{commit}"]),n=t.stdout.trim();if(t.status!==0||!n)throw new Error(`${e} has no commit checked out, so the gate cannot be decided`);let i=sg(e,["cat-file","commit",n]).stdout.split(`
|
|
164
|
+
|
|
165
|
+
`)[0]??"",r=/^parent ([0-9a-f]{40,64})$/m.exec(i)?.[1];if(!r)return n;let o=()=>sg(e,["cat-file","-e",`${r}^{commit}`]).status===0;if(o()||sg(e,["fetch","-q","--depth=1","origin",r]),!o())throw new Error(`cannot fetch ${r.slice(0,12)}, the commit before this one, so the gate cannot be decided`);return r}function w4(e,t){let n=a=>({signers:{base:t,signersPath:Br,active:!1,signers:[],problems:a},roles:{}}),i=ak(e,t,nr),r=Br,o={};if(i!==void 0){let a;try{a=JSON.parse(i)}catch(c){return n([`${nr} is not JSON: ${c instanceof Error?c.message:String(c)}`])}let l=Ov(a);if(l.length>0)return n([`${nr} is invalid: ${l.join("; ")}`]);r=a.signers??Br,o=a.roles??{}}let s=ak(e,t,r);return{signers:{base:t,signersPath:r,active:s!==void 0,signers:s===void 0?[]:ds(s).signers,problems:[]},roles:o}}function _be(e,t){return w4(e,t).signers}function v4(e,t){for(let n of["chant.workspace.json","chant.workspace.jsonc"]){let i=ak(e,t,n);if(i===void 0)continue;let r=ga(i,{jsonc:n.endsWith(".jsonc")});if(!r.ok)throw new Error(`${n} at base is not valid JSON (${r.message}), so the gate cannot be decided`);return{file:n,value:r.value}}return null}function k4(e){let t=e?.identity?.gates??{};return Object.entries(t).map(([n,i])=>({gate:n,class:typeof i?.class=="string"?i.class:null}))}function Ibe(e,t){let n=v4(e,t);return n===null?[]:k4(n.value)}function Tbe(e,t,n,i){let r=[],o=[];return(Array.isArray(n)?n:[]).forEach((s,a)=>{let l=s!==null&&typeof s=="object"?s:{};if(typeof l.path=="string"&&l.path){let d=b4.normalize(l.path),p=f=>ak(e,t,d==="."?f:b4.join(d,f));r.push({pin:a,source:l.path,read:Bf(p,l.path,mC)});return}if(typeof l.package!="string"||!l.package)return;let c=ia(l.package,i);if(!c){o.push(`${l.package} is not installed under ${i}`);return}let u;try{u=JSON.parse(Pbe(Obe(c,"package.json"),"utf-8")).version}catch{u=void 0}if(typeof l.version=="string"&&l.version&&u!==l.version){o.push(`${l.package} is pinned at ${l.version}, and ${String(u??"an unknown version")} is installed under ${i}`);return}r.push({pin:a,source:l.package,read:Bf(Ff(c),l.package,mC)})}),{classes:bw(r).classes,unread:o}}function Nbe(e,t,n,i={}){let r=v4(e,t),o=r===null?void 0:k4(r.value).find(p=>p.gate===n);if(!o)return null;let{signers:s,roles:a}=w4(e,t),l=r.value.pins,c=i.classes?{classes:i.classes,unread:[]}:Tbe(e,t,l,i.packages??e),u=o.class;if(u!==null&&!Dbe.has(u)&&c.unread.length>0){let p=`identity.gates.${n} names the class ${u}, and the pins in ${r.file} at base could not all be read, so no approval can show it is in that class: ${c.unread.join("; ")}`;return{requirement:o,refuses:()=>p}}let d={gate:n,class:u,signers:s,roles:a,classes:[...io,...c.classes]};return{requirement:o,refuses:p=>Nu(d,p)}}function jbe(e,t,n){let i={pr:e.pr,head:e.head,...e.url?{url:e.url}:{}};if(e.approvers.length===0){let r=e.refused.length>0?e.refused.join("; "):"nobody approved it";return{approved:!1,review:{...i,reason:`no writer other than its author approved the head of #${e.pr}: ${r}`}}}return t===void 0?{approved:!1,review:{...i,approvers:e.approvers,reason:`no plans are recorded for the head ${e.head.slice(0,12)} of #${e.pr} (its pipeline runs \`chant run wave --record-plans\`)`}}:t!==n?{approved:!1,review:{...i,approvers:e.approvers,reason:`the plan moved after the review: the head planned ${t}, and the merge plans ${n}`}}:{approved:!0,review:{...i,approvers:e.approvers}}}function Mbe(e){let{gate:t,planDigest:n,environment:i}=e,r=e.mode??"ledger",o=i===void 0?e.ledger.pending:e.ledger.pending.filter(k=>k.environment===i),s=(i===void 0?e.ledger.resolutions:e.ledger.resolutions.filter(k=>k.environment===void 0||k.environment===i)).filter(k=>k.gate===t),a=r==="sealed",l={base:null,signersPath:Br,active:!1,signers:[],problems:["no signers were read for this sealed gate"]},c=k=>e.refuses?.(k)??(a?na(e.signers??l,k):null),u=Cn(o,t),d=u?.timestamp??Lbe,p=[],f=[],g;for(let k of s){if(e.spend&&Mr(e.ledger.applied??[],k)){new Date(k.timestamp).getTime()>=new Date(d).getTime()&&(!g||new Date(k.timestamp).getTime()>=new Date(g.timestamp).getTime())&&(g=k);continue}let R=c(k);R===null?p.push(k):mt(k.planDigest,n)&&new Date(k.timestamp).getTime()>=new Date(d).getTime()&&f.push({resolution:k,reason:R})}let h=jr(p,t,d,n);if(h.resolution)return{status:"approved",via:"ledger",resolution:h.resolution};let b=e.spend===!0&&e.review?.approved===!0&&Mr(e.ledger.applied??[],{gate:t,planDigest:n,review:{...e.review.review.head?{head:e.review.review.head}:{}}});if(r==="pr-review"&&e.review?.approved&&!b)return{status:"approved",via:"pr-review",review:e.review.review};let w=e.now??new Date().toISOString(),x=u&&!Wn(u,w)&&mt(u.planDigest,n)?u:void 0;return{status:"waiting",...x?{standing:x}:{},...h.mismatched?{mismatched:h.mismatched}:{},uncounted:f.sort((k,R)=>new Date(k.resolution.timestamp).getTime()-new Date(R.resolution.timestamp).getTime()),...r==="pr-review"&&e.review?{review:b?{...e.review.review,reason:`a wave already applied this digest under the review of ${e.review.review.head?.slice(0,12)??"its head"}, so the review is spent`}:e.review.review}:{},...g?{spent:g}:{}}}var Dbe,Lbe,jT=v(()=>{"use strict";zc();On();Hc();ra();_d();nd();Sc();ju();Bd();zc();ra();_d();Sc();Hc();Dbe=new Set(io.filter(e=>e.role!==null).map(e=>e.name));Lbe=new Date(0).toISOString()});var $4={};_e($4,{DEFAULT_GATE_POINT_PASS:()=>Md,GATE_POINT_INPUTS:()=>Vm,chantGatePointAsker:()=>Bbe,chantPointQuestions:()=>Gbe,defaultGatePointStore:()=>Ld,evaluatePointGate:()=>ag,gatePointInputs:()=>al,gatePointOf:()=>Zv,gatePointProblems:()=>sl,gateSubject:()=>qm,isGateRunLocator:()=>Vc,parseGateSubject:()=>Yv,pointGateResumable:()=>cg,resolveGateRunLocator:()=>va});import{execFile as Fbe}from"node:child_process";function x4(e){return e.answeredBy.length>0?e.answeredBy.join(", "):e.decider}async function ag(e,t,n){let i=n.now??new Date().toISOString(),r={component:n.op,name:n.gate,env:n.env??null,planDigest:n.planDigest??null},o=await t.ask({point:n.point.name,inputs:n.inputs??{},facts:r,subject:qm(n.op,n.gate,n.env),...n.point.store?{store:n.point.store}:{}}),s={point:o.point,id:o.id,path:o.path};if(o.state==="answered"&&o.answer!==null){let h={...s,answer:o.answer,decider:o.decider,...o.answeredBy.length>0?{answeredBy:o.answeredBy}:{}},b=n.point.pass??Md;if(!b.includes(o.answer))return{satisfied:!1,answer:h,refused:`decision point ${o.point} answered ${JSON.stringify(o.answer)} (${o.id}, by ${x4(o)}), and gate "${n.gate}" passes only on ${b.map(_=>JSON.stringify(_)).join(" or ")}. To ask again, take the answer back: chant workspace points retract ${o.id} --by <name>`};let x=(await e.read(n.op)).resolutions.find(_=>_.gate===n.gate&&_.answer?.id===o.id&&_.environment===void 0&&mt(_.planDigest,n.planDigest));if(x)return{satisfied:!0,resolution:x,answer:h,recorded:!1};if(!e.appendResolution)throw new Error(`gate "${n.gate}" asks decision point ${o.point}, and this gate ledger cannot record the resolution that cites its answer`);let{record:k,pushed:R,pushWarning:$}=await e.appendResolution({op:n.op,gate:n.gate,resolvedBy:x4(o),timestamp:i,note:`answered through decision point ${o.point} (${o.id})`,...n.planDigest!==void 0?{planDigest:n.planDigest}:{},approver:{kind:o.decider==="quorum"||o.answeredBy.length>0?"human":"agent"},answer:h});return{satisfied:!0,resolution:k,answer:h,recorded:!0,pushed:R,...$?{pushWarning:$}:{}}}let a={id:o.id,point:o.point,state:o.state==="proposed"?"proposed":"escalated",path:o.path,subject:o.subject,steward:o.steward},l=await e.read(n.op),c=Cn(l.pending.filter(h=>h.environment===void 0),n.gate);if(c&&!Wn(c,i)&&mt(c.planDigest,n.planDigest)&&c.answer?.id===o.id&&(!n.neverOverMcp||c.neverOverMcp===!0))return{satisfied:!1,waiting:a,pending:c,recorded:!1};let u=ss(),d=n.resume===!1?void 0:n.resume??va(),{record:p,pushed:f,pushWarning:g}=await e.appendPending({...n.fields,op:n.op,gate:n.gate,timestamp:i,expiresAt:new Date(new Date(i).getTime()+Fi(n.timeout??"48h")).toISOString(),...n.description?{description:n.description}:{},...n.runId?{runId:n.runId}:{},...u?{url:u}:{},...n.planDigest!==void 0?{planDigest:n.planDigest}:{},...d?{resume:d}:{},answer:{...s,...n.point.pass?{pass:n.point.pass}:{}},...n.neverOverMcp?{neverOverMcp:!0}:{}});return{satisfied:!1,waiting:a,pending:p,recorded:!0,pushed:f,...g?{pushWarning:g}:{}}}function cg(e,t){let n=e.answer;if(!n)return{resumable:!1,why:"not-a-point",message:"the pending fact cites no decision point's question"};if(!t||t.id!==n.id)return{resumable:!1,why:"unknown",message:`question ${n.id} (${n.point}) can't be read here`};if(t.state!=="answered"||t.answer===null)return{resumable:!1,why:"open",message:`question ${n.id} (${n.point}) is ${t.state}, not answered yet`};let i=n.pass??Md;return i.includes(t.answer)?{resumable:!0,answer:{point:n.point,id:n.id,path:n.path,answer:t.answer,...t.answeredBy.length>0?{answeredBy:t.answeredBy}:{}},answeredBy:t.answeredBy.length>0?t.answeredBy.join(", "):"quorum",answeredOn:t.answeredOn}:{resumable:!1,why:"refused",message:`question ${n.id} (${n.point}) was answered ${JSON.stringify(t.answer)}, and the gate passes only on ${i.map(r=>JSON.stringify(r)).join(" or ")}`}}function LT(e,t){let[n,...i]=e.command;return new Promise((r,o)=>{Fbe(n,[...i,...t],{cwd:e.cwd,encoding:"utf-8",maxBuffer:16*1024*1024,env:{...process.env,NO_COLOR:"1"}},(s,a,l)=>{try{r(JSON.parse(a))}catch{o(new Error(`chant ${t.slice(0,3).join(" ")} printed no JSON document${s?`: ${s.message}`:""}${l?`
|
|
166
|
+
${l.trim()}`:""}`))}})})}function MT(e,t){let n=t.error;return n?new Error(`${e}: ${n.code}: ${n.message}`):void 0}function Bbe(e){return{async ask(t){let n=await LT(e,["workspace","points","--json"]),i=MT(`decision point ${t.point}`,n);if(i)throw i;let r=n.points?.find(u=>u.name===t.point);if(!r)throw new Error(`gate "${t.facts.name}" asks decision point ${t.point}, and no points file declares it`);let o=al(t.point,r.inputs.map(u=>u.name),t.facts,t.inputs),s=t.store??Ld(),a=await LT(e,["workspace","points","ask",t.point,"--inputs",JSON.stringify(o),"--subject",t.subject,...s?["--store",s]:[]]),l=MT(`decision point ${t.point}`,a);if(l)throw l;let c=a.question;return{id:c.id,point:c.point,path:c.path,state:c.state,answer:c.state==="answered"?c.answer:null,decider:typeof c.decider?.kind=="string"?c.decider.kind:"quorum",answeredBy:c.answeredBy??[],subject:c.subject,steward:c.askedBy?.steward??null}}}}async function Gbe(e){let t=await LT(e,["workspace","points","--json"]),n=MT("chant workspace points",t);if(n)throw n;let i=t.questions??[];return new Map(i.map(r=>[r.id,{id:r.id,state:r.state,answer:r.answer??null,answeredBy:r.answeredBy??[],answeredOn:r.answeredOn??null}]))}var ck=v(()=>{"use strict";zc();V0();On();cs();ws();yd();ws();yd()});function wo(){if(R4)return R4;let e=process.env[S4];return e&&e.trim()!==""?{steward:e.trim()}:void 0}var S4,R4,cl=v(()=>{"use strict";S4="CHANT_STEWARD"});import{execFileSync as Wbe}from"node:child_process";import{closeSync as zbe,existsSync as E4,openSync as Ube,readdirSync as Hbe,readSync as Vbe,statSync as qbe}from"node:fs";import{isAbsolute as Kbe,join as lg,relative as Jbe,resolve as Da,sep as A4}from"node:path";function BT(e,t){let n=Jbe(e,Da(t));if(!(n===""||n===".."||n.startsWith(`..${A4}`)||Kbe(n)))return n.split(A4)}function Xbe(e){if(!e||e.exclude.length===0&&e.include.length===0)return;let t=Da(e.root),n=r=>{if(r.length===0)return()=>!1;let o=(0,FT.default)(r,{dot:!0});return s=>{let a=BT(t,s);return a!==void 0&&a.some((l,c)=>o(a.slice(0,c+1).join("/")))}},i=e.include.map(r=>FT.default.scan(r).base).filter(r=>r!=="");return{excluded:n(e.exclude),included:n(e.include),includeBelow:r=>{let o=BT(t,r);if(o===void 0)return!1;let s=o.join("/");return i.some(a=>a.startsWith(`${s}/`))}}}function Qbe(e){let t;try{t=Wbe("git",["ls-files","-z","--others","--ignored","--exclude-standard","--directory"],{cwd:e,encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:256*1024*1024})}catch{return new Set}let n=new Set,i=Da(e);for(let r of t.split("\0")){if(r==="")continue;let o=r.endsWith("/")?r.slice(0,-1):r;if(o==="."||o==="")return new Set;n.add(lg(i,o))}return n}function ewe(e){if(E4(lg(e,"chant.config.ts")))return!0;let t=lg(e,"chant.config.json");return E4(t)&&!nw(t)}function twe(e,t){return e==="ops"||kf(t).configPath!==void 0}async function ug(e){let t=gr(e);if(!t)return[];let n=Da(e),[{readDeclaration:i,resolveGroups:r,rootExclusions:o},{workingTree:s}]=await Promise.all([Promise.resolve().then(()=>(_t(),T0)),Promise.resolve().then(()=>(Zt(),iC))]),a;try{let l=s(t.dir),c=i(l);a=o(c,r(c,l)).map(u=>Da(t.dir,u.dir))}catch{return[]}return a.filter(l=>BT(n,l)!==void 0)}function P4(e,t){let n;try{n=Ube(e,"r");let i=Buffer.alloc(t),r=Vbe(n,i,0,t,0);return i.toString("utf8",0,r)}catch{return""}finally{n!==void 0&&zbe(n)}}function dg(e){let t=[],n=Xbe(e.globs),i=Qbe(e.root),r=twe(e.walker,e.root),o=new Set((e.excludeDirs??[]).map(p=>Da(p))),s=e.walker==="audit"?Zbe:new Set,a=e.limit,l=p=>i.size>0&&i.has(Da(p)),c=p=>a&&t.length>=a.max?(a.truncated=!0,!1):(t.push(p),!0),u=(p,f)=>{if(f.isDirectory())return"dir";if(f.isFile())return"file";if(e.followSymlinks&&f.isSymbolicLink())try{let g=qbe(lg(p,f.name));return g.isDirectory()?"dir":g.isFile()?"file":void 0}catch{return}},d=(p,f)=>{let g;try{g=Hbe(p,{withFileTypes:!0})}catch{return!0}e.sorted&&g.sort((h,b)=>h.name<b.name?-1:h.name>b.name?1:0);for(let h of g){if(a?.truncated)return!1;let b=lg(p,h.name),w=u(p,h);if(w==="dir"){if(Ybe.has(h.name)||o.has(Da(b)))continue;let x=h.name.startsWith(".")&&!s.has(h.name);if(x&&e.takeSkippedDir?.(h.name,b)){if(!c(b))return!1;continue}if(x||h.name==="dist"||l(b)&&!e.keepIgnored?.(b)||r&&ewe(b)||f){if(n?.included(b)){if(!d(b,!1))return!1}else if(n?.includeBelow(b)&&!d(b,!0))return!1;continue}if(!d(b,!1))return!1}else if(w==="file"){if((f||l(b)&&!e.keepIgnored?.(b)||(n?.excluded(b)??!1))&&!n?.included(b)||!e.accept(h.name,b))continue;if(!c(b))return!1}}return!0};return d(e.root,!1),t}var FT,Zbe,Ybe,lk=v(()=>{"use strict";FT=Le(Tf(),1);Si();Kt();Zbe=new Set([".github",".forgejo"]),Ybe=new Set(["node_modules",".git"])});function rwe(e){return nwe.test(e.slice(0,O4))}function dk(e){let t=P4(e,O4);return t.slice(0,256).includes(uk)||rwe(t)}function iwe(e){return e.endsWith(".ts")&&!e.endsWith(".test.ts")&&!e.endsWith(".spec.ts")}async function pk(e,t){let n=t?.globs===null?void 0:t?.globs??await Su(e);return dg({walker:"source",root:e,globs:n,excludeDirs:await ug(e),accept:(i,r)=>iwe(i)&&!dk(r)})}var uk,O4,nwe,ll=v(()=>{"use strict";Kt();lk();uk="Generated by chant \u2014 do not edit directly",O4=1024,nwe=/^[ \t]*(?:\/\/|\/\*+|\*)[ \t]*chant-discovery-skip(?![\w-])/m});var pg=v(()=>{"use strict"});function Wd(e){if(typeof e!="string")return`${JSON.stringify(e)} is not a string`;if(!fg.test(e))return`${JSON.stringify(e)} can't key a work lease: use letters, digits, ".", "_" and "-", starting with a letter or digit, at most 100 characters`;if(e.includes(".."))return`${JSON.stringify(e)} can't key a work lease: git refuses ".." in a ref name`;if(e.endsWith("."))return`${JSON.stringify(e)} can't key a work lease: git refuses a ref name ending in "."`;if(e.toLowerCase().endsWith(".lock"))return`${JSON.stringify(e)} can't key a work lease: git refuses a ref name ending in ".lock"`}function GT(e){return Wd(e)===void 0}var fg,WT=v(()=>{"use strict";fg=/^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/});var fk=v(()=>{"use strict";Bi();cs();WT();uo()});function gk(e){if(!e||typeof e!="object")return!1;let t=e;return t.kind===I4&&typeof t.name=="string"&&Array.isArray(t.ops)&&!!t.form&&typeof t.form=="object"&&typeof t.form.default=="string"}var I4,ul=v(()=>{"use strict";Bi();pg();fk();I4="Chant::Steward"});var HT={};_e(HT,{discoverOps:()=>vs,discoverStewards:()=>UT});import{existsSync as T4}from"node:fs";import{dirname as swe,join as D4,resolve as N4}from"node:path";async function awe(e){let n=await ot().spawn(["git","rev-parse","--show-toplevel"],{cwd:e});if(n.exitCode!==0)throw new Error("Not in a git repository");return n.stdout.trim()}async function j4(e){let t=N4(await awe(e)),n=N4(e??process.cwd());for(;;){if(T4(D4(n,"chant.config.ts"))||T4(D4(n,"chant.config.json")))return n;if(n===t)break;let i=swe(n);if(i===n)break;n=i}return t}async function L4(e){return dg({walker:"ops",root:e,globs:await Su(e),excludeDirs:await ug(e),accept:(t,n)=>t.endsWith(".op.ts")&&!t.endsWith(".test.ts")&&!t.endsWith(".spec.ts")&&!dk(n)})}function cwe(e){if(!e||typeof e!="object")return;let t=e.props;if(!(!t||typeof t.name!="string"||!Array.isArray(t.phases)))return t}function lwe(e){let t=[],n=new Set,i=(r,o)=>{if(n.has(o))return;let s=cwe(o);s&&(n.add(o),t.push({exportName:r,config:s}))};i("default",e.default);for(let r of Object.keys(e))r!=="default"&&i(r,e[r]);return t}async function vs(e){let t=[],n=new Map,i=await j4(e?.cwd),r=await L4(i),o=new Map;for(let s of r)try{Mn();let a=hr(await import(s)),l=lwe(a);if(l.length===0&&Object.values(a).some(gk))continue;if(l.length===0){t.push(`${s}: exports no Op. Expected \`export default Op({...})\` or a named export such as \`export const deploy = Op({...})\``);continue}for(let{exportName:c,config:u}of l){let d=o.get(u.name);if(d!==void 0){t.push(d===s?`Duplicate Op name "${u.name}" declared twice in ${s}`:`Duplicate Op name "${u.name}" in ${s} and ${d}`);continue}o.set(u.name,s),n.set(u.name,{config:u,filePath:s,exportName:c})}}catch(a){t.push(`${s}: ${a instanceof Error?a.message:String(a)}`)}return{ops:n,errors:t}}async function UT(e){let t=[],n=[],i=new Map,r=new Map,o=await j4(e?.cwd),s=await L4(o);for(let a of s){let l;try{Mn(),l=hr(await import(a))}catch(d){t.push(`${a}: ${d instanceof Error?d.message:String(d)}`);continue}let c=new Set,u=["default",...Object.keys(l).filter(d=>d!=="default")];for(let d of u){let p=l[d];if(!gk(p)||c.has(p))continue;c.add(p);let f=i.get(p.name);if(f){n.push(`Duplicate steward "${p.name}" in ${a} and ${f.filePath}`);continue}let g=p.ops.find(h=>r.has(h.name));if(g){n.push(`${a}: steward "${p.name}" lists op "${g.name}", which steward "${r.get(g.name)}" already runs. Two stewards running one Op are two writers; list it on one of them.`);continue}for(let h of p.ops)r.set(h.name,p.name);i.set(p.name,{declaration:p,filePath:a,exportName:d})}}return{stewards:i,errors:t,conflicts:n}}var Wi=v(()=>{"use strict";no();lk();ll();Kt();ul();Ei();Zs()});import{AsyncLocalStorage as uwe}from"node:async_hooks";import{createHash as B4,randomBytes as JT}from"node:crypto";import{existsSync as dwe,mkdirSync as pwe,readFileSync as ZT,realpathSync as fwe,renameSync as hk,rmSync as YT,statSync as G4,unlinkSync as mwe,writeFileSync as W4}from"node:fs";import{hostname as gwe,tmpdir as hwe}from"node:os";import{dirname as ywe,isAbsolute as bwe,join as Na,resolve as VT}from"node:path";function U4(e){let t=VT(e);for(;;){let n=Na(t,".git");try{let r=G4(n);if(r.isDirectory())return n;if(r.isFile()){let o=ZT(n,"utf-8").match(/^gitdir:\s*(.+?)\s*$/m);if(o)return bwe(o[1])?o[1]:VT(t,o[1])}}catch{}let i=ywe(t);if(i===t)return null;t=i}}function qT(e){try{return fwe(e)}catch{return VT(e)}}function $we(e){let t=U4(qT(e));return t?Na(t,kwe):Na(hwe(),`chant-write-${B4("sha256").update(qT(e)).digest("hex").slice(0,16)}.lock`)}function H4(e){let t=U4(qT(e));return t?Na(t,xwe):null}function yk(e){try{return JSON.parse(ZT(Na(e,"owner.json"),"utf-8"))}catch{return null}}function Rwe(e){try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}}function q4(e,t,n){if(t===null)try{return n-G4(e).mtimeMs>5e3?"it names no holder":null}catch{return null}return Date.parse(t.expiresAt)<n?`it expired at ${t.expiresAt}`:t.pid!==null&&t.host===V4&&!Rwe(t.pid)?`its process ${t.pid} has exited`:null}function K4(e){if(!e)return"a writer that has not said who it is";let t=[e.by,e.agent?`agent ${e.agent}`:null].filter(Boolean).join(", ");return`${e.verb}${t?` (${t})`:""}, since ${e.acquiredAt}, until ${e.expiresAt}`}function Swe(e,t){let n=`${e}.broken-${JT(6).toString("hex")}`;try{hk(e,n)}catch{return}let i=yk(n);if(i!==null&&t!==null&&i.token!==t.token)try{hk(n,e);return}catch{}YT(n,{recursive:!0,force:!0})}function J4(e,t,n=!0){try{pwe(e)}catch(r){if(r.code!=="EEXIST")throw r;let o=yk(e);return n&&q4(e,o,Date.now())!==null?(Swe(e,o),J4(e,t,!1)):{ok:!1,holder:o}}let i=Na(e,`owner.${process.pid}.tmp`);return W4(i,`${JSON.stringify(t,null,2)}
|
|
167
|
+
`),hk(i,Na(e,"owner.json")),{ok:!0}}function Ewe(){let e=process.env[z4],t=e===void 0||e===""?NaN:Number(e);return Number.isFinite(t)&&t>=0?t:wwe}function Awe(e,t,n){let i=Date.now();return{token:JT(16).toString("hex"),pid:n,host:V4,verb:e.verb,by:e.by??null,agent:e.agent??null,acquiredAt:new Date(i).toISOString(),expiresAt:new Date(i+t).toISOString()}}function Pwe(e){if(KT.getStore()?.has(e))return!0;let t=process.env[M4];if(t===void 0||t==="")return!1;let n=yk(e);if(n?.token!==t||q4(e,n,Date.now())!==null)throw new ja("write-lock-not-held",`${M4} names a lock token that no longer holds this working tree's write lock (${n?`it is held by ${K4(n)}`:"nobody holds it"}): the batch's lock was released or expired, so take it again with chant workspace lock acquire and re-read what the batch writes`,n);return!0}function Owe(e,t){if(yk(e)?.token!==t)return!1;try{mwe(Na(e,"owner.json"))}catch{}return YT(e,{recursive:!0,force:!0}),!0}function Cwe(e,t,n){return new ja("write-lock-timeout",`another write holds this working tree's write lock (${e}): ${K4(t)}. Waited ${n}ms; run the write again once it is done, or raise ${z4}`,t)}async function Iwe(e,t){let n=Ewe(),i=Date.now();for(;;){let r=J4(e,t);if(r.ok)return;if(Date.now()-i>=n)throw Cwe(e,r.holder,n);await new Promise(o=>setTimeout(o,_we()))}}async function vo(e,t,n,i){if(n)return i();let r=$we(e);if(Pwe(r))return i();let o=Awe(t,vwe,process.pid);await Iwe(r,o),F4.add(r);try{return await KT.run(new Set([...KT.getStore()??[],r]),i)}finally{F4.delete(r),Owe(r,o.token)}}function dl(e,t){let n=`${e}.chant-${process.pid}-${JT(4).toString("hex")}.tmp`;W4(n,t);try{hk(n,e)}catch(i){throw YT(n,{force:!0}),i}}function Z4(e){return B4("sha256").update(e,"utf-8").digest("hex")}function Y4(e){try{let t=JSON.parse(ZT(e,"utf-8"));if(t&&t.version===1&&t.files&&typeof t.files=="object")return t}catch{}return{version:1,files:{}}}function ks(e,t,n){let i=H4(e);if(!(i===null||t.length===0))try{let r=Y4(i),o=new Date().toISOString();for(let a of t)delete r.files[a.path],r.files[a.path]={sha256:Z4(a.text),verb:n.verb,by:n.by??null,agent:n.agent??null,at:o};let s=Object.keys(r.files);for(let a of s.slice(0,Math.max(0,s.length-Twe)))delete r.files[a];dl(i,`${JSON.stringify(r)}
|
|
168
|
+
`)}catch{}}function bk(e){let t=H4(e),n=t!==null&&dwe(t)?Y4(t):null;return(i,r)=>{let o=n?.files[i];return!o||r===null||o.sha256!==Z4(r)?null:{verb:o.verb,by:o.by,agent:o.agent,at:o.at}}}var M4,z4,wwe,vwe,lHe,kwe,xwe,La,ja,V4,KT,F4,_we,Twe,mg=v(()=>{"use strict";M4="CHANT_WRITE_LOCK",z4="CHANT_WRITE_LOCK_WAIT_MS",wwe=15e3,vwe=2*6e4,lHe=10*6e4,kwe="chant-write.lock",xwe="chant-writes.json",La=["write-lock-timeout","write-lock-not-held"],ja=class extends Error{constructor(n,i,r){super(i);this.code=n;this.holder=r;this.name="WriteLockError"}};V4=gwe(),KT=new uwe,F4=new Set;_we=()=>20+Math.floor(Math.random()*40);Twe=2e3});import{execFileSync as Dwe}from"node:child_process";function X4(e,t,n){try{return Dwe("git",t,{cwd:e,input:n,stdio:[n===void 0?"ignore":"pipe","pipe","pipe"],maxBuffer:512*1024*1024})}catch{return}}function Nwe(e,t){let n=new Map;if(t.length===0)return n;let i=X4(e,["cat-file","--batch"],`${t.join(`
|
|
169
|
+
`)}
|
|
170
|
+
`);if(!i)return n;let r=0;for(let o of t){let s=i.indexOf(10,r);if(s<0)break;let a=i.subarray(r,s).toString("utf-8");r=s+1;let l=a.match(/^[0-9a-f]+ (\w+) (\d+)$/);if(!l)continue;let c=Number(l[2]);l[1]==="blob"&&n.set(o,i.subarray(r,r+c).toString("utf-8")),r+=c+1}return n}function Q4(e,t,n,i){let r=new Map(n.map(d=>[d,null])),o=i.stateField;if(!o||n.length===0)return r;let s=X4(e,["log","--no-renames","--format=%x00%H%x1f%aI%x1f%s","--name-only",t,"--",...n])?.toString("utf-8");if(s===void 0)return r;let a=new Set(n),l=new Map,c=new Map;for(let d of s.split("\0")){if(!d)continue;let p=d.indexOf(`
|
|
171
|
+
`),[f,g,h]=(p<0?d:d.slice(0,p)).split("");l.set(f,{date:g,subject:h});for(let b of(p<0?"":d.slice(p+1)).split(`
|
|
172
|
+
`)){if(!a.has(b))continue;let w=c.get(b)??[];w.push(f),c.set(b,w)}}let u=Nwe(e,[...c].flatMap(([d,p])=>p.map(f=>`${f}:${d}`)));for(let[d,p]of c){let f=null;for(let g of p){let h=u.get(`${g}:${d}`),b=h===void 0?void 0:Sv(i.format,h),w=b?.ok?b.value[o]:void 0;if(typeof w!="string"||!qc(i,w))break;f=g}f&&r.set(d,{sha:f,...l.get(f)})}return r}var eJ=v(()=>{"use strict";mn();xd()});import{dirname as hHe,join as jwe,relative as yHe,resolve as bHe,sep as wHe}from"node:path";function Ma(e,t){return jwe(t,...e.path.split("/"))}var zd=v(()=>{"use strict";_t()});import{execFileSync as Lwe}from"node:child_process";function Mwe(e,t){return Lwe("git",["--no-optional-locks","--literal-pathspecs",...t],{cwd:e,encoding:"utf-8",stdio:["ignore","pipe","pipe"],maxBuffer:256*1024*1024})}function gg(e,t){try{return Mwe(e,t)}catch{return}}function XT(e,t){let n=gg(e,["symbolic-ref","--quiet","--short","HEAD"])?.trim()||null,i=gg(e,["rev-parse","--verify","--quiet","HEAD^{commit}"])?.trim()||null,r=Gr(e,t),o=i&&r.commit&&gg(e,["merge-base",i,r.commit])?.trim()||null;return{branch:n,head:i,base:o,baseFrom:r.from}}function tJ(e){return(e??"").split("\0").filter(Boolean)}function nJ(e,t,n,i,r){let o=new Map;if(t===null){for(let f of i)o.set(f,"new");return{states:o,deleted:[]}}let s=n==="."?"":`${n}/`,a=f=>f.startsWith(s)&&!f.slice(s.length).includes("/"),l=n==="."?".":n,c=new Set(tJ(gg(e,["ls-tree","-r","-z","--name-only",t,"--",l])).filter(a)),u=new Set(tJ(gg(e,["diff","--name-only","-z","--no-renames",t,"--",l])));for(let f of i)o.set(f,c.has(f)?u.has(f)?"modified":"committed":"new");let d=new Set(i),p=[...c].filter(f=>!d.has(f)&&r.test(f.slice(s.length))).sort();return{states:o,deleted:p}}var QT=v(()=>{"use strict";Qc()});var Ud={};_e(Ud,{GATE_SEAL_NAMESPACE:()=>Rn,RECORD_SEAL_NAMESPACE:()=>vk,REVIEW_SEAL_NAMESPACE:()=>iD,SealError:()=>pl,checkGateSeal:()=>Wwe,checkRecordSeal:()=>Gwe,checkVerdictSeal:()=>Bwe,gateSealPayload:()=>ro,recordSealPayload:()=>sD,resolveSigningKey:()=>Uwe,reviewSealPayload:()=>oD,sealGateApproval:()=>qwe,sealRecord:()=>Vwe,sealVerdict:()=>Hwe});import{execFileSync as Fwe}from"node:child_process";import{mkdtempSync as eD,rmSync as tD,writeFileSync as nD}from"node:fs";import{homedir as rJ,tmpdir as rD}from"node:os";import{join as fl,resolve as iJ}from"node:path";function oD(e,t,n,i,r){return Buffer.from(`${e}
|
|
173
|
+
${t}
|
|
174
|
+
${n}
|
|
175
|
+
${i}
|
|
176
|
+
${r}`,"utf-8")}function sD(e,t,n,i){return Buffer.from(`${e}
|
|
177
|
+
${t}
|
|
178
|
+
${n}
|
|
179
|
+
${i??""}`,"utf-8")}function Bwe(e,t){let n=t.record===null||t.digest===null||typeof t.on!="string";return aD(e,{principal:t.reviewer,what:`the verdict by ${t.reviewer}`,role:"reviewer",namespace:iD,seal:t.seal,payload:n?`a seal covers the record id, the verdict's digest and on, and the verdict by ${t.reviewer} lacks one`:oD(t.record,t.digest,t.verdict,t.reviewer,t.on)})}function Gwe(e,t){let n=t.record??"the record";return t.author===null&&(t.seal===void 0||t.seal===null)?{attested:null,code:"seal-missing",message:`${n} names no ${t.authorField}, so it claims no author to seal`}:aD(e,{principal:t.author??"",what:n,role:t.authorField,namespace:vk,seal:t.seal,payload:t.record===null||t.author===null?`a record's seal covers its id and its ${t.authorField}, and ${n} lacks one`:sD(t.record,t.digest,t.author,t.state)})}function Wwe(e,t){return aD(e,{principal:t.resolvedBy,what:`the approval of gate ${t.gate} by ${t.resolvedBy}`,role:"approver",namespace:Rn,seal:t.seal,payload:ro(t)})}function aD(e,t){let n=`${e.signersPath} at base`;if(t.seal===void 0||t.seal===null)return e.active?{attested:!1,code:"seal-missing",message:`${t.what} carries no seal`}:{attested:null,code:"seal-missing",message:`${t.what} carries no seal; there is no signers file at base, so none is needed`};let i=t.seal;if(typeof i!="object"||Array.isArray(i)||typeof i.signer!="string"||typeof i.signature!="string")return{attested:!1,code:"seal-signature-invalid",message:`the seal on ${t.what} is malformed: it needs signer and signature`};if(wk(i.signer)!==wk(t.principal))return{attested:!1,code:"seal-signature-invalid",message:t.role==="reviewer"?`the seal is by ${i.signer}, and the verdict is ${t.principal}'s`:`the seal on ${t.what} is by ${i.signer}, and its ${t.role} is ${t.principal||"empty"}`};if(typeof t.payload=="string")return{attested:!1,code:"seal-signature-invalid",message:t.payload};if(!e.active)return oJ(t.principal,t.payload,i.signature,t.namespace);let r=e.signers.filter(s=>wk(s.principal)===wk(t.principal));if(r.length===0&&e.returnedFrom!==void 0){let s=oJ(t.principal,t.payload,i.signature,t.namespace);return s.attested===!1?s:{attested:null,code:"seal-unverifiable",message:`${t.what} came back in return ${e.returnedFrom}, sealed by ${t.principal}${s.key?` with ${s.key}`:""}, whom neither ${n} nor an admission for that return lists; it counts once an admin admits the signer (chant workspace admit ${e.returnedFrom})`,...s.key?{key:s.key}:{}}}if(r.length===0)return{attested:!1,code:"seal-signer-unlisted",message:`${t.principal} has no key in ${n}, so the seal can't count`};let o=t.namespace===Rn?zwe(r,t.payload,i.signature):Td(r,t.payload,i.signature,t.namespace);return o.ok?{attested:!0,message:`sealed by ${o.principal}${o.key?` with ${o.key}`:""}, a signer ${n} lists`,...o.key?{key:o.key}:{}}:o.missing?{attested:null,code:"seal-unverifiable",message:`the seal by ${t.principal} can't be checked here: ${o.reason}`}:{attested:!1,code:"seal-signature-invalid",message:`the seal does not verify for ${t.principal} against ${n}: ${o.reason}`}}function zwe(e,t,n){let i=e.filter(o=>Lf(o.namespaces,Rn)).map(o=>Buffer.from(o.key.split(" ")[1]??"","base64")),r=ta(n,t,Rn,i);return r.ok?{ok:!0,principal:e[0].principal,key:r.key}:{ok:!1,reason:r.reason}}function oJ(e,t,n,i){if(i===Rn){let o=gU(n),s=o?ta(n,t,i,[o]):{ok:!1,reason:"it is not an SSHSIG"};return s.ok?{attested:null,code:"seal-unverifiable",message:`the signature is intact (${s.key}), and there is no signers file at base to say whose key it is`,key:s.key}:{attested:!1,code:"seal-signature-invalid",message:`the seal by ${e} does not verify over this approval, even without a signers file`}}let r=eD(fl(rD(),"chant-seal-"));try{let o=fl(r,"signature");nD(o,n);let s=Pa(["-Y","check-novalidate","-n",i,"-s",o],t);if(s.missing)return{attested:null,code:"seal-unverifiable",message:`the seal by ${e} can't be checked here: ssh-keygen is not installed`};if(s.status!==0)return{attested:!1,code:"seal-signature-invalid",message:`the seal by ${e} does not verify over ${i===vk?"this record":i===Rn?"this approval":"this verdict"}, even without a signers file`};let a=aJ.exec(s.stdout+s.stderr)?.[1];return{attested:null,code:"seal-unverifiable",message:`the signature is intact${a?` (${a})`:""}, and there is no signers file at base to say whose key it is`,...a?{key:a}:{}}}finally{tD(r,{recursive:!0,force:!0})}}function Uwe(e,t){let n={cleanup:()=>{}};if(e!==!0)return{file:iJ(t,sJ(e)),...n};let i=c=>{try{return Fwe("git",["config","--get",c],{cwd:t,encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).trim()||void 0}catch{return}},r=i("gpg.format"),o=i("user.signingkey");if(r!=="ssh"||o===void 0)throw new pl(`--sign with no key file uses git's user.signingkey when gpg.format is ssh, and git has ${r==="ssh"?"no user.signingkey":`gpg.format ${r??"unset"}`}; pass --sign <key file>`);let s=o.startsWith("key::")?o.slice(5):o.startsWith("ssh-")||o.startsWith("ecdsa-")||o.startsWith("sk-")?o:void 0;if(s===void 0)return{file:iJ(t,sJ(o)),...n};let a=eD(fl(rD(),"chant-sign-")),l=fl(a,"key.pub");return nD(l,`${s}
|
|
180
|
+
`),{file:l,cleanup:()=>tD(a,{recursive:!0,force:!0})}}function sJ(e){return e==="~"?rJ():e.startsWith("~/")?fl(rJ(),e.slice(2)):e}function Hwe(e,t){return cD(e,oD(t.record,t.digest,t.verdict,t.reviewer,t.on),iD,t.reviewer)}function Vwe(e,t){return cD(e,sD(t.record,t.digest,t.author,t.state),vk,t.author)}function qwe(e,t){return cD(e,ro(t),Rn,t.resolvedBy)}function cD(e,t,n,i){let r=Pa(["-q","-Y","sign","-n",n,"-f",e],t);if(r.missing)throw new pl("--sign needs ssh-keygen, and it is not installed here");if(r.status!==0||!r.stdout.startsWith("-----BEGIN SSH SIGNATURE-----"))throw new pl(`ssh-keygen could not sign with ${e}: ${r.stderr.trim()||`exit ${r.status}`}`);let o=eD(fl(rD(),"chant-seal-"));try{let s=fl(o,"signature");nD(s,r.stdout);let a=Pa(["-Y","check-novalidate","-n",n,"-s",s],t),l=aJ.exec(a.stdout+a.stderr)?.[1];if(a.status!==0||!l)throw new pl(`the signature ssh-keygen made with ${e} does not check: ${a.stderr.trim()}`);return{signer:i,key:l,signature:r.stdout}}finally{tD(o,{recursive:!0,force:!0})}}var iD,vk,wk,aJ,pl,Hd=v(()=>{"use strict";Wm();ra();ra();iD="chant-review",vk="chant-record";wk=e=>e.normalize("NFKC").trim().toLowerCase(),aJ=/key (SHA256:[A-Za-z0-9+/=]+)/;pl=class extends Error{constructor(t){super(t),this.name="SealError"}}});import{execFileSync as Kwe}from"node:child_process";import{dirname as Jwe,resolve as lD}from"node:path";async function hg(e,t=[]){let n=[...t.map(o=>lD(e,o))];try{n.push(...li(e).map(o=>o.file))}catch(o){if(!(o instanceof ve))throw o}let i=new Set,r=[];for(let o of n){let s=Tn(o);if(!i.has(s)){i.add(s);try{let a=await gn(o,e);a.kind.session&&r.push(a)}catch(a){if(!(a instanceof Ve))throw a}}}return r}async function lJ(e,t){let n=Tn(lD(t,e));return(await hg(t)).filter(i=>Im(i.kind.session).some(r=>Tn(lD(Jwe(i.file),r))===n))}function yg(e){let t=Un(Tn(e));if(!t)return null;try{return Xc(t,"HEAD")}catch(n){if(n instanceof Ve)return null;throw n}}function kk(e,t,n){try{return Kwe("git",["log",...n,"--format=%H","--",t],{cwd:e,encoding:"utf-8",stdio:["ignore","pipe","pipe"]}).split(`
|
|
181
|
+
`).filter(Boolean)}catch{return[]}}var cJ,xk=v(()=>{"use strict";_t();go();mn();ko();cJ=/^[A-Za-z][A-Za-z0-9]*-[0-9]+$/});var uJ={};_e(uJ,{CLOSE_ERROR_CODES:()=>Zwe,RECORDS_CLOSE_SCHEMA_ID:()=>$k,closeRecord:()=>Xwe});function Ywe(e){return e.toISOString().replace(/\.\d{3}Z$/,"Z")}async function Xwe(e){try{if(e.expect!==void 0&&!/^[0-9a-f]{64}$/.test(e.expect))throw new he("write-usage-invalid",`--expect takes a record's digest, 64 lowercase hex digits as records --json prints it, not ${JSON.stringify(e.expect)}`);return await vo(e.cwd,Ui("records close",e),e.dryRun,()=>Qwe(e))}catch(t){return Ro($k,t)}}async function Qwe(e){try{let t=await $s(e.kind,e.cwd);ml(t,"close",e.cwd,e);let{kind:n}=t.loaded,i=n.session;if(!i||n.stateField===void 0)throw new he("write-usage-invalid",`the ${n.name} kind has no session block, and records close closes a review session; amend sets the state of other records`);let r=(n.closedStates??[])[0];if(r===void 0)throw new he("write-usage-invalid",`the ${n.name} kind lists no closed state, so a session of it can't close`);let o=await zi(t,t.source),s=Vd(o,e.id,n.name);if(bg(t,s,e.id,e.expect),s.state!==null&&(n.closedStates??[]).includes(s.state))throw new he("record-closed",`${e.id} is already ${s.state}, and a closed session is sealed and stays as it is`);if(s.data===null)throw new he("record-unparseable",`${s.path} can't be read, so it can't be closed`);let a=s.data,l=yg(t.root),c={...wg(n,a,t.root),[n.stateField]:r,...i.closedOn?{[i.closedOn]:Ywe(e.now??new Date)}:{},...i.closedRev?{[i.closedRev]:l}:{}},u={...a,...c};delete u[i.seal];let d=xs(t.source.read(s.path),c,u);if(d===void 0)throw new he("record-unparseable",`${s.path}: its fields can't be rewritten in place without changing the rest of the file`);let p=wv(d,i.seal,n.format);if(p===null)throw new he("record-unparseable",`${s.path} can't be read, so it can't be sealed`);let f=xs(d,{[i.seal]:p},{...u,[i.seal]:p});if(f===void 0||wv(f,i.seal,n.format)!==p)throw new he("record-unparseable",`${s.path}: the ${i.seal} line can't be added without changing the text it seals`);let g=await Ba(t,o,s.path,f);e.dryRun||(dl($o(t,s.path),f),ks(t.root,[{path:s.path,text:f}],Ui("records close",e)));let h={...u,[i.seal]:p};return{$schema:$k,contract:xo,kind:t.view,path:s.path,id:e.id,changed:Object.keys(h).filter(b=>sn(a[b])!==sn(h[b])),seal:{field:i.seal,digest:p},closedRev:l,dryRun:!!e.dryRun,warnings:g.warnings,digest:g.digest,...e.dryRun?{text:f}:{}}}catch(t){return Ro($k,t)}}var $k,Zwe,dJ=v(()=>{"use strict";OI();mn();vg();mg();xk();gs();$k="https://intentius.io/chant/schemas/workspace/records-close/v1/records-close.schema.json",Zwe=[...Fa,"write-usage-invalid","record-not-found","record-closed","record-conflict",...La,..._a,...Sa]});var DJ={};_e(DJ,{AMEND_ERROR_CODES:()=>ive,LOAD_ERROR_CODES:()=>Fa,NEW_ERROR_CODES:()=>rve,RECORDS_AMEND_SCHEMA_ID:()=>kg,RECORDS_NEW_SCHEMA_ID:()=>Ga,RECORDS_REVIEW_SCHEMA_ID:()=>xg,RECORDS_WRITE_CONTRACT_VERSION:()=>xo,REVIEW_ERROR_CODES:()=>ove,RecordWriteError:()=>he,VERDICTS:()=>fD,WRITE_USAGE:()=>IJ,abs:()=>$o,allocateId:()=>AJ,amendRecord:()=>CJ,declaredSessionKind:()=>TJ,declaredWriteKind:()=>gD,failure:()=>Ro,findRecord:()=>Vd,isContentAddressed:()=>Rk,newRecord:()=>OJ,open:()=>$s,openedRevFill:()=>wg,overlay:()=>$g,pick:()=>Wa,readAll:()=>zi,refuseOutOfScope:()=>ml,refuseStale:()=>bg,removeField:()=>bJ,renderRecord:()=>gl,replaceFields:()=>xs,resolveWriteKind:()=>Kd,reviewRecord:()=>_J,runRecordsWrite:()=>wve,schemaOrder:()=>Zd,slug:()=>mD,stableJson:()=>sn,toYaml:()=>qd,validateWrite:()=>Sk,validatedEntry:()=>Ba,writeWho:()=>Ui});import{createHash as eve}from"node:crypto";import{readFileSync as tve,statSync as nve,writeFileSync as hJ}from"node:fs";import{join as hD,posix as Jd,relative as pJ,resolve as yJ}from"node:path";function uD(e){return sve.test(e)&&!ave.has(e)?e:JSON.stringify(e)}function dD(e){return e===null||typeof e!="object"}function fJ(e){return Array.isArray(e)?e.length===0:e!==null&&typeof e=="object"&&Object.keys(e).length===0}function qd(e,t=0){let n=" ".repeat(t);if(Array.isArray(e))return e.length===0?`${n}[]`:e.map(r=>dD(r)?`${n}- ${pD(r)}`:fJ(r)?`${n}- ${mJ(r)}`:Array.isArray(r)?`${n}-
|
|
182
|
+
${qd(r,t+2)}`:`${n}- ${qd(r,t+2).slice(t+2)}`).join(`
|
|
183
|
+
`);if(dD(e))return`${n}${pD(e)}`;let i=[];for(let[r,o]of Object.entries(e))dD(o)?i.push(`${n}${uD(r)}: ${pD(o)}`):fJ(o)?i.push(`${n}${uD(r)}: ${mJ(o)}`):i.push(`${n}${uD(r)}:
|
|
184
|
+
${qd(o,t+2)}`);return i.join(`
|
|
185
|
+
`)}function gl(e,t){return`---
|
|
186
|
+
${qd(e)}
|
|
187
|
+
---
|
|
188
|
+
${t}`}function cve(e){let t=e.replace(/\r\n?/g,`
|
|
189
|
+
`),n=t.match(/^---\n[\s\S]*?\n---(?:\n|$)/);return n?t.slice(n[0].length):""}function sn(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(sn).join(",")}]`;let t=e;return`{${Object.keys(t).sort().map(n=>`${JSON.stringify(n)}:${sn(t[n])}`).join(",")}}`}function xs(e,t,n){let i=e.replace(/\r\n?/g,`
|
|
190
|
+
`).split(`
|
|
191
|
+
`);if(i[0]!=="---")return;let r=i.indexOf("---",1);if(r<0)return;for(let[a,l]of Object.entries(t)){let c=qd({[a]:l}).split(`
|
|
192
|
+
`),u=a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),d=new RegExp(`^(?:${u}|"${u}"|'${u}')[ \\t]*:(?:[ \\t]|$)`),p=i.findIndex((g,h)=>h>0&&h<r&&d.test(g));if(p<0){i.splice(r,0,...c),r+=c.length;continue}let f=p;for(;f+1<r&&/^(?:$|[ \t#-])/.test(i[f+1]);)f++;for(;f>p&&i[f]==="";)f--;i.splice(p,f-p+1,...c),r+=c.length-(f-p+1)}let o=i.join(`
|
|
193
|
+
`),s=us(o);return s.ok&&sn(s.value)===sn(n)?o:void 0}function bJ(e,t,n){let i=e.replace(/\r\n?/g,`
|
|
194
|
+
`).split(`
|
|
195
|
+
`);if(i[0]!=="---")return;let r=i.indexOf("---",1);if(r<0)return;let o=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=new RegExp(`^(?:${o}|"${o}"|'${o}')[ \\t]*:(?:[ \\t]|$)`),a=i.findIndex((u,d)=>d>0&&d<r&&s.test(u));if(a>=0){let u=a;for(;u+1<r&&/^(?:$|[ \t#-])/.test(i[u+1]);)u++;for(;u>a&&i[u]==="";)u--;i.splice(a,u-a+1)}let l=i.join(`
|
|
196
|
+
`),c=us(l);return c.ok&&sn(c.value)===sn(n)?l:void 0}function mD(e){return e.toLowerCase().replace(/`/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,48).replace(/-$/,"")}function Rk(e){return e.format==="json"&&e.idFrom==="sha256"}async function $s(e,t,n={}){let i=Tn(t),r=Un(i)??i,o=await gn(e,i);if(!(o.kind.format==="markdown-front-matter"&&o.kind.idField!==void 0||!!n.contentAddressed&&Rk(o.kind))){let l=o.kind.format!=="markdown-front-matter"?`format ${o.kind.format}`:`ids from ${o.kind.idFrom}`,c=Rk(o.kind)?"a content-addressed record never changes once records new writes it, so amend, review and close never write one":"records new, amend and review write only Markdown front matter records with an idField, and records new a JSON record named for the sha256 of its bytes";throw new he("write-usage-invalid",`the ${o.kind.name} kind has ${l}: ${c}`)}let a=pJ(r,o.dir).split("\\").join("/")||".";return{loaded:o,root:r,workspaceRoot:Ek(o.file,r),source:Od(r),view:{name:o.kind.name,schema:o.kind.schema.id,file:pJ(r,o.file).split("\\").join("/")},dirRel:a}}function ml(e,t,n,i){let r=lT(n,{kindName:e.loaded.kind.name,kindFile:e.loaded.file,recordsDir:e.loaded.dir,verb:t,agent:i.agent,principal:i.by});return i.by!==void 0&&ys(r,[i.by],"--by",{agent:i.agent}),r}function wJ(e,t,n,i,r){let o=[t.reviews?.decider,t.proposedBy?.field].filter(s=>s!==void 0).map(s=>n[s]).filter(s=>typeof s=="string"&&s.trim()!=="");ys(e,o,`${i} author`,{agent:r})}async function zi(e,t){let n=$n(e.workspaceRoot==="."?e.root:hD(e.root,...e.workspaceRoot.split("/"))),i=await Rv(e.loaded,e.root,t);return(await $a(e.loaded,{root:e.root,source:t,assets:n,workspaceRoot:e.workspaceRoot,...i?{subjects:i}:{}})).records}function $g(e,t,n){let i=Jd.dirname(t),r=Jd.basename(t);return{label:e.label,list(o){let s=e.list(o);return o!==i||!s||s.includes(r)?s:[...s,r]},read(o){return o===t?n:e.read(o)},bytes(o){return o===t?Buffer.from(n,"utf-8"):e.bytes(o)}}}async function Sk(e,t,n,i,r=e.source){return(await Ba(e,t,n,i,r)).warnings}async function Ba(e,t,n,i,r=e.source){let o=await zi(e,$g(r,n,i)),s=o.find(l=>l.path===n);if(!s)throw new he("record-path-unmatched",`${n} is not a file the kind ${e.view.name} reads`);if(s.reasons.length>0)throw new he(s.reasons[0].code,s.reasons.map(l=>`${l.code}: ${l.message}`).join("; "));let a=new Map(t.map(l=>[l.path,new Set(l.reasons.map(c=>`${c.code}\0${c.message}`))]));for(let l of o){if(l.path===n)continue;let c=l.reasons.find(u=>!a.get(l.path)?.has(`${u.code}\0${u.message}`));if(c)throw new he(c.code,`writing ${n} would make ${l.path} invalid: ${c.message}`)}return s}async function vJ(e,t,n){let i=e.loaded.kind.reviews?.ratified;if(i===void 0||t.state!==i)return;let r=Un(e.root),o=ai(r??e.root,r?Gr(r):{commit:null,from:null}),s=$n(e.workspaceRoot==="."?e.root:hD(e.root,...e.workspaceRoot.split("/"))),a=await Rg(e.loaded,s,o),l=a?Ev(e.loaded.kind,t,a):null;if(l===null||l.met)return;let c=l.notCounted.length>0?` (not counted: ${l.notCounted.map(u=>`${u.reviewer}, ${u.reason.code}`).join("; ")})`:"";throw new he("ratify-quorum-not-met",`${n} can't be ${i} yet: its quorum needs ${l.need} agreeing verdicts that count, and it has ${l.agreed}${c}. Add verdicts with chant workspace records review ${n} --verdict agree --by <reviewer>, then set ${e.loaded.kind.stateField} to ${i} again`)}function bg(e,t,n,i){if(i===void 0||i===t.digest)return;let r=bk(e.root)(t.path,e.source.read(t.path)),o=r?` It was last written by chant workspace ${r.verb}${r.by?` for ${r.by}`:""}${r.agent?` in agent session ${r.agent}`:""} at ${r.at}.`:"";throw new he("record-conflict",`${n} has changed since the digest given with --expect (${i}): its digest is now ${t.digest}.${o} Read it again with chant workspace records --json, and write again with --expect ${t.digest} if the change still stands`,{id:n,path:t.path,expected:i,digest:t.digest,lastWrite:r})}function kJ(e){if(e!==void 0&&!/^[0-9a-f]{64}$/.test(e))throw new he("write-usage-invalid",`--expect takes a record's digest, 64 lowercase hex digits as records --json prints it, not ${JSON.stringify(e)}`)}function Ui(e,t){return{verb:e,by:t.by??null,agent:t.agent??null}}function Vd(e,t,n){let i=e.filter(r=>r.id===t);if(i.length===0)throw new he("record-not-found",`no ${n} record has id ${t}`);if(i.length>1)throw new he("record-id-duplicate",`id ${t} is used by ${i.map(r=>r.path).join(" and ")}; make the ids unique before writing either`);return i[0]}function xJ(e,t){let n;try{n=JSON.parse(e)}catch(i){throw new he("write-input-invalid",`the fields given with ${t} are not JSON: ${i instanceof Error?i.message:String(i)}`)}if(n===null||typeof n!="object"||Array.isArray(n))throw new he("write-input-invalid",`the fields given with ${t} must be a JSON object`);return n}function $J(e,t,n){if(e.loaded.kind.reviews&&on in t)throw new he("write-input-invalid",`the fields given with ${n} set ${on}, and only --sign writes a record's seal`);let i=e.loaded.kind.seal?.field;if(i!==void 0&&!e.loaded.kind.session&&i in t)throw new he("write-input-invalid",`the fields given with ${n} set ${i}, and chant writes it when the record closes`)}function RJ(e,t,n,i){let{kind:r}=e.loaded;if(!r.seal||r.session||r.stateField===void 0)return{text:t,data:n};let o=n[r.stateField];if(typeof o!="string"||!(r.closedStates??[]).includes(o))return{text:t,data:n};let s=r.seal.field,a=wd(t,s,r.format);if(a===null)throw new he("record-unparseable",`${i} can't be read, so it can't be sealed`);let l={...n,[s]:a},c=xs(t,{[s]:a},l);if(c===void 0||wd(c,s,r.format)!==a)throw new he("record-unparseable",`the ${s} field can't be written into ${i} without changing the text it seals`);return{text:c,data:l}}function SJ(e,t,n,i){for(let r of[e.session?.openedRev,e.session?.closedRev])if(!(r===void 0||!(r in t)||r in n&&sn(n[r])===sn(t[r])))throw new he("write-input-invalid",`the fields given with ${i} set ${r}, and chant writes it: records new writes the commit a session opened at, and records close the one it closed at`)}function lve(e,t){if(!e.source||!e.states||e.stateField===void 0)return;let n=t[e.source.field];if(n===null||typeof n!="object"||Array.isArray(n)||n.via!=="harvest")return;let i=e.states[0],r=t[e.stateField];if(r!==i)throw new he("source-harvest-not-proposed",`${e.source.field}.via is harvest, and a harvested ${e.name} opens ${i}, not ${JSON.stringify(r??null)}: write it with ${e.stateField} "${i}", and let the person who decides it move it on with chant workspace records amend or review`)}async function EJ(e,t,n,i,r,o){let{kind:s}=e.loaded;if(!s.reviews)throw new he("write-usage-invalid",`--sign seals a record's author, named by the kind's reviews.decider field, and the ${s.name} kind declares no reviews`);let a=s.reviews.decider,l=n[a];if(typeof l!="string"||l.trim()==="")throw new he("record-sign-failed",`${i} names no ${a}, so there is no author to seal: set ${a}, then seal it with records amend ${i} --sign`);let c=s.stateField!==void 0&&typeof n[s.stateField]=="string"?n[s.stateField]:null,u=Yc(t,Zc(s),s.format),{resolveSigningKey:d,sealRecord:p,SealError:f}=await Promise.resolve().then(()=>(Hd(),Ud)),g;try{let b=d(r,o);try{g={...p(b.file,{record:i,digest:u,author:l,state:c})}}finally{b.cleanup()}}catch(b){throw b instanceof f?new he("record-sign-failed",b.message):b}let h=xs(t,{[on]:g},{...n,[on]:g});if(h===void 0)throw new he("record-unparseable",`the ${on} field can't be written into ${i} without changing the rest of the file`);if(Yc(h,Zc(s),s.format)!==u)throw new Error(`sealing ${i} moved its digest; the seal block and the digest rule disagree`);return{text:h,seal:g}}function uve(e,t,n){let{kind:i,schema:r}=e.loaded;if(i.session)return`A closed session is sealed and stays as it is: open a new session for what follows, with chant workspace records new ${e.view.file}`;let o=r.properties!==null&&typeof r.properties=="object"?r.properties:{};return i.supersedes&&(r.additionalProperties!==!1||i.supersedes.field in o)?`Write a new record that supersedes it: ${n}`:`Write a new record in its place with chant workspace records new ${e.view.file}; the ${i.name} schema has no field that links it to ${t}`}function wg(e,t,n){let i=e.session?.openedRev;if(i===void 0||t[i]!==null)return{};let r=yg(n);return r===null?{}:{[i]:r}}function Zd(e,t){let n=Array.isArray(t.required)?t.required.filter(s=>typeof s=="string"):[],i=t.properties!==null&&typeof t.properties=="object"?Object.keys(t.properties):[],r=[...new Set([...n,...i])],o=Object.keys(e);return[...r.filter(s=>o.includes(s)),...o.filter(s=>!r.includes(s))]}function Wa(e,t){return Object.fromEntries(t.map(n=>[n,e[n]]))}function $o(e,t){return hD(e.root,...t.split("/"))}function dve(){return new Date().toISOString().slice(0,10)}function Ro(e,t){if(t instanceof he||t instanceof Ve||t instanceof ms||t instanceof hs||t instanceof ja){let n=t instanceof he?t.conflict:void 0;return{$schema:e,contract:xo,error:{code:t.code,message:t.message},...n?{conflict:n}:{}}}throw t}function AJ(e,t,n){let i=[];for(let a of e){let c=(a.id??Jd.basename(a.path).match(/^([A-Za-z][A-Za-z0-9]*-[0-9]+)/)?.[1]??null)?.match(pve);c&&i.push({prefix:c[1],digits:c[2]})}if(t===void 0){let a=[...new Set(i.map(l=>l.prefix))];if(a.length!==1)throw new he("record-id-unallocatable",a.length===0?`no ${n} record has an id of the form <prefix>-<number> to follow; pass --prefix <prefix>, or give the id in the fields`:`the ${n} records use the prefixes ${a.join(", ")}; pass --prefix with one of them, or give the id in the fields`);t=a[0]}let r=i.filter(a=>a.prefix===t),o=r.reduce((a,l)=>Math.max(a,Number(l.digits)),0),s=Math.max(3,...r.map(a=>a.digits.length));return`${t}-${String(o+1).padStart(s,"0")}`}function PJ(e,t,n,i,r){let{kind:o}=e.loaded,s={...t},a=n.through;if(i&&a?.opensInitial&&o.states&&o.stateField!==void 0){let l=o.states[0],c=s[o.stateField];if(c===void 0)s[o.stateField]=l;else if(c!==l)throw new he("record-state-not-initial",`a new ${o.name} opens ${l}, and the fields give ${o.stateField} ${JSON.stringify(c)}: write it ${l}, and let the person who decides it move it on with a review or an amendment`)}if(n.by!==void 0){if(n.by.trim()==="")throw new he("write-usage-invalid","by needs the name of the person or agent that proposed or decided");let l=i&&!!o.states&&o.stateField!==void 0&&(s[o.stateField]===void 0||s[o.stateField]===o.states[0]);if(o.proposedBy&&l){let c=o.proposedBy.field;if(s[c]!==void 0&&s[c]!==null&&s[c]!==n.by)throw new he("write-input-invalid",`the fields given with ${r} set ${c} to ${JSON.stringify(s[c])}, and by names ${JSON.stringify(n.by)}: give one proposer`);s[c]=n.by}else{if(!o.reviews)throw new he("write-usage-invalid",`by names a record's author, the kind's reviews.decider field, and the ${o.name} kind declares no reviews`);let c=o.reviews.decider;if(s[c]!==void 0&&s[c]!==null&&s[c]!==n.by)throw new he("write-input-invalid",`the fields given with ${r} set ${c} to ${JSON.stringify(s[c])}, and by names ${JSON.stringify(n.by)}: give one author`);s[c]=n.by}}if(!a)return s;if(o.source&&(i||o.source.field in s)){let l=o.source.field,c=s[l];c==null?s[l]={...a.source}:typeof c=="object"&&!Array.isArray(c)&&(s[l]={...c,...a.source})}return s}async function OJ(e){try{return await vo(e.cwd,Ui("records new",e),e.dryRun,()=>fve(e))}catch(t){return Ro(Ga,t)}}async function fve(e){try{if(e.prefix!==void 0&&!/^[A-Za-z][A-Za-z0-9]*$/.test(e.prefix))throw new he("write-usage-invalid",`--prefix takes letters and digits, starting with a letter, not ${JSON.stringify(e.prefix)}`);let t=await $s(e.kind,e.cwd,{contentAddressed:!0}),n=ml(t,"new",e.cwd,e),i=PJ(t,xJ(e.fields,"--from"),e,!0,"--from"),{kind:r,schema:o}=t.loaded;if(wJ(n,r,i,"--from",e.agent),$J(t,i,"--from"),SJ(r,i,{},"--from"),Rk(r))return await mve(t,i,e);let s=r.idField,a=await zi(t,t.source),l=i[s],c;if(l===void 0)c=AJ(a,e.prefix,r.name);else{if(typeof l!="string"||l==="")throw new he("write-input-invalid",`${s} must be a non-empty string when it is given`);let _=a.find(T=>T.id===l||Jd.basename(T.path).startsWith(`${l}-`)||Jd.basename(T.path)===`${l}.md`);if(_)throw new he("record-id-taken",`id ${l} is already used by ${_.path}; ids are never reused, so leave ${s} out to have the next one allocated`);c=l}lve(r,i);let u=r.session?.openedRev?{[r.session.openedRev]:yg(t.root)}:{},d={...i,...u,[s]:c},p=Wa(d,Zd(d,o)),f=typeof p.title=="string"?p.title:"",g=new RegExp(r.location.match),h=[mD(f)?`${c}-${mD(f)}.md`:null,`${c}.md`].filter(_=>_!==null),b=h.find(_=>g.test(_));if(!b)throw new he("record-path-unmatched",`the kind's location.match ${r.location.match} matches none of ${h.join(", ")}`);let w=t.dirRel==="."?b:`${t.dirRel}/${b}`;if(t.source.list(t.dirRel)?.includes(b))throw new he("record-id-taken",`${w} already exists`);let x=gl(p,f?`
|
|
197
|
+
# ${f}
|
|
198
|
+
`:""),k;e.sign!==void 0&&({text:x,seal:k}=await EJ(t,x,p,c,e.sign,e.cwd)),{text:x}=RJ(t,x,k?{...p,[on]:k}:p,c);let R=await Ba(t,a,w,x);await vJ(t,R,c);let $=R.warnings;return e.dryRun||(hJ($o(t,w),x,{flag:"wx"}),ks(t.root,[{path:w,text:x}],Ui("records new",e))),{$schema:Ga,contract:xo,kind:t.view,path:w,id:c,...k?{seal:k}:{},dryRun:!!e.dryRun,warnings:$,digest:R.digest,...e.dryRun?{text:x}:{}}}catch(t){return Ro(Ga,t)}}async function mve(e,t,n){let{kind:i,schema:r}=e.loaded;if(n.prefix!==void 0)throw new he("write-usage-invalid",`the ${i.name} kind's ids are the sha256 of each record's bytes, so --prefix allocates nothing`);if(n.sign!==void 0)throw new he("write-usage-invalid",`the ${i.name} kind names no author to seal: its records are named for the sha256 of their bytes`);let o=Wa(t,Zd(t,r)),s=`${JSON.stringify(o,null,2)}
|
|
199
|
+
`,a=eve("sha256").update(s,"utf-8").digest("hex"),l=`${a}.json`;if(!new RegExp(i.location.match).test(l))throw new he("record-path-unmatched",`the kind's location.match ${i.location.match} does not match ${l}`);let c=e.dirRel==="."?l:`${e.dirRel}/${l}`;if(e.source.list(e.dirRel)?.includes(l))throw new he("record-id-taken",`${c} already exists, with the same bytes: the record is already written`);let u=await zi(e,e.source),d=await Ba(e,u,c,s);return n.dryRun||(hJ($o(e,c),s,{flag:"wx"}),ks(e.root,[{path:c,text:s}],Ui("records new",n))),{$schema:Ga,contract:xo,kind:e.view,path:c,id:a,dryRun:!!n.dryRun,warnings:d.warnings,digest:d.digest,...n.dryRun?{text:s}:{}}}async function CJ(e){try{return kJ(e.expect),await vo(e.cwd,Ui("records amend",e),e.dryRun,()=>gve(e))}catch(t){return Ro(kg,t)}}async function gve(e){try{let t=await $s(e.kind,e.cwd),n=ml(t,"amend",e.cwd,e),i=PJ(t,xJ(e.fields,"--set"),e,!1,"--set"),{kind:r}=t.loaded;wJ(n,r,i,"--set",e.agent),$J(t,i,"--set");let o=await zi(t,t.source),s=Vd(o,e.id,r.name);bg(t,s,e.id,e.expect);let a=s.data;SJ(r,i,a,"--set");let c={...s.state!==null&&(r.closedStates??[]).includes(s.state)?{}:wg(r,a,t.root),...i},u=Object.keys(c).filter(C=>!(C in a)),d=Wa({...a,...c},[...Object.keys(a),...Zd(Wa(c,u),t.loaded.schema)]),p=Object.keys(d).filter(C=>sn(a[C])!==sn(d[C]));if(p.includes(r.idField))throw new he("amend-id-immutable",`${r.idField} never changes: ids are never renumbered. Write a new record that supersedes ${e.id} instead`);let f=s.state,g=r.supersedes?.key===void 0?JSON.stringify(e.id):`[{"${r.supersedes.key}": "${e.id}"}]`,h=r.supersedes?`chant workspace records new with ${r.supersedes.field}: ${g}`:"chant workspace records new";if((p.length>0||e.sign!==void 0)&&f!==null&&(r.closedStates??[]).includes(f))throw new he("record-closed",`${e.id} is ${f}, a closed state, so nothing in it changes. ${uve(t,e.id,h)}`);let b=C=>typeof C=="string"?r.approval?.[C]??0:0;if(p.length>0&&r.approval&&b(f)>0){let C=[r.stateField,r.pins?.field,r.reviews?.field].filter(pe=>typeof pe=="string"),K=(r.states??[]).filter(pe=>b(pe)>=b(f)),O=p.filter(pe=>!C.includes(pe));if(O.length>0)throw new he("amend-supersede-instead",`${e.id} is ${f}, so ${O.join(", ")} can't change in place: only ${C.join(", ")} may. Write the change as a new record that supersedes it (${h}); it replaces ${e.id} once it is ${K.filter(pe=>b(pe)>0).join(" or ")}`);if(r.stateField!==void 0&&p.includes(r.stateField)&&b(d[r.stateField])<b(f))throw new he("amend-supersede-instead",`${e.id} is ${f}, and ${JSON.stringify(d[r.stateField])} is approved less strongly: a state only moves to ${K.join(", ")}. Write a new record that supersedes it (${h})`)}let w=t.source.read(s.path),x=p.length===0?w:xs(w,Wa(d,p),d)??gl(d,cve(w)),k,R,$=r.reviews!==void 0&&on in a;if(e.sign!==void 0)({text:x,seal:k}=await EJ(t,x,d,e.id,e.sign,e.cwd)),d[on]=k;else if($&&(Yc(x,Zc(r),r.format)!==Yc(w,Zc(r),r.format)||r.stateField!==void 0&&sn(a[r.stateField])!==sn(d[r.stateField]))){let C=a[on]?.signer;delete d[on];let K=bJ(x,on,d);if(K===void 0)throw new he("record-unparseable",`${s.path}: the ${on} block can't be removed without changing the rest of the file`);x=K,R=`${e.id} was sealed${typeof C=="string"?` by ${C}`:""}, and the amendment moves its digest or its state, so the seal was removed: seal it again with records amend ${e.id} --sign`}if(sn(a[on])!==sn(d[on])&&p.push(on),p.length>0&&r.seal&&!r.session){let C=RJ(t,x,d,e.id);x=C.text,sn(a[r.seal.field])!==sn(C.data[r.seal.field])&&p.push(r.seal.field)}let _=s.warnings,T=s.digest;if(p.length>0){let C=await Ba(t,o,s.path,x);r.stateField!==void 0&&p.includes(r.stateField)&&await vJ(t,C,e.id),_=C.warnings,T=C.digest}return!e.dryRun&&p.length>0&&(dl($o(t,s.path),x),ks(t.root,[{path:s.path,text:x}],Ui("records amend",e))),{$schema:kg,contract:xo,kind:t.view,path:s.path,id:e.id,changed:p,...k?{seal:k}:{},...R?{sealDropped:R}:{},dryRun:!!e.dryRun,warnings:_,digest:T,...e.dryRun?{text:x}:{}}}catch(t){return Ro(kg,t)}}async function _J(e){try{return kJ(e.expect),await vo(e.cwd,Ui("records review",e),e.dryRun,()=>hve(e))}catch(t){return Ro(xg,t)}}async function hve(e){try{if(!fD.includes(e.verdict))throw new he("write-usage-invalid",`--verdict takes ${fD.join(", ")}, not ${JSON.stringify(e.verdict)}`);if(e.by.trim()==="")throw new he("write-usage-invalid","--by needs the reviewer's name");if(e.session!==void 0&&e.session==="")throw new he("write-usage-invalid","--session needs a session id");let t=await $s(e.kind,e.cwd);ml(t,"review",e.cwd,e);let{kind:n}=t.loaded;if(!n.reviews)throw new he("review-unsupported",`the ${n.name} kind declares no reviews field, so its records take no review`);let i=n.reviews.field,r=await zi(t,t.source),o=Vd(r,e.id,n.name);if(bg(t,o,e.id,e.expect),o.state!==null&&(n.closedStates??[]).includes(o.state))throw new he("record-closed",`${e.id} is ${o.state}, a closed state, so it takes no more reviews`);if(e.verdict==="dissent"&&!(e.note??"").trim())throw new he("review-note-required","a dissent needs a reason: pass --note <text> with the concern");let s=e.session!==void 0?await yve(t,e.session,e.cwd):void 0;s&&ml(s.so,"review",e.cwd,e);let a=o.data[i]??[];if(!Array.isArray(a))throw new he("record-schema-invalid",`${o.path}: ${i} is not a list`);let l=t.source.read(o.path),c={reviewer:e.by,verdict:e.verdict,...e.note!==void 0?{note:e.note}:{},on:e.on??dve(),digest:Yc(l,Zc(n),n.format),...e.session!==void 0?{session:e.session}:{}};e.sign!==void 0&&(c.seal=await bve(e.sign,e.cwd,{record:e.id,digest:c.digest,verdict:e.verdict,reviewer:e.by,on:c.on}));let u=[...a,c],d=xs(l,{[i]:u},{...o.data,[i]:u});if(d===void 0)throw new he("record-unparseable",`${o.path}: the ${i} block can't be rewritten in place without changing the rest of the file`);let p=await Ba(t,r,o.path,d),f=p.warnings,g;if(s){let{so:h,before:b,target:w}=s,x=h.loaded.kind.session,k=w.data[x.verdicts]??[];if(!Array.isArray(k))throw new he("record-schema-invalid",`${w.path}: ${x.verdicts} is not a list`);let R={record:e.id,principal:e.by,verdict:e.verdict,digest:c.digest},$={...wg(h.loaded.kind,w.data,h.root),[x.verdicts]:[...k,R]},_=xs(h.source.read(w.path),$,{...w.data,...$});if(_===void 0)throw new he("record-unparseable",`${w.path}: the ${x.verdicts} block can't be rewritten in place without changing the rest of the file`);await Sk(h,b,w.path,_,$g(t.source,o.path,d)),g={path:w.path,text:_,out:{id:e.session,path:w.path,verdict:R,...e.dryRun?{text:_}:{}}}}return e.dryRun||(dl($o(t,o.path),d),g&&dl($o(t,g.path),g.text),ks(t.root,[{path:o.path,text:d},...g?[{path:g.path,text:g.text}]:[]],Ui("records review",e))),{$schema:xg,contract:xo,kind:t.view,path:o.path,id:e.id,review:c,...g?{session:g.out}:{},dryRun:!!e.dryRun,warnings:f,digest:p.digest,...e.dryRun?{text:d}:{}}}catch(t){return Ro(xg,t)}}async function yve(e,t,n){let i=await lJ(e.loaded.file,n);for(let r of i){let o=await $s(r.file,n),s=await zi(o,o.source);if(!s.some(l=>l.id===t))continue;let a=Vd(s,t,o.view.name);if(a.data===null)throw new he("record-unparseable",`session ${t} (${a.path}) can't be read, so the verdict can't be added to it`);if(a.state!==null&&(o.loaded.kind.closedStates??[]).includes(a.state))throw new he("session-not-open",`session ${t} is ${a.state}, so it takes no more verdicts: give the verdict in an open session, or without --session`);return{so:o,before:s,target:a}}throw new he("session-unknown",i.length===0?`no session kind the workspace declaration names has ${e.view.file} as its subjects, so there is no session ${t} to give the verdict in`:`no ${i.map(r=>r.kind.name).join(" or ")} record has id ${t}`)}async function bve(e,t,n){let{resolveSigningKey:i,sealVerdict:r,SealError:o}=await Promise.resolve().then(()=>(Hd(),Ud));try{let s=i(e,t);try{return{...r(s.file,n)}}finally{s.cleanup()}}catch(s){throw s instanceof o?new he("review-sign-failed",s.message):s}}function Wr(e,t){return{$schema:e,contract:xo,error:{code:"write-usage-invalid",message:`${t}
|
|
200
|
+
${IJ}`}}}function gD(e,t,n){let i;try{i=li(t)}catch(r){if(!(r instanceof ve))throw r;return Wr(e,`${n}; the declaration can't name one: ${r.code}: ${r.describe()}`)}return i.length===0?Wr(e,n):i.length>1?Wr(e,`the declaration names ${i.length} record kinds (${i.map(r=>r.declared.path).join(", ")}), so name the one to write with --kind`):i[0].file}function Kd(e,t){try{if(nve(yJ(t,e)).isFile())return e}catch{}let n;try{n=li(t)}catch{return e}let i=n.filter(r=>(r.declared.name??Jd.basename(r.declared.path).replace(/(?:\.kind)?\.[cm]?[jt]s$/,""))===e);return i.length===1?i[0].file:e}function gJ(e,t,n,i){if(n===void 0||n==="")return Wr(e,`${t} <file|-> is required`);try{return tve(n==="-"?0:yJ(i,n),"utf-8")}catch(r){return{$schema:e,contract:xo,error:{code:"write-input-invalid",message:`${t} ${n} could not be read: ${r instanceof Error?r.message:String(r)}`}}}}async function TJ(e,t){let n=(await hg(t)).map(i=>i.file);return n.length===1?n[0]:n.length===0?Wr(e,"--kind <session kind file> is required: the declaration names no session kind"):Wr(e,`the declaration names ${n.length} session kinds (${n.join(", ")}), so name the one to close with --kind`)}async function wve(e){let{args:t}=e,n=process.cwd(),i=t.extraPositional,r=process.env[iT]||void 0,o=c=>(console.log(JSON.stringify(c,null,2)),"error"in c?1:0);if(i==="close"){let{closeRecord:c,RECORDS_CLOSE_SCHEMA_ID:u}=await Promise.resolve().then(()=>(dJ(),uJ));if(t.sign!==void 0)return o(Wr(u,"--sign is not taken by close: the seal close writes is the digest of the session text"));let d=t.extraPositional2;if(!d)return o(Wr(u,"close needs the session's id"));let p=t.kind!==void 0?Kd(t.kind,n):await TJ(u,n);return o(typeof p!="string"?p:await c({kind:p,id:d,dryRun:t.dryRun,cwd:n,agent:r,expect:t.expect}))}if(i==="new"){let c=t.extraPositional2??t.kind,u=c!==void 0?Kd(c,n):gD(Ga,n,"new needs the kind file");if(typeof u!="string")return o(u);if(t.expect!==void 0)return o(Wr(Ga,"--expect is not taken by new: a new record has no digest yet, and its id is allocated under the write lock"));let d=gJ(Ga,"--from",t.migrateFrom,n);return o(typeof d!="string"?d:await OJ({kind:u,fields:d,prefix:t.prefix,by:t.by,sign:t.sign,dryRun:t.dryRun,cwd:n,agent:r}))}let s=i==="amend"?kg:xg,a=t.extraPositional2;if(!a)return o(Wr(s,`${i} needs the record's id`));let l=t.kind!==void 0?Kd(t.kind,n):gD(s,n,"--kind <kind file> is required");if(typeof l!="string")return o(l);if(i==="amend"){if(t.by!==void 0)return o(Wr(s,"--by is not taken by amend: set decided_by, or a kind's proposedBy field, with --set"));let c=gJ(s,"--set",t.set,n);return o(typeof c!="string"?c:await CJ({kind:l,id:a,fields:c,sign:t.sign,dryRun:t.dryRun,cwd:n,agent:r,expect:t.expect}))}return t.verdict===void 0?o(Wr(s,"--verdict agree|dissent|abstain is required")):t.by===void 0?o(Wr(s,"--by <principal> is required")):o(await _J({kind:l,id:a,verdict:t.verdict,by:t.by,note:t.note,session:t.session,sign:t.sign,dryRun:t.dryRun,cwd:n,agent:r,expect:t.expect}))}var xo,Ga,kg,xg,Fa,rve,ive,ove,fD,he,sve,ave,pD,mJ,pve,IJ,vg=v(()=>{"use strict";go();mn();ko();Qc();_t();xk();Zt();gs();nl();mg();xo=1,Ga="https://intentius.io/chant/schemas/workspace/records-new/v1/records-new.schema.json",kg="https://intentius.io/chant/schemas/workspace/records-amend/v1/records-amend.schema.json",xg="https://intentius.io/chant/schemas/workspace/records-review/v1/records-review.schema.json",Fa=["kind-unreadable","kind-invalid","schema-unreadable","schema-id-mismatch","schema-invalid","location-missing"],rve=[...Fa,"write-usage-invalid","write-input-invalid","record-id-taken","record-id-unallocatable","record-path-unmatched","record-sign-failed","source-harvest-not-proposed","record-state-not-initial","ratify-quorum-not-met",...La,..._a,...tl,...Sa],ive=[...Fa,"write-usage-invalid","write-input-invalid","record-not-found","amend-id-immutable","record-closed","amend-supersede-instead","record-sign-failed","ratify-quorum-not-met","record-conflict",...La,..._a,...tl,...Sa],ove=[...Fa,"write-usage-invalid","record-not-found","review-unsupported","record-closed","review-note-required","review-sign-failed","session-unknown","session-not-open","record-conflict",...La,..._a,...tl,...Sa],fD=["agree","dissent","abstain"],he=class extends Error{constructor(n,i,r){super(i);this.code=n;this.conflict=r;this.name="RecordWriteError"}},sve=/^[A-Za-z_][A-Za-z0-9_-]*$/,ave=new Set(["true","false","null"]);pD=e=>e===null?"null":JSON.stringify(e),mJ=e=>Array.isArray(e)?"[]":"{}";pve=/^([A-Za-z][A-Za-z0-9]*)-([0-9]+)$/;IJ=["chant workspace records new [<kind file or declared kind>] --from <file|-> [--prefix <prefix>] [--by <name>] [--sign [<key file>]] [--dry-run]","chant workspace records amend <id> [--kind <kind file>] --set <file|-> [--expect <digest>] [--sign [<key file>]] [--dry-run]","chant workspace records review <id> [--kind <kind file>] --verdict agree|dissent|abstain --by <principal> [--note <text>] [--session <id>] [--expect <digest>] [--sign [<key file>]] [--dry-run]","chant workspace records close <session id> [--kind <session kind file>] [--expect <digest>] [--dry-run]"].join(`
|
|
201
|
+
`)});var bD={};_e(bD,{ANSWERS_LEDGER_DIR:()=>jJ,answersLedgerDir:()=>MJ,readLedgerAnswers:()=>Sg,refreshLedger:()=>Ak,withLedgerAnswers:()=>Eg,writeLedgerAnswer:()=>yD});import{basename as vve,dirname as NJ}from"node:path";function MJ(e){return`${jJ}/${e.replace(/[^A-Za-z0-9._-]/g,"_")}`}function kve(e,t){return e==="."?t:`${e}/${t}`}async function Sg(e){let t=NJ(e.file),n=MJ(e.name),i={cwd:t,dir:n,dirRel:e.dirRel,byPath:new Map};try{let r=(await Bc(n,{cwd:t})).filter(s=>s.endsWith(".md"));if(r.length===0)return i;let o=await oi(n,{cwd:t});for(let s of r){let a=await $r(n,s,{cwd:t}),l=a?await fn(a,{cwd:t}):null;if(a===null||l===null)continue;let c=kve(e.dirRel,s);i.byPath.set(c,{path:c,ledger:`${LJ}:${o}/${s}`,text:l,sha:a})}}catch{}return i}function Eg(e,t){let n=e;for(let i of t.byPath.values())n=$g(n,i.path,i.text);return n}async function Ak(e){await wa({cwd:NJ(e)}).catch(()=>{})}async function yD(e,t,n,i,r){let o=vve(t);await An(e.dir,o,n,i,{cwd:e.cwd,expectPriorPathSha:r});let s=await Gc({cwd:e.cwd}).catch(()=>!1);return{ledger:`${LJ}:${await oi(e.dir,{cwd:e.cwd})}/${o}`,pushed:s}}var jJ,LJ,Ag=v(()=>{"use strict";$t();vg();jJ="_answers",LJ="chant/lifecycle"});import{randomUUID as xve}from"node:crypto";function Pk(e,t=""){return`${wD}${t}${e}`}function $ve(e,t=""){return`${vD}${t}${e}`}async function xD(e,t){let{prefix:n}=await ii(t?.cwd??process.cwd());return{ref:Pk(e,n),trackingRef:$ve(e,n)}}function FJ(e){return e?`${e.acquiredAt} ${e.expiresAt}`:""}function Rve(e,t){return new Date(e.expiresAt).getTime()<=t.getTime()}function Sve(e){try{let t=JSON.parse(e);return typeof t.op=="string"&&typeof t.holder=="string"&&typeof t.token=="string"&&typeof t.acquiredAt=="string"&&typeof t.expiresAt=="string"?t:void 0}catch{return}}async function BJ(e,t){let n=await Wc(e,t);return{sha:n,record:n?Sve(await fn(n,t)??""):void 0}}async function za(e,t){let{ref:n,trackingRef:i}=await xD(e,t);if(await sv(n,i,t).catch(()=>"failed")==="missing"){let u=await Wc(i,t);u&&await ld(i,u,t).catch(()=>{})}let{sha:o,record:s}=await BJ(n,t),{sha:a,record:l}=await BJ(i,t),c=FJ(l)>FJ(s)?l:s;return{sha:o,record:c,remoteSha:a}}async function Pg(e,t,n){let i=Date.now()+(n?.lockWaitMs??0);for(;;)try{return await Eve(e,t,n)}catch(r){if(!(r instanceof Mc)||Date.now()>=i)throw r;await new Promise(o=>setTimeout(o,20+Math.floor(Math.random()*60)))}}async function Eve(e,t,n){let i=n?.ttlMs??kD,r=n?.now?.()??new Date,o=n?.mode??"acquire",{sha:s,record:a,remoteSha:l}=await za(e,n),c=!a||Rve(a,r),u=a?.holder===t;if(o==="renew"){if(!a||c||!u)return{acquired:!1,reason:a&&!c?"held":"not-held",...a?{heldBy:a}:{}};if(n?.token!==void 0&&a.token!==n.token)return{acquired:!1,reason:"token-mismatch",heldBy:a}}else if(a&&!c&&(!u||o==="claim"))return{acquired:!1,heldBy:a,reason:"held"};let d=!!a&&u&&!c,p={op:e,holder:t,token:d?a.token:xve(),acquiredAt:d?a.acquiredAt:r.toISOString(),expiresAt:new Date(r.getTime()+i).toISOString()},{ref:f,trackingRef:g}=await xD(e,n),h=await U0(JSON.stringify(p),n);try{await cd(f,h,s,n)}catch(w){if(w instanceof Vt)return{acquired:!1,heldBy:(await za(e,n)).record,reason:"race"};throw w}let b=await vm(f,{...n,expect:l}).catch(()=>"rejected");if(b==="pushed")await cd(g,h,l,n).catch(()=>{});else if(b==="rejected"&&n?.requirePush){await(s===null?ld(f,h,n):cd(f,s,h,n)).catch(()=>{});let w=await za(e,n),x=w.record&&w.record.token!==p.token?w.record:void 0;return{acquired:!1,reason:"push-rejected",...x?{heldBy:x}:{}}}return{acquired:!0,lease:p}}async function Ok(e,t,n,i){let{sha:r,record:o,remoteSha:s}=await za(e,i);if(!o||o.holder!==t||o.token!==n)return!1;let{ref:a,trackingRef:l}=await xD(e,i);if(r)try{await ld(a,r,i)}catch{return!1}let c=await vm(a,{...i,expect:s}).catch(()=>"rejected");return c==="pushed"&&s&&await ld(l,s,i).catch(()=>{}),r!==null||c==="pushed"}var wD,vD,kD,Yd=v(()=>{"use strict";$t();ya();wD="refs/chant/lease/",vD="refs/chant/lease-remote/",kD=5*6e4});var ZJ={};_e(ZJ,{ATTEMPT_OUTCOMES:()=>zJ,DEFAULT_WORK_LEASE_TTL_MS:()=>_k,KEPT_REF_PREFIX:()=>SD,LEASES_DIR:()=>Cg,WORK_ITEM_ID_PATTERN:()=>fg,WORK_LEASE_KEY_PREFIX:()=>Ck,WORK_LEASE_OUTCOMES:()=>RD,WORK_LEASE_REFUSALS:()=>_ve,activeWorkLeases:()=>Nve,claimWorkLease:()=>HJ,isWorkItemId:()=>GT,isWorkLeaseOutcome:()=>Ik,keptAttemptPrefix:()=>ED,keptAttemptRef:()=>UJ,leaseHistoryPath:()=>WJ,listKeptAttempts:()=>Cve,listWorkLeases:()=>Nk,outcomeCountsAsAttempt:()=>Ove,parseLeaseHistory:()=>Dk,readLeaseHistory:()=>Tve,releaseWorkLease:()=>KJ,renewWorkLease:()=>VJ,workItemIdProblem:()=>Wd,workLeaseKey:()=>Ig,workLeaseRef:()=>$D});import{dirname as Ave}from"node:path";function Ig(e){return`${Ck}${e}`}function $D(e,t=""){return Pk(Ig(e),t)}function WJ(e,t=""){return`${t}${Cg}/${e}.jsonl`}function Ik(e){return typeof e=="string"&&RD.includes(e)}function Ove(e){return Ik(e)?zJ.includes(e):!0}function UJ(e,t,n=[]){return`${ED(e,n)}${t}`}function ED(e,t=[]){return`${SD}${t.length?`${t.join("/")}/`:""}${e}/`}async function Cve(e,t){let n=ED(e,t.members??[]),i=await ot().spawn(["git","for-each-ref","--format=%(refname) %(objectname)",n],{cwd:t.cwd});return i.exitCode!==0?[]:i.stdout.split(`
|
|
202
|
+
`).filter(Boolean).map(r=>{let[o,s]=r.split(" ");return{token:o.slice(n.length),ref:o,commit:s}}).filter(r=>r.token!==""&&!r.token.includes("/")).sort((r,o)=>r.ref<o.ref?-1:r.ref>o.ref?1:0)}function _g(e,t){return{item:e,holder:t.holder,token:t.token,acquiredAt:t.acquiredAt,expiresAt:t.expiresAt}}function Tk(e){let t=Wd(e);if(t)throw new Error(t)}function Og(e,t,n){let i=n?`${n.holder} until ${n.expiresAt}`:void 0;switch(t){case"lease-held":return`${e} is held by ${i}`;case"lease-not-held":return`${e} is not held${n?` by the caller: ${i}`:""}; claim it again`;case"lease-token-mismatch":return`${e} is held with another token (${n?.token}) by ${i}`;case"lease-race":return`${e} changed while it was being written${i?`: it is held by ${i}`:""}`;case"lease-push-rejected":return`the remote refused the lease on ${e}${i?`: it is held there by ${i}`:", or could not be reached"}`}}async function HJ(e,t,n){Tk(e);let i=await Pg(Ig(e),t,{cwd:n.cwd,ttlMs:n.ttlMs??_k,now:n.now,mode:"claim",requirePush:!0,lockWaitMs:GJ});return qJ(e,"claim",t,i,n)}async function VJ(e,t,n){Tk(e);let i=await Pg(Ig(e),t,{cwd:n.cwd,ttlMs:n.ttlMs??_k,now:n.now,mode:"renew",token:n.token,requirePush:!0,lockWaitMs:GJ});return qJ(e,"renew",t,i,n)}async function qJ(e,t,n,i,r){if(!i.acquired||!i.lease){let l=Ive[i.reason??"race"],c=i.heldBy?_g(e,i.heldBy):void 0;return{ok:!1,reason:l,message:Og(e,l,c),...c?{heldBy:c}:{}}}let o=_g(e,i.lease),s=r.now?.()??new Date,a=await JJ({version:1,event:t,item:e,holder:n,by:n,token:o.token,acquiredAt:o.acquiredAt,expiresAt:o.expiresAt,timestamp:s.toISOString(),...r.note?{note:r.note}:{}},r);return{ok:!0,lease:o,history:a}}async function KJ(e,t,n){if(Tk(e),n.outcome!==void 0&&!Ik(n.outcome))throw new Error(`${JSON.stringify(n.outcome)} is not a work lease outcome: use one of ${RD.join(", ")}`);let i=Ig(e),r=n.now?.()??new Date,{record:o}=await za(i,{cwd:n.cwd});if(!o)return{ok:!1,reason:"lease-not-held",message:Og(e,"lease-not-held",void 0)};let s=_g(e,o);if(new Date(o.expiresAt).getTime()>r.getTime()&&o.holder!==t)return{ok:!1,reason:"lease-held",message:Og(e,"lease-held",s),heldBy:s};if(n.token!==void 0&&o.token!==n.token)return{ok:!1,reason:"lease-token-mismatch",message:Og(e,"lease-token-mismatch",s),heldBy:s};if(!await Ok(i,o.holder,o.token,{cwd:n.cwd})){let c=(await za(i,{cwd:n.cwd})).record,u=c?_g(e,c):void 0;return{ok:!1,reason:"lease-race",message:Og(e,"lease-race",u),...u?{heldBy:u}:{}}}let l=await JJ({version:1,event:"release",item:e,holder:o.holder,by:t,token:o.token,acquiredAt:o.acquiredAt,expiresAt:o.expiresAt,timestamp:r.toISOString(),...n.outcome?{outcome:n.outcome}:{},...n.note?{note:n.note}:{}},n);return{ok:!0,lease:s,history:l}}async function JJ(e,t){await wa(t).catch(()=>{});let n=`${e.item}.jsonl`,i=JSON.stringify(e,pn),r,o;for(let l=1;l<=Pve&&r===void 0;l++)try{let c=await $r(Cg,n,t),u=c?await fn(c,t):null,d=`${u?`${u.replace(/\n$/,"")}
|
|
203
|
+
`:""}${i}
|
|
204
|
+
`;r=await An(Cg,n,d,`Work lease ${e.event}: ${e.item} (${e.holder})`,{...t,expectPriorPathSha:c})}catch(c){if(!(c instanceof Vt))throw c;o=c}if(r===void 0)throw o;let s=await Gc(t).catch(()=>!1),{prefix:a}=await ii(t.cwd);return{path:WJ(e.item,a),commit:r,pushed:s}}function Dk(e){let t=[],n=0;for(let i of e.split(`
|
|
205
|
+
`).map(r=>r.trim()).filter(Boolean))try{let r=JSON.parse(i);r.version===1&&(r.event==="claim"||r.event==="renew"||r.event==="release")&&[r.item,r.holder,r.by,r.token,r.acquiredAt,r.expiresAt,r.timestamp].every(s=>typeof s=="string")?t.push(r):n++}catch{n++}return{records:t,malformed:n}}async function Tve(e,t){Tk(e);let n=await rn(Cg,`${e}.jsonl`,t);return n?Dk(n):{records:[],malformed:0}}function Dve(e){try{let t=JSON.parse(e);return typeof t.holder=="string"&&typeof t.token=="string"&&typeof t.acquiredAt=="string"&&typeof t.expiresAt=="string"?t:void 0}catch{return}}async function Nk(e){let t=ot(),n=(e.now??new Date).getTime(),i=`${wD}${e.memberPrefix}${Ck}`,r=`${vD}${e.memberPrefix}${Ck}`,o=await t.spawn(["git","for-each-ref","--format=%(refname) %(objectname)",i,r],{cwd:e.cwd});if(o.exitCode!==0)return[];let s=new Map;for(let a of o.stdout.split(`
|
|
206
|
+
`).filter(Boolean)){let[l,c]=a.split(" "),u=l.startsWith(i)?l.slice(i.length):l.slice(r.length);if(!fg.test(u))continue;let d=Dve(await fn(c,e)??"");if(!d)continue;let p=s.get(u),f=g=>`${g.acquiredAt} ${g.expiresAt}`;(!p||f(d)>f(p)||f(d)===f(p)&&l.startsWith(i))&&s.set(u,d)}return[...s.entries()].sort(([a],[l])=>a<l?-1:a>l?1:0).map(([a,l])=>({..._g(a,l),state:new Date(l.expiresAt).getTime()>n?"active":"expired",ref:$D(a,e.memberPrefix)}))}async function Nve(e,t=new Date){let n=Ave(e);try{let{prefix:i}=await ii(n),r=await Nk({cwd:n,memberPrefix:i,now:t});return new Map(r.filter(o=>o.state==="active").map(o=>[o.item,{holder:o.holder,token:o.token,acquiredAt:o.acquiredAt,expiresAt:o.expiresAt}]))}catch{return new Map}}var Ck,Cg,_k,GJ,Pve,RD,zJ,SD,_ve,Ive,hl=v(()=>{"use strict";Wt();no();Yd();$t();ya();WT();Ck="work/",Cg="_leases",_k=10*6e4,GJ=2e3,Pve=5;RD=["done","not_done","abandoned","gated","waiting","dropped","redraft","ask"],zJ=["not_done","abandoned"];SD="refs/chant/kept/";_ve=["lease-held","lease-not-held","lease-token-mismatch","lease-race","lease-push-rejected"];Ive={held:"lease-held","not-held":"lease-not-held","token-mismatch":"lease-token-mismatch",race:"lease-race","push-rejected":"lease-push-rejected"}});function Fve(e){return jve.find(t=>t.pattern.test(e))}function YJ(e,t){let n=t?.get(e);if(n)return n.handWritten?{class:"owned"}:{class:"generated",command:n.command};if(Mve.some(r=>e===r||e.startsWith(`${r}/`)))return{class:"ignored"};let i=Fve(e);return i?{class:"generated",command:i.command}:Lve.includes(e)?{class:"seed"}:{class:"owned"}}function Bve(e,t){let n=new Map;for(let i of e.members)for(let r of i.generated){let o=i.dir==="."?r.path:`${i.dir}/${r.path}`;xr(o,t)&&n.set(t==="."?o:o.slice(t.length+1),{command:r.generator,handWritten:r.handWritten!==null})}return n}function AD(e,t){let i=e.members.find(o=>o.name===Fr(t,e.members))?.dir??".",r=i==="."?t:t.slice(i.length+1);return YJ(r,Bve(e,i)).class==="generated"}var jve,Lve,Mve,PD=v(()=>{"use strict";Si();_t();po();Zt();jve=[{glob:"skills/*/SKILL.md",pattern:/^skills\/[^/]+\/SKILL\.md$/,command:"chant update"}],Lve=[".mcp.json"],Mve=[".chant/types"]});import{createHash as Gve}from"node:crypto";function QJ(e){return`sha256:${Gve("sha256").update(e).digest("hex")}`}var Wve,OD,zve,Uve,XJ,Hve,Vve,qve,Kve,Jve,Zve,OVe,Rs,eZ=v(()=>{"use strict";Ln();_t();PD();Wve=1,OD=m.string().regex(/^sha256:[0-9a-f]{64}$/,"expected sha256:<64 hex>"),zve=["owned","generated","seed"],Uve=m.object({class:m.enum(zve),sha256:OD,command:m.string().min(1).optional()}).strict(),XJ=m.discriminatedUnion("type",[m.object({type:m.literal("git"),repo:m.string().min(1),url:m.string().min(1),path:m.string().optional()}).strict(),m.object({type:m.literal("dir"),path:m.string().min(1),member:m.string().optional()}).strict(),m.object({type:m.literal("lexicon"),lexicon:m.string().min(1),template:m.string().min(1)}).strict(),m.object({type:m.literal("local"),path:m.string().min(1)}).strict(),m.object({type:m.literal("archive"),url:m.string().url(),subpath:m.string().optional()}).strict()]),Hve=m.object({digest:OD,commit:m.string().regex(/^[0-9a-f]{40,64}$/).optional(),tree:m.string().regex(/^[0-9a-f]{40,64}$/).optional(),package:m.string().optional(),version:m.string().nullable().optional(),chant:m.string().optional()}).strict(),Vve=["changed-locally","deleted-locally","exists-locally","removed-upstream"],qve=m.object({path:m.string().min(1),reason:m.enum(Vve),upstream:OD.nullable()}).strict(),Kve=m.string().regex(/^[0-9a-f]{40,64}$/),Jve=m.object({by:m.enum(["files","lineage"]),commits:m.object({to:Kve}).strict(),match:m.object({files:m.number().int().nonnegative(),identical:m.number().int().nonnegative(),edited:m.number().int().nonnegative(),missing:m.number().int().nonnegative()}).strict(),index:m.enum(["computed","cache"]),previous:m.object({template:m.string().min(1),source:XJ}).strict().optional()}).strict(),Zve=m.object({kind:m.enum(["template","vendor"]),name:m.string().min(1).optional(),template:m.string().min(1),source:XJ,ref:m.string().optional(),address:Hve.nullable(),parameters:m.record(m.string(),m.unknown()),hostBound:m.record(m.string(),m.array(m.string().min(1))).optional(),repinned:m.array(m.object({record:m.string().min(1),paths:m.array(m.string().min(1))}).strict()).optional(),migrations:m.array(m.string()),files:m.record(m.string(),Uve),manualSteps:m.array(qve),adoption:Jve.optional()}).strict(),OVe=m.object({lockVersion:m.literal(Wve),scopes:m.record(m.string(),Zve)}).strict();Rs=class extends Error{constructor(){super(...arguments);this.name="LockError"}}});var cZ={};_e(cZ,{RETURNS_DIR:()=>Tg,admitReturn:()=>uke,buildOrigin:()=>ike,gitObjectId:()=>Lk,originSigners:()=>ske,parseReturn:()=>sZ,parseTree:()=>ID,readReturns:()=>cke,renderReturn:()=>aZ,returnedProvenance:()=>lke,verifyOrigin:()=>TD,writeReturn:()=>ake});import{execFileSync as Yve}from"node:child_process";import{createHash as Xve}from"node:crypto";import{existsSync as Qve,mkdirSync as nZ,readFileSync as eke,writeFileSync as rZ}from"node:fs";import{dirname as tke,join as _D}from"node:path";function Lk(e,t,n){return Xve(n).update(`${e} ${t.length}\0`).update(t).digest("hex")}function ID(e,t){let n=[],i=0;for(;i<e.length;){let r=e.indexOf(32,i),o=e.indexOf(0,r);if(r<0||o<0||o+1+t>e.length)throw new Error("malformed tree object");n.push({mode:e.subarray(i,r).toString("latin1"),name:e.subarray(r+1,o).toString("utf-8"),id:e.subarray(o+1,o+1+t).toString("hex")}),i=o+1+t}return n}function CD(e,t){return Yve("git",t,{cwd:e,maxBuffer:256*1024*1024,stdio:["ignore","pipe","pipe"]})}function ike(e,t,n){let i;try{i=CD(e,["log","-1","--format=%H","HEAD","--",t]).toString("utf-8").trim()}catch{return}if(!i)return;let r=CD(e,["cat-file","commit",i]),o={commit:i,raw:r.toString("base64"),trees:[]},s=/^tree ([0-9a-f]+)$/m.exec(r.toString("latin1"))?.[1],a=t.split("/");for(let l=0;l<a.length&&s;l++){let c=CD(e,["cat-file","tree",s]);o.trees.push(c.toString("base64")),s=ID(c,s.length/2).find(u=>u.name===a[l])?.id}return TD(o,t,n).ok?o:void 0}function TD(e,t,n){let i=e.commit.length===64?"sha256":"sha1",r=Buffer.from(e.raw,"base64");if(Lk("commit",r,i)!==e.commit)return{ok:!1,reason:`the commit object does not hash to ${e.commit.slice(0,12)}`};let o=/^tree ([0-9a-f]+)$/m.exec(r.toString("latin1"))?.[1],s=t.split("/");if(e.trees.length!==s.length)return{ok:!1,reason:`the proof has ${e.trees.length} tree(s) for a path ${s.length} deep`};for(let a=0;a<s.length;a++){let l=Buffer.from(e.trees[a],"base64");if(!o||Lk("tree",l,i)!==o)return{ok:!1,reason:`the tree for ${s.slice(0,a).join("/")||"the root"} does not hash to its id`};let c;try{c=ID(l,o.length/2)}catch{return{ok:!1,reason:"a tree object in the proof is malformed"}}o=c.find(u=>u.name===s[a])?.id}return!o||Lk("blob",n,i)!==o?{ok:!1,reason:`the commit holds other bytes at ${t}`}:{ok:!0}}function oke(e){return/^committer [^<]*<([^>]+)>/m.exec(e.toString("utf-8"))?.[1]}function oZ(e){return e.commit.length===64?"gpgsig-sha256":"gpgsig"}function ske(e){let t=new Map,n=new Set;for(let i of e){if(n.has(i.commit))continue;n.add(i.commit);let r=Buffer.from(i.raw,"base64"),{payload:o,signature:s}=Gm(r,oZ(i));if(!s)continue;let a=KI(s);if(!a)continue;let l=t.get(a);if(l){l.commits.push(i.commit);continue}let c=Iv(o,s,"git");c!==!1&&t.set(a,{key:a,fingerprint:c??"",principal:oke(r)??"unknown",commits:[i.commit]})}return[...t.values()].sort((i,r)=>i.key.localeCompare(r.key))}function sZ(e,t){let n;try{n=JSON.parse(e)}catch(r){throw new Rs(`${t} is not JSON: ${r instanceof Error?r.message:String(r)}`)}let i=iZ.safeParse(n);if(!i.success)throw new Rs(`${t} is not a return record: ${i.error.issues.map(r=>`${r.path.join(".")||"/"}: ${r.message}`).join("; ")}`);return i.data}function aZ(e){let t={};for(let n of Object.keys(e.paths).sort())t[n]=e.paths[n];return JSON.stringify(iZ.parse({...e,paths:t,removed:[...e.removed].sort(),hostValues:[...e.hostValues].sort()}),null,2)+`
|
|
207
|
+
`}function ake(e,t){let n=`${Tg}/${t.id}.json`;return nZ(_D(e,Tg),{recursive:!0}),rZ(_D(e,n),aZ(t)),n}function cke(e){let t=[],n=[];for(let i of(e.list(Tg)??[]).filter(r=>r.type==="file"&&r.name.endsWith(".json")).sort((r,o)=>r.name.localeCompare(o.name))){let r=`${Tg}/${i.name}`;try{let o=sZ(e.read(r),r);if(`${o.id}.json`!==i.name)throw new Rs(`${r} holds return ${o.id}`);t.push(o)}catch(o){if(!(o instanceof Rs))throw o;n.push(o.message)}}return{returns:t,problems:n}}function lke(e,t,n,i,r,o){let s=n.paths[i];if(!s||s.sha256!==QJ(r))return;let a={id:n.id,importedIn:o.commit};if(!s.origin)return;let l=TD(s.origin,i,r);if(!l.ok)return{level:"unattested",commit:o.commit,reason:`returned in ${n.id}, and its origin does not check: ${l.reason}`,returned:{...a,commit:s.origin.commit}};let c=Buffer.from(s.origin.raw,"base64"),u=_v(e,n.id),d=JI({repo:"",policy:u},c,t),p=`returned in ${n.id} from commit ${s.origin.commit.slice(0,12)}`,f={commit:o.commit,attestor:d.attestor,returned:{...a,commit:s.origin.commit}};if(d.level==="attested"){let g=(e.admitted[n.id]??[]).some(h=>h.principal===d.principal)&&!e.signers.some(h=>h.principal===d.principal);return{...f,level:"attested",...d.principal?{principal:d.principal}:{},...d.key?{key:d.key}:{},reason:`${p}, ${d.reason}${g?`, a signer admitted for ${n.id} at base`:""}`}}if(d.level==="unattested"){let{payload:g,signature:h}=Gm(c,oZ(s.origin)),b=h?.startsWith("-----BEGIN SSH SIGNATURE-----")?Iv(g,h,"git"):!1;if(b)return{...f,level:"attested-unverifiable-here",key:b,reason:`${p}, signed with ${b}, a key neither the signers nor an admission at base lists; it reads as attested once an admin admits the signer (chant workspace admit ${n.id})`}}return{...f,level:d.level,...d.key?{key:d.key}:{},reason:`${p}: ${d.reason}`}}function uke(e,t,n={}){if(t.signers.length===0)throw new Rs(`return ${t.id} names no signer: none of its origin commits carries an ssh signature`);let i=_D(e,nr),r={schema:1};if(Qve(i))try{r=JSON.parse(eke(i,"utf-8"))}catch(l){throw new Rs(`${nr} is not valid JSON, so the admission cannot be added to it: ${l instanceof Error?l.message:String(l)}`)}let o=Array.isArray(r.admitted)?r.admitted:[],s=new Set(o.filter(l=>l.return===t.id).flatMap(l=>(l.signers??[]).map(c=>c.key))),a=t.signers.filter(l=>!s.has(l.key)).map(l=>({principal:l.principal,key:l.key}));return a.length>0&&!n.dryRun&&(r.admitted=[...o,{return:t.id,signers:a,...n.note?{note:n.note}:{}}],nZ(tke(i),{recursive:!0}),rZ(i,JSON.stringify(r,null,2)+`
|
|
208
|
+
`)),{id:t.id,path:nr,added:a,written:a.length>0&&!n.dryRun}}var Tg,nke,jk,tZ,rke,iZ,lZ=v(()=>{"use strict";Ln();eZ();Dd();fs();Wm();Tg=".chant/returns",nke=m.string().regex(/^sha256:[0-9a-f]{64}$/),jk=m.string().regex(/^[0-9a-f]{40}([0-9a-f]{24})?$/),tZ=m.string().regex(/^[A-Za-z0-9+/]*={0,2}$/),rke=m.object({commit:jk,raw:tZ,trees:m.array(tZ).min(1)}).strict(),iZ=m.object({schema:m.literal(1),id:m.string().regex(/^ret-[0-9a-f]{12}$/),export:m.object({id:m.string().min(1),workspace:m.string().min(1),revision:jk.nullable()}).strict(),head:jk.nullable(),paths:m.record(m.string(),m.object({sha256:nke,origin:rke.optional()}).strict()),removed:m.array(m.string()),hostValues:m.array(m.string()),signers:m.array(m.object({key:m.string().min(1),fingerprint:m.string(),principal:m.string().min(1),commits:m.array(jk)}).strict())}).strict()});function Dg(e){return e.normalize("NFKC").toLowerCase().replace(/[^\p{L}\p{N}]/gu,"")}function Ng(e,t){if(e===t)return e===""?void 0:"exact";let n=Dg(e);return n!==""&&n===Dg(t)?"folded":void 0}var DD=v(()=>{"use strict"});function pke(e,t,n){if(n.member===t.name)return`member ${t.name} links to itself; a link joins two members`;let i=e.entries.find(r=>r.name===n.member);if(!i)return`member ${t.name} links to ${n.member}, which is not a member of this workspace`;if(i.type==="group")return`member ${t.name} links to ${n.member}, which is an example group; a group has no links`}function fke(e,t){let n=Dg(e);return[...new Set(t.filter(i=>i.name!==e&&Dg(i.name)===n).map(i=>i.name))].sort(Xd)}function ND(e,t,n){let i=[],r=new Map;for(let s of e.members)for(let a of s.links){let l=a.kind??dZ,c={consumer:s.name,producer:a.member,output:a.output,kind:l,origin:"declared",label:"exact",input:null,resolves:"source",status:"resolved",reason:null,pointer:a.pointer,...a.protocol?{protocol:a.protocol}:{}};i.push(c);let u=pke(e,s,a);if(u){c.status="invalid",c.reason=u;continue}if((r.get(s.name)??r.set(s.name,new Set).get(s.name)).add(`${a.member}\0${a.output}`),!uZ.includes(l)){c.status="invalid",c.reason=`the link kind ${l} is not one chant knows; known link kinds: ${uZ.join(", ")}`;continue}if(l===dke){mke(c,n);continue}if(a.protocol){c.status="invalid",c.reason=`protocol applies to telemetry links; this link has kind ${l}`;continue}let d=t.get(a.member),p=d?.outputs.find(f=>f.name===a.output);if(p){p.node&&(c.to=p.node);continue}if(!d)c.status="unresolved",c.reason=`the outputs of ${a.member} were not read`;else if(d.exposesNone)c.status="missing",c.reason=d.why??`${a.member} exposes no outputs`;else if(!d.complete)c.status="unresolved",c.reason=`${a.output} was not found in ${a.member}, whose outputs could not all be read in source${d.why?` (${d.why})`:""}`;else{let f=fke(a.output,d.outputs),g=d.outputs.map(h=>h.name);c.status="missing",c.reason=`${a.member} has no output ${a.output}`+(f.length?`; did you mean ${f.join(" or ")}? Links match exactly`:"")+(g.length?`; its outputs: ${[...new Set(g)].sort(Xd).join(", ")}`:"; it exposes no outputs")}}let o=[];for(let s of e.members){let a=t.get(s.name);if(!a)continue;let l=r.get(s.name)??new Set;for(let c of a.inputs){let u=[];for(let p of e.members)if(p.name!==s.name)for(let f of t.get(p.name)?.outputs??[]){let g=Ng(c.name,f.name);g&&(u.some(h=>h.producer===p.name&&h.output===f.name)||u.push({producer:p.name,output:f.name,label:g,...f.node?{to:f.node}:{}}))}if(u.length===0||u.some(p=>l.has(`${p.producer}\0${p.output}`)))continue;let d={consumer:s.name,kind:dZ,origin:"inferred:joinKey",resolves:"source"};if(u.length===1){let p=u[0];o.push({...d,status:"resolved",reason:null,producer:p.producer,output:p.output,label:p.label,input:c.name,...c.node?{from:c.node}:{},...p.to?{to:p.to}:{}})}else{u.sort((f,g)=>Xd(f.producer,g.producer)||Xd(f.output,g.output));let p=new Set(u.map(f=>f.producer));o.push({...d,status:"ambiguous",reason:p.size>1?`parameter ${c.name} of ${s.name} matches outputs of ${[...p].join(" and ")}`:`parameter ${c.name} of ${s.name} matches ${u.map(f=>f.output).join(" and ")} of ${u[0].producer}`,input:c.name,...c.node?{from:c.node}:{},candidates:u})}}}return o.sort((s,a)=>Xd(s.consumer,a.consumer)||Xd(s.input??"",a.input??"")),[...i,...o]}function mke(e,t){if(!t){e.status="unresolved",e.reason=`the collector of ${e.producer} is read by chant workspace graph; chant workspace check reads source and runs no member`;return}let n=t.collectors.get(e.producer);if(!n){t.composed.has(e.producer)?(e.status="missing",e.reason=`${e.producer} declares no collector: its build reports no collector pipelines or components`):(e.status="unresolved",e.reason=`the collector of ${e.producer} was not read: ${e.producer} was not composed`);return}let i=n.pipelines.find(l=>l.id===e.output),r=i?void 0:n.exporters.find(l=>l.id===e.output);if(!i&&!r){e.status="missing",e.reason=`${e.producer}'s collector has no pipeline or exporter ${e.output}; pipelines: ${n.pipelines.map(l=>l.id).join(", ")||"none"}; exporters: ${n.exporters.map(l=>l.id).join(", ")||"none"}`;return}if(e.target=i?"pipeline":"exporter",!e.protocol)return;let o=i?i.receivers:[r.id],s=[...new Set(n.components.filter(l=>o.includes(l.id)).flatMap(l=>l.protocols))],a=i?`the receivers of pipeline ${e.output}`:`exporter ${e.output}`;s.length===0?(e.status="unresolved",e.reason=`${a} state no protocols, so ${e.protocol} could not be confirmed`):s.includes(e.protocol)||(e.status="invalid",e.reason=`${a} speak ${s.join(", ")}, and the link sends ${e.protocol}`)}function jD(e,t){let n=t.outputs;if(n.from==="none")return{member:e.name,outputs:[],inputs:[],complete:!0,why:`${e.name} is kind ${e.kind}, which exposes no outputs as link targets`,exposesNone:!0};if(n.from==="declared"){let i=[...new Set([...n.names,...e.outputs??[]])];return{member:e.name,outputs:i.map(r=>({name:r})),inputs:[],complete:!0,why:null,exposesNone:!1}}}function gke(e){let t=new Map;for(let n of e.composed)t.set(n,{member:n,outputs:e.exports.filter(i=>i.member===n).map(i=>({name:i.name,...i.node?{node:i.node}:{}})),inputs:e.imports.filter(i=>i.member===n).map(i=>({name:i.name,node:i.node})),complete:!0,why:null,exposesNone:!1});return t}function pZ(e,t,n){let i=gke(t);for(let o of e.members){let s=n?.get(o.kind);if(i.has(o.name)||!s)continue;let a=jD(o,s);a&&i.set(o.name,a)}let r={collectors:new Map((t.collectors??[]).map(o=>[o.member,o])),composed:new Set(t.composed)};return ND(e,i,r).map(o=>{if(o.status==="ambiguous"||o.origin!=="declared")return o;let{pointer:s,...a}=o;return a})}var uZ,dZ,dke,Xd,jg=v(()=>{"use strict";DD();uZ=["output","telemetry"],dZ="output",dke="telemetry",Xd=(e,t)=>e<t?-1:e>t?1:0});var Ke=ie((zVe,LD)=>{if(typeof LD=="object")throw new Error("typescript is not part of chant's wave-job runtime (wave-runtime.mjs): this path needs the full @intentius/chant CLI");LD.exports={}});function bke(e){return!/\.(m?ts|tsx)$/.test(e)||e.endsWith(".d.ts")||/\.(test|spec)\.m?tsx?$/.test(e)?!1:!e.startsWith("chant.config.")}function wke(e,t,n){let i=[],r=o=>{for(let s of e.list(o)??[]){let a=ze(o,s.name);if(s.type==="dir"){if(ns(s.name)||hke.has(s.name)||n.has(a))continue;r(a)}else bke(s.name)&&i.push(a)}};return r(t),i.sort()}function vke(e){let t=new Map,n=new Set;for(let i of e.statements){if(!De.isImportDeclaration(i)||!De.isStringLiteral(i.moduleSpecifier))continue;let r=i.moduleSpecifier.text;if(!yke.test(r)||r.includes("/components"))continue;let o=i.importClause?.namedBindings;if(o)if(De.isNamespaceImport(o))n.add(o.name.text);else for(let s of o.elements)t.set(s.name.text,(s.propertyName??s.name).text)}return{names:t,namespaces:n}}function MD(e,t){if(De.isIdentifier(e))return t.names.get(e.text);if(De.isPropertyAccessExpression(e)&&De.isIdentifier(e.expression)&&t.namespaces.has(e.expression.text))return e.name.text}function kke(e){let t=new Map;for(let n of e.statements)if(!(!De.isVariableStatement(n)||(n.declarationList.flags&De.NodeFlags.Const)===0))for(let i of n.declarationList.declarations)De.isIdentifier(i.name)&&i.initializer&&t.set(i.name.text,i.initializer);return t}function FD(e,t,n=new Set){if(De.isStringLiteral(e)||De.isNoSubstitutionTemplateLiteral(e))return e.text;if(De.isParenthesizedExpression(e)||De.isAsExpression(e)||De.isSatisfiesExpression(e))return FD(e.expression,t,n);if(De.isIdentifier(e)&&!n.has(e.text)){let i=t.get(e.text);if(i)return FD(i,t,new Set([...n,e.text]))}}function xke(e){return(De.canHaveModifiers(e)?De.getModifiers(e):void 0)?.some(t=>t.kind===De.SyntaxKind.ExportKeyword)??!1}function $ke(e,t,n){let i=De.createSourceFile(e,t,De.ScriptTarget.Latest,!1),r=vke(i);if(r.names.size===0&&r.namespaces.size===0)return;let o=kke(i),s=l=>i.getLineAndCharacterOfPosition(l.getStart(i)).line+1;for(let l of i.statements)if(!(!De.isVariableStatement(l)||!xke(l)))for(let c of l.declarationList.declarations){if(!De.isIdentifier(c.name)||!c.initializer)continue;let u=c.initializer;if(De.isNewExpression(u)&&MD(u.expression,r)==="Parameter")n.inputs.push({name:c.name.text,file:e,line:s(c)});else if(De.isCallExpression(u)&&MD(u.expression,r)==="stackOutput"){let d=u.arguments[0];d&&!De.isStringLiteralLike(d)&&n.outputs.push({name:c.name.text,file:e,line:s(c)})}}let a=l=>{if(De.isCallExpression(l)&&MD(l.expression,r)==="output"&&l.arguments.length>=2){let c=FD(l.arguments[1],o);c!==void 0?n.outputs.push({name:c,file:e,line:s(l)}):n.gaps.push(`${e}:${s(l)}: an output whose name is not a string literal`)}De.forEachChild(l,a)};a(i)}function Rke(e,t,n=new Set){let i={outputs:[],inputs:[],gaps:[]};for(let r of wke(e,t,n)){let o;try{o=e.read(r)}catch{i.gaps.push(`${r}: the file could not be read`);continue}$ke(r,o,i)}return i}function mZ(e,t,n,i){let r=new Map;for(let o of e.members){let s=i.get(o.kind);if(!s||t.stat(fZ(o.dir))!=="dir")continue;let a=jD(o,s);if(a)r.set(o.name,a);else{let l=new Set;for(let u of e.members)u!==o&&u.dir!=="."&&xr(u.dir,o.dir)&&l.add(u.dir);for(let u of n)for(let d of u.matches)xr(d,o.dir)&&l.add(d);let c=Rke(t,fZ(o.dir),l);r.set(o.name,{member:o.name,outputs:c.outputs.map(u=>({name:u.name})),inputs:c.inputs.map(u=>({name:u.name})),complete:c.gaps.length===0,why:c.gaps.length===0?null:c.gaps.length===1?c.gaps[0]:`${c.gaps[0]}, and ${c.gaps.length-1} more`,exposesNone:!1})}}return r}var De,fZ,hke,yke,gZ=v(()=>{"use strict";De=Le(Ke(),1);_t();jg();Zt();fZ=e=>e==="."?"":e,hke=new Set(["dist","coverage","generated"]),yke=/^@intentius\/chant(-lexicon-[a-z0-9-]+)?(\/.*)?$/});import{execFileSync as Ske}from"node:child_process";function Ss(e,t,n={}){try{return Ske("git",t,{cwd:e,encoding:"utf-8",input:n.input,timeout:n.timeout,stdio:[n.input===void 0?"ignore":"pipe","pipe","pipe"],maxBuffer:256*1024*1024,env:{...process.env,GIT_TERMINAL_PROMPT:"0"}})}catch{return}}function Ake(e){let t=e.match(/\(#([0-9]+)\)\s*$/);return t?Number(t[1]):null}function Pke(e){if(!e)return null;let t=(e.match(/^[a-z][a-z0-9+.-]*:\/\/(?:[^@/]*@)?([^/:]+)/i)?.[1]??e.match(/^(?:[^@/]*@)?([^/:]+):/)?.[1]??"").toLowerCase();return t==="github.com"||t.endsWith(".github.com")||/(^|[.-])github([.-]|$)/.test(t)?"github":t==="codeberg.org"||/(^|[.-])(forgejo|gitea)([.-]|$)/.test(t)?"forgejo":null}function Mg(e,t){return`refs/pull/${t}/head`}function Oke(e,t,n){for(let i of[`${Mk}${n}/head`,Mg(t,n),`refs/remotes/${Lg}/pr/${n}`]){let r=hZ(e,i);if(r)return{ref:i,head:r}}}function Cke(e,t,n){let i=o=>`+${Mg(t,o)}:${Mk}${o}/head`,r=o=>Ss(e,["fetch","--no-tags","--quiet","--no-write-fetch-head",Lg,...o.map(i)],{timeout:Eke})!==void 0;return n.length===0?new Set:r(n)?new Set(n):new Set(n.length===1?[]:n.filter(o=>r([o])))}function Fg(e,t,n){let i=new Map,r=t.map(p=>({sha:p.sha,n:Ake(p.subject)})).filter(p=>p.n!==null);if(r.length===0)return i;let o=new Map;for(let p of(Ss(e,["log","--no-walk=unsorted","--stdin","--format=%H %P"],{input:`${r.map(f=>f.sha).join(`
|
|
209
|
+
`)}
|
|
210
|
+
`})??"").split(`
|
|
211
|
+
`)){let[f,...g]=p.trim().split(/\s+/);f&&o.set(f,g)}let s=r.filter(p=>o.get(p.sha)?.length===1);if(s.length===0)return i;let a=Ss(e,["config","--get",`remote.${Lg}.url`])?.trim()||null,l=Pke(a),c=new Map;for(let p of new Set(s.map(f=>f.n))){let f=Oke(e,l,p);f&&c.set(p,f)}let u=[...new Set(s.map(p=>p.n))].filter(p=>!c.has(p)),d=n.fetchMissing&&a?Cke(e,l,u):new Set;for(let p of d){let f=hZ(e,`${Mk}${p}/head`);f&&c.set(p,{ref:`${Mk}${p}/head`,head:f})}for(let p of s){let f=c.get(p.n),g={sha:p.sha,pullRequest:p.n,forge:l,ref:null,head:null,fetched:!1,followed:!1,commits:[],problem:null};if(!f){let x=n.fetchMissing?a?`${Mg(l,p.n)} could not be fetched from ${Lg}: the forge has no such ref, or it can't be reached`:`there is no ${Lg} remote to fetch ${Mg(l,p.n)} from`:`${Mg(l,p.n)} is not in this clone`;i.set(p.sha,{...g,problem:x});continue}if(Ss(e,["merge-base","--is-ancestor",f.head,p.sha])!==void 0)continue;let h=o.get(p.sha)[0],b=Ss(e,["rev-list","--reverse","--no-merges",f.head,`^${h}`]);if(b===void 0){i.set(p.sha,{...g,ref:f.ref,head:f.head,fetched:d.has(p.n),problem:`the commits of ${f.ref} could not be listed`});continue}let w=b.split(`
|
|
212
|
+
`).map(x=>x.trim()).filter(Boolean);i.set(p.sha,{...g,ref:f.ref,head:f.head,fetched:d.has(p.n),followed:!0,commits:w})}return i}function yZ(e,t,n,i,r){let o=Ss(e,["rev-parse","--verify","--quiet",`${t}:${i}`])?.trim(),s=Ss(e,["rev-parse","--verify","--quiet",`${n}:${i}`])?.trim();if(!o||o!==s)return;let a=Ss(e,["blame","--porcelain",n,"--",i]);if(a===void 0)return;let l=new Map;for(let c of a.split(`
|
|
213
|
+
`)){let u=c.match(/^([0-9a-f]{40,64}) \d+ (\d+)(?: \d+)?$/);u&&r.has(u[1])&&l.set(Number(u[2]),u[1])}return l}var Mk,Lg,Eke,hZ,Fk=v(()=>{"use strict";Mk="refs/chant/pull/",Lg="origin",Eke=6e4;hZ=(e,t)=>Ss(e,["rev-parse","--verify","--quiet",`${t}^{commit}`])?.trim()||void 0});var GD,Dke,BD,bZ,QVe,wZ=v(()=>{"use strict";Ln();er();Nv();GD="https://in-toto.io/Statement/v1",Dke="https://intentius.io/chant/runner-evidence/v1",BD=m.string().regex(/^[0-9a-f]{64}$/),bZ=m.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/),QVe=m.object({_type:m.literal(GD),subject:m.array(m.object({name:m.string().min(1).refine(e=>!e.startsWith("/")&&!e.split("/").includes(".."),"a path inside the repository"),digest:m.object({sha256:BD}).strict()}).strict()),predicateType:m.literal(Dke),predicate:m.object({runner:m.string().min(1),commit:bZ,tree:bZ,check:m.string().min(1),claim:m.object({sha256:BD}).strict().optional(),environment:m.object({sha256:BD}).strict().optional()}).strict()}).strict()});import{createHash as Nke}from"node:crypto";function kZ(e,t){return Nke("sha256").update(Rr([e,t]),"utf8").digest("hex")}var jke,Lke,vZ,Mke,Es,sqe,xZ=v(()=>{"use strict";Ln();er();Nv();wZ();jke="https://intentius.io/chant/agent-run/v1",Lke=m.string().regex(/^[0-9a-f]{64}$/),vZ=m.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/),Mke=m.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/),Es=m.string().min(1),sqe=m.object({_type:m.literal(GD),subject:m.array(m.object({name:vZ,digest:m.object({gitCommit:vZ}).strict(),annotations:m.object({patchId:Mke}).strict().optional()}).strict().refine(e=>e.name===e.digest.gitCommit,"a commit subject is named by its own id")),predicateType:m.literal(jke),predicate:m.object({signer:Es,run:m.object({id:Es,record:m.object({sha256:Lke}).strict()}).strict(),unit:m.object({id:Es,kind:Es.nullable()}).strict().nullable(),harness:m.object({name:Es,version:Es.nullable()}).strict(),model:Es.nullable(),provider:Es.nullable(),by:Es.nullable()}).strict()}).strict()});import{execFileSync as Fke}from"node:child_process";function Bg(e,t,n){try{return Fke("git",t,{cwd:e,encoding:"utf-8",input:n,stdio:[n===void 0?"ignore":"pipe","pipe","pipe"],maxBuffer:512*1024*1024})}catch{return}}function Jke(e,t){return Bg(e,["rev-parse","--verify","--quiet",`${t}^{commit}`])?.trim()||void 0}function Zke(e){let t=new Map;for(let n of(e??"").split(`
|
|
214
|
+
`)){let[i,r]=n.trim().split(/\s+/);i&&r&&!t.has(r)&&t.set(r,i)}return t}function Yke(e,t){if(t.length===0)return new Map;let n=Bg(e,["log","--no-walk=unsorted","--stdin","--no-merges","--format=commit %H","--patch","--no-color","--no-ext-diff"],`${t.join(`
|
|
215
|
+
`)}
|
|
216
|
+
`);return n?.trim()?Zke(Bg(e,["patch-id","--stable"],n)):new Map}function Xke(e,t){let n=[],i=0;for(let r of e.split(`
|
|
217
|
+
`).map(o=>o.trim()).filter(Boolean))try{let o=JSON.parse(r),s=o.event==="statement"&&typeof o.envelope=="object"&&o.envelope!==null;o.version===1&&(o.event==="start"||o.event==="end"||s)&&o.run===t&&typeof o.at=="string"?n.push(o):i++}catch{i++}return{lines:n,malformed:i}}async function Qke(e){let{prefix:t}=await ii(e);return`${t}${Bke}`}function exe(e,t,n=`refs/heads/${Gke}`){let i=new Map,r=Jke(e,n)??null;if(!r)return{tip:r,files:i};let o=Bg(e,["ls-tree","-z",`${r}:${t}`]);if(!o)return{tip:r,files:i};let s=[];for(let c of o.split("\0").filter(Boolean)){let u=c.indexOf(" "),[,d,p]=c.slice(0,u).split(" "),g=c.slice(u+1).match(/^(.+)\.jsonl$/);d==="blob"&&g&&EZ.test(g[1])&&s.push({id:g[1],sha:p})}if(s.length===0)return{tip:r,files:i};let a=Bg(e,["cat-file","--batch"],`${s.map(c=>c.sha).join(`
|
|
218
|
+
`)}
|
|
219
|
+
`)??"",l=0;for(let c of s){let u=a.indexOf(`
|
|
220
|
+
`,l);if(u<0)break;let d=Number(a.slice(l,u).split(" ")[2]),p=u+1,f=Buffer.from(a.slice(p)).subarray(0,d).toString("utf-8");i.set(c.id,{path:`${t}/${c.id}.jsonl`,content:f}),l=p+f.length+1}return{tip:r,files:i}}function txe(e,t,n){let i=n.find(o=>o.event==="start");if(!i)return;let r=n.find(o=>o.event==="end");return{id:e,state:r?"ended":"running",startedAt:i.at,endedAt:r?.at??null,outcome:r?.outcome??null,by:i.by,agent:i.agent,harness:i.harness,model:i.model,provider:i.provider,unit:i.unit,lease:i.lease,records:i.records??[],instruction:i.instruction??null,usage:r?.usage??null,models:r?.models??[],cost:r?.cost??null,transcript:r?.transcript??null,commits:(r?.commits??[]).map(o=>({sha:o.sha,patchId:o.patchId,joinedBy:["record"],hunks:Array.isArray(o.hunks)&&o.hunks.length>0?o.hunks:null})),decisions:[],ledger:t,record:r?{sha256:kZ(i,r)}:null,statements:n.filter(o=>o.event==="statement").map(o=>({at:o.at,envelope:o.envelope}))}}async function nxe(e,t){let n=await Qke(t),{tip:i,files:r}=exe(e,n),o=new Map,s=0;for(let[a,l]of r){let c=Xke(l.content,a);s+=c.malformed;let u=txe(a,l.path,c.lines);u?o.set(a,u):s+=c.lines.length}return{tip:i,dir:n,runs:o,malformed:s}}function rxe(e){let t=new Map;for(let n of e)for(let i of n.commits){if(!i.patchId||!i.joinedBy.includes("record"))continue;let r=t.get(i.patchId)??t.set(i.patchId,[]).get(i.patchId);r.some(o=>o.run===n.id&&o.sha===i.sha)||r.push({run:n.id,sha:i.sha})}return t}async function Bk(e,t,n){let i=new Map;try{i=(await nxe(e,t)).runs}catch{}let r=new Map;for(let u of i.values())for(let d of u.commits)(r.get(d.sha)??r.set(d.sha,[]).get(d.sha)).push(u.id);let o=rxe(i.values()),s=o.size>0?Yke(e,n.map(u=>u.sha)):new Map,a=new Map,l=[],c=(u,d,p)=>{let f=i.get(u);return{id:u,recorded:f!==void 0,state:f?.state??null,harness:f?.harness.name??null,model:f?.model??null,provider:f?.provider??null,by:f?.by??null,agent:f?.agent??null,unit:f?.unit?.id??null,joinedBy:d,...p?{recordedAs:p}:{}}};for(let u of n){let d=r.get(u.sha)??[],p=[...new Set([...u.run?[u.run]:[],...d])],f=(o.get(s.get(u.sha)??"")??[]).filter(h=>h.sha!==u.sha);if(p.length>0){let h=f.filter(b=>!p.includes(b.run));h.length>0&&l.push({sha:u.sha,joined:p,content:h}),a.set(u.sha,p.map(b=>c(b,[...u.run===b?["trailer"]:[],...d.includes(b)?["record"]:[]])));continue}let g=new Map;for(let h of f)g.has(h.run)||g.set(h.run,h.sha);a.set(u.sha,[...g].map(([h,b])=>c(h,["patch-id"],b)))}return{refs:a,runs:i,conflicts:l}}function Gk(e,t){for(let n of t.values()){if(!n.followed)continue;let i=e.get(n.sha)??e.set(n.sha,[]).get(n.sha);for(let r of n.commits)for(let o of e.get(r)??[]){let s=i.find(u=>u.id===o.id);if(s){s.joinedBy.includes("squash")||s.joinedBy.push("squash"),s.via=[...new Set([...s.via??[],r])];continue}let{recordedAs:a,via:l,...c}=o;i.push({...c,joinedBy:["squash"],via:[r]})}}}var Bke,Gke,EZ,AZ,$Z,Wke,As,an,PZ,RZ,zke,Uke,Hke,Vke,SZ,qke,Kke,OZ,CZ,hqe,yqe,bqe,_Z,wqe,WD=v(()=>{"use strict";Ln();$t();ya();Wt();Fk();Wv();xZ();Bke="_agent-runs",Gke="chant/lifecycle",EZ=/^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/,AZ=/^[0-9a-f]{64}$/,$Z=/^[0-9a-f]{4,64}$/,Wke=/^[A-Z]{3}$/,As=m.number().int().nonnegative(),an=m.string().trim().min(1).refine(e=>!/[\r\n]/.test(e),"one line of text"),PZ=m.string().refine(e=>!Number.isNaN(Date.parse(e))&&/^\d{4}-\d{2}-\d{2}T/.test(e),"an ISO 8601 date and time"),RZ=m.object({amount:m.number().nonnegative().finite(),currency:m.string().regex(Wke,"an ISO 4217 code such as USD"),source:an}).strict(),zke=m.object({turns:As.optional(),inputTokens:As.optional(),outputTokens:As.optional(),cacheReadTokens:As.optional(),cacheWriteTokens:As.optional()}).strict(),Uke=m.object({sha256:m.string().regex(AZ,"64 lower-case hex digits").optional(),path:an.optional(),ref:an.optional()}).strict().refine(e=>e.sha256===void 0!=(e.path===void 0),"give sha256, or a path for chant to hash, not both"),Hke=500,Vke=m.object({sha256:m.string().regex(AZ,"64 lower-case hex digits").optional(),path:an.optional(),ref:an.optional(),excerpt:m.string().trim().min(1).max(Hke).optional()}).strict().refine(e=>e.sha256===void 0!=(e.path===void 0),"give sha256, or a path for chant to hash, not both"),SZ=m.number().int().positive(),qke=m.object({path:an,start:SZ,end:SZ}).strict().refine(e=>e.end>=e.start,"end is not before start").refine(e=>!e.path.startsWith("/")&&!e.path.split("/").includes(".."),"a path from the repository root"),Kke=m.union([m.string().regex($Z,"a commit id"),m.object({sha:m.string().regex($Z,"a commit id"),hunks:m.array(qke).min(1)}).strict()]),OZ={id:m.string().regex(EZ,"letters, digits, '.', '_' and '-', starting with a letter or digit").optional(),startedAt:PZ.optional(),by:an.optional(),agent:an.optional(),harness:m.union([an,m.object({name:an,version:an.optional()}).strict()]),model:an.optional(),provider:an.optional(),unit:m.union([an,m.object({id:an,kind:an.optional()}).strict()]).optional(),lease:an.optional(),records:m.array(m.string().refine(e=>nT(e)!==void 0,"<kind>:<id>")).optional(),instruction:Vke.optional()},CZ={endedAt:PZ.optional(),outcome:an.optional(),usage:zke.optional(),models:m.array(m.object({model:an,provider:an.optional(),inputTokens:As.optional(),outputTokens:As.optional(),cacheReadTokens:As.optional(),cacheWriteTokens:As.optional(),cost:RZ.optional()}).strict()).optional(),cost:RZ.optional(),transcript:Uke.optional(),commits:m.array(Kke).optional()},hqe=m.object(OZ).strict(),yqe=m.object(CZ).strict(),bqe=m.object({...OZ,...CZ}).strict();_Z=["trailer","record","patch-id","squash"];wqe=1440*60*1e3});function Wk(e){return e.isTag===!0}function zk(e){return e.isTag!==!0&&e.foldsAsCall===!0}function yl(e){return e.isTag!==!0&&e.foldsEagerly===!0}function Qd(e){if(typeof e!="object"||e===null||!("name"in e)||typeof e.name!="string"||!("serializer"in e)||typeof e.serializer!="object")return!1;let t=e;return typeof t.generate=="function"&&typeof t.validate=="function"&&typeof t.coverage=="function"&&typeof t.package=="function"}var So=v(()=>{"use strict"});function bl(e){return oxe.has(e)}function Uk(e){return sxe.some(t=>e===t||e.startsWith(t.endsWith("-")?t:`${t}/`))}var ixe,oxe,sxe,Hk=v(()=>{"use strict";ixe=[{name:"phase",module:"components/component.ts, op/builders.ts",note:"Returns a plain `{ phase, steps, parallel? }` / `{ name, steps, parallel? }` object literal built from its arguments. No state, no I/O."},{name:"gate",module:"components/component.ts, op/builders.ts",note:"Returns a plain `{ kind: 'gate', gate, ... }` object literal built from its arguments."},{name:"activity",module:"op/builders.ts",note:"Returns a plain `{ kind: 'activity', fn, args?, profile? }` object literal built from its arguments."},{name:"stackOutput",module:"components/component.ts, stack-output.ts",note:"Component form returns a plain `{ stackOutput: { stack, name } }` literal. Cross-stack form derives a `StackOutput` from a real `AttrRef`/`Intrinsic` and throws on anything else \u2014 so a fold that only has a symbolic reference fails loudly into run-fallback rather than producing a wrong output."},{name:"output",module:"lexicon-output.ts",note:"Constructs a `LexiconOutput` from a real `AttrRef`/`Intrinsic` and a name. Pure, but identity-sensitive: it reads through the ref's `WeakRef` to its parent entity. Only folds when the ref argument revives to a REAL live reference (see fold-import.ts's `requireLiveRefs`); a symbolic `{ __attrRef }` envelope is rejected, not silently wrapped."},{name:"when",module:"op/converge-rule.ts",note:"Returns a plain `{ id, when, then, why, flapThreshold? }` rule record built from its arguments. Throws at construction on a missing `id`/`why` or a non-positive `flapThreshold`, which is the build-time refusal the run path performs too, so a bad rule fails identically either way."},{name:"eq",module:"op/converge-rule.ts",note:"Returns a plain `{ kind: 'field-comparison', field, op: 'eq', value }` literal built from its arguments."},{name:"neq",module:"op/converge-rule.ts",note:"Returns a plain `{ kind: 'field-comparison', field, op: 'neq', value }` literal built from its arguments."},{name:"gt",module:"op/converge-rule.ts",note:"Returns a plain `{ kind: 'field-comparison', field, op: 'gt', value }` literal built from its arguments."},{name:"gte",module:"op/converge-rule.ts",note:"Returns a plain `{ kind: 'field-comparison', field, op: 'gte', value }` literal built from its arguments."},{name:"lt",module:"op/converge-rule.ts",note:"Returns a plain `{ kind: 'field-comparison', field, op: 'lt', value }` literal built from its arguments."},{name:"lte",module:"op/converge-rule.ts",note:"Returns a plain `{ kind: 'field-comparison', field, op: 'lte', value }` literal built from its arguments."},{name:"truthy",module:"op/converge-rule.ts",note:"Returns a plain `{ kind: 'field-truthiness', field, op: 'truthy' }` literal built from its argument."},{name:"falsy",module:"op/converge-rule.ts",note:"Returns a plain `{ kind: 'field-truthiness', field, op: 'falsy' }` literal built from its argument."},{name:"allOf",module:"op/converge-rule.ts",note:"Returns a plain `{ kind: 'all-of', predicates }` literal over its already-folded predicate arguments."},{name:"anyOf",module:"op/converge-rule.ts",note:"Returns a plain `{ kind: 'any-of', predicates }` literal over its already-folded predicate arguments."},{name:"run",module:"op/converge-rule.ts",note:"Returns a plain `{ kind: 'run', op }` action literal. Names an Op for a later tick to dispatch; it runs nothing at fold time, or at any other time."},{name:"report",module:"op/converge-rule.ts",note:"Returns a plain `{ kind: 'report', reason }` action literal built from its argument."}],oxe=new Set(ixe.map(e=>e.name));sxe=["@intentius/chant","@intentius/chant-lexicon-"]});function IZ(e){return Ie.isIdentifier(e)||Ie.isStringLiteral(e)||Ie.isNumericLiteral(e)}function Gg(e){return Ie.isStringLiteral(e)||Ie.isNumericLiteral(e)}function ir(e,t=60){let n=e.getText().replace(/\s+/g," ").trim();return n.length>t?`${n.slice(0,t-3)}...`:n}function Kk(e){return`computed/dynamic property name not foldable: ${ir(e)}`}function TZ(e){return`dynamic property access \u2014 computed key must be a string or numeric literal: ${ir(e)}`}function zg(e){return`unsupported binary operator: ${Ie.SyntaxKind[e]}`}function ep(e){return`function call as a value is not foldable: ${ir(e.expression)}(...)`}function Ug(e){return`unsupported expression: ${Ie.SyntaxKind[e.kind]}`}var Ie,Vk,qk,Wg,Jk,wl=v(()=>{"use strict";Ie=Le(Ke(),1);Hk();So();Vk=new Set([Ie.SyntaxKind.AmpersandAmpersandToken,Ie.SyntaxKind.BarBarToken,Ie.SyntaxKind.QuestionQuestionToken,Ie.SyntaxKind.PlusToken,Ie.SyntaxKind.MinusToken,Ie.SyntaxKind.AsteriskToken,Ie.SyntaxKind.SlashToken,Ie.SyntaxKind.EqualsEqualsEqualsToken,Ie.SyntaxKind.ExclamationEqualsEqualsToken,Ie.SyntaxKind.GreaterThanToken,Ie.SyntaxKind.LessThanToken,Ie.SyntaxKind.GreaterThanEqualsToken,Ie.SyntaxKind.LessThanEqualsToken]),qk=new Set([Ie.SyntaxKind.ExclamationToken,Ie.SyntaxKind.MinusToken]);Wg="unsupported object member",Jk="unsupported unary"});import{relative as axe}from"node:path";function cxe(e){if(typeof e!="object"||e===null)return;let t=e;if("__attrRef"in t){let n=t.__attrRef;return`a resource attribute reference${typeof n?.entity=="string"&&typeof n?.attribute=="string"?` (${n.entity}.${n.attribute})`:""}`}if("__intrinsic"in t&&typeof t.__intrinsic=="string")return`the intrinsic \`${t.__intrinsic}\``;if("__helper"in t&&typeof t.__helper=="string")return`the helper \`${t.__helper}\``;if("__resource"in t&&typeof t.__resource=="string")return`a nested \`new ${t.__resource}\``;if("__compositeStep"in t&&typeof t.__compositeStep=="string")return`the composite step \`${t.__compositeStep}(\u2026).step\``}function UD(e,t=new Set){if(e===null||typeof e!="object")return typeof e=="function";if(t.has(e))return!1;t.add(e);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==Array.prototype&&n!==null)return!0;for(let i of Object.values(e))if(UD(i,t))return!0;return!1}function Qk(e,t,n=new Set){if(n.has(t))return!1;n.add(t);let i=e.get(t);return i===void 0?!1:J.isNewExpression(i)?!0:J.isIdentifier(i)?Qk(e,i.text,n):!1}function lxe(e){let t=e;for(;J.isParenthesizedExpression(t)||J.isAsExpression(t)||J.isSatisfiesExpression(t);)t=t.expression;return J.isArrowFunction(t)||J.isFunctionExpression(t)?t:void 0}function VD(e,t,n,i,r){let o=new Map(t);for(let[l]of[...o])Qk(t,l,new Set)&&o.delete(l);let s=new Map,a=(l,c)=>{s.set(l,new Xk(l,c,n,o,i,r))};for(let l of e.statements){if(J.isFunctionDeclaration(l)){l.name&&l.body&&a(l.name.text,l);continue}if(J.isVariableStatement(l)&&(l.declarationList.flags&J.NodeFlags.Const)!==0)for(let c of l.declarationList.declarations){if(!J.isIdentifier(c.name)||!c.initializer)continue;let u=lxe(c.initializer);u&&a(c.name.text,u)}}return s}function uxe(e,t){let n;try{n=e.getSourceFile()}catch{return}if(!n)return;let i=DZ.get(n);i||(i=new WeakMap,DZ.set(n,i));let r=i.get(t);if(r)return r;let o=new Map,s=VD(n,t,n.fileName,o);for(let[a,l]of s)o.set(a,l);return i.set(t,s),s}function Ps(e){return e instanceof Xk}function HD(e){if(e.dotDotDotToken||e.initializer||!J.isIdentifier(e.name))return;let t=e.propertyName??e.name;if(J.isIdentifier(t)||J.isStringLiteral(t)||J.isNumericLiteral(t))return t.text}function dxe(e){if(e.asteriskToken)return"a generator function is not foldable";if(e.modifiers?.some(n=>n.kind===J.SyntaxKind.AsyncKeyword))return"an async function is not foldable";if(!e.body)return"a function without a body (an overload signature) is not foldable";for(let n of e.parameters){if(n.dotDotDotToken)return"a rest parameter is not foldable";if(!J.isIdentifier(n.name)){if(J.isObjectBindingPattern(n.name)){for(let i of n.name.elements)if(HD(i)===void 0)return"a destructured parameter with a rest, default, or nested element is not foldable";continue}return"an array-destructured parameter is not foldable"}}if(!J.isBlock(e.body))return;let t=e.body.statements;for(let n=0;n<t.length;n+=1){let i=t[n],r=n===t.length-1;if(J.isReturnStatement(i)){if(!r)return"an early `return` is not foldable";continue}if(!J.isVariableStatement(i))return`\`${J.SyntaxKind[i.kind]}\` in a function body is not foldable \u2014 only \`const\` declarations and a final \`return\` are`;if((i.declarationList.flags&J.NodeFlags.Const)===0)return"`let`/`var` in a function body is not foldable";for(let o of i.declarationList.declarations){if(!o.initializer)return"an uninitialized `const` in a function body is not foldable";if(!J.isIdentifier(o.name)){if(J.isObjectBindingPattern(o.name)){for(let s of o.name.elements)if(HD(s)===void 0)return"a destructured `const` with a rest, default, or nested element is not foldable";continue}return"an array-destructured `const` in a function body is not foldable"}}}}function Hg(e,t){if(Zk!==0)return dt(e,`${t} inside a folded function body is not foldable`,"EVL001",!0)}function NZ(e){let t=axe(process.cwd(),e);return t.startsWith("..")?e:t}function jZ(e,t,n,i,r){let o=`call to "${e.name}" (${NZ(e.file)})`,s=dxe(e.fn);if(s)throw dt(t,`${o} is not foldable: ${s}`);if(Zk>=pxe)throw dt(t,`${o} is not foldable: call depth exceeded \u2014 is it recursive?`);let a=[];for(let p of t.arguments){if(J.isSpreadElement(p))throw dt(p,`${o} is not foldable: a spread argument is not foldable`);a.push(Me(p,n,i,r))}let l=new Map(e.consts),c=new Map(e.externals),u=(p,f)=>{l.delete(p),c.set(p,f)},d=(p,f)=>{if(f===null||typeof f!="object")throw dt(p,`destructured source in \`${ir(p)}\` is not an object`);for(let g of p.elements)u(g.name.text,f[HD(g)])};Zk+=1;try{let p=fxe(e,a,l,c,i,u,d);return!e.leakedIdentity&&UD(p)&&!a.some(f=>UD(f))&&(e.leakedIdentity=!0),p}catch(p){if(!(p instanceof Eo))throw p;let f=`${p.line}:${p.column} - `,g=p.message.startsWith(f)?p.message.slice(f.length):p.message,h=g,b=/^unresolved identifier: (\w+)$/.exec(g);throw b&&e.failures?.has(b[1])&&(h=`${g} (${e.failures.get(b[1])})`),dt(t,`${o} is not foldable: ${NZ(e.file)}:${p.line}:${p.column} - ${h}`,p.ruleId,p.refusedAtDepth)}finally{Zk-=1}}function fxe(e,t,n,i,r,o,s){e.fn.parameters.forEach((l,c)=>{let u=t[c];u===void 0&&l.initializer&&(u=Me(l.initializer,n,r,i)),J.isIdentifier(l.name)?o(l.name.text,u):s(l.name,u)});let a=e.fn.body;if(!J.isBlock(a))return Me(a,n,r,i);for(let l of a.statements){if(J.isReturnStatement(l))return l.expression?Me(l.expression,n,r,i):void 0;for(let c of l.declarationList.declarations){let u=Me(c.initializer,n,r,i);J.isIdentifier(c.name)?o(c.name.text,u):s(c.name,u)}}}function qD(e){let t=e.getSourceFile(),{line:n,character:i}=t.getLineAndCharacterOfPosition(e.getStart());return{line:n+1,column:i+1}}function dt(e,t,n="EVL001",i=!1){let{line:r,column:o}=qD(e);return new Eo(t,r,o,n,i)}function Vg(e){let t=new Map;for(let n of e.statements)if(J.isVariableStatement(n)&&(n.declarationList.flags&J.NodeFlags.Const)!==0)for(let i of n.declarationList.declarations)J.isIdentifier(i.name)&&i.initializer&&t.set(i.name.text,i.initializer);return t}function qg(e){if(IZ(e))return e.text;throw dt(e,Kk(e))}function mxe(e){if(Gg(e))return e.text;throw dt(e,TZ(e),"EVL003")}function LZ(e,t){let n=e.get(t.text);return n!==void 0&&J.isNewExpression(n)}function gxe(e,t,n,i){if(!J.isCallExpression(e)||!J.isIdentifier(e.expression))return!1;let r=e.expression.text;return!(t.has(r)||bl(r)||n.some(o=>o.name===r&&zk(o))||Ps(i?.get(r)))}function MZ(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&"__resource"in e}function hxe(e){return typeof e!="object"||e===null||Array.isArray(e)?!1:"__attrRef"in e||"__intrinsic"in e||"__helper"in e||"__resource"in e||"__compositeStep"in e}function FZ(e,t){if(J.isIdentifier(e.expression))return{__attrRef:{entity:e.expression.text,attribute:t}};throw dt(e,`attribute "${t}" read on an inline resource expression is not foldable \u2014 bind the resource to a const first (falls back to run)`)}function zD(e){return e===GZ}function tp(e){return WZ(e)?GZ:void 0}function WZ(e){let t=e.parent;return t===void 0?!1:J.isNonNullExpression(t)&&J.isOptionalChain(t)?WZ(t):(J.isPropertyAccessExpression(t)||J.isElementAccessExpression(t)||J.isCallExpression(t))&&t.expression===e&&J.isOptionalChain(t)}function BZ(e,t){return`property "${e}" read on ${String(t)} is not foldable \u2014 running this expression throws a TypeError, so the file falls back to run (write \`?.\` if the value is genuinely optional)`}function Yk(e,t,n){return J.isIdentifier(e)?e.text!=="undefined"&&!t.has(e.text)&&!n?.has(e.text):J.isPropertyAccessExpression(e)||J.isElementAccessExpression(e)||J.isNonNullExpression(e)?Yk(e.expression,t,n):!1}function zZ(e,t,n,i){return Yk(e,t,i)?{__symbol:e.getText()}:Me(e,t,n,i)}function yxe(e){let t=e.rawText;if(t===void 0){let n=e.getText(),i=J.isTemplateHead(e)||J.isTemplateMiddle(e)?2:1;t=n.slice(1,n.length-i)}return t.replace(/\r\n?/g,`
|
|
221
|
+
`)}function bxe(e){for(let t=0;t<e.length;t++){if(e[t]!=="\\")continue;let n=e.slice(t+1),i=n[0];if(i==="x"){if(!/^x[0-9a-fA-F]{2}/.test(n))return!0}else if(i==="u"){let r=/^u(?:[0-9a-fA-F]{4}|\{([0-9a-fA-F]+)\})/.exec(n);if(!r||r[1]!==void 0&&parseInt(r[1],16)>1114111)return!0}else{if(i!==void 0&&i>="1"&&i<="9")return!0;if(i==="0"&&n[1]!==void 0&&n[1]>="0"&&n[1]<="9")return!0}t+=1}return!1}function wxe(e,t,n,i){let r=e.tag.getText();if(!n.some(d=>d.name===r&&Wk(d)))throw dt(e,`unregistered tagged template intrinsic: ${ir(e.tag)}\`...\``);let s=e.template,a=J.isNoSubstitutionTemplateLiteral(s)?[s]:[s.head,...s.templateSpans.map(d=>d.literal)],l=a.map(yxe);if(l.some(bxe))throw dt(e,`${ir(e.tag)}\`...\` holds an escape sequence with no cooked value \u2014 not foldable, falls back to run`);let c=a.map(d=>d.text),u=J.isNoSubstitutionTemplateLiteral(s)?[]:s.templateSpans.map(d=>zZ(d.expression,t,n,i));return{__intrinsic:r,strings:c,raw:l,values:u}}function Me(e,t,n=[],i){if(J.isParenthesizedExpression(e)||J.isAsExpression(e)||J.isSatisfiesExpression(e)||J.isNonNullExpression(e))return Me(e.expression,t,n,i);if(J.isArrowFunction(e)||J.isFunctionExpression(e))throw dt(e,"a function used as a value is not foldable");if(J.isStringLiteral(e)||J.isNoSubstitutionTemplateLiteral(e))return e.text;if(J.isNumericLiteral(e))return Number(e.text);if(e.kind===J.SyntaxKind.TrueKeyword)return!0;if(e.kind===J.SyntaxKind.FalseKeyword)return!1;if(e.kind===J.SyntaxKind.NullKeyword)return null;if(!(J.isIdentifier(e)&&e.text==="undefined")){if(J.isTaggedTemplateExpression(e)){let r=Hg(e,"a tagged template intrinsic");if(r)throw r;return wxe(e,t,n,i)}if(J.isTemplateExpression(e)){let r=e.head.text;for(let o of e.templateSpans){let s=Me(o.expression,t,n,i),a=cxe(s);if(a)throw dt(o.expression,`${a} interpolated into a plain template literal, which would stringify it as "[object Object]". A symbolic value has no string form until the build resolves it, so a plain template cannot carry one. Use the lexicon's own intrinsic, whose interior handles envelopes \u2014 \`Sub\`\${\u2026}\`\` for CloudFormation \u2014 or move the reference out of the template.`);r+=String(s)+o.literal.text}return r}if(J.isObjectLiteralExpression(e)){let r={};for(let o of e.properties)if(J.isPropertyAssignment(o))r[qg(o.name)]=Me(o.initializer,t,n,i);else if(J.isShorthandPropertyAssignment(o))r[o.name.text]=Me(o.name,t,n,i);else if(J.isSpreadAssignment(o)){let s=Me(o.expression,t,n,i);if(s===null||typeof s!="object")throw dt(o,"spread source not an object");Object.assign(r,s)}else throw dt(o,Wg);return r}if(J.isArrayLiteralExpression(e)){let r=[];for(let o of e.elements)if(J.isSpreadElement(o)){let s=Me(o.expression,t,n,i);if(!Array.isArray(s))throw dt(o,"spread source not an array");r.push(...s)}else r.push(Me(o,t,n,i));return r}if(J.isIdentifier(e)){if(!t.has(e.text)){if(i?.has(e.text)){let o=i.get(e.text);if(Ps(o))throw dt(e,`function "${e.text}" used as a value is not foldable`);if(typeof o=="function"&&n.some(s=>s.name===e.text&&yl(s)))throw dt(e,`function "${e.text}" used as a value is not foldable \u2014 call it instead`);return o}throw e.text==="process"?dt(e,'ambient "process" read is not foldable \u2014 declare a build-time parameter instead (chant.config.ts\'s buildParams + `chant build --param name=value`/`--params-file`) and reference it via `import { params } from "@intentius/chant/params"`, rather than reading process.env directly'):dt(e,`unresolved identifier: ${e.text}`)}let r=t.get(e.text);if((J.isTaggedTemplateExpression(r)||J.isCallExpression(r))&&i?.has(e.text))return i.get(e.text);if(J.isNewExpression(r)){if(i?.has(e.text))return i.get(e.text);throw dt(e,`same-file resource \`${e.text}\` used as a value is not foldable \u2014 falls back to run`)}return Me(r,t,n,i)}if(J.isPropertyAccessExpression(e)){if(J.isIdentifier(e.expression)&&LZ(t,e.expression))return{__attrRef:{entity:e.expression.text,attribute:e.name.text}};if(e.name.text==="step"&&gxe(e.expression,t,n,i)){let o=e.expression,s=o.expression.text,a=Hg(e,`composite call \`${s}(...).step\``);if(a)throw a;return{__compositeStep:s,args:o.arguments.map(l=>Me(l,t,n,i))}}let r=Me(e.expression,t,n,i);if(zD(r))return tp(e);if(r==null){if(e.questionDotToken)return tp(e);throw dt(e,BZ(e.name.text,r))}return MZ(r)?FZ(e,e.name.text):r[e.name.text]}if(J.isElementAccessExpression(e)){let r=mxe(e.argumentExpression);if(J.isIdentifier(e.expression)&&LZ(t,e.expression))return{__attrRef:{entity:e.expression.text,attribute:r}};let o=Me(e.expression,t,n,i);if(zD(o))return tp(e);if(o==null){if(e.questionDotToken)return tp(e);throw dt(e,BZ(r,o))}return MZ(o)?FZ(e,r):o[r]}if(J.isPrefixUnaryExpression(e)){if(!qk.has(e.operator))throw dt(e,Jk);let r=Me(e.operand,t,n,i);return e.operator===J.SyntaxKind.ExclamationToken?!r:-r}if(J.isBinaryExpression(e)){let r=e.operatorToken.kind,o=J.SyntaxKind;if(r===o.AmpersandAmpersandToken){let l=Me(e.left,t,n,i);return l&&Me(e.right,t,n,i)}if(r===o.BarBarToken){let l=Me(e.left,t,n,i);return l||Me(e.right,t,n,i)}if(r===o.QuestionQuestionToken){let l=Me(e.left,t,n,i);return l??Me(e.right,t,n,i)}if(!Vk.has(r))throw dt(e,zg(r));let s=Me(e.left,t,n,i),a=Me(e.right,t,n,i);switch(r){case o.PlusToken:return s+a;case o.MinusToken:return s-a;case o.AsteriskToken:return s*a;case o.SlashToken:return s/a;case o.EqualsEqualsEqualsToken:return s===a;case o.ExclamationEqualsEqualsToken:return s!==a;case o.GreaterThanToken:return s>a;case o.LessThanToken:return s<a;case o.GreaterThanEqualsToken:return s>=a;case o.LessThanEqualsToken:return s<=a;default:throw dt(e,zg(r))}}if(J.isConditionalExpression(e))return Me(e.condition,t,n,i)?Me(e.whenTrue,t,n,i):Me(e.whenFalse,t,n,i);if(J.isNewExpression(e)){if(!J.isIdentifier(e.expression))throw dt(e,`nested \`new ${ir(e.expression)}(...)\` as a value needs a plain imported constructor \u2014 falls back to run`);let r=Hg(e,`\`new ${e.expression.text}(...)\``);if(r)throw r;return ex(e,t,n,i)}if(J.isCallExpression(e)){if(J.isIdentifier(e.expression)&&bl(e.expression.text)&&!t.has(e.expression.text)){let r=Hg(e,`authoring helper call \`${e.expression.text}(...)\``);if(r)throw r;return{__helper:e.expression.text,args:e.arguments.map(o=>Me(o,t,n,i))}}if(J.isIdentifier(e.expression)&&!t.has(e.expression.text)){let r=e.expression.text;if(n.some(o=>o.name===r&&zk(o))){let o=Hg(e,`intrinsic call \`${r}(...)\``);if(o)throw o;return{__intrinsic:r,args:e.arguments.map(s=>zZ(s,t,n,i))}}}if(J.isIdentifier(e.expression)){let r=i?.get(e.expression.text);if(Ps(r))return jZ(r,e,t,n,i);if(i===void 0){let o=uxe(e,t)?.get(e.expression.text);if(o)return jZ(o,e,t,n,o.externals)}}if(J.isIdentifier(e.expression)&&!t.has(e.expression.text)&&n.some(r=>r.name===e.expression.text&&yl(r))){let r=i?.get(e.expression.text);if(typeof r!="function")throw dt(e,`"${e.expression.text}" did not resolve to a function \u2014 falls back to run`);let o=e.arguments.map(s=>Me(s,t,n,i));return r(...o)}if(J.isPropertyAccessExpression(e.expression)){let r=e.expression.name.text,o=Me(e.expression.expression,t,n,i);if(zD(o))return tp(e);if(o==null){if(e.expression.questionDotToken)return tp(e);throw dt(e,`cannot call ".${r}(...)" on ${String(o)}`)}if(hxe(o))throw dt(e,`method call \`.${r}(...)\` on an unresolved value is not foldable \u2014 falls back to run`);let s=o[r];if(typeof s!="function")throw dt(e,`"${r}" is not a callable method on the folded value \u2014 falls back to run`);let a=e.arguments.map(l=>Me(l,t,n,i));return s.apply(o,a)}throw dt(e,ep(e))}throw dt(e,Ug(e))}}function ex(e,t,n=[],i){let r=e.expression.getText(),o=e.arguments??[],[s,a]=o,l=p=>Me(p,t,n,i);if(!s)return{__resource:r,props:{}};if(J.isObjectLiteralExpression(s)){let p=l(s);if(o.length===1)return{__resource:r,props:p};if(o.length===2&&J.isObjectLiteralExpression(a))return{__resource:r,props:p,attributes:l(a)}}let c=o.map(l),u=o.findIndex(p=>J.isObjectLiteralExpression(p)),d=u===-1?{}:c[u];return{__resource:r,props:d,args:c}}var J,Eo,Xk,DZ,Zk,pxe,GZ,tx=v(()=>{"use strict";J=Le(Ke(),1);So();wl();Hk();Eo=class extends Error{constructor(t,n,i,r="EVL001",o=!1){let s=Error.stackTraceLimit;Error.stackTraceLimit=0,super(`${n}:${i} - ${t}`),Error.stackTraceLimit=s,this.name="FoldError",this.line=n,this.column=i,this.ruleId=r,this.refusedAtDepth=o}},Xk=class{constructor(t,n,i,r,o,s){this.name=t;this.fn=n;this.file=i;this.consts=r;this.externals=o;this.failures=s;this.leakedIdentity=!1}};DZ=new WeakMap;Zk=0,pxe=32;GZ=Symbol("chant.fold.optional-chain-short-circuit")});var JZ={};_e(JZ,{readConfigFieldsStatically:()=>$xe,readLexiconDeclarationsStatically:()=>KD,staticConfigBaseDir:()=>Rxe,unknownPathLexiconsNotice:()=>JD});import{existsSync as vxe,readFileSync as HZ}from"node:fs";import{dirname as kxe,join as xxe}from"node:path";function KD(e){let{configPath:t}=Pf(e);if(t===void 0)return{status:"no-config"};try{let n=qZ(t,["lexicons"]).lexicons;if(n===void 0)return{status:"read",configPath:t,entries:[]};let i=Af.shape.lexicons.safeParse(n);return i.success?{status:"read",configPath:t,entries:i.data??[]}:{status:"unknown",configPath:t,reason:"`lexicons` is not a list of lexicon entries"}}catch(n){return{status:"unknown",configPath:t,reason:VZ(n)}}}function VZ(e){return e instanceof Eo?`line ${e.line}: ${e.message}`:e instanceof ui?e.message:`the file could not be read (${e instanceof Error?e.message:String(e)})`}function $xe(e,t){let n=["chant.config.ts","chant.config.json"].map(i=>xxe(e,i)).find(i=>vxe(i));if(n===void 0)return{status:"no-config"};try{return{status:"read",configPath:n,fields:qZ(n,t)}}catch(i){return{status:"unknown",configPath:n,reason:VZ(i)}}}function qZ(e,t){let n=e.endsWith(".json")?Sxe(e,t):Exe(e,t);return Object.fromEntries(Object.entries(n).filter(([,i])=>i!==void 0))}function Rxe(e){return kxe(e.configPath)}function JD(e){if(e.status==="unknown")return`note: could not read the lexicons in ${e.configPath} without running it (${e.reason}). chant does not run it for this command, so any lexicon it declares by path is unknown here and is treated as a package.`}function Sxe(e,t){let n=JSON.parse(HZ(e,"utf-8"));if(typeof n!="object"||n===null||Array.isArray(n))throw new ui("the config is not a JSON object");return Object.fromEntries(t.map(i=>[i,n[i]]))}function Exe(e,t){let n=We.createSourceFile(e,HZ(e,"utf-8"),We.ScriptTarget.Latest,!0),i=Vg(n),r,o=new Map;for(let l of n.statements)if(We.isExportAssignment(l)){if(l.isExportEquals)throw new ui("`export =` is not read");r=l.expression}else{if(We.isExportDeclaration(l))throw new ui("an `export { \u2026 }` or `export \u2026 from` declaration is not read");if(We.isVariableStatement(l)&&UZ(l)){if((l.declarationList.flags&We.NodeFlags.Const)===0)throw new ui("an exported `let` or `var` is not read");for(let c of l.declarationList.declarations)if(We.isIdentifier(c.name)&&c.initializer)o.set(c.name.text,c.initializer);else throw new ui("a destructured export is not read")}else if(UZ(l)&&Oxe(l))throw new ui("the default export is not an object")}let s=r??o.get("config");if(s===void 0)return Object.fromEntries(t.map(l=>{let c=o.get(l);return[l,c===void 0?void 0:Me(c,i)]}));let a=KZ(s,i,new Set);return Object.fromEntries(t.map(l=>[l,Axe(a,l,i)]))}function KZ(e,t,n){let i=Pxe(e);if(We.isObjectLiteralExpression(i))return i;if(We.isIdentifier(i)){let r=t.get(i.text);if(r===void 0||n.has(i.text))throw new ui(`the exported config \`${i.text}\` is not a top-level const of this file`);return n.add(i.text),KZ(r,t,n)}throw new ui("the exported config is not an object literal")}function Axe(e,t,n){let i;for(let r of e.properties){if(We.isSpreadAssignment(r)){let s=Me(r.expression,n);s!==null&&typeof s=="object"&&Object.prototype.hasOwnProperty.call(s,t)&&(i=s[t]);continue}if(!(r.name===void 0||qg(r.name)!==t))if(We.isPropertyAssignment(r))i=Me(r.initializer,n);else if(We.isShorthandPropertyAssignment(r))i=Me(r.name,n);else throw new ui(`\`${t}\` is a method or accessor`)}return i}function Pxe(e){let t=e;for(;We.isParenthesizedExpression(t)||We.isAsExpression(t)||We.isSatisfiesExpression(t)||We.isNonNullExpression(t)||We.isTypeAssertionExpression(t);)t=t.expression;return t}function UZ(e){return(We.canHaveModifiers(e)&&We.getModifiers(e)?.some(t=>t.kind===We.SyntaxKind.ExportKeyword))??!1}function Oxe(e){return(We.canHaveModifiers(e)&&We.getModifiers(e)?.some(t=>t.kind===We.SyntaxKind.DefaultKeyword))??!1}var We,ui,nx=v(()=>{"use strict";We=Le(Ke(),1);Kt();tx();ui=class extends Error{}});var rx=v(()=>{"use strict"});function Cxe(e,t){if(e==="")return!0;if(!t.startsWith(e))return!1;if(t.length===e.length)return!0;let n=t[e.length];return n==="."||n==="["}function Hi(e,t){if(!Object.isExtensible(e))return;let n=e[ZD];if(n){if(n.sourceFile??=t.sourceFile,n.composite??=t.composite,n.compositeInstance??=t.compositeInstance,n.compositeCall??=t.compositeCall,t.paths){n.paths??={};for(let[i,r]of Object.entries(t.paths))n.paths[i]??=r}return}Object.defineProperty(e,ZD,{value:{...t,...t.paths?{paths:{...t.paths}}:{}},enumerable:!1,writable:!0,configurable:!0})}function Ao(e){return e[ZD]}function Os(e,t,n){Hi(e,{paths:{[t]:n}})}function YD(e,t){if(!e)return;let n;for(let i of Object.keys(e))Cxe(i,t)&&(n===void 0||i.length>n.length)&&(n=i);return n===void 0?void 0:e[n]}function ZZ(e){return e[_xe]}var ZD,_xe,di=v(()=>{"use strict";ZD=Symbol.for("chant.provenance");_xe=Symbol.for("chant.interpolationFields")});function Vi(e){return typeof e=="object"&&e!==null&&XD in e&&e[XD]===!0}function XZ(e,t){let n=Symbol(),i=t??"anonymous",r=(o=>{let s=e(o);for(let[l,c]of Object.entries(s))if(!qt(c)&&!Vi(c))throw new Error(`Composite "${i}" member "${l}" is not a Declarable or CompositeInstance`);QZ(s,i);let a={};return Object.defineProperty(a,XD,{value:!0,enumerable:!1}),Object.defineProperty(a,"members",{value:s,enumerable:!1}),Object.defineProperty(a,"_definition",{value:r,enumerable:!1}),Object.assign(a,s)});return Object.defineProperty(r,"compositeName",{value:i,writable:!1}),Object.defineProperty(r,"_id",{value:n,writable:!1}),QD.register(r),r}function QZ(e,t){for(let n of Object.values(e))Vi(n)?QZ(n.members,t):qt(n)&&Object.isExtensible(n)&&!Object.prototype.hasOwnProperty.call(n,eN)&&Object.defineProperty(n,eN,{value:t,enumerable:!1,configurable:!0})}function e5(e){let t=e[eN];return typeof t=="string"?t:void 0}function ix(e,t,n=e){let i=new Map,r=t[Ixe],o=t._definition?.compositeName;for(let[s,a]of Object.entries(t.members)){let l=`${e}${s[0].toUpperCase()}${s.slice(1)}`;if(Vi(a)){let c=ix(l,a,n);for(let[u,d]of c)o&&Hi(d,{composite:o}),i.set(u,d)}else o&&Hi(a,{composite:o}),i.set(l,a)}if(o)for(let s of i.values())Os(s,"",{kind:"composite",composite:o,instance:n});if(r){for(let s of i.values())if("props"in s){let l=s[YZ];l===void 0&&(l=s.props,Object.defineProperty(s,YZ,{value:l,enumerable:!1,configurable:!0}));let c={};for(let[u,d]of Object.entries(r))d!==void 0&&(c[u]=d);for(let[u,d]of Object.entries(l))d!==void 0&&(Array.isArray(d)&&Array.isArray(c[u])?c[u]=[...c[u],...d]:c[u]=d);if(Object.defineProperty(s,"props",{value:c,enumerable:!1,configurable:!0}),o)for(let u of Object.keys(r))r[u]===void 0||l[u]!==void 0||Os(s,u,{kind:"composite",composite:o,instance:n})}}return i}var XD,QD,eN,Ixe,YZ,ox=v(()=>{"use strict";Pn();di();XD=Symbol.for("chant.composite");QD=class{static{this.definitions=new Map}static register(t){this.definitions.set(t._id,t)}static getAll(){return Array.from(this.definitions.values())}static clear(){this.definitions.clear()}static get size(){return this.definitions.size}};eN=Symbol.for("chant.composite.memberOf");Ixe=Symbol.for("chant.composite.shared"),YZ=Symbol.for("chant.composite.origProps")});function n5(e){return typeof e=="object"&&e!==null&&t5 in e&&e[t5]===!0}var t5,tN=v(()=>{"use strict";Pn();t5=Symbol.for("chant.secret-declaration")});var Txe,nN,r5,rN=v(()=>{"use strict";Txe=new WeakMap,nN="[secret material]",r5=class e{constructor(){}static mint(t){let n=new e;return Txe.set(n,t),n}toString(){return nN}toJSON(){return nN}[Symbol.for("nodejs.util.inspect.custom")](){return nN}}});function iN(e){return Object.fromEntries(e.map(t=>[t.name,t.value]))}var Kg=v(()=>{"use strict"});var i5=v(()=>{"use strict"});var vl={};_e(vl,{BuildError:()=>Cs,DiscoveryError:()=>Hn,LintError:()=>oN});var Hn,Cs,oN,or=v(()=>{"use strict";Hn=class extends Error{constructor(t,n,i){super(n),this.name="DiscoveryError",this.file=t,this.type=i}toJSON(){return{name:this.name,file:this.file,message:this.message,type:this.type}}},Cs=class extends Error{constructor(t,n){super(n),this.name="BuildError",this.entityName=t}toJSON(){return{name:this.name,entityName:this.entityName,message:this.message}}},oN=class extends Error{constructor(t,n,i,r,o){super(o),this.name="LintError",this.file=t,this.line=n,this.column=i,this.ruleId=r}toJSON(){return{name:this.name,file:this.file,line:this.line,column:this.column,ruleId:this.ruleId,message:this.message}}}});var o5=v(()=>{"use strict"});var s5=v(()=>{"use strict"});function Dxe(...e){let t=e.join("_").split(/[^A-Za-z0-9]+/).filter(n=>n.length>0);return t.length===0?"Output":t.map((n,i)=>i===0?n:n.charAt(0).toUpperCase()+n.slice(1)).join("")}function zr(e){return typeof e=="object"&&e!==null&&sx in e&&e[sx]===!0}var sx,a5,sN,np,kl=v(()=>{"use strict";Qo();Wt();sx=Symbol.for("chant.lexiconOutput");a5=Ci;sN=class sN{constructor(t,n){this[a5]=!0;if(Object.defineProperty(this,sx,{value:!0,enumerable:!1}),dn(t)){let i=t.parent.deref();if(!i)throw new Error("Cannot create LexiconOutput: parent entity has been garbage collected");if(!("lexicon"in i)||typeof i.lexicon!="string")throw new Error("Cannot create LexiconOutput: parent entity has no lexicon field");this.sourceLexicon=i.lexicon,this.sourceEntity="",this.sourceAttribute=t.attribute,this.outputName=n,this._sourceParent=t.parent,this._intrinsic=null,this._literalValue=null}else if(Ou(t))this.sourceLexicon="",this.sourceEntity="",this.sourceAttribute=null,this.outputName=n,this._sourceParent=null,this._intrinsic=t,this._literalValue=null;else if(typeof t=="string"||typeof t=="number"||typeof t=="boolean")this.sourceLexicon="",this.sourceEntity="",this.sourceAttribute=null,this.outputName=n,this._sourceParent=null,this._intrinsic=null,this._literalValue=t;else throw new Error(`output(ref, "${n}"): ref must be an AttrRef, an Intrinsic, or an already-resolved string/number/boolean \u2014 got ${t===null?"null":typeof t} instead. If this came from a resource member access (e.g. "resource.SomeField"), that member is neither a generated attribute nor a real value here \u2014 check for a typo or a property that CloudFormation does not expose via Fn::GetAtt.`)}_setSourceEntity(t){this.sourceEntity=t}getOutputValue(){return this._literalValue!==null?this._literalValue:this._intrinsic?this._intrinsic.toJSON():{"Fn::GetAtt":[this.sourceEntity,this.sourceAttribute]}}static auto(t,n){let i=Dxe(n,t.attribute),r=new sN(t,i);return r._setSourceEntity(n),r}toJSON(){return{"chant::output":this.outputName}}},np=sN});async function ax(e){let t=c5.get(e);if(t)throw t;try{return Mn(),hr(await import(e))}catch(n){let i=n instanceof Error?n.message:"Unknown import error",r=new Hn(e,i,"import");throw c5.set(e,r),r}}var c5,cx=v(()=>{"use strict";or();Ei();Zs();c5=new Map});function Nxe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function cN(e,t){return Object.isExtensible(e)&&!Object.prototype.hasOwnProperty.call(e,aN)&&Object.defineProperty(e,aN,{value:t,enumerable:!1,configurable:!0}),l5(e,t),e}function l5(e,t){for(let n of Object.values(e))qt(n)?Hi(n,{composite:t}):xl(n)!==void 0&&l5(n,t)}function xl(e){if(!Nxe(e))return;let t=e[aN];return typeof t=="string"?t:void 0}function lN(e,t,n=e){let i=[],r=xl(t);for(let[o,s]of Object.entries(t)){if(o.length===0)continue;let a=`${e}${o[0].toUpperCase()}${o.slice(1)}`;if(xl(s)!==void 0){i.push(...lN(a,s,n));continue}if(!qt(s))continue;Hi(s,{composite:r,compositeInstance:n});let l=Ao(s)?.composite??r;Os(s,"",{kind:"composite",composite:l,instance:n}),i.push([a,s])}return i}var aN,uN=v(()=>{"use strict";Pn();di();aN=Symbol.for("chant.fold.hostCompositeInstance")});import{basename as jxe,dirname as dN,relative as Lxe,resolve as u5}from"node:path";function Mxe(e,t){return e!=="default"?e:jxe(t).replace(/\.ts$/,"").replace(/\.op$/,"")}function Fxe(e,t){let n=dN(e);return(t?Lxe(u5(t),u5(n)):n).split(/[^A-Za-z0-9]+/).filter(o=>o.length>0).map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join("")}function d5(e,t){let n=e5(e);return{sourceFile:t,...n?{composite:n}:{},paths:Bxe}}function Gxe(e){let t=[];for(let{file:n,exports:i}of e){let r=Object.entries(i).sort(([o],[s])=>o.localeCompare(s));for(let[o,s]of r){let a=Mxe(o,n);if(qt(s))t.push({bareKey:a,value:s,file:n,provenance:d5(s,n)});else if(Array.isArray(s))for(let l=0;l<s.length;l++){let c=s[l];if(qt(c))t.push({bareKey:`${a}_${l}`,value:c,file:n,provenance:d5(c,n)});else if(Vi(c)){let u=`${a}_${l}`;for(let[d,p]of ix(u,c))t.push({bareKey:d,value:p,file:n,provenance:{sourceFile:n,compositeInstance:u}})}}else if(Vi(s))for(let[l,c]of ix(a,s))t.push({bareKey:l,value:c,file:n,provenance:{sourceFile:n,compositeInstance:a}});else if(xl(s)!==void 0)for(let[l,c]of lN(a,s))t.push({bareKey:l,value:c,file:n,provenance:{sourceFile:n,compositeInstance:a}});else zr(s)&&t.push({bareKey:a,value:s,file:n,provenance:{sourceFile:n}})}}return t}function pN(e,t){let n=Gxe(e),i=new Map;for(let{bareKey:a,value:l,file:c}of n){let u=dN(c),d=i.get(a);d||(d=new Map,i.set(a,d));let p=d.get(u);p||(p=new Set,d.set(u,p)),p.add(l)}let r=new Set;for(let[a,l]of i){let c=[...l.values()].filter(d=>d.size>0).length,u=new Set;for(let d of l.values())for(let p of d)u.add(p);c>1&&u.size>1&&r.add(a)}let o=new Map,s=new Map;for(let{bareKey:a,value:l,file:c,provenance:u}of n){let d=dN(c),p=s.get(a);p||(p=new Map,s.set(a,p));let f=p.get(d);if(f!==void 0&&f!==l)throw new Hn(c,`Duplicate export name "${a}" found`,"resolution");p.set(d,l);let g=r.has(a)?`${Fxe(c,t)}${a}`:a,h=o.get(g);if(h!==void 0){if(h!==l)throw new Hn(c,`Duplicate export name "${a}" found`,"resolution");continue}Hi(l,u),o.set(g,l)}return o}var Bxe,lx=v(()=>{"use strict";Pn();ox();kl();or();di();uN();Bxe={"":{kind:"authored"}}});function Wxe(e){if(e instanceof Map)return e;let t=new Map;for(let[n,i]of Object.entries(e))t.set(n,new Set(i));return t}function p5(e){let t=Wxe(e),n=0,i=1,r=2,o=new Map,s=new Map,a=[],l=new Set;for(let u of t.keys())o.set(u,n);function c(u){o.set(u,i);let d=t.get(u)??new Set;for(let p of d){let f=o.get(p);if(f===void 0||f===n){if(f===void 0)continue;s.set(p,u),c(p)}else if(f===i){let g=[p],h=u;for(;h!==p;)g.push(h),h=s.get(h);g.push(p),g.reverse();let b=zxe(g);l.has(b)||(l.add(b),a.push(g.slice(0,-1)))}}o.set(u,r)}for(let u of t.keys())o.get(u)===n&&c(u);return a}function zxe(e){let t=e.slice(0,-1),n=0;for(let r=1;r<t.length;r++)t[r]<t[n]&&(n=r);return[...t.slice(n),...t.slice(0,n)].join(",")}var fN=v(()=>{"use strict"});function f5(e){let t=p5(e);if(t.length>0){let s=t[0].join(" -> ");throw new Cs(t[0][0],`Circular dependency detected: ${s}`)}let n=[],i=new Set,r=new Set;function o(s){if(i.has(s))return;r.add(s);let a=e[s]||[];for(let l of a)i.has(l)||o(l);r.delete(s),i.add(s),n.push(s)}for(let s of Object.keys(e))i.has(s)||o(s);return n}var mN=v(()=>{"use strict";or();fN()});function m5(e){for(let[t,n]of e.entries())n[eC]=t;for(let[t,n]of e.entries()){let i=eU(n);for(let r of i){let o=n[r];if(dn(o)){let s=o.parent.deref();if(!s)throw new Error(`Cannot resolve AttrRef on "${t}.${r}": parent has been garbage collected`);let a;for(let[l,c]of e.entries())if(c===s){a=l;break}if(!a)throw new Error(`Cannot resolve AttrRef on "${t}.${r}": parent entity not found in entities collection`);o._setLogicalName(a)}}}}var gN=v(()=>{"use strict";Wt()});function ux(e){let t=new Map;for(let i of e.keys())t.set(i,new Set);let n=new Map;for(let[i,r]of e.entries())n.set(r,i);for(let[i,r]of e.entries()){let o=t.get(i);hN(r,e,n,o,new Set,r)}return t}function hN(e,t,n,i,r,o){if(!qt(e)&&!r.has(e)&&r.add(e),Array.isArray(e)){for(let s of e)g5(s,t,n,i,r,o);return}for(let s in e)if(Object.prototype.hasOwnProperty.call(e,s)){let a=e[s];g5(a,t,n,i,r,o)}}function g5(e,t,n,i,r,o){if(e!=null&&typeof e=="object"){if(dn(e)){if(r.has(e))return;r.add(e);let s=e.parent.deref();if(s&&qt(s)&&s!==o){let a=n.get(s);a&&i.add(a)}return}if(qt(e)){if(e===o){if(r.has(e)){let a=n.get(e);a&&i.add(a);return}r.add(e),hN(e,t,n,i,r,o);return}let s=n.get(e);s&&i.add(s);return}r.has(e)||hN(e,t,n,i,r,o)}}var dx=v(()=>{"use strict";Pn();Wt()});import{readFileSync as Uxe,statSync as yN}from"node:fs";import{dirname as ip,extname as Hxe,isAbsolute as Vxe,join as rp,resolve as bN}from"node:path";function Po(e){try{return yN(e,{throwIfNoEntry:!1})?.isFile()??!1}catch{return!1}}function qxe(e){try{return yN(e,{throwIfNoEntry:!1})?.isDirectory()??!1}catch{return!1}}function wN(e){let t=Hxe(e),n=Kxe[t];if(n){let r=e.slice(0,-t.length);for(let o of n)if(Po(r+o))return r+o}return[e,`${e}.ts`,`${e}.tsx`,`${e}.js`,`${e}.mjs`,rp(e,"index.ts"),rp(e,"index.js")].find(Po)}function v5(e){let t=e.split("/"),n=e.startsWith("@")?2:1;if(t.length<n||t.slice(0,n).some(o=>o===""))return;let i=t.slice(0,n).join("/"),r=t.slice(n).join("/");return{name:i,subpath:r===""?".":`./${r}`}}function Jg(e,t){if(typeof e=="string")return t===void 0?e:e.split("*").join(t);if(Array.isArray(e)){for(let n of e){let i=Jg(n,t);if(i!==void 0)return i}return}if(!(typeof e!="object"||e===null))for(let[n,i]of Object.entries(e)){if(!Jxe.has(n))continue;let r=Jg(i,t);if(r!==void 0)return r}}function k5(e,t){if(!(typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.keys(e).some(s=>s.startsWith("."))))return t==="."?Jg(e,void 0):void 0;let i=e;if(Object.prototype.hasOwnProperty.call(i,t)&&!t.includes("*"))return Jg(i[t],void 0);let r,o;for(let s of Object.keys(i)){let a=s.indexOf("*");if(a===-1||s.indexOf("*",a+1)!==-1)continue;let l=s.slice(0,a),c=s.slice(a+1);!t.startsWith(l)||t===l||c!==""&&(!t.endsWith(c)||t.length<s.length)||(r===void 0||l.length>r.indexOf("*")||l.length===r.indexOf("*")&&s.length>r.length)&&(r=s,o=t.slice(l.length,t.length-c.length))}return r===void 0?void 0:Jg(i[r],o)}function x5(e){let t=h5.get(e);if(t!==void 0)return t;let n=rp(e,"tsconfig.json"),i;if(Po(n))i=n;else{let r=ip(e);i=r===e?null:x5(r)}return h5.set(e,i),i}function b5(e){try{return yN(e,{throwIfNoEntry:!1})?.mtimeMs??-1}catch{return-1}}function Zxe(e,t){let n=ip(t);if(e.startsWith(".")||Vxe(e)){let i=bN(n,e);return Po(i)?i:!i.endsWith(".json")&&Po(`${i}.json`)?`${i}.json`:void 0}for(let i=n;;){let r=rp(i,"node_modules",e);if(Po(r))return r;if(!r.endsWith(".json")&&Po(`${r}.json`))return`${r}.json`;if(qxe(r)&&Po(rp(r,"tsconfig.json")))return rp(r,"tsconfig.json");let o=ip(i);if(o===i)return;i=o}}function $5(e,t,n){if(n.has(e))return{};n.add(e),t.push(e);let i;try{i=Uxe(e,"utf-8")}catch{return{}}let{config:r}=w5.parseConfigFileTextToJson(e,i);if(typeof r!="object"||r===null)return{};let o=r,s={},a=typeof o.extends=="string"?[o.extends]:Array.isArray(o.extends)?o.extends:[];for(let c of a){if(typeof c!="string")continue;let u=Zxe(c,e);if(u===void 0)continue;let d=$5(u,t,n);d.paths&&(s.paths=d.paths),d.baseUrl!==void 0&&(s.baseUrl=d.baseUrl)}let l=o.compilerOptions;return l&&typeof l.paths=="object"&&l.paths!==null&&!Array.isArray(l.paths)&&(s.paths={value:l.paths,declaredIn:ip(e)}),l&&typeof l.baseUrl=="string"&&(s.baseUrl=bN(ip(e),l.baseUrl)),s}function Yxe(e){if(!e.paths)return;let t=[];for(let[n,i]of Object.entries(e.paths.value)){if(!Array.isArray(i))continue;let r=i.filter(s=>typeof s=="string"),o=n.indexOf("*");o!==-1&&n.indexOf("*",o+1)!==-1||t.push(o===-1?{key:n,prefix:n,suffix:void 0,substitutions:r}:{key:n,prefix:n.slice(0,o),suffix:n.slice(o+1),substitutions:r})}return{base:e.baseUrl??e.paths.declaredIn,patterns:t}}function Xxe(e){let t=y5.get(e);if(t&&t.stamps.every(([r,o])=>b5(r)===o))return t.paths;let n=[],i=Yxe($5(e,n,new Set));return y5.set(e,{stamps:n.map(r=>[r,b5(r)]),paths:i}),i}function R5(e,t){let n=x5(ip(t));if(n===null)return;let i=Xxe(n);if(!i)return;let r;for(let s of i.patterns){if(s.suffix===void 0){if(s.key===e){r=s;break}continue}e.length>=s.prefix.length+s.suffix.length&&e.startsWith(s.prefix)&&e.endsWith(s.suffix)&&(r===void 0||s.prefix.length>r.prefix.length)&&(r=s)}if(!r)return;let o=r.suffix===void 0?"":e.slice(r.prefix.length,e.length-r.suffix.length);for(let s of r.substitutions){let a=wN(bN(i.base,s.split("*").join(o)));if(a!==void 0)return{key:r.key,target:a}}return{key:r.key,target:void 0}}var w5,Kxe,Jxe,h5,y5,S5=v(()=>{"use strict";w5=Le(Ke(),1);Kxe={".js":[".ts",".tsx"],".jsx":[".tsx"],".mjs":[".mts"],".cjs":[".cts"]};Jxe=new Set(["import","node","default"]);h5=new Map,y5=new Map});function vN(e){if(e&&(ke.isIdentifier(e)||ke.isStringLiteral(e)||ke.isNumericLiteral(e)))return e.text}function $l(e){let t=e;for(;;){if(ke.isParenthesizedExpression(t)||ke.isAsExpression(t)||ke.isNonNullExpression(t)){t=t.expression;continue}return t}}function Qxe(e,t,n,i){let r=new Set,o=s=>{if(ke.isPropertyAccessExpression(s)){if(ke.isIdentifier(s.expression)&&n.has(s.expression.text)){i.add(s.name.text);return}o(s.expression);return}if(ke.isElementAccessExpression(s)){ke.isIdentifier(s.expression)&&n.has(s.expression.text)?ke.isStringLiteralLike(s.argumentExpression)&&i.add(s.argumentExpression.text):o(s.expression),o(s.argumentExpression);return}if(ke.isIdentifier(s)){if(n.has(s.text))return;let a=t.get(s.text);a&&!r.has(s.text)&&(r.add(s.text),o(a));return}if(ke.isPropertyAssignment(s)){o(s.initializer);return}ke.forEachChild(s,o)};o(e)}function e$e(e,t,n,i){let r=new Set,o,s=a=>{if(!o){if(ke.isCallExpression(a)){let l=$l(a.expression);if(ke.isPropertyAccessExpression(l)||ke.isElementAccessExpression(l)){o="host-call";return}if(ke.isIdentifier(l)&&!t.has(l.text)&&i.eagerCalls.has(l.text)){o="host-call";return}for(let c of a.arguments)s(c);return}if(ke.isPropertyAccessExpression(a)){s(a.expression);return}if(ke.isIdentifier(a)){if(n.has(a.text))return;let l=t.get(a.text);if(l){if(ke.isNewExpression($l(l))||r.has(a.text))return;r.add(a.text),s(l);return}i.values.has(a.text)&&(o="host-value");return}if(ke.isPropertyAssignment(a)){s(a.initializer);return}if(ke.isTaggedTemplateExpression(a)){s(a.template);return}ke.forEachChild(a,s)}};return s(e),o}function A5(e,t,n,i){let r={};if(n.size===0&&!i)return r;let o=(a,l)=>{if(r[a]?.kind==="host")return;let c=i?e$e(l,t,n,i):void 0;if(c){r[a]={kind:"host",reason:c};return}let u=new Set;if(Qxe(l,t,n,u),u.size===0)return;let d=r[a],p=d&&d.kind==="build-param"?new Set([...d.params,...u]):u;r[a]={kind:"build-param",params:[...p].sort()}},s=(a,l)=>{for(let c of a.properties){if(ke.isSpreadAssignment(c)){o(l,c.expression);continue}if(ke.isShorthandPropertyAssignment(c)){let f=c.name.text;o(l?`${l}.${f}`:f,c.name);continue}if(!ke.isPropertyAssignment(c))continue;let u=vN(c.name);if(u===void 0)continue;let d=l?`${l}.${u}`:u,p=$l(c.initializer);if(ke.isObjectLiteralExpression(p)){s(p,d);continue}o(d,c.initializer)}};return s(e,""),r}function E5(e,t){let n=[],i=e;for(;;){if(ke.isPropertyAccessExpression(i)){n.unshift(i.name.text),i=i.expression;continue}if(ke.isElementAccessExpression(i)&&ke.isStringLiteralLike(i.argumentExpression)){n.unshift(i.argumentExpression.text),i=i.expression;continue}break}if(!ke.isIdentifier(i))return;if(t.whole.has(i.text))return n.length===0?void 0:n.join(".");let r=t.destructured.get(i.text);if(r!==void 0)return n.length===0?r:`${r}.${n.join(".")}`}function t$e(e){let t=$l(e);return ke.isNewExpression(t)||ke.isCallExpression(t)}function P5(e,t,n,i){let r=new Set,o=s=>{if(ke.isPropertyAccessExpression(s)||ke.isElementAccessExpression(s)){let a=E5(s,n);if(a!==void 0){i.add(a);return}o(s.expression),ke.isElementAccessExpression(s)&&o(s.argumentExpression);return}if(ke.isIdentifier(s)){let a=E5(s,n);if(a!==void 0){i.add(a);return}if(n.whole.has(s.text))return;let l=t.get(s.text);l&&!r.has(s.text)&&!t$e(l)&&(r.add(s.text),o(l));return}if(ke.isPropertyAssignment(s)){o(s.initializer);return}ke.forEachChild(s,o)};o(e)}function px(e,t){let n=t.getSourceFile(),{line:i,character:r}=n.getLineAndCharacterOfPosition(t.getStart(n));return{file:e,line:i+1,column:r+1}}function n$e(e,t){let n={parameter:t,...px(e.file,e.node)},i=e.node.arguments[0];if(!i)return n;let r=$l(i),o;for(let s of t.split(".")){if(!ke.isObjectLiteralExpression(r))return n;o=void 0;for(let a of r.properties)(ke.isShorthandPropertyAssignment(a)&&a.name.text===s||ke.isPropertyAssignment(a)&&vN(a.name)===s)&&(o=a);if(!o)return n;r=ke.isPropertyAssignment(o)?$l(o.initializer):o.name}return o?{parameter:t,...px(e.file,o),text:o.getText()}:n}function r$e(e,t){return e?t.map(n=>n$e(e,n)):void 0}function O5(e,t,n,i,r){let o={},s=c=>{let u=new Set;return P5(c,t,n,u),[...u].sort()},a=(c,u,d)=>{let p=s(u);if(p.length>0){let f=o[c],g=f&&f.kind==="composite-parameter"?[...new Set([...f.parameters,...p])].sort():p;o[c]=_5(i,g,r);return}d||(o[c]??={kind:"composite-literal",composite:i})},l=(c,u)=>{for(let d of c.properties){if(ke.isSpreadAssignment(d)){a(u,d.expression,!0);continue}if(ke.isShorthandPropertyAssignment(d)){let h=d.name.text;a(u?`${u}.${h}`:h,d.name,!1);continue}if(!ke.isPropertyAssignment(d))continue;let p=vN(d.name);if(p===void 0)continue;let f=u?`${u}.${p}`:p,g=$l(d.initializer);if(ke.isObjectLiteralExpression(g)){l(g,f);continue}a(f,d.initializer,!1)}};return l(e,""),o}function C5(e,t,n,i,r,o,s){let a={};if(e.forEach((l,c)=>{let u=new Set;if(P5(l,i,r,u),u.size!==0)for(let d of t[c]??[]){let p=a[d],f=new Set(p?.kind==="composite-parameter"?p.parameters:[]);for(let g of u)f.add(g);a[d]=_5(o,[...f].sort(),s)}}),n!==null&&typeof n=="object"&&!Array.isArray(n))for(let[l,c]of Object.entries(n))c!==void 0&&(a[l]??={kind:"composite-literal",composite:o});return a}function _5(e,t,n){let i=r$e(n,t);return{kind:"composite-parameter",composite:e,parameters:t,...i?{arguments:i}:{}}}var ke,I5=v(()=>{"use strict";ke=Le(Ke(),1)});function i$e(e){if(e===null||typeof e!="object"||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function o$e(e){let t=[],n=(i,r)=>{if(i!==void 0){if(i$e(i)){let o=Object.keys(i).sort();if(o.length===0){r&&t.push(r);return}for(let s of o)n(i[s],r?`${r}.${s}`:s);return}r&&t.push(r)}};return n(e,""),t}function s$e(e,t){if(!t)return{kind:"unknown",reason:"no-provenance"};let n=t.compositeInstance,i=t.compositeCall;switch(e?.kind){case"composite-parameter":return{kind:"composite-parameter",composite:e.composite,...n?{instance:n}:{},parameters:[...e.parameters],...i?{call:{...i}}:{},...e.arguments?{arguments:e.arguments.map(r=>({...r}))}:{}};case"composite-literal":return{kind:"composite-literal",composite:e.composite,...n?{instance:n}:{},...i?{call:{...i}}:{}};case"composite":return{kind:"unknown",reason:"composite-not-interpreted"};case"authored":return t.composite?{kind:"unknown",reason:"composite-not-interpreted"}:{kind:"direct"};case"host":return{kind:"unknown",reason:e.reason};case"build-param":return{kind:"direct"};case void 0:return t.composite?{kind:"unknown",reason:"composite-not-interpreted"}:{kind:"direct"}}}function a$e(e,t){if(!km(e))return;let n=o$e(e.props);if(n.length===0)return;let i={};for(let r of n)i[r]=s$e(YD(t?.paths,r),t);return{...t?.sourceFile?{sourceFile:t.sourceFile}:{},...t?.composite?{composite:t.composite}:{},...t?.compositeInstance?{instance:t.compositeInstance}:{},...t?.compositeCall?{compositeCall:{...t.compositeCall}}:{},fields:i}}function kN(e,t){let n={};for(let i of[...e.keys()].sort()){let r=e.get(i),o=a$e(r,t(r));o&&(n[i]=o)}return n}var fx=v(()=>{"use strict";Pn();di()});import{readFile as vx}from"node:fs/promises";import{existsSync as PN,readFileSync as F5,realpathSync as c$e}from"node:fs";import{dirname as Co,basename as hx,join as sp,sep as RN,isAbsolute as th,resolve as Zg}from"node:path";import{fileURLToPath as B5}from"node:url";import{createRequire as l$e}from"node:module";function u$e(e){return`@intentius/chant-lexicon-${e}`}function ON(e=[],t,n=[],i=!1,r=[],o=!1,s=[]){let a=new Set(r),l=new Set,c=[];for(let u of n){let d=Pi(u);d===void 0?a.add(u$e(u)):l.add(Qg(d,d));let p=PO(u);p!==void 0&&!s.some(f=>rh(Zg(f),p))&&c.push(p)}return{intrinsics:e,cache:new Map,stack:[],importCache:new Map,resolvePathCache:new Map,buildParams:t,lexiconPackages:a,lexiconModules:l,lexiconRoots:c,sandbox:i,executing:o,factoryModules:new Map}}function sr(e,t,n){let i=!e.startsWith(".")&&!th(e),r=`${Co(t)}\0${e}`;if(i){let a=n.get(r);if(a!==void 0)return a;let l=nh(e,t);if(l!==void 0)return n.set(r,l),l;let c=T5.get(e);if(c!==void 0)return c;let u=Qg(e,t);return T5.set(e,u),u}let o=n.get(r);if(o!==void 0)return o;let s=Qg(e,t);return n.set(r,s),s}function Qe(e){let t=Error.stackTraceLimit;Error.stackTraceLimit=0;try{return new Error(e)}finally{Error.stackTraceLimit=t}}function ap(e,t){let n=t.get(e);if(n)return n;let i=ax(e);return t.set(e,i),i}function Yg(e){return e.modifiers?.some(t=>t.kind===D.SyntaxKind.ExportKeyword)??!1}function Ua(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Sl(e){if(!(e.dotDotDotToken||e.initializer||!D.isIdentifier(e.name)))return e.propertyName?D.isIdentifier(e.propertyName)?e.propertyName.text:void 0:e.name.text}function d$e(e){let t=[];for(let n of e.statements){if(D.isExportAssignment(n))return{declarators:t,unfoldableReason:"`export default` is not foldable"};if(D.isExportDeclaration(n)){if(n.isTypeOnly)continue;if(n.moduleSpecifier){if(!D.isStringLiteral(n.moduleSpecifier))return{declarators:t,unfoldableReason:"re-export declaration is not foldable"};if(!n.exportClause||!D.isNamedExports(n.exportClause))return{declarators:t,unfoldableReason:"re-export declaration is not foldable"};let r=[];for(let o of n.exportClause.elements){if(o.isTypeOnly)continue;let s=o.propertyName??o.name;if(!D.isIdentifier(s))return{declarators:t,unfoldableReason:"re-export declaration is not foldable"};r.push({imported:s.text,exportedName:o.name.text})}t.push({kind:"re-export",specifier:n.moduleSpecifier.text,specifierNode:n.moduleSpecifier,elements:r});continue}if(!n.exportClause||!D.isNamedExports(n.exportClause))return{declarators:t,unfoldableReason:"export declaration is not foldable"};let i=[];for(let r of n.exportClause.elements){if(r.isTypeOnly)continue;let o=r.propertyName??r.name;if(!D.isIdentifier(o))return{declarators:t,unfoldableReason:"export declaration is not foldable"};i.push({localNameNode:o,exportedName:r.name.text})}t.push({kind:"named-export",elements:i});continue}if(D.isFunctionDeclaration(n)&&Yg(n)){if(n.modifiers?.some(i=>i.kind===D.SyntaxKind.DefaultKeyword)||!n.name)return{declarators:t,unfoldableReason:"`export default` is not foldable"};if(!n.body)continue;t.push({kind:"function",name:n.name.text});continue}if(D.isClassDeclaration(n)&&Yg(n))return{declarators:t,unfoldableReason:`exported class declaration "${n.name?.text??"<anonymous>"}" is not foldable`};if(!(!D.isVariableStatement(n)||!Yg(n))){if((n.declarationList.flags&D.NodeFlags.Const)===0)return{declarators:t,unfoldableReason:"exported `let`/`var` declaration is not foldable"};for(let i of n.declarationList.declarations){if(!i.initializer)return{declarators:t,unfoldableReason:"exported destructured or uninitialized declaration is not foldable"};if(D.isIdentifier(i.name)){D.isNewExpression(i.initializer)?t.push({kind:"resource",name:i.name.text,node:i.initializer}):t.push({kind:"single",name:i.name.text,node:i.initializer});continue}if(D.isObjectBindingPattern(i.name)){let r=[],o=!0;for(let s of i.name.elements){let a=Sl(s);if(a===void 0){o=!1;break}r.push({propKey:a,bindingName:s.name.getText()})}if(!o)return{declarators:t,unfoldableReason:"exported destructured or uninitialized declaration is not foldable"};t.push({kind:"destructure",node:i.initializer,elements:r});continue}return{declarators:t,unfoldableReason:"exported destructured or uninitialized declaration is not foldable"}}}}return{declarators:t}}function p$e(e){let t=new Map;for(let n of e.statements)if(D.isVariableStatement(n)&&(n.declarationList.flags&D.NodeFlags.Const)!==0){for(let i of n.declarationList.declarations)if(i.initializer){if(D.isIdentifier(i.name))t.set(i.name.text,{source:i.initializer});else if(D.isObjectBindingPattern(i.name))for(let r of i.name.elements){let o=Sl(r);o!==void 0&&t.set(r.name.getText(),{source:i.initializer,propKey:o})}}}return t}function f$e(e,t){return VD(e,t.consts,t.file,t.externals,t.crossFileFailures)}function CN(e){let t=new Map,n=new Map;for(let i of e.statements){if(!D.isImportDeclaration(i)||!D.isStringLiteral(i.moduleSpecifier))continue;let r=i.importClause;if(!r||r.isTypeOnly)continue;let o=i.moduleSpecifier.text,s=i.moduleSpecifier;if(r.name&&t.set(r.name.text,{specifier:o,imported:"default",specifierNode:s}),r.namedBindings)if(D.isNamedImports(r.namedBindings))for(let a of r.namedBindings.elements){if(a.isTypeOnly)continue;let l=a.propertyName?.text??a.name.text;t.set(a.name.text,{specifier:o,imported:l,specifierNode:s})}else D.isNamespaceImport(r.namedBindings)&&n.set(r.namedBindings.name.text,{specifier:o,specifierNode:s})}return{named:t,namespaces:n}}function m$e(e,t){let n=v5(e);if(n===void 0)return;let i=Co(t);for(;;){let r=sp(i,"node_modules",n.name);if(PN(r)){let s=G5(r,n.subpath);if(s===void 0||!Po(s))return;try{return c$e(s)}catch{return}}let o=Co(i);if(o===i)return;i=o}}function G5(e,t){let n=sp(e,"package.json");if(!PN(n))return;let i;try{i=JSON.parse(F5(n,"utf-8"))}catch{return}if(typeof i!="object"||i===null)return;let r=i.exports;if(r!==void 0){let s=k5(r,t);return s===void 0?void 0:Zg(e,s)}if(t!==".")return G5(sp(e,t),".");let o=i.main;return o!==void 0?typeof o=="string"?Zg(e,o):void 0:Zg(e,"index.js")}function nh(e,t){return W5(e,t)?.target}function W5(e,t){if(!(e.startsWith(".")||th(e)||Uk(e)))return R5(e,t)}function Qg(e,t){if(e.startsWith(".")||th(e)){let r=e.startsWith(".")?Zg(Co(t),e):e;return wN(r)??r}let n=nh(e,t);if(n!==void 0)return n;let i=m$e(e,t);return i!==void 0?i:l$e(t).resolve(e)}function h$e(){if(mx===void 0)try{mx=Qg("../params",B5(import.meta.url))}catch{mx=null}return mx}function eh(e,t){return t.has(e)?e:void 0}function z5(e,t,n){if(eh(e,n)!==void 0)return nh(e,t)===void 0?e:void 0}function U5(e,t,n,i){if(n.size===0||!_s(e,t))return;let r;try{r=sr(e,t,i)}catch{return}return n.has(r)?r:void 0}function rh(e,t){return e.startsWith(t.endsWith(RN)?t:t+RN)}function gx(e,t){return t.some(n=>rh(e,n))}function H5(e){if(e.startsWith(".")||th(e))return;let t=e.split("/");return e.startsWith("@")?t.length>2?`${t[0]}/${t[1]}`:void 0:t.length>1?t[0]:void 0}async function D5(e,t,n){let i;if(z5(e.specifier,t,n.lexiconPackages))try{i=sr(e.specifier,t,n.resolvePathCache)}catch{return}else if(i=U5(e.specifier,t,n.lexiconModules,n.resolvePathCache),i===void 0)return;let r;try{r=await ap(i,n.importCache)}catch{return}if(!(e.imported in r))return;let o=r[e.imported];if(!(typeof o=="function"&&!n.intrinsics.some(a=>a.name===e.imported&&yl(a))))return{value:o}}async function y$e(e,t,n){let i;try{i=await ap(e,n.importCache)}catch{return}if(!(!(t in i)||typeof i[t]=="function"))return{value:i[t]}}function _N(e,t){let n=t.memo.get(e);if(n)return n;let i=yx(e,t);return t.memo.set(e,i),i}async function yx(e,t){if(D.isParenthesizedExpression(e)||D.isNonNullExpression(e)||D.isAsExpression(e)||D.isSatisfiesExpression(e))return yx(e.expression,t);if(D.isIdentifier(e)){let n=t.locals.get(e.text);if(!n){if(t.externals.has(e.text)){let r=t.externals.get(e.text);if(Ps(r))throw Qe(`function "${e.text}" used as a value is not foldable`);return{value:r}}return}let i=await _N(n.source,t);if(i===void 0)return;if(n.propKey===void 0)return i;if(!Ua(i.value))throw Qe(`destructured member "${n.propKey}" is not on a composite value`);return{value:i.value[n.propKey]}}if(D.isCallExpression(e))return{value:await b$e(e,t)};if(D.isPropertyAccessExpression(e)){let n=await yx(e.expression,t);if(n===void 0)return;let i=e.name.text;if(!Ua(n.value))throw Qe(`property access ".${i}" on a non-composite value is not foldable`);return{value:n.value[i]}}}async function b$e(e,t){if(!D.isIdentifier(e.expression))throw Qe(ep(e));let n=e.expression.text,i=t.imports.get(n),r=t.externals.get(n);if(Ps(r)){let o;try{let s=Me(e,t.consts,t.intrinsics,t.externals);return await pi(s,t,!1)}catch(s){if(!(s instanceof Error))throw s;o=s}if(t.executing&&i)try{return await N5(e,n,i,t)}catch(s){throw Qe(`${o.message}; invoking it instead failed: ${s instanceof Error?s.message:String(s)}`)}throw i&&!t.sandbox?Qe(`${o.message} (the default mode does not invoke a declared project function; \`executing\` would run it and fold what it returns)`):o}if(!i)throw Qe(ep(e));return N5(e,n,i,t)}async function N5(e,t,n,i){let r=await Z5(n,i);if(r){let o=await q5(e,t,i),s=await X5(r,o,i,{file:i.file,node:e});return s?s.value:j5(e,t,n,i,o)}return j5(e,t,n,i)}async function V5(e,t,n,i){let r=kx(t,n,e,"composite factory");if(r)throw Qe(r);if(!n.executing&&_s(t.specifier,n.file)&&!t9(t,n))throw Qe(`"${e}" is imported from "${t.specifier}", which is a project file; the default mode does not invoke project-owned code (\`executing\` would run it and fold what it returns)`);let o;try{o=sr(t.specifier,n.file,n.resolvePathCache)}catch(d){throw Qe(`could not resolve import "${t.specifier}" for "${e}": ${d instanceof Error?d.message:String(d)}`)}let s;try{s=await ap(o,n.importCache)}catch(d){throw Qe(`could not import "${t.specifier}" to resolve "${e}": ${d instanceof Error?d.message:String(d)}`)}let a=s[t.imported];if(typeof a!="function")throw Qe(`"${t.imported}" from "${t.specifier}" is not a function`);SN.factoryInvocations+=1;let l=n.packageRoot!==void 0&&rh(o,n.packageRoot);_s(t.specifier,n.file)&&!l&&(SN.projectFactoryInvocations+=1);let c=a(...i),u=a.compositeName;return typeof u=="string"&&Ua(c)&&!Vi(c)&&cN(c,u),c}async function j5(e,t,n,i,r){let o=r??await q5(e,t,i);return V5(t,n,i,o)}async function w$e(e,t,n){let i=n.imports.get(e);if(!i)throw Qe(`unresolved identifier: ${e}`);let r=await Z5(i,n);if(r){let o=await X5(r,t,n);if(o)return o.value}return V5(e,i,n,t)}async function q5(e,t,n){let i=bl(t),r=[];for(let o of e.arguments){let s=await yx(o,n);if(s!==void 0){r.push(s.value);continue}let a=await v$e(o,n);try{r.push(await pi(Me(o,n.consts,n.intrinsics,n.externals),n,i))}finally{for(let l of a)n.externals.delete(l)}}return r}async function v$e(e,t){let n=new Set,i=o=>{if(D.isIdentifier(o)){k$e(o.text,t)&&n.add(o.text);return}if(!(D.isFunctionLike(o)||D.isTypeNode(o))){if(D.isPropertyAccessExpression(o))return i(o.expression);if(D.isPropertyAssignment(o))return D.isComputedPropertyName(o.name)&&i(o.name),i(o.initializer);D.forEachChild(o,i)}};i(e);let r=[];for(let o of n){let s;try{s=await _N(t.locals.get(o).source,t)}catch{continue}s&&(qt(s.value)||Vi(s.value)||xl(s.value)!==void 0)&&(t.externals.set(o,s.value),r.push(o))}return r}function k$e(e,t){if(t.externals.has(e))return!1;let n=t.locals.get(e);if(!n||n.propKey!==void 0||t.consts.get(e)!==n.source)return!1;let i=n.source;if(!D.isCallExpression(i)||!D.isIdentifier(i.expression))return!1;let r=i.expression.text;return t.imports.has(r)&&!bl(r)&&!t.intrinsics.some(o=>o.name===r)&&!Ps(t.externals.get(r))}function x$e(e,t,n){let i=t===void 0?e:`${t}\0${e}`,r=n.factoryModules.get(i);if(r)return r;let o=$$e(e,t);return n.factoryModules.set(i,o),o}async function $$e(e,t){let n;try{let o=await vx(e,"utf-8");n=D.createSourceFile(e,o,D.ScriptTarget.Latest,!0)}catch{return}let i=CN(n),r=Vg(n);for(let[o]of[...r])Qk(r,o,new Set)&&r.delete(o);return{file:e,sourceFile:n,packageRoot:t,consts:r,imports:i.named,namespaceImports:i.namespaces}}function R$e(e,t){if(e.resolved)return e.resolved;if(t.stack.includes(e.file)||t.stack.length>=EN)return Promise.resolve({externals:new Map,failures:new Map});t.stack.push(e.file);let n=e.packageRoot===void 0?[]:[e.packageRoot];return e.resolved=s9(e.file,e.imports,e.namespaceImports,t,n).finally(()=>{let i=t.stack.lastIndexOf(e.file);i!==-1&&t.stack.splice(i,1)}),e.resolved}function S$e(e,t,n){for(let i of e.sourceFile.statements)if(D.isVariableStatement(i)&&Yg(i)&&(i.declarationList.flags&D.NodeFlags.Const)!==0)for(let r of i.declarationList.declarations){if(!D.isIdentifier(r.name)||r.name.text!==t)continue;let o=r.initializer;if(!o||!D.isCallExpression(o)||!D.isIdentifier(o.expression))return;let s=e.imports.get(o.expression.text);if(!s||s.imported!=="Composite")return;let a=e9(s,{...n,file:e.file}),l=z5(s.specifier,e.file,n.lexiconPackages)!==void 0||U5(s.specifier,e.file,n.lexiconModules,n.resolvePathCache)!==void 0;if(!a&&!l)return;let[c,u]=o.arguments;return!c||!D.isArrowFunction(c)&&!D.isFunctionExpression(c)||u!==void 0&&!D.isStringLiteral(u)?void 0:{fn:c,compositeName:u?u.text:"anonymous",hostForm:!a}}}function K5(e){return/\.[cm]?tsx?$/.test(e)&&!/\.d\.[cm]?ts$/.test(e)}function A$e(e,t){let n=Co(e),i=`${t}\0${n}`;if(xN.has(i))return xN.get(i);let r;for(let o=n;hx(o)!=="node_modules";){let s=sp(o,"package.json");if(PN(s))try{if(JSON.parse(F5(s,"utf-8")).name===t){r=o;break}}catch{}let a=Co(o);if(a===o)break;o=a}return xN.set(i,r),r}function P$e(e,t,n){if(_s(e,t)){let s;try{s=sr(e,t,n.resolvePathCache)}catch{return}return n.packageRoot===void 0?{modulePath:s}:rh(s,n.packageRoot)?{modulePath:s,packageRoot:n.packageRoot}:void 0}let i=eh(e,n.lexiconPackages)??eh(H5(e)??"",n.lexiconPackages);if(i===void 0)return;let r;try{r=sr(e,t,n.resolvePathCache)}catch{return}if(!K5(r))return;let o=A$e(r,i);return o===void 0?void 0:{modulePath:r,packageRoot:o}}function O$e(e,t){let n=[];for(let i of e.statements){if(D.isExportDeclaration(i)){if(i.isTypeOnly)continue;let r=i.moduleSpecifier&&D.isStringLiteral(i.moduleSpecifier)?i.moduleSpecifier.text:void 0,o=i.exportClause;if(o===void 0){r!==void 0&&n.push({specifier:r,imported:t,star:!0});continue}if(!D.isNamedExports(o)){if(o.name.text===t)return[];continue}for(let s of o.elements)if(s.name.text===t)return r===void 0||s.isTypeOnly?[]:[{specifier:r,imported:(s.propertyName??s.name).text,star:!1}];continue}if(Yg(i)){if(D.isVariableStatement(i)){for(let r of i.declarationList.declarations)if(D.isIdentifier(r.name)&&r.name.text===t)return[]}else if((D.isFunctionDeclaration(i)||D.isClassDeclaration(i)||D.isEnumDeclaration(i))&&i.name?.text===t)return[]}}return n}async function C$e(e,t){try{let n=await vx(e,"utf-8");return n.includes(t)||/export\s*\*\s*from/.test(n)}catch{return!1}}async function J5(e,t,n,i=new Set,r=0){i.add(e.modulePath);let o=await x$e(e.modulePath,e.packageRoot,n.session);if(!o)return;let s=S$e(o,t,n);if(s)return{scope:o,definition:s};if(!(r>=E$e))for(let{specifier:a,imported:l,star:c}of O$e(o.sourceFile,t)){if(!DN(a))continue;let u;try{u=sr(a,o.file,n.resolvePathCache)}catch{continue}if(i.has(u)||!K5(u)||e.packageRoot!==void 0&&!rh(u,e.packageRoot)||c&&!await C$e(u,l))continue;let d=await J5({modulePath:u,packageRoot:e.packageRoot},l,n,i,r+1);if(d)return d}}async function Z5(e,t){let n=P$e(e.specifier,t.file,t);if(!n)return;if(t.interpretDepth>=L5)throw new bx(`interpretation depth exceeded ${L5} at "${e.imported}" \u2014 a composite chain this deep is almost certainly recursive. Falling back to run rather than invoking the factory, which would have reported this file as folded while evaluating it a different way.`,0,0);let i=await J5(n,e.imported,t);if(!i)return;let{scope:r,definition:o}=i;if(_$e(o.fn)===void 0)return{scope:r,fn:o.fn,compositeName:o.compositeName,hostForm:o.hostForm}}function _$e(e){if(e.parameters.length>1)return"a composite factory takes a single props parameter";let t=e.parameters[0];if(t){if(t.dotDotDotToken)return"a rest parameter is not interpretable";if(t.initializer)return"a defaulted parameter is not interpretable";if(D.isObjectBindingPattern(t.name)){for(let i of t.name.elements)if(Sl(i)===void 0)return"a destructured props parameter with a rest, default, or nested element is not interpretable"}else if(!D.isIdentifier(t.name))return"an array-destructured props parameter is not interpretable"}if(!D.isBlock(e.body))return yn(e.body);let n=e.body.statements;if(n.length===0)return"an empty composite factory body has no members to interpret";for(let i=0;i<n.length;i+=1){let r=n[i],o=i===n.length-1;if(D.isReturnStatement(r)){if(!o)return"an early `return` is not interpretable";if(!r.expression)return"a composite factory must return its members";let s=yn(r.expression);if(s)return s;continue}if(o)return"a composite factory body must end in `return`";if(!D.isVariableStatement(r))return`\`${D.SyntaxKind[r.kind]}\` in a composite factory body is not interpretable`;if((r.declarationList.flags&D.NodeFlags.Const)===0)return"`let`/`var` in a composite factory body is not interpretable";for(let s of r.declarationList.declarations){if(!s.initializer)return"an uninitialized `const` in a composite factory body is not interpretable";if(D.isObjectBindingPattern(s.name)){for(let l of s.name.elements)if(Sl(l)===void 0)return"a destructured `const` with a rest, default, or nested element is not interpretable"}else if(!D.isIdentifier(s.name))return"an array-destructured `const` is not interpretable";let a=yn(s.initializer);if(a)return a}}}function yn(e){if(D.isParenthesizedExpression(e)||D.isAsExpression(e)||D.isSatisfiesExpression(e)||D.isNonNullExpression(e)||D.isTypeAssertionExpression(e))return yn(e.expression);if(!(D.isStringLiteral(e)||D.isNoSubstitutionTemplateLiteral(e)||D.isNumericLiteral(e)||D.isIdentifier(e)||e.kind===D.SyntaxKind.TrueKeyword||e.kind===D.SyntaxKind.FalseKeyword||e.kind===D.SyntaxKind.NullKeyword)){if(D.isNewExpression(e)||D.isCallExpression(e)){if(!D.isIdentifier(e.expression))return D.isNewExpression(e)?`\`new ${ir(e.expression)}(...)\` needs a plain imported constructor to interpret`:ep(e);for(let t of e.arguments??[]){let n=yn(t);if(n)return n}return}if(D.isTaggedTemplateExpression(e)){if(!D.isIdentifier(e.tag))return Ug(e);if(D.isNoSubstitutionTemplateLiteral(e.template))return;for(let t of e.template.templateSpans){let n=yn(t.expression);if(n)return n}return}if(D.isTemplateExpression(e)){for(let t of e.templateSpans){let n=yn(t.expression);if(n)return n}return}if(D.isObjectLiteralExpression(e)){for(let t of e.properties)if(D.isPropertyAssignment(t)){if(!I$e(t.name))return Kk(t.name);let n=yn(t.initializer);if(n)return n}else if(D.isShorthandPropertyAssignment(t)){if(t.objectAssignmentInitializer)return Wg}else if(D.isSpreadAssignment(t)){let n=yn(t.expression);if(n)return n}else return Wg;return}if(D.isArrayLiteralExpression(e)){for(let t of e.elements){let n=yn(D.isSpreadElement(t)?t.expression:t);if(n)return n}return}return D.isPropertyAccessExpression(e)?yn(e.expression):D.isElementAccessExpression(e)?Gg(e.argumentExpression)?yn(e.expression):`dynamic element access [${ir(e.argumentExpression)}] is not interpretable`:D.isPrefixUnaryExpression(e)?qk.has(e.operator)?yn(e.operand):Jk:D.isBinaryExpression(e)?Vk.has(e.operatorToken.kind)?yn(e.left)??yn(e.right):zg(e.operatorToken.kind):D.isConditionalExpression(e)?yn(e.condition)??yn(e.whenTrue)??yn(e.whenFalse):Ug(e)}}function I$e(e){return D.isIdentifier(e)||D.isStringLiteral(e)||D.isNumericLiteral(e)}function T$e(e,t,n){let i=new Set,r=new Map,o=e.fn.parameters[0];if(o){if(D.isIdentifier(o.name))i.add(o.name.text);else if(D.isObjectBindingPattern(o.name))for(let l of o.name.elements){let c=Sl(l);c!==void 0&&D.isIdentifier(l.name)&&r.set(l.name.text,c)}}let s=new Map(t),a=e.fn.body;if(D.isBlock(a)){for(let l of a.statements)if(D.isVariableStatement(l))for(let c of l.declarationList.declarations)D.isIdentifier(c.name)&&c.initializer&&s.set(c.name.text,c.initializer)}return{composite:e.compositeName,scope:{whole:i,destructured:r},consts:s,...n?{call:n}:{}}}function D$e(e,t,n){let i=n.compositeParams;if(!i||typeof e!="object"||e===null)return;let r;for(let s of t.arguments??[])if(D.isObjectLiteralExpression(s)){r=s;break}if(!r)return;Y5(e,i);let o=O5(r,i.consts,i.scope,i.composite,i.call);for(let[s,a]of Object.entries(o))Os(e,s,a)}function Y5(e,t){t.call&&Hi(e,{compositeCall:px(t.call.file,t.call.node)})}function N$e(e,t,n){let i=n.compositeParams;if(!i||!qt(e)||!km(e))return;let r=ZZ(e);if(!r)return;let o=D.isTemplateExpression(t.template)?t.template.templateSpans.map(a=>a.expression):[];Y5(e,i);let s=C5(o,r,e.props,i.consts,i.scope,i.composite,i.call);for(let[a,l]of Object.entries(s))Os(e,a,l)}async function X5(e,t,n,i){if(t.length>1)return;let{scope:r,fn:o}=e,s=await R$e(r,n.session),a=new Map(r.consts),l=new Map(s.externals),c={file:r.file,consts:a,locals:new Map,imports:r.imports,namespaceImports:r.namespaceImports,memo:new Map,intrinsics:n.intrinsics,externals:l,crossFileFailures:s.failures,importCache:n.importCache,resolvePathCache:n.resolvePathCache,lexiconPackages:n.lexiconPackages,lexiconModules:n.lexiconModules,lexiconRoots:r.packageRoot===void 0?n.lexiconRoots:[...n.lexiconRoots,r.packageRoot],packageRoot:r.packageRoot,sandbox:n.sandbox,executing:n.executing,session:n.session,interpretDepth:n.interpretDepth+1,compositeParams:T$e(e,r.consts,i)},u=(d,p)=>{a.delete(d),l.set(d,p)};try{let d=o.parameters[0];if(d){let g=t[0];if(D.isIdentifier(d.name))u(d.name.text,g);else if(D.isObjectBindingPattern(d.name)){if(!Ua(g))return;for(let h of d.name.elements){let b=Sl(h);if(b===void 0)return;u(h.name.getText(),g[b])}}}let p=await j$e(o,c,u);if(!Ua(p))return;let f=e.hostForm?cN(p,e.compositeName):XZ(()=>p,e.compositeName)();return SN.factoryInterpretations+=1,{value:f}}catch(d){if(d instanceof bx)throw d;return}}async function j$e(e,t,n){if(!D.isBlock(e.body))return ln(e.body,t);for(let i of e.body.statements){if(D.isReturnStatement(i))return ln(i.expression,t);let r=i.declarationList.declarations;for(let o of r){let s=await ln(o.initializer,t);if(D.isIdentifier(o.name)){n(o.name.text,s);continue}if(!Ua(s))throw Qe(`destructured \`const\` source in "${ir(o.name)}" is not an object`);for(let a of o.name.elements)n(a.name.getText(),s[Sl(a)])}}throw Qe("composite factory body did not return")}async function ln(e,t){if(D.isParenthesizedExpression(e)||D.isAsExpression(e)||D.isSatisfiesExpression(e)||D.isNonNullExpression(e))return ln(e.expression,t);if(D.isNewExpression(e))return L$e(e,t);if(D.isTaggedTemplateExpression(e)){let n=(await Xg(e,t)).value;return N$e(n,e,t),n}if(D.isObjectLiteralExpression(e)){let n={};for(let i of e.properties)if(D.isPropertyAssignment(i))n[qg(i.name)]=await ln(i.initializer,t);else if(D.isShorthandPropertyAssignment(i))n[i.name.text]=await ln(i.name,t);else{let r=await ln(i.expression,t);if(r===null||typeof r!="object")throw Qe("spread source not an object");Object.assign(n,r)}return n}if(D.isArrayLiteralExpression(e)){let n=[];for(let i of e.elements)if(D.isSpreadElement(i)){let r=await ln(i.expression,t);if(!Array.isArray(r))throw Qe("spread source not an array");n.push(...r)}else n.push(await ln(i,t));return n}if(D.isConditionalExpression(e))return await ln(e.condition,t)?ln(e.whenTrue,t):ln(e.whenFalse,t);if(D.isBinaryExpression(e)){let n=D.SyntaxKind,i=e.operatorToken.kind;if(i===n.AmpersandAmpersandToken){let r=await ln(e.left,t);return r&&ln(e.right,t)}if(i===n.BarBarToken){let r=await ln(e.left,t);return r||ln(e.right,t)}if(i===n.QuestionQuestionToken){let r=await ln(e.left,t);return r??ln(e.right,t)}}return(await Xg(e,t)).value}async function L$e(e,t){if(!D.isIdentifier(e.expression))throw Qe(`\`new ${ir(e.expression)}(...)\` needs a plain imported constructor`);let n=e.expression.text,i=t.imports.get(n);if(!i)throw Qe(`constructor "${n}" is not a resolvable import`);let r=kx(i,t,n,"constructor");if(r)throw Qe(r);let o=sr(i.specifier,t.file,t.resolvePathCache),a=(await ap(o,t.importCache))[i.imported];if(typeof a!="function")throw Qe(`"${i.imported}" from "${i.specifier}" is not a constructor`);let l=[];for(let u of e.arguments??[])l.push(await ln(u,t));let c=new a(...l);return D$e(c,e,t),c}function Oo(e,t,n,i){i.set(e,t),(qt(t)||Vi(t))&&n.push([e,t])}async function IN(e,t){let n=t.imports.get(e);if(!n)throw Qe(`"${e}" is not a resolvable import`);let i=kx(n,t,e,"import");if(i)throw Qe(i);let r;try{r=sr(n.specifier,t.file,t.resolvePathCache)}catch(s){throw Qe(`could not resolve import "${n.specifier}" for "${e}": ${s instanceof Error?s.message:String(s)}`)}let o;try{o=await ap(r,t.importCache)}catch(s){throw Qe(`could not import "${n.specifier}" to resolve "${e}": ${s instanceof Error?s.message:String(s)}`)}return o[n.imported]}async function F$e(e,t){if(!M$e.test(e))throw Qe(`symbol "${e}" is not a simple dotted import reference`);let[n,...i]=e.split("."),r=await IN(n,t);for(let o of i){if(r==null)throw Qe(`symbol "${e}": "${n}" has no "${o}"`);r=r[o]}return r}function Q5(e){return e===null||typeof e!="object"?!0:dn(e)||qt(e)||Vi(e)||Ou(e)}async function pi(e,t,n){if(e===null||typeof e!="object"||Q5(e))return e;if(Array.isArray(e)){let r=[];for(let o of e)r.push(await pi(o,t,n));return r}if("__symbol"in e)return F$e(e.__symbol,t);if("__intrinsic"in e){let r=e,o=await IN(r.__intrinsic,t);if(typeof o!="function")throw Qe(`intrinsic "${r.__intrinsic}" did not resolve to a function`);let s=[];if("args"in r){for(let l of r.args)s.push(await pi(l,t,!0));return o(...s)}for(let l of r.values)s.push(await pi(l,t,!0));let a=Object.freeze(Object.defineProperty([...r.strings],"raw",{value:Object.freeze([...r.raw])}));return o(a,...s)}if("__helper"in e)return B$e(e,t);if("__compositeStep"in e){let r=e,o=[];for(let a of r.args)o.push(await pi(a,t,!1));let s=await w$e(r.__compositeStep,o,t);if(!Ua(s))throw Qe(`composite call \`${r.__compositeStep}(...)\` did not resolve to an object with a "step" member`);return s.step}if("__attrRef"in e){if(n)throw Qe("a same-file resource reference passed to a folded intrinsic or authoring helper is not foldable yet");return e}if("__resource"in e)return i9(e,t,n);let i={};for(let[r,o]of Object.entries(e))i[r]=await pi(o,t,n);return i}async function B$e(e,t){let n=e.__helper,i=t.imports.get(n);if(!i)throw Qe(`authoring helper "${n}(...)" is not a resolvable import`);if(!e9(i,t))throw Qe(`"${n}" is imported from "${i.specifier}", which is not chant's own \u2014 only chant's registered authoring helpers fold as calls`);let r=await IN(n,t);if(typeof r!="function")throw Qe(`authoring helper "${n}" did not resolve to a function`);let o=[];for(let s of e.args)o.push(await pi(s,t,!0));return r(...o)}function e9(e,t){if(Uk(e.specifier))return!0;if(!_s(e.specifier,t.file))return!1;let n;try{n=sr(e.specifier,t.file,t.resolvePathCache)}catch{return!1}return TN(n)}function t9(e,t){let n=nh(e.specifier,t.file)!==void 0;if(!n&&eh(e.specifier,t.lexiconPackages)!==void 0)return!0;let i=H5(e.specifier);if(!n&&i!==void 0&&eh(i,t.lexiconPackages)!==void 0)return!0;if(!n&&!DN(e.specifier)&&!Uk(e.specifier))return!1;let r;try{r=sr(e.specifier,t.file,t.resolvePathCache)}catch{return!1}return t.lexiconModules.has(r)||gx(r,t.lexiconRoots)?!0:TN(r)}function kx(e,t,n,i){if(t.sandbox&&!t9(e,t))return`${i} "${n}" is imported from "${e.specifier}", which is neither chant's own nor an active lexicon \u2014 under --sandbox it is executed in the sandboxed child, not in this process`}function G$e(){if(!$N){let e=Co(Co(B5(import.meta.url))),t=hx(e),n=t==="dist"?sp(Co(e),"src"):t==="src"?sp(Co(e),"dist"):void 0;$N=n?[e,n]:[e]}return $N}function TN(e){return G$e().some(t=>e===t||e.startsWith(t+RN))}async function M5(e,t,n){let i={};for(let[r,o]of Object.entries(e))i[r]=await pi(o,t,n);return i}async function n9(e,t,n){if(e.args){let r=[];for(let o of e.args)r.push(await pi(o,t,n));return r}return[await M5(e.props,t,n),e.attributes?await M5(e.attributes,t,n):void 0]}async function r9(e,t,n,i){let r=n.imports.get(e);if(!r)throw Qe(`constructor "${e}"${i} is not a resolvable import`);let o=kx(r,n,e,"constructor");if(o)throw Qe(o);let s;try{s=sr(r.specifier,n.file,n.resolvePathCache)}catch(c){throw Qe(`could not resolve import "${r.specifier}" for "${e}": ${c instanceof Error?c.message:String(c)}`)}let a;try{a=await ap(s,n.importCache)}catch(c){throw Qe(`could not import "${r.specifier}" to resolve "${e}": ${c instanceof Error?c.message:String(c)}`)}let l=a[r.imported];if(typeof l!="function")throw Qe(`"${r.imported}" from "${r.specifier}" is not a constructor`);return new l(...t)}async function i9(e,t,n){let i=await n9(e,t,n);return r9(e.__resource,i,t,"")}function W$e(e){let t=new Set,n=e.session.buildParams;if(!n)return t;for(let[i,r]of e.externals)r===n&&t.add(i);return t}function o9(e,t,n){if(typeof e!="object"||e===null)return;let i=W$e(n),r={values:n.hostValues??new Set,eagerCalls:new Set(n.intrinsics.filter(s=>yl(s)).map(s=>s.name))},o;for(let s of t.arguments??[])if(D.isObjectLiteralExpression(s)){o=s;break}if(o)for(let[s,a]of Object.entries(A5(o,n.consts,i,r)))Os(e,s,a)}async function z$e(e){let t=new Map;for(let[n,i]of e.consts){if(D.isTaggedTemplateExpression(i)&&D.isIdentifier(i.tag)&&e.intrinsics.some(r=>r.name===i.tag.text&&Wk(r))){try{let r=await pi(Me(i,e.consts,e.intrinsics,e.externals),e,!1);t.set(i,r),Q5(r)&&e.externals.set(n,r)}catch(r){e.prebuildFailures?.set(n,Rl(r,e))}continue}if(!(!D.isNewExpression(i)||!D.isIdentifier(i.expression)))try{let r=ex(i,e.consts,e.intrinsics,e.externals),o=await i9(r,e,!1);o9(o,i,e),t.set(i,o),e.externals.set(n,o)}catch(r){e.prebuildFailures?.set(n,Rl(r,e))}}return t}async function U$e(e,t,n){let i;try{i=ex(t,n.consts,n.intrinsics,n.externals)}catch(o){if(o instanceof Eo)return{ok:!1,reason:`"${e}" is not foldable: ${Rl(o,n)}`};throw o}let r;try{r=await n9(i,n,!1)}catch(o){return{ok:!1,reason:`"${e}" is not foldable: ${Rl(o,n)}`}}try{let o=await r9(i.__resource,r,n,` for "${e}"`);return o9(o,t,n),{ok:!0,entity:o}}catch(o){return{ok:!1,reason:o instanceof Error?o.message:String(o)}}}function Rl(e,t){if(!(e instanceof Error))return String(e);let n=H$e.exec(e.message);if(n){let r=t.crossFileFailures.get(n[1]);if(r)return`${e.message} (${r})`}let i=V$e.exec(e.message);if(i){let r=t.prebuildFailures?.get(i[1]);if(r)return`${e.message} (${r})`}return e.message}function q$e(e){return D.isCallExpression(e)?`${ir(e.expression)}(...)`:ir(e)}function op(e,t){let{line:n,column:i}=qD(e);return new Eo(t,n,i).message}function wx(e,t){let n=t.stack.indexOf(e);if(n!==-1){let o=[...t.stack.slice(n),e].map(s=>hx(s));return Promise.resolve({ok:!1,reason:`import cycle: ${o.join(" -> ")}`})}let i=t.cache.get(e);if(i)return i;if(t.stack.length>=EN){let o=[...t.stack.slice(-5),e].map(s=>hx(s));return Promise.resolve({ok:!1,reason:`cross-file resolution depth exceeded ${EN} (...-> ${o.join(" -> ")}) \u2014 this is almost certainly a resolution bug (memoization not taking effect), not a genuinely thousand-file-deep import chain`})}t.stack.push(e);let r=K$e(e,t).finally(()=>{let o=t.stack.lastIndexOf(e);o!==-1&&t.stack.splice(o,1)});return t.cache.set(e,r),r}function DN(e){return e.startsWith(".")||th(e)}function _s(e,t){return DN(e)||nh(e,t)!==void 0}async function s9(e,t,n,i,r=[]){let o=r.length===0?i.lexiconRoots:[...i.lexiconRoots,...r],s=new Map,a=new Map,l=new Set,c=new Set;for(let[u,d]of t){if(i.buildParams&&d.imported==="params"){if(d.specifier===g$e){s.set(u,i.buildParams);continue}if(_s(d.specifier,e))try{if(sr(d.specifier,e,i.resolvePathCache)===h$e()){s.set(u,i.buildParams);continue}}catch{}}if(!_s(d.specifier,e)){let g=await D5(d,e,i);if(g){s.set(u,g.value),c.add(u);continue}let h=W5(d.specifier,e);h&&a.set(u,op(d.specifierNode,`tsconfig paths entry "${h.key}" matches "${d.specifier}" but names no file`));continue}let p;try{p=sr(d.specifier,e,i.resolvePathCache)}catch{continue}if(i.lexiconModules.has(p)){let g=await D5(d,e,i);g&&(s.set(u,g.value),c.add(u));continue}if(gx(p,r)){let g=await y$e(p,d.imported,i);g&&(s.set(u,g.value),c.add(u));continue}if(gx(p,o))continue;let f=await wx(p,i);if(!f.ok){a.set(u,op(d.specifierNode,f.reason));continue}if(f.exportedValues.has(d.imported)){let g=f.exportedValues.get(d.imported);s.set(u,g),AN(g)&&l.add(p)}else a.set(u,op(d.specifierNode,`"${d.imported}" is not exported by "${d.specifier}"`))}for(let[u,d]of n){if(!_s(d.specifier,e))continue;let p;try{p=sr(d.specifier,e,i.resolvePathCache)}catch{continue}if(i.lexiconModules.has(p)||gx(p,o))continue;let f=await wx(p,i);if(!f.ok){a.set(u,op(d.specifierNode,f.reason));continue}s.set(u,Object.fromEntries(f.exportedValues));for(let g of f.exportedValues.values())if(AN(g)){l.add(p);break}}return{externals:s,failures:a,liveSources:l,hostValues:c}}function AN(e){return Ps(e)?!1:e!==null&&(typeof e=="object"||typeof e=="function")}async function Xg(e,t){let n=await _N(e,t);if(n!==void 0)return n;let i=Me(e,t.consts,t.intrinsics,t.externals);return{value:await pi(i,t,!1)}}async function K$e(e,t){if(TN(e))return{ok:!1,reason:"chant's own module is not project source"};try{let n=await vx(e,"utf-8"),i=D.createSourceFile(e,n,D.ScriptTarget.Latest,!0),r=d$e(i);if(r.unfoldableReason)return{ok:!1,reason:r.unfoldableReason};if(r.declarators.length===0)return{ok:!1,reason:"no foldable resource exports"};let o=CN(i),{externals:s,failures:a,liveSources:l,hostValues:c}=await s9(e,o.named,o.namespaces,t),u={file:e,consts:Vg(i),locals:p$e(i),imports:o.named,namespaceImports:o.namespaces,memo:new Map,intrinsics:t.intrinsics,externals:s,hostValues:c,crossFileFailures:a,importCache:t.importCache,resolvePathCache:t.resolvePathCache,lexiconPackages:t.lexiconPackages,lexiconModules:t.lexiconModules,lexiconRoots:t.lexiconRoots,sandbox:t.sandbox,executing:t.executing,session:t,interpretDepth:0,prebuildFailures:new Map},d=await z$e(u),p=f$e(i,u);for(let[h,b]of p)u.externals.has(h)||u.externals.set(h,b);let f=[],g=new Map;for(let h of r.declarators){if(h.kind==="function"){Oo(h.name,p.get(h.name),f,g);continue}if(h.kind==="resource"){let x=d.get(h.node);if(x!==void 0){Oo(h.name,x,f,g);continue}let k=await U$e(h.name,h.node,u);if(!k.ok)return k;Oo(h.name,k.entity,f,g);continue}if(h.kind==="single"){let x=D.isIdentifier(h.node)?u.externals.get(h.node.text):void 0,k=p.get(h.name)??(Ps(x)?x:void 0);if(k){Oo(h.name,k,f,g);continue}if(d.has(h.node)){Oo(h.name,d.get(h.node),f,g);continue}let R;try{R=(await Xg(h.node,u)).value}catch($){return{ok:!1,reason:`"${h.name}" is not foldable: ${Rl($,u)}`}}Oo(h.name,R,f,g);continue}if(h.kind==="destructure"){let x,k=h.elements.map($=>$.bindingName).join(", "),R=q$e(h.node);try{x=(await Xg(h.node,u)).value}catch($){return{ok:!1,reason:`"${k}" (destructured from ${R}) is not foldable: ${Rl($,u)}`}}if(!Ua(x))return{ok:!1,reason:`"${k}" (destructured from ${R}) is not foldable: not a composite call or object`};for(let{propKey:$,bindingName:_}of h.elements)Oo(_,x[$],f,g);continue}if(h.kind==="named-export"){for(let{localNameNode:x,exportedName:k}of h.elements){let R=p.get(x.text);if(R){Oo(k,R,f,g);continue}let $;try{$=(await Xg(x,u)).value}catch(_){return{ok:!1,reason:`exported "${k}" is not foldable: ${Rl(_,u)}`}}Oo(k,$,f,g)}continue}let b;try{b=sr(h.specifier,e,t.resolvePathCache)}catch(x){return{ok:!1,reason:`could not resolve re-export "${h.specifier}": ${x instanceof Error?x.message:String(x)}`}}let w=await wx(b,t);if(!w.ok)return{ok:!1,reason:`re-export from "${h.specifier}" is not foldable: ${op(h.specifierNode,w.reason)}`};for(let{imported:x,exportedName:k}of h.elements){if(!w.exportedValues.has(x))return{ok:!1,reason:op(h.specifierNode,`"${x}" is not exported by "${h.specifier}"`)};let R=w.exportedValues.get(x);AN(R)&&l.add(b),Oo(k,R,f,g)}}return{ok:!0,entities:f,exportedValues:g,liveSources:l}}catch(n){return{ok:!1,reason:n instanceof Error?n.message:String(n)}}}async function a9(e,t=[],n){return wx(e,n??ON(t))}async function J$e(e){let t=new Set(e),n=new Map;for(let i of e){let r=new Set,o=s=>{if(!_s(s,i))return;let a;try{a=Qg(s,i)}catch{return}t.has(a)&&r.add(a)};try{let s=await vx(i,"utf-8"),a=D.createSourceFile(i,s,D.ScriptTarget.Latest,!0),l=CN(a);for(let c of l.named.values())o(c.specifier);for(let c of l.namespaces.values())o(c.specifier);for(let c of a.statements)D.isExportDeclaration(c)&&!c.isTypeOnly&&c.moduleSpecifier&&D.isStringLiteral(c.moduleSpecifier)&&o(c.moduleSpecifier.text)}catch{}n.set(i,r)}return n}async function NN(e,t,n){let i=new Set(e),r=await J$e(e),o=new Map;for(let[c,u]of n??[])if(i.has(c))for(let d of u){if(!i.has(d))continue;let p=r.get(d);p||(p=new Set,r.set(d,p)),p.add(c);let f=o.get(d);f||(f=new Set,o.set(d,f)),f.add(c)}let s=new Set(e.filter(c=>t.get(c)!==!0)),a=new Map,l=[...s];for(;l.length>0;){let c=l.shift();for(let u of r.get(c)??[])if(!s.has(u)){s.add(u);let d=!o.get(c)?.has(u);a.set(u,{from:c,kind:d?"importer":"capture"}),l.push(u)}}return{tainted:s,reachedBy:a}}var D,T5,SN,g$e,mx,L5,bx,E$e,xN,M$e,$N,H$e,V$e,EN,jN=v(()=>{"use strict";D=Le(Ke(),1);Pn();ox();Wt();Qo();tx();Hk();xn();S5();wl();cx();I5();di();fx();lx();uN();So();T5=new Map;SN={factoryInvocations:0,projectFactoryInvocations:0,factoryInterpretations:0};g$e="@intentius/chant/params";L5=16,bx=class extends Eo{};E$e=8;xN=new Map;M$e=/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/;H$e=/unresolved identifier: (\S+)$/,V$e=/same-file resource `([^`]+)` used as a value is not foldable/;EN=200});function LN(e){return typeof e=="object"&&e!==null&&c9 in e&&e[c9]===!0}var c9,xx=v(()=>{"use strict";c9=Symbol.for("chant.childProject")});function _o(e,t){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(r=>_o(r,t));let n=e;if("__attrRef"in n){let{entity:r,attribute:o}=n.__attrRef,s=t.get(r);if(!s)throw new Error(`decodeEntitySet: __attrRef refers to unknown entity "${r}"`);let a=new es(s,o);return a._setLogicalName(r),a}if("__entityRef"in n){let{entity:r}=n.__entityRef,o=t.get(r);if(!o)throw new Error(`decodeEntitySet: __entityRef refers to unknown entity "${r}"`);return o}if("__property"in n){let{lexicon:r,entityType:o,props:s}=n.__property,a={};return Object.defineProperty(a,Li,{value:!0,enumerable:!1}),Object.defineProperty(a,"lexicon",{value:r,enumerable:!1,configurable:!0}),Object.defineProperty(a,"entityType",{value:o,enumerable:!1,configurable:!0}),Object.defineProperty(a,"kind",{value:"property",enumerable:!1,configurable:!0}),s!==void 0&&Object.defineProperty(a,"props",{value:_o(s,t),enumerable:!1,configurable:!0}),a}if("__intrinsic"in n){let r=n.__intrinsic,o=_o(r.value,t),s=r.refs.map(l=>_o(l,t)),a={[Ci]:!0,__chantWireRefs:s,toJSON(){return o}};if("yaml"in r){let l=_o(r.yaml,t);a.toYAML=()=>l}return a}let i={};for(let[r,o]of Object.entries(n))i[r]=_o(o,t);return i}function Z$e(e){let t={};for(let n of e.markers)Object.defineProperty(t,Symbol.for(n),{value:!0,enumerable:!1,configurable:!0});return Li in t||Object.defineProperty(t,Li,{value:!0,enumerable:!1}),Object.defineProperty(t,"lexicon",{value:e.lexicon,enumerable:!1,configurable:!0}),Object.defineProperty(t,"entityType",{value:e.entityType,enumerable:!1,configurable:!0}),e.kind!==void 0&&Object.defineProperty(t,"kind",{value:e.kind,enumerable:!1,configurable:!0}),t}function ih(e){let t=new Map;for(let i of e.entities)i.form==="declarable"&&t.set(i.name,Z$e(i));let n=new Map;for(let i of e.entities){if(i.form==="declarable"){let s=t.get(i.name);i.props!==void 0&&Object.defineProperty(s,"props",{value:_o(i.props,t),enumerable:!1,configurable:!0}),i.attributes!==void 0&&Object.defineProperty(s,"attributes",{value:_o(i.attributes,t),enumerable:!1,configurable:!0});for(let[a,l]of Object.entries(i.extra??{}))s[a]=_o(l,t);n.set(i.name,s);continue}let r=_o(i.ref,t),o=new np(r,i.outputName);t.set(i.name,o),n.set(i.name,o)}return n}var $x=v(()=>{"use strict";Pn();Cu();Qo();Wt();kl();xx()});function Y$e(e){return typeof e=="object"&&e!==null&&e.code==="ERR_ACCESS_DENIED"}function l9(e,t,n="import"){if(Y$e(t)){let r=typeof t.permission=="string"?t.permission:"an unrecognized sandboxed operation",o=typeof t.resource=="string"?` (${t.resource})`:"",s=e?`"${e}"`:"sandboxed run-fallback code";return new Hn(e,`sandbox denied ${r}${o}: ${s} attempted an operation outside the sandbox's allowlist`,"permission")}let i=t instanceof Error?t.message:String(t);return new Hn(e,i,n)}var u9=v(()=>{"use strict";or()});var p9={};_e(p9,{runFallbackFilesSandboxed:()=>nRe});import{realpathSync as X$e,rmSync as Q$e}from"node:fs";import{resolve as d9}from"node:path";function tRe(e){return typeof e=="object"&&e!==null&&"entitySet"in e&&"errors"in e}async function nRe(e,t){if(e.length===0)return{entities:new Map,errors:[],bundleMs:0,bundleBytes:0,provenanceByName:{}};let n=zW({files:e,buildRoot:t}),{bundlePath:i,bundleDir:r,externalReadPaths:o,durationMs:s,bytes:a}=await qb(n);try{let l;try{l=X$e(d9(t))}catch{l=d9(t)}let c=await Yb({bundlePath:i,bundleDir:r,projectRealpath:l,externalReadPaths:o,env:{PATH:process.env.PATH??""},timeoutMs:eRe,label:"sandboxed run",outputPrefix:"[sandbox:run]"},tRe),u=(c.errors??[]).map(f=>new Hn(f.file,f.message,f.type)),d=c.provenanceByName??{};return c.fatal?{entities:new Map,errors:u,bundleMs:s,bundleBytes:a,provenanceByName:d}:{entities:ih(c.entitySet??{entities:[]}),errors:u,bundleMs:s,bundleBytes:a,provenanceByName:d}}catch(l){return{entities:new Map,errors:[l9("",l,"import")],provenanceByName:{},bundleMs:s,bundleBytes:a}}finally{Q$e(r,{recursive:!0,force:!0})}}var eRe,f9=v(()=>{"use strict";or();$x();kO();u9();$O();RO();eRe=12e4});import{relative as rRe}from"node:path";import{existsSync as iRe,readFileSync as oRe}from"node:fs";import{dirname as sRe,join as aRe,parse as cRe}from"node:path";function lRe(e,t){if(Object.keys(t).length!==0)try{let n=uRe(e);if(!n)return;let i=JSON.parse(oRe(n,"utf-8"));if(i.type==="module")return;let r=i.type?`"type": "${i.type}"`:"no `type` field",o=Object.keys(t).sort().join(", ");console.error(`warning: ${n} has ${r}, but chant is ESM \u2014 build parameters (${o}) will read as empty in project source on the run path, so declarations conditioned on them take their default branch. Set "type": "module". (chant #1421)`)}catch{}}function uRe(e){let t=e,{root:n}=cRe(t);for(;;){let i=aRe(t,"package.json");if(iRe(i))return i;if(t===n)return;let r=sRe(t);if(r===t)return;t=r}}async function MN(e,t){let n=[],i=[],r=[],o=iN(t?.buildParams??[]);xO(o),lRe(e,o);let s=await pk(e);i.push(...s);let a=[],l=[],c=new Map;if(t?.sandbox===!0&&t?.executing===!0)throw new Error("discover: `sandbox` and `executing` are mutually exclusive \u2014 the first refuses to import project code and the second exists to invoke it. Pass one.");let u=t?.fold?ON(t.intrinsics,o,t.lexicons,t.sandbox===!0,t.lexiconPackages??[],t.executing===!0,s):void 0;if(t?.fold)for(let h of s)c.set(h,await a9(h,t.intrinsics,u));let d=t?.fold?await NN(s,new Map(s.map(h=>[h,c.get(h)?.ok===!0])),new Map(s.flatMap(h=>{let b=c.get(h);return b?.ok===!0?[[h,b.liveSources]]:[]}))):{tainted:new Set,reachedBy:new Map},p=d.tainted;for(let h of s){if(t?.fold){let b=c.get(h);if(b.ok&&!p.has(h)){a.push({file:h,exports:Object.fromEntries(b.exportedValues)}),r.push({file:h,mode:"fold",resourceCount:b.entities.length});continue}let w=d.reachedBy.get(h),x=b.ok?w?.kind==="capture"?`would fold in isolation, but it captured objects from ${rRe(process.cwd(),w.from)}, which falls back to run \u2014 folding independently would hold an instance the build never collects`:"would fold in isolation, but a file that imports it (directly or transitively) falls back to run \u2014 folding independently would create a duplicate, non-identical instance":b.reason;r.push({file:h,mode:"run",reason:x,reverseTainted:b.ok})}if(t?.sandbox){l.push(h);continue}try{let b=await ax(h);a.push({file:h,exports:b})}catch(b){if(b instanceof Error&&b.name==="DiscoveryError")n.push(b);else{let{DiscoveryError:w}=await Promise.resolve().then(()=>(or(),vl));n.push(new w(h,b instanceof Error?b.message:String(b),"import"))}}}let f=new Map;try{f=pN(a,e)}catch(h){if(h instanceof Error&&h.name==="DiscoveryError")n.push(h);else{let{DiscoveryError:b}=await Promise.resolve().then(()=>(or(),vl));n.push(new b("",h instanceof Error?h.message:String(h),"resolution"))}return{entities:new Map,dependencies:new Map,sourceFiles:i,errors:n,foldDecisions:r}}if(t?.sandbox&&l.length>0)try{let{runFallbackFilesSandboxed:h}=await Promise.resolve().then(()=>(f9(),p9)),b=await h(l,e);n.push(...b.errors);for(let[k,R]of b.entities){if(f.has(k)){let{DiscoveryError:$}=await Promise.resolve().then(()=>(or(),vl)),_=b.provenanceByName[k]??e;n.push(new $(_,`Duplicate export name "${k}" found`,"resolution"));continue}f.set(k,R)}let w=new Map(s.map((k,R)=>[k,R])),x=[...f.entries()].map(([k,R])=>{let $=Ao(R)?.sourceFile??b.provenanceByName[k],_=$!==void 0?w.get($):void 0;return{name:k,entity:R,index:_??Number.MAX_SAFE_INTEGER}});x.sort((k,R)=>k.index-R.index),f=new Map(x.map(({name:k,entity:R})=>[k,R]))}catch(h){let{DiscoveryError:b}=await Promise.resolve().then(()=>(or(),vl));n.push(new b(e,h instanceof Error?h.message:String(h),"resolution"))}try{m5(f)}catch(h){let{DiscoveryError:b}=await Promise.resolve().then(()=>(or(),vl));n.push(new b("",h instanceof Error?h.message:String(h),"resolution"))}let g=new Map;try{g=ux(f)}catch(h){let{DiscoveryError:b}=await Promise.resolve().then(()=>(or(),vl));n.push(new b("",h instanceof Error?h.message:String(h),"resolution"))}return{entities:f,dependencies:g,sourceFiles:i,errors:n,foldDecisions:r}}var Rx=v(()=>{"use strict";ll();cx();lx();gN();dx();jN();di();Kg();Kb()});var m9=v(()=>{"use strict"});function h9(e){return typeof e=="object"&&e!==null&&g9 in e&&e[g9]===!0}var g9,FN=v(()=>{"use strict";Pn();g9=Symbol.for("chant.scenario")});function y9(e,t,n){let i=function(r,o){Object.defineProperty(this,Li,{value:!0,enumerable:!1}),Object.defineProperty(this,"lexicon",{value:t,enumerable:!1}),Object.defineProperty(this,"entityType",{value:e,enumerable:!1}),Object.defineProperty(this,"kind",{value:"resource",enumerable:!1}),Object.defineProperty(this,"props",{value:r??{},enumerable:!1,configurable:!0}),Object.defineProperty(this,"attributes",{value:o??{},enumerable:!1,configurable:!0}),Object.defineProperty(this,"Ref",{value:this,enumerable:!1});for(let[s,a]of Object.entries(n))Object.defineProperty(this,s,{value:new es(this,a),enumerable:!0,writable:!1})};return Object.defineProperty(i,"name",{value:e.split("::").pop()??e}),i}var BN=v(()=>{"use strict";Pn();Cu()});function w9(e){return e?.entityType===b9}var b9,GN,Sx=v(()=>{"use strict";BN();b9="Chant::Op",GN=y9(b9,"chant",{})});var v9=v(()=>{"use strict";$x();Rx();$x()});var A9={};_e(A9,{build:()=>oh,buildFromEntitiesJson:()=>hRe,collectLexiconOutputs:()=>$9,computeStackGraph:()=>k9,detectCrossLexiconRefs:()=>R9,isStackMember:()=>Ex,mergeBuildRootEntities:()=>S9,partitionByLexicon:()=>x9});import{statSync as pRe}from"node:fs";import{resolve as WN}from"node:path";function Ex(e){return!zr(e)&&!n5(e)&&!h9(e)&&!w9(e)}function k9(e,t){let n=[],i=new Set,r=(p,f)=>{if(typeof p!="string"||typeof f!="string"||p===f)return;let g=`${p}\0${f}`;i.has(g)||(i.add(g),n.push({from:p,to:f}))},o=(p,f,g)=>{if(!(p==null||typeof p!="object")&&!g.has(p)){if(g.add(p),dn(p)){let h=p.parent.deref(),b=h?h.lexicon:void 0;typeof b=="string"&&b!==f&&r(f,b);return}if(!zr(p)){if(Array.isArray(p)){for(let h of p)o(h,f,g);return}for(let h of Object.values(p))o(h,f,g)}}};for(let[,p]of e){if(!Ex(p))continue;let f=p.lexicon,g=new Set;for(let h of Object.values(p))o(h,f,g);"props"in p&&typeof p.props=="object"&&p.props!==null&&o(p.props,f,g)}let s=t.length?[...t]:[...new Set([...e.values()].filter(Ex).map(p=>p.lexicon))],a=new Map;for(let p of s)a.set(p,new Set);for(let{from:p,to:f}of n)a.has(p)||a.set(p,new Set),a.has(f)||a.set(f,new Set),a.get(p).add(f);let l=new Set(a.keys()),c=[],u=[];for(;l.size>0;){let p=[...l].filter(f=>[...a.get(f)].every(g=>!l.has(g))).sort();if(p.length===0)break;for(let f of p)l.delete(f),u.push(f);c.push(p)}let d=l.size>0?[[...l].sort()]:[];return n.sort((p,f)=>`${p.from}\0${p.to}`.localeCompare(`${f.from}\0${f.to}`)),{nodes:[...s].sort(),edges:n,order:u,waves:c,cycles:d}}function x9(e){let t=new Map;for(let[n,i]of e){if(!Ex(i))continue;let r=i.lexicon;t.has(r)||t.set(r,new Map),t.get(r).set(n,i)}return t}function $9(e){let t=[],n=new Set;function i(r){if(!(r==null||typeof r!="object")&&!n.has(r)){if(n.add(r),zr(r)){t.push(r);return}if(Array.isArray(r)){for(let o of r)i(o);return}for(let o of Object.values(r))i(o)}}for(let[r,o]of e){if(zr(o)){let s=o;if(s._literalValue===null){let a=s._sourceParent?.deref(),l=r;if(a){for(let[c,u]of e)if(u===a){l=c;break}}s._setSourceEntity(l)}t.push(s);continue}if("props"in o&&typeof o.props=="object"&&o.props!==null){let s=t.length;i(o.props);for(let a=s;a<t.length;a++)!t[a].sourceEntity&&t[a]._literalValue===null&&t[a]._setSourceEntity(r)}}return t}function R9(e){let t=[],n=new Set,i=new Map;for(let[o,s]of e)i.set(s,o);function r(o,s,a){if(!(o==null||typeof o!="object")&&!a.has(o)){if(a.add(o),dn(o)){let l=o.parent.deref();if(!l)return;let c=l.lexicon;if(typeof c!="string")return;if(c!==s){let u=i.get(l);if(!u)return;let d=`${u}_${o.attribute}`;n.has(d)||(n.add(d),t.push(np.auto(o,u)))}return}if(!zr(o)&&!i.has(o)){if(Array.isArray(o)){for(let l of o)r(l,s,a);return}for(let l of Object.values(o))r(l,s,a)}}}for(let[,o]of e){let s=new Set,a=o.lexicon;for(let l of Object.values(o))r(l,a,s);"props"in o&&typeof o.props=="object"&&o.props!==null&&r(o.props,a,s)}return t}function fRe(e,t){let n=new Map;for(let a of e)n.set(a,new Set);for(let a of t)for(let l of e)l!==a.sourceLexicon&&n.get(l)?.add(a.sourceLexicon);let i=[],r=new Set,o=new Set;function s(a){if(!r.has(a)&&!o.has(a)){o.add(a);for(let l of n.get(a)??[])s(l);o.delete(a),r.add(a),i.push(a)}}for(let a of e)s(a);return i}function mRe(e,t,n){let i={};for(let r of t)i[r.outputName]={source:r.sourceLexicon,entity:r.sourceEntity,attribute:r.sourceAttribute??""};return{lexicons:e,outputs:i,deployOrder:fRe(e,t),stackGraph:k9(n,e)}}function gRe(e){try{return pRe(e).isDirectory()?WN(e):void 0}catch{return}}async function S9(e,t,n){let i=[],r=[];for(let o of t)try{let s=await o({entities:e,...n!==void 0?{sourceDir:n}:{}});i.push(...s.warnings??[]);for(let[a,l]of s.entities){if(e.has(a)){r.push(`Build-root entity "${a}" collides with a discovered entity of the same name`);continue}e.set(a,l)}}catch(s){r.push(s instanceof Error?s.message:String(s))}return{warnings:i,errors:r}}async function oh(e,t,n,i){let r=await MN(e,{fold:i?.fold,intrinsics:i?.intrinsics,lexicons:i?.lexicons,lexiconPackages:i?.lexiconPackages,sandbox:i?.sandbox,executing:i?.executing,buildParams:i?.buildParams});return E9(r,e,t,n,i)}async function E9(e,t,n,i,r){let o=[],s=[];s.push(...e.errors);let a={};for(let[$,_]of e.dependencies)a[$]=Array.from(_);try{f5(a)}catch($){$ instanceof Error&&$.name==="BuildError"?s.push($):s.push(new Cs("",$ instanceof Error?$.message:String($)))}let l=WN(t),c=i?new Set(i):new Set;c.add(l);for(let[$,_]of e.entities)if(LN(_)){let T=WN(_.projectPath);if(c.has(T)){s.push(new Cs(T,`Circular nested stack: ${[...c].join(" \u2192 ")} \u2192 ${T}`));continue}let C=await oh(T,n,c,r);if(_.buildResult=C,C.errors.length>0)for(let K of C.errors)s.push(K)}if(!i&&r?.buildRoots){let $=await S9(e.entities,r.buildRoots,gRe(t));o.push(...$.warnings);for(let _ of $.errors)s.push(new Cs("",_))}let u=x9(e.entities),d=new Map;for(let $ of n)d.set($.name,$);let p=$9(e.entities),f=R9(e.entities),g=p.map($=>({parent:$._sourceParent?.deref(),attribute:$.sourceAttribute})),h=[...p,...f.filter($=>{let _=$._sourceParent?.deref();return!g.some(T=>T.parent===_&&T.attribute===$.sourceAttribute)})],b=new Map,w=[];for(let $ of h){if(!$.sourceLexicon){w.push($);continue}b.has($.sourceLexicon)||b.set($.sourceLexicon,[]),b.get($.sourceLexicon).push($)}let x=new Map;for(let[$,_]of u){let T=d.get($),{applyBound:C,receipts:K}=rq(_);if(T){let O=[...b.get($)??[],...w],pe=T.serialize(C,O,{ownership:r?.ownership,config:r?.config,...r?.telemetry?{telemetry:r.telemetry}:{},...K.size>0?{receipts:K}:{}});if(typeof pe!="string"&&pe.warnings)for(let F of pe.warnings)o.push(F);x.set($,pe)}else C.size===0&&K.size>0||o.push(`No serializer found for lexicon "${$}". List the lexicon in chant.config.ts.`)}let k=Array.from(u.keys()),R=mRe(k,h,e.entities);return{outputs:x,entities:e.entities,dependencies:e.dependencies,warnings:o,errors:s,manifest:R,sourceFileCount:e.sourceFiles.length,foldDecisions:e.foldDecisions,lexiconVersions:{...r?.lexiconVersions??{}},buildParams:r?.buildParams??[],foldProvenance:kN(e.entities,Ao)}}async function hRe(e,t,n="<json-entity-set>",i,r){let o=ih(e.entitySet),s=ux(o),a=e.errors.map(c=>new Hn(c.file,c.message,c.type)),l={entities:o,dependencies:s,sourceFiles:e.sourceFiles,errors:a,foldDecisions:e.foldDecisions};return E9(l,n,t,i,r)}var cp=v(()=>{"use strict";di();fx();or();kl();tN();er();FN();Sx();Wt();xx();Rx();v9();dx();mN()});var N9={};_e(N9,{GRAPH_IR_VERSION:()=>Ax,buildGraphIr:()=>D9,buildLiveGraphIr:()=>RRe,collectUnobserved:()=>SRe,entityReferences:()=>P9,entityStack:()=>O9,overlayGraphs:()=>ERe,sourceOverlayGraphs:()=>ARe});import{relative as yRe,isAbsolute as bRe}from"node:path";function wRe(e){return typeof e=="object"&&e!==null&&typeof e.to=="string"}function P9(e){let t=e.references;return Array.isArray(t)?t.filter(wRe):[]}function O9(e){let t=e.stack;return typeof t=="string"&&t.length>0?t:void 0}function vRe(e){return!(zr(e)||e.kind==="property")}function kRe(e,t){if(e){if(t&&bRe(e)){let n=yRe(t,e);return n.startsWith("..")?e:n}return e}}function C9(e){try{let t=e.toJSON?.();if(t&&typeof t=="object"&&typeof t.Ref=="string")return t.Ref}catch{}}function _9(e,t){let n=e.parent.deref();return e.getLogicalName()??(n?t.get(n):void 0)}function I9(e,t,n){let i=t.get(e);return i!==void 0&&n.has(i)?i:void 0}function zN(e,t,n,i){if(e===null)return null;let r=typeof e;if(r==="string"||r==="number"||r==="boolean")return e;if(r!=="object")return;if(dn(e)){let s=_9(e,n);return{$ref:s?`${s}.${e.attribute}`:e.attribute}}if(e[Ci]===!0){let s=C9(e);return s&&i.has(s)?{$ref:s}:{$intrinsic:!0}}if(t.has(e))return;if(t.add(e),qt(e)){let s=I9(e,n,i);if(s)return{$ref:s};let a=T9(e,t,n,i);return t.delete(e),a}if(Array.isArray(e)){let s=e.map(a=>zN(a,t,n,i)).filter(a=>a!==void 0);return t.delete(e),s}let o={};for(let[s,a]of Object.entries(e)){let l=zN(a,t,n,i);l!==void 0&&(o[s]=l)}return t.delete(e),o}function UN(e){let t=[];for(let[i,r]of Object.entries(e))xRe.has(i)||i==="props"||t.push([i,r]);let n=e.props;if(n&&typeof n=="object"&&!Array.isArray(n))for(let[i,r]of Object.entries(n))t.push([i,r]);return t}function T9(e,t,n,i){let r={};for(let[o,s]of UN(e)){let a=zN(s,t,n,i);a!==void 0&&(r[o]=a)}return r}function $Re(e,t,n,i){let r=[];for(let a of P9(e))a.to===t||!n.has(a.to)||r.push({from:t,to:a.to,kind:"ref",...a.viaAttr?{viaAttr:a.viaAttr}:{},...a.toAttr?{toAttr:a.toAttr}:{}});let o=new Set,s=(a,l)=>{if(a===null||typeof a!="object")return;if(dn(a)){let u=_9(a,i);u&&u!==t&&n.has(u)&&r.push({from:t,to:u,kind:"ref",viaAttr:l});return}if(a[Ci]===!0){let u=C9(a);u&&u!==t&&n.has(u)&&r.push({from:t,to:u,kind:"ref",viaAttr:l});return}let c=I9(a,i,n);if(c){c!==t&&r.push({from:t,to:c,kind:"ref",viaAttr:l});return}if(!o.has(a)){if(o.add(a),qt(a)){for(let[,u]of UN(a))s(u,l);return}if(Array.isArray(a)){for(let u of a)s(u,l);return}for(let u of Object.values(a))s(u,l)}};for(let[a,l]of UN(e))s(l,a);return r}function El(e){return`${e.from}\0${e.to}\0${e.viaAttr??""}`}function D9(e,t){let n=new Map;for(let[g,h]of e)n.set(h,g);let i=new Set;for(let[g,h]of e)vRe(h)&&i.add(g);let r=[],o={},s={},a={};for(let[g,h]of e){if(!i.has(g))continue;let b=Ao(h),w={id:g,kind:h.entityType,lexicon:h.lexicon,attrs:T9(h,new Set,n,i)};b?.composite&&(w.compositeParent=b.composite),b?.compositeInstance&&(w.compositeInstance=b.compositeInstance);let x=kRe(b?.sourceFile,t);x&&(w.sourceLoc={file:x}),r.push(w),(o[h.lexicon]??=[]).push(g),(a[O9(h)??h.lexicon]??=[]).push(g),b?.composite&&(s[b.composite]??=[]).push(g)}let l=new Map;for(let[g,h]of e)if(i.has(g))for(let b of $Re(h,g,i,n))l.set(El(b),b);r.sort((g,h)=>g.id.localeCompare(h.id));let c=[...l.values()].sort((g,h)=>El(g).localeCompare(El(h)));for(let g of Object.values(o))g.sort();for(let g of Object.values(s))g.sort();for(let g of Object.values(a))g.sort();let u={};Object.keys(o).length&&(u.byLexicon=sh(o)),Object.keys(s).length&&(u.byComposite=sh(s)),Object.keys(a).length&&(u.byStack=sh(a));let d=[];for(let g of e.values()){if(!zr(g))continue;let h=g;if(!h.outputName)continue;let b=h._sourceParent?.deref(),w=(b?n.get(b):void 0)??(h.sourceEntity||void 0);d.push({name:h.outputName,...w?{node:w}:{},...h.sourceAttribute?{attr:h.sourceAttribute}:{}})}d.sort((g,h)=>g.name.localeCompare(h.name));let p=r.filter(g=>/(^|::)Parameter$/i.test(g.kind)).map(g=>({name:g.id,node:g.id})).sort((g,h)=>g.name.localeCompare(h.name)),f={nodes:r,edges:c,groups:u};return d.length&&(f.exports=d),p.length&&(f.imports=p),f}function sh(e){let t={};for(let n of Object.keys(e).sort())t[n]=e[n];return t}function RRe(e){let t=[],n={},i={};for(let{lexicon:c,resources:u}of e)for(let[d,p]of Object.entries(u)){let f={id:d,kind:p.type,lexicon:c,attrs:p.attributes??{}};p.physicalId&&(f.physicalId=p.physicalId),(p.ownership==="owned"||p.ownership==="foreign")&&(f.ownership=p.ownership),p.ownerChain?.root==="declared"&&(f.runtimeOwner=p.ownerChain.entity),t.push(f),(n[c]??=[]).push(d),(i[c]??=[]).push(d)}t.sort((c,u)=>c.id.localeCompare(u.id));for(let c of Object.values(n))c.sort();for(let c of Object.values(i))c.sort();let r={};Object.keys(n).length&&(r.byLexicon=sh(n)),Object.keys(i).length&&(r.byStack=sh(i));let o=new Set(t.map(c=>c.id)),s=new Set,a=[];for(let c of e)for(let u of c.edges??[]){if(!o.has(u.from)||!o.has(u.to))continue;let d=`${u.from}\0${u.to}\0${u.viaAttr??""}\0${u.toAttr??""}`;s.has(d)||(s.add(d),a.push(u))}a.sort((c,u)=>c.from.localeCompare(u.from)||c.to.localeCompare(u.to)||(c.viaAttr??"").localeCompare(u.viaAttr??""));let l=[];for(let c of e)for(let[u,d]of Object.entries(c.stackExports??{}))for(let[p,f]of Object.entries(d))l.push({name:p,value:f,stack:u});return l.sort((c,u)=>c.name.localeCompare(u.name)||(c.stack??"").localeCompare(u.stack??"")),{nodes:t,edges:a,groups:r,...l.length>0?{exports:l}:{}}}function SRe(e){let t={};for(let n of e)Object.assign(t,n.unobserved??{});return t}function Al(e,t,n){return{...e,attrs:{...e.attrs,_status:t,...n?{_unobserved:n.reason}:{}}}}function ERe(e,t,n){let i=new Set(t.nodes.map(a=>a.id)),r=new Set(e.nodes.map(a=>a.id)),o=n?.unobserved??{},s=e.nodes.map(a=>Al(a,i.has(a.id)?"good":a.runtimeOwner?"runtime":"warn"));for(let a of t.nodes){if(r.has(a.id))continue;let l=o[a.id];s.push(l?Al(a,"neutral",l):Al(a,"accent"))}return s.sort((a,l)=>a.id.localeCompare(l.id)),{...e,nodes:s}}function ARe(e,t,n){let i=new Map(t.nodes.map(p=>[p.id,p])),r=new Set(e.nodes.map(p=>p.id)),o=new Set(t.nodes.filter(p=>!r.has(p.id)).map(p=>p.id)),s=n?.unobserved??{},a=e.nodes.map(p=>{let f=i.get(p.id);if(!f){let h=s[p.id];return h?Al(p,"neutral",h):Al(p,"accent")}let g={...p};return f.physicalId&&(g.physicalId=f.physicalId),f.ownership&&(g.ownership=f.ownership),f.attrs&&Object.keys(f.attrs).length>0&&(g.attrs={...p.attrs,...f.attrs}),Al(g,"good")});for(let p of t.nodes)o.has(p.id)&&a.push(Al(p,p.runtimeOwner?"runtime":"warn"));a.sort((p,f)=>p.id.localeCompare(f.id));let l=new Set(e.edges.map(El)),c=[...e.edges];for(let p of t.edges){if(!(o.has(p.from)||o.has(p.to)))continue;let f=El(p);l.has(f)||(l.add(f),c.push(p))}c.sort((p,f)=>El(p).localeCompare(El(f)));let u=t.exports??[],d=e.exports;if(u.length>0){let p=new Map(u.map(g=>[g.name,g])),f=(e.exports??[]).map(g=>{let h=p.get(g.name);return h?(p.delete(g.name),{...g,value:h.value,...h.stack?{stack:h.stack}:{}}):g});for(let g of p.values())f.push(g);f.sort((g,h)=>g.name.localeCompare(h.name)),d=f}return{...e,nodes:a,edges:c,...d?{exports:d}:{}}}var Ax,xRe,ah=v(()=>{"use strict";Wt();Pn();kl();di();Qo();Ax=1;xRe=new Set(["lexicon","entityType","kind","attributes","Ref","references","stack"])});var j9=v(()=>{"use strict"});var L9=v(()=>{"use strict"});var M9=v(()=>{"use strict"});var F9=v(()=>{"use strict"});var B9=v(()=>{"use strict"});import{readFile as PRe}from"node:fs/promises";function W9(e){return e instanceof Error&&e.message===G9}async function z9(e){let t=new Set;for(let n of e){let i;try{i=await PRe(n,"utf-8")}catch{continue}let r=/(?:import|export)\s+[\s\S]*?\s+from\s+['"]@intentius\/chant-lexicon-([a-z][\w-]*)(?:\/[^'"\s]*)?['"]/g;for(let o of i.matchAll(r))t.add(o[1])}if(t.size===0)throw new Error(G9);return Array.from(t)}var G9,HN=v(()=>{"use strict";G9="No lexicon detected in infrastructure files"});var VN,U9=v(()=>{"use strict";VN=Le(Ke(),1)});var H9=v(()=>{"use strict"});var Px,Ox=v(()=>{"use strict";Px=Le(Ke(),1)});var ch,qN=v(()=>{"use strict";ch=Le(Ke(),1);Ox()});var Ha,KN=v(()=>{"use strict";Ha=Le(Ke(),1)});var JN,ZN=v(()=>{"use strict";JN=Le(Ke(),1);Ox()});var q9,YN=v(()=>{"use strict";q9=Le(Ke(),1)});var lh,XN=v(()=>{"use strict";lh=Le(Ke(),1)});var Pl,QN=v(()=>{"use strict";Pl=Le(Ke(),1)});var Cx,ej=v(()=>{"use strict";Cx=Le(Ke(),1)});var Ol,tj=v(()=>{"use strict";Ol=Le(Ke(),1);Ox()});var lp,nj=v(()=>{"use strict";lp=Le(Ke(),1)});var _x,rj=v(()=>{"use strict";_x=Le(Ke(),1)});var uh,ij=v(()=>{"use strict";uh=Le(Ke(),1)});var dh,Va=v(()=>{"use strict";dh=Le(Ke(),1)});var sj,aj=v(()=>{"use strict";sj=Le(Ke(),1);Va();wl()});var fi,T4e,cj=v(()=>{"use strict";fi=Le(Ke(),1),T4e=new Set([fi.SyntaxKind.IfStatement,fi.SyntaxKind.ForStatement,fi.SyntaxKind.ForInStatement,fi.SyntaxKind.ForOfStatement,fi.SyntaxKind.WhileStatement,fi.SyntaxKind.DoStatement,fi.SyntaxKind.SwitchStatement,fi.SyntaxKind.TryStatement])});var K9,lj=v(()=>{"use strict";K9=Le(Ke(),1);wl()});var mi,uj=v(()=>{"use strict";mi=Le(Ke(),1);Va()});var ph,dj=v(()=>{"use strict";ph=Le(Ke(),1)});var Ur,pj=v(()=>{"use strict";Ur=Le(Ke(),1)});var ar,fj=v(()=>{"use strict";ar=Le(Ke(),1);Va()});var mj,gj=v(()=>{"use strict";mj=Le(Ke(),1);Va()});var qa,hj=v(()=>{"use strict";qa=Le(Ke(),1)});var fh,yj=v(()=>{"use strict";fh=Le(Ke(),1);Va()});var Io,bj=v(()=>{"use strict";Io=Le(Ke(),1);Va()});var Cl,wj=v(()=>{"use strict";Cl=Le(Ke(),1)});var _l,Ix=v(()=>{"use strict";_l=Le(Ke(),1)});var qi,vj=v(()=>{"use strict";qi=Le(Ke(),1);Ix()});var IRe,kj=v(()=>{"use strict";IRe=Le(Ke(),1)});var J9=v(()=>{"use strict";qN();KN();ZN();YN();XN();QN();ej();tj();nj();rj();ij();aj();cj();lj();uj();dj();pj();fj();gj();hj();yj();bj();wj();Ix();vj();kj();Va();qN();KN();ZN();YN();XN();QN();ej();tj();nj();rj();ij();aj();cj();lj();uj();dj();pj();fj();gj();hj();yj();bj();wj();Ix();vj();kj()});function Il(e,t){let n=[];function i(r){t(r)&&n.push(r),Ft.forEachChild(r,i)}return i(e),n}function Z9(e){return Il(e,t=>Ft.isNewExpression(t))}function sSe(e){return Z9(e)}function aSe(e){return Il(e,t=>Ft.isStringLiteral(t))}function cSe(e){return Il(e,t=>Ft.isVariableStatement(t)?t.modifiers?.some(n=>n.kind===Ft.SyntaxKind.ExportKeyword)??!1:Ft.isFunctionDeclaration(t)||Ft.isClassDeclaration(t)?t.modifiers?.some(n=>n.kind===Ft.SyntaxKind.ExportKeyword)??!1:!1)}function lSe(e){return Il(e,t=>!!Ft.isImportDeclaration(t))}function uSe(e){return Il(e,t=>Ft.isPropertyAssignment(t))}function dSe(e){return Il(e,t=>!!(Ft.isNewExpression(t)&&t.typeArguments&&t.typeArguments.length>0))}function pSe(e){return Il(e,t=>!Ft.isVariableStatement(t)||!(t.modifiers?.some(i=>i.kind===Ft.SyntaxKind.ExportKeyword)??!1)?!1:t.declarationList.flags===Ft.NodeFlags.Const||(t.declarationList.flags&Ft.NodeFlags.Const)!==0)}var Ft,oSe,fSe,xj=v(()=>{"use strict";Ft=Le(Ke(),1),oSe=new Map;fSe=[["resource",Z9],["any-resource",sSe],["string-literal",aSe],["export-name",cSe],["import-source",lSe],["property",uSe],["resource-type",dSe],["exported-const",pSe]];for(let[e,t]of fSe)oSe.set(e,t)});var $j=v(()=>{"use strict"});var Y9=v(()=>{"use strict";xj();$j()});function ySe(e){if(e===null)return!1;let t=e.length,n=0,i=!1;if(!t)return!1;let r=e[n];if((r==="-"||r==="+")&&(r=e[++n]),r==="0"){if(n+1===t)return!0;r=e[++n];let o={b:s=>s===48||s===49,x:mSe,o:gSe}[r];if(o){for(n++;n<t;n++){if(!o(e.charCodeAt(n)))return!1;i=!0}return i&&isFinite(Rj(e))}}for(;n<t;n++){if(!hSe(e.charCodeAt(n)))return!1;i=!0}return i?isFinite(Rj(e)):!1}function Rj(e){let t=e,n=1,i=t[0];if((i==="-"||i==="+")&&(i==="-"&&(n=-1),t=t.slice(1),i=t[0]),t==="0")return 0;if(i==="0"){if(t[1]==="b")return n*parseInt(t.slice(2),2);if(t[1]==="x")return n*parseInt(t.slice(2),16);if(t[1]==="o")return n*parseInt(t.slice(2),8)}return n*parseInt(t,10)}function vSe(e){return e===null||!bSe.test(e)?!1:isFinite(parseFloat(e,10))?!0:wSe.test(e)}function X9(e){switch(e){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return`
|
|
222
|
+
`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"\x85";case 95:return"\xA0";case 76:return"\u2028";case 80:return"\u2029";default:return""}}var Q9,mSe,gSe,hSe,e3,bSe,wSe,t3,n3,r3,i3,kSe,xSe,o3=v(()=>{"use strict";Q9={tag:"tag:yaml.org,2002:null",kind:"scalar",resolve:e=>e===null||e==="~"||e==="null"||e==="Null"||e==="NULL",construct:()=>null},mSe=e=>e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102,gSe=e=>e>=48&&e<=55,hSe=e=>e>=48&&e<=57;e3={tag:"tag:yaml.org,2002:int",kind:"scalar",resolve:ySe,construct:Rj},bSe=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),wSe=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");t3={tag:"tag:yaml.org,2002:float",kind:"scalar",resolve:vSe,construct:e=>{let t=e.toLowerCase(),n=t[0]==="-"?-1:1;return"+-".indexOf(t[0])>=0&&(t=t.slice(1)),t===".inf"?n===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:t===".nan"?NaN:n*parseFloat(t,10)}},n3={tag:"tag:yaml.org,2002:str",kind:"scalar",construct:e=>e!==null?e:""},r3={tag:"tag:yaml.org,2002:seq",kind:"sequence",construct:e=>e!==null?e:[]},i3={tag:"tag:yaml.org,2002:map",kind:"mapping",construct:e=>e!==null?e:{}};for(let e of[Q9,e3,t3,n3,r3,i3])e.resolve??=()=>!0;kSe=new Array(256),xSe=new Array(256);for(let e=0;e<256;e++)kSe[e]=X9(e)?1:0,xSe[e]=X9(e)});var Sj=v(()=>{"use strict";o3()});var Ej=v(()=>{"use strict";Sj()});var Tx=v(()=>{"use strict";Ej();Ej()});var s3=v(()=>{"use strict";Kt();up()});function Aj(e,t){for(let[n,i]of Object.entries(t)){let r=e[n];if(!r)throw new Error(`audit lineage names ${n}, which this catalog does not define`);i.length>0&&(r.lineage=i)}}var Pj=v(()=>{"use strict"});var l3,u3=v(()=>{"use strict";l3={AGT002:[{tool:"agent-audit",rule:"auth-bypass/env-secret-in-config",url:"https://raw.githubusercontent.com/piiiico/agent-audit/main/README.md",relation:"equivalent"},{tool:"mcp-audit",rule:"Secrets Detection",url:"https://raw.githubusercontent.com/apisec-inc/mcp-audit/main/README.md",relation:"overlaps"},{tool:"agent-scan",rule:"W008",url:"https://raw.githubusercontent.com/invariantlabs-ai/mcp-scan/main/docs/issue-codes.md",relation:"overlaps"}],COR020:[{tool:"cfn-lint",rule:"E3004",url:"https://github.com/aws-cloudformation/cfn-lint/blob/main/docs/rules.md#E3004",relation:"equivalent"}],EXT001:[{tool:"cfn-lint",url:"https://github.com/aws-cloudformation/cfn-lint/blob/main/docs/cfn-schema-specification.md#extending-the-schemas-with-new-keywords",relation:"equivalent"},{tool:"cfn-lint",rule:"E3014",url:"https://github.com/aws-cloudformation/cfn-lint/blob/main/docs/rules.md#E3014",relation:"equivalent"},{tool:"cfn-lint",rule:"E3021",url:"https://github.com/aws-cloudformation/cfn-lint/blob/main/docs/rules.md#E3021",relation:"equivalent"}],NGX001:[{tool:"gixy-ng",rule:"weak_ssl_tls",url:"https://gixy.getpagespeed.com/plugins/weak_ssl_tls/",relation:"overlaps"}],NGX002:[{tool:"gixy-ng",rule:"weak_ssl_tls",url:"https://gixy.getpagespeed.com/plugins/weak_ssl_tls/",relation:"overlaps"}],NGX004:[{tool:"gixy",rule:"alias_traversal",url:"https://github.com/yandex/gixy",relation:"equivalent"},{tool:"gixy-ng",rule:"alias_traversal",url:"https://gixy.getpagespeed.com/plugins/aliastraversal/",relation:"equivalent"}],NGX005:[{tool:"gixy-ng",rule:"status_page_exposed",url:"https://gixy.getpagespeed.com/checks/status-page-exposed/",relation:"overlaps"}],NGX006:[{tool:"gixy-ng",rule:"version_disclosure",url:"https://gixy.getpagespeed.com/plugins/version_disclosure/",relation:"equivalent"}],SEC001:[{tool:"gitleaks",rule:"aws-access-token",url:"https://github.com/gitleaks/gitleaks/blob/master/config/gitleaks.toml",relation:"equivalent"},{tool:"trufflehog",rule:"aws",url:"https://github.com/trufflesecurity/trufflehog/blob/main/pkg/detectors/aws/access_keys/accesskey.go",relation:"overlaps"},{tool:"detect-secrets",rule:"AWSKeyDetector",url:"https://github.com/Yelp/detect-secrets/blob/master/detect_secrets/plugins/aws.py",relation:"equivalent"}],SEC002:[{tool:"gitleaks",rule:"generic-api-key",url:"https://github.com/gitleaks/gitleaks/blob/master/config/gitleaks.toml",relation:"overlaps"},{tool:"trufflehog",rule:"aws",url:"https://github.com/trufflesecurity/trufflehog/blob/main/pkg/detectors/aws/access_keys/accesskey.go",relation:"overlaps"},{tool:"detect-secrets",rule:"AWSKeyDetector",url:"https://github.com/Yelp/detect-secrets/blob/master/detect_secrets/plugins/aws.py",relation:"overlaps"}],SEC003:[{tool:"gitleaks",rule:"github-pat",url:"https://github.com/gitleaks/gitleaks/blob/master/config/gitleaks.toml",relation:"overlaps"},{tool:"trufflehog",rule:"github",url:"https://github.com/trufflesecurity/trufflehog/blob/main/pkg/detectors/github/v2/github.go",relation:"equivalent"},{tool:"detect-secrets",rule:"GitHubTokenDetector",url:"https://github.com/Yelp/detect-secrets/blob/master/detect_secrets/plugins/github_token.py",relation:"overlaps"}],SEC004:[{tool:"gitleaks",rule:"slack-bot-token",url:"https://github.com/gitleaks/gitleaks/blob/master/config/gitleaks.toml",relation:"overlaps"},{tool:"trufflehog",rule:"slack",url:"https://github.com/trufflesecurity/trufflehog/blob/main/pkg/detectors/slack/slack.go",relation:"overlaps"},{tool:"detect-secrets",rule:"SlackDetector",url:"https://github.com/Yelp/detect-secrets/blob/master/detect_secrets/plugins/slack.py",relation:"overlaps"}],SEC005:[{tool:"gitleaks",rule:"gcp-api-key",url:"https://github.com/gitleaks/gitleaks/blob/master/config/gitleaks.toml",relation:"equivalent"},{tool:"trufflehog",rule:"googlegemini",url:"https://github.com/trufflesecurity/trufflehog/blob/main/pkg/detectors/googlegemini/googlegemini.go",relation:"overlaps"}],SEC006:[{tool:"gitleaks",rule:"stripe-access-token",url:"https://github.com/gitleaks/gitleaks/blob/master/config/gitleaks.toml",relation:"overlaps"},{tool:"trufflehog",rule:"stripe",url:"https://github.com/trufflesecurity/trufflehog/blob/main/pkg/detectors/stripe/stripe.go",relation:"overlaps"},{tool:"detect-secrets",rule:"StripeDetector",url:"https://github.com/Yelp/detect-secrets/blob/master/detect_secrets/plugins/stripe.py",relation:"overlaps"}],SEC007:[{tool:"gitleaks",rule:"private-key",url:"https://github.com/gitleaks/gitleaks/blob/master/config/gitleaks.toml",relation:"equivalent"},{tool:"trufflehog",rule:"privatekey",url:"https://github.com/trufflesecurity/trufflehog/blob/main/pkg/detectors/privatekey/privatekey.go",relation:"equivalent"},{tool:"detect-secrets",rule:"PrivateKeyDetector",url:"https://github.com/Yelp/detect-secrets/blob/master/detect_secrets/plugins/private_key.py",relation:"equivalent"}],SEC008:[{tool:"gitleaks",rule:"curl-auth-header",url:"https://github.com/gitleaks/gitleaks/blob/master/config/gitleaks.toml",relation:"overlaps"}],SEC009:[{tool:"detect-secrets",rule:"BasicAuthDetector",url:"https://github.com/Yelp/detect-secrets/blob/master/detect_secrets/plugins/basic_auth.py",relation:"equivalent"},{tool:"trufflehog",rule:"uri",url:"https://github.com/trufflesecurity/trufflehog/blob/main/pkg/detectors/uri/uri.go",relation:"overlaps"},{tool:"gitleaks",rule:"curl-auth-user",url:"https://github.com/gitleaks/gitleaks/blob/master/config/gitleaks.toml",relation:"overlaps"}],SEC010:[{tool:"detect-secrets",rule:"Base64HighEntropyString",url:"https://github.com/Yelp/detect-secrets/blob/master/detect_secrets/plugins/high_entropy_strings.py",relation:"overlaps"},{tool:"detect-secrets",rule:"HexHighEntropyString",url:"https://github.com/Yelp/detect-secrets/blob/master/detect_secrets/plugins/high_entropy_strings.py",relation:"overlaps"},{tool:"gitleaks",rule:"generic-api-key",url:"https://github.com/gitleaks/gitleaks/blob/master/config/gitleaks.toml",relation:"overlaps"}],TF023:[{tool:"hashicorp-style-guide",rule:".gitignore: do not commit terraform.tfstate, terraform.tfstate.* backups, or the .terraform directory",url:"https://developer.hashicorp.com/terraform/language/style#gitignore",relation:"equivalent"}]}});function It(e,t,n,i,r,o,s){let a=o&&o.length>0?"security":f3[e]??"best-practice";return{id:e,tier:t,fixKind:n,category:a,title:i,remediation:r,authority:o,...s?.length?{lineage:s}:{},yamlBased:!0}}function Ka(e,t,n,i,r){let o=r&&r.length>0?"security":f3[e]??"best-practice";return{id:e,tier:t,fixKind:Ot,category:o,title:n,remediation:i,authority:r,yamlBased:!1}}var d3,To,SSe,ESe,ASe,PSe,OSe,p3,CSe,_Se,ISe,TSe,DSe,NSe,Rt,dp,Ot,f3,jSe,m3=v(()=>{"use strict";Pj();u3();Pj();d3={name:"OSSF Scorecard \u2014 Pinned-Dependencies",url:"https://github.com/ossf/scorecard/blob/main/docs/checks.md#pinned-dependencies"},To={name:"GitHub \u2014 About secret scanning",url:"https://docs.github.com/en/code-security/secret-scanning/introduction/about-secret-scanning"},SSe={name:"Cloudflare Workers \u2014 workers.dev",url:"https://developers.cloudflare.com/workers/configuration/routing/workers-dev/"},ESe={name:"Cloudflare Workers \u2014 Secrets",url:"https://developers.cloudflare.com/workers/configuration/secrets/"},ASe={name:"Cloudflare Workers \u2014 Routes",url:"https://developers.cloudflare.com/workers/configuration/routing/routes/"},PSe={name:"Cloudflare Workers \u2014 Wrangler environments",url:"https://developers.cloudflare.com/workers/wrangler/configuration/#environments"},OSe={name:"Cloudflare Workers \u2014 Static assets",url:"https://developers.cloudflare.com/workers/static-assets/"},p3={name:"Mozilla \u2014 Server Side TLS",url:"https://wiki.mozilla.org/Security/Server_Side_TLS"},CSe={name:"CWE-548 \u2014 Exposure of Information Through Directory Listing",url:"https://cwe.mitre.org/data/definitions/548.html"},_Se={name:"Gixy \u2014 alias traversal",url:"https://github.com/yandex/gixy/blob/master/docs/en/plugins/aliastraversal.md"},ISe={name:"nginx \u2014 ngx_http_stub_status_module",url:"https://nginx.org/en/docs/http/ngx_http_stub_status_module.html"},TSe={name:"CWE-798 \u2014 Use of Hard-coded Credentials",url:"https://cwe.mitre.org/data/definitions/798.html"},DSe={name:"HashiCorp Terraform style guide \u2014 .gitignore",url:"https://developer.hashicorp.com/terraform/language/style#gitignore"},NSe={name:"CWE-319 \u2014 Cleartext Transmission of Sensitive Information",url:"https://cwe.mitre.org/data/definitions/319.html"};Rt="merge-worthy",dp="report-only",Ot="guidance";f3={COR020:"correctness",EXT001:"correctness",SEC001:"security",SEC002:"security",SEC003:"security",SEC004:"security",SEC005:"security",SEC006:"security",SEC007:"security",SEC008:"security",SEC009:"security",SEC010:"security",WRG001:"security",WRG002:"security",WRG003:"best-practice",WRG004:"security",WRG005:"security",WRG006:"security",NGX001:"security",NGX002:"security",NGX003:"security",NGX004:"security",NGX005:"security",NGX006:"best-practice",NGX007:"best-practice",TF023:"security",AGT001:"security",AGT002:"security",AGT003:"security",AGT004:"security",AGT005:"security",AGT006:"best-practice",AGT007:"correctness",AGT008:"best-practice"},jSe={COR020:It("COR020",Rt,Ot,"Circular resource dependency","Break the dependency cycle between resources."),EXT001:It("EXT001",Rt,Ot,"Extension constraint violation","Fix the cross-property constraint flagged by the cfn-lint extension schema."),SEC001:It("SEC001",Rt,Ot,"AWS access key ID found","Remove the key from source, rotate it in IAM, and load it from a secret store or environment variable instead.",[To]),SEC002:It("SEC002",Rt,Ot,"AWS secret access key found","Remove the key from source, rotate it in IAM, and load it from a secret store or environment variable instead.",[To]),SEC003:It("SEC003",Rt,Ot,"GitHub token found","Remove the token from source and revoke it at github.com/settings/tokens; use a GitHub Actions secret instead.",[To]),SEC004:It("SEC004",Rt,Ot,"Slack token found","Remove the token from source and revoke it in the Slack app's OAuth settings.",[To]),SEC005:It("SEC005",Rt,Ot,"Google API key found","Remove the key from source and regenerate it in the Google Cloud Console credentials page.",[To]),SEC006:It("SEC006",Rt,Ot,"Stripe live secret key found","Remove the key from source and roll it in the Stripe dashboard immediately \u2014 this is a live-mode key.",[To]),SEC007:It("SEC007",Rt,Ot,"Private key block found","Remove the private key from source, rotate the keypair, and load the key from a secret store instead.",[To]),SEC008:It("SEC008",Rt,Ot,"Bearer/authorization token found","Remove the token from source; if it's long-lived, revoke and reissue it via the issuing service.",[To]),SEC009:It("SEC009",Rt,Ot,"Credentials embedded in a connection string","Move the username/password out of the URI into a secret store, and rotate the credential.",[To]),SEC010:It("SEC010",Rt,Ot,"High-entropy string \u2014 possible secret","Confirm whether this is a live credential; if so, remove it from source and rotate it. If it's a false positive, suppress with a `chant-audit-ignore` comment or an allowlist entry.",[To]),WRG001:It("WRG001",Rt,Ot,"Production environment exposed on *.workers.dev","Remove workers_dev (or set it to false) for this environment and rely on its custom domain/route instead of the shared public subdomain.",[SSe]),WRG002:It("WRG002",Rt,Ot,"Credential-shaped key stored in [vars]","Move the value out of [vars] and into `wrangler secret put <name>` so it isn't committed to source or visible in `wrangler dev`/the dashboard.",[ESe]),WRG003:It("WRG003",dp,Ot,"Observability explicitly disabled","Set observability.enabled = true (or remove the override) so Workers Logs are recorded for this deployment."),WRG004:It("WRG004",Rt,Ot,"Unscoped wildcard route",'Scope the route pattern to the intended zone (e.g. "example.com/*") instead of a bare "*" or "*/*" that matches every zone on the account.',[ASe]),WRG005:It("WRG005",Rt,Ot,"Non-production environment shares a data store with production","Give the non-production environment its own KV namespace/R2 bucket/D1 database id instead of reusing production's.",[PSe]),WRG006:It("WRG006",Rt,Ot,"Static assets served from the project root","Point [site].bucket / [assets].directory at a dedicated public output folder, not the project root, so non-public files (config, source maps, .git) aren't served.",[OSe]),NGX001:It("NGX001",Rt,Ot,"Deprecated TLS protocol enabled","Remove SSLv2/SSLv3/TLSv1/TLSv1.1 from ssl_protocols and serve TLSv1.2 and TLSv1.3 only.",[p3]),NGX002:It("NGX002",Rt,Ot,"Weak cipher suite enabled","Remove the RC4/DES/MD5/NULL/EXPORT-class entries from ssl_ciphers and use a modern cipher list (e.g. Mozilla's intermediate configuration).",[p3]),NGX003:It("NGX003",Rt,Ot,"Directory listing enabled","Remove `autoindex on` (or scope it to a directory that is genuinely meant to be enumerated) so file listings aren't served to anyone who asks.",[CSe]),NGX004:It("NGX004",Rt,Ot,"alias path traversal",'End the location prefix with "/" so it matches the trailing slash of the alias target \u2014 without it, a request for "<prefix>../" escapes the aliased directory.',[_Se]),NGX005:It("NGX005",Rt,Ot,"Status endpoint with no access restriction","Restrict the stub_status location with allow/deny (or auth_basic/auth_request) so connection metrics aren't public reconnaissance.",[ISe]),NGX006:It("NGX006",dp,Ot,"Server version disclosure","Add `server_tokens off;` in the http block so nginx stops advertising its exact version in the Server header and error pages."),NGX007:It("NGX007",dp,Ot,"Access logging disabled at server scope","Re-enable access_log at http/server scope (silencing a single noisy location is fine) so requests are recorded for incident investigation."),TF023:It("TF023",Rt,Ot,"Terraform state committed to the repository","Delete the state file (or `.terraform/`) from version control, add it to .gitignore, move the state to a remote backend, and rotate every credential the file held.",[DSe]),AGT001:Ka("AGT001",Rt,"MCP server runs an unpinned package","Pin the package spec to an exact version (`server@1.2.3`), so a new upstream release can't execute on this machine unreviewed.",[d3]),AGT002:Ka("AGT002",Rt,"Literal credential in agent config","Replace the value with an environment reference (`${TOKEN}`) and keep the secret in a secret store \u2014 agent config files sync, back up, and get shared.",[TSe]),AGT003:Ka("AGT003",Rt,"MCP server reached over cleartext HTTP","Use an https:// endpoint. Tool arguments and results \u2014 including data the agent read locally \u2014 otherwise cross the network in the clear.",[NSe]),AGT004:Ka("AGT004",Rt,"Remote skill or plugin is unpinned","Pin the source to a tag or commit sha, so the instructions the agent follows can't change upstream without a local edit.",[d3]),AGT005:Ka("AGT005",Rt,"Tool permission granted without constraint","Scope the grant to the specific commands you run (`Bash(git status:*)`), and re-enable the confirmation prompt for dangerous operations."),AGT006:Ka("AGT006",dp,"User-scope config applies to every project","Move project-specific instructions, MCP servers, and skills to that project's own config so they don't follow you into unrelated repos."),AGT007:Ka("AGT007",dp,"MCP server declared in multiple files","Delete the shadowed declarations. The harness silently picks one, so the file you read may not be the one that decides what runs."),AGT008:Ka("AGT008",dp,"Instruction file exceeds the attention budget","Move situational guidance into skills that load on demand, so the always-on instructions stay short enough to be followed reliably.")};Aj(jSe,l3)});var h3,g3=v(()=>{h3={rules:{COR001:"error",COR002:"error",COR003:"warning",COR004:"warning",COR005:"warning",COR006:"error",COR007:"warning",COR008:"error",COR009:"warning",COR010:"warning",COR011:"error",COR012:"warning",COR013:"info",COR014:"warning",COR015:"warning",COMP001:"error",COMP002:"error",COMP003:"error",COMP004:"error",COMP005:"error",COMP006:"error",COMP007:"warning"}}});import{join as MZe,dirname as FZe,resolve as y3}from"path";var HZe,b3,w3,VZe,qZe,v3=v(()=>{"use strict";Ln();EO();no();m3();g3();Si();HZe={"@intentius/chant/lint/presets/strict":y3(qO(import.meta.url),"presets/strict.json"),"@intentius/chant/lint/presets/relaxed":y3(qO(import.meta.url),"presets/relaxed.json")},b3=m.enum(["off","error","warning","info"]),w3=m.union([b3,m.tuple([b3,m.record(m.string(),m.unknown())])]),VZe=m.object({rules:m.record(m.string(),w3).optional(),extends:m.array(m.string()).optional(),overrides:m.array(m.object({files:m.array(m.string()),rules:m.record(m.string(),w3)})).optional(),plugins:m.array(m.string()).optional(),policies:m.array(m.string()).optional(),presets:m.record(m.string(),m.string()).optional()}),qZe={rules:{...h3.rules},extends:[]}});var k3=v(()=>{"use strict";Ei();Zs()});var Oj=v(()=>{"use strict";Kt();Kg();up();s3();Kn();cp();Tx();v3();k3()});function R3(e){switch(e){case"template":return{basis:"deterministic-synthesis",verifyBy:"re-synth"};case"image":case"asset":return{basis:"best-effort"};case"sbom":return}}var Cj=v(()=>{"use strict"});function S3(e){let t=e.map(n=>({kind:n.kind,path:n.path,digest:n.digest})).sort((n,i)=>n.path<i.path?-1:n.path>i.path?1:0);return Nr(Rr(t))}function Dx(e,t){let n=(t?.now??(()=>new Date))().toISOString();return{version:1,component:e,createdAt:n,contents:[],manifestDigest:S3([])}}function Nx(e,t){let n=t.reproducibility??(t.kind==="image"||t.kind==="template"||t.kind==="asset"||t.kind==="sbom"?R3(t.kind):void 0),i={mediaType:MSe[t.kind],...t,...n?{reproducibility:n}:{}},r=[...e.contents.filter(o=>o.path!==i.path),i];return{...e,contents:r,manifestDigest:S3(r)}}function _j(e){return e.startsWith("archive:")?e.slice(8):e}var MSe,pp=v(()=>{"use strict";Cj();as();er();MSe={image:"application/vnd.oci.image.layout.v1.tar",template:"application/json",asset:"application/octet-stream",sbom:"application/spdx+json"}});import{exec as FSe}from"node:child_process";import{createConnection as BSe}from"node:net";import{promisify as GSe}from"node:util";import{isAbsolute as WSe,join as zSe}from"node:path";function Ja(e){return USe(e,{maxBuffer:64*1024*1024})}function Er(e){return`'${e.replace(/'/g,"'\\''")}'`}function qSe(e,t=5e3){let[n,i]=e.split(":"),r=Number(i??7687);return new Promise(o=>{let s=BSe({host:n,port:r,timeout:t}),a=l=>{s.destroy(),o(l)};s.once("connect",()=>a(!0)),s.once("timeout",()=>a(!1)),s.once("error",()=>a(!1))})}function KSe(){return{docker:HSe,neo4j:VSe}}function jx(){return Ij||(Ij=KSe()),Ij}function Lx(e){return new Promise(t=>setTimeout(t,e))}var USe,HSe,VSe,Ij,Mx=v(()=>{"use strict";USe=GSe(FSe);HSe={async build(e){let t=["docker build",`-t ${Er(e.tag)}`];if(e.dockerfile){let i=WSe(e.dockerfile)?e.dockerfile:zSe(e.context,e.dockerfile);t.push(`-f ${Er(i)}`)}e.target&&t.push(`--target ${Er(e.target)}`);for(let[i,r]of Object.entries(e.buildArgs??{}))t.push(`--build-arg ${Er(`${i}=${r}`)}`);t.push(Er(e.context)),await Ja(t.join(" "));let{stdout:n}=await Ja(`docker image inspect ${Er(e.tag)} --format '{{.Id}}'`);return{digest:n.trim()}},async save(e){await Ja(`docker save ${Er(e.image)} -o ${Er(e.outFile)}`)},async load(e){let{stdout:t}=await Ja(`docker load -i ${Er(e.inFile)}`);return{digest:t.match(/[Ll]oaded image(?: ID)?:\s*(\S+)/)?.[1]??t.trim()}},async tag(e){await Ja(`docker tag ${Er(e.source)} ${Er(e.target)}`)},async push(e){await Ja(`docker push ${Er(e.image)}`);let{stdout:t}=await Ja(`docker image inspect ${Er(e.image)} --format '{{index .RepoDigests 0}}'`);return{digest:t.trim()}},async remoteDigest(e){let{stdout:t}=await Ja(`docker manifest inspect -v ${Er(e)}`);return t.trim()}},VSe={async probe(e){let t=e.cluster.split(",").map(i=>i.trim()).filter(Boolean);return{healthyCount:(await Promise.all(t.map(i=>qSe(i)))).filter(Boolean).length,total:t.length}}}});import{exec as JSe}from"node:child_process";import{promisify as ZSe}from"node:util";function Se(e){return`'${e.replace(/'/g,"'\\''")}'`}function XSe(){return YSe}function en(){return Tj||(Tj=XSe()),Tj}async function un(e,t,n){if(!await e.available(t))throw new mh(t,n)}var E3,YSe,Tj,mh,Ki=v(()=>{"use strict";E3=ZSe(JSe);YSe={async run(e,t){return E3(e,{cwd:t?.cwd,maxBuffer:t?.maxBuffer??64*1024*1024})},async available(e){try{return await E3(`command -v ${Se(e)}`),!0}catch{return!1}}};mh=class extends Error{constructor(n,i){super(`"${n}" is not installed or not on PATH \u2014 required to ${i}. Install it and retry.`);this.tool=n;this.purpose=i;this.name="ToolNotAvailableError"}}});import{readFileSync as A3}from"node:fs";import{createHash as P3}from"node:crypto";function QSe(e=jx()){return{kind:"docker-build",async run(t,n){let i=`chant-build/${n.into.replace(/[^a-zA-Z0-9_.-]/g,"-")}:latest`,{digest:r}=await e.docker.build({context:n.context,dockerfile:n.dockerfile,buildArgs:n.buildArgs,target:n.target,tag:i});await e.docker.save({image:i,outFile:n.into});let o=n.manifest??Dx(t.component),s=n.sourceRef?{sourceRef:n.sourceRef,artifactDigest:r}:void 0,a=Nx(o,{kind:"image",path:n.into,digest:r,...s?{provenance:s}:{}});return{archivePath:n.into,digest:r,manifest:a}}}}function tEe(e=en()){return{kind:"zip-package",async run(t,n){let i=(n.exclude??[]).map(o=>`-x ${Se(o)}`).join(" ");await e.run(`rm -f ${Se(n.into)} && zip -r -X ${Se(n.into)} ${Se(n.source)}${i?` ${i}`:""}`);let r=`sha256:${P3("sha256").update(A3(n.into)).digest("hex")}`;return{archivePath:n.into,digest:r}}}}function rEe(e=en()){return{kind:"jvm-build",async run(t,n){if(n.tool==="gradle"){let r=(n.goals??["build"]).join(" ");await e.run(`./gradlew -q ${r}`,{cwd:n.path}),await e.run(`cp "$(ls ${Se(n.path)}/build/libs/*.jar | head -1)" ${Se(n.into)}`)}else{let r=(n.goals??["package"]).join(" ");await e.run(`mvn -q -B -f ${Se(`${n.path}/pom.xml`)} ${r}`),await e.run(`cp "$(ls ${Se(`${n.path}/target`)}/*.jar | grep -Ev '(-sources|-javadoc)\\.jar$' | head -1)" ${Se(n.into)}`)}let i=`sha256:${P3("sha256").update(A3(n.into)).digest("hex")}`;return{archivePath:n.into,digest:i}}}}var eEe,nEe,iEe,O3=v(()=>{"use strict";Mx();Ki();pp();eEe=QSe();nEe=tEe();iEe=rEe()});function oEe(e){return`${_j(e)}.sbom.json`}async function sEe(e,t,n){switch(t.artifactType){case"image":return e.forImage({imagePath:n,digest:t.digest??"",format:t.format});case"jar":return e.forJar({jarPath:n,digest:t.digest??"",format:t.format});case"zip":return e.forZip({zipPath:n,digest:t.digest??"",format:t.format});case"dir":return e.forDir({path:n,format:t.format})}}function aEe(e=OW()){return{kind:"generate-sbom",async run(t,n){let i=_j(n.path),r=n.format??Jr,o=await sEe(e,{...n,format:r},i),s=n.into??oEe(n.path),a=Nr(o.bytes),l=n.manifest??Dx(t.component),c=Nx(l,{kind:"sbom",path:s,digest:a,mediaType:o.mediaType,subjectDigest:n.digest,packageCount:o.packageCount,generator:o.generator});return{sbom:o,archivePath:s,digest:a,manifest:c}}}}var cEe,C3=v(()=>{"use strict";pp();Xo();cEe=aEe()});import{basename as T3,dirname as _3,join as gh}from"node:path";import{existsSync as I3}from"node:fs";function Tl(e,t){try{let n=JSON.parse(t);if(e==="cyclonedx"&&Array.isArray(n.components))return n.components.length;if(e==="spdx"&&Array.isArray(n.packages))return n.packages.length}catch{}}function Bx(e,t,n){let i=e??"/tmp/chant-sbom",r=T3(t).replace(/[^a-zA-Z0-9_.-]/g,"_");return gh(i,`${r}.${Date.now()}.${n}.json`)}function uEe(e={}){let t=e.runner??en();async function n(i,r){await un(t,"syft",`scan ${i} for a software bill of materials`);let o=Bx(e.workDir,i,r);await t.run(`syft ${Se(i)} -o ${lEe[r]}=${Se(o)}`);let{stdout:s}=await t.run(`cat ${Se(o)}`);return{bytes:s,generator:"syft"}}return{async forImage(i){let r=i.format??Jr,o=_3(i.imagePath);if(I3(gh(o,"Dockerfile"))&&await t.available("docker")){let c=Bx(e.workDir,i.imagePath,r);await t.run(`docker buildx build --sbom=true --output type=local,dest=${Se(c)} ${Se(o)}`);let{stdout:u}=await t.run(`cat ${Se(gh(c,"sbom.spdx.json"))}`);return{format:r,mediaType:to[r],bytes:u,packageCount:Tl(r,u),generator:"buildkit"}}let{bytes:a,generator:l}=await n(i.imagePath,r);return{format:r,mediaType:to[r],bytes:a,packageCount:Tl(r,a),generator:l}},async forJar(i){let r=i.format??Jr,o=_3(i.jarPath);if(I3(gh(o,"pom.xml"))&&await t.available("mvn")){await un(t,"mvn",`run cyclonedx-maven against ${o}`);let c=Bx(e.workDir,i.jarPath,"cyclonedx");await t.run(`mvn -f ${Se(gh(o,"pom.xml"))} org.cyclonedx:cyclonedx-maven-plugin:makeAggregateBom -DoutputFormat=json -DoutputName=${Se(T3(c,".json"))}`,{cwd:o});let{stdout:u}=await t.run(`cat ${Se(c)}`);return{format:"cyclonedx",mediaType:to.cyclonedx,bytes:u,packageCount:Tl("cyclonedx",u),generator:"cyclonedx-maven"}}let{bytes:a,generator:l}=await n(i.jarPath,r);return{format:r,mediaType:to[r],bytes:a,packageCount:Tl(r,a),generator:l}},async forZip(i){let r=i.format??Jr,{bytes:o,generator:s}=await n(i.zipPath,r);return{format:r,mediaType:to[r],bytes:o,packageCount:Tl(r,o),generator:s}},async forDir(i){let r=i.format??Jr;if(await t.available("syft")){let{bytes:a,generator:l}=await n(i.path,r);return{format:r,mediaType:to[r],bytes:a,packageCount:Tl(r,a),generator:l}}await un(t,"cdxgen",`scan ${i.path} for a software bill of materials (syft is also unavailable)`);let o=Bx(e.workDir,i.path,Fx);await t.run(`cdxgen -o ${Se(o)} ${Se(i.path)}`);let{stdout:s}=await t.run(`cat ${Se(o)}`);return{format:Fx,mediaType:to[Fx],bytes:s,packageCount:Tl(Fx,s),generator:"cdxgen"}}}}var lEe,Fx,z5e,D3=v(()=>{"use strict";Xo();Ki();lEe={spdx:"spdx-json",cyclonedx:"cyclonedx-json"},Fx="cyclonedx";z5e=uEe()});var N3=v(()=>{"use strict";pp();Ub();Xo()});function pEe(e){return/@sha256:[0-9a-f]{64}$/i.test(e)}function j3(e,t){if(!pEe(e))throw new Gx(e,t)}function L3(e,t){if(t.key){e.push("--key",Se(t.key.key));return}let n=t.keyless;n?.identityToken&&e.push("--identity-token",Se(n.identityToken)),n?.oidcIssuer&&e.push("--oidc-issuer",Se(n.oidcIssuer)),n?.oidcClientId&&e.push("--oidc-client-id",Se(n.oidcClientId)),n?.fulcioUrl&&e.push("--fulcio-url",Se(n.fulcioUrl)),n?.rekorUrl&&e.push("--rekor-url",Se(n.rekorUrl))}function fEe(e){let t=["cosign","sign","--yes"];L3(t,{keyless:e.keyless,key:e.key});for(let[n,i]of Object.entries(e.annotations??{}))t.push("-a",Se(`${n}=${i}`));return t.push(Se(e.imageRef)),t.join(" ")}function mEe(e=en()){return{kind:"sign",async run(t,n){return j3(n.imageRef,"sign"),await un(e,"cosign",`sign ${n.imageRef}`),await e.run(fEe(n)),{imageRef:n.imageRef,signed:!0,method:n.key?"key":"keyless"}}}}function M3(e){let t=/sha256:([0-9a-f]{64})$/i.exec(e);if(!t)throw new Gx(e,"attest");return t[1]}function F3(e){let t=M3(e.imageRef);return{_type:"https://in-toto.io/Statement/v1",predicateType:"https://slsa.dev/provenance/v1",subject:[{name:e.imageRef,digest:{sha256:t}}],predicate:{buildDefinition:{buildType:e.buildType??hEe,externalParameters:{...e.externalParameters,sourceRef:e.provenance.sourceRef},internalParameters:{...e.internalParameters,artifactDigest:e.provenance.artifactDigest},resolvedDependencies:[{uri:e.provenance.sourceRef,digest:{sha256:t}}]},runDetails:{builder:{id:e.builderId},metadata:{...e.invocationId?{invocationId:e.invocationId}:{},finishedOn:e.finishedOn??new Date().toISOString()}}}}}function yEe(e,t){let n=["cosign","attest","--yes","--type","slsaprovenance1","--predicate",Se(t)];return L3(n,{keyless:e.keyless,key:e.key}),n.push(Se(e.imageRef)),n.join(" ")}function bEe(e=en()){return{kind:"attest-provenance",async run(t,n){j3(n.imageRef,"attest"),await un(e,"cosign",`attest SLSA provenance for ${n.imageRef}`);let i=F3(n),r=`/tmp/chant-provenance-attest/${M3(n.imageRef)}-${Date.now()}.json`;return await e.run(`mkdir -p ${Se("/tmp/chant-provenance-attest")}`),await e.run(`printf '%s' ${Se(JSON.stringify(i))} > ${Se(r)}`),await e.run(yEe(n,r)),{imageRef:n.imageRef,statement:i,attested:!0,method:n.key?"key":"keyless"}}}}var Gx,gEe,hEe,wEe,Dj=v(()=>{"use strict";Ki();Gx=class extends Error{constructor(n,i){super(`${i} "${n}": expected a digest reference ("repo@sha256:...", e.g. from a prior publish step's "@Publish.uri") \u2014 signing a mutable tag would not pin which bytes were signed. Pass the digest-qualified reference instead.`);this.ref=n;this.verb=i;this.name="SignTargetNotDigestError"}};gEe=mEe(),hEe="https://chant.dev/build-archive/v1";wEe=bEe()});function B3(e,t){if(t.key){e.push("--key",Se(t.key));return}e.push("--certificate-oidc-issuer",Se(t.expectedIssuer)),e.push(t.identityIsRegexp?"--certificate-identity-regexp":"--certificate-identity",Se(t.expectedIdentity))}function vEe(e){let t=["cosign","verify"];return B3(t,e.policy),t.push(Se(e.imageRef)),t.join(" ")}function kEe(e){let t=["cosign","verify-attestation","--type","slsaprovenance1"];return B3(t,e.policy),t.push(Se(e.imageRef)),t.join(" ")}function xEe(e=en()){return{kind:"verify",async run(t,n){await un(e,"cosign",`verify ${n.imageRef} against the configured identity policy`);let i=[];try{await e.run(vEe(n))}catch(r){throw new Wx(n.imageRef,"signature",r instanceof Error?r.message:String(r))}if(i.push("signature"),n.requireProvenance!==!1){try{await e.run(kEe(n))}catch(r){throw new Wx(n.imageRef,"provenance",r instanceof Error?r.message:String(r))}i.push("provenance")}return{verified:!0,checked:i}}}}var Wx,$Ee,G3=v(()=>{"use strict";Ki();Wx=class extends Error{constructor(n,i,r){super(`verify "${n}": ${i} verification failed \u2014 ${r}`);this.imageRef=n;this.check=i;this.reason=r;this.name="VerificationFailedError"}};$Ee=xEe()});function REe(){let e=t=>async()=>{throw new Nj(t)};return{create:e("create"),checkpoint:e("checkpoint"),exec:e("exec"),restore:e("restore"),destroy:e("destroy"),writeFile:e("writeFile"),readFile:e("readFile")}}function SEe(e=REe()){let t=new WeakMap;return{kind:"run-agent",rollbackPolicy:"native",async run(n,i){let r=!!i.workspace.spriteName,o=i.workspace.spriteName??OEe(n);r||await e.create({name:o,image:i.workspace.image});let s=i.workspace.checkpointComment??"pre-run",{checkpointId:a}=await e.checkpoint({id:o,comment:s});t.set(i,{spriteId:o,checkpointId:a}),await e.writeFile({id:o,path:hh,content:i.task.prompt,mkdir:!0});let l=new Date().toISOString(),c=await e.exec({id:o,cmd:PEe(i.agent)}),u={status:c.exitCode===0?"completed":"failed",exitCode:c.exitCode,startedAt:l,endedAt:new Date().toISOString()},d=await _Ee(e,o);!r&&u.status==="completed"&&await e.destroy({id:o});let p=AEe({agent:i.agent,prompt:i.task.prompt,images:i.task.images,turn:u,stdout:c.stdout,stderr:c.stderr,artifacts:d}),g={sourceRef:i.sourceRef?`${i.sourceRef}@${p}`:p,artifactDigest:d.files[0]?.digest??EEe},h=`${n.component}/run-agent@${p}`;return{spriteId:o,checkpointId:a,turn:u,artifacts:d,provenance:g,attestationRef:h}},async rollback(n,i,r){let o=t.get(i),s=r?.spriteId??o?.spriteId??i.workspace.spriteName;if(!s)return;let a=r?.checkpointId??o?.checkpointId;if(a){await e.restore({id:s,checkpoint:a});return}let l=i.workspace.checkpointComment??"pre-run";await e.restore({id:s,comment:l})}}}function AEe(e){let t={agent:e.agent,promptDigest:Za(e.prompt),images:(e.images??[]).map(n=>({mediaType:n.media_type,digest:Za(n.data)})),status:e.turn.status,exitCode:e.turn.exitCode,stdoutDigest:Za(e.stdout),stderrDigest:Za(e.stderr),artifacts:[...e.artifacts.files].sort((n,i)=>n.path<i.path?-1:n.path>i.path?1:0).map(n=>({path:n.path,digest:n.digest})),diffDigest:Za(e.artifacts.diff??"")};return Za(JSON.stringify(t))}function PEe(e){switch(e){case"claude":return`claude -p "$(cat ${hh})" --output-format json`;case"codex":return`codex exec "$(cat ${hh})"`;case"gemini":return`gemini -p "$(cat ${hh})"`;case"opencode":return`opencode run "$(cat ${hh})"`;default:return e}}function OEe(e){let t=Math.random().toString(36).slice(2,10);return`run-agent-${e.component}-${t}`.replace(/[^a-zA-Z0-9._-]/g,"-")}function CEe(e){return e instanceof Error&&/^sprite .+ read .+: not found$/.test(e.message)}async function _Ee(e,t){try{let{content:n}=await e.readFile({id:t,path:W3});return{files:[{path:W3,digest:Za(n)}]}}catch(n){if(CEe(n))return{files:[]};throw n}}var Nj,hh,W3,Za,EEe,t9e,z3=v(()=>{"use strict";as();Dj();Nj=class extends Error{constructor(n){super(`SpriteActivities.${n}: not wired to a real sprite backend yet \u2014 sprite lifecycle wiring is #1942 (epic #1564 phase 2). Inject a real or fake ("sprites-fake"/"sprites-emulator") implementation to exercise "run-agent" end to end.`);this.method=n;this.name="SpriteActivitiesNotWiredError"}};hh="/work/prompt",W3="/work/output",Za=Nr,EEe=Za("");t9e=SEe()});function Ux(e,t){return t?`${e}#${t}`:e}function IEe(e){let t=["wrangler","deploy","--config",Se(e.config)];return e.env&&t.push("--env",Se(e.env)),t.join(" ")}function TEe(e,t){let n=["wrangler","versions","list","--config",Se(e),"--json"];return t&&n.push("--env",Se(t)),n.join(" ")}function jj(e,t,n,i){let r=["wrangler","versions","deploy",Se(`${t}@${n}`),"--config",Se(e),"--yes"];return i&&r.push("--env",Se(i)),r.join(" ")}function NEe(e){let t=DEe.exec(e);if(!t)throw new Lj(e);return t[1]}async function U3(e,t,n){try{let{stdout:i}=await e.run(TEe(t,n));return JSON.parse(i).find(o=>o.percentage===100)?.id}catch{return}}function jEe(e=en()){let t=new Map;return{kind:"wrangler-deploy",async run(n,i){await un(e,zx,`deploy the Worker in ${i.config}`);let r=Ux(i.config,i.env);t.has(r)||t.set(r,await U3(e,i.config,i.env));let{stdout:o}=await e.run(IEe(i));return{versionId:NEe(o)}},async rollback(n,i){let r=Ux(i.config,i.env),o=t.get(r);o&&(await un(e,zx,`roll back the Worker in ${i.config}`),await e.run(jj(i.config,o,100,i.env)))}}}function MEe(e=en()){let t=new Map;return{kind:"wrangler-versions-promote",async run(n,i){await un(e,zx,`promote version ${i.versionId} in ${i.config}`);let r=i.percentage??100,o=Ux(i.config,i.env);return t.has(o)||t.set(o,await U3(e,i.config,i.env)),await e.run(jj(i.config,i.versionId,r,i.env)),{versionId:i.versionId,percentage:r}},async rollback(n,i){let r=Ux(i.config,i.env),o=t.get(r);o&&(await un(e,zx,`roll back version promotion in ${i.config}`),await e.run(jj(i.config,o,100,i.env)))}}}var zx,Lj,DEe,LEe,FEe,H3=v(()=>{"use strict";Ki();zx="wrangler";Lj=class extends Error{constructor(n){super(`wrangler-deploy: could not find a Version ID in wrangler's output. Got:
|
|
223
|
+
${n}`);this.stdout=n;this.name="WranglerVersionIdNotFoundError"}},DEe=/Version(?: ID)?:\s*([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})/;LEe=jEe();FEe=MEe()});function WEe(e,t="r2"){let n=GEe.exec(e);if(!n)throw new Mj(e);let[,i,r]=n;return`${t}:${i}${r?`/${r}`:""}`}function zEe(e){let t=WEe(e.to,e.remote);return`rclone ${e.delete?"sync":"copy"} ${Se(e.from)} ${Se(t)} -v`}function qEe(e){let t=(e.match(UEe)??[]).length+(e.match(HEe)??[]).length,n=(e.match(VEe)??[]).length;return{uploaded:t,deleted:n}}function KEe(e=en()){return{kind:"r2-sync",rollbackPolicy:"needs-opt-out",async run(t,n){await un(e,BEe,`sync ${n.from} to ${n.to}`);let{stdout:i}=await e.run(zEe(n));return qEe(i)}}}var BEe,GEe,Mj,UEe,HEe,VEe,JEe,V3=v(()=>{"use strict";Ki();BEe="rclone",GEe=/^r2:\/\/([^/]+)(?:\/(.*))?$/,Mj=class extends Error{constructor(n){super(`r2-sync: destination "${n}" is not an "r2://bucket[/prefix]" URI \u2014 mirror s3-sync's "s3://bucket/prefix" shape.`);this.to=n;this.name="R2SyncInvalidDestinationError"}};UEe=/: Copied \(new\)/g,HEe=/: Copied \(replaced existing\)/g,VEe=/: Deleted$/gm;JEe=KEe()});import{readFileSync as c9e,writeFileSync as ZEe}from"node:fs";import{tmpdir as YEe}from"node:os";import{join as XEe}from"node:path";import{createHash as QEe}from"node:crypto";function q3(e){let t=(e??"").toLowerCase();return t==="critical"||t==="high"||t==="medium"||t==="low"||t==="negligible"?t:"unknown"}function eAe(e){return(JSON.parse(e).matches??[]).map(n=>{let i=n.vulnerability?.fix?.versions??[],r=n.vulnerability?.epss?.[0],o=n.vulnerability?.knownExploited?.[0];return{cveId:n.vulnerability?.id??"UNKNOWN",severity:q3(n.vulnerability?.severity),package:n.artifact?.name??"unknown",installedVersion:n.artifact?.version??"",fixedVersion:i[0],fixable:n.vulnerability?.fix?.state==="fixed"||i.length>0,epss:r?.epss,epssPercentile:r?.percentile,inKev:o?!0:void 0,kevDateAdded:o?.dateAdded,kevDueDate:o?.dueDate,kevRansomware:o?.knownRansomwareCampaignUse?.toLowerCase()==="known"?!0:void 0}})}function tAe(e){let t=JSON.parse(e),n=[];for(let i of t.Results??[])for(let r of i.Vulnerabilities??[])n.push({cveId:r.VulnerabilityID??"UNKNOWN",severity:q3(r.Severity),package:r.PkgName??"unknown",installedVersion:r.InstalledVersion??"",fixedVersion:r.FixedVersion||void 0,fixable:!!r.FixedVersion});return n}function nAe(e="grype",t=en()){return{async scan(n){await un(t,e,"scan the SBOM for known vulnerabilities");let i=QEe("sha256").update(n.sbom.bytes).digest("hex").slice(0,16),r=n.sbom.format==="cyclonedx"?"cdx.json":"spdx.json",o=XEe(YEe(),`chant-scan-${i}.${r}`);if(ZEe(o,n.sbom.bytes),e==="trivy"){let{stdout:a}=await t.run(`trivy sbom --quiet --format json ${Se(o)}`);return tAe(a)}let{stdout:s}=await t.run(`grype sbom:${Se(o)} -o json`);return eAe(s)}}}function rAe(e=en()){return{async scan(t){let n=await e.available("grype")?"grype":await e.available("trivy")?"trivy":void 0;if(!n)throw new mh("grype or trivy","scan the SBOM for known vulnerabilities");return nAe(n,e).scan(t)}}}function Bj(){return Fj||(Fj=rAe()),Fj}function iAe(e=Bj()){return{kind:"scan-vulnerabilities",async run(t,n){return{findings:await e.scan({sbom:n.sbom,digest:n.digest}),digest:n.digest}}}}var Hx,Fj,oAe,Gj=v(()=>{"use strict";Ki();Hx={critical:5,high:4,medium:3,low:2,negligible:1,unknown:0};oAe=iAe()});function sAe(e){return e==="not_affected"||e==="fixed"}function aAe(e){switch((e??"").toLowerCase()){case"not_affected":return"not_affected";case"affected":return"affected";case"fixed":return"fixed";case"under_investigation":return"under_investigation";default:return}}function cAe(e){let t=JSON.parse(e),n=[];for(let i of t.statements??[]){let r=typeof i.vulnerability=="string"?i.vulnerability:i.vulnerability?.name??i.vulnerability?.["@id"],o=aAe(i.status);!r||!o||n.push({cveId:r,status:o,justification:i.justification??i.impact_statement})}return n}function lAe(e){switch((e??"").toLowerCase()){case"not_affected":case"false_positive":return"not_affected";case"resolved":case"resolved_with_pedigree":return"fixed";case"exploitable":return"affected";case"in_triage":return"under_investigation";default:return}}function uAe(e){let t=JSON.parse(e),n=[];for(let i of t.vulnerabilities??[]){let r=lAe(i.analysis?.state);!i.id||!r||n.push({cveId:i.id,status:r,justification:i.analysis?.justification??i.analysis?.detail})}return n}function K3(e){let t;try{t=JSON.parse(e)}catch{return[]}return Array.isArray(t.statements)?cAe(e):Array.isArray(t.vulnerabilities)?uAe(e):[]}function J3(e,t){let n=new Map;for(let o of t){let s=n.get(o.cveId);s?s.push(o):n.set(o.cveId,[o])}let i=[],r=[];for(let o of e){let s=n.get(o.cveId)??[],l=s.some(c=>c.status==="affected"||c.status==="under_investigation")?void 0:s.find(c=>sAe(c.status));l?r.push({finding:o,status:l.status,justification:l.justification}):i.push(o)}return{gating:i,suppressed:r}}var Wj=v(()=>{"use strict"});function dAe(e){let t=JSON.parse(e.bytes);return e.format==="cyclonedx"||Array.isArray(t.components)?(t.components??[]).map(n=>{let i=n.licenses?.[0],r=i?.expression??i?.license?.id??i?.license?.name??"NOASSERTION";return{package:n.name??"unknown",license:r}}):(t.packages??[]).map(n=>({package:n.name??"unknown",license:n.licenseConcluded&&n.licenseConcluded!=="NOASSERTION"?n.licenseConcluded:n.licenseDeclared??"NOASSERTION"}))}function Z3(e,t){let n=t.toLowerCase();return e.some(i=>i.toLowerCase()===n)}function pAe(e){return e.replace(/[()]/g," ").split(/\s+(?:OR|AND)\s+/i).map(t=>t.split(/\s+WITH\s+/i)[0].trim()).filter(Boolean)}function Y3(e,t){let n=[];for(let{package:i,license:r}of dAe(e)){if(!r||r==="NOASSERTION")continue;let o=pAe(r);if(t.deny&&o.some(s=>Z3(t.deny,s))){n.push({package:i,license:r,reason:"denied"});continue}t.allow&&t.allow.length>0&&o.some(s=>!Z3(t.allow,s))&&n.push({package:i,license:r,reason:"not-allowed"})}return n}var zj=v(()=>{"use strict"});function mAe(e){let t=e.finding;switch(e.reason){case"kev":{let n=t.kevDateAdded?`in CISA KEV since ${t.kevDateAdded}`:"in CISA KEV";return t.kevRansomware?`${n}, known ransomware use`:n}case"epss-threshold":return`EPSS ${t.epss} at/above the fail threshold`;case"unknown-severity":return"severity unreported by the scanner (failOnUnknownSeverity)";case"severity-threshold":return`severity at/above the fail threshold${t.fixable?", fixable":""}`}}function gAe(e){let t=[];for(let n of e??[])t.push(...K3(n));return t}function hAe(e=Bj()){return{kind:"vuln-gate",async run(t,n){let i={...fAe,...n.policy},r=n.findings??await e.scan({sbom:n.sbom,digest:n.digest}),{gating:o,suppressed:s}=J3(r,gAe(n.vex)),a=Hx[i.failSeverity],l=Hx[i.warnSeverity],c=[],u=[];for(let f of o){let g=Hx[f.severity],h=i.failEpssAtOrAbove!==void 0&&f.epss!==void 0&&f.epss>=i.failEpssAtOrAbove,b=i.warnEpssAtOrAbove!==void 0&&f.epss!==void 0&&f.epss>=i.warnEpssAtOrAbove,w=i.failOnKev&&f.inKev===!0,x=!i.exploitabilityFixableOnly||f.fixable;w&&x?c.push({finding:f,reason:"kev"}):h&&x?c.push({finding:f,reason:"epss-threshold"}):g>=a&&(!i.fixableOnly||f.fixable)?c.push({finding:f,reason:"severity-threshold"}):f.severity==="unknown"?i.failOnUnknownSeverity?c.push({finding:f,reason:"unknown-severity"}):u.push(f):(g>=l||w||h||b)&&u.push(f)}let d=i.license?Y3(n.sbom,i.license):[],p=i.failOnLicense?d:[];if(c.length>0||p.length>0)throw new Uj(c,p);return{passed:!0,warnings:u,suppressed:s,licenseFindings:d}}}}var fAe,Uj,yAe,X3=v(()=>{"use strict";Gj();Wj();zj();fAe={failSeverity:"critical",fixableOnly:!0,warnSeverity:"high",failOnLicense:!1,failOnUnknownSeverity:!1,failOnKev:!1,exploitabilityFixableOnly:!0},Uj=class extends Error{constructor(n,i){let r=i.map(s=>`${s.license} in ${s.package}`).join(", "),o=[];if(n.length){let s=n.map(a=>` ${a.finding.cveId} (${a.finding.severity}, ${a.finding.package}) \u2014 ${mAe(a)}`);o.push(`${n.length} vulnerability finding(s):
|
|
224
|
+
${s.join(`
|
|
225
|
+
`)}`)}i.length&&o.push(`${i.length} license violation(s): ${r}`);super(`vuln-gate blocked the deploy \u2014 ${o.join(`
|
|
226
|
+
`)}
|
|
227
|
+
Fix the dependency, or record a VEX statement if it is not exploitable.`);this.blocking=n;this.blockingLicenses=i;this.name="VulnGateFailedError"}};yAe=hAe()});function bAe(e=jx()){return{kind:"wait-cluster-healthy",async run(t,n){let i=n.cluster??t.vars?.clusterEndpoints??t.component,r=n.intervalMs??5e3,o=Date.now()+(n.timeoutMs??5*6e4);for(;;){let{healthyCount:s,total:a}=await e.neo4j.probe({cluster:i}),l=n.quorum?Math.floor(a/2)+1:n.size??a;if(s>=l)return{healthyCount:s};if(Date.now()>o)throw new Error(`wait-cluster-healthy "${i}" timed out: ${s}/${a} healthy, needed ${l}`);await Lx(r)}}}}function vAe(e=e8){return{kind:"wait-endpoint",async run(t,n){let i=n.expectStatus??[200],r=n.intervalMs??5e3,o=n.timeoutMs??5*6e4,s=Date.now()+o;for(;;){try{let a=await e(n.url);if(i.includes(a.status))return{status:a.status}}catch{}if(Date.now()>=s)throw new Error(`wait-endpoint: ${n.url} did not return ${i.join("/")} within ${o}ms`);await Lx(r)}}}}function Q3(e){if(!e.host)return e.path;let t=/^https?:\/\//.test(e.host)?e.host:`http://${e.host}`;return new URL(e.path,t).toString()}function xAe(e=e8){return{kind:"health-gate",async run(t,n){let i=n.consecutiveSuccesses??1,r=n.intervalMs??5e3,o=Date.now()+5*6e4,s=0;for(;;){let a=!1;try{a=(await e(Q3(n))).ok}catch{a=!1}if(s=a?s+1:0,s>=i)return{healthy:!0};if(Date.now()>=o)throw new Error(`health-gate: ${Q3(n)} did not reach ${i} consecutive healthy check(s) within 300000ms`);await Lx(r)}}}}var e8,wAe,kAe,$Ae,t8=v(()=>{"use strict";Mx();e8=e=>fetch(e);wAe=bAe();kAe=vAe();$Ae=xAe()});function SAe(e){return e?[["service.version",e.version],["vcs.ref.head.revision",e.revision]].filter(n=>n[1]!==void 0&&n[1]!=="").map(([n,i])=>`,${n}=${encodeURIComponent(i)}`).join(""):""}function n8(e){let t=SAe(e);return t===""?{}:{[RAe]:t}}var RAe,r8=v(()=>{"use strict";Si();RAe="CHANT_RELEASE_ATTRIBUTES"});function EAe(e=en()){return{kind:"shell",async run(t,n){let i={...n8(t.release),...n.env??{}},r=Object.keys(i).length>0?`env ${Object.entries(i).map(([s,a])=>`${s}=${Se(a)}`).join(" ")} `:"",{stdout:o}=await e.run(`${r}${n.cmd}`,{cwd:n.cwd});return{stdout:o,exitCode:0}}}}var AAe,i8=v(()=>{"use strict";Ki();r8();AAe=EAe()});var Hj=v(()=>{"use strict"});var o8=v(()=>{"use strict";Hj();rN()});var s8=v(()=>{"use strict";pp();O3();Ub();Xo();C3();yO();D3();N3();Cj();Dj();G3();z3();H3();V3();Gj();Wj();zj();X3();t8();i8();o8();Mx();Ki()});var Vj=v(()=>{"use strict"});var a8,qj=v(()=>{"use strict";s8();Vj();a8={build:["docker-build","zip-package","jvm-build"],sbom:["generate-sbom"],supplyChainSecurity:["sign","attest-provenance","verify"],supplyChainPolicy:["scan-vulnerabilities","vuln-gate"],waitVerify:["wait-cluster-healthy","wait-endpoint","health-gate"],secrets:["ensure-secret"],escapeHatch:["shell"],cloudflare:["wrangler-deploy","wrangler-versions-promote","r2-sync"]}});var c8=v(()=>{"use strict"});var m3e,l8=v(()=>{"use strict";qj();c8();m3e=new Set(Object.values(a8).flat())});var u8=v(()=>{"use strict";Ei();Zs()});import{createRequire as PAe}from"module";function OAe(){if(!d8&&(d8=!0,!Mn()))try{let e=PAe(import.meta.url),{register:t}=e("tsx/cjs/api");t()}catch{}}var d8,p8=v(()=>{"use strict";Ei();d8=!1;import.meta.url.endsWith(".js")||OAe()});var f8=v(()=>{"use strict"});var m8=v(()=>{"use strict"});var CAe,x3e,gi=v(()=>{"use strict";CAe={"read-failed":!0,"no-credentials":!0,"no-binding":!0,"unsupported-kind":!0,filtered:!0},x3e=Object.keys(CAe)});function Zj(e,t=process.env){let n=e;for(let[i,r]of Object.entries(t))!r||r.length<_Ae||Vx.test(i)&&n.includes(r)&&(n=n.split(r).join(Hr));for(let i of Kj)n=n.replace(i,Hr);for(let{re:i}of Jj)n=n.replace(i,Hr);return n}var Hr,Vx,_Ae,Kj,Jj,qx=v(()=>{"use strict";Hr="[redacted]",Vx=/(SECRET|TOKEN|PASSWORD|PASSWD|CREDENTIAL|PRIVATE_KEY|APIKEY|API_KEY|ACCESS_KEY|SESSION_KEY|AUTH)/i,_Ae=8,Kj=[/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/g,/\beyJ[A-Za-z0-9_-]{4,}\.[A-Za-z0-9_-]{4,}\.[A-Za-z0-9_-]*/g,/\b(?:Bearer|Basic)\s+[A-Za-z0-9\-._~+/]{16,}={0,2}/g],Jj=[{name:"a GitHub token",re:/\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{6,}\b/g},{name:"a GitHub fine-grained token",re:/\bgithub_pat_[A-Za-z0-9_]{6,}\b/g},{name:"a GitLab personal access token",re:/\bglpat-[A-Za-z0-9_-]{3,}\b/g},{name:"an OpenAI-style secret key",re:/\bsk-(?:live-|proj-|test-)?[A-Za-z0-9]{6,}\b/g},{name:"a Stripe key",re:/\b[rs]k_(?:live|test)_[A-Za-z0-9]{6,}\b/g},{name:"a Slack token",re:/\bxox[abposr]-[A-Za-z0-9-]{6,}\b/g},{name:"an AWS access key id",re:/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g},{name:"a Google API key",re:/\bAIza[0-9A-Za-z_-]{20,}\b/g},{name:"a Google OAuth token",re:/\bya29\.[0-9A-Za-z_-]{10,}/g},{name:"an npm token",re:/\bnpm_[A-Za-z0-9]{10,}\b/g}]});var Yj=v(()=>{"use strict"});var fp=v(()=>{"use strict";rx()});function eL(e){return typeof e=="string"&&DAe.includes(e)}function tL(e,t){return{rate:"per-hour",perHour:e,currency:t}}function nL(e){return typeof e=="string"&&jAe.includes(e)}function Kx(e){return typeof e=="string"&&b8.includes(e)}function Xa(e){return typeof e=="object"&&e!==null&&"refusal"in e}function w8(e){if(typeof e!="object"||e===null)return!1;let t=e;return t.behaviour!=="v1"?!1:typeof t.refusal=="object"&&t.refusal!==null?!0:typeof t.entities=="object"&&t.entities!==null&&typeof t.meta=="object"&&t.meta!==null}function g8(e){return MAe.includes(e.trim().toLowerCase().replace(/\.$/,""))}function rL(e,t){let n=a=>{throw new Error(`predictBehaviour produced an invalid block for "${e}": ${a}. behold's own validator (behold/src/behaviour.ts) drops a block failing this, so it would render nothing rather than render wrong \u2014 which is worse to debug, because everything here looked legal.`)};Do(t.at?.traffic)||n("at.traffic is missing \u2014 name the traffic level you priced");let i=t.cost?.perHour;(typeof i!="number"||!Number.isFinite(i))&&n("cost.perHour is not a finite number"),i<0&&n("cost.perHour is negative"),Do(t.cost?.currency)||n("cost.currency is missing");let r=t.headroom;(!r||typeof r!="object")&&n("headroom is missing");let o=r;o.cpu!==void 0&&!Xj(o.cpu)&&n("headroom.cpu is not a fraction 0..1"),o.latency!==void 0&&!Xj(o.latency)&&n("headroom.latency is not a fraction 0..1"),o.cpu===void 0&&o.latency===void 0&&n("headroom carries neither cpu nor latency \u2014 an axis you did not model is absent, and a block with no axis at all says nothing"),Xj(t.errorRate)||n("errorRate is not a fraction 0..1"),Do(t.resilience?.failure)||n("resilience.failure is missing \u2014 a verdict with no named failure says nothing"),g8(t.resilience.failure)&&n(`resilience.failure ${JSON.stringify(t.resilience.failure)} names no failure. behold takes any non-empty string here, so this passes its validator and renders a confident verdict about nothing. Name the event: "one zone lost", "primary database failover"`),nL(t.resilience?.verdict)||n(`resilience.verdict ${JSON.stringify(t.resilience?.verdict)} is not survives/degrades/fails`),t.rightSize!==void 0&&!Do(t.rightSize.suggestion)&&n("rightSize is present without a suggestion");let s=t.provenance;(!s||typeof s!="object")&&n("provenance is missing"),Do(s?.engine)||n("provenance.engine is missing"),Do(s?.version)||n("provenance.version is missing"),Do(s?.tolerance)||n("provenance.tolerance is missing \u2014 a figure without a stated tolerance is not a prediction"),g8(s.tolerance)&&n(`provenance.tolerance ${JSON.stringify(s.tolerance)} states no tolerance. An engine with nothing to say about its own error bars has no business publishing a figure; say the number, however wide`),eL(s?.basis)||n(`provenance.basis ${JSON.stringify(s?.basis)} is not modeled/validated`)}function v8(e,t,n,i){if(!Do(t?.engine))throw new Error("predictBehaviour: meta.engine is missing");if(!Do(t?.version))throw new Error("predictBehaviour: meta.version is missing");if(!Do(e?.traffic))throw new Error("predictBehaviour: meta.at.traffic is missing");if(t.total&&(!Number.isFinite(t.total.perHour)||t.total.perHour<0))throw new Error("predictBehaviour: meta.total.perHour is not a non-negative finite number");aL(e.edgeCoverage);let r={engine:t.engine,version:t.version,at:{traffic:e.traffic},...t.total?{total:t.total}:{},edgeCoverage:cPe(e.edgeCoverage)},o=e.entityNames,s=new Set(o),a=new Set(Object.keys(i??{}));for(let c of Object.keys(n)){if(a.has(c))throw new Error(`predictBehaviour reported "${c}" as both priced and unpriced. An entity has one verdict.`);if(!s.has(c))throw new Error(`predictBehaviour returned a figure for "${c}", which was not in entityNames. An engine answering about entities nobody asked about is answering about the wrong estate.`);if(rL(c,n[c]),n[c].at.traffic!==r.at.traffic)throw new Error(`predictBehaviour priced "${c}" at ${JSON.stringify(n[c].at.traffic)} in a run whose meta.at.traffic is ${JSON.stringify(r.at.traffic)}. One run, one level.`)}for(let c of a){if(!s.has(c))throw new Error(`predictBehaviour reported "${c}" unpredicted, and it was not in entityNames.`);if(!Kx(i[c]?.reason))throw new Error(`predictBehaviour gave "${c}" the reason ${JSON.stringify(i[c]?.reason)}, which is not one of ${b8.join(", ")}.`)}let l=o.filter(c=>!Object.prototype.hasOwnProperty.call(n,c)&&!a.has(c));if(l.length>0)throw new Error(`predictBehaviour gave no verdict at all for ${l.map(c=>`"${c}"`).join(", ")}. Every entity asked about lands in \`entities\` or in \`unpredicted\` \u2014 there is no third position, because a prediction has no equivalent of "the provider says it is not there". An entity you could not price is \`unsupported-kind\`, not an omission.`);return{behaviour:"v1",meta:r,entities:n,...i&&Object.keys(i).length>0?{unpredicted:i}:{}}}function Dl(e){return{behaviour:"v1",refusal:e}}function FAe(e,t){return e.engine!==t.engine||e.version!==t.version||e.tolerance!==t.tolerance?"mixed-engine":e.basis===t.basis?"comparable":"mixed-basis"}function x8(e,t){let n=new Set;return FAe(e.provenance,t.provenance)==="mixed-engine"&&n.add("mixed-engine"),e.at.traffic!==t.at.traffic&&n.add("mixed-level"),e.cost.currency!==t.cost.currency&&n.add("mixed-currency"),e.provenance.basis!==t.provenance.basis&&n.add("mixed-basis"),e.resilience.failure!==t.resilience.failure&&n.add("mixed-failure"),n}function iL(e){return[`CHANT_BEHAVIOUR_ENGINE_${e.toUpperCase().replace(/[^A-Z0-9]+/g,"_")}`,"CHANT_BEHAVIOUR_ENGINE","BEHAVIOUR_ENGINE"]}function $8(e,t){for(let n of iL(e)){let i=t[n]?.trim();if(i)return{value:i,source:n}}}function BAe(e){let[t,n,i]=iL(e);return`predictBehaviour has the ${e} estate to predict and no engine to predict it with. Set a ${n} environment variable to the engine's address \u2014 a URL, a socket path, or a command on PATH \u2014 or ${i} where nothing else in the environment is chant's. ${t} is read first, for an estate whose lexicons are priced by different engines. The address is not a credential: the engine is never handed one and never writes.`}function oL(e){return[`CHANT_BEHAVIOUR_TOKEN_${e.toUpperCase().replace(/[^A-Z0-9]+/g,"_")}`,"CHANT_BEHAVIOUR_TOKEN","BEHAVIOUR_TOKEN"]}function R8(e,t){for(let n of oL(e)){let i=t[n]?.trim();if(i)return{value:i,source:n}}}function GAe(e,t){let[n,i,r]=oL(e);return`predictBehaviour has the ${e} behaviour engine at ${Ya(t.value)}, named by ${t.source}, and no token to authenticate to it with, so nothing was sent. Set a ${i} environment variable to the bearer token the engine issued \u2014 or ${r} where nothing else in the environment is chant's. ${n} is read first, for an estate whose lexicons are priced by different engines on different accounts. The token goes in a header the engine reads and nowhere else; it is never in the request body and never in a message.`}function S8(e,t){let[,n]=oL(e);return Dl({cause:"no-engine",reason:GAe(e,t),remedy:`Set ${n} to the bearer token the engine at ${Ya(t.value)} issued.`})}function E8(e,t,n,i){return Dl({cause:"no-engine",reason:`The ${e} behaviour engine at ${Ya(t.value)}, named by ${t.source}, answered and rejected the token ${n.source} holds (${Jx(i)}). The address is reachable and the account is not the problem; the token is not one this engine accepts. No overlay is drawn and no figure is guessed locally.`,remedy:`Set ${n.source} to a bearer token the engine at ${Ya(t.value)} accepts.`,source:n.source})}function WAe(e,t,n){return`predictBehaviour reached for the ${e} behaviour engine at ${Ya(t.value)}, named by ${t.source}, and it did not answer: ${Jx(n)}. No overlay is drawn and no figure is guessed locally. Check the engine is up and that ${t.source} names the address this environment can reach.`}function A8(e){let[,t]=iL(e);return Dl({cause:"no-engine",reason:BAe(e),remedy:`Set ${t} to the engine's address.`})}function yh(e,t,n){return Dl({cause:"engine-unreachable",reason:WAe(e,t,n),remedy:`Check the engine at ${Ya(t.value)} is reachable, or repoint ${t.source}.`,source:t.source})}function zAe(e,t,n){return`The ${e} behaviour engine at ${Ya(t.value)}, named by ${t.source}, answered and refused: the account behind it is out of credit (${Jx(n)}). The address is reachable and nothing here is a networking problem. Add credit to the account this engine bills, or point ${t.source} at an engine on an account that has some. No overlay is drawn and no figure is guessed locally.`}function UAe(e,t,n){return`The ${e} behaviour engine at ${Ya(t.value)}, named by ${t.source}, answered and refused: a rate or volume limit is spent (${Jx(n)}). The account has credit and the address is reachable, so this usually clears when the engine's window rolls over. Wait for it, raise the limit on the account, or point ${t.source} at an engine with its own budget. No overlay is drawn and no figure is guessed locally.`}function HAe(e,t,n){return Dl({cause:"engine-out-of-credit",reason:zAe(e,t,n),remedy:`Add credit to the account behind ${t.source}, or repoint it at a funded engine.`,source:t.source})}function VAe(e,t,n){return Dl({cause:"engine-over-quota",reason:UAe(e,t,n),remedy:`Wait for the engine's window to roll over, or raise the limit on the account behind ${t.source}.`,source:t.source})}function Qa(e,t,n,i){switch(n){case"engine-out-of-credit":return HAe(e,t,i);case"engine-over-quota":return VAe(e,t,i);case"engine-unreachable":return yh(e,t,i)}}function P8(e=process.env){return{PATH:e.PATH??""}}function sL(e,t={}){let n=t.color??(!process.env.NO_COLOR&&process.stdout.isTTY!==!1),i=`behaviour: refused (${e.cause}) \u2014 ${e.reason}
|
|
228
|
+
${e.remedy}`;return n?`${qAe}${i}${KAe}`:i}function ePe(e){if(/^[a-z][a-z0-9+.-]*:\/\//i.test(e))try{if(new URL(e).password!=="")return!0}catch{}return/^[^\s:@/]+:[^\s:@/]+@[A-Za-z0-9._-]+(?::\d+)?(?:[/?#]|$)/.test(e.trim())}function tPe(e){let t=e.toLowerCase().replace(/[^a-z0-9]/g,"");return XAe.includes(t)||YAe.some(n=>t.endsWith(n))?!1:JAe.includes(t)?!0:Vx.test(e)||QAe.test(t)}function nPe(e){return/^\{\{[^}]+\}\}$/.test(e.trim())||/^\$\{[^}]+\}$/.test(e.trim())||/^!(?:Ref|GetAtt|Sub|ImportValue)\b/.test(e.trim())||/^arn:[a-z0-9-]*:secretsmanager:/i.test(e.trim())||/^projects\/[^/]+\/secrets\/[^/]+/.test(e.trim())}function rPe(e){for(let t of Kj)if(t.lastIndex=0,t.test(e))return"a literal credential shape (PEM key, JWT or Authorization value)";for(let{name:t,re:n}of Jj)if(n.lastIndex=0,n.test(e))return t;if(ePe(e))return"a password in a URL's userinfo"}function iPe(e){if(!/^[a-z][a-z0-9+.-]*:\/\//i.test(e))return e;try{let t=new URL(e),n=t.username!==""||t.password!=="",i=t.search!=="",r=t.hash!=="";t.username="",t.password="",t.search="",t.hash="";let o=t.toString();return n&&(o=o.replace("://",`://${Hr}@`)),i&&(o+=`?${Hr}`),r&&(o+=`#${Hr}`),o}catch{return e}}function oPe(e){return e.replace(/(--?[A-Za-z0-9-]*(?:secret|token|password|passwd|key|credential|auth|pat)[A-Za-z0-9-]*)([=\s])(\S+)/gi,(t,n,i)=>`${n}${i}${Hr}`).replace(/(^|\s)(-[pPkK])(\s+)(\S+)/g,(t,n,i,r)=>`${n}${i}${r}${Hr}`)}function Ya(e,t=process.env){return Zj(oPe(iPe(e)),t)}function Jx(e,t=process.env){let n=e.replace(/\b[a-z][a-z0-9+.-]*:\/\/\S+/gi,r=>{try{return new URL(r).host||Hr}catch{return Hr}}),i=Zj(n,t).replace(/\s+/g," ").trim();return i.length>h8?`${i.slice(0,h8)}\u2026`:i}function aPe(e){return typeof e=="string"&&O8.includes(e)}function cPe(e){let t={verdict:e.verdict,...e.dangling?{dangling:Object.freeze(e.dangling.map(n=>Object.freeze({...n})))}:{},...e.unresolvedKinds?{unresolvedKinds:Object.freeze([...e.unresolvedKinds])}:{},...e.containmentEdges?{containmentEdges:Object.freeze(e.containmentEdges.map(n=>Object.freeze({...n})))}:{}};return Object.freeze(t)}function aL(e){if(!aPe(e?.verdict))throw new Error(`predictBehaviour: edgeCoverage.verdict ${JSON.stringify(e?.verdict)} is not ${O8.join("/")}.`);if(e.verdict==="partial"&&(e.dangling?.length??0)===0&&(e.unresolvedKinds?.length??0)===0)throw new Error('predictBehaviour: edgeCoverage is "partial" and names nothing missing. Populate `dangling` or `unresolvedKinds`, or say "unknown" \u2014 a partial that lists no gap is an unknown with a more confident word on it.')}function C8(e){let t=[],n=new WeakSet,i=(o,s,a)=>{if(a>y8){t.push({path:s,rule:"walk-depth",what:`a structure deeper than ${y8} levels, which the credential walk did not read`});return}if(typeof o=="string"){let l=rPe(o);l&&t.push({path:s,rule:"value-shape",what:l});return}if(!(o===null||typeof o!="object")&&!n.has(o)){if(n.add(o),Array.isArray(o)){o.forEach((l,c)=>i(l,`${s}[${c}]`,a+1));return}if(o instanceof Map){for(let[l,c]of o){let u=typeof l=="string"?l:String(l),d=`${s}.get(${u})`;typeof l=="string"&&r(l,d,c),i(c,d,a+1)}return}if(o instanceof Set){let l=0;for(let c of o)i(c,`${s}.item[${l++}]`,a+1);return}for(let[l,c]of Object.entries(o)){let u=`${s}.${l}`;r(l,u,c),i(c,u,a+1)}}};function r(o,s,a){typeof a=="string"&&(a.length<ZAe||nPe(a)||tPe(o)&&t.push({path:s,rule:"key-name",what:`a credential-shaped field name ("${o}")`}))}return i(e,"options",0),t}function lPe(e){let t=C8(e).filter(i=>i.rule==="value-shape");if(t.length===0)return;let[n]=t;throw new Error(`predictBehaviour was passed ${n.what} at ${n.path}. The behaviour engine is never handed a credential: it is given the resource graph and a traffic level, and nothing it receives can reach the account. Remove it \u2014 a lexicon that needs authenticated access to its own engine resolves that on its own transport, not through this contract.`)}function _8(e,t){lPe(t);let n=C8(t);if(n.length===0)return;let[i]=n,r=n.length>1?` (and ${n.length-1} more)`:"";return Dl({cause:"credential-in-request",reason:`The ${e} behaviour request carries ${i.what} at ${i.path}${r}, so it was not sent. The engine is a third party and this contract hands it the resource graph and a traffic level only. No overlay is drawn and no figure is guessed locally.`,remedy:"Remove the value from the declaration, or hold it in a secret reference the build does not expand. If the field is a false positive, it still leaves the process in this request."})}var TAe,DAe,NAe,jAe,LAe,b8,MAe,Xj,Do,Qj,k8,qAe,KAe,JAe,ZAe,YAe,XAe,QAe,h8,sPe,O8,y8,ec=v(()=>{"use strict";qx();TAe={modeled:!0,validated:!0},DAe=Object.keys(TAe);NAe={survives:!0,degrades:!0,fails:!0},jAe=Object.keys(NAe);LAe={"read-failed":!0,"no-binding":!0,"unsupported-kind":!0,filtered:!0,"no-engine":!0,"engine-unreachable":!0,"engine-out-of-credit":!0,"engine-over-quota":!0,"credential-in-request":!0},b8=Object.keys(LAe);MAe=["n/a","na","none","unknown","-","?","tbd","null"];Xj=e=>typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1,Do=e=>typeof e=="string"&&e.trim()!=="";Qj={"mixed-engine":0,"mixed-level":1,"mixed-currency":2,"mixed-basis":3,"mixed-failure":4},k8=Object.keys(Qj).sort((e,t)=>Qj[e]-Qj[t]);qAe="\x1B[31m",KAe="\x1B[0m";JAe=["pat","cookie"],ZAe=8,YAe=["ref","refs","name","names","id","ids","arn","arns","count","validity","mode","modes","policy","policies","scope","scopes","network","networks","type","types","enabled","required","version","uri","url","urls","config","configs","settings","options"],XAe=["imagepullsecrets","clienttoken","automountserviceaccounttoken","author","authors","authority","secretsmanager"],QAe=new RegExp(Vx.source.replace(/_/g,""),"i");h8=200,sPe={complete:!0,partial:!0,unknown:!0},O8=Object.keys(sPe);y8=32});function T8(e){return/^https?:\/\//i.test(e.trim())}function cL(e,t){return e.value.length<4||!t.includes(e.value)?t:t.split(e.value).join(Hr)}function dPe(e,t,n,i,r,o){if(i>=200&&i<300)return;let s=r.trim().length>0?`: ${r.trim()}`:"";if(i===401||i===403)return E8(e,t,n,`HTTP ${i}${s}`);if(i===402)return Qa(e,t,"engine-out-of-credit",`the account ${n.source} authenticates answered HTTP 402${s}`);if(i===429){let a=o&&o.trim().length>0?`, retry after ${o.trim()}`:"";return Qa(e,t,"engine-over-quota",`the account ${n.source} authenticates answered HTTP 429${a}${s}`)}return Qa(e,t,"engine-unreachable",`HTTP ${i}${s||" with no body"}`)}function pPe(e){let t=e.split(`
|
|
229
|
+
`).find(n=>n.trim().length>0)?.trim()??"";return t.length>I8?`${t.slice(0,I8)}\u2026`:t}function D8(e,t,n,i={}){let r=R8(e,n),o=i.fetch??globalThis.fetch,s=i.timeoutMs??uPe;if(!r){let a=S8(e,t);return{async send(){return{ok:!1,refusal:a}}}}return{async send(a){let l;try{l=await o(t.value.trim(),{method:"POST",headers:{"content-type":"application/json",accept:"application/json",authorization:`Bearer ${r.value}`},body:a,redirect:"error",signal:AbortSignal.timeout(s)})}catch(d){return{ok:!1,refusal:Qa(e,t,"engine-unreachable",cL(r,fPe(d,s)))}}let c=await l.text().catch(()=>""),u=dPe(e,t,r,l.status,cL(r,pPe(c)),l.headers.get("retry-after")??void 0);return u?{ok:!1,refusal:u}:{ok:!0,body:cL(r,c)}}}}function fPe(e,t){if(e instanceof Error){if(e.name==="TimeoutError"||e.name==="AbortError")return`no answer within ${t} ms`;let n=e.cause,i=typeof n?.code=="string"?n.code:void 0;return i?`${i}: ${e.message}`:e.message}return String(e)}var uPe,I8,lL=v(()=>{"use strict";ec();qx();uPe=3e4,I8=300});function N8(e,t,n){if(t.startsWith(gPe))return{status:"declared-unmapped",reason:"one of chant's own build-time entities rather than something an account holds \u2014 a declared output, or a default that rides onto the resources beside it. It is never created and never billed"};let i=e.find(a=>a.prefixes.some(l=>t.startsWith(l)));if(!i)return{status:"unknown-type"};if(i.nothingPriced)return{status:"provider-not-modelled",substrate:i.nothingPriced};let r=i.resolveType?i.resolveType(t,n):t;if(r===void 0)return{status:"unknown-type"};if(i.mapped&&Object.prototype.hasOwnProperty.call(i.mapped,r)){let a=i.mapped[r];return{status:"mapped",mapping:{...a,provider:a.provider??i.provider}}}if(i.unmapped&&Object.prototype.hasOwnProperty.call(i.unmapped,r))return{status:"declared-unmapped",reason:i.unmapped[r]};let o=i.notModelledWhen?.(r);if(o!==void 0)return{status:"provider-not-modelled",substrate:o};let s=i.unmappedWhen?.(r);return s!==void 0?{status:"declared-unmapped",reason:s}:{status:"unknown-type"}}function uL(e,t){return e.find(n=>n.prefixes.some(i=>t.startsWith(i)))}function j8(e,t,n){let i=uL(e,t);if(!i?.resolveType)return t;let r=i.resolveType(t,n);return r===void 0||r===t?t:`${r} (${t})`}function L8(e,t,n){if(t.status==="declared-unmapped")return`${e} is declared unmapped by the ${n?.provider??"declaring"} coverage rows: ${t.reason}.`;if(t.status==="provider-not-modelled")return`${e} belongs to ${t.substrate}, which nothing here models. A substrate is added by the lexicon that owns its types contributing rows for them, not by adding a row elsewhere. This is a stated boundary rather than a gap \u2014 nothing needs filing.`;let i=n?`the lexicon that owns ${n.prefixes.join(", ")}`:"the lexicon that owns this entity type";return`${e} has no row in any contributed coverage table. It is a type from a substrate that is modelled, and is neither mapped to an engine kind nor declared unmapped, so nothing has an opinion about it rather than a stated one. Add a row in ${i}.`}var mPe,N3e,gPe,mp,dL=v(()=>{"use strict";mPe={compute:!0,serverless:!0,"control-plane":!0,database:!0,cache:!0,queue:!0,"object-store":!0,"block-store":!0,"load-balancer":!0,cdn:!0},N3e=Object.keys(mPe),gPe="chant:";mp=(e,t)=>e<t?-1:e>t?1:0});function G8(e,t){if(!w8(e))throw new Error('behaviour result is neither a report nor a refusal: expected `behaviour: "v1"` with either `refusal` or both `meta` and `entities`.');if(Xa(e)){let a=e.refusal;if(!Kx(a.cause))throw new Error(`behaviour refusal carries the cause ${JSON.stringify(a.cause)}, which is not a legal reason.`);if(typeof a.reason!="string"||a.reason.trim()==="")throw new Error("behaviour refusal states no reason \u2014 the sentence a consumer prints is missing.");if(typeof a.remedy!="string"||a.remedy.trim()==="")throw new Error("behaviour refusal states no remedy \u2014 a refusal exists to be acted on.");return e}let n=e;if(aL(n.meta.edgeCoverage),typeof n.meta.at?.traffic!="string"||n.meta.at.traffic.trim()==="")throw new Error("behaviour report states no traffic level in meta.at \u2014 a figure without its question is a bill in waiting.");let i=new Set(t),r=n.unpredicted??{},o=new Set(Object.keys(r));for(let a of Object.keys(n.entities)){if(o.has(a))throw new Error(`behaviour report names "${a}" as both predicted and unpredicted.`);if(!i.has(a))throw new Error(`behaviour report carries a figure for "${a}", which was not asked about.`);if(rL(a,n.entities[a]),n.entities[a].at.traffic!==n.meta.at.traffic)throw new Error(`behaviour report priced "${a}" at ${JSON.stringify(n.entities[a].at.traffic)} in a run whose meta.at.traffic is ${JSON.stringify(n.meta.at.traffic)}.`)}for(let a of o){if(!i.has(a))throw new Error(`behaviour report names "${a}" unpredicted, and it was not asked about.`);if(!Kx(r[a]?.reason))throw new Error(`behaviour report gives "${a}" the reason ${JSON.stringify(r[a]?.reason)}, which is not a legal one.`)}let s=t.filter(a=>!Object.prototype.hasOwnProperty.call(n.entities,a)&&!o.has(a));if(s.length>0)throw new Error(`behaviour report gives no verdict at all for ${s.map(a=>`"${a}"`).join(", ")}. Every entity asked about lands in \`entities\` or in \`unpredicted\`; there is no third position.`);return n}function M8(e,t){return e<t?-1:e>t?1:0}function Zx(e,t){return e!==void 0&&Object.prototype.hasOwnProperty.call(e,t)}function W8(e,t){let n=Xa(e.result),i=Xa(t.result);if(n||i)return{kind:"no-prediction",base:{label:e.label,...e.ref?{ref:e.ref}:{},...n?{refusal:e.result.refusal}:{}},head:{label:t.label,...t.ref?{ref:t.ref}:{},...i?{refusal:t.result.refusal}:{}}};let r=e.result,o=t.result,s=new Set([...Object.keys(r.entities),...Object.keys(r.unpredicted??{}),...Object.keys(o.entities),...Object.keys(o.unpredicted??{})]),a=[],l=new Map;for(let c of[...s].sort(M8)){let u=Zx(r.entities,c)?r.entities[c]:void 0,d=Zx(o.entities,c)?o.entities[c]:void 0,p=Zx(r.unpredicted,c)?r.unpredicted[c]:void 0,f=Zx(o.unpredicted,c)?o.unpredicted[c]:void 0,g=p?.type??f?.type,h={name:c,...g?{type:g}:{},kind:"comparable",...u?{base:u}:{},...d?{head:d}:{},...p?{baseDeclined:p}:{},...f?{headDeclined:f}:{}};if(p||f)h.kind="declined";else if(u&&d){let b=x8(u,d);if(b.size>0)h.kind="marked",h.mismatches=k8.filter(w=>b.has(w));else{h.kind="comparable",h.deltaPerHour=d.cost.perHour-u.cost.perHour,h.currency=d.cost.currency;let w=l.get(h.currency)??{currency:h.currency,perHour:0,pairs:0};w.perHour+=h.deltaPerHour,w.pairs+=1,l.set(h.currency,w)}}else u?h.kind="only-base":h.kind="only-head";a.push(h)}return{kind:"delta",base:{label:e.label,...e.ref?{ref:e.ref}:{},meta:r.meta},head:{label:t.label,...t.ref?{ref:t.ref}:{},meta:o.meta},rows:a,sums:[...l.values()].sort((c,u)=>M8(c.currency,u.currency)),resilienceComparable:r.meta.edgeCoverage.verdict==="complete"&&o.meta.edgeCoverage.verdict==="complete"}}function bh(e){let t=e.toFixed(4);return t.includes(".")?t.replace(/0+$/,"").replace(/\.$/,""):t}function z8(e){return`${bh(e.perHour)} ${e.currency}/hour`}function U8(e,t){return`${e>0?"+":""}${bh(e)} ${t}/hour`}function Yx(e){return`${e.engine} ${e.version} \xB7 ${e.tolerance} \xB7 ${e.basis}`}function hPe(e){let t=[];return e.unresolvedKinds&&e.unresolvedKinds.length>0&&t.push(`unresolved kinds: ${e.unresolvedKinds.join(", ")}`),e.dangling&&e.dangling.length>0&&t.push(`${e.dangling.length} dangling reference(s)`),e.containmentEdges&&e.containmentEdges.length>0&&t.push(`${e.containmentEdges.length} containment edge(s)`),t.length>0?`${e.verdict} (${t.join("; ")})`:e.verdict}function F8(e,t,n){let i=t===void 0?"\u2014":bh(t),r=n===void 0?"\u2014":bh(n);return`${e} ${i} \u2192 ${r}`}function yPe(e,t){let n=e?.headroom??{},i=t?.headroom??{};return[F8("cpu",n.cpu,i.cpu),F8("latency",n.latency,i.latency)].join(" \xB7 ")}function Xx(e){return e?`${e.resilience.verdict} (${e.resilience.failure})`:"\u2014"}function bPe(e,t){let{base:n,head:i}=e;if(!n||!i)return n?`base ${Xx(n)}`:i?`head ${Xx(i)}`:"\u2014";if(t&&n.resilience.failure===i.resilience.failure){let r=n.resilience.verdict===i.resilience.verdict?"=":"\u2192";return`${n.resilience.verdict} ${r} ${i.resilience.verdict} (${n.resilience.failure})`}return`base ${Xx(n)}; head ${Xx(i)}`}function wPe(e){let{base:t,head:n}=e;if(t&&n){let i=Yx(t.provenance),r=Yx(n.provenance);return i===r?i:`base: ${i}; head: ${r}`}return t?Yx(t.provenance):n?Yx(n.provenance):"\u2014"}function hi(e){return e.replace(/\|/g,"\\|").replace(/\r?\n/g," ")}function B8(e,t){return t?`declined: ${t.reason}`:e?z8(e.cost):"\u2014"}function vPe(e){switch(e.kind){case"comparable":return U8(e.deltaPerHour,e.currency);case"marked":return`marked: ${(e.mismatches??[]).join(", ")}`;case"declined":return"no delta (declined)";case"only-base":return"removed";case"only-head":return"added"}}function H8(e,t){let n=[];if(e.kind==="no-prediction"){n.push(`## Predicted behaviour for \`${t.env}\` \u2014 no prediction (Op \`${t.op}\`)`,""),n.push("No delta is shown and no figure is guessed locally. A prediction refused on one side is not a prediction of zero on that side, so there is nothing to difference the other side against.","");for(let c of[e.base,e.head]){if(!c.refusal)continue;let u=c.ref?`${c.label} (${c.ref})`:c.label;n.push(`**${u}**`,"","```",sL(c.refusal,{color:!1}),"```","")}return n.join(`
|
|
230
|
+
`).trimEnd()+`
|
|
231
|
+
`}let i=e.head.meta.at.traffic;n.push(`## Predicted behaviour for \`${t.env}\` at \`${i}\` (Op \`${t.op}\`)`,""),n.push("A prediction, not a measurement. Every figure below is one engine's modeled rate for one hypothetical hour at the stated traffic level, shown with that engine's name, version, stated tolerance and basis (`modeled` from list prices, or `validated`). Nothing here is an amount owed for an hour that happened.",""),n.push("| Side | Predicted from | Engine | Traffic level | Edge coverage | Engine's own estate total |"),n.push("|---|---|---|---|---|---|");for(let c of[e.base,e.head]){let u=c.meta.total?z8(c.meta.total):"not stated";n.push(`| ${c.label} | ${hi(c.ref??"\u2014")} | ${hi(`${c.meta.engine} ${c.meta.version}`)} | ${hi(c.meta.at.traffic)} | ${hi(hPe(c.meta.edgeCoverage))} | ${u} |`)}n.push(""),e.base.meta.at.traffic!==e.head.meta.at.traffic&&n.push(`The two sides were predicted at different traffic levels (\`${e.base.meta.at.traffic}\` and \`${e.head.meta.at.traffic}\`), so every pair below is marked \`mixed-level\` and none is differenced.`,""),e.resilienceComparable||n.push(`Resilience verdicts are shown per side and **not compared**: edge coverage is \`${e.base.meta.edgeCoverage.verdict}\` on ${e.base.label} and \`${e.head.meta.edgeCoverage.verdict}\` on ${e.head.label}, so the two verdicts were computed over graphs of different completeness, and a difference between them is not a difference in the estate.`,""),n.push(`| Entity | Type | ${e.base.label} | ${e.head.label} | Delta per hour | Headroom (${e.base.label} \u2192 ${e.head.label}) | Resilience | Provenance |`),n.push("|---|---|---|---|---|---|---|---|");for(let c of e.rows)n.push(`| ${hi(c.name)} | ${hi(c.type??"")} | ${hi(B8(c.base,c.baseDeclined))} | ${hi(B8(c.head,c.headDeclined))} | ${hi(vPe(c))} | ${hi(yPe(c.base,c.head))} | ${hi(bPe(c,e.resilienceComparable))} | ${hi(wPe(c))} |`);n.push("");let r=e.rows.filter(c=>c.kind==="marked").length,o=e.rows.filter(c=>c.kind==="declined").length,s=e.rows.filter(c=>c.kind==="only-base"||c.kind==="only-head").length;if(e.sums.length>0){for(let c of e.sums)n.push(`Sum of the comparable deltas: **${U8(c.perHour,c.currency)}** over ${c.pairs} pair(s). This is chant's own arithmetic over the comparable rows above and not an engine figure; it excludes ${r} marked pair(s), ${o} declined entit${o===1?"y":"ies"} and ${s} entit`+(s===1?"y":"ies")+" present on one side only.");n.push("")}else n.push("No pair is comparable, so no delta is summed.","");let a=e.rows.filter(c=>c.kind==="declined");if(a.length>0){n.push("### Declined entities",""),n.push("An entity the engine could not price is reported, not priced at nothing. It carries no delta on either side; the reason is the lexicon's own.","");for(let c of a)for(let[u,d]of[[e.base.label,c.baseDeclined],[e.head.label,c.headDeclined]])d&&n.push(`- \`${c.name}\` on ${u}: \`${d.reason}\`${d.detail?` \u2014 ${d.detail}`:""}`);n.push("")}let l=e.rows.filter(c=>c.head?.rightSize);if(l.length>0){n.push(`### Right-size hints on ${e.head.label}`,"");for(let c of l){let u=c.head.rightSize;n.push(`- \`${c.name}\`: ${u.suggestion}${u.reason?` \u2014 ${u.reason}`:""}`)}n.push("")}return n.join(`
|
|
232
|
+
`).trimEnd()+`
|
|
233
|
+
`}var Qx=v(()=>{"use strict";ec()});var e$=v(()=>{"use strict";fp()});var V8=v(()=>{"use strict"});var pL=v(()=>{"use strict";no()});var q8=v(()=>{"use strict"});var RPe,SPe,V3e,EPe,APe,q3e,K8=v(()=>{"use strict";Ln();RPe=m.object({name:m.string().min(1,"intrinsic name must not be empty"),description:m.string().optional(),outputKey:m.string().optional(),isTag:m.boolean(),foldsAsCall:m.boolean().optional(),foldsEagerly:m.boolean().optional()}),SPe=/^\d+\.\d+\.\d+(-[a-zA-Z0-9.]+)?(\+[a-zA-Z0-9.]+)?$/,V3e=m.object({name:m.string().min(1,"manifest name must not be empty"),version:m.string().regex(SPe,"version must be valid semver (X.Y.Z)"),chantVersion:m.string().optional(),namespace:m.string().optional(),intrinsics:m.array(RPe).optional(),pseudoParameters:m.record(m.string(),m.string()).optional()}),EPe=m.object({name:m.string(),type:m.enum(["if_then","dependent_excluded","required_or","required_xor"]),condition:m.unknown().optional(),requirement:m.unknown().optional()}),APe=m.object({pattern:m.string().optional(),minLength:m.number().optional(),maxLength:m.number().optional(),minimum:m.number().optional(),maximum:m.number().optional(),format:m.string().optional(),const:m.unknown().optional(),default:m.unknown().optional(),enum:m.array(m.string()).optional()}),q3e=m.object({resourceType:m.string(),kind:m.enum(["resource","property"]),lexicon:m.string(),attrs:m.record(m.string(),m.string()).optional(),constraints:m.array(EPe).optional(),propertyConstraints:m.record(m.string(),APe).optional(),createOnly:m.array(m.string()).optional(),writeOnly:m.array(m.string()).optional(),primaryIdentifier:m.array(m.string()).optional(),deprecatedProperties:m.array(m.string()).optional(),conditionalCreateOnly:m.array(m.string()).optional(),replacementStrategy:m.enum(["delete_then_create","create_then_delete"]).optional(),tagging:m.object({taggable:m.boolean(),tagOnCreate:m.boolean(),tagUpdatable:m.boolean()}).optional(),runtimeDeprecations:m.record(m.string(),m.string()).optional()})});var J8=v(()=>{"use strict"});var Z8=v(()=>{"use strict"});var Y8=v(()=>{"use strict"});var X8=v(()=>{"use strict"});var t8e,n8e,fL=v(()=>{"use strict";X8();t8e=1440*60*1e3,n8e=10080*60*1e3});var Q8=v(()=>{"use strict"});var gp=v(()=>{"use strict"});var mL=v(()=>{"use strict";gp()});var eY=v(()=>{"use strict";ah();kl();di();Sj()});var No,tY=v(()=>{"use strict";No=Le(Ke(),1);eY()});var nY=v(()=>{"use strict";pL();mL();tY()});var rY=v(()=>{"use strict";no()});var gL=v(()=>{"use strict"});var wh=v(()=>{"use strict"});var hL=v(()=>{"use strict";gL();wh()});var t$=v(()=>{"use strict";gp()});var cY=v(()=>{"use strict";t$()});var lY=v(()=>{"use strict";gp();So()});var uY=v(()=>{"use strict";gp();t$();mL();cY();lY();gp();t$()});var n$=v(()=>{"use strict";hL();wh()});var pY=v(()=>{"use strict";wh();n$()});var fY=v(()=>{"use strict";n$();fL();So();xn();Ei()});var mY=v(()=>{"use strict"});var gY=v(()=>{"use strict";Pn();Qo();Wt()});var hY=v(()=>{"use strict"});var yY=v(()=>{"use strict"});var bY=v(()=>{"use strict"});var wY=v(()=>{"use strict"});var yL=v(()=>{"use strict";er();as();Wt()});var bL=v(()=>{"use strict";$t();Wt();er()});var wL=v(()=>{"use strict";fp();e$();rx();di();bL()});var vL=v(()=>{"use strict";fp();e$();gi();wL()});var vh=v(()=>{"use strict"});import{exec as DPe,execFile as NPe}from"node:child_process";import{promisify as vY}from"node:util";var oXe,sXe,kL=v(()=>{"use strict";vh();oXe=vY(DPe),sXe=vY(NPe)});var xL=v(()=>{"use strict";Kt();kL()});var kY=v(()=>{"use strict"});var xY=v(()=>{"use strict";cp();gi();xL();kY();Pn()});var $Y=v(()=>{"use strict";vL();yL();xY();$t();Wt();gi();fp();Pn()});var RL=v(()=>{"use strict"});var SL=v(()=>{"use strict"});var o$=v(()=>{"use strict";RL();gi();SL()});var EL=v(()=>{"use strict";gi()});var RY=v(()=>{"use strict";Cu();er()});import{execFile as GPe}from"node:child_process";import{promisify as WPe}from"node:util";var t7e,SY=v(()=>{"use strict";cp();Tx();t7e=WPe(GPe)});var xh=v(()=>{"use strict"});var AL=v(()=>{"use strict";xh()});var $h=v(()=>{"use strict";Wt();xh();$t();AL();AL()});var EY=v(()=>{"use strict";pp()});var AY=v(()=>{"use strict";Wt();xh();$t()});var PY=v(()=>{"use strict";Ki()});var OY=v(()=>{"use strict";$h();xh();gi()});var PL=v(()=>{"use strict";gi()});var CY=v(()=>{"use strict";gi()});var Rh=v(()=>{"use strict";o$();gi()});var s$=v(()=>{"use strict";Wt();$t()});var Nl=v(()=>{"use strict";Wt();$t()});var _Y=v(()=>{"use strict";o$();EL();gi();ec();Qx()});var IY=v(()=>{"use strict";wY();$t();yL();$Y();RL();wL();vL();bL();o$();SL();EL();RY();SY();$h();EY();AY();PY();OY();PL();CY();Rh();s$();Nl();FN();_Y();On()});var a$=v(()=>{"use strict";er()});var yi=v(()=>{"use strict";Sx();fk();uo();er();a$();Em();ws();Bi();pg()});var DY=v(()=>{"use strict"});var hp=v(()=>{"use strict";no();hl();ya();Yd();cs();Bi();uo();uo();fk()});var NY=v(()=>{"use strict";yi();a$()});var jY=v(()=>{"use strict";yi()});import{exec as QPe}from"node:child_process";import{promisify as eOe}from"node:util";var oet,OL=v(()=>{"use strict";Yj();xn();oet=eOe(QPe)});var MY=v(()=>{"use strict";yi();Bi();Oi();OL()});var c$=v(()=>{"use strict"});var FY=v(()=>{"use strict";yi();Bi();c$();Rh()});var BY=v(()=>{"use strict";yi()});var GY=v(()=>{"use strict";yi()});var WY=v(()=>{"use strict";yi()});var zY=v(()=>{"use strict";yi()});var UY=v(()=>{"use strict";NY();jY();MY();FY();BY();GY();WY();zY()});var HY=v(()=>{"use strict";Wi();xn();So();Bd()});import{exec as fOe}from"node:child_process";import{promisify as mOe}from"node:util";var qet,VY=v(()=>{"use strict";qet=mOe(fOe)});var qY=v(()=>{"use strict";vh()});import{exec as gOe}from"node:child_process";import{promisify as hOe}from"node:util";var ett,KY=v(()=>{"use strict";qY();ett=hOe(gOe)});var yOe,JY,ZY,l$,u$=v(()=>{"use strict";yOe=Symbol.for("chant.op.GateWait"),l$=class extends(ZY=Error,JY=yOe,ZY){constructor(n){super(`stopped at gate ${n.op} / ${n.gate}: approve it with \`chant approve ${n.op} ${n.gate}\` and run again`);this.pending=n;this[JY]=!0;this.name="GateWait"}}});import{AsyncLocalStorage as bOe}from"node:async_hooks";import{execFile as wOe}from"node:child_process";import{promisify as vOe}from"node:util";var att,ctt,bp=v(()=>{"use strict";ya();att=vOe(wOe),ctt=new bOe});import{exec as xOe}from"node:child_process";import{promisify as $Oe}from"node:util";var gtt,htt,YY=v(()=>{"use strict";u$();bp();gtt=$Oe(xOe),htt=64*1024*1024});var XY=v(()=>{"use strict";vh()});var CL=v(()=>{"use strict"});var _L=v(()=>{"use strict";Wt();CL()});var QY=v(()=>{"use strict";CL();_L()});import{exec as EOe}from"node:child_process";import{promisify as AOe}from"node:util";var Ttt,eX=v(()=>{"use strict";On();Ttt=AOe(EOe)});import{exec as POe}from"node:child_process";import{promisify as OOe}from"node:util";var ztt,tX=v(()=>{"use strict";gT();Qh();ztt=OOe(POe)});import{exec as COe}from"node:child_process";import{promisify as _Oe}from"node:util";var qtt,nX=v(()=>{"use strict";qtt=_Oe(COe)});var rX=v(()=>{"use strict";Kt();vu();xL();PL()});import{execFile as IOe}from"node:child_process";import{promisify as TOe}from"node:util";function Eh(e){let t=e?.trim();if(!t)return;let n=/^[^@/\s]+@([^:/\s]+):(?!\/)/.exec(t);if(n)return n[1].toLowerCase();try{let i=new URL(t);return(i.protocol==="ssh:"?i.hostname:i.host).toLowerCase()||void 0}catch{return}}function NOe(e){return Eh(e.FORGEJO_SERVER_URL)??Eh(e.GITHUB_SERVER_URL)}function jOe(e,t){if(e.GH_HOST?.trim()||!t||t==="github.com")return e;let n={...e,GH_HOST:t},i=e.GH_TOKEN?.trim()||e.GITHUB_TOKEN?.trim();return i&&!e.GH_ENTERPRISE_TOKEN?.trim()&&!e.GITHUB_ENTERPRISE_TOKEN?.trim()&&(n.GH_ENTERPRISE_TOKEN=i),n}async function d$(e=process.env,t){if(e.GH_HOST?.trim())return e;let n=NOe(e);if(!n)try{let{stdout:i}=await DOe("git",["remote","get-url","origin"],t?{cwd:t}:{});n=Eh(i)}catch{n=void 0}return jOe(e,n)}var DOe,Ah=v(()=>{"use strict";DOe=TOe(IOe)});import{execFile as LOe}from"node:child_process";import{promisify as MOe}from"node:util";function BOe(e){let t=e?.trim();if(!t)return;let n=/^[^@/\s]+@[^:/\s]+:(?!\/)(.+)$/.exec(t),i;if(n)i=n[1];else try{i=new URL(t).pathname}catch{return}let r=i.replace(/^\/+/,"").replace(/\/+$/,"").replace(/\.git$/,"");return r.includes("/")?r:void 0}async function p$(e=process.env,t={}){let n=Qm(e);if(n!=="forgejo"&&n!=="gitlab")return;let i=t4(e,{kind:n});if(t.cwd){let r=await(t.remoteUrl??GOe)(t.cwd,t.remote??"origin"),o=BOe(r);o&&Eh(r)===i.host&&(i.repo=o)}return n4(i,t.fetch)}var FOe,GOe,f$=v(()=>{"use strict";eg();Ah();FOe=MOe(LOe);GOe=async(e,t)=>{try{return(await FOe("git",["remote","get-url",t],{cwd:e})).stdout.trim()}catch{return}}});import{exec as WOe}from"node:child_process";import{readFile as zOe}from"node:fs/promises";import{promisify as UOe}from"node:util";function HOe(e){return`chant/reconcile-${e.replace(/[^a-zA-Z0-9._-]+/g,"-")}`}function VOe(e,t){let n=[`Reconcile from live environment \`${e}\`.`,"","This PR regenerates chant TypeScript from live state to close the gap between the cloud and source. It was triggered by the following change-set entries:","","| Entry | Action | Type |","|---|---|---|"];for(let i of t)n.push(`| ${i.name} | ${i.action} | ${i.type??""} |`);return t.length===0&&n.push("| _(none)_ | | |"),n.push(""),n.push("Review the diff before merging \u2014 live import may surface values that need redaction."),n.join(`
|
|
234
|
+
`)}function bi(e){return`'${e.replace(/'/g,"'\\''")}'`}function iX(e){return`<!-- chant-reconcile:${wp(e)} -->`}function qOe(e,t){return`<!-- chant-reconcile-issue:${wp(e)}/${wp(t)} -->`}function wp(e){return e.replace(/[^a-zA-Z0-9._-]+/g,"-")}function KOe(e){return`reconcilePr was given the marker ${JSON.stringify(e)}, which it cannot use. The marker goes into the \`--jq\` filter that finds this Op's own comment or issue, as \`startswith("<marker>")\`, so a double quote, a backslash or a control character in it either breaks that filter or changes what it matches. Markers this activity builds itself are slugified to letters, digits, dot, underscore and hyphen and cannot contain any of the three. Keep a supplied marker to printable text without \`"\` or \`\\\`, or drop \`marker\` and pass \`op\` instead.`}function m$(e){let t=e?.trim();if(t){if(/["\\]|[\u0000-\u001f\u007f]/.test(t))throw new Error(KOe(t));return t}}function JOe(e){return`reconcilePr mode "issue" edits the one OPEN issue carrying this Op's hidden marker in place, so the marker has to name the Op. This step supplies env "${e}" and no identity, and an env alone is not unique: two Ops over one env \u2014 a stock terraform drift watch and a live one over the same root, or a terraform root and a chant environment that happen to share a name \u2014 resolve to the same marker, and each run then rewrites the other's issue title and body. Pass \`op\` with the Op's own name (every composite in tree does), or pass an explicit \`marker\` you keep unique yourself.`}function ZOe(){return'reconcilePr mode "comment" posts the finding on the pull request or merge request that triggered the run, and this run has none. On GitHub Actions it needs GITHUB_REPOSITORY plus a pull request number, read from the event payload at GITHUB_EVENT_PATH (`.number` / `.pull_request.number`) or from GITHUB_REF (`refs/pull/<n>/merge`), which a pull_request event sets and nothing else does. On GitLab CI it needs CI_MERGE_REQUEST_IID plus the project (CI_MERGE_REQUEST_PROJECT_ID or CI_PROJECT_ID) and the API base (CI_API_V4_URL, or CI_SERVER_URL to derive it), which a merge_request_event pipeline sets and nothing else does. Trigger this Op from a pull_request or merge_request pipeline, or give it findingMode "issue" or "report".'}function YOe(e){if(typeof e!="object"||e===null)return;let t=e;if(typeof t.number=="number")return t.number;if(typeof t.pull_request?.number=="number")return t.pull_request.number}function oX(e,t){let n=e.GITHUB_REPOSITORY;if(!n)return;let i=/^refs\/pull\/(\d+)\//.exec(e.GITHUB_REF??"")?.[1],r=YOe(t)??(i?Number(i):void 0);if(!(r===void 0||!Number.isInteger(r)||r<=0))return{repo:n,number:r}}async function sX(e=process.env){let t,n=e.GITHUB_EVENT_PATH;if(n)try{t=JSON.parse(await zOe(n,"utf8"))}catch{t=void 0}let i=oX(e,t);if(!i)throw new Error(ZOe());return i}function aX(e){return e.GITHUB_API_URL?.trim().replace(/\/+$/,"")||"https://api.github.com"}function cX(e){return Qm(e)==="forgejo"||/\/api\/v1$/.test(aX(e))?"forgejo":"github"}function lX(e){for(let t of PT[cX(e)]){let n=e[t]?.trim();if(n)return{value:n,source:t}}}function XOe(e,t){return`reconcilePr mode "comment" has pull request ${e}#${t} to post its finding on and no token to post it with. GH_TOKEN or GITHUB_TOKEN, set from github.token, already covers this on a GitHub Actions or Forgejo Actions run \u2014 set CHANT_GITHUB_TOKEN (GitHub) or CHANT_FORGEJO_TOKEN (Forgejo) to post against a different instance than the one the job runs on. It is read first where the two must differ.`}function QOe(e){return`reconcilePr mode "issue" has repository ${e} to open or edit its finding in and no token to do it with. GH_TOKEN or GITHUB_TOKEN, set from github.token, already covers this on a GitHub Actions or Forgejo Actions run \u2014 set CHANT_GITHUB_TOKEN (GitHub) or CHANT_FORGEJO_TOKEN (Forgejo) to post against a different instance than the one the job runs on. It is read first where the two must differ.`}function uX(e,t,n,i){let r=aX(e),o=cX(e)==="forgejo",s=(c,u)=>globalThis.fetch(c,{...u,...i?{signal:i}:{}}),a={apiBase:r,repo:t,token:n.value,fetch:s};if(!o)return ET(a);let l;try{l=new URL(r).host}catch{l=r}return AT({...a,host:l})}async function dX(e,t){try{return await t()}catch(n){throw n instanceof rr?new Error(`${n.message} (token from ${e.source}).`):n}}async function eCe(e,t,n,i){let r=lX(process.env);if(!r)throw new Error(XOe(e.repo,e.number));let o=uX(process.env,e.repo,r,i);return dX(r,()=>o.upsertNote(e.number,t,`${t}
|
|
235
|
+
|
|
236
|
+
${n}`))}function pX(e){let t=e.CI_MERGE_REQUEST_IID?.trim();if(!t)return;let n=Number(t);if(!Number.isInteger(n)||n<=0)return;let i=e.CI_SERVER_URL?.trim().replace(/\/+$/,""),r=e.CI_API_V4_URL?.trim().replace(/\/+$/,"")||(i?`${i}/api/v4`:"");if(!r)return;let o=e.CI_MERGE_REQUEST_PROJECT_ID?.trim()||e.CI_PROJECT_ID?.trim()||e.CI_MERGE_REQUEST_PROJECT_PATH?.trim()||e.CI_PROJECT_PATH?.trim()||"";if(!o)return;let s=e.CI_MERGE_REQUEST_PROJECT_PATH?.trim()||e.CI_PROJECT_PATH?.trim(),a=e.CI_MERGE_REQUEST_PROJECT_URL?.trim()||e.CI_PROJECT_URL?.trim();return{api:r,project:o,iid:n,...s?{path:s}:{},...a?{webUrl:a}:{}}}function tCe(e){let t=e.CI_PROJECT_ID?.trim();if(!t)return;let n=e.CI_SERVER_URL?.trim().replace(/\/+$/,""),i=e.CI_API_V4_URL?.trim().replace(/\/+$/,"")||(n?`${n}/api/v4`:"");if(!i)return;let r=e.CI_PROJECT_PATH?.trim(),o=e.CI_PROJECT_URL?.trim();return{api:i,project:t,...r?{path:r}:{},...o?{webUrl:o}:{}}}function IL(e){for(let n of["CHANT_GITLAB_TOKEN","GITLAB_TOKEN"]){let i=e[n]?.trim();if(i)return{header:"PRIVATE-TOKEN",value:i,source:n}}let t=e.CI_JOB_TOKEN?.trim();if(t)return{header:"JOB-TOKEN",value:t,source:"CI_JOB_TOKEN"}}function nCe(e){return`reconcilePr mode "comment" has merge request !${e} to post its finding on and no token to post it with. Set a GITLAB_TOKEN CI/CD variable (masked, scope: api) on the project \u2014 a project access token is enough \u2014 or, on an instance whose job-token allowlist covers the notes API, make CI_JOB_TOKEN available to the job. CHANT_GITLAB_TOKEN is read first where the two must differ.`}function rCe(e){return`reconcilePr mode "issue" wants to open or update an issue on GitLab project ${e} and has no token to do it with. Set a GITLAB_TOKEN CI/CD variable (masked, scope: api) on the project \u2014 a project access token is enough \u2014 or, on an instance whose job-token allowlist covers the issues API, make CI_JOB_TOKEN available to the job. CHANT_GITLAB_TOKEN is read first where the two must differ.`}function fX(e){return`${e.api}/projects/${encodeURIComponent(e.project)}/merge_requests/${e.iid}/notes`}async function vp(e,t,n,i){let r=await fetch(e,{...n,...i?{signal:i}:{},headers:{[t.header]:t.value,"content-type":"application/json"}});if(!r.ok){let o=(await r.text().catch(()=>"")).slice(0,500);throw new Error(`GitLab API ${n.method??"GET"} ${e} answered ${r.status}${o?`: ${o}`:""} (token from ${t.source}, sent as ${t.header}).`)}return r}async function iCe(e,t,n,i){let r=fX(e),o=50;for(let s=1;s<=o;s++){let a=await vp(`${r}?per_page=100&page=${s}`,t,{method:"GET"},i),c=(await a.json()).find(d=>!d.system&&(d.body??"").startsWith(n));if(c)return c.id;if(!a.headers.get("x-next-page")?.trim())return}}async function oCe(e,t,n,i,r){let o=fX(e),s=await iCe(e,t,n,r),a=JSON.stringify({body:`${n}
|
|
237
|
+
|
|
238
|
+
${i}`}),c=await(s?await vp(`${o}/${s}`,t,{method:"PUT",body:a},r):await vp(o,t,{method:"POST",body:a},r)).json();return e.webUrl?`${e.webUrl}/-/merge_requests/${e.iid}#note_${c.id}`:`${o}/${c.id}`}function mX(e){return`${e.api}/projects/${encodeURIComponent(e.project)}/issues`}async function sCe(e,t,n,i){let r=mX(e),o=50;for(let s=1;s<=o;s++){let a=await vp(`${r}?per_page=100&page=${s}&search=${encodeURIComponent(n)}&in=description`,t,{method:"GET"},i),c=(await a.json()).find(d=>(d.description??"").startsWith(n));if(c)return c.iid;if(!a.headers.get("x-next-page")?.trim())return}}async function aCe(e,t,n,i,r,o){let s=mX(e),a=await sCe(e,t,n,o),l=JSON.stringify({title:i,description:`${n}
|
|
239
|
+
|
|
240
|
+
${r}`}),u=await(a?await vp(`${s}/${a}`,t,{method:"PUT",body:l},o):await vp(s,t,{method:"POST",body:l},o)).json();return e.webUrl?`${e.webUrl}/-/issues/${u.iid}`:`${s}/${u.iid}`}function cCe(e){return(JSON.parse(e).entries??[]).filter(n=>n.action!=="noop").map(n=>({name:n.name,action:n.action,type:n.type}))}async function lCe(e,t,n){let i=t?" --owned":"",{stdout:r}=await tc(`chant lifecycle plan ${bi(e)}${i} --json`,{signal:n});return cCe(r)}function uCe(e,t){if(e==="issue"){let n=m$(t.marker),i=t.op?.trim();if(!n&&!i)throw new Error(JOe(t.env));return n??qOe(i,t.env)}if(e==="comment")return m$(t.marker)??iX(t.env)}async function TL(e,t){let n=e.mode??"pull-request",i=e.owned??!1,r=uCe(n,e),o=e.entries??(e.body!==void 0?[]:await lCe(e.env,i,t)),s=e.body??VOe(e.env,o),a=e.title??`Reconcile ${e.env}: ${o.length} change(s) from live`;if(n==="report")return{mode:n,summary:s,entries:o};if(n==="issue"){let f=r,g=tCe(process.env);if(g){let w=IL(process.env);if(!w)throw new Error(rCe(g.project));let x=await aCe(g,w,f,a,s,t);return{mode:n,summary:s,entries:o,issueUrl:x}}let h=process.env.GITHUB_REPOSITORY;if(h){let w=lX(process.env);if(!w)throw new Error(QOe(h));let x=uX(process.env,h,w,t),k=await dX(w,()=>x.upsertIssue(f,a,`${f}
|
|
241
|
+
|
|
242
|
+
${s}`));return{mode:n,summary:s,entries:o,issueUrl:k}}let{stdout:b}=await tc(`gh issue create --title ${bi(a)} --body ${bi(`${f}
|
|
243
|
+
|
|
244
|
+
${s}`)}`,{signal:t});return{mode:n,summary:s,entries:o,issueUrl:b.trim()}}if(n==="comment"){let f=r,g=pX(process.env);if(g){let w=IL(process.env);if(!w)throw new Error(nCe(g.iid));let x=await oCe(g,w,f,s,t);return{mode:n,summary:s,entries:o,commentUrl:x,mergeRequest:`${g.path??g.project}!${g.iid}`}}let h=await sX(),b=await eCe(h,f,s,t);return{mode:n,summary:s,entries:o,commentUrl:b,pullRequest:`${h.repo}#${h.number}`}}let l=e.branch??HOe(e.env),c=e.output??"./infra",u=i?" --owned":"";await tc(`git checkout -b ${bi(l)}`,{signal:t}),await tc(`chant import --from ${bi(e.env)}${u} --output ${bi(c)} --force`,{signal:t}),await tc(`git add ${bi(c)}`,{signal:t}),await tc(`git commit -m ${bi(a)}`,{signal:t}),await tc(`git push -u origin ${bi(l)}`,{signal:t});let d=await p$(process.env,{fetch:(f,g)=>globalThis.fetch(f,{...g,...t?{signal:t}:{}})});if(d){let f=await d.openPullRequest({head:l,title:a,body:s});return{mode:n,branch:l,summary:s,entries:o,prUrl:f.url??""}}let{stdout:p}=await tc(`gh pr create --title ${bi(a)} --body ${bi(s)} --head ${bi(l)}`,{signal:t,env:await d$(process.env)});return{mode:n,branch:l,summary:s,entries:o,prUrl:p.trim()}}var tc,g$=v(()=>{"use strict";eg();Ah();f$();tc=UOe(WOe)});var h$=v(()=>{"use strict"});var hX=v(()=>{"use strict";h$();Oj()});var yX=v(()=>{"use strict";h$()});var bX=v(()=>{"use strict"});var wX=v(()=>{"use strict"});var vX=v(()=>{"use strict"});var DL=v(()=>{"use strict"});import{exec as yCe}from"node:child_process";import{promisify as bCe}from"node:util";var Unt,kX=v(()=>{"use strict";c$();DL();Wi();Rh();s$();Mi();$t();Unt=bCe(yCe)});var xX=v(()=>{"use strict"});import{exec as wCe}from"node:child_process";import{promisify as vCe}from"node:util";var nrt,$X=v(()=>{"use strict";xX();Ah();f$();g$();nrt=vCe(wCe)});function RX(e,t){let n=e;for(let i of t.split(".")){if(typeof n!="object"||n===null)return;n=n[i]}return n}function xCe(e,t,n){if(!t)return;let i=RX(e,t);return n==="number"?typeof i=="number"&&Number.isFinite(i)?String(i):void 0:SX(i)?i:void 0}function SX(e){return typeof e=="string"&&e.length>0&&!e.includes("${")}function EX(e,t){let n=[],i=[];for(let o of[...e.entityNames].sort(mp)){let s=e.entities.get(o);if(!s){i.push({name:o,entityType:"(undeclared)",status:"unknown-type",detail:`${o} was named in entityNames and is not in the entities map, so this lexicon has nothing to translate. It is reported rather than dropped: an entity that vanished between the build and the request is a defect in the caller, and a silent omission hides it behind an estate that looks smaller.`});continue}let a=N8(t,s.entityType,s.props),l=uL(t,s.entityType),c=l?.resolveType?.(s.entityType,s.props),u=c&&c!==s.entityType?c:void 0;if(a.status!=="mapped"){i.push({name:o,entityType:s.entityType,...u?{resourceType:u}:{},status:a.status,detail:L8(j8(t,s.entityType,s.props),a,l)});continue}let{mapping:d}=a,p=d.regionProp?RX(s.props,d.regionProp):void 0,f=SX(p)?p:e.region,g=xCe(s.props,d.sizeProp,d.sizeType);n.push({name:o,entityType:s.entityType,...u?{resourceType:u}:{},kind:d.kind,provider:d.provider,...f?{region:f}:{},...g?{size:g}:{}})}let r=e.edges.map(o=>({from:o.from,to:o.to,...o.viaAttr?{via:o.viaAttr}:{},...o.toAttr?{toAttr:o.toAttr}:{}})).sort((o,s)=>mp(o.from,s.from)||mp(o.to,s.to)||mp(o.via??"",s.via??"")||mp(o.toAttr??"",s.toAttr??""));return{request:kCe,traffic:e.traffic,...e.region?{region:e.region}:{},nodes:n,edges:r,coverage:e.edgeCoverage,withheld:i}}function AX(e){return`${JSON.stringify(NL(e),null,2)}
|
|
245
|
+
`}function NL(e){if(Array.isArray(e))return e.map(NL);if(typeof e=="object"&&e!==null){let t={};for(let n of Object.keys(e).sort()){let i=e[n];i!==void 0&&(t[n]=NL(i))}return t}return e}var kCe,jL=v(()=>{"use strict";dL();kCe="behaviour/v1"});import{execFile as $Ce}from"node:child_process";function PX(e,t){return{async predict(n){let i=await e.send(AX(n));if(!i.ok)return{ok:!1,refusal:i.refusal};let r=OCe(i.body);if(!r.ok){let o=OX(i.body);return o?{ok:!1,refusal:Qa(Ts,t,o,`the engine answered ${CX(i.body)}`)}:{ok:!1,refusal:yh(Ts,t,r.detail)}}return{ok:!0,answer:r.answer}}}}function ECe(e){let[t,...n]=e.value.trim().split(/\s+/);return{async send(i){let r=await new Promise(o=>{$Ce(t,n,{timeout:RCe,maxBuffer:SCe,env:P8()},(a,l,c)=>{o({stdout:String(l),stderr:String(c),...a?{error:a}:{}})}).stdin?.end(i)});return r.error?{ok:!1,refusal:Qa(Ts,e,OX(r.stderr)??"engine-unreachable",CX(r.stderr)||r.error.message)}:{ok:!0,body:r.stdout}}}}function ACe(e){return PX(ECe(e),e)}function OX(e){let t=e.toLowerCase();if(/\b(out of credit|insufficient (funds|balance)|no balance|payment required)\b/.test(t))return"engine-out-of-credit";if(/\b(over quota|quota exceeded|rate limit|too many requests|throttl)/.test(t))return"engine-over-quota"}function CX(e){return e.split(`
|
|
246
|
+
`).find(t=>t.trim().length>0)?.trim()??""}function PCe(e,t){let n=c=>`figures.${e}.${c}`;if(typeof t!="object"||t===null||Array.isArray(t))return[`${n("")} is ${Array.isArray(t)?"an array":typeof t}, not an object`];let i=t,r=[],o=(c,u)=>{(typeof u!="number"||!Number.isFinite(u)||u<0||u>1)&&r.push(`${n(c)} is not a number in 0..1`)};(typeof i.perHour!="number"||!Number.isFinite(i.perHour)||i.perHour<0)&&r.push(`${n("perHour")} is not a non-negative finite number`),(typeof i.currency!="string"||i.currency.trim().length===0)&&r.push(`${n("currency")} is empty`),o("errorRate",i.errorRate);let s=i.headroom;if(typeof s!="object"||s===null||Array.isArray(s))r.push(`${n("headroom")} is missing`);else{let c=s;c.cpu===void 0&&c.latency===void 0&&r.push(`${n("headroom")} carries neither cpu nor latency`);for(let u of["cpu","latency"])c[u]!==void 0&&o(`headroom.${u}`,c[u])}let a=i.resilience;if(typeof a!="object"||a===null||Array.isArray(a))r.push(`${n("resilience")} is missing`);else{let c=a;(typeof c.failure!="string"||c.failure.trim().length===0)&&r.push(`${n("resilience.failure")} names no failure`),nL(c.verdict)||r.push(`${n("resilience.verdict")} is not survives/degrades/fails`),c.note!==void 0&&typeof c.note!="string"&&r.push(`${n("resilience.note")} is not a string`)}let l=i.rightSize;return l!==void 0&&(typeof l!="object"||l===null||Array.isArray(l)?r.push(`${n("rightSize")} is not an object`):typeof l.suggestion!="string"&&r.push(`${n("rightSize.suggestion")} is missing`)),r}function Is(e){return{ok:!1,detail:e}}function OCe(e){let t;try{t=JSON.parse(e)}catch{return Is(`the engine wrote ${e.length} byte(s) that are not JSON`)}if(typeof t!="object"||t===null||Array.isArray(t))return Is("the engine's answer is not an object");let n=t,i=["engine","version","tolerance"].filter(o=>typeof n[o]!="string"||n[o].trim().length===0);if(i.length>0)return Is(`the engine's answer states no ${i.join(", ")}. Every figure carries provenance, so an answer that cannot say who produced it is not a usable answer`);if(!eL(n.basis))return Is(`the engine's answer states a basis of ${JSON.stringify(n.basis)}, which is not modeled or validated`);if(typeof n.figures!="object"||n.figures===null||Array.isArray(n.figures))return Is("the engine's answer carries no figures map");if(n.total!==void 0){let o=n.total;if(typeof o!="object"||o===null||typeof o.perHour!="number"||!Number.isFinite(o.perHour)||o.perHour<0||typeof o.currency!="string"||o.currency.trim().length===0)return Is("the engine's answer states a total that is not a non-negative rate in a named currency")}if(n.declined!==void 0){let o=n.declined;if(typeof o!="object"||o===null||Array.isArray(o))return Is("the engine's answer carries a declined list that is not a map");for(let[s,a]of Object.entries(o))if(typeof a!="string")return Is(`the engine declined ${s} with a reason that is not a string`)}let r=[];for(let[o,s]of Object.entries(n.figures))if(r.push(...PCe(o,s)),r.length>=5)break;return r.length>0?Is(`the engine's answer is malformed: ${r.slice(0,5).join("; ")}`+(r.length>=5?" (and possibly more)":"")):{ok:!0,answer:n}}function CCe(e={}){return(t,n)=>{let i=t.value.trim();if(i.length!==0){if(T8(i))return PX(D8(Ts,t,n,e),t);if(!/^[a-z][a-z0-9+.-]*:\/\//i.test(i))return ACe(t)}}}var Ts,RCe,SCe,_X,IX=v(()=>{"use strict";ec();lL();jL();Ts="chant";RCe=3e4,SCe=8*1024*1024;_X=CCe()});function DX(e={}){let t=e.env??process.env,n=e.kinds??[],i=e.connect??_X;return async function(o){let s=_8(Ts,o);if(s)return s;let a=$8(Ts,t);if(!a)return A8(Ts);let l=i(a,t);if(!l)return yh(Ts,a,"no transport speaks that address \u2014 a http(s) URL is dialled with a bearer token, and a bare address is run as a command on PATH; any other scheme has no transport yet");let c=EX(o,n),u=await l.predict(c);if(!u.ok)return u.refusal;let{answer:d}=u,p=Object.create(null),f=Object.create(null);for(let g of c.withheld)f[g.name]={...g.entityType==="(undeclared)"?{}:{type:g.entityType},reason:"unsupported-kind",detail:g.detail};for(let g of c.nodes){let h=TX(d.declined,g.name)?d.declined[g.name]:void 0;if(h!==void 0){f[g.name]={type:g.entityType,reason:"read-failed",detail:`${d.engine} was sent ${g.name} as a ${g.kind} and declined it: ${h}`};continue}let b=TX(d.figures,g.name)?d.figures[g.name]:void 0;if(b===void 0){f[g.name]={type:g.entityType,reason:"read-failed",detail:`${d.engine} was sent ${g.name} and its answer names it in neither its figures nor its declined list. An engine that loses a node is reported, not rendered as an estate one node smaller.`};continue}p[g.name]=_Ce(o.traffic,b,d)}return v8(o,{engine:d.engine,version:d.version,...d.total?{total:tL(d.total.perHour,d.total.currency)}:{}},p,f)}}function TX(e,t){return e!==void 0&&Object.prototype.hasOwnProperty.call(e,t)}function _Ce(e,t,n){let i=t.headroom?.cpu,r=t.headroom?.latency,o=i!==void 0?{cpu:i,...r!==void 0?{latency:r}:{}}:{latency:r};if(i===void 0&&r===void 0)throw new Error("predictBehaviour: the engine's figure for this entity carries neither a cpu nor a latency headroom axis, and parseEngineAnswer should have refused it.");return{at:{traffic:e},cost:tL(t.perHour,t.currency),headroom:o,errorRate:t.errorRate,resilience:{failure:t.resilience.failure,verdict:t.resilience.verdict,...t.resilience.note?{note:t.resilience.note}:{}},...t.rightSize?{rightSize:t.rightSize}:{},provenance:{engine:n.engine,version:n.version,tolerance:n.tolerance,basis:n.basis}}}var NX=v(()=>{"use strict";ec();jL();IX()});import{exec as ICe}from"node:child_process";import{mkdtemp as TCe,rm as jX}from"node:fs/promises";import{join as LX,resolve as MX}from"node:path";import{promisify as DCe}from"node:util";function y$(e){return`'${e.replace(/'/g,"'\\''")}'`}function FX(){return{verdict:"unknown"}}async function NCe(e,t){let{loadChantConfigUpward:n}=await Promise.resolve().then(()=>(Kt(),iw)),{loadPlugins:i,resolveProjectLexicons:r}=await Promise.resolve().then(()=>(up(),b$)),{build:o}=await Promise.resolve().then(()=>(cp(),A9)),{buildGraphIr:s}=await Promise.resolve().then(()=>(ah(),N9)),{config:a}=await n(e),l=await r(e),c=await i(l),u=c.map(k=>k.behaviourKinds).filter(k=>k!==void 0),d=MX(e,a.sourceDir??"."),p=await o(d,c.map(k=>k.serializer));if(p.errors.length>0){let k=p.errors.map(R=>typeof R=="string"?R:R.message??String(R));throw new Error(`predictBehaviour: the project under ${e} did not build: ${k.join("; ")}`)}let f=new Map;for(let[k,R]of p.entities){let $=R;typeof $.entityType=="string"&&f.set(k,{entityType:$.entityType,props:$.props!=null?$.props:{}})}let g=s(p.entities,d).edges,h=[...p.outputs.values()][0],b=h===void 0?"":typeof h=="string"?h:h.primary,w={environment:t.environment,buildOutput:b,entityNames:[...f.keys()],entities:f,...t.stack?{stack:t.stack}:{},...t.region?{region:t.region}:{},...t.owned!==void 0?{owned:t.owned}:{},traffic:t.traffic,edges:g,edgeCoverage:FX(),from:"declared"},x=await DX({kinds:u})(w);return G8(x,w.entityNames)}function BX(e,t){return`<!-- chant-behaviour:${wp(e)}/${wp(t)} -->`}function GX(){return"behaviourFinding predicts the pull request's declared estate against its base branch's, and this run names no base branch. On GitHub Actions and Forgejo Actions a pull_request event sets GITHUB_BASE_REF; on GitLab CI a merge_request_event pipeline sets CI_MERGE_REQUEST_TARGET_BRANCH_NAME. Trigger the Op from one of those, or pass `base` with the branch name."}function WX(e,t){let n=t?.trim();if(n)return n;for(let i of["GITHUB_BASE_REF","CI_MERGE_REQUEST_TARGET_BRANCH_NAME"]){let r=e[i]?.trim();if(r)return r}}function zX(e,t){for(let n of["GITHUB_HEAD_REF","CI_MERGE_REQUEST_SOURCE_BRANCH_NAME"]){let i=e[n]?.trim();if(i)return i}return t?.trim()||"head"}async function jCe(e,t){let{stdout:n}=await kp("git rev-parse --show-toplevel",{signal:t}),{stdout:i}=await kp("git rev-parse --show-prefix",{signal:t}),r=n.trim(),o=i.trim(),s="FETCH_HEAD";try{await kp(`git fetch --depth=1 origin ${y$(e)}`,{signal:t})}catch{s=e}let a=await TCe(LX(r,".chant-behaviour-base-"));try{await kp(`git worktree add --detach ${y$(a)} ${y$(s)}`,{signal:t})}catch(l){throw await jX(a,{recursive:!0,force:!0}),new Error(`behaviourFinding could not check out base branch ${JSON.stringify(e)}: ${l.message}`)}return{projectPath:o?LX(a,o):a,async cleanup(){try{await kp(`git worktree remove --force ${y$(a)}`)}catch{await jX(a,{recursive:!0,force:!0})}}}}async function LCe(){try{let{stdout:e}=await kp("git rev-parse --short HEAD");return e.trim()}catch{return}}function MCe(e={}){let t=e.predict??NCe,n=e.checkout??jCe,i=e.post??TL,r=e.env??process.env,o=e.shortSha??LCe;return async function(a,l){let c=a.mode??"comment";if(typeof a.op!="string"||a.op.trim()==="")throw new Error("behaviourFinding needs `op`, the name of the Op this step belongs to: it keys the comment's marker together with `environment`, and an env alone is not unique across Ops (#2319).");let u=WX(r,a.base);if(!u)throw new Error(GX());let d=zX(r,await o()),p={environment:a.environment,traffic:a.traffic,...a.stack?{stack:a.stack}:{},...a.region?{region:a.region}:{},...a.owned!==void 0?{owned:a.owned}:{}},f=await t(MX("."),p),g=await n(u,l),h;try{h=await t(g.projectPath,p)}finally{await g.cleanup()}let b=W8({label:"base",ref:u,result:h},{label:"head",ref:d,result:f}),w=H8(b,{env:a.environment,op:a.op}),x=Xa(h)||Xa(f),k={mode:c,base:u,head:d,finding:b,refused:x,summary:w};if(c==="report")return k;let R=await i({env:a.environment,op:a.op,mode:"comment",marker:m$(BX(a.op,a.environment)),body:w,title:a.title??`Predicted behaviour for ${a.environment} at ${a.traffic}`},l);return{...k,...R.commentUrl?{commentUrl:R.commentUrl}:{},...R.pullRequest?{pullRequest:R.pullRequest}:{},...R.mergeRequest?{mergeRequest:R.mergeRequest}:{}}}}var kp,FCe,UX=v(()=>{"use strict";ec();Qx();NX();g$();kp=DCe(ICe);FCe=MCe()});import{execFile as BCe}from"node:child_process";import{promisify as GCe}from"node:util";var Ort,HX=v(()=>{"use strict";Ah();f$();Ort=GCe(BCe)});var VX=v(()=>{"use strict"});var FL={};_e(FL,{DEFAULT_TIMEOUT_MS:()=>LL,DecideConfigError:()=>nc,SYSTEMONE_PATH:()=>KX,backendAsk:()=>zCe,brokeredCapability:()=>ML,checkKey:()=>WCe,postQuestion:()=>YX,questionName:()=>JX,resolveKey:()=>ZX});function ML(e,t){let n;try{n=Lt(Qt(t).tree).members}catch(s){throw new nc(`the key names the brokered capability ${e.capability}, and the workspace declaration can't be read: ${s instanceof Error?s.message:String(s)}`)}let i=n.filter(s=>(e.member===void 0||s.name===e.member)&&s.box?.capabilities.some(a=>a.name===e.capability));if(i.length===0){let s=e.member!==void 0?`member ${e.member}'s box does not declare the capability ${e.capability}`:`no member's box declares the capability ${e.capability}`;throw new nc(`${s} (box.capabilities in chant.workspace.json, #2726)`)}if(i.length>1)throw new nc(`the capability ${e.capability} is declared by ${i.map(s=>s.name).join(" and ")}: name the member in the key`);let r=i[0],o=r.box.capabilities.find(s=>s.name===e.capability);if(o.broker===null)throw new nc(`member ${r.name}'s capability ${e.capability} names no broker (WSP122), so nothing holds its key`);return{member:r.name,broker:o.broker,scope:o.scope}}function WCe(e,t,n){if(e!==void 0){if(typeof e=="string")throw new nc(`${t} is a literal string; a key is { env: "<VARIABLE>" } or a brokered capability, never the key itself (SYS001)`);e!==null&&typeof e=="object"&&"capability"in e&&ML(e,n)}}function ZX(e,t,n=process.env){if(e===void 0)return;if("capability"in e){let r=ML(e,t);if(e.env===void 0)return;let o=n[e.env];if(!o)throw new Error(`the broker ${r.broker} has not set ${e.env} for the capability ${e.capability}`);return o}let i=n[e.env];if(!i)throw new Error(`the environment variable ${e.env} is not set`);return i}function qX(e){let t=e.replace(/\s+/g," ").trim();return t.length>300?`${t.slice(0,300)}...`:t}async function YX(e,t,n,i){let r=ZX(e.key,i.cwd,i.env),o=JX(n.point),s={model:n.model,state:n.state,questions:{[o]:{type:n.question.type,instructions:n.question.instructions,criteria:n.question.criteria}}},a=`${e.url.replace(/\/+$/,"")}${KX}`,l=AbortSignal.timeout(e.timeoutMs??LL),c=i.signal?AbortSignal.any([i.signal,l]):l,u;try{u=await(i.transport??fetch)(a,{method:"POST",headers:{"content-type":"application/json",accept:"application/json",...r?{authorization:`Bearer ${r}`}:{}},body:JSON.stringify(s),signal:c})}catch(h){let b=l.aborted?`no answer within ${e.timeoutMs??LL} ms`:h instanceof Error?h.message:String(h);throw new Error(`${t} at ${a}: ${b}`)}let d=await u.text();if(!u.ok)throw new Error(`${t} at ${a} answered ${u.status}${d?`: ${qX(d)}`:""}`);let p;try{p=JSON.parse(d)}catch{throw new Error(`${t} at ${a} answered with something that is not JSON: ${qX(d)}`)}let f=p;if(f===null||typeof f!="object")throw new Error(`${t} answered with no JSON object`);if(typeof f.model!="string"||f.model==="")throw new Error(`${t}'s response names no model`);let g=f.answers?.[o];if(g===null||typeof g!="object")throw new Error(`${t}'s response has no answer to ${o}`);return{model:f.model,answer:g,response:f}}function zCe(e){return async t=>{let n=e.backends[t.backend];if(!n)throw new Error(`no backend named ${t.backend} is configured (decide.backends)`);let{model:i,answer:r,response:o}=await YX(n,t.backend,t,e);return e.onResponse?.(t.backend,o),{model:i,answer:r}}}var KX,LL,JX,nc,BL=v(()=>{"use strict";_t();ci();KX="/v1/systemone",LL=3e4,JX=e=>e,nc=class extends Error{constructor(t){super(t),this.name="DecideConfigError"}}});function GL(e,t,n){return async(i,r,o)=>{let s=`${UCe(e)}${r}`,a=await n(s,{method:i,headers:{...t,...o!==void 0?{"Content-Type":"application/json"}:{}},...o!==void 0?{body:JSON.stringify(o)}:{}}),l=await a.text();if(!a.ok)throw new rr(i,s,a.status,l);if(!l)return null;try{return JSON.parse(l)}catch{return l}}}async function WL(e,t){let n=t.fetch??globalThis.fetch,i=e.url?{url:e.url}:{},r=g=>({status:"skipped",forge:e.forge,reason:g,...i}),o=g=>({status:"would-resume",forge:e.forge,how:`would ${g}`,...i});if(e.forge==="github"){let g=GL(e.api,{Authorization:`Bearer ${t.token}`,Accept:"application/vnd.github+json"},n),h=`/repos/${e.repo}/actions/runs/${e.run}`,b=await g("GET",h);if(!Ds(b))throw new Error(`GET ${h} returned no run`);if(b.status!=="completed")return r(`run ${e.run} is ${String(b.status)}, not finished`);let w=typeof b.run_attempt=="number"?b.run_attempt:void 0;return e.attempt!==void 0&&w!==void 0&&w>e.attempt?r(`run ${e.run} was already re-run (attempt ${w}; attempt ${e.attempt} waited)`):b.conclusion==="success"?r(`run ${e.run} succeeded`):t.dryRun?o(`re-run the failed jobs of run ${e.run}`):(await g("POST",`${h}/rerun-failed-jobs`,{}),{status:"resumed",forge:"github",how:`re-ran the failed jobs of run ${e.run}`,...i})}if(e.forge==="gitlab"){let g=GL(e.api,{"PRIVATE-TOKEN":t.token},n),h=`/projects/${encodeURIComponent(decodeURIComponent(e.repo))}`,b=await g("GET",`${h}/jobs/${e.job}`);if(!Ds(b))throw new Error(`GET ${h}/jobs/${e.job} returned no job`);let w=String(b.status);if(w==="success")return r(`job ${e.job} succeeded`);if(!["failed","canceled","skipped"].includes(w))return r(`job ${e.job} is ${w}, not finished`);let x=e.jobName??(typeof b.name=="string"?b.name:void 0);if(x){let $=await g("GET",`${h}/pipelines/${e.run}/jobs?per_page=100`),_=Array.isArray($)?$.find(T=>Ds(T)&&T.name===x):void 0;if(Ds(_)&&String(_.id)!==String(e.job))return r(`job ${e.job} (${x}) was already retried as job ${String(_.id)}`)}if(t.dryRun)return o(`retry job ${e.job}`);let k=await g("POST",`${h}/jobs/${e.job}/retry`),R=Ds(k)&&k.id!==void 0?` as job ${String(k.id)}`:"";return{status:"resumed",forge:"gitlab",how:`retried job ${e.job}${R}`,...i}}let s=GL(e.api,{Authorization:`token ${t.token}`,Accept:"application/json"},n),a=`/repos/${e.repo}`,l=await s("GET",`${a}/actions/runs/${e.run}`);if(!Ds(l))throw new Error(`GET ${a}/actions/runs/${e.run} returned no run`);let c=String(l.status);if(c==="success")return r(`run ${e.run} succeeded`);if(["waiting","running","blocked","unknown"].includes(c))return r(`run ${e.run} is ${c}, not finished`);let u=await s("GET",`${a}/actions/runs?workflow_id=${encodeURIComponent(e.workflow)}&limit=50`),d=Ds(u)&&Array.isArray(u.workflow_runs)?u.workflow_runs:Array.isArray(u)?u:[],p=t.since?Math.floor(new Date(t.since).getTime()/1e3)*1e3:void 0,f=d.find(g=>Ds(g)&&Number(g.id)>Number(e.run)&&(g.prettyref===void 0||g.prettyref===e.ref)&&(p===void 0||typeof g.created=="string"&&new Date(g.created).getTime()>=p));return Ds(f)?r(`run ${String(f.id)} of ${e.workflow} started after the approval`):t.dryRun?o(`dispatch ${e.workflow} on ${e.ref}`):(await s("POST",`${a}/actions/workflows/${encodeURIComponent(e.workflow)}/dispatches`,{ref:e.ref}),{status:"resumed",forge:"forgejo",how:`dispatched ${e.workflow} on ${e.ref}`,...i})}function zL(e,t=process.env){return t.CHANT_FORGE_TOKEN?t.CHANT_FORGE_TOKEN:e==="gitlab"?t.GITLAB_TOKEN:t.GITHUB_TOKEN??t.GH_TOKEN}var UCe,Ds,XX=v(()=>{"use strict";eg();yd();UCe=e=>e.replace(/\/+$/,""),Ds=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)});function UL(e,t,n=[t]){let i=t.environment,r=e.filter(o=>i===void 0||o.environment===i);if(t.approval){let o=rl(r,t.gate,t.timestamp,t.planDigest,t.approval,il(n,t));return o.permit?o.permit:o.counted.length>=o.need?o.counted[o.counted.length-1]:void 0}return jr(r,t.gate,t.timestamp,t.planDigest).resolution}var QX=v(()=>{"use strict";Mi();Gi();XX()});function r7(e,t){let n=new Map;for(let i of e){if(t!==void 0&&i.gate!==t)continue;let r=`${i.gate}\0${i.environment??""}`,o=n.get(r);(!o||Mo(i.timestamp)>=Mo(o.timestamp))&&n.set(r,i)}return[...n.values()]}function e7(e,t,n,i){if(n===void 0)return;let r={gate:t,planDigest:n,timestamp:i.timestamp,...i.review?{review:{pr:i.review.pr,head:i.review.head}}:{}};if(Mr(e,r))return e.find(o=>Mr([o],r))}function w$(e){let t=e.applied??[],n=e.finished??[],i=e.answering??HCe,r=[],o=r7(e.pending,e.gate).filter(s=>!Wn(s,e.now));for(let s of o){let a={source:"pending",op:s.op||e.op,gate:s.gate,...s.environment!==void 0?{environment:s.environment}:{},...s.planDigest!==void 0?{planDigest:s.planDigest}:{},...Vc(s.resume)?{run:s.resume}:{},pending:s};if(s.answer){let u=cg(s,e.questions?.get(s.answer.id));if(!u.resumable){r.push({...a,resumable:!1,reason:"not-approved",message:u.message});continue}let p=e.resolutions.filter(f=>f.gate===s.gate&&f.answer?.id===s.answer.id&&mt(f.planDigest,s.planDigest)).map(f=>({r:f,by:e7(t,s.gate,s.planDigest,f)})).find(f=>f.by);if(p?.by){r.push({...a,resumable:!1,reason:"spent",approvedBy:u.answeredBy,approvedAt:p.r.timestamp,message:n7(p.by),spent:t7(p.by)});continue}r.push({...a,resumable:!0,reason:"answered",approvedBy:u.answeredBy,...u.answeredOn?{approvedAt:u.answeredOn}:{},message:`question ${s.answer.id} has an answer the gate passes on`});continue}let l=i(e.resolutions,s,e.pending);if(!l){r.push({...a,resumable:!1,reason:"not-approved",message:s.approval&&!e.answering?"its gate has an approval block, which needs chant's tally (pass answering)":"no approval answers it yet"});continue}let c=e7(t,s.gate,s.planDigest,l);if(c){r.push({...a,resumable:!1,reason:"spent",approvedBy:l.resolvedBy,approvedAt:l.timestamp,message:n7(c),spent:t7(c)});continue}r.push({...a,resumable:!0,reason:"approved",approvedBy:l.resolvedBy,approvedAt:l.timestamp,message:`approved by ${l.resolvedBy} at ${l.timestamp}`})}for(let s of VCe(t,n,e.pending,e.gate))r.push({source:"stopped",op:s.op||e.op,gate:s.gate,planDigest:s.planDigest,resumable:!0,reason:"stopped",approvedBy:s.approvedBy,approvedAt:s.approvedAt,run:s.resume,stopped:{appliedAt:s.timestamp,approvedAt:s.approvedAt,kind:s.kind,...s.wave?{wave:s.wave}:{}},message:`the apply of ${s.planDigest} under the approval by ${s.approvedBy||"?"} began at ${s.timestamp} and never recorded how it ended; it resumes once run ${s.resume.run} is gone`});return r}function VCe(e,t,n,i){let r=new Map;for(let s of e){if(i!==void 0&&s.gate!==i)continue;let a=r.get(s.gate);(!a||Mo(s.timestamp)>=Mo(a.timestamp))&&r.set(s.gate,s)}let o=[];for(let[s,a]of r){let l=e.filter(u=>u.gate===s&&mt(u.planDigest,a.planDigest)&&Mo(u.approvedAt)===Mo(a.approvedAt)&&Vc(u.resume)),c=l.reduce((u,d)=>!u||Mo(d.timestamp)>=Mo(u.timestamp)?d:u,void 0);c&&(l.some(u=>aq(t,u))||n.some(u=>u.gate===s&&Mo(u.timestamp)>Mo(c.timestamp))||o.push(c))}return o}var Mo,HCe,t7,n7,HL=v(()=>{"use strict";zc();Hc();On();ck();yd();Mo=e=>new Date(e).getTime();HCe=(e,t)=>{if(t.approval)return;let n=e.filter(i=>t.environment===void 0||i.environment===t.environment);return jr(n,t.gate,t.timestamp,t.planDigest).resolution};t7=e=>({appliedAt:e.timestamp,approvedAt:e.approvedAt,...e.wave?{wave:e.wave}:{}}),n7=e=>`the approval that answers it is spent: ${e.wave?`wave ${e.wave.number} (${e.wave.name})`:"a wave"} applied under it at ${e.timestamp}`});var JL={};_e(JL,{readAppliedGateFile:()=>o7,resumeAfterAnswer:()=>JCe,resumeAfterApproval:()=>KCe,resumeCandidate:()=>VL,resumeOpGates:()=>v$,resumeStanding:()=>qCe,resumeWaitingGates:()=>s7,runResumeCommand:()=>KL,workspaceQuestions:()=>i7});async function i7(e){let{workspacePoints:t}=await Promise.resolve().then(()=>(Ph(),x$)),n=await t({cwd:e}).catch(()=>{});return!n||!("questions"in n)?new Map:new Map(n.questions.map(i=>[i.id,{id:i.id,state:i.state,answer:i.answer,answeredBy:i.answeredBy,answeredOn:i.answeredOn}]))}async function qCe(e,t,n={},i=[e]){let[r]=w$({op:e.op,pending:[e],resolutions:t,applied:n.applied??[],now:e.timestamp,...n.questions?{questions:n.questions}:{},answering:(o,s)=>UL(o,s,i)});return VL(r,n)}async function VL(e,t={}){let n={op:e.op,gate:e.gate,...e.environment!==void 0?{environment:e.environment}:{},source:e.source,status:"not-approved",reason:e.reason,resumable:e.resumable,message:e.message,...e.planDigest!==void 0?{planDigest:e.planDigest}:{},...e.approvedBy!==void 0?{approvedBy:e.approvedBy}:{},...e.approvedAt!==void 0?{approvedAt:e.approvedAt}:{},...e.run?.url?{url:e.run.url}:{},...e.run?{run:e.run}:{},...e.spent?{spent:e.spent}:{},...e.stopped?{stopped:{...e.stopped}}:{}};if(e.reason==="spent")return{...n,status:"spent"};if(!e.resumable)return n;if(!e.run)return{...n,status:"no-job",message:"its pending fact names no CI job (it was recorded outside CI); run it again by hand"};let i=e.source==="stopped",r=zL(e.run.forge,t.env??process.env);if(t.dryRun&&!i)return{...n,status:"would-resume",message:`would resume ${e.run.forge} run ${e.run.run}; ${e.message}`};if(!r){let o=`${e.run.forge==="gitlab"?"GITLAB_TOKEN":"GITHUB_TOKEN"}`;return{...n,...i?{resumable:!1}:{},status:"no-token",message:i?`${e.message}; whether run ${e.run.run} is gone needs a token to read ${e.run.forge} with: set CHANT_FORGE_TOKEN (or ${o})`:`no token to call ${e.run.forge} with: set CHANT_FORGE_TOKEN (or ${o})`}}try{let o=i?e.stopped.appliedAt:e.approvedAt,s=await WL(e.run,{token:r,...o?{since:o}:{},...t.fetch?{fetch:t.fetch}:{},...t.dryRun?{dryRun:!0}:{}}),a=s.status==="skipped"?s.reason:s.how;if(!i)return{...n,status:s.status,message:a};let l=s.status!=="skipped";return{...n,status:s.status,resumable:l,message:l?`the apply that began at ${e.stopped.appliedAt} stopped and its run is gone: ${a}`:`the apply that began at ${e.stopped.appliedAt} is left alone: ${a}`,stopped:{...e.stopped,runGone:l}}}catch(o){return{...n,status:"failed",message:o instanceof Error?o.message:String(o)}}}async function o7(e){let{dir:t,file:n}=Uc(e),i=await rn(t,n);return i?sq(i):{applied:[],finished:[]}}async function v$(e,t,n={}){let i=await Lr(e),r=n.applied?{applied:n.applied,finished:n.finished??[]}:await o7(e),o=n.now??new Date().toISOString(),s=n.questions??(i.pending.some(c=>c.answer)?await i7(process.cwd()):void 0),a=w$({op:e,pending:i.pending,resolutions:i.resolutions,applied:r.applied,finished:r.finished,now:o,...t!==void 0?{gate:t}:{},...s?{questions:s}:{},answering:UL}),l=[];for(let c of a)l.push(await VL(c,n));return l}function qL(e){let t=`${e.op} / ${e.gate}${e.environment!==void 0?` (${e.environment})`:""}`,n=e.approvedBy?`, approved by ${e.approvedBy}`:"",i=e.url?` ${e.url}`:"";e.status==="resumed"?console.error(Dp(`${t}${n}: ${e.message}${i}`)):e.status==="would-resume"?console.error(ur(`${t}${n}: ${e.message}${i}`)):e.status==="failed"||e.status==="no-token"?console.error(fe({message:`${t}${n}: not resumed: ${e.message}`,hint:"GitHub needs actions: write; GitLab a token with the api scope and the Developer role; Forgejo a token with write:repository."})):console.error(ur(`${t}${n}: not resumed: ${e.message}${i}`))}async function KCe(e,t,n,i){if(!i)return console.error(Vr({message:"Not resuming: the approval did not reach the remote, so the resumed job would not see it.",hint:"Push chant/lifecycle, then run `chant run resume --op "+e+"`."})),1;let r=(await v$(e,t)).filter(o=>n===void 0||o.environment===n);if(r.length===0)return console.error(ur(`No pending fact for ${e} / ${t} is waiting, so there is nothing to resume.`)),0;for(let o of r)qL(o);return r.some(o=>o.status==="failed"||o.status==="no-token")?1:0}async function JCe(e,t=process.cwd()){let n=Yv(e.subject);if(!n)return console.error(ur(`Question ${e.id} names no gate in its subject, so there is nothing to resume.`)),0;if(e.ledger===null)return console.error(Vr({message:`Not resuming: the answer to ${e.id} is in the working tree, and the resumed job would not see it.`,hint:`Commit and push it, then run \`chant run resume --op ${n.op}\`.`})),1;if((await ad({cwd:t})).status!=="pushed")return console.error(Vr({message:"Not resuming: the answer did not reach the remote, so the resumed job would not see it.",hint:`Push chant/lifecycle, then run \`chant run resume --op ${n.op}\`.`})),1;let i=(await v$(n.op,n.gate)).filter(r=>r.environment===void 0);if(i.length===0)return console.error(ur(`No pending fact for ${n.op} / ${n.gate} is waiting, so there is nothing to resume.`)),0;for(let r of i)qL(r);return i.some(r=>r.status==="failed"||r.status==="no-token")?1:0}async function s7(e={}){let{op:t,gate:n,...i}=e,r=t?[t]:(await Bc(uv)).filter(s=>s.endsWith(".jsonl")).map(s=>s.slice(0,-6)),o=[];for(let s of r)o.push(...await v$(s,n,i));return o}async function KL(e){try{await si()}catch(i){return console.error(fe({message:`Cannot read the gate ledgers: ${i instanceof Error?i.message:String(i)}`})),1}let t=e.args.dryRun===!0,n=await s7({...e.args.op?{op:e.args.op}:{},...e.args.gate?{gate:e.args.gate}:{},dryRun:t});if(e.args.json)console.log(JSON.stringify({dryRun:t,reports:n},null,2));else{for(let o of n.filter(s=>s.status!=="not-approved"))qL(o);let i=n.filter(o=>o.status==="not-approved").length,r=t?`${n.filter(o=>o.resumable).length} would resume`:`${n.filter(o=>o.status==="resumed").length} resumed`;console.error(ur(`${r}, ${i} still waiting for an approval or a passing answer.`))}return n.some(i=>i.status==="failed"||!t&&i.status==="no-token")?1:0}var k$=v(()=>{"use strict";Mi();Hc();$t();ws();QX();HL();Kn()});var x$={};_e(x$,{POINTS_CONTRACT_VERSION:()=>l7,POINTS_ERROR_CODES:()=>QCe,POINTS_OUTPUT_SCHEMA_ID:()=>u7,POINTS_SOURCE_REASON_CODES:()=>e_e,formatPoints:()=>d7,readQuestionStates:()=>t_e,responseAsk:()=>p7,runWorkspacePoints:()=>XL,workspacePoints:()=>YL});import{readFileSync as ZCe}from"node:fs";import{relative as YCe,resolve as c7,sep as XCe}from"node:path";async function YL(e){let t={$schema:u7,contract:l7,chant:Xt()},n,i;try{n=Qt(e.cwd,e.at),i=Lt(n.tree)}catch(c){if(!(c instanceof ve))throw c;return{...t,error:{code:c.code,message:c.message,location:c.location??null}}}let r=e.kind!==void 0?[{shown:e.kind,file:c7(e.cwd,e.kind),given:!0}]:Ni(i).map(c=>({shown:c.path,file:Ma(c,n.rootOnDisk),given:!1})),o=[],s=[],a=[];for(let c of r)try{let u=await gn(c.file);if(!u.kind.answers){c.given&&o.push({kind:c.shown,points:null,reason:{code:"kind-invalid",message:`the ${u.kind.name} kind has no answers block, so it holds no answers to decision points`}});continue}let d,p=await Ns({kind:c.file,cwd:e.cwd,at:e.at,overlay:async(w,{loaded:x,root:k})=>(d=await Sg({file:x.file,name:x.kind.name,dirRel:YCe(k,x.dir).split(XCe).join("/")||"."}),Eg(w,d))}),f=p.at!==null&&p.top?Ea(p.top,p.at):Od(p.root),g=Ad(p.loaded,p.root),h=Pd(f,g),b="points"in h?h.points:{};o.push({kind:c.shown,points:g,reason:"error"in h?{code:"points-invalid",message:h.error}:null});for(let[w,x]of Object.entries(b))s.push({name:w,title:x.title,kind:c.shown,file:g,version:Ra(x),questionType:x.question.type,instructions:x.question.instructions,candidates:x.adhoc?[]:mo(x.question),criteria:x.question.criteria??(x.question.type==="score"?[]:{}),adhoc:!!x.adhoc,inputs:Object.entries(x.inputs).map(([k,R])=>({name:k,output:Jc(k),description:R})),deciders:x.deciders,quorum:Ed(x)});for(let w of p.result.records){let x=xp(w,typeof w.data?.point=="string"?b[w.data.point]:void 0,d?.byPath.get(w.path)?.ledger??null);x&&(!e.open||x.open)&&a.push(x)}}catch(u){if(!(u instanceof Ve))throw u;o.push({kind:c.shown,points:null,reason:{code:u.code,message:u.message}})}let l=c=>a.filter(u=>u.state===c).length;return{...t,at:n.at,workspace:{name:i.name,root:n.root},open:!!e.open,sources:o,points:s,questions:a,summary:{points:s.length,questions:a.length,open:a.filter(c=>c.open).length,escalated:l("escalated"),proposed:l("proposed"),answered:l("answered")}}}async function t_e(e){try{let t=await YL({cwd:e});return!("questions"in t)||t.sources.some(n=>n.reason!==null)?null:new Map(t.questions.map(n=>[n.id,n.state]))}catch{return null}}function d7(e){let t=[];for(let i of e.sources)i.reason&&t.push(`${i.kind}: ${i.reason.code}: ${i.reason.message}`);for(let i of e.points)t.push(`${i.name} ${i.questionType}${i.adhoc?", ad hoc":""} ${i.title} (${i.deciders.map(r=>r.kind).join(", ")})`);e.points.length===0&&t.push("no decision points are declared"),t.push("");for(let i of e.questions){let r=i.model&&i.state!=="answered"?` model ${JSON.stringify(i.model.answer)} at ${i.model.confidence??"?"}${i.model.observed?"":`, below ${i.model.threshold??"?"}`}`:"";t.push(`${i.id} ${i.state} ${i.title}${r}`)}let n=e.summary.questions;return t.push(e.open?`${n} open ${n===1?"question":"questions"}`:`${n} ${n===1?"question":"questions"}, ${e.summary.open} open`),t.join(`
|
|
247
|
+
`)}function p7(e){return async t=>{let n=e;if(n===null||typeof n!="object")throw new Error("the response is not a JSON object");if(typeof n.model!="string"||n.model==="")throw new Error("the response names no model");let i=n.answers?.[t.point];if(i===null||typeof i!="object")throw new Error(`the response has no answer for ${t.point}`);return{model:n.model,answer:i}}}function rc(e,t){return{$schema:Bo,contract:Fo,verb:e,error:{code:"write-usage-invalid",message:t}}}function ZL(e,t,n,i){let r;try{r=n_e(n)?n:ZCe(n==="-"?0:c7(i,n),"utf-8")}catch(o){return{$schema:Bo,contract:Fo,verb:e,error:{code:"write-input-invalid",message:`${t} ${n} could not be read: ${o instanceof Error?o.message:String(o)}`}}}try{return{value:JSON.parse(r)}}catch(o){return{$schema:Bo,contract:Fo,verb:e,error:{code:"write-input-invalid",message:`${t} ${n} is not JSON: ${o instanceof Error?o.message:String(o)}`}}}}async function XL(e){let{args:t}=e,n=process.cwd(),i=s=>(console.log(JSON.stringify(s,null,2)),"error"in s?1:0),r=t.extraPositional;if(r==="ask"){let s=t.extraPositional2;if(!s)return i(rc("ask","ask needs the point's name"));if(t.inputs===void 0)return i(rc("ask","--inputs <file|-|json> is required"));if(t.inputs==="-"&&t.candidates==="-")return i(rc("ask","--inputs and --candidates can't both read standard input: give one as a file or as JSON"));let a=ZL("ask","--inputs",t.inputs,n);if(!("value"in a))return i(a);let l;if(t.candidates!==void 0){let u=ZL("ask","--candidates",t.candidates,n);if(!("value"in u))return i(u);l=u.value}let c;if(t.response!==void 0){let u=ZL("ask","--response",t.response,n);if(!("value"in u))return i(u);c=p7(u.value)}return i(await QL({cwd:n,point:s,inputs:a.value,candidates:l,subject:t.subject,kind:t.kind,ask:c,...t.store?{store:t.store}:{},dryRun:t.dryRun}))}if(r==="answer"){let s=t.extraPositional2;if(!s)return i(rc("answer","answer needs the question's id"));if(t.answer===void 0)return i(rc("answer","--answer <value> is required"));if(!t.bys||t.bys.length===0)return i(rc("answer","--by <name> is required, once for each person who answered"));let a=await eM({cwd:n,id:s,answer:t.answer,by:t.bys,note:t.note,relayedBy:t.relayedBy,kind:t.kind,dryRun:t.dryRun}),l=i(a);if(l!==0||t.dryRun||!(t.resumeRun||t.resume!==void 0)||!("question"in a))return l;let{resumeAfterAnswer:c}=await Promise.resolve().then(()=>(k$(),JL));return c(a.question,n)}if(r==="retract"){let s=t.extraPositional2;return s?!t.bys||t.bys.length===0?i(rc("retract","--by <name> is required, once for each person who takes the answer back")):i(await tM({cwd:n,id:s,by:t.bys,note:t.note,kind:t.kind,dryRun:t.dryRun})):i(rc("retract","retract needs the question's id"))}if(r!==void 0)return console.error(fe({message:`chant workspace points takes no argument but ask, answer or retract (got ${r})`,hint:a7})),1;let o=await YL({cwd:n,at:t.at,open:t.open,kind:t.kind});return t.json?console.log(JSON.stringify(o,null,2)):"error"in o?console.error(fe({message:`${o.error.code}: ${o.error.message}`,hint:a7})):console.log(d7(o)),"error"in o?1:0}var l7,u7,QCe,e_e,a7,n_e,Ph=v(()=>{"use strict";Kn();_t();zd();$$();jm();go();Ag();mn();ko();ci();l7=1,u7="https://intentius.io/chant/schemas/workspace/points/v1/points.schema.json",QCe=["declaration-missing","declaration-ambiguous","declaration-unparseable","declaration-invalid","placement-invalid","reader-too-old","root-chant-required","not-a-git-repository","revision-unknown"],e_e=["kind-unreadable","kind-invalid","schema-unreadable","schema-id-mismatch","schema-invalid","location-missing","points-invalid"];a7=["chant workspace points [--open] [--kind <kind file>] [--at <rev>] [--json]","chant workspace points ask <point> --inputs <file|-|json> [--candidates <file|-|json>] [--response <file>] [--subject <id>] [--kind <kind file>] [--dry-run]","chant workspace points answer <id> --answer <value> --by <name> [--by <name>...] [--note <text>] [--relayed-by <principal>] [--kind <kind file>] [--resume] [--dry-run]","chant workspace points retract <id> --by <name> [--by <name>...] [--note <text>] [--kind <kind file>] [--dry-run]"].join(`
|
|
248
|
+
`);n_e=e=>/^\s*[[{]/.test(e)});var f7,nM=v(()=>{"use strict";ll();_t();Zt();f7=".chant/generated.json"});function m7(e){return e===".gitlab-ci.yml"?!0:/^(\.github\/workflows|\.forgejo\/workflows|\.gitea\/workflows|\.gitlab\/ci)\/[^/]+$/.test(e)}var g7=v(()=>{"use strict";jg();nM()});function i_e(e,t){let n;try{n=bd.load(t)}catch{return null}if(!n||typeof n!="object"||Array.isArray(n))return null;let i=n;if(e.startsWith(".gitlab/ci/")||e===".gitlab-ci.yml")return Object.entries(i).filter(([o,s])=>!o.startsWith(".")&&!r_e.has(o)&&s&&typeof s=="object"&&!Array.isArray(s)).map(([o])=>o);let r=i.jobs;return!r||typeof r!="object"||Array.isArray(r)?null:Object.entries(r).map(([o,s])=>{let a=s&&typeof s=="object"?s.name:void 0;return typeof a=="string"&&a!==""?a:o})}function h7(e,t,n){let i=a=>ze(n,a),r=new Map,o=ze(e.dir,f7);if(t.stat(o)==="file")try{let a=JSON.parse(t.read(o));for(let l of Array.isArray(a.files)?a.files:[])typeof l.path=="string"&&r.set(l.path,{path:l.path,command:typeof l.command=="string"?l.command:"",env:typeof l.env=="string"?l.env:null,jobs:null})}catch{}for(let a of e.generated){if(a.handWritten)continue;let l=i(ze(e.dir,a.path));r.set(l,{path:l,command:a.generator,env:r.get(l)?.env??null,jobs:null})}let s=n==="."?"":`${n}/`;for(let a of r.values()){if(!m7(a.path)||!a.path.startsWith(s))continue;let l=a.path.slice(s.length);if(t.stat(l)==="file")try{a.jobs=i_e(a.path,t.read(l))}catch{a.jobs=null}}return[...r.values()].sort((a,l)=>a.path<l.path?-1:a.path>l.path?1:0)}var r_e,y7=v(()=>{"use strict";AI();g7();nM();Zt();r_e=new Set(["stages","variables","default","include","workflow","image","services","cache","before_script","after_script","pages"])});import{isAbsolute as o_e,resolve as Ait}from"node:path";function R$(e,t,n){if(t.stat(e.dir==="."?"":e.dir)!=="dir")return{code:"dir-missing",message:`${e.dir} is not a directory${t.label}`};let i=n.get(e.kind);return i?hV(i,t,e.dir==="."?"":e.dir)?null:{code:"kind-probe-failed",message:`${e.dir} is not ${i.description}`}:{code:"unknown-kind",message:`no built-in kind or pinned package supplies kind ${e.kind}; known kinds: ${n.names().join(", ")}`}}function w7(e){return c_e(e).doc}function c_e(e){let t=Xt(),n={$schema:a_e,contract:s_e,chant:t};try{let i=Qt(e.cwd,e.at),{tree:r,rootOnDisk:o,at:s}=i,a=Lt(r,"",{rootChant:!0}),l=e.kinds??ma(a.pins,o).registry,c=ha(a,r),u=o_e(i.root)?".":i.root,d=s!==null?{agents:a.agents,from:"at"}:cT(e.cwd)??{agents:a.agents,from:"working-tree"},p=a.members.map(b=>{let w=R$(b,r,l);return{name:b.name,dir:b.dir,kind:b.kind,roles:b.roles,upstream:b.upstream,because:b.because,readable:w===null,reason:w,records:b7(b.records),generated:h7(b,r,u),agents:d.agents.filter(x=>x.members.includes(b.name)).map(x=>x.name),...bm(a,b.pointer)}}),f=c.map(b=>({name:b.group.name,kind:"examples",glob:b.group.globs,matches:b.matches,skipped:b.skipped,reason:b.matches.length===0?{code:"no-matches",message:`no directory ${b.group.globs.join(" or ")} matches${r.label} holds a chant project`}:null})),g=_0(a).map(b=>({name:b.name,title:b.title,source:b.source,render:b.render,renderer:b.renderer,member:b.member}));return{doc:{...n,at:s,workspace:{name:a.name,root:i.root,file:a.file,schema:a.schema,minReader:a.minReader,pins:a.pins,records:b7(a.records),agentsFrom:d.from,...bm(a,"")},members:p,groups:f,diagrams:g,ci:a.ci?{green:a.ci.green?{branch:a.ci.green.branch,window:a.ci.green.window,phases:a.ci.green.phases.map(b=>({name:b.name,runs:b.runs,skipped:b.skipped})),require:a.ci.green.require}:null}:null,summary:{members:p.length,unreadable:p.filter(b=>!b.readable).length,groups:f.length,matches:f.reduce((b,w)=>b+w.matches.length,0)}},declaration:a,tree:r,rootOnDisk:o}}catch(i){if(!(i instanceof ve))throw i;return{doc:{...n,error:{code:i.code,message:i.message,location:i.location??null}}}}}var s_e,a_e,b7,rM=v(()=>{"use strict";Kn();_t();y7();co();ci();gs();s_e=1,a_e="https://intentius.io/chant/schemas/workspace/ls/v1/ls.schema.json";b7=e=>e.map(t=>({name:t.name,path:t.path,kind:null,reason:null,acceptance:null}))});function v7(e,t){let n=e;for(let i of t.split(".")){if(n===null||typeof n!="object"||!Object.prototype.hasOwnProperty.call(n,i))return;n=n[i]}return n}function k7(e,t,n="acceptance"){let i=e??{},r=Array.isArray(i[n])?i[n]:[],o=iM(v7(i,"source.ask.said"))||iM(v7(i,"source.intent.answer")),s=t.split(`
|
|
249
|
+
`).filter(u=>!l_e.test(u)),a=r.map(u=>typeof u=="string"?u:iM(u?.text)),l=[o,...s,...a].join(`
|
|
250
|
+
`),c=new Set([...l.matchAll(/`([^`\s]+)`/g)].map(u=>u[1]).filter(u=>u_e.test(u)));return{criteria:r.length,files:c.size,words:l.split(/\s+/).filter(Boolean).length}}function d_e(e,t){return t?["criteria","files","words"].every(n=>t[n]===void 0||e[n]<=t[n]):!1}function x7(e,t=oM){let n={criteria:e.criteria,files:e.files,words:e.words};for(let[i,r]of Object.entries(t))n[`fits_${i}`]=d_e(e,r);return n}var oM,l_e,u_e,iM,$7=v(()=>{"use strict";oM=Object.freeze({small:{criteria:10,files:5,words:150},medium:{criteria:20,files:10,words:300}}),l_e=/^\s*#/,u_e=/^[\w@.-]+(\/[\w@.*-]+)+\/?$|^[\w@-][\w@.-]*\.[a-z]{1,5}$/i,iM=e=>typeof e=="string"?e:""});var R7={};_e(R7,{InputReadError:()=>ic,READABLE_OUTPUTS:()=>sM,fieldOf:()=>S$,readInputs:()=>b_e});import{readFileSync as p_e}from"node:fs";import{join as f_e}from"node:path";function S$(e,t){let n=e;for(let i of t.split(".")){if(n===null||typeof n!="object"||!Object.prototype.hasOwnProperty.call(n,i))return;n=n[i]}return n}async function m_e(e,t,n){let i=li(t),r=await E$(i,{cwd:t}),o=[];for(let[s,a]of r.kinds.entries()){if("error"in a){o.push(`${a.declared.path}: ${a.error.code}`);continue}let l=a.records.find(c=>c.id===e);if(l){let c=l;return n==="work-item"?{...c,...await g_e(i[s].file,l.path,l.data,t)}:c}}throw new ic(`no declared record kind holds a record with id ${e} (read for ${n})${o.length?`; not read: ${o.join(", ")}`:""}`)}async function g_e(e,t,n,i){let o=(await gn(e,i)).kind.work;if(!o)return{};let s=Qt(i),a="";try{a=WI(p_e(f_e(s.top??s.rootOnDisk,...t.split("/")),"utf-8"))}catch{}let l=k7(n,a,o.acceptance?.field??"acceptance");return x7(l,o.tier?.limits??oM)}function h_e(e,t){let n=w7({cwd:t});if("error"in n)throw new ic(`the workspace can't be listed: ${n.error.code}: ${n.error.message}`);let i=n.members.find(r=>r.name===e);if(!i)throw new ic(`the workspace has no member named ${e}`);return i}function y_e(e,t,n){let i=e.length>t.length?e.slice(t.length+1):"";if(i==="")return n;if(t==="member")return S$(n,i);let r=S$(n.data,i);return r!==void 0?r:S$(n,i)}async function b_e(e,t,n){let i=new Set(e.map(Jc));for(let a of Object.keys(t)){if(!sM.includes(a))throw new ic(`${a} is not read by id here; pass its values in inputs, as the read contract printed them (read takes ${sM.join(", ")})`);if(!i.has(a))throw new ic(`the point reads no ${a} input (its inputs are ${e.join(", ")})`)}let r=new Map;for(let[a,l]of Object.entries(t))r.set(a,a==="member"?h_e(l,n):await m_e(l,n,a));let o={},s=[];for(let a of e){let l=Jc(a),c=r.get(l);if(c===void 0)continue;let u=y_e(a,l,c);u===void 0?s.push(a):o[a]=u}return{inputs:o,missing:s}}var sM,ic,S7=v(()=>{"use strict";ko();rM();jm();mn();ci();$7();sM=["record","decision","work-item","member"],ic=class extends Error{constructor(t){super(t),this.name="InputReadError"}}});var O7={};_e(O7,{DecideError:()=>wi,decide:()=>P7,runDecide:()=>A7});async function w_e(e,t){let{checkKey:n,DecideConfigError:i}=await Promise.resolve().then(()=>(BL(),FL)),r=e.backends;if(r===void 0){let{config:s}=await Qs(t);r=s.decide?.backends??{}}if(r===null||typeof r!="object"||Array.isArray(r))throw new i("backends must be an object of backend name to { url, key? }");let o={};for(let[s,a]of Object.entries(r)){n(a?.key,`backend ${s}'s key`,t);let l=$u.safeParse(a);if(!l.success)throw new i(`backend ${s} is not { url, key?, timeoutMs? }: ${l.error.issues.map(c=>`${c.path.join(".")||"(backend)"} ${c.message}`).join("; ")}`);o[s]=l.data}return o}async function v_e(e,t){let{workspacePoints:n}=await Promise.resolve().then(()=>(Ph(),x$)),i=await n({cwd:t,...e.kind!==void 0?{kind:e.kind}:{}});if("error"in i)throw new wi(i.error.code,i.error.message);let r=i.points.find(o=>o.name===e.point);if(!r){let o=i.sources.find(s=>s.reason);throw new wi("point-unknown",`no points file declares ${JSON.stringify(e.point)}${o?` (${o.kind}: ${o.reason.message})`:i.points.length?` (the points are ${i.points.map(s=>s.name).join(", ")})`:""}`)}return r}function E7(e,t){let n=typeof e.decider.kind=="string"?e.decider.kind:"quorum",i=n==="model";return{id:e.id,path:e.path,state:e.state,open:e.open,answer:e.answer,decider:n,model:i?e.model?.model??null:null,backend:i?e.model?.backend??null:null,confidence:i?e.confidence:null,threshold:i?e.threshold:null,reason:i?e.reason:null,answeredBy:e.answeredBy,escalations:e.escalations,missing:t}}async function A7(e,t={},n){if(typeof e?.point!="string"||e.point==="")throw new wi("write-usage-invalid","decide needs the point's name");let i=e.cwd??process.cwd(),{backendAsk:r,brokeredCapability:o,checkKey:s,DecideConfigError:a}=await Promise.resolve().then(()=>(BL(),FL)),l=k=>{try{return k()}catch(R){throw R instanceof a?new wi("backend-invalid",R.message):R}},c;try{c=await w_e(e,i)}catch(k){throw k instanceof a?new wi("backend-invalid",k.message):k}let u=await v_e(e,i),d;for(let k of u.deciders){if(k.kind!=="model")continue;let R=c[k.backend];if(!R)throw new wi("backend-invalid",`${e.point}'s model decider names the backend ${k.backend}, and none is configured (decide.backends${Object.keys(c).length?`: ${Object.keys(c).join(", ")}`:" is empty"})`);if(l(()=>s(R.key,`backend ${k.backend}'s key`,i)),d===void 0&&R.key&&"capability"in R.key){let $=R.key;d={capability:$.capability,broker:l(()=>o($,i)).broker}}}let p={inputs:{},missing:[]};if(e.read&&Object.keys(e.read).length>0)try{let{readInputs:k}=await Promise.resolve().then(()=>(S7(),R7));p=await k(u.inputs.map(R=>R.name),e.read,i)}catch(k){throw new wi("point-inputs-invalid",k instanceof Error?k.message:String(k))}let f={...p.inputs,...e.inputs??{}},g=p.missing.filter(k=>!(k in f)),h=r({backends:c,cwd:i,...t.transport?{transport:t.transport}:{},...t.env?{env:t.env}:{},...n?{signal:n}:{},...t.onResponse?{onResponse:t.onResponse}:{}}),b=wo(),w=async k=>{let R=c[k.backend]?.key;if(b&&R&&!("capability"in R))throw new Error(`in the steward ${b.steward}'s turn a model call goes through the broker, and backend ${k.backend}'s key is the environment variable ${R.env}, a credential the steward would hold`);return h(k)},x={cwd:i,point:e.point,inputs:f,...e.subject!==void 0?{subject:e.subject}:{},...e.kind!==void 0?{kind:e.kind}:{},...e.store!==void 0?{store:e.store}:{},...t.on?{on:t.on}:{}};if(e.dryRun){let{askPoint:k}=await Promise.resolve().then(()=>($$(),cM)),R=await k({...x,ask:await A$(w,{...d||{},turn:b??null,cwd:i}),...b?{steward:{name:b.steward,...b.run?{run:b.run}:{}}}:{client:{name:"chant decide"}},dryRun:!0});if("error"in R)throw new wi(R.error.code,`${R.error.code}: ${R.error.message}`);return E7(R.question,g)}try{let{question:k}=await lM({...x,ask:w,...d?{capability:d.capability,broker:d.broker}:{},turn:b??null});return E7(k,g)}catch(k){if($p(k))throw k;let R=k instanceof Error?/^decision point [^:]+: ([a-z0-9-]+): /.exec(k.message):null;throw R?new wi(R[1],k instanceof Error?k.message:String(k)):k}}async function P7(e,t){return A7(e,{},t)}var wi,aM=v(()=>{"use strict";Kt();Oh();cl();ew();wi=class extends Error{constructor(n,i){super(i);this.code=n;this.name="DecideError"}}});var C7=v(()=>{"use strict";bp()});var _7=v(()=>{"use strict";VY();KY();YY();XY();_L();QY();eX();tX();nX();rX();g$();OL();hX();yX();bX();wX();vX();kX();$X();UX();HX();VX();aM();C7()});var P$=v(()=>{"use strict";_7();gd();xn()});var wst,vst,kst,xst,$st,Rst,Sst,Est,Ast,Pst,Ost,uM,Cst,_st,Ist,Tst,Dst,x_e,Nst,jst,Lst,O$,$_e,Mst,Fst,Bst,Gst,Wst,zst,I7=v(()=>{"use strict";Ln();Rm();ew();wst=Pt("lifecycleSnapshot",m.strictObject({env:m.string()})),vst=Pt("lifecycleDiff",m.strictObject({env:m.string(),live:m.boolean().optional()}),m.object({output:m.string(),exitCode:m.number(),drifted:m.boolean()})),kst=Pt("shellCmd",m.strictObject({cmd:m.string(),env:m.record(m.string(),m.string()).optional(),cwd:m.string().optional(),okExit:m.array(m.number()).optional(),gatedExit:m.number().optional(),gate:m.strictObject({op:m.string(),gate:m.string()}).optional(),json:m.boolean().optional()}),m.object({stdout:m.string(),stderr:m.string(),exitCode:m.number(),json:m.unknown().optional()})),xst=Pt("httpCheck",m.strictObject({url:m.string(),method:m.string().optional(),status:m.number().optional(),contains:m.string().optional(),retries:m.number().optional(),intervalMs:m.number().optional()}),m.object({status:m.number()}),{entities:["url"]}),$st=Pt("chantTeardown",m.strictObject({path:m.string()})),Rst=Pt("predictBehaviour",m.strictObject({environment:m.string(),traffic:m.string(),stack:m.string().optional(),region:m.string().optional(),owned:m.boolean().optional()}),m.object({behaviour:m.literal("v1"),refusal:m.unknown().optional()})),Sst=Pt("behaviourFinding",m.strictObject({environment:m.string(),traffic:m.string(),op:m.string(),mode:m.enum(["comment","report"]).optional(),base:m.string().optional(),title:m.string().optional(),stack:m.string().optional(),region:m.string().optional(),owned:m.boolean().optional()}),m.object({mode:m.enum(["comment","report"]),base:m.string(),head:m.string(),refused:m.boolean(),summary:m.string(),commentUrl:m.string().optional(),pullRequest:m.string().optional(),mergeRequest:m.string().optional()})),Est=Pt("proposeWorkspaceUpgrade",m.strictObject({scope:m.string().optional(),to:m.string().optional(),mode:m.enum(["report","branch","pull-request"]).optional(),branch:m.string().optional(),base:m.string().optional(),remote:m.string().optional(),allowCode:m.boolean().optional(),source:m.string().optional(),cwd:m.string().optional()}),m.object({scope:m.string(),mode:m.enum(["report","branch","pull-request"]),changed:m.boolean(),proposed:m.boolean(),checksOk:m.boolean(),from:m.string().nullable(),to:m.string().nullable(),digest:m.string(),manualSteps:m.number(),governance:m.boolean(),branch:m.string().optional(),commit:m.string().optional(),pushed:m.boolean().optional(),prUrl:m.string().optional(),summary:m.string()})),Ast=Pt("changeCoverage",m.strictObject({cwd:m.string().optional(),range:m.string().optional(),work:m.string().optional(),severity:m.enum(["off","warn","fail"]).optional()}),m.object({ok:m.boolean(),range:m.object({spec:m.string(),base:m.string(),head:m.string()}),work:m.string().nullable(),severity:m.enum(["off","warn","fail"]),findings:m.array(m.object({code:m.enum(["change-uncovered","change-out-of-scope"]),path:m.string(),message:m.string(),severity:m.enum(["warn","fail"]),records:m.array(m.string()),triage:m.object({finding:m.enum(["change-uncovered","change-out-of-scope"]),region:m.string()})})),summary:m.object({paths:m.number(),covered:m.number(),uncovered:m.number(),outOfScope:m.number(),ignored:m.number(),records:m.number()})})),Pst=Pt("workEvidence",m.strictObject({lease:m.unknown(),criterion:m.string(),result:m.enum(["pass","fail"]),title:m.string(),url:m.string().optional(),path:m.string().optional(),kind:m.string().optional(),cwd:m.string().optional()}),m.object({item:m.string(),path:m.string(),evidence:m.record(m.string(),m.unknown()),acceptance:m.object({met:m.number(),total:m.number(),criteria:m.array(m.object({id:m.string(),verification:m.string(),met:m.boolean()}))})})),Ost=Pt("sourceArchive",m.strictObject({path:m.string(),ref:m.string().optional(),out:m.string().optional(),cwd:m.string().optional()}),m.object({digest:m.string(),archive:m.string(),commit:m.string(),dir:m.string(),files:m.number(),bytes:m.number()})),uM=m.object({member:m.object({member:m.string(),planDigest:m.string().nullable()}).passthrough(),entries:m.array(m.unknown())}),Cst=Pt("composeChangeSet",m.strictObject({parts:m.array(uM)}),m.object({document:m.record(m.string(),m.unknown()),digest:m.string(),summary:m.record(m.string(),m.unknown())})),_st=Pt("lifecyclePlanChangeSet",m.strictObject({member:m.string(),env:m.string(),cwd:m.string().optional(),owned:m.boolean().optional()}),m.object({part:uM})),Ist=Pt("readChangeSetPart",m.strictObject({member:m.string(),planner:m.enum(["chant","warden","sql"]),file:m.string(),lexicon:m.string().optional()}),m.object({part:uM})),Tst=Pt("releasePlan",m.strictObject({component:m.string(),env:m.string(),gitSha:m.string(),content:m.record(m.string(),m.unknown()),dir:m.string().optional(),cwd:m.string().optional()}),m.object({digest:m.string(),file:m.string(),gitSha:m.string()})),Dst=Pt("releaseRecord",m.strictObject({plan:m.string(),digest:m.string().optional(),approval:m.strictObject({op:m.string(),gate:m.string()}).optional(),actor:m.string().optional(),runId:m.string().optional(),cwd:m.string().optional()}),m.object({recorded:m.boolean(),digest:m.string(),env:m.string(),component:m.string(),approver:m.string().nullable()})),x_e=m.object({kind:m.enum(["table","model"]),reason:m.string()}).loose(),Nst=Pt("decide",m.strictObject({point:m.string().min(1),inputs:m.record(m.string(),m.unknown()).optional(),read:m.record(m.string(),m.string()).optional(),subject:m.string().optional(),kind:m.string().optional(),cwd:m.string().optional(),backends:m.record(m.string(),$u).optional(),dryRun:m.boolean().optional(),store:m.enum(["tree","ledger"]).optional()}),m.strictObject({id:m.string(),path:m.string(),state:m.enum(["escalated","proposed","answered"]),open:m.boolean(),answer:m.union([m.string(),m.boolean(),m.null()]),decider:m.string(),model:m.string().nullable(),backend:m.string().nullable(),confidence:m.number().nullable(),threshold:m.number().nullable(),answeredBy:m.array(m.string()),escalations:m.array(x_e),missing:m.array(m.string())}),{entities:["point"]}),jst=Pt("releaseRollbackPlan",m.strictObject({component:m.string(),env:m.string(),to:m.string().optional(),path:m.string().optional(),dir:m.string().optional(),cwd:m.string().optional()}),m.object({digest:m.string(),file:m.string(),to:m.string(),from:m.string(),gitSha:m.string(),archive:m.string(),archiveDigest:m.string(),dir:m.string()})),Lst=Pt("releaseRollbackRecord",m.strictObject({plan:m.string(),digest:m.string().optional(),approval:m.strictObject({op:m.string(),gate:m.string()}).optional(),actor:m.string().optional(),runId:m.string().optional(),cwd:m.string().optional()}),m.object({recorded:m.boolean(),digest:m.string(),env:m.string(),component:m.string(),approver:m.string().nullable()})),O$=m.unknown(),$_e=m.record(m.string(),$u).optional(),Mst=Pt("factoryPick",m.strictObject({cwd:m.string().optional(),kind:m.string().optional()}),m.strictObject({candidates:m.array(m.string()),held:m.array(m.object({item:m.string(),hold:m.string(),message:m.string()})),keys:m.array(m.string())})),Fst=Pt("factoryReady",m.strictObject({cwd:m.string().optional(),kind:m.string().optional(),also:m.string().optional()}),m.array(m.string())),Bst=Pt("factoryAsk",m.strictObject({lease:O$,cwd:m.string().optional(),kind:m.string().optional(),backends:$_e}),m.strictObject({item:m.string(),ask:m.boolean(),tier:m.string(),understand:m.string().nullable(),outcome:m.enum(["dropped","redraft","ask"]).nullable()})),Gst=Pt("factoryBuild",m.strictObject({lease:O$,ask:m.unknown(),builder:m.string().min(1),context:m.string().optional(),cwd:m.string().optional()}),m.strictObject({ran:m.boolean(),finished:m.boolean(),exitCode:m.number().nullable(),reverted:m.array(m.string()),note:m.string(),report:m.record(m.string(),m.unknown()).nullable()})),Wst=Pt("factoryCheck",m.strictObject({lease:O$,build:m.unknown(),check:m.string().optional(),cwd:m.string().optional()}),m.strictObject({ran:m.boolean(),ok:m.boolean(),command:m.string().nullable(),evidence:m.array(m.string()),log:m.string().nullable(),report:m.record(m.string(),m.unknown()).nullable()})),zst=Pt("factoryRecord",m.strictObject({lease:O$,ask:m.unknown(),build:m.unknown(),check:m.unknown(),after:m.string().optional(),cwd:m.string().optional()}),m.strictObject({outcome:m.enum(["done","not_done","dropped","redraft","ask"]),reason:m.string().nullable(),commit:m.string().nullable(),implementsProposed:m.array(m.object({decision:m.string(),paths:m.array(m.string())}))}))});var T7=v(()=>{"use strict";I7();Rm();xn()});import{AsyncLocalStorage as E_e}from"node:async_hooks";var Kst,dM=v(()=>{"use strict";Kst=new E_e});var vat,Ch=v(()=>{"use strict";uo();P$();Bi();cs();gd();Gi();Oi();ws();C$();mv();dM();Oh();u$();cl();Nl();hp();uo();bp();Nl();cs();vat=5*6e4});var mM=v(()=>{"use strict"});var N7=v(()=>{"use strict";or();mM();Kg();Kb();ll();Kt();lk();Ei();Zs()});var j7=v(()=>{"use strict"});var L7=v(()=>{"use strict"});var M7=v(()=>{"use strict";On()});var F7=v(()=>{"use strict";$t();$h()});var B7=v(()=>{"use strict";j7();L7();Gi();Oi();M7();F7()});var G7=v(()=>{"use strict";Hj();xn();Vj();qj()});var W7=v(()=>{"use strict";Kt()});var z7=v(()=>{"use strict";wT();xn();N7();mM();B7();Oi();So();$t();G7();W7();Kt()});var gM=v(()=>{"use strict"});var H7=v(()=>{"use strict";xn();Kt();P$();Ch();z7();Wi();Nl();gM()});var V7=v(()=>{"use strict";gd();Oi()});var q7=v(()=>{"use strict";Gi();iv()});var bM=v(()=>{"use strict";Ch();cs();Yd();ul()});var wM=v(()=>{"use strict"});var Y7=v(()=>{"use strict";Wi();Ch();Yd();Nl();Mi();cl();ul();bM();hp();$t();pg();wM()});var Q7=v(()=>{"use strict";yi();Bi();hp()});var eQ=v(()=>{"use strict";yi();Sx();vh();kL();DY();uo();hp();pg();UY();Rh();a$();Wi();HY();Bd();AM();YO();P$();T7();gd();h$();Ch();dM();Gi();Gi();HL();Em();mv();On();Oi();ws();C$();H7();gM();V7();q7();Rm();Bi();c$();Y7();bM();ul();Wi();Oh();u$();cl();bp();wM();DL();yi();Q7()});var iQ=v(()=>{"use strict";Pn();rx();ox();di();tN();rN();er();Kg();Qo();i5();or();Cu();Wt();o5();s5();kl();ll();cx();lx();fN();mN();gN();dx();Rx();m9();cp();vu();ah();j9();L9();M9();F9();B9();HN();tx();wl();wl();jN();U9();H9();J9();Y9();xj();$j();Tx();Oj();l8();u8();p8();f8();m8();So();gi();qx();Yj();fp();ec();lL();dL();Qx();e$();fx();V8();pL();q8();K8();Kt();J8();Z8();Y8();fL();Q8();nY();rY();gL();hL();uY();wh();n$();pY();fY();BN();no();mY();gY();xx();hY();yY();bY();IY();eQ()});function oQ(e){let t=[],n=[],i=new Map;for(let l of e){let c=l.lintRules?.()??[];for(let u of c){let d=i.get(u.id)??[];d.push(l.name),i.set(u.id,d)}}for(let[l,c]of i)c.length>1&&t.push({type:"rule-id",key:l,plugins:c});let r=new Map;for(let l of e){let c=l.skills?.()??[];for(let u of c){let d=r.get(u.name)??[];d.push(l.name),r.set(u.name,d)}}for(let[l,c]of r)c.length>1&&n.push({type:"skill-name",key:l,plugins:c});let o=new Map;for(let l of e){let c=l.mcpTools?.()??[];for(let u of c){let d=o.get(u.name)??[];d.push(l.name),o.set(u.name,d)}}for(let[l,c]of o)c.length>1&&n.push({type:"mcp-tool",key:l,plugins:c});let s=new Map;for(let l of e){let c=l.mcpResources?.()??[];for(let u of c){let d=s.get(u.uri)??[];d.push(l.name),s.set(u.uri,d)}}for(let[l,c]of s)c.length>1&&n.push({type:"mcp-resource",key:l,plugins:c});let a=new Map;for(let l of e){let c=l.commands?.();if(!c)continue;let u=a.get(c.name)??[];u.push(l.name),a.set(c.name,u)}for(let[l,c]of a)(c.length>1||nR.has(l))&&t.push({type:"command-group-name",key:l,plugins:c});return{conflicts:t,warnings:n}}function sQ(e){let t=` ${e.type} "${e.key}" from: ${e.plugins.join(", ")}`;return e.type==="command-group-name"&&nR.has(e.key)?`${t} \u2014 "${e.key}" is a reserved chant command name, so no lexicon can register a command group with it. Rename the group.`:t}var aQ=v(()=>{"use strict";rR()});import{createHash as n0e}from"node:crypto";import{existsSync as cQ,mkdirSync as pgt,readFileSync as r0e,readdirSync as fgt,rmdirSync as mgt,rmSync as ggt,writeFileSync as hgt}from"node:fs";import{dirname as bgt,isAbsolute as i0e,join as lQ,relative as o0e,resolve as uQ,sep as dQ}from"node:path";function c0e(e,t){let n=t.codegen,i=typeof n?.outDir=="string"&&n.outDir.length>0?n.outDir:s0e;return uQ(e,i)}function pQ(e,t,n){return{projectRoot:t,config:n,outDir:lQ(c0e(t,n),e)}}function l0e(e){return`sha256:${n0e("sha256").update(Rr(e)).digest("hex")}`}function u0e(e){let t=lQ(e,a0e);if(cQ(t))try{let n=JSON.parse(r0e(t,"utf8"));return typeof n.inputs!="string"||!Array.isArray(n.files)?void 0:{inputs:n.inputs,files:n.files.filter(i=>typeof i=="string")}}catch{return}}async function d0e(e,t,n){let i=e.projectCodegen?.();if(!i)return{status:"none"};let r=pQ(e.name,t,n),o=f0e(t,r.outDir),s=u0e(r.outDir),a=await i.inputs(r);if(a===void 0)return s?{status:"orphan",message:`${o} holds generated ${e.name} code, but chant.config declares no ${e.name} sources for it. Run \`chant generate\` to remove it.`}:{status:"none"};if(!s)return{status:"missing",message:`chant.config declares ${e.name} sources to generate, but ${o} has no generated code. Run \`chant generate\` and commit the result.`};let l=s.files.filter(c=>!cQ(p0e(r.outDir,c)));return l.length>0?{status:"missing",message:`generated ${e.name} file(s) missing from ${o}: ${l.join(", ")}. Run \`chant generate\` and commit the result.`}:s.inputs!==l0e(a)?{status:"drift",message:`generated ${e.name} code in ${o} is out of date: its declared sources changed since it was generated. Run \`chant generate\` and commit the result.`}:{status:"current"}}async function fQ(e,t,n){let i=await d0e(e,t,n);if("message"in i)throw new Error(i.message);i.status!=="none"&&await e.projectCodegen?.().load?.(pQ(e.name,t,n))}function p0e(e,t){let n=uQ(e,t);if(i0e(t)||n!==e&&!n.startsWith(e+dQ))throw new Error(`generated file path "${t}" is outside ${e}`);return n}function f0e(e,t){let n=o0e(e,t);return n===""?".":n.split(dQ).join("/")}var s0e,a0e,kgt,mQ=v(()=>{"use strict";er();ll();s0e="src/generated",a0e="chant-codegen.json",kgt=`// ${uk}. Run \`chant generate\` to update.`});var b$={};_e(b$,{collectBuildRootContributors:()=>c3,collectChangeSubscribers:()=>x0e,listInstalledLexicons:()=>k0e,loadPlugin:()=>yQ,loadPlugins:()=>x3,recordProjectLexicons:()=>v0e,resolveLexiconVersions:()=>a3,resolveProjectLexicons:()=>$3,unknownPathLexiconsNotice:()=>JD});import{createRequire as m0e}from"node:module";import{dirname as Ih,join as hQ,resolve as g0e}from"node:path";import{fileURLToPath as h0e}from"node:url";import{existsSync as y0e,readdirSync as b0e,readFileSync as w0e}from"node:fs";function v0e(e){let t=KD(e);return t.status==="read"&&Xs(t.entries,Ih(t.configPath)),t}async function yQ(e){let t=Pi(e);if(t!==void 0){let o=await kc(e);for(let s of Object.values(o))if(Qd(s)){if(s.name!==e)throw new Error(`lexicon "${e}" is declared with module ${t}, but the plugin it exports is named "${s.name}"`);return s}throw new Error(`Module ${t} (lexicon "${e}") does not export a LexiconPlugin`)}let n=`@intentius/chant-lexicon-${e}`,i=await Yr(n);for(let o of Object.values(i))if(Qd(o))return o;let r=i.serializer??i.default?.serializer??i[`${e}Serializer`];if(r&&typeof r=="object"&&"name"in r&&"serialize"in r){let o=s=>async()=>{throw new Error(`${r.name}: ${s} is not supported (raw serializer fallback)`)};return{name:r.name,serializer:r,generate:o("generate"),validate:o("validate"),coverage:o("coverage"),package:o("package")}}throw new Error(`Package ${n} does not export a LexiconPlugin or Serializer`)}function k0e(e=process.cwd()){let t=new Set,n=[Ih(h0e(import.meta.url)),g0e(e)];for(let i of n){let r=i;for(;;){let o=hQ(r,"node_modules","@intentius"),s=[];try{s=b0e(o,{withFileTypes:!0})}catch{}for(let l of s){if(!l.name.startsWith(gQ)||!l.isDirectory()&&!l.isSymbolicLink())continue;let c=l.name.slice(gQ.length);c!==""&&t.add(c)}let a=Ih(r);if(a===r)break;r=a}}return[...t].sort()}function a3(e){let t=m0e(import.meta.url),n={};for(let i of e){if(Pi(i)!==void 0)continue;let r=`@intentius/chant-lexicon-${i}`;try{let o;try{o=t.resolve(r)}catch(a){if(o=Qb(r),o===void 0)throw a}let s=Ih(o);for(let a=0;a<10;a++){let l=hQ(s,"package.json");if(y0e(l)){let u=JSON.parse(w0e(l,"utf-8"));if(u.name===r&&u.version){n[i]=u.version;break}}let c=Ih(s);if(c===s)break;s=c}}catch{}}return n}function c3(e,t,n){let i=(e??[]).filter(o=>typeof o.projectCodegen=="function").map(o=>async()=>(await fQ(o,n,t),{entities:new Map})),r=(e??[]).filter(o=>typeof o.buildRoots=="function").map(o=>s=>o.buildRoots({projectRoot:n,config:t,entities:s?.entities,...s?.sourceDir!==void 0?{sourceDir:s.sourceDir}:{}}));return[...i,...r]}function x0e(e,t){return(e??[]).filter(n=>typeof n.subscribeChanges=="function").filter(n=>(t.entities.get(n.name)?.size??0)>0).map(n=>({lexicon:n.name,subscribe:i=>n.subscribeChanges({environment:t.environment,...t.cwd?{cwd:t.cwd}:{},entities:t.entities.get(n.name),onChange:i.onChange,onError:i.onError,signal:i.signal})}))}async function x3(e){let t=[];for(let i of e){let r=await yQ(i);r.init&&await r.init(),t.push(r)}let n=oQ(t);for(let i of n.warnings)console.warn(`[chant] warning: ${i.type} "${i.key}" is provided by multiple lexicons: ${i.plugins.join(", ")}`);if(n.conflicts.length>0){let i=n.conflicts.map(sQ).join(`
|
|
251
|
+
`);throw new Error(`Cross-lexicon conflicts detected:
|
|
252
|
+
${i}`)}return t}async function $3(e,t={}){let n=t.lexicon,{config:i}=await tw(e),r;if(i.lexicons&&i.lexicons.length>0)r=Zr(i.lexicons);else{let o=await pk(e);try{r=await z9(o)}catch(s){if(n&&W9(s))return[n];throw s}}return n&&!r.includes(n)?[...r,n]:r}var gQ,up=v(()=>{"use strict";xn();nx();nx();So();Kt();iQ();HN();aQ();mQ();gQ="chant-lexicon-"});import{join as $0e}from"node:path";function R0e(e,t,n){let i=t;if(!(i!==null&&typeof i=="object"&&typeof i.language=="string"&&Array.isArray(i.extensions)&&i.extensions.length>0&&i.extensions.every(s=>typeof s=="string"&&/^\.[^./\\]+$/.test(s))&&typeof i.declarations=="function")){n.push(`lexicon "${e}" returned a symbol resolver that is not { language, extensions: [".ext", ...], declarations(path, text) }`);return}let o=i.declarations.bind(i);return{language:`${i.language} (lexicon ${e})`,extensions:[...i.extensions],declarations(s,a){let l=o(s,a);return Array.isArray(l)?l.filter(c=>c!==null&&typeof c=="object"&&typeof c.qualified=="string"&&c.qualified!==""&&typeof c.kind=="string"&&Number.isInteger(c.lines?.start)&&Number.isInteger(c.lines?.end)&&c.lines.start>=1&&c.lines.end>=c.lines.start):[]}}}async function S0e(e){let{readLexiconDeclarationsStatically:t}=await Promise.resolve().then(()=>(nx(),JZ)),n=t(e);if(n.status==="no-config")return[];if(n.status==="read"){let{registerLexiconDeclarations:o}=await Promise.resolve().then(()=>(xn(),nz)),{dirname:s}=await import("node:path");return o(n.entries,s(n.configPath)),Zr(n.entries)}let{loadChantConfig:i}=await Promise.resolve().then(()=>(Kt(),iw)),{config:r}=await i(e);return Zr(r.lexicons??[])}async function bQ(e,t){let n=[],i;try{i=await S0e(e)}catch(s){return{resolvers:[],problems:[`its chant.config could not be read: ${PM(s)}`]}}let r=t??(await Promise.resolve().then(()=>(up(),b$))).loadPlugin,o=[];for(let s of i){let a;try{a=await r(s)}catch(c){n.push(`lexicon "${s}" could not be loaded: ${PM(c)}`);continue}if(typeof a.symbolResolvers!="function")continue;let l;try{l=a.symbolResolvers()}catch(c){n.push(`lexicon "${s}" symbolResolvers() threw: ${PM(c)}`);continue}if(!Array.isArray(l)){n.push(`lexicon "${s}" symbolResolvers() did not return a list`);continue}for(let c of l){let u=R0e(s,c,n);u&&o.push(u)}}return{resolvers:o,problems:n}}var PM,wQ,vQ=v(()=>{"use strict";xn();PM=e=>(e instanceof Error?e.message:String(e)).split(`
|
|
253
|
+
`)[0];wQ=(e,t)=>t==="."?e:$0e(e,...t.split("/"))});function E0e(e){return/\.tsx$/.test(e)?be.ScriptKind.TSX:/\.jsx$/.test(e)?be.ScriptKind.JSX:/\.[cm]?js$/.test(e)?be.ScriptKind.JS:be.ScriptKind.TS}function I$(e){if(e&&(be.isIdentifier(e)||be.isPrivateIdentifier(e)||be.isStringLiteral(e)||be.isNumericLiteral(e)))return e.text}function OM(e,t=[]){let n=e.toLowerCase();return[...kQ,...t].find(i=>i.extensions.some(r=>n.endsWith(r.toLowerCase())))}function CM(e,t,n,i=[]){let r=OM(e,i);if(!r){let u=[...new Set([...kQ,...i].flatMap(d=>d.extensions))].join(", ");return{ok:!1,reason:"unsupported",message:`${e} has no symbol resolver: symbols resolve in ${u} files. Give a line range, ${e}:<start>-<end>, instead`,candidates:[]}}let o=r.declarations(e,t),s=o.filter(u=>u.qualified===n);if(s.length>0){let u=Math.min(...s.map(p=>p.lines.start)),d=Math.max(...s.map(p=>p.lines.end));return{ok:!0,declaration:{qualified:n,kind:s[0].kind,lines:{start:u,end:d}}}}let a=[...new Set(o.filter(u=>u.qualified.endsWith(`.${n}`)).map(u=>u.qualified))];if(a.length===1)return CM(e,t,a[0],i);if(a.length>1)return{ok:!1,reason:"ambiguous",message:`${n} names ${a.length} declarations in ${e}: ${a.join(", ")}. Give the qualified name`,candidates:a};let l=[...new Set(o.filter(u=>!u.qualified.includes(".")).map(u=>u.qualified))],c=l.slice(0,20);return{ok:!1,reason:"unknown",message:`${e} declares no ${n}${l.length>0?`; its top-level declarations are ${c.join(", ")}${l.length>c.length?`, and ${l.length-c.length} more`:""}`:", and no top-level declaration a resolver reads"}`,candidates:c}}var be,A0e,kQ,xQ=v(()=>{"use strict";be=Le(Ke(),1);A0e={language:"TypeScript and JavaScript",extensions:[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"],declarations(e,t){let n=be.createSourceFile(e,t,be.ScriptTarget.Latest,!0,E0e(e)),i=[],r=c=>n.getLineAndCharacterOfPosition(c).line+1,o=(c,u,d)=>{i.push({qualified:c,kind:u,lines:{start:r(d.getStart(n,!0)),end:r(d.getEnd())}})},s=(c,u)=>{for(let d of u){let p=I$(d.name);if(p===void 0){be.isConstructorDeclaration(d)&&o(`${c}.constructor`,"method",d);continue}let f=`${c}.${p}`;be.isMethodDeclaration(d)||be.isMethodSignature(d)||be.isGetAccessorDeclaration(d)||be.isSetAccessorDeclaration(d)?o(f,"method",d):be.isPropertyDeclaration(d)||be.isPropertySignature(d)?(o(f,"property",d),be.isPropertyDeclaration(d)&&d.initializer&&a(f,d.initializer)):be.isEnumMember(d)?o(f,"member",d):be.isPropertyAssignment(d)?(o(f,"property",d),a(f,d.initializer)):be.isShorthandPropertyAssignment(d)&&o(f,"property",d)}},a=(c,u)=>{let d=u;for(;be.isParenthesizedExpression(d)||be.isAsExpression(d)||be.isSatisfiesExpression(d);)d=d.expression;be.isClassExpression(d)?s(c,d.members):be.isObjectLiteralExpression(d)&&s(c,d.properties)},l=(c,u)=>{let d=p=>c?`${c}.${p}`:p;for(let p of u)if(be.isFunctionDeclaration(p)&&p.name)o(d(p.name.text),"function",p);else if(be.isClassDeclaration(p)&&p.name)o(d(p.name.text),"class",p),s(d(p.name.text),p.members);else if(be.isInterfaceDeclaration(p))o(d(p.name.text),"interface",p),s(d(p.name.text),p.members);else if(be.isTypeAliasDeclaration(p))o(d(p.name.text),"type",p);else if(be.isEnumDeclaration(p))o(d(p.name.text),"enum",p),s(d(p.name.text),p.members);else if(be.isModuleDeclaration(p)){let f=I$(p.name);if(f===void 0)continue;o(d(f),"namespace",p);let g=p.body,h=d(f);for(;g&&be.isModuleDeclaration(g);)h=`${h}.${I$(g.name)}`,g=g.body;g&&be.isModuleBlock(g)&&l(h,g.statements)}else if(be.isVariableStatement(p)){let f=p.declarationList.declarations.length===1;for(let g of p.declarationList.declarations){let h=I$(g.name);h!==void 0&&(o(d(h),"variable",f?p:g),g.initializer&&a(d(h),g.initializer))}}else be.isExportAssignment(p)&&!p.isExportEquals&&(o(d("default"),"variable",p),a(d("default"),p.expression))};return l("",n.statements),i}},kQ=[A0e]});import{execFileSync as P0e}from"node:child_process";function _M(e,t){try{return P0e("git",t,{cwd:e,encoding:"utf-8",stdio:["ignore","pipe","pipe"],maxBuffer:256*1024*1024})}catch{return}}function O0e(e,t){let n=new Map,i=[...new Set(t.filter(o=>o!==""))];if(i.length===0||_M(e,["rev-parse","--verify","--quiet",Th])===void 0)return n;let r=_M(e,["grep","-l","-F",...i.flatMap(o=>["-e",o]),Th,"--",":(glob)**/_leases/*.jsonl"]);for(let o of(r??"").split(`
|
|
254
|
+
`)){let s=o.startsWith(`${Th}:`)?o.slice(Th.length+1):"",a=s.match(/(?:^|\/)_leases\/([^/]+)\.jsonl$/);if(!a)continue;let l=_M(e,["show",`${Th}:${s}`]);for(let c of Dk(l??"").records)i.includes(c.token)&&c.item===a[1]&&!n.has(c.token)&&n.set(c.token,c.item)}return n}function T$(e,t){let n=t.map(o=>({sha:o.sha,trailers:f6(o.trailers)})),i=O0e(e,n.map(o=>o.trailers.lease).filter(o=>o!==null)),r=new Map;for(let{sha:o,trailers:s}of n)r.set(o,{trailers:s,joins:{agent:s.agent,lease:s.lease===null?null:{token:s.lease,item:i.get(s.lease)??null},run:s.run,records:s.records.map(a=>({kind:a.kind,id:a.id,node:null})),applied:s.applied}});return r}var Th,IM=v(()=>{"use strict";hl();Wv();Th="refs/heads/chant/lifecycle"});import{createHash as C0e}from"node:crypto";function TM(e){let t=e.members.filter(n=>(n.box?.services.length??0)>0);return t.length===1?{plantable:!0,box:t[0].name,reason:null}:t.length===0?{plantable:!1,box:null,reason:{code:"box-none",message:"no member's box block declares services, so there is no box to plant"}}:{plantable:!1,box:null,reason:{code:"box-several",message:`members ${t.map(n=>n.name).join(", ")} each declare box services, and a planted workspace runs one box`}}}function $Q(e,t=[]){return e===null?null:{builds:[...e.builds],check:e.check===null?null:{...e.check},checks:e.checks,builders:e.builders,tiers:e.tiers.map(n=>({...n,kinds:n.kinds===null?null:[...n.kinds]})),builderFor:_0e(e,t),publish:e.publish===null?null:{...e.publish}}}function _0e(e,t){let n=[...new Set(e.tiers.map(r=>r.tier))],i={};for(let r of e.builds){let o=t.find(a=>a.name===r)?.kind,s={};for(let a of n){let l=e.tiers.find(c=>c.tier===a&&o!==void 0&&c.kinds?.includes(o))??e.tiers.find(c=>c.tier===a&&c.kinds===null);l&&(s[a]={agent:l.agent,session:l.session})}i[r]=s}return i}function RQ(e,t){if(e===null)return null;let n=null;if(e.cover!==null){let i=t(e.cover);n={path:e.cover,sha256:i===null?null:C0e("sha256").update(i).digest("hex")}}return{published:e.published,title:e.title,line:e.line,cover:n}}function SQ(e){return t=>{try{return e.stat(t)!=="file"?null:e.bytes?e.bytes(t):new TextEncoder().encode(e.read(t))}catch{return null}}}function EQ(e,t,n=[]){return e===null||e.factory===null&&e.listing===null?null:{factory:$Q(e.factory,n),listing:RQ(e.listing,SQ(t))}}var DM=v(()=>{"use strict"});function Rp(e){let t;try{t=JSON.parse(e)}catch{return{reason:{code:"output-unreadable",message:"chant graph --format ir printed something that is not JSON"}}}if(t===null||typeof t!="object"||!Array.isArray(t.nodes)||!Array.isArray(t.edges))return{reason:{code:"output-unreadable",message:"chant graph --format ir printed JSON with no nodes and edges"}};let n=t,i=n.version;if(i===void 0)n.version=1;else if(typeof i!="number"||i>Ax)return{reason:{code:"ir-version-unsupported",message:`the member's chant printed IR version ${String(i)}, and this chant reads up to version ${Ax}`}};return n.groups??={},{ir:n,irVersion:i===void 0?null:i}}function D0e(e,t){if(typeof t!="object"||t===null||!Array.isArray(t.pipelines))return null;let n=t;return{member:e,pipelines:NM(n.pipelines).map(i=>({id:String(i.id),signal:String(i.signal),receivers:js(i.receivers),processors:js(i.processors),exporters:js(i.exporters)})),components:NM(n.components).map(i=>({id:String(i.id),kind:String(i.kind),type:String(i.type),endpoints:js(i.endpoints),protocols:js(i.protocols),pipelines:js(i.pipelines)})),exporters:NM(n.exporters).map(i=>({id:String(i.id),type:String(i.type),endpoints:js(i.endpoints),pipelines:js(i.pipelines),signals:js(i.signals)}))}}function jM(e,t){if(Array.isArray(e))return e.map(i=>jM(i,t));if(e===null||typeof e!="object")return e;let n={};for(let[i,r]of Object.entries(e))n[i]=i==="$ref"&&typeof r=="string"?Ji(t,r):jM(r,t);return n}function AQ(e,t,n){(e[t]??=[]).push(...n)}function PQ(e){let t={};for(let n of Object.keys(e).sort())t[n]=[...e[n]].sort();return t}function OQ(e,t,n){let i=[],r=[],o=[],s=[],a={},l={byLexicon:{},byComposite:{}},c={byStack:{},byContainer:{},byWave:{}},u={},d=[];for(let{member:h,ir:b}of t){if(!b)continue;let w=h.name,x=[];for(let k of b.nodes){let R={...k,id:Ji(w,k.id),member:w,attrs:jM(k.attrs??{},w)};k.compositeInstance&&(R.compositeInstance=Ji(w,k.compositeInstance)),k.runtimeOwner&&(R.runtimeOwner=Ji(w,k.runtimeOwner)),i.push(R),x.push(R.id)}a[w]=x.sort();for(let k of b.edges)r.push({...k,from:Ji(w,k.from),to:Ji(w,k.to),member:w});for(let k of["byLexicon","byComposite"])for(let[R,$]of Object.entries(b.groups[k]??{}))AQ(l[k],R,$.map(_=>Ji(w,_)));for(let k of["byStack","byContainer","byWave"])for(let[R,$]of Object.entries(b.groups[k]??{}))AQ(c[k],Ji(w,R),$.map(_=>Ji(w,_)));for(let k of b.exports??[])o.push({...k,...k.node?{node:Ji(w,k.node)}:{},member:w});for(let k of b.imports??[])s.push({...k,node:Ji(w,k.node),member:w});for(let[k,R]of Object.entries(b.derivedAttrs??{}))for(let $ of R)(u[k]??=new Set).add($);if(b.meta){let{[T0e]:k,...R}=b.meta,$=D0e(w,k);$&&d.push($),$?Object.keys(R).length>0&&(h.meta=R):h.meta=b.meta}b.pipeline&&(h.pipeline=b.pipeline)}i.sort((h,b)=>h.id.localeCompare(b.id));let p=h=>`${h.from}\0${h.to}\0${h.viaAttr??""}`;r.sort((h,b)=>p(h).localeCompare(p(b)));let f={byMember:a};for(let h of["byLexicon","byComposite"])Object.keys(l[h]).length&&(f[h]=PQ(l[h]));for(let h of["byStack","byContainer","byWave"])Object.keys(c[h]).length&&(f[h]=PQ(c[h]));let g={version:I0e,workspace:e,members:t.map(h=>h.member),nodes:i,edges:r,groups:f,exports:o,imports:s,links:n?pZ(n.declaration,{composed:t.filter(h=>h.ir).map(h=>h.member.name),collectors:d,exports:o,imports:s},n.kinds):[],collectors:d,records:[]};return Object.keys(u).length&&(g.derivedAttrs=Object.fromEntries(Object.keys(u).sort().map(h=>[h,[...u[h]].sort()]))),g}var I0e,T0e,Ji,js,NM,D$=v(()=>{"use strict";jg();ah();I0e=1,T0e="collector";Ji=(e,t)=>`${e}/${t}`,js=e=>Array.isArray(e)?e.filter(t=>typeof t=="string"):[],NM=e=>Array.isArray(e)?e.filter(t=>typeof t=="object"&&t!==null):[]});var CQ=v(()=>{"use strict"});var LM,_Q,IQ=v(()=>{"use strict";vu();_t();LM="@@chant-member-run@@ ",_Q=1});import{spawn as N0e}from"node:child_process";import{existsSync as j0e,mkdirSync as jQ,realpathSync as L0e,writeFileSync as M0e}from"node:fs";import{dirname as Nh,join as Dh,resolve as jh}from"node:path";import{fileURLToPath as F0e}from"node:url";function TQ(){return jh(Nh(F0e(import.meta.url)),"..","..","bin","chant")}function LQ(e){try{return L0e(e)}catch{return e}}function N$(){let e=process.argv[1]??"";return{command:/[\\/]cli[\\/]main\.(ts|js|mjs)$/.test(e)?[process.execPath,...process.execArgv,e]:[TQ()],identity:LQ(TQ()),source:"reader"}}function B0e(e,t,n=N$()){for(let i=e;;i=Nh(i)){let r=Dh(i,"node_modules",".bin","chant");if(j0e(r)){let o=LQ(r),s=i===t?"root":"member";return o===n.identity?{...n,source:s}:{command:[r],identity:o,source:s}}if(i===t||Nh(i)===i)break}return n}function j$(e,t,n={}){let i=n.tree??$n(t),r=Lt(i),o=ha(r,i),s=n.kinds??gV(),a=n.only?.length?new Set(n.only):void 0;if(a){let g=new Set(r.entries.map(b=>b.name)),h=[...a].filter(b=>!g.has(b));if(h.length>0)throw new ve("declaration-invalid",`--member names ${h.join(", ")}, which the declaration does not declare; it declares ${[...g].join(", ")}`)}let l=[],c=[],u=[],d=e==="build"||e==="lint";for(let g of r.entries){if(a&&!a.has(g.name))continue;if(g.type==="group"){let w=o.find(x=>x.group===g);if(!d){c.push({name:g.name,dir:null,kind:g.kind,reason:{code:"kind-not-run",message:`example groups are built and linted only; chant workspace ${e} leaves them out`}});continue}for(let x of w.matches)l.push({id:`${g.name}:${x}`,member:g.name,kind:g.kind,group:!0,dir:x,abs:Dh(t,x),exclude:[]});continue}let h=e==="graph"&&g.kind!=="chant"?s.get(g.kind):void 0;if(h?.graph&&h.packageDir){let w=R$(g,i,s);if(w){u.push({name:g.name,dir:g.dir,kind:g.kind,reason:w});continue}l.push({id:g.name,member:g.name,kind:g.kind,group:!1,dir:g.dir,abs:g.dir==="."?t:Dh(t,g.dir),exclude:[],reader:{...h.graph,packageDir:h.packageDir}});continue}if(g.kind!=="chant"){let w=g.kind==="workspace"?"a nested workspace runs its own chant workspace commands":g.kind==="design"?"a design member is data: chant reads its files for record pins and builds nothing":`chant workspace ${e} runs members of kind chant, and this one is kind ${g.kind}`;c.push({name:g.name,dir:g.dir,kind:g.kind,reason:{code:"kind-not-run",message:w}});continue}let b=R$(g,i,s);if(b){u.push({name:g.name,dir:g.dir,kind:g.kind,reason:b});continue}l.push({id:g.name,member:g.name,kind:g.kind,group:!1,dir:g.dir,abs:g.dir==="."?t:Dh(t,g.dir),exclude:g.dir==="."?rv(r,o).map(w=>w.dir):[]})}let p=n.reader??N$(),f=new Map;for(let g of l){let h=B0e(g.abs,t,p),b=f.get(h.identity)??{toolchain:h,units:[]};b.units.push(g),f.set(h.identity,b)}return{verb:e,workspace:{name:r.name,root:t,file:r.file},groups:[...f.values()],unreadable:u,skipped:c}}function DQ(e,t){return e==="graph"?"ir":e==="audit"?"json":e==="lint"?t.format==="sarif"||t.format==="json"?t.format:"stylish":t.format==="yaml"?"yaml":"json"}function MM(e,t,n){let i=e==="build"&&!n.format?[e,"."]:[e,".","--format",DQ(e,n)],r=()=>{for(let o of n.param??[])i.push("--param",o);n.paramsFile&&i.push("--params-file",jh(n.paramsFile))};return e==="build"?(n.env&&i.push("--env",n.env),r(),n.lexicon&&i.push("--lexicon",n.lexicon),n.output&&i.push("--output",G0e(n.output,t,DQ(e,n)))):e==="lint"?(r(),n.fix&&i.push("--fix")):e==="audit"?(n.tier&&i.push("--tier",n.tier),n.failOn&&i.push("--fail-on",n.failOn),n.maxFiles!==void 0&&i.push("--max-files",String(n.maxFiles))):(n.env&&(!t.reader||n.live)&&i.push("--env",n.env),n.live&&i.push("--live"),n.overlay&&i.push("--overlay"),n.traffic&&i.push("--traffic",n.traffic)),i}function G0e(e,t,n){let i=n==="yaml"?"yaml":"json";return`${jh(e,t.group?Dh(t.member,t.dir):t.member)}.${i}`}function NQ(e,t,n,i){let[r,...o]=e;return new Promise(s=>{let a=N0e(r,[...o,...t],{cwd:n,stdio:["pipe","pipe","pipe"],env:process.env}),l=[],c=[];a.stdout.on("data",u=>l.push(u)),a.stderr.on("data",u=>c.push(u)),a.on("error",u=>s({exitCode:127,stdout:"",stderr:`could not start ${r}: ${u.message}
|
|
255
|
+
`})),a.on("close",u=>s({exitCode:u??1,stdout:Buffer.concat(l).toString("utf8"),stderr:Buffer.concat(c).toString("utf8")})),a.stdin.on("error",()=>{}),a.stdin.end(i??"")})}function W0e(e){let t,n=new Map,i=[];for(let r of e.split(`
|
|
256
|
+
`)){if(!r.startsWith(LM)){r.trim()&&i.push(r);continue}let o;try{o=JSON.parse(r.slice(LM.length))}catch{continue}o.type==="header"&&!t?t=o:o.type==="result"&&t&&n.set(o.id,o)}return t?{chant:t.chant,results:n,stray:i.join(`
|
|
257
|
+
`)}:void 0}async function z0e(e,t,n,i,r){let{toolchain:o,units:s}=t,a=new Map(s.map(f=>[f.id,r?r(f):MM(e,f,i)]));for(let f of s){let g=a.get(f.id),h=g.indexOf("--output");h>=0&&jQ(Nh(g[h+1]),{recursive:!0})}let l={protocol:_Q,units:s.map(f=>({id:f.id,dir:f.abs,argv:a.get(f.id),...f.exclude.length?{exclude:f.exclude}:{}}))},c=await NQ(o.command,["workspace","member-run"],n,JSON.stringify(l)),u=new Date().toISOString(),d=W0e(c.stdout);if(d)return d.stray&&process.stderr.write(`${d.stray}
|
|
258
|
+
`),s.map(f=>{let g=d.results.get(f.id),h={unit:f,toolchain:o,chant:d.chant,mode:"member-run",id:f.id,member:f.member,dir:f.dir,exclude:f.exclude};return g?{...h,exitCode:g.exitCode,stdout:g.stdout,stderr:g.stderr,finishedAt:g.finishedAt??u}:{...h,exitCode:c.exitCode||1,stdout:"",stderr:`the member-run process for ${o.identity} ended before running this member
|
|
259
|
+
${c.stderr}`}});let p=[];for(let f of s){let g=await NQ(o.command,a.get(f.id),f.abs);p.push({unit:f,toolchain:o,chant:null,mode:"per-member",id:f.id,member:f.member,dir:f.dir,exclude:f.exclude,...g,finishedAt:new Date().toISOString()})}return p}async function FM(e,t,n){let i=await Promise.all(e.groups.map(s=>z0e(e.verb,s,e.workspace.root,t,n))),r=new Map(i.flat().map(s=>[s.id,s]));return e.groups.flatMap(s=>s.units).map(s=>r.get(s.id))}function MQ(e){let t=[`chant workspace ${e.verb} in ${e.workspace.name} (${e.workspace.root})`];for(let n of e.groups){t.push("",`${n.toolchain.identity} (${n.toolchain.source}, ${n.units.length} project${n.units.length===1?"":"s"}, one process)`);for(let i of n.units)t.push(` ${i.id}${i.group?"":` ${i.dir}`}`)}for(let n of e.unreadable)t.push("",`unreadable ${n.name}: ${n.reason.code}: ${n.reason.message}`);if(e.skipped.length){t.push("","skipped:");for(let n of e.skipped)t.push(` ${n.name} ${n.reason.code}: ${n.reason.message}`)}return t.join(`
|
|
260
|
+
`)}function FQ(e){return{verb:e.verb,workspace:e.workspace,toolchains:e.groups.map(t=>({...t.toolchain,units:t.units.map(n=>({id:n.id,member:n.member,dir:n.dir,group:n.group}))})),unreadable:e.unreadable,skipped:e.skipped}}function Lh(e,t){let n=JSON.stringify(e,null,2);t?(jQ(Nh(jh(t)),{recursive:!0}),M0e(jh(t),`${n}
|
|
261
|
+
`)):console.log(n)}function Mh(e,t,n,i,r,o){return{name:e,dir:t,kind:n,status:i,reason:r,chant:o,irVersion:null,live:!1}}var Fh=v(()=>{"use strict";Kn();Si();CQ();_t();co();rM();IQ();Zt()});import{createHash as U0e,randomBytes as H0e}from"node:crypto";import{existsSync as V0e,mkdirSync as q0e,readdirSync as BQ,readFileSync as BM,realpathSync as K0e,renameSync as J0e,rmSync as Z0e,statSync as GM,utimesSync as Y0e,writeFileSync as X0e}from"node:fs";import{homedir as Q0e}from"node:os";import{dirname as L$,join as cr,relative as eIe,resolve as WM,sep as GQ}from"node:path";function cIe(e){return!e.some(t=>iIe.some(n=>t===n||t.startsWith(`${n}=`)))}function Bh(e){return U0e("sha256").update(e).digest("hex")}function lIe(e,t){let n=new Set(t.map(s=>WM(e,s))),i=[],r=0,o=s=>{for(let a of BQ(s,{withFileTypes:!0})){let l=cr(s,a.name);if(a.isDirectory()){if(sIe.has(a.name)||a.name.startsWith(".")||n.has(l))continue;o(l)}else if(a.isFile()){let c=GM(l);i.push(`${eIe(e,l).split(GQ).join("/")}\0${c.mtimeMs}\0${c.size}`),c.mtimeMs>r&&(r=c.mtimeMs)}}};return o(e),i.sort(),{lines:i,newest:r}}function uIe(e){let t=[];for(let n=WM(e);;n=L$(n)){for(let i of aIe){let r=cr(n,i);try{let o=GM(r);o.isFile()&&t.push(`${r}\0${o.mtimeMs}\0${o.size}`)}catch{}}if(L$(n)===n)break}return t}function UM(e,t=[],n){try{let i=uIe(e);if(n)return{value:`sha256:${Bh(["at",n.commit,n.dir,...i].join(`
|
|
262
|
+
`))}`,newest:0};let{lines:r,newest:o}=lIe(e,t);return{value:`sha256:${Bh(["files",...r,"install",...i].join(`
|
|
263
|
+
`))}`,newest:o}}catch{return}}function dIe(e){let t=L$(L$(e.identity)),n="";try{n=String(JSON.parse(BM(cr(t,"package.json"),"utf-8")).version??"")}catch{}let i=e.identity.split(GQ).includes("node_modules"),r="";return!i&&V0e(cr(t,"src"))&&(r=UM(cr(t,"src"))?.value??`unstamped:${Date.now()}`),`${e.identity}\0${n}\0${r}`}function pIe(e){let t="";try{t=String(JSON.parse(BM(cr(e.packageDir,"package.json"),"utf-8")).version??"")}catch{}return JSON.stringify([e.lexicon,e.config,e.packageDir,t])}function fIe(e=process.env){let t=Object.keys(e).filter(n=>!oIe.some(i=>typeof i=="string"?i===n:i.test(n))).sort();return Bh(t.map(n=>`${n}=${e[n]??""}`).join("\0"))}function mIe(e){return Bh(JSON.stringify([zM,e.member,e.dir,e.stamp,e.toolchain,e.argv,e.env]))}function gIe(e,t=process.env){let n=t[WQ]||cr(t.XDG_CACHE_HOME||cr(Q0e(),".cache"),"chant"),i=WM(e);try{i=K0e(i)}catch{}return cr(n,"workspace-graph",Bh(i).slice(0,16))}function zQ(e,t=process.env){let n=gIe(e,t),i=r=>cr(n,`${r}.json`);return{dir:n,get(r){try{let o=JSON.parse(BM(i(r),"utf-8"));if(o.format!==zM||o.key!==r||typeof o.stdout!="string")return;let s=new Date;return Y0e(i(r),s,s),o}catch{return}},put(r){try{q0e(n,{recursive:!0});let o=cr(n,`.${r.key}.${process.pid}.${H0e(4).toString("hex")}.tmp`);X0e(o,JSON.stringify(r)),J0e(o,i(r.key)),hIe(n)}catch{}}}}function hIe(e){let t=BQ(e).filter(i=>i.endsWith(".json")&&!i.startsWith(".")).map(i=>{try{let r=GM(cr(e,i));return{path:cr(e,i),mtime:r.mtimeMs,size:r.size}}catch{return}}).filter(i=>i!==void 0).sort((i,r)=>r.mtime-i.mtime),n=0;t.forEach((i,r)=>{n+=i.size,(r>=tIe||n>nIe)&&Z0e(i.path,{force:!0})})}function UQ(e,t,n,i,r=o=>MM("graph",o,t)){let o=Date.now(),s=fIe(),a=[],l=new Map,c=new Map;for(let u of e.groups){let d=dIe(u.toolchain);for(let p of u.units){if(p.group)continue;let f=r(p);if(!cIe(f))continue;let g=p.reader?pIe(p.reader):"",h=p.dir==="."?e.workspace.root:cr(e.workspace.root,...p.dir.split("/")),b=i?{commit:i,dir:p.dir}:void 0,w=UM(h,p.exclude,b);if(!w)continue;l.set(p.id,w.value);let x=mIe({member:p.member,dir:p.dir,stamp:w.value,toolchain:`${d}\0${g}`,argv:f,env:s}),k=n.get(x);k?a.push({unit:p,toolchain:u.toolchain,chant:k.chant,mode:"member-run",id:p.id,member:p.member,dir:p.dir,exclude:p.exclude,exitCode:0,stdout:k.stdout,stderr:""}):c.set(p.id,{key:x,stamp:w,abs:h,exclude:p.exclude,...b?{at:b}:{},member:p.member})}}return{hits:a,stamps:l,pending:c,started:o}}function M$(e,t){if(t.size===0)return e;let n=e.groups.map(i=>({...i,units:i.units.filter(r=>!t.has(r.id))})).filter(i=>i.units.length>0);return{...e,groups:n}}function HQ(e,t,n){for(let i of t){let r=e.pending.get(i.id);if(!r||i.exitCode!==0||"reason"in Rp(i.stdout)||!r.at&&r.stamp.newest>e.started-rIe)continue;let o=UM(r.abs,r.exclude,r.at);!o||o.value!==r.stamp.value||n.put({format:zM,key:r.key,member:r.member,stamp:r.stamp.value,chant:i.chant,stdout:i.stdout})}}var zM,WQ,tIe,nIe,rIe,iIe,oIe,sIe,aIe,VQ=v(()=>{"use strict";D$();Fh();zM=1,WQ="CHANT_CACHE_DIR",tIe=512,nIe=128*1024*1024,rIe=2e3,iIe=["--live","--overlay","--traffic"],oIe=["_","PWD","OLDPWD","SHLVL","COLUMNS","LINES","WINDOWID",/^TERM/,/^ITERM_/,/^TMUX/,/^SSH_/,/^VSCODE_/,/^npm_/,/^VITEST/,/^__/,WQ],sIe=new Set(["node_modules","dist",".git"]),aIe=[cr("node_modules",".package-lock.json"),"package-lock.json","npm-shrinkwrap.json","yarn.lock","pnpm-lock.yaml","bun.lock","bun.lockb"]});import{mkdirSync as yIe,mkdtempSync as bIe,realpathSync as wIe,rmSync as vIe,symlinkSync as kIe,writeFileSync as xIe}from"node:fs";import{tmpdir as $Ie}from"node:os";import{join as Gh}from"node:path";function RIe(e,t){let n=e;for(let i=0;i<t.split("/").length;i++)n=Gh(n,"..");return n}function HM(e){try{return wIe(e)}catch{return e}}function SIe(e,t){let n=e.reader,i=Xw(n.lexicon),r=ia(i,t);return r?HM(r)!==HM(n.packageDir)?{message:`kind ${e.kind} comes from ${n.packageDir}, and the ${i} found from ${t} is ${HM(r)}; install the pinned package where the workspace resolves it`}:{modules:RIe(r,i)}:{message:`kind ${e.kind} is read by the ${n.lexicon} lexicon, and ${i} is not installed in a node_modules at or above ${t}; install it there to read this member`}}function qQ(e,t){let n=[],i,r=()=>{i&&vIe(i,{recursive:!0,force:!0}),i=void 0};try{for(let o of e.groups)o.units=o.units.filter(s=>{if(!s.reader)return!0;let a=SIe(s,t);if("message"in a)return n.push({name:s.member,dir:s.dir,kind:s.kind,reason:{code:"command-failed",message:a.message}}),!1;i??=bIe(Gh($Ie(),"chant-ws-reader-"));let l=Gh(i,s.id);yIe(l,{recursive:!0});let c=bV(s.reader.config,{member:s.member,dir:s.abs,workspace:t});return xIe(Gh(l,"chant.config.json"),`${JSON.stringify({lexicons:[s.reader.lexicon],[s.reader.lexicon]:c},null,2)}
|
|
264
|
+
`),kIe(a.modules,Gh(l,"node_modules"),"dir"),s.abs=l,!0});e.groups=e.groups.filter(o=>o.units.length>0)}catch(o){throw r(),o}return e.unreadable.push(...n),{failed:n,cleanup:r}}var KQ=v(()=>{"use strict";co()});var YQ={};_e(YQ,{foldNested:()=>OIe,nestedArgv:()=>JQ,readNested:()=>PIe,readNestedDocument:()=>ZQ});import{spawn as EIe}from"node:child_process";function JQ(e,t,n){return["workspace","graph",e,...n?["--at",n]:[],...t.env?["--env",t.env]:[],...t.live?["--live"]:[],...t.overlay?["--overlay"]:[],...t.traffic!==void 0?["--traffic",String(t.traffic)]:[],...t.noCache?["--no-cache"]:[]]}function AIe(e,t,n){let[i,...r]=e;return new Promise(o=>{let s=EIe(i,[...r,...t],{cwd:n,stdio:["ignore","pipe","pipe"],env:process.env}),a=[],l=[];s.stdout.on("data",c=>a.push(c)),s.stderr.on("data",c=>l.push(c)),s.on("error",c=>o({exitCode:127,stdout:"",stderr:`could not start ${i}: ${c.message}
|
|
265
|
+
`})),s.on("close",c=>o({exitCode:c??1,stdout:Buffer.concat(a).toString("utf8"),stderr:Buffer.concat(l).toString("utf8")}))})}function ZQ(e,t,n,i,r){let o;try{o=JSON.parse(e)}catch{let l=n.trim().split(`
|
|
266
|
+
`).slice(-5).join(`
|
|
267
|
+
`);return{ok:!1,chant:null,code:t===0?"output-unreadable":"command-failed",message:`the nested chant workspace graph exited ${t} and printed no document${l?`: ${l}`:""}`}}let s=o,a=typeof s.chant=="string"?s.chant:null;if(s.$schema!==i||typeof s.contract!="number")return{ok:!1,chant:a,code:"output-unreadable",message:"the nested chant workspace graph printed something that is not a workspace graph document"};if(s.contract>r)return{ok:!1,chant:a,code:"ir-version-unsupported",message:`the nested workspace's chant printed graph contract ${s.contract}, and this chant reads up to ${r}`};if(s.error&&typeof s.error=="object"){let l=s.error;return{ok:!1,chant:a,code:"command-failed",message:`the nested workspace could not be read: ${String(l.code)}: ${String(l.message)}`}}return!Array.isArray(s.nodes)||!Array.isArray(s.edges)||!Array.isArray(s.members)?{ok:!1,chant:a,code:"output-unreadable",message:"the nested workspace graph has no nodes, edges and members"}:{ok:!0,chant:a,doc:s}}async function PIe(e,t,n,i,r,o=void 0){let s=await AIe((o??N$()).command,JQ(e,t,n),e);return{...ZQ(s.stdout,s.exitCode,s.stderr,i,r),stderr:s.stderr}}function VM(e,t){if(Array.isArray(e))return e.map(i=>VM(i,t));if(e===null||typeof e!="object")return e;let n={};for(let[i,r]of Object.entries(e))n[i]=i==="$ref"&&typeof r=="string"?vi(t,r):VM(r,t);return n}function OIe(e,t,n){let i=t.name,r=new Map(n.members.map(c=>[c.name,c.dir])),o=[];for(let c of n.nodes){let u={...c,id:vi(i,c.id),member:i,nested:c.member,attrs:VM(c.attrs??{},i)};c.compositeInstance&&(u.compositeInstance=vi(i,c.compositeInstance)),c.runtimeOwner&&(u.runtimeOwner=vi(i,c.runtimeOwner)),c.compositeParent&&(u.compositeParent=c.compositeParent);let d=r.get(c.member);c.sourceLoc&&d&&d!=="."&&(u.sourceLoc={...c.sourceLoc,file:`${d}/${c.sourceLoc.file}`}),e.nodes.push(u),o.push(u.id)}for(let c of n.edges)e.edges.push({...c,from:vi(i,c.from),to:vi(i,c.to),member:i});for(let c of n.exports??[])e.exports.push({...c,...c.node?{node:vi(i,c.node)}:{},member:i});for(let c of n.imports??[])e.imports.push({...c,node:vi(i,c.node),member:i});e.groups.byMember[i]=o.sort();let s=e.groups,a=n.groups;for(let c of["byLexicon","byComposite"])for(let[u,d]of Object.entries(a[c]??{})){let p=s[c]??={};p[u]=[...p[u]??[],...d.map(f=>vi(i,f))].sort()}for(let c of["byStack","byContainer","byWave"])for(let[u,d]of Object.entries(a[c]??{})){let p=s[c]??={};p[vi(i,u)]=d.map(f=>vi(i,f)).sort()}for(let c of n.collectors??[])e.collectors.push({...c,member:vi(i,c.member)});for(let[c,u]of Object.entries(n.derivedAttrs??{})){let d=new Set([...e.derivedAttrs?.[c]??[],...u]);e.derivedAttrs={...e.derivedAttrs??{},[c]:[...d].sort()}}e.nodes.sort((c,u)=>c.id.localeCompare(u.id));let l=c=>`${c.from}\0${c.to}\0${c.viaAttr??""}`;e.edges.sort((c,u)=>l(c).localeCompare(l(u))),t.status="composed",t.reason=null,t.nested={name:n.workspace.name,contract:n.contract,members:n.members,links:n.links??[]}}var vi,XQ=v(()=>{"use strict";Fh();vi=(e,t)=>`${e}/${t}`});import{join as CIe}from"node:path";async function _Ie(e,t){let n=[],i,r;try{let{loadChantConfig:a}=await Promise.resolve().then(()=>(Kt(),iw)),{config:l}=await a(e);i=Zr(l.lexicons??[]),r=l.environments??[]}catch(a){return{lexicons:[],default:Go,reasons:[{code:"runtimes-config-unreadable",message:`chant.config.ts: ${QQ(a)}`}],environments:null}}let o=t??(await Promise.resolve().then(()=>(up(),b$))).loadPlugin,s=[];for(let a of i)try{(await o(a)).opRuntime?.runComponents&&s.push(a)}catch(l){n.push({code:"runtimes-lexicon-unreadable",message:`lexicon "${a}": ${QQ(l)}`})}return{lexicons:s,default:Go,reasons:n,environments:r}}function tee(e,t){let n=t?.default??Go,i=(r,o)=>({name:r,lexicon:o,default:r===n,command:`chant run --components ${e}${r===Go?"":` --on ${r}`}`});return[i(Go,null),...(t?.lexicons??[]).filter(r=>r!==Go).map(r=>i(r,r))]}async function nee(e,t,n){let i=new Map;for(let r of t)r.kind==="chant"&&i.set(r.name,await _Ie(r.dir==="."?e:CIe(e,...r.dir.split("/")),n));return i}var Go,eee,QQ,qM=v(()=>{"use strict";xn();Go="local",eee=["runtimes-config-unreadable","runtimes-lexicon-unreadable"],QQ=e=>(e instanceof Error?e.message:String(e)).split(`
|
|
268
|
+
`)[0]});var ree=v(()=>{"use strict";Wt();$t()});var Bht,Ght,iee=v(()=>{"use strict";hl();_t();nl();Zt();ci();gs();Bht=[...lo],Ght=[...lo,"write-usage-invalid","wip-no-branch","wip-none","wip-snapshot-unknown","wip-branch-other","wip-race","wip-policy-none","wip-remote-unknown",...tl]});var oee=v(()=>{"use strict";_t();nd()});var see=v(()=>{"use strict";zd();po();Zt()});var KM=v(()=>{"use strict";On();Mi();Gi()});import{execFile as IIe}from"node:child_process";import{promisify as TIe}from"node:util";var syt,aee=v(()=>{"use strict";Qh();Wi();ul();syt=TIe(IIe)});var cee=v(()=>{"use strict";ul();Nl();s$();Yd();$t();ya();hl();hp();aee();bp();KM()});var Sp,JM,lee,uee=v(()=>{"use strict";Kn();Mi();$t();$h();ree();hl();QT();iee();Si();oee();see();co();DM();_t();nl();gs();KM();cee();Zt();ci();Sp="chant/lifecycle",JM="_members",lee=/^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/});import{execFileSync as DIe}from"node:child_process";function ZM(e,t,n){return DIe("git",t,{cwd:e,encoding:"utf-8",input:n,stdio:[n===void 0?"ignore":"pipe","pipe","pipe"]})}function dee(e,t){try{return ZM(e,["rev-parse","--verify","--quiet",t]),!0}catch{return!1}}function mee(e,t){let n=[],i=e?.environments??null;if(e&&i===null){let u=e.reasons.find(d=>d.code==="runtimes-config-unreadable");n.push({code:"runtimes-config-unreadable",message:u?.message??"chant.config.ts could not be read"})}else i&&i.length===0&&n.push({code:"environments-none-declared",message:"chant.config.ts declares no environments, so only local and the environments in the ledger are listed"});t?.reason&&n.push(t.reason);let r=(i??[]).map(xc).filter(u=>!Sf(u)),o=t?.envs??[],s=u=>!i||i.length===0||Ef(i,u),a=o.filter(u=>u!==Ep&&!s(u));a.length>0&&n.push({code:"environments-ledger-undeclared",message:`the ledger has releases in ${a.join(", ")}, which chant.config.ts's environments don't cover, so chant run --env refuses ${a.length===1?"it":"them"}`});let l=[],c=(u,d)=>{l.some(p=>p.name===u)||l.push({name:u,default:u===Ep,source:d})};c(Ep,r.includes(Ep)?"config":o.includes(Ep)?"ledger":"builtin");for(let u of r)c(u,"config");for(let u of o)s(u)&&c(u,"ledger");return{environments:l,reasons:n,declared:i}}function gee(e,t,n=Go,i=[],r=[],o=[]){let s=[...t?.environments??[{name:Ep,default:!0,source:"builtin"}]],a=t?.declared,l=u=>!a||a.length===0||Ef(a,u),c=new Map;for(let u of i)c.set(u.name,{runtime:u.runtime??null,url:u.url??null,domain:u.domain??null,lifecycle:u.lifecycle??null}),!s.some(d=>d.name===u.name)&&(l(u.name)?s.push({name:u.name,default:!1,source:"component"}):o.push({code:"environments-component-undeclared",message:`component ${e} declares environment ${u.name}, which chant.config.ts's environments don't cover, so chant run --env refuses it`}));return s.map(u=>{let d=c.get(u.name)??null,p=d?.runtime&&(d.runtime===Go||r.includes(d.runtime))?d.runtime:n;return{...u,site:d,command:`chant run --components ${e}${p===Go?"":` --on ${p}`}${u.default?"":` --env ${u.name}`}`}})}var Ep,pee,fee,hee=v(()=>{"use strict";Kt();qM();uee();Ep="local",pee=["runtimes-config-unreadable","environments-none-declared","environments-ledger-undeclared","environments-ledger-unreadable","environments-component-undeclared"];fee=(e,t)=>{if(!dee(t,`refs/heads/${Sp}`))return{envs:[],reason:null};let i=e.dir!=="."&&dee(t,`refs/heads/${Sp}:${JM}/${e.name}`)?`${JM}/${e.name}/`:"";try{let r=ZM(t,["ls-tree","--full-tree",`refs/heads/${Sp}:${i}`]).split(`
|
|
269
|
+
`).map(s=>s.match(/^\d+ tree [0-9a-f]+\t(.+)$/)?.[1]).filter(s=>!!s&&lee.test(s));if(r.length===0)return{envs:[],reason:null};let o=ZM(t,["cat-file","--batch-check"],r.map(s=>`refs/heads/${Sp}:${i}${s}/releases.jsonl
|
|
270
|
+
`).join("")).split(`
|
|
271
|
+
`).filter(Boolean);return{envs:r.filter((s,a)=>o[a]!==void 0&&!o[a].endsWith(" missing")).sort(),reason:null}}catch(r){let o=(r instanceof Error?r.message:String(r)).split(`
|
|
272
|
+
`)[0];return{envs:[],reason:{code:"environments-ledger-unreadable",message:`${Sp}:${i||"."}: ${o}`}}}}});var xee={};_e(xee,{COMPOSITES_CONTRACT_VERSION:()=>bee,COMPOSITES_ENVIRONMENT_REASON_CODES:()=>MIe,COMPOSITES_ERROR_CODES:()=>NIe,COMPOSITES_OUTPUT_SCHEMA_ID:()=>yee,COMPOSITES_REASON_CODES:()=>jIe,COMPOSITES_RUNTIME_REASON_CODES:()=>LIe,compositeInstances:()=>wee,joinComponents:()=>vee,runWorkspaceComposites:()=>WIe,workspaceComposites:()=>kee});function FIe(e,t,n,i,r){if(n.exitCode!==0){let a=n.stderr.trim().split(`
|
|
273
|
+
`).slice(-5).join(`
|
|
274
|
+
`);return{reason:{code:"command-failed",message:`chant graph --components exited ${n.exitCode}${a?`: ${a}`:""}`}}}let o=Rp(n.stdout);if("reason"in o)return{reason:{...o.reason,message:`chant graph --components: ${o.reason.message}`}};let s=[];for(let a of o.ir.nodes){if(a.kind!=="Component")continue;let l=a.attrs??{},c=Array.isArray(l.composites)?l.composites.filter(d=>typeof d=="string"):null,u=a.sourceLoc?.file;s.push({id:`${e}/${a.id}`,name:a.id,member:e,archetype:typeof l.archetype=="string"?l.archetype:null,composites:c&&c.length>0?c:null,file:u?t==="."?u:`${t}/${u}`:null,runtimes:tee(a.id,i),environments:gee(a.id,r,i?.default,BIe(l.environments),i?.lexicons??[],r?.reasons??[])})}return{components:s}}function BIe(e){if(!Array.isArray(e))return[];let t=n=>typeof n=="string"&&n.length>0?n:void 0;return e.filter(n=>n!==null&&typeof n=="object"&&typeof n.name=="string").map(n=>({name:n.name,runtime:t(n.runtime),url:t(n.url),domain:t(n.domain),lifecycle:t(n.lifecycle)}))}function wee(e){let t=new Map;for(let n of e.nodes){if(!n.compositeInstance)continue;let i=t.get(n.compositeInstance)??{member:n.member,kinds:new Set,lexicons:new Set,nodes:[]};n.compositeParent&&i.kinds.add(n.compositeParent),i.lexicons.add(n.lexicon),i.nodes.push(n.id),t.set(n.compositeInstance,i)}return[...t.entries()].sort(([n],[i])=>n.localeCompare(i)).map(([n,i])=>({id:n,member:i.member,instance:n.slice(i.member.length+1),kinds:[...i.kinds].sort(),lexicons:[...i.lexicons].sort(),nodes:i.nodes.sort(),components:[]}))}function vee(e,t,n){let i=new Set;for(let o of n)"consumer"in o&&"producer"in o&&o.status==="resolved"&&i.add(`${o.consumer}\0${o.producer}`);let r=(o,s)=>o.member===s.member?"member":i.has(`${o.member}\0${s.member}`)?"link":"unlinked";return e.map(o=>{let s=[];for(let a of t){if(a.composites){let c=o.kinds.find(u=>a.composites.includes(u));c&&s.push({component:a.id,by:"composites",against:"kind",value:c,label:"exact",via:r(a,o)});continue}let l;for(let c of o.kinds){let u=Ng(a.name,c);u&&(!l||u==="exact"&&l.label!=="exact")&&(l={by:"name",against:"kind",value:c,label:u})}if(!l){let c=Ng(a.name,o.instance);c&&(l={by:"name",against:"instance",value:o.instance,label:c})}l&&s.push({component:a.id,...l,via:r(a,o)})}return s.sort((a,l)=>a.component.localeCompare(l.component)),{...o,components:s}})}function GIe(e,t,n,i){let r=e.reason??t,o=e.status==="composed"?t?"failed":"read":e.status;return{name:e.name,dir:e.dir,kind:e.kind,status:o,reason:r,chant:e.chant,runtimeReasons:n?.reasons??[],environmentReasons:i?.reasons??[]}}async function kee(e){let t={$schema:yee,contract:bee,chant:Xt()},n=new Map,{loadPlugin:i,readLedgerEnvironments:r=fee,...o}=e,{doc:s,failed:a,components:l}=await F$({...o,...o.args?{args:{...o.args,live:!1,overlay:!1,traffic:void 0}}:{},components:!0,inTree:async(w,x)=>{n=await nee(w,x,i)}});if("error"in s)return{doc:{...t,error:{...s.error,code:s.error.code}},failed:!0};let c=new Map((l??[]).map(w=>[w.unit.member,w])),u=[],d=[],p=!1;for(let w of s.members){let x=w.status==="composed"?c.get(w.name):void 0,k=n.get(w.name),R=k?mee(k,r(w,e.cwd)):void 0,$=null;if(x){let _=FIe(w.name,w.dir,x,k,R);"reason"in _?($=_.reason,p=!0):d.push(..._.components)}u.push(GIe(w,$,k,R))}d.sort((w,x)=>w.id.localeCompare(x.id));let f=vee(wee(s),d,s.links),g=u.filter(w=>w.status==="read"),h=[];if(!u.some(w=>w.kind==="chant"&&w.status!=="skipped"))h.push({code:"composites-no-chant-member",message:"no member of kind chant was read, so nothing declares a composite or a component"});else if(g.length>0){let w=g.map(x=>x.name).join(", ");f.length===0&&h.push({code:"composites-none-declared",message:`the members read (${w}) declare no composite instance`}),d.length===0&&h.push({code:"composites-no-component",message:`the members read (${w}) declare no component in a *.component.ts file`})}let b=f.filter(w=>w.components.length>0).length;return{doc:{...t,at:s.at,workspace:s.workspace,members:u,composites:f,components:d,reasons:h,summary:{composites:f.length,withComponent:b,withoutComponent:f.length-b,components:d.length}},failed:a||p}}async function WIe(e,t){let{args:n}=e,{doc:i,failed:r}=await kee({cwd:t,at:n.at,members:n.members,args:n,onStderr:o=>process.stderr.write(o)});if(Lh(i,n.output),"error"in i){let o=i.error.location;console.error(fe({message:`${i.error.code}: ${o?`${o.file}:${o.line}:${o.column}: `:""}${i.error.message}`}))}return r?1:0}var yee,bee,NIe,jIe,LIe,MIe,$ee=v(()=>{"use strict";Kn();DD();D$();YM();Fh();_t();hee();qM();yee="https://intentius.io/chant/schemas/workspace/composites/v1/composites.schema.json",bee=1,NIe=lo,jIe=["composites-no-chant-member","composites-none-declared","composites-no-component"],LIe=eee,MIe=pee});async function Ree(e){let t={$schema:UIe,contract:zIe,chant:Xt()};try{return await VIe(e,t)}catch(n){if(n instanceof tn||n instanceof ve||n instanceof Ve)return{doc:{...t,error:{code:n.code,message:n.message}},failed:!0};throw n}}async function VIe(e,t){let n=Qt(e.cwd,e.at),i=n.top;if(!i)throw new tn("not-a-git-repository","the intent walk reads git history, and this directory is not in a git repository");let r=Lt(n.tree,"",{rootChant:!0}),o=e.kinds??Ni(r).map(W=>Ma(W,n.rootOnDisk)),s=await W$({cwd:e.cwd,region:"",at:e.at,kinds:o},i),a=n.root==="."?"":n.root,l=W=>W.records.workspaceRoot==="."?"":W.records.workspaceRoot,c=W=>a===""?W:W.startsWith(`${a}/`)?W.slice(a.length+1):W===a?".":W,u=e.record.indexOf("/"),[d,p]=u>0?[e.record.slice(0,u),e.record.slice(u+1)]:[null,e.record],f=s.filter(W=>W.records&&!W.records.loaded.kind.work),g=f.filter(W=>d===null||W.records.loaded.kind.name===d).flatMap(W=>W.records.views.filter(de=>de.id===p).map(de=>({kind:W,view:de})))[0];if(!g){let W=f.map(de=>de.records.loaded.kind.name);throw new tn("intent-record-unknown",`no record of ${W.length>0?`the decision kinds read (${W.join(", ")})`:"a decision kind: none was read"} has the id ${e.record}`)}let h=g.kind.records.loaded.kind,b=g.view,w=n.at??(Dn(i,["rev-parse","--verify","--quiet","HEAD^{commit}"])?.trim()||null),x=Dn(i,["rev-parse","--is-shallow-repository"])?.trim()==="true",k=[];x&&k.push({code:"intent-history-shallow",message:"this is a shallow clone, so the history stops at its boundary and the oldest commit listed may stand for many"});let R=[],$=[],_=[],T=new Map,C=h.constrains?.field?b.data?.[h.constrains.field]:void 0;for(let W of Array.isArray(C)?C:[])if(typeof W=="string")if(W.startsWith("path:")){let de=W.slice(5);if(!_n(de)){R.push({entry:W,granularity:"path",path:null,exists:null,walked:!1});continue}let Oe=ze(l(g.kind),de),pt=n.tree.stat(c(Oe));if(R.push({entry:W,granularity:"path",path:c(Oe),exists:pt!==void 0,walked:w!==null}),$.push({entry:W,full:Oe}),!w)continue;for(let et of B$(i,w,Oe,pt==="file"?"file":"dir",null))(T.get(et.sha)??T.set(et.sha,[]).get(et.sha)).push(W)}else if(W.startsWith("member:")){let de=W.slice(7),Oe=r.members.find(Tt=>Tt.name===de);if(R.push({entry:W,granularity:"member",path:Oe?Oe.dir:null,exists:!!Oe,walked:!!Oe&&w!==null}),!Oe||(_.push({entry:W,name:de}),!w))continue;let pt=ze(a,Oe.dir),et=r.members.filter(Tt=>Tt.name!==Oe.name&&Tt.dir!==Oe.dir&&(Oe.dir==="."||Tt.dir.startsWith(`${Oe.dir}/`))).map(Tt=>`:(exclude)${ze(a,Tt.dir)}`),Ut=Dn(i,["log","--format=%H",w,"--",pt===""?".":pt,...et]);for(let Tt of(Ut??"").split(`
|
|
275
|
+
`).map(wt=>wt.trim()).filter(Boolean))(T.get(Tt)??T.set(Tt,[]).get(Tt)).push(W)}else R.push({entry:W,granularity:/^[^/\s]+\/[^/\s]+#[0-9]+$/.test(W)?"issue":"contract",path:null,exists:null,walked:!1});let K=new Map;for(let W of f)for(let de of W.records.views)de.id!==null&&K.set(`${W.records.loaded.kind.name}/${de.id}`,{kind:W,view:de});let O=(W,de)=>{let Oe=w?Pp(i,w,de):null,pt=de.supersededBy?K.get(`${W.records.loaded.kind.name}/${de.supersededBy}`):void 0,et=w&&pt?Pp(i,w,pt.view):null;return{from:Oe,until:et,fromSet:Oe&&w?Wo(i,Oe,w):new Set,untilSet:et&&w?Wo(i,et,w):null}},pe=(W,de)=>W.fromSet.has(de)&&!W.untilSet?.has(de),F=O(g.kind,b),Q=[...T.keys()].filter(W=>pe(F,W)),I=Ap(i,Q),B=e.followSquash?Fg(i,[...I.values()],{fetchMissing:!0}):new Map;for(let W of B.values())W.problem&&k.push({code:"squash-unfollowed",message:`${W.sha.slice(0,8)} squashes pull request #${W.pullRequest}, and ${W.problem}, so its original commits are not followed`});let Z=Ap(i,[...new Set([...B.values()].flatMap(W=>W.commits))]),xe=W=>(B.get(W)?.commits??[]).map(de=>Z.get(de)).filter(de=>de!==void 0),we=(Q.length>0?Dn(i,["rev-list","--no-walk=sorted","--stdin"],`${Q.join(`
|
|
276
|
+
`)}
|
|
277
|
+
`):"")?.split(`
|
|
278
|
+
`).map(W=>W.trim()).filter(Boolean)??Q;Q.sort((W,de)=>we.indexOf(W)-we.indexOf(de));let Ct=W=>$.some(de=>ls(de.full,W))||_.some(de=>Fr(c(W),r.members)===de.name),at=new Map;if(Q.length>0){let W=Dn(i,["log","--no-walk=unsorted","--stdin","--format=%x00%H","--name-only","--no-renames","--diff-merges=first-parent"],`${Q.join(`
|
|
279
|
+
`)}
|
|
280
|
+
`)??"";for(let de of W.split("\0")){if(!de)continue;let[Oe,...pt]=de.split(`
|
|
281
|
+
`).map(et=>et.trim());at.set(Oe,[...new Set(pt.filter(et=>et!==""&&Ct(et)))].map(c))}}let $e=(W,de)=>{let Oe=W.records.loaded.kind.constrains?.field,pt=Oe?de.data?.[Oe]:void 0;return(Array.isArray(pt)?pt:[]).filter(et=>typeof et=="string"&&et.startsWith("path:")&&_n(et.slice(5))).map(et=>ze(l(W),et.slice(5)))},Te=[...new Set([...at.values()].flat())].map(W=>ze(a,W)),nt=[];for(let[,W]of K){if(W.view===b)continue;let de=$e(W.kind,W.view);de.some(Oe=>Te.some(pt=>ls(Oe,pt)))&&nt.push({ref:{recordKind:W.kind.records.loaded.kind.name,record:W.view.id,state:W.view.state},paths:de,window:O(W.kind,W.view)})}let St=[];for(let W of s.filter(de=>de.records?.loaded.kind.work)){let de=W.records.loaded.kind;for(let Oe of W.records.views){if(Oe.id===null||Oe.state!==null&&Oe.state!==de.work.done&&(de.closedStates??[]).includes(Oe.state))continue;let et=Sr(Oe.data,de.work.implements).includes(b.id),Ut=$e(W,Oe);if(!et&&!Ut.some(Pr=>Te.some(Or=>ls(Pr,Or))))continue;let Tt=w?Wh(i,w,Oe.path):null,wt=w&&de.stateField?G$(i,w,Oe.path,de.stateField,de.closedStates??[]):null,qn=wt&&w?Wo(i,wt,w):null;wt&&qn.delete(wt),St.push({ref:{recordKind:de.name,record:Oe.id,state:Oe.state},paths:Ut,implementsRecord:et,window:{fromSet:Tt&&w?Wo(i,Tt,w):new Set,untilSet:qn}})}}let Ee=W=>_n(W)&&n.tree.stat(W)==="file"?n.tree.read(W):void 0,zt=W=>{let de=W==="."?"":W.replace(/\/+$/,"");if(!(de!==""&&(!_n(de)||n.tree.stat(de)!=="dir")))return n.tree.list(de)?.map(Oe=>`${ze(de,Oe.name)}${Oe.type==="dir"?"/":""}`).sort()},Vn=new Set,ne=R.filter(W=>W.granularity==="contract").map(W=>W.entry),Re=[],X=T$(i,[...I.values(),...Z.values()]),Ce=new Map(s.filter(W=>W.records).map(W=>[W.records.loaded.kind.name,W])),tt=s.filter(W=>W.records?.loaded.kind.work),gt=await Bk(i,n.rootOnDisk,[...new Set([...Q,...Z.keys()])].map(W=>({sha:W,run:X.get(W)?.joins.run??null})));Gk(gt.refs,B);let Je=(W,de)=>{let Oe=W.records.views.find(pt=>pt.id===de);return Oe?Sr(Oe.data,W.records.loaded.kind.work.implements).includes(b.id):void 0};for(let W of Q){let de=I.get(W);if(!de)continue;let Oe=null,pt=!1,et=X.get(W).joins,Ut=xe(W);for(let y of[et,...Ut.map(N=>X.get(N.sha).joins)]){for(let q of y.records){let Y=Ce.get(q.kind);!Y||!Y.records.views.some(z=>z.id===q.id)||(q.node=`record:${q.kind}/${q.id}`,(Y.records.loaded.kind.work?Je(Y,q.id):q.kind===h.name&&q.id===b.id)&&(pt=!0))}let N=y.lease?.item;if(N){let q=tt.filter(Y=>Y.records.views.some(z=>z.id===N));q.length===1&&Je(q[0],N)&&(pt=!0)}}let Tt=[de,...Ut];for(let y of s)if(y.joins)for(let N of Tt){let q;try{q=await Bv(y.joins,N,{read:Ee,list:zt,at:n.at},y.name)}catch(z){let E=`${y.display}: commitJoins failed for ${N.sha.slice(0,8)}: ${z instanceof Error?z.message:String(z)}`;Vn.has(E)||k.push({code:"intent-plugin-failed",message:E}),Vn.add(E);continue}if(!q.unit)continue;Oe??=q.unit.id,[...Nd(q.unit),...Nd(q.contract)].some(z=>z===b.id||z===`${h.name}/${b.id}`)&&(pt=!0),q.contract&&ne.includes(q.contract.id)&&(pt=!0)}let wt=B.get(W),qn=(at.get(W)??[]).map(y=>ze(a,y)),Pr=y=>y.some(N=>qn.some(q=>ls(N,q))),Or=St.filter(y=>pe(y.window,W)&&(y.implementsRecord||Pr(y.paths))).map(y=>y.ref),ki=nt.filter(y=>pe(y.window,W)&&Pr(y.paths)).map(y=>y.ref),Vo=de.subject.match(/\(#([0-9]+)\)\s*$/);Re.push({sha:W,subject:de.subject,author:de.author,date:de.date,trailers:de.trailers,pullRequest:Vo?Number(Vo[1]):null,unit:Oe,joins:et,runs:gt.refs.get(W)??[],...wt?{squash:{pullRequest:wt.pullRequest,forge:wt.forge,ref:wt.ref,head:wt.head,fetched:wt.fetched,followed:wt.followed,commits:Ut.map(y=>({sha:y.sha,subject:y.subject,author:y.author,date:y.date,trailers:y.trailers,joins:X.get(y.sha).joins}))}}:{},entries:T.get(W),files:at.get(W)??[],bucket:pt?"own":Or.length>0?"worked":ki.length>0?"within-other":"unexplained",workedBy:Or,alsoWithin:ki})}let Bt=W=>Re.filter(de=>de.bucket===W).length;return{doc:{...t,at:n.at,workspace:{name:r.name,root:n.root},record:{id:`record:${h.name}/${b.id}`,recordKind:h.name,record:b.id,path:b.path,title:HIe(b.data?.title),state:b.state,supersededBy:b.supersededBy,decidedIn:b.decidedIn??null,constrains:R},history:{rev:w,shallow:x},window:{from:F.from,until:F.until},kinds:s.map(W=>({file:W.display,name:W.name,records:W.records?.loaded.kind.name??null,joins:W.joins?.form??null})),commits:Re,counts:{commits:Re.length,own:Bt("own"),worked:Bt("worked"),withinOther:Bt("within-other"),unexplained:Bt("unexplained"),outsideWindow:T.size-Q.length},reasons:k},failed:k.some(W=>W.code==="intent-plugin-failed")}}var zIe,UIe,HIe,See=v(()=>{"use strict";_t();zd();Gv();z$();po();mn();WD();Fk();IM();Zt();ci();xd();zIe=1,UIe="https://intentius.io/chant/schemas/workspace/intent-record/v1/intent-record.schema.json",HIe=e=>typeof e=="string"?e:null});var Tee={};_e(Tee,{IN_WINDOW_QUESTION:()=>Oee,formatIntent:()=>_ee,formatIntentRecord:()=>Iee,runWorkspaceIntent:()=>eTe,whyLines:()=>Cee});import{resolve as Aee}from"node:path";function zh(e,t,n){return e.edges.filter(i=>i.from===t&&i.kind===n)}function oc(e,t){return e.nodes.filter(n=>n.kind===t)}function qIe(e,t){let n=e.edges.filter(r=>r.kind==="within"&&r.to===t.id),i=[];for(let r of n){let o=e.nodes.find(d=>d.kind==="commit"&&d.id===r.from);if(!o)continue;let s=zh(e,o.id,"produced-by").map(d=>e.nodes.find(p=>p.id===d.to)).map(d=>d&&"ref"in d?d.ref:void 0).filter(Boolean),a=(o.joins?.records??[]).filter(d=>d.node!==null).map(d=>`${d.kind}:${d.id}`),l=o.joins?.lease?.item;l&&!a.some(d=>d.endsWith(`:${l}`))&&a.push(`lease on ${l}`);let c=s.length>0?`unit ${s.join(", ")}`:a.length>0?`carries ${a.join(", ")}`:"no unit",u=r.state==="decided"?"decided ":"within ";i.push(` ${u} ${Nn(o.sha)} ${o.subject}; ${c}${r.state==="decided"?`, ${t.record}'s own work`:`, in ${t.record}'s window and not its work`}`)}return n.some(r=>r.state==="decided-by-window")&&i.push(` ask ${Oee}`),i}function KIe(e){let t=e.constrains.length>0?e.constrains.map(s=>`${s.entry} (${s.granularity})`).join(", "):"through supersession only",n=e.decided_by?`, decided by ${e.decided_by}${e.decided_on?` on ${e.decided_on}`:""}`:"",i=e.decidedIn?` in ${Nn(e.decidedIn.sha)}`:"",r=`${e.reviews.agree} agree, ${e.reviews.dissent} dissent, ${e.reviews.abstain} abstain`,o=e.supersededBy?`, superseded by ${e.supersededBy}`:"";return`decision ${e.record} ${e.state??"stateless"}${o}: ${e.title??e.path}; constrains ${t}${n}${i}; ${r}; ${e.provenance.level}${e.valid?"":`; invalid: ${e.reasons.map(s=>s.code).join(", ")}`}`}function JIe(e,t){let n=t.constrains.length>0?t.constrains.map(l=>`${l.entry} (${l.granularity})`).join(", "):"through a link only",i=t.implements.length>0?`; implements ${t.implements.map(l=>`${l.id} (${l.state??"unknown"})`).join(", ")}`:"",r=t.ready?"; ready":t.blockedBy.length>0?`; blocked by ${t.blockedBy.map(l=>`${l.id} (${l.state??"unknown"})`).join(", ")}`:"",o=t.owner?`, owned by ${t.owner}`:"",s=t.source?`; from ${t.source.finding} on ${t.source.region}`:"",a=[`work ${t.record} ${t.state??"stateless"}${o}: ${t.title??t.path}; constrains ${n}${i}${r}${s}`];for(let l of e.edges.filter(c=>c.kind==="within"&&c.to===t.id)){let c=e.nodes.find(u=>u.kind==="commit"&&u.id===l.from);c&&a.push(` worked ${Nn(c.sha)} ${c.subject}; in ${t.record}'s window`)}for(let l of t.warnings)a.push(` warning ${l.code}: ${l.message}`);return a}function ZIe(e,t){let n=e.edges.filter(i=>i.kind==="pins"&&i.to===t.id).map(i=>`${i.from.slice(i.from.indexOf("/")+1)} at ${Nn(i.pinnedSha256)} (${i.pinState})`);return`artifact ${t.path} ${t.pinState}; pinned by ${n.join(", ")}; now ${Nn(t.currentSha256)}`}function YIe(e){if(!e)return[];let t=[];e.agent&&t.push(` agent ${e.agent}`),e.lease&&t.push(` lease ${e.lease.token}${e.lease.item?` on ${e.lease.item}`:", no lease history names it"}`);for(let n of e.records)t.push(` record ${n.kind}:${n.id}${n.node?"":", in no kind read"}`);return e.applied&&t.push(` applied by ${e.applied.by}${e.applied.at?` at ${e.applied.at}`:""}${e.applied.commit?`, ${Nn(e.applied.commit)}`:""}`),t}function XIe(e,t){let n=t.lines&&t.lines.length>0?`, lines ${t.lines.map(r=>r.start===r.end?`${r.start}`:`${r.start}-${r.end}`).join(", ")}`:"",i=[`commit ${Nn(t.sha)} ${t.date.slice(0,10)} ${t.author.name}: ${t.subject}${n}; ${t.signature.level}`];for(let r of zh(e,t.id,"produced-by")){let o=e.nodes.find(s=>s.id===r.to);i.push(` unit ${o&&"ref"in o?o.ref:r.to}`);for(let s of zh(e,r.to,"serves"))i.push(` contract ${s.to.slice(9)}`);for(let s of zh(e,r.to,"cites-evidence"))i.push(` evidence ${s.to.slice(9)}`)}if(i.push(...YIe(t.joins)),t.squash){let r=t.squash;i.push(` squash #${r.pullRequest}${r.followed?`: ${r.commits.length} original ${r.commits.length===1?"commit":"commits"} from ${r.ref}${r.fetched?", fetched":""}`:", not followed"}`);for(let o of r.commits){let s=[...o.joins.records.map(a=>`${a.kind}:${a.id}`),...o.joins.lease?[`lease ${o.joins.lease.token}`]:[],...o.joins.run?[`run ${o.joins.run}`]:[]];i.push(` original ${Nn(o.sha)} ${o.subject}; ${o.signature.level}${s.length>0?`; ${s.join(", ")}`:""}`)}}for(let r of zh(e,t.id,"made-by")){let o=e.nodes.find(l=>l.kind==="run"&&l.id===r.to);if(!o)continue;let s=o.recorded?`${[o.harness?.name,o.model].filter(Boolean).join("/")||"no model recorded"}${o.by?` for ${o.by}`:""}${o.cost?`, ${o.cost.amount} ${o.cost.currency}`:", unpriced"}`:"not in the run ledger",a=r.kind!=="made-by"?"":r.joinedBy.includes("patch-id")?`; joined by content${r.recordedAs?`, as ${Nn(r.recordedAs)}`:""}`:r.joinedBy.length===1&&r.joinedBy[0]==="squash"?`; through the squash, by ${(r.via??[]).map(Nn).join(", ")}`:"";i.push(` run ${o.run}: ${s}${a}`)}return i}function Cee(e,t){let n=[],i=o=>{let s=e.nodes.find(a=>a.id===o);return s&&(s.kind==="decision"||s.kind==="work")?s.record:o},r=o=>{let s=e.nodes.find(l=>l.kind==="run"&&l.id===o);if(!s)return o;let a=[s.harness?.name,s.model].filter(Boolean).join("/");return`${s.run}${a?` (${a})`:s.recorded?"":" (not in the run ledger)"}${s.unit?` on ${s.unit}`:""}`};n.push(`why ${t.explained?"explained":"unexplained"}${t.lines?`, lines ${U$(t.lines)}`:""}`);for(let o of t.decisions)n.push(` decision ${i(o.decision)} ${o.relevance}${o.lines>0?`, ${o.lines} ${o.lines===1?"line":"lines"}`:""}${o.current?"":", superseded"}${o.closed?", closed":""}`);for(let o of t.blame){let s=o.runs.length>0?`; ${o.runs.map(r).join(", ")}${o.narrowedBy?" (by its hunks)":""}${o.joinedBy?.includes("patch-id")?" (joined by content)":""}${o.via&&o.via.length>0?` (squashed from ${o.via.map(Nn).join(", ")})`:""}`:o.sha?"; no run":"";n.push(` lines ${U$(o)} ${o.sha?Nn(o.sha):"uncommitted"}${s}`)}for(let o of t.gaps)n.push(` gap ${o.code}: ${o.message}${o.lines?` (lines ${o.lines.map(U$).join(", ")})`:""}`);return n}function _ee(e){let t=[],n=e.nodes.find(s=>s.id===e.region);if(n?.kind==="region"){let s=n.lines?`:${n.lines.start}${n.lines.end===n.lines.start?"":`-${n.lines.end}`}`:"",a=e.at?`at ${Nn(e.at)}`:"in the working tree",l=n.symbol?`#${n.symbol.name} (${n.symbol.kind} ${n.symbol.qualified}, lines ${n.lines?U$(n.lines):"none"})`:s;t.push(`region ${n.path}${l} (${n.type}, member ${n.member??"none"}${n.generated?", generated":""}) ${a}${n.node?`, from node ${n.node}`:""}`)}let i=oc(e,"file");i.length>0&&t.push(`files ${i.length} under the region, ${i.filter(s=>s.generated).length} generated`);for(let s of oc(e,"decision"))t.push(KIe(s),...qIe(e,s));for(let s of oc(e,"work"))t.push(...JIe(e,s));for(let s of oc(e,"artifact"))t.push(ZIe(e,s));for(let s of oc(e,"commit"))t.push(...XIe(e,s));for(let s of oc(e,"link")){let a=s.row;t.push(`link ${a.consumer} reads ${"producer"in a?`${a.producer} ${a.output}`:a.input} (${a.status})`)}for(let s of oc(e,"finding")){let a=s.addressedBy&&s.addressedBy.length>0?`; addressed by ${s.addressedBy.map(l=>`${l.id} (${l.state??"unknown"})`).join(", ")}`:"";t.push(`finding ${s.code}: ${s.message}${a}`)}for(let s of e.reasons)t.push(`reason ${s.code}: ${s.message}`);e.why&&t.push(...Cee(e,e.why));let r=e.kinds.length===0?"; no --kind, so no decisions were read":"",o=oc(e,"work").length;return t.push(`${e.summary.commits} commits, ${e.summary.decisions} decisions, ${o>0?`${o} work ${o===1?"item":"items"}, `:""}${e.summary.artifacts} artifacts, ${e.summary.findings} findings${r}`),t.join(`
|
|
282
|
+
`)}function Iee(e){let t=e.record,n=[`record ${t.record} ${t.state??"stateless"}${t.supersededBy?`, superseded by ${t.supersededBy}`:""}: ${t.title??t.path}`];n.push(`window ${e.window.from?`from ${Nn(e.window.from)}`:"no history"}${e.window.until?` until ${Nn(e.window.until)}`:""}${t.decidedIn?`; decided in ${Nn(t.decidedIn.sha)} ${t.decidedIn.date.slice(0,10)}: ${t.decidedIn.subject}`:"; not decided in the history read"}`);for(let r of t.constrains)n.push(`entry ${r.entry}${r.walked?"":r.exists===!1?" (not in the tree read)":" (not walked)"}`);for(let r of e.commits){let o=r.bucket==="own"?r.unit!==null?`unit ${r.unit}`:`carries ${[...(r.joins?.records??[]).filter(l=>l.node!==null).map(l=>`${l.kind}:${l.id}`),...r.joins?.lease?.item?[`lease on ${r.joins.lease.item}`]:[]].join(", ")}`:r.bucket==="worked"?`worked by ${r.workedBy.map(l=>l.record).join(", ")}`:r.bucket==="within-other"?`within ${r.alsoWithin.map(l=>l.record).join(", ")}`:"nothing else accounts for it",s=(r.runs??[]).map(l=>`run ${l.id}${l.model?` (${l.model})`:""}${l.joinedBy?.includes("squash")&&!l.joinedBy.some(c=>c!=="squash")?" through the squash":""}`).join(", "),a=r.squash?`; squash of #${r.squash.pullRequest}${r.squash.followed?`, ${r.squash.commits.length} original ${r.squash.commits.length===1?"commit":"commits"}`:", not followed"}`:"";n.push(`${r.bucket.padEnd(12)} ${Nn(r.sha)} ${r.date.slice(0,10)} ${r.subject}; ${o}${s?`; ${s}`:""}${a}; ${r.files.join(", ")||r.entries.join(", ")}`)}for(let r of e.reasons)n.push(`reason ${r.code}: ${r.message}`);let i=e.counts;return n.push(`${i.commits} commits in the window: ${i.own} own, ${i.worked} worked, ${i.withinOther} within another record's window, ${i.unexplained} unexplained; ${i.outsideWindow} outside it`),n.join(`
|
|
283
|
+
`)}async function QIe(e,t,n){let{args:i}=e,{doc:r,failed:o}=await Ree({cwd:t,record:i.record,at:i.at,kinds:n?.map(s=>Aee(s)),followSquash:i.followSquash});return i.json&&console.log(JSON.stringify(r,null,2)),"error"in r?(console.error(fe({message:`${r.error.code}: ${r.error.message}`,hint:Pee})),1):(i.json||console.log(Iee(r)),o?1:0)}async function eTe(e,t){let{args:n}=e;if(n.record!==void 0)return n.intent?(console.error(fe({message:"--record walks a record, so --intent takes no region with it",hint:Pee})),1):QIe(e,t,n.kinds??(n.kind!==void 0?[n.kind]:void 0));if(!n.intent)return console.error(fe({message:"--intent needs a region: a path, path:line, path:start-end or path#symbol",hint:Eee})),1;let i=n.kinds??(n.kind!==void 0?[n.kind]:void 0),{doc:r,failed:o}=await XM({cwd:t,region:n.intent,at:n.at,kinds:i?.map(s=>Aee(s)),followSquash:n.followSquash});return n.json&&console.log(JSON.stringify(r,null,2)),"error"in r?(console.error(fe({message:`${r.error.code}: ${r.error.message}`,hint:Eee})),1):(n.json||console.log(_ee(r)),o?1:0)}var Eee,Pee,Nn,Oee,U$,Dee=v(()=>{"use strict";Kn();See();z$();Eee="chant workspace graph --intent <path[:start-end]|path#symbol> [--at <rev>] [--kind <kind file>...] [--follow-squash] [--json]",Pee="chant workspace graph --intent --record <id> [--at <rev>] [--kind <kind file>...] [--follow-squash] [--json]";Nn=e=>e?e.slice(0,8):"none",Oee="is this drift, a superseding decision nobody wrote down, or the decision being wrong?";U$=e=>e.start===e.end?`${e.start}`:`${e.start}-${e.end}`});var Wee={};_e(Wee,{GRAPH_CONTRACT_VERSION:()=>H$,GRAPH_ERROR_CODES:()=>iTe,GRAPH_OUTPUT_SCHEMA_ID:()=>V$,componentGraphArgv:()=>Fee,exportRevision:()=>Bee,planGraph:()=>Gee,runWorkspaceGraph:()=>aTe,workspaceGraph:()=>F$});import{execFileSync as Nee}from"node:child_process";import{existsSync as jl,mkdirSync as tTe,mkdtempSync as nTe,rmSync as Mee,symlinkSync as jee}from"node:fs";import{tmpdir as rTe}from"node:os";import{dirname as Uh,join as zo,resolve as Lee}from"node:path";function Fee(e){return["graph",".","--components","--format","ir",...e.env?["--env",e.env]:[]]}function Bee(e,t){let{top:n,at:i,root:r,rootOnDisk:o}=e;if(!n||!i)throw new Error("exportRevision needs a revision");let s=nTe(zo(rTe(),"chant-ws-at-")),a=zo(s,"root"),l=zo(s,"tree.tar");Nee("git",["archive","--format=tar","-o",l,r==="."?i:`${i}:${r}`],{cwd:n,stdio:["ignore","ignore","pipe"]}),tTe(a,{recursive:!0}),Nee("tar",["-xf",l,"-C",a],{stdio:["ignore","ignore","pipe"]}),Mee(l,{force:!0});let c=new Set([""]);for(let u of t){if(u===".")continue;let d=u.split("/");for(let p=1;p<=d.length;p++)c.add(d.slice(0,p).join("/"))}for(let u of c){let d=zo(o,...u.split("/"),"node_modules"),p=zo(a,...u.split("/"),"node_modules");jl(d)&&jl(Uh(p))&&!jl(p)&&jee(d,p,"dir")}if(!jl(zo(a,"node_modules")))for(let u=Uh(o);;u=Uh(u)){if(jl(zo(u,"node_modules"))){jee(zo(u,"node_modules"),zo(a,"node_modules"),"dir");break}if(Uh(u)===u)break}return a}function oTe(e,t,n,i,r=!1){let o=(c,u)=>(r&&(c.live=!0,u.finishedAt&&(c.readAt=u.finishedAt)),c),s=new Map(t.map(c=>[c.id,c])),a=[],l=e.unreadable.length>0;for(let c of i){if(n?.length&&!n.includes(c.name))continue;let u=s.get(c.name),d=e.skipped.find(g=>g.name===c.name)??e.unreadable.find(g=>g.name===c.name);if(!u){let g=e.unreadable.some(h=>h.name===c.name)?"failed":"skipped";a.push({member:Mh(c.name,c.dir,c.kind,g,d?.reason??null,null)});continue}if(u.exitCode!==0){l=!0;let g=u.stderr.trim().split(`
|
|
284
|
+
`).slice(-5).join(`
|
|
285
|
+
`);a.push({member:o(Mh(c.name,c.dir,c.kind,"failed",{code:"command-failed",message:`chant graph exited ${u.exitCode}${g?`: ${g}`:""}`},u.chant),u)});continue}let p=Rp(u.stdout);if("reason"in p){l=!0,a.push({member:o(Mh(c.name,c.dir,c.kind,"failed",p.reason,u.chant),u)});continue}let f=o(Mh(c.name,c.dir,c.kind,"composed",null,u.chant),u);f.irVersion=p.irVersion,a.push({member:f,ir:p.ir})}return{inputs:a,failed:l}}function Gee(e){let t=Qt(e.cwd,e.at),n=Lt(t.tree,"",{rootChant:!0}),i=ma(n.pins,t.rootOnDisk).registry;return j$("graph",t.rootOnDisk,{only:e.members,reader:e.reader,tree:t.tree,kinds:i})}async function F$(e){let t={$schema:V$,contract:H$,chant:Xt()},n,i;if(e.args?.live&&e.at!==void 0)return{doc:{...t,error:{code:"live-at-revision",message:QM,location:null}},failed:!0};try{let r=Qt(e.cwd,e.at),o=Lt(r.tree,"",{rootChant:!0}),s=ma(o.pins,r.rootOnDisk).registry,a=j$("graph",r.rootOnDisk,{only:e.members,reader:e.reader,tree:r.tree,kinds:s}),l=e.args??{},c=e.noCache||e.components?void 0:zQ(r.rootOnDisk),u=c?UQ(a,l,c,r.at):void 0,d=new Set(u?.hits.map($=>$.id));r.at!==null&&M$(a,d).groups.length>0&&(n=Bee(r,M$(a,d).groups.flatMap($=>$.units.map(_=>_.dir))),a=j$("graph",n,{only:e.members,reader:e.reader,tree:$n(n),kinds:s}));let p=M$(a,d);i=qQ(p,n??r.rootOnDisk);let[f,g]=await Promise.all([FM(p,l),e.components?FM(a,l,()=>Fee(l)):Promise.resolve(void 0)]);c&&u&&HQ(u,f,c);let h=[...u?.hits??[],...f];e.inTree&&await e.inTree(n??r.rootOnDisk,o.members.filter($=>!e.members?.length||e.members.includes($.name)));for(let $ of g??[])$.stderr.trim()&&e.onStderr&&e.onStderr($.stderr.endsWith(`
|
|
286
|
+
`)?$.stderr:`${$.stderr}
|
|
287
|
+
`);for(let $ of h)$.stderr.trim()&&e.onStderr&&e.onStderr($.stderr.endsWith(`
|
|
288
|
+
`)?$.stderr:`${$.stderr}
|
|
289
|
+
`);let{inputs:b,failed:w}=oTe(a,h,e.members,o.members,!!l.live);for(let{member:$}of b)$.status==="composed"&&($.cached=d.has($.name),$.stamp=u?.stamps.get($.name)??null);let x=OQ({name:o.name,root:r.root},b,{declaration:o,kinds:s});for(let $ of x.members)$.box=EQ(o.members.find(_=>_.name===$.name)?.box??null,r.tree,o.members);let k=await sTe(x,o.members,e,r.rootOnDisk,r.at),R=!1;if(e.kind!==void 0){let{readRecordsFor:$}=await Promise.resolve().then(()=>(ko(),zee));try{let _=await $({kind:e.kind,cwd:e.cwd,at:e.at}),T=_.loaded.kind.name;x.records=_.result.records.map(C=>({kind:T,id:C.id,path:C.path,state:C.state,valid:C.valid,supersededBy:C.supersededBy,remediatedBy:C.remediatedBy})),x.links.push(...oK(T,_.result.records,_.loaded.kind.constrains?.field,r.tree,o.members))}catch(_){if(!(_ instanceof Ve))throw _;R=!0,e.onStderr?.(`${fe({message:`--kind ${e.kind}: ${_.code}: ${_.message}`,hint:sc})}
|
|
290
|
+
`)}}return{doc:{...t,at:r.at,plantable:TM(o),...x},failed:w||R||k,...g?{components:g}:{}}}catch(r){if(!(r instanceof ve))throw r;return{doc:{...t,error:{code:r.code,message:r.message,location:r.location??null}},failed:!0}}finally{i?.cleanup(),n&&Mee(Uh(n),{recursive:!0,force:!0})}}async function sTe(e,t,n,i,r){let o=t.filter(u=>u.kind==="workspace"&&(!n.members?.length||n.members.includes(u.name)));if(o.length===0)return!1;let{foldNested:s,readNested:a}=await Promise.resolve().then(()=>(XQ(),YQ)),l=await Promise.all(o.map(async u=>{let d=zo(i,...u.dir.split("/"));return jl(d)?{m:u,read:await a(d,n.args??{},r,V$,H$,n.reader)}:{m:u,read:null}})),c=!1;for(let{m:u,read:d}of l){let p=e.members.find(f=>f.name===u.name);if(p){if(!d){c=!0,p.status="failed",p.reason={code:"dir-missing",message:`the nested workspace's directory ${u.dir} does not exist`};continue}d.stderr.trim()&&n.onStderr&&n.onStderr(d.stderr.endsWith(`
|
|
291
|
+
`)?d.stderr:`${d.stderr}
|
|
292
|
+
`),p.chant=d.chant,d.ok?s(e,p,d.doc):(c=!0,p.status="failed",p.reason={code:d.code,message:d.message})}}return c}async function aTe(e){let{args:t}=e,n=Lee(t.extraPositional??".");if(!jl(n))return console.error(fe({message:`${n} does not exist`,hint:sc})),1;let i=await zv(n,t.at);if(i!==void 0)return i;if(t.composites){if(t.intent!==void 0||t.kind!==void 0)return console.error(fe({message:"--composites takes neither --intent nor --kind",hint:sc})),1;if(!t.dryRun)return(await Promise.resolve().then(()=>($ee(),xee))).runWorkspaceComposites(e,n)}if(!t.composites&&t.intent===void 0){if((t.overlay||t.traffic!==void 0)&&!t.live)return console.error(fe({message:"--overlay and --traffic act on a live read; add --live --env <env>",hint:sc})),1;if(t.live&&t.at!==void 0)return Lh({$schema:V$,contract:H$,chant:Xt(),error:{code:"live-at-revision",message:QM,location:null}},t.output),console.error(fe({message:`live-at-revision: ${QM}`,hint:sc})),1;if(t.live&&!t.env)return console.error(fe({message:"--live needs an environment, as each member's chant graph --live does: --live --env <env>",hint:sc})),1}if(t.intent!==void 0)return(await Promise.resolve().then(()=>(Dee(),Tee))).runWorkspaceIntent(e,n);if(t.dryRun){let s;try{s=Gee({cwd:n,at:t.at,members:t.members})}catch(a){if(!(a instanceof ve))throw a;return console.error(fe({message:`${a.code}: ${a.describe()}`,hint:sc})),1}return console.log(t.json?JSON.stringify(FQ(s),null,2):MQ(s)),0}let{doc:r,failed:o}=await F$({cwd:n,at:t.at,members:t.members,args:t,...t.noCache?{noCache:!0}:{},...t.kind!==void 0?{kind:Lee(t.kind)}:{},onStderr:s=>process.stderr.write(s)});if(Lh(r,t.output),"error"in r){let s=r.error.location;console.error(fe({message:`${r.error.code}: ${s?`${s.file}:${s.line}:${s.column}: `:""}${r.error.message}`,hint:sc}))}return o?1:0}var H$,V$,iTe,QM,sc,YM=v(()=>{"use strict";Kn();DM();D$();VQ();_t();Fh();co();KQ();po();mn();Zt();ci();H$=1,V$="https://intentius.io/chant/schemas/workspace/graph/v1/graph.schema.json",iTe=[...lo,"live-at-revision"],QM="--live reads the account as it stands now, and --at reads the source at a revision; chant workspace graph takes one of them",sc="chant workspace graph [dir] [--at <rev>] [--member <name>] [--kind <kind file>] [-o <file>] [--env <env>] [--live [--overlay] [--traffic <level>]] [--no-cache] [--dry-run] | chant workspace graph --composites [--at <rev>] [--member <name>] [-o <file>] | chant workspace graph --intent <path[:start-end]|path#symbol> [--at <rev>] [--kind <kind file>...] [--follow-squash] [--json]"});var Qee={};_e(Qee,{INTENT_CONTRACT_VERSION:()=>Kee,INTENT_ERROR_CODES:()=>fTe,INTENT_FINDING_CODES:()=>e1,INTENT_OUTPUT_SCHEMA_ID:()=>Jee,INTENT_REASON_CODES:()=>pTe,INTENT_WHY_CODES:()=>mTe,IntentError:()=>tn,addingCommit:()=>Wh,blameLines:()=>Yee,closingCommit:()=>G$,commitDetails:()=>Ap,descendants:()=>Wo,intentGraph:()=>XM,loadKinds:()=>W$,parseRegion:()=>n1,regionHistory:()=>B$,tryGit:()=>Dn,windowOpening:()=>Pp});import{execFileSync as cTe}from"node:child_process";import{realpathSync as lTe}from"node:fs";import{basename as uTe,dirname as dTe,relative as qee,resolve as t1,sep as Uee}from"node:path";function Zee(e,t,n){return cTe("git",t,{cwd:e,encoding:"utf-8",input:n,stdio:[n===void 0?"ignore":"pipe","pipe","pipe"],maxBuffer:512*1024*1024})}function Dn(e,t,n){try{return Zee(e,t,n)}catch{return}}function gTe(e){let t=[];for(let n of e.matchAll(/^@@+ [^@]*\+(\d+)(?:,(\d+))? @@/gm)){let i=Number(n[1]),r=n[2]===void 0?1:Number(n[2]);r>0&&t.push({start:i,end:i+r-1})}return t}function B$(e,t,n,i,r){if(r){let a=Dn(e,["log",`-L${r.start},${r.end}:${n}`,"--format=%x00%H","--no-color",t]);return a===void 0?[]:a.split("\0").filter(Boolean).map(l=>{let c=l.indexOf(`
|
|
293
|
+
`);return{sha:(c<0?l:l.slice(0,c)).trim(),lines:gTe(c<0?"":l.slice(c+1))}})}let s=Dn(e,i==="file"?["log","--follow","--format=%H",t,"--",n]:["log","--format=%H",t,"--",n===""?".":n]);return s===void 0?[]:s.split(`
|
|
294
|
+
`).map(a=>a.trim()).filter(Boolean).map(a=>({sha:a,lines:null}))}function Yee(e,t,n,i){let r=Dn(e,["blame","--line-porcelain",...i?[`-L${i.start},${i.end}`]:[],...t?[t]:[],"--",n]);if(r===void 0)return;let o=[],s;for(let a of r.split(`
|
|
295
|
+
`)){if(a.startsWith(" ")){s&&o.push({line:s.line,sha:hTe.test(s.sha)?null:s.sha,origPath:s.origPath,origLine:s.origLine}),s=void 0;continue}let l=a.match(/^([0-9a-f]{40,64}) (\d+) (\d+)(?: \d+)?$/);if(l){s={sha:l[1],origLine:Number(l[2]),line:Number(l[3]),origPath:n};continue}s&&a.startsWith("filename ")&&(s.origPath=a.slice(9))}return o}function Ap(e,t){let n=new Map;if(t.length===0)return n;let i=Zee(e,["log","--no-walk=unsorted","--stdin","--format=%x00%H%x1f%an%x1f%ae%x1f%aI%x1f%(trailers:only,unfold,separator=%x1e)%x1f%B"],`${t.join(`
|
|
296
|
+
`)}
|
|
297
|
+
`);for(let r of i.split("\0")){if(!r)continue;let[o,s,a,l,c,...u]=r.split(""),d=u.join("").replace(/\n+$/,""),p=d.indexOf(`
|
|
298
|
+
`),f={};for(let g of(c??"").split("")){let h=g.indexOf(":");if(h<=0)continue;let b=g.slice(0,h).trim();(f[b]??=[]).push(g.slice(h+1).trim())}n.set(o.trim(),{sha:o.trim(),subject:p<0?d:d.slice(0,p),body:p<0?"":d.slice(p+1).replace(/^\n+/,""),author:{name:s,email:a},date:l,trailers:f})}return n}function Wh(e,t,n){return Dn(e,["log","--diff-filter=A","-1","--format=%H",t,"--",n])?.trim()||null}function G$(e,t,n,i,r){let o=Dn(e,["log","--format=%H",t,"--",n]),s=null;for(let a of(o??"").split(`
|
|
299
|
+
`).map(l=>l.trim()).filter(Boolean)){let l=Dn(e,["show",`${a}:${n}`]),c=l===void 0?void 0:us(l),u=c?.ok?c.value[i]:void 0;if(typeof u!="string"||!r.includes(u))break;s=a}return s}function Pp(e,t,n){return n.decidedIn?.sha??Wh(e,t,n.path)}function Wo(e,t,n){let i=new Set([t]),r=Dn(e,["rev-list","--ancestry-path",`${t}..${n}`]);for(let o of(r??"").split(`
|
|
300
|
+
`))o.trim()&&i.add(o.trim());return i}function yTe(e){let n=Dn(e,["config","--get","remote.origin.url"])?.trim()?.match(/[:/]([^/:]+)\/([^/]+?)(?:\.git)?\/?$/);return n?`${n[1]}/${n[2]}`.toLowerCase():null}function Hh(e){try{return lTe(e)}catch{return e}}function n1(e){let t=e.match(/^(.+?):(\d+)(?:-(\d+))?$/);if(!t)return{path:e,lines:null};let n=Number(t[2]),i=t[3]===void 0?n:Number(t[3]);return n<1||i<n?{error:`${e}: a line range is start-end with 1 <= start <= end`}:{path:t[1],lines:{start:n,end:i}}}function bTe(e,t,n){return n!==void 0?`region:${e}#${n}`:`region:${e}${t?`:${t.start}${t.end===t.start?"":`-${t.end}`}`:""}`}function wTe(e,t){let n=[],i=r=>{for(let o of(e.list(r)??[]).sort((s,a)=>s.name.localeCompare(a.name))){let s=ze(r,o.name);o.type==="dir"?ns(o.name)||i(s):n.push(s)}};return i(t==="."?"":t),n}function Ll(e){return typeof e=="string"?e:null}function Hee(e){let t=e?.source;if(t===null||typeof t!="object"||Array.isArray(t))return null;let n=t;return typeof n.finding!="string"||typeof n.region!="string"?null:{finding:n.finding,region:n.region,...typeof n.decision=="string"?{decision:n.decision}:{},...typeof n.artifact=="string"?{artifact:n.artifact}:{}}}function vTe(e){let t={agree:0,dissent:0,abstain:0,openConcerns:0},n=e?.reviews;if(!Array.isArray(n))return t;for(let i of n){if(i===null||typeof i!="object")continue;let r=i;r.verdict==="agree"?t.agree++:r.verdict==="abstain"?t.abstain++:r.verdict==="dissent"&&(t.dissent++,r.addressed_by==null&&r.withdrawn_on==null&&t.openConcerns++)}return t}async function $Te(e,t,n,i){let{workspaceGraph:r}=await Promise.resolve().then(()=>(YM(),Wee)),{doc:o}=await r({cwd:e,at:t,members:[n]});if("error"in o)return null;let s=o.nodes.find(a=>a.id===i);return s?s.sourceLoc?{file:s.sourceLoc.file,line:s.sourceLoc.line??null}:{file:".",line:null}:null}async function W$(e,t){let n=[];for(let i of e.kinds??[]){let r=t1(e.cwd,i),o=Xee(qee(t,Hh(r))),s;try{s=await GI(r)}catch(c){throw new tn("kind-unreadable",`kind file ${i} could not be loaded: ${c instanceof Error?c.message:String(c)}`)}let a=d6(s);if(typeof a=="string")throw new tn("kind-invalid",`kind file ${i} has a commitJoins export that can't be read: ${a}`);let l={file:r,display:o,name:a?.name??uTe(r).replace(/(?:\.kind)?\.[cm]?[jt]s$/,""),...a?{joins:a}:{}};if(s.recordKind!==void 0){let c=await Vh({kind:r,at:e.at,cwd:e.cwd,workGaps:!1});if("error"in c)throw new tn(c.error.code,c.error.message);try{l.records={loaded:await gn(r),views:c.records,workspaceRoot:c.workspaceRoot},l.name=a?.name??l.records.loaded.kind.name}catch(u){throw u instanceof Ve?new tn(u.code,u.message):u}}else if(!a)throw new tn("kind-invalid",`kind file ${i} exports neither recordKind nor commitJoins`);n.push(l)}return n}async function RTe(e,t,n){let i=n1(e.region);if("error"in i)throw new tn("intent-region-invalid",i.error);let r=c=>{let u=Xee(qee(Hh(t.rootOnDisk),t1(Hh(e.cwd),c))),d=u===""?".":u;return d==="."||_n(d)&&!d.startsWith("../")&&t.tree.stat(d)!==void 0?d:void 0},o=r(i.path);if(o!==void 0)return{path:o,lines:i.lines,node:null,symbol:null};let s=i.lines?-1:e.region.lastIndexOf("#");if(s>0){let c=e.region.slice(s+1),u=r(e.region.slice(0,s));if(u!==void 0&&c!==""){if(u==="."||t.tree.stat(u)!=="file")throw new tn("intent-region-invalid",`${u} is a directory, and a symbol needs a file`);let d=[],p="";if(!OM(u)){let g=Fr(u,n.members),h=g?n.members.find(b=>b.name===g):void 0;if(h&&h.kind==="chant"){let b=await bQ(wQ(t.rootOnDisk,h.dir),e.loadLexicon);d=b.resolvers,b.problems.length>0&&(p=`; member ${h.name}: ${b.problems.join("; ")}`)}}let f=CM(u,t.tree.read(u),c,d);if(!f.ok)throw new tn(f.reason==="unsupported"?"intent-symbol-unsupported":f.reason==="ambiguous"?"intent-symbol-ambiguous":"intent-symbol-unknown",`${f.message}${f.reason==="unsupported"?p:""}${t.tree.label}`);return{path:u,lines:f.declaration.lines,node:null,symbol:{name:c,qualified:f.declaration.qualified,kind:f.declaration.kind}}}}let a=e.region.indexOf("/"),l=a>0?n.members.find(c=>c.name===e.region.slice(0,a)):void 0;if(l&&!i.lines){let c=await(e.resolveNode??$Te)(e.cwd,e.at,l.name,e.region);if(c){let u=ze(l.dir,c.file);return{path:u===""?".":u,lines:c.line?{start:c.line,end:c.line}:null,node:e.region,symbol:null}}}throw new tn("intent-region-invalid",`${e.region} is not a path in the workspace${t.tree.label}, a path#symbol, or a graph node id`)}async function XM(e){let t={$schema:Jee,contract:Kee,chant:Xt()};try{return await STe(e,t)}catch(n){if(n instanceof tn||n instanceof ve||n instanceof Ve)return{doc:{...t,error:{code:n.code,message:n.message}},failed:!0};throw n}}async function STe(e,t){let n=Qt(e.cwd,e.at),i=n.top;if(!i)throw new tn("not-a-git-repository","the intent graph reads git history, and this directory is not in a git repository");let r=Lt(n.tree,"",{rootChant:!0}),o=await RTe(e,n,r),s=o.path==="."?"dir":n.tree.stat(o.path);if(!s)throw new tn("intent-region-invalid",`${o.path} does not exist${n.tree.label}`);if(o.lines){if(s!=="file")throw new tn("intent-region-invalid",`${o.path} is a directory, and a line range needs a file`);let S=n.tree.read(o.path).replace(/\n$/,"").split(`
|
|
301
|
+
`).length;if(o.lines.end>S)throw new tn("intent-region-invalid",`${o.path} has ${S} lines${n.tree.label}, so ${o.lines.start}-${o.lines.end} is not in it`)}let a=e.kinds??Ni(r).map(S=>Ma(S,n.rootOnDisk)),l=await W$({...e,kinds:a},i),c=new Map,u=[],d=[],p=[],f=S=>(c.has(S.id)||c.set(S.id,S),c.get(S.id)),g=(S,A,P)=>{p.push({id:`finding:${S}:${p.filter(j=>j.code===S).length+1}`,kind:"finding",code:S,message:A,concerns:P})},h=o.path==="."?r.members.find(S=>S.dir===".")?.name??null:Fr(o.path,r.members),b=bTe(o.path,o.lines,o.symbol?.name);f({id:b,kind:"region",path:o.path,lines:o.lines,member:h,at:n.at,type:s,generated:s==="file"?AD(r,o.path):null,node:o.node,symbol:o.symbol});let w=s==="dir"?wTe(n.tree,o.path):[];for(let S of w)f({id:`file:${S}`,kind:"file",path:S,member:Fr(S,r.members),generated:AD(r,S)});let x=S=>{let A=r.members.find(P=>P.name===S);return f({id:`member:${S}`,kind:"member",name:S,dir:A?.dir??"",memberKind:A?.kind??""})};h&&x(h);let k=n.at??(Dn(i,["rev-parse","--verify","--quiet","HEAD^{commit}"])?.trim()||null),R=Dn(i,["rev-parse","--is-shallow-repository"])?.trim()==="true";R&&d.push({code:"intent-history-shallow",message:"this is a shallow clone, so the history stops at its boundary and the oldest commit listed may stand for many"});let $=n.root==="."?"":n.root,_=ze($,o.path),T=k?B$(i,k,_,s,o.lines):[],C=s==="file"?o.lines??{start:1,end:Math.max(1,n.tree.read(o.path).replace(/\n$/,"").split(`
|
|
302
|
+
`).length)}:null,K=C===null?[]:(k?Yee(i,n.at,_,o.lines):void 0)??(n.at===null?Array.from({length:C.end-C.start+1},(S,A)=>({line:C.start+A,sha:null,origPath:_,origLine:C.start+A})):[]);for(let S of new Set(K.map(A=>A.sha).filter(A=>A!==null)))T.some(A=>A.sha===S)||T.push({sha:S,lines:null});let O=Ap(i,T.map(S=>S.sha)),pe=e.followSquash?Fg(i,[...O.values()],{fetchMissing:!0}):new Map;for(let S of pe.values())S.problem&&d.push({code:"squash-unfollowed",message:`${S.sha.slice(0,8)} squashes pull request #${S.pullRequest}, and ${S.problem}, so its original commits are not followed`});let F=Ap(i,[...new Set([...pe.values()].flatMap(S=>S.commits))]),Q=S=>(pe.get(S)?.commits??[]).map(A=>F.get(A)).filter(A=>A!==void 0),I=ai(i,Gr(i)),B=I.active?await zm():[],Z=S=>{if(!(!_n(S)||n.tree.stat(S)!=="file"))return n.tree.read(S)},xe=S=>{let A=S==="."?"":S.replace(/\/+$/,"");return A!==""&&(!_n(A)||n.tree.stat(A)!=="dir")?void 0:n.tree.list(A)?.map(j=>`${ze(A,j.name)}${j.type==="dir"?"/":""}`).sort()},we=new Map,Ct=T$(i,[...O.values(),...F.values()]),at=[],$e=S=>{if(!I.active)return{level:"unattested",reason:I.problems.length?I.problems.join("; "):`no signers file (${I.signersPath}) at base; attestation is off`};let A=Um(i,I,S,B);return{level:A.level,reason:A.reason,...A.principal?{principal:A.principal}:{}}},Te=new Set;for(let S of T){let A=O.get(S.sha);if(!A)continue;let P=$e(A.sha),j=A.subject.match(/\(#([0-9]+)\)\s*$/),U=`commit:${A.sha}`,L=pe.get(A.sha),re=L?{pullRequest:L.pullRequest,forge:L.forge,ref:L.ref,head:L.head,fetched:L.fetched,followed:L.followed,commits:Q(A.sha).map(it=>({sha:it.sha,subject:it.subject,author:it.author,date:it.date,trailers:it.trailers,signature:$e(it.sha),joins:Ct.get(it.sha).joins}))}:void 0;f({id:U,kind:"commit",sha:A.sha,subject:A.subject,author:A.author,date:A.date,trailers:A.trailers,pullRequest:j?Number(j[1]):null,signature:P,lines:S.lines,state:null,joins:Ct.get(A.sha).joins,...re?{squash:re}:{}}),u.push({kind:"touched-by",from:b,to:U,lines:S.lines});let me={contracts:[],authorship:[],decisions:[],carries:[]};we.set(A.sha,me);let Be=it=>{u.some(lr=>lr.kind===it.kind&&lr.from===it.from&&lr.to===it.to)||u.push(it)},Gt=[A,...Q(A.sha)];for(let it of l)if(it.joins)for(let lr of Gt){let Tp=lr!==A,wn;try{wn=await Bv(it.joins,lr,{read:Z,list:xe,at:n.at},it.name)}catch(Cr){let Zi=`${it.display}: commitJoins failed for ${lr.sha.slice(0,8)}: ${Cr instanceof Error?Cr.message:String(Cr)}`;Te.has(Zi)||d.push({code:"intent-plugin-failed",message:Zi}),Te.add(Zi);continue}let Bl=(Cr,Zi)=>{let{id:Ms,...ae}=Zi;return f({id:`${Cr}:${Ms}`,kind:Cr,ref:Ms,plugin:it.display,data:ae}).id},xi=wn.unit?Bl("unit",wn.unit):void 0,cc=wn.contract?Bl("contract",wn.contract):void 0;xi&&(Tp?me.unit??=xi:me.unit=xi,Be({kind:"produced-by",from:U,to:xi}),cc&&Be({kind:"serves",from:xi,to:cc})),cc&&me.contracts.push(wn.contract.id),xi&&me.decisions.push(...Nd(wn.unit),...Nd(wn.contract));for(let Cr of wn.findings??[])at.push({commit:U,plugin:it.display,finding:Cr});let lc=wn.evidence===void 0?[]:Array.isArray(wn.evidence)?wn.evidence:[wn.evidence];for(let Cr of lc)Be({kind:"cites-evidence",from:xi??cc??U,to:Bl("evidence",Cr)});Tp||me.authorship.push(...wn.authorship??[])}}let nt=await Bk(i,n.rootOnDisk,[...new Set([...T.map(S=>S.sha),...F.keys()])].map(S=>({sha:S,run:Ct.get(S)?.joins.run??null})));Gk(nt.refs,pe);for(let S of T)if(c.has(`commit:${S.sha}`))for(let A of nt.refs.get(S.sha)??[]){let P=nt.runs.get(A.id),j=f({id:`run:${A.id}`,kind:"run",run:A.id,recorded:P!==void 0,state:P?.state??null,harness:P?.harness??null,model:P?.model??null,provider:P?.provider??null,by:P?.by??null,agent:P?.agent??null,unit:P?.unit?.id??null,startedAt:P?.startedAt??null,endedAt:P?.endedAt??null,outcome:P?.outcome??null,usage:P?.usage??null,cost:P?.cost??null,transcript:P?.transcript??null,instruction:P?.instruction??null,lease:P?.lease??null});u.push({kind:"made-by",from:`commit:${S.sha}`,to:j.id,joinedBy:A.joinedBy,...A.recordedAs?{recordedAs:A.recordedAs}:{},...A.via?{via:A.via}:{}})}for(let S of nt.conflicts){if(!c.has(`commit:${S.sha}`))continue;let A=S.content.map(P=>`${P.run} (${P.sha.slice(0,8)})`).join(", ");g("intent-commit-join-conflict",`${S.sha.slice(0,8)} joins ${S.joined.join(", ")} by its trailer or the run's record, and has the patch-id of a commit ${A} recorded; it is not joined to ${S.content.length===1?"that run":"those runs"}`,[`commit:${S.sha}`,...S.joined.map(P=>`run:${P}`)])}let St=o.path==="."?$:_,Ee=yTe(i),zt=new Set;for(let S of O.values())for(let A of S.subject.matchAll(/#([0-9]+)/g))zt.add(A[1]);let Vn=new Set([...we.values()].flatMap(S=>S.contracts)),ne=[],Re=new Map,X=(S,A)=>`record:${S.records.loaded.kind.name}/${A}`,Ce=(S,A)=>{let P=S.records.loaded.kind,j=zI(P,A.data);return f({id:X(S,A.id),kind:"decision",recordKind:P.name,record:A.id,path:A.path,title:Ll(A.data?.title),state:A.state,closed:A.state!==null&&(P.closedStates??[]).includes(A.state),valid:A.valid,reasons:A.reasons,provenance:{level:A.provenance.level,commit:A.provenance.commit,reason:A.provenance.reason},decided_by:Ll(A.data?.decided_by),decided_on:Ll(A.data?.decided_on),decidedIn:A.decidedIn??null,reviews:vTe(A.data),supersededBy:A.supersededBy,supersedes:j,constrains:[]})},tt=S=>w.filter(A=>ls(S,ze($,A))),gt=(S,A)=>{let P=S.records.loaded.kind.constrains?.field,j=S.records.workspaceRoot==="."?"":S.records.workspaceRoot,U=P?A.data?.[P]:void 0,L=[];if(!Array.isArray(U))return L;for(let re of U)if(typeof re=="string")if(re.startsWith("path:")){let me=re.slice(5);if(!_n(me))continue;let Be=ze(j,me);if(St!==""&&ls(Be,St))L.push({entry:re,granularity:"path",to:b});else if(s==="dir"&&Be!==St&&(St===""||Be.startsWith(`${St}/`)))for(let Gt of tt(Be))L.push({entry:re,granularity:"path",to:`file:${Gt}`})}else if(re.startsWith("member:"))h!==null&&re.slice(7)===h&&L.push({entry:re,granularity:"member",to:b});else{let me=re.match(xTe);me&&Ee!==null&&me[1].toLowerCase()===Ee&&zt.has(me[2])?L.push({entry:re,granularity:"issue",to:b}):Vn.has(re)&&L.push({entry:re,granularity:"contract",to:`contract:${re}`})}return L};for(let S of l)if(!(!S.records||S.records.loaded.kind.work))for(let A of S.records.views){if(A.id===null)continue;Re.set(`${S.records.loaded.kind.name}/${A.id}`,{view:A,kind:S});let P=gt(S,A);if(P.length===0)continue;let j=Ce(S,A);for(let U of P)u.push({kind:"constrains",from:j.id,to:U.to,granularity:U.granularity,entry:U.entry}),(U.to===b||U.granularity==="contract")&&j.constrains.push({entry:U.entry,granularity:U.granularity});j.constrains.length>0&&ne.push({view:A,kind:S,node:j})}let Je=[...c.values()].filter(S=>S.kind==="decision");for(;Je.length>0;){let S=Je.shift(),A=[];S.supersededBy&&A.push(`${S.recordKind}/${S.supersededBy}`);for(let[P,{view:j}]of Re)P.startsWith(`${S.recordKind}/`)&&j.supersededBy===S.record&&A.push(P);for(let P of A){let j=Re.get(P);if(!j)continue;let U=X(j.kind,j.view.id);c.has(U)||Je.push(Ce(j.kind,j.view))}}let Bt=[...c.values()].filter(S=>S.kind==="decision");for(let S of Bt)if(S.supersededBy){let A=`record:${S.recordKind}/${S.supersededBy}`;c.has(A)&&u.push({kind:"supersedes",from:A,to:S.id})}let W=new Map;for(let S of Bt){let A=Re.get(`${S.recordKind}/${S.record}`),P=A.kind.records.loaded.kind;for(let U of A.view.assets){let L=W.get(U.path)??[];L.push({decision:S,state:U.state,sha256:U.sha256,actual:U.actual}),W.set(U.path,L)}let j=P.pins?A.view.data?.[P.pins.field]:void 0;if(Array.isArray(j))for(let U of j){if(U===null||typeof U!="object"||Array.isArray(U))continue;let L=U,re=typeof L.sha256=="string"&&kTe.test(L.sha256);if(_n(L.path)){if(re)continue;let Be=W.get(L.path)??[];Be.push({decision:S,state:"unpinned",sha256:null,actual:null}),W.set(L.path,Be),g("intent-evidence-unpinned",`${S.record} names ${L.path} as evidence with no sha256, so a later edit can't be told from what was decided on`,[S.id,`artifact:${L.path}`]);continue}if(typeof L.url!="string")continue;let me=f({id:`evidence:${L.url}`,kind:"evidence",ref:L.url,plugin:null,data:{title:Ll(L.title),url:L.url,path:null,as_of:Ll(L.as_of),sha256:re?L.sha256:null}});u.push({kind:"cites-evidence",from:S.id,to:me.id}),re||g("intent-evidence-unpinned",`${S.record} cites ${L.url} with no hash, so what the page said when it was decided can't be checked`,[S.id,me.id])}}for(let[S,A]of W){let P=`artifact:${S}`,U=[...A.filter(L=>L.decision.supersededBy===null&&L.state!=="unpinned")].sort((L,re)=>Vee.indexOf(L.state)-Vee.indexOf(re.state))[0];f({id:P,kind:"artifact",path:S,anchor:null,pinnedSha256:U?.sha256??null,currentSha256:A.find(L=>L.state!=="unpinned")?.actual??null,pinState:U?.state??"unpinned"});for(let L of A)if(u.push({kind:"pins",from:L.decision.id,to:P,pinnedSha256:L.sha256,pinState:L.state}),L.state==="drifted"&&g("intent-pin-drifted",`${S} changed after ${L.decision.record} pinned it: sha256 ${L.sha256?.slice(0,12)} is pinned, the file hashes to ${L.actual?.slice(0,12)}`,[L.decision.id,P]),L.state==="missing"&&g("intent-pin-missing",`${L.decision.record} pins ${S}, which does not exist${n.tree.label}`,[L.decision.id,P]),L.state==="stale"&&L.decision.supersededBy===null&&L.decision.constrains.length>0){let re=A.find(me=>me.decision.supersededBy===L.decision.record&&me.decision.recordKind===L.decision.recordKind&&me.sha256===L.sha256);g("intent-pin-stale",`${S} is pinned by ${L.decision.record} at sha256 ${L.sha256?.slice(0,12)}, the hash ${re?re.decision.record:"the record it supersedes"} pinned, and it has not changed since: the decision moved on and the artifact did not`,[L.decision.id,P,...re?[re.decision.id]:[]])}!U&&A.some(L=>L.state!=="unpinned")&&g("intent-artifact-unpinned",`${S} was pinned by ${[...new Set(A.map(L=>L.decision.record))].join(", ")}, and no current decision pins it`,[P,...new Set(A.map(L=>L.decision.id))])}for(let S of Bt){let A=Re.get(`${S.recordKind}/${S.record}`),P=A.kind.records.loaded.kind.constrains?.field,j=P?A.view.data?.[P]:void 0;if(!Array.isArray(j))continue;let U=A.kind.records.workspaceRoot==="."?"":A.kind.records.workspaceRoot;for(let L of j){if(typeof L!="string"||!L.startsWith("path:"))continue;let re=L.slice(5);if(!_n(re))continue;let me=ze(U,re),Be=$===""?me:me.startsWith(`${$}/`)?me.slice($.length+1):void 0;Be!==void 0&&n.tree.stat(Be)===void 0&&g("intent-constraint-lost",`${S.record} constrains ${re}, which does not exist${n.tree.label}`,[S.id])}}let de=new Map;if(k)for(let S of ne){let A=Pp(i,k,S.view),P=S.view.supersededBy?Re.get(`${S.node.recordKind}/${S.view.supersededBy}`):void 0,j=P?Pp(i,k,P.view):null;de.set(S.node.id,{from:A?Wo(i,A,k):new Set,until:j?Wo(i,j,k):null})}let Oe=l.filter(S=>S.records?.loaded.kind.work),pt=Oe.length>0,et=[],Ut=new Map;for(let S of Oe)for(let A of S.records.views){if(A.id===null)continue;let P={view:A,kind:S};et.push(P);let j=`${S.records.loaded.kind.name}/${A.id}`;Ut.has(j)||Ut.set(j,P)}let Tt=S=>S.kind.records.loaded.kind.work,wt=S=>{if(S.node)return S.node;let A=S.kind.records.loaded.kind,P=S.view;return S.node=f({id:`record:${A.name}/${P.id}`,kind:"work",recordKind:A.name,record:P.id,path:P.path,title:Ll(P.data?.title),state:P.state,closed:P.state!==null&&(A.closedStates??[]).includes(P.state),valid:P.valid,reasons:P.reasons,provenance:{level:P.provenance.level,commit:P.provenance.commit,reason:P.provenance.reason},owner:Ll(P.data?.owner),ready:P.ready??!1,blockedBy:P.blockedBy??[],implements:P.implements??[],needs:Sr(P.data,A.work.needs),source:Hee(P.data),supersededBy:P.supersededBy,constrains:[],warnings:P.warnings.filter(j=>II.includes(j.code))}),S.node},qn=S=>{let A=Hh(t1(dTe(S.records.loaded.file),S.records.loaded.kind.work.decisions));return l.find(P=>P.records&&!P.records.loaded.kind.work&&Hh(P.records.loaded.file)===A)},Pr=S=>{let A=qn(S.kind);return A?Sr(S.view.data,Tt(S).implements).map(P=>Re.get(`${A.records.loaded.kind.name}/${P}`)).filter(P=>P!==void 0).map(P=>X(P.kind,P.view.id)):[]},Or=S=>et.filter(A=>{let P=A.kind.records.loaded.kind;return!(A.view.state!==null&&A.view.state!==P.work.done&&(P.closedStates??[]).includes(A.view.state))&&Pr(A).includes(S.id)}),ki=[];for(let S of et){let A=gt(S.kind,S.view);if(A.length===0)continue;let P=wt(S);for(let j of A)u.push({kind:"constrains",from:P.id,to:j.to,granularity:j.granularity,entry:j.entry}),(j.to===b||j.granularity==="contract")&&P.constrains.push({entry:j.entry,granularity:j.granularity});P.constrains.length>0&&ki.push(S)}let Vo=new Map;if(k)for(let S of ki){let A=S.kind.records.loaded.kind,P=Wh(i,k,S.view.path),j=A.stateField?G$(i,k,S.view.path,A.stateField,A.closedStates??[]):null,U=j?Wo(i,j,k):null;j&&U.delete(j),Vo.set(S.node.id,{from:P?Wo(i,P,k):new Set,until:U})}let y=(S,A)=>{let P=Vo.get(S.node.id);return!!P&&P.from.has(A)&&!P.until?.has(A)},N=new Map(l.filter(S=>S.records).map(S=>[S.records.loaded.kind.name,S])),q=S=>{let A=[],P=j=>{A.some(U=>U.node===j.node)||A.push(j)};if(S.unit){let U=(S.unit.kind?Oe.filter(L=>L.records.loaded.kind.name===S.unit.kind):Oe).map(L=>Ut.get(`${L.records.loaded.kind.name}/${S.unit.id}`)).filter(L=>L!==void 0);U.length===1&&P({node:wt(U[0]).id,work:U[0]})}for(let j of S.records){let U=N.get(j.kind);if(!U)continue;if(U.records.loaded.kind.work){let re=Ut.get(`${j.kind}/${j.id}`);re&&P({node:wt(re).id,work:re});continue}let L=Re.get(`${j.kind}/${j.id}`);L&&P({node:Ce(L.kind,L.view).id,decision:`${j.kind}/${j.id}`})}return A};for(let S of T){let A=c.get(`commit:${S.sha}`),P=we.get(S.sha);if(!A||!P)continue;let j=L=>{P.carries.includes(L)||(P.carries.push(L),u.push({kind:"carries",from:A.id,to:L}))},U=L=>{let re=wt(L);return j(re.id),P.decisions.push(...Pr(L).map(me=>me.slice(7))),re.id};for(let L of[A.joins,...(A.squash?.commits??[]).map(re=>re.joins)]){for(let me of L.records){let Be=N.get(me.kind);if(!Be)continue;if(Be.records.loaded.kind.work){let it=Ut.get(`${me.kind}/${me.id}`);it&&(me.node=U(it));continue}let Gt=Re.get(`${me.kind}/${me.id}`);Gt&&(me.node=Ce(Gt.kind,Gt.view).id,j(me.node),P.decisions.push(`${me.kind}/${me.id}`))}let re=L.lease?.item;if(re){let me=Oe.map(Be=>Ut.get(`${Be.records.loaded.kind.name}/${re}`)).filter(Be=>Be!==void 0);me.length===1&&U(me[0])}}for(let L of nt.refs.get(S.sha)??[]){let re=nt.runs.get(L.id);if(re)for(let me of q(re))me.work?U(me.work):me.decision&&(j(me.node),P.decisions.push(me.decision))}}for(let S of[...c.values()]){if(S.kind!=="run")continue;let A=nt.runs.get(S.run);if(A)for(let P of q(A))u.push({kind:"worked-on",from:S.id,to:P.node})}for(let S of et.filter(A=>A.node)){for(let A of Pr(S)){let P=Re.get(A.slice(7));u.push({kind:"implements",from:S.node.id,to:Ce(P.kind,P.view).id})}for(let A of Sr(S.view.data,Tt(S).needs)){let P=Ut.get(`${S.kind.records.loaded.kind.name}/${A}`);P&&u.push({kind:"needs",from:S.node.id,to:wt(P).id})}}let Y=(S,A)=>ne.filter(P=>{if(!P.node.constrains.some(U=>A.includes(U.granularity)))return!1;let j=de.get(P.node.id);return!!j&&j.from.has(S)&&!j.until?.has(S)}),z=l.some(S=>S.records),E=(S,A)=>(!!S.unit||S.carries.length>0)&&(S.decisions.some(P=>P===A.record||P===`${A.recordKind}/${A.record}`)||A.constrains.some(P=>P.granularity==="contract"&&S.contracts.includes(P.entry)));for(let S of T){let A=c.get(`commit:${S.sha}`);if(!A)continue;let P=we.get(S.sha);if(z){let U=Y(S.sha,["path"]);for(let L of U)u.push({kind:"within",from:A.id,to:L.node.id,state:E(P,L.node)?"decided":"decided-by-window"});A.state=U.length===0?"undecided":U.some(L=>E(P,L.node))?"decided":"decided-by-window"}for(let U of ki)U.node.constrains.some(L=>L.granularity==="path")&&y(U,S.sha)&&u.push({kind:"within",from:A.id,to:U.node.id,state:"worked"});z&&A.state==="undecided"&&g("intent-commit-undecided",`${S.sha.slice(0,8)} changed the region when no decision constrained ${o.path} by path`,[A.id,b]),z&&!P.unit&&P.carries.length===0&&A.pullRequest===null&&Y(S.sha,["path","member","contract","issue"]).length===0&&g("intent-commit-bare",`${S.sha.slice(0,8)} names no unit, no record, no pull request and no decision`,[A.id]);let j=[...new Set(P.authorship)].filter(U=>tT(A.trailers,U));j.length>0&&A.signature.level!=="attested"&&g("intent-trailer-unverified",`${S.sha.slice(0,8)} carries ${j.join(", ")}, and the commit is ${A.signature.level}, so nothing vouches for the trailer`,[A.id])}if(z){let S=ne.filter(P=>P.node.supersededBy===null);ne.length===0?g("intent-region-unconstrained",`no decision constrains ${o.path}`,[b]):S.length===0?g("intent-decision-superseded-live",`every decision constraining ${o.path} is superseded: ${ne.map(P=>`${P.node.record} by ${P.node.supersededBy}`).join(", ")}`,[b,...ne.map(P=>P.node.id)]):S.every(P=>!P.node.closed)&&g("intent-decision-provisional",`the decisions constraining ${o.path} are ${[...new Set(S.map(P=>P.node.state??"stateless"))].join(" or ")}, and none is in a closed state`,[b,...S.map(P=>P.node.id)]);for(let P of S){let j=P.view.quorum?.openConcerns??[];if(j.length===0)continue;let U=[...new Set(j.map(L=>L.principal))];p.push({id:`finding:intent-decision-contested:${p.filter(L=>L.code==="intent-decision-contested").length+1}`,kind:"finding",code:"intent-decision-contested",message:`${P.node.record} constrains ${o.path} and has ${j.length} open ${j.length===1?"concern":"concerns"}, from ${j.map(L=>L.reviewer).join(", ")}: a dissent neither addressed nor withdrawn`,concerns:[P.node.id,b],openConcerns:{count:j.length,principals:U}})}let A=new Set(ne.flatMap(P=>P.node.constrains.map(j=>j.granularity)));ne.length>0&&!A.has("path")&&A.has("member")&&g("intent-constraint-coarse",`${o.path} is constrained only through its member, ${h}`,[b,...ne.map(P=>P.node.id)])}if(pt){for(let S of ne){if(S.node.supersededBy!==null||!qc(S.kind.records.loaded.kind,S.node.state)||Or(S.node).length>0)continue;let A=de.get(S.node.id);A&&T.some(P=>A.from.has(P.sha)&&!A.until?.has(P.sha))||g("intent-decision-unimplemented",`${S.node.record} is ${S.node.state} and constrains ${o.path}, and no work item that is not dropped implements it, and no commit changed the region in its window`,[S.node.id,b])}for(let S of ki){let A=S.node;if(A.blockedBy.length===0)continue;let P=T.filter(L=>y(S,L.sha));if(P.length===0)continue;let j=A.blockedBy.map(L=>`${L.id} (${L.state??"unknown"})`).join(", "),U=A.blockedBy.map(L=>Ut.get(`${A.recordKind}/${L.id}`)).filter(L=>L!==void 0).map(L=>wt(L).id);g("intent-work-blocked",`${A.record} has ${P.length} ${P.length===1?"commit":"commits"} in its window while it waits on ${j}`,[A.id,...P.map(L=>`commit:${L.sha}`),...U])}for(let S of[...c.values()].filter(A=>A.kind==="decision")){let A=u.filter(j=>j.kind==="within"&&j.to===S.id&&j.state==="decided").map(j=>j.from);if(A.length===0)continue;let P=Or(S);P.length===0||P.some(j=>j.view.state===Tt(j).done)||g("intent-work-open-decided-code",`${A.length} ${A.length===1?"commit":"commits"} in ${o.path} ${A.length===1?"is":"are"} ${S.record}'s own work, and ${P.map(j=>`${j.view.id} is ${j.view.state??"stateless"}`).join(", ")}: the code says done and the queue says not`,[S.id,...A,...P.map(j=>wt(j).id)])}}if(h){let S=[];try{let A=ha(r,n.tree),P=ma(r.pins,n.rootOnDisk).registry;S=ND(r,mZ(r,n.tree,A,P)).filter(j=>j.origin==="declared")}catch(A){if(!(A instanceof ve))throw A}S.forEach((A,P)=>{let j="producer"in A?A.producer:null;if(A.consumer!==h&&j!==h)return;let{pointer:U,...L}=A;f({id:`link:${P+1}`,kind:"link",row:L}),x(A.consumer),j&&r.members.some(re=>re.name===j)&&(x(j),u.push({kind:"links",from:`member:${A.consumer}`,to:`member:${j}`}))})}p.sort((S,A)=>e1.indexOf(S.code)-e1.indexOf(A.code));let G=S=>{if(c.has(S))return S;for(let A of["commit","unit","contract","evidence","artifact","file","member"])if(c.has(`${A}:${S}`))return`${A}:${S}`;for(let A of c.values())if(A.kind==="decision"&&(S===A.record||S===`${A.recordKind}/${A.record}`)||A.kind==="commit"&&/^[0-9a-f]{7,}$/.test(S)&&A.sha.startsWith(S))return A.id};for(let{commit:S,plugin:A,finding:P}of at){let j=P.code,U=P.refs??[],L=[...new Set([S,...U.map(G).filter(re=>re!==void 0)])];p.push({id:`finding:${j}:${p.filter(re=>re.code===j).length+1}`,kind:"finding",code:j,message:P.message,concerns:L,plugin:A,refs:U})}if(pt){let S=new Set(["intent-pin-drifted","intent-pin-missing","intent-pin-stale"]),A=(P,j)=>{let U=Hee(P.view.data);if(U===null||U.finding!==j)return!1;let L=n1(U.region);if("error"in L)return!1;let re=P.kind.records.workspaceRoot==="."?"":P.kind.records.workspaceRoot,me=ze(re,L.path),Be=(Gt,it)=>Gt===it||Gt===""||it.startsWith(`${Gt}/`);return!Be(me,St)&&!Be(St,me)?!1:me===St&&L.lines&&o.lines?L.lines.start<=o.lines.end&&o.lines.start<=L.lines.end:!0};for(let P of p){let j=[];for(let U of et){let L=A(U,P.code),re=(S.has(P.code)||Lv(P.code))&&Pr(U).some(me=>P.concerns.includes(me));if((L||re)&&j.push(U),L&&U.view.state===Tt(U).done){let me=wt(U);me.warnings.some(Be=>Be.code==="work-done-gap-open")||me.warnings.push({code:"work-done-gap-open",message:`${me.record} is ${U.view.state}, and ${P.code}, the gap it came from, still fires on ${o.path}`})}}P.addressed=j.length>0,P.addressedBy=j.map(U=>({id:U.view.id,state:U.view.state}));for(let U of j)u.push({kind:"addressed-by",from:P.id,to:wt(U).id})}}let H=[...c.values()].filter(S=>S.kind==="work");if(H.length>0){let S=new Map(H.map(A=>[`${A.recordKind}:${A.record}`,A]));for(let A of l){let P=A.records?.loaded.kind;if(P?.session)for(let j of A.records.views){if(j.id===null||!j.data)continue;let U=new Map,L=(me,Be)=>{if(Array.isArray(me))for(let Gt of me){let it=typeof Gt=="string"?S.get(Gt):void 0;if(!it)continue;let lr=U.get(it)??[];Be!==null&&!lr.includes(Be)&&lr.push(Be),U.set(it,lr)}};L(j.data.follow_ups,null),(Array.isArray(j.data.comments)?j.data.comments:[]).forEach((me,Be)=>L(me?.follow_ups,Be+1));for(let[me,Be]of U)(me.reviews??=[]).push({id:`record:${P.name}/${j.id}`,recordKind:P.name,record:j.id,path:j.path,state:j.state,comments:Be.sort((Gt,it)=>Gt-it)})}}}for(let S of p)c.set(S.id,S);let ee=oe(),te=[...c.values()];return{doc:{...t,at:n.at,workspace:{name:r.name,root:n.root},region:b,history:{rev:k,follows:o.lines?"line-range":s==="file"?"file":"directory",shallow:R},kinds:l.map(S=>({file:S.display,name:S.name,records:S.records?.loaded.kind.name??null,joins:S.joins?.form??null})),nodes:te,edges:u,reasons:d,summary:{commits:te.filter(S=>S.kind==="commit").length,decisions:te.filter(S=>S.kind==="decision").length,artifacts:te.filter(S=>S.kind==="artifact").length,findings:p.length},why:ee},failed:d.some(S=>S.code==="intent-plugin-failed")};function oe(){let S=(ae,ye)=>nt.runs.get(ae)?.commits.find(ct=>ct.sha===ye)?.hunks??null,A=(ae,ye)=>(nt.refs.get(ye)??[]).find(ct=>ct.id===ae)?.joinedBy??[],P=(ae,ye)=>{let ct=new Set(ae.flatMap(ft=>ye.flatMap(_r=>A(ft,_r))));return _Z.filter(ft=>ct.has(ft))},j=new Map,U=(ae,ye,ct)=>{let ft=pe.get(ae);if(!ft?.followed||!ft.head)return{squash:!1,origin:void 0};let _r=`${ae}\0${ye}`;return j.has(_r)||j.set(_r,yZ(i,ae,ft.head,ye,new Set(ft.commits))),{squash:!0,origin:j.get(_r)?.get(ct)}},L=K.map(ae=>{if(ae.sha===null)return{line:ae.line,sha:null,runs:[],narrowedBy:null,via:void 0};let ye=ae.sha,{squash:ct,origin:ft}=U(ye,ae.origPath,ae.origLine),_r=ct?ft?[ft]:[]:void 0,uc=(nt.refs.get(ye)??[]).filter(Dt=>!ft||Dt.joinedBy.some(qo=>qo!=="squash")||(Dt.via??[]).includes(ft)).map(Dt=>Dt.id),vn=uc.filter(Dt=>S(Dt,ye)!==null);if(vn.length===0)return{line:ae.line,sha:ye,runs:uc,narrowedBy:null,via:_r};let Xh=vn.filter(Dt=>S(Dt,ye).some(qo=>qo.path===ae.origPath&&qo.start<=ae.origLine&&ae.origLine<=qo.end));return{line:ae.line,sha:ye,runs:Xh.length>0?Xh:uc.filter(Dt=>!vn.includes(Dt)),narrowedBy:"hunks",via:_r}}),re=[];for(let ae of L){let ye=re[re.length-1],ct=ae.via;if(ye&&ye.end===ae.line-1&&ye.sha===ae.sha&&ye.narrowedBy===ae.narrowedBy&&ye.runs.join("\0")===ae.runs.map(ft=>`run:${ft}`).join("\0")&&ye.via?.join("\0")===ct?.join("\0")){ye.end=ae.line;continue}re.push({start:ae.line,end:ae.line,commit:ae.sha?`commit:${ae.sha}`:null,sha:ae.sha,runs:ae.runs.map(ft=>`run:${ft}`),narrowedBy:ae.narrowedBy,joinedBy:ae.sha?P(ae.runs,[ae.sha]):[],...ct?{via:ct}:{}})}let me=ae=>{let ye=[];for(let ct of ae){let ft=ye[ye.length-1];ft&&ft.end===ct-1?ft.end=ct:ye.push({start:ct,end:ct})}return ye},Be=[...c.values()].filter(ae=>ae.kind==="decision"),Gt=ae=>L.filter(ye=>ye.sha!==null&&E(we.get(ye.sha)??{contracts:[],authorship:[],decisions:[],carries:[]},ae)).length,it=["carried","path","contract","issue","member","related"],lr=Be.map(ae=>{let ye=Gt(ae),ct=ye>0||C===null&&T.some(vn=>E(we.get(vn.sha)??{contracts:[],authorship:[],decisions:[],carries:[]},ae)),ft=new Set(ae.constrains.map(vn=>vn.granularity)),_r=ct?"carried":["path","contract","issue","member"].find(vn=>ft.has(vn))??"related",uc=Math.max(0,...ae.constrains.filter(vn=>vn.granularity==="path").map(vn=>vn.entry.length));return{d:ae,entry:{decision:ae.id,relevance:_r,current:ae.supersededBy===null,closed:ae.closed,lines:ye},specificity:uc}});lr.sort((ae,ye)=>Number(ye.entry.current)-Number(ae.entry.current)||it.indexOf(ae.entry.relevance)-it.indexOf(ye.entry.relevance)||ye.entry.lines-ae.entry.lines||Number(ye.entry.closed)-Number(ae.entry.closed)||ye.specificity-ae.specificity||(ye.d.decidedIn?.date??"").localeCompare(ae.d.decidedIn?.date??"")||ae.d.id.localeCompare(ye.d.id));let Tp=lr.map(ae=>ae.entry),wn=[...c.values()].filter(ae=>ae.kind==="run"),Bl=(ae,ye,ct)=>{let ft=nt.runs.get(ae.run),_r=u.filter(Dt=>Dt.kind==="worked-on"&&Dt.from===ae.id).map(Dt=>c.get(Dt.to)),uc=ft?.unit?_r.find(Dt=>Dt?.kind==="work"&&Dt.record===ft.unit.id):void 0,vn=new Set;for(let Dt of _r)if(Dt?.kind==="decision"&&vn.add(Dt.id),Dt?.kind==="work")for(let qo of u)qo.kind==="implements"&&qo.from===Dt.id&&vn.add(qo.to);let Xh=ct.map(Dt=>Dt.slice(7));return{run:ae.id,lines:ye,commits:ct,unit:ft?.unit?{id:ft.unit.id,kind:ft.unit.kind,node:uc?.id??null}:null,decisions:[...vn],joinedBy:P([ae.run],Xh)}},xi;if(C!==null){let ae=new Map;for(let ye of L)for(let ct of ye.runs){let ft=ae.get(ct)??ae.set(ct,{lines:0,commits:new Set}).get(ct);ft.lines++,ft.commits.add(`commit:${ye.sha}`)}xi=[...ae].map(([ye,ct])=>({n:c.get(`run:${ye}`),t:ct})).filter(ye=>ye.n!==void 0).sort((ye,ct)=>ct.t.lines-ye.t.lines||(ct.n.startedAt??"").localeCompare(ye.n.startedAt??"")||ye.n.run.localeCompare(ct.n.run)).map(ye=>Bl(ye.n,ye.t.lines,[...ye.t.commits]))}else xi=wn.sort((ae,ye)=>(ye.startedAt??"").localeCompare(ae.startedAt??"")||ae.run.localeCompare(ye.run)).map(ae=>Bl(ae,0,u.filter(ye=>ye.kind==="made-by"&&ye.to===ae.id).map(ye=>ye.from)));let cc=Tp.some(ae=>ae.current&&ae.relevance!=="related"),lc=[];cc||lc.push({code:"intent-why-no-decision",message:z?`no current decision governs ${o.path}, and none is carried out by what made its lines`:`no record kind was read, so no decision can account for ${o.path}`});let Cr=L.filter(ae=>ae.sha!==null);(C!==null?Cr.length>0&&Cr.every(ae=>ae.runs.length===0):T.length>0&&wn.length===0)&&lc.push({code:"intent-why-no-run",message:`no agent run is joined to the commits that made ${C!==null?"the current lines of ":""}${o.path}`});let Zi=L.filter(ae=>ae.sha===null).map(ae=>ae.line);Zi.length>0&&lc.push({code:"intent-why-uncommitted",message:`${Zi.length} ${Zi.length===1?"line is":"lines are"} not committed yet`,lines:me(Zi)});let Ms=L.filter(ae=>ae.runs.length>1).map(ae=>ae.line);return Ms.length>0&&lc.push({code:"intent-why-run-ambiguous",message:`${Ms.length} ${Ms.length===1?"line comes":"lines come"} from a commit several runs made, and no run's recorded hunks say which wrote ${Ms.length===1?"it":"them"}`,lines:me(Ms)}),{lines:C,blame:re,decisions:Tp,runs:xi,explained:cc,gaps:lc}}}var Kee,Jee,e1,pTe,fTe,mTe,tn,hTe,Xee,kTe,xTe,Vee,z$=v(()=>{"use strict";_t();zd();PD();Gv();co();jg();gZ();po();mn();ko();QI();WD();Fk();vQ();xQ();IM();Zt();Dd();Qc();ci();xd();Kee=1,Jee="https://intentius.io/chant/schemas/workspace/intent/v1/intent.schema.json",e1=["intent-commit-undecided","intent-commit-bare","intent-pin-drifted","intent-pin-missing","intent-pin-stale","intent-artifact-unpinned","intent-decision-superseded-live","intent-decision-provisional","intent-decision-contested","intent-constraint-coarse","intent-constraint-lost","intent-evidence-unpinned","intent-trailer-unverified","intent-region-unconstrained","intent-decision-unimplemented","intent-work-blocked","intent-work-open-decided-code","intent-commit-join-conflict"],pTe=["intent-history-shallow","intent-plugin-failed","squash-unfollowed"],fTe=[...lo,"kind-unreadable","kind-invalid","schema-unreadable","schema-id-mismatch","schema-invalid","location-missing","intent-region-invalid","intent-record-unknown","intent-symbol-unsupported","intent-symbol-unknown","intent-symbol-ambiguous"],mTe=["intent-why-no-decision","intent-why-no-run","intent-why-uncommitted","intent-why-run-ambiguous"],tn=class extends Error{constructor(n,i){super(i);this.code=n;this.name="IntentError"}};hTe=/^0+$/;Xee=e=>Uee==="/"?e:e.split(Uee).join("/");kTe=/^[0-9a-f]{64}$/,xTe=/^([A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+)#([0-9]+)$/,Vee=["missing","drifted","stale","pinned"]});var o1={};_e(o1,{RECORDS_SINCE_ERROR_CODES:()=>PTe,RECORDS_SINCE_OUTPUT_SCHEMA_ID:()=>r1,RECORDS_SINCE_REASON_CODES:()=>OTe,SINCE_CHANGE_KINDS:()=>i1,compareRecords:()=>nte,formatSince:()=>NTe,queryRecordsSince:()=>_Te});import{realpathSync as ETe}from"node:fs";import{relative as ATe}from"node:path";async function _Te(e){let t=(n,i)=>({$schema:r1,contract:Ls,error:{code:n,message:i}});try{let n=await TTe(e),i=DTe(e.cwd,n?n.since:e.since,n?.session.id),r=n?n.at??void 0:e.at,o=await Ns({kind:e.kind,at:r,cwd:e.cwd}),s;try{s=(await Ns({kind:e.kind,at:i,cwd:e.cwd})).result.records}catch(c){if(!(c instanceof Ve)||c.code!=="location-missing")throw c;s=[]}let a=nte(o.loaded.kind,s,o.result.records),l=Object.fromEntries(i1.map(c=>[c,a.filter(u=>u.change===c).length]));return{$schema:r1,contract:Ls,kind:ITe(o.loaded,o.root),since:i,at:o.at,...n?{session:n.session}:{},changes:a,summary:l}}catch(n){if(n instanceof Op||n instanceof Ve)return t(n.code,n.message);throw n}}function ITe(e,t){return{name:e.kind.name,schema:e.kind.schema.id,file:ATe(t,e.file).split("\\").join("/")}}async function TTe(e){let t=Un(Tn(e.cwd));if(!t||!cJ.test(e.since))return null;let n=await hg(e.cwd,[e.kind]);for(let i of n){let r;try{r=(await Ns({kind:i.file,cwd:e.cwd})).result.records}catch(p){if(p instanceof Ve)continue;throw p}let o=r.find(p=>p.id===e.since);if(!o)continue;let s=i.kind.session,a=p=>p!==void 0&&typeof o.data?.[p]=="string"?o.data[p]:null,l=o.state!==null&&(i.kind.closedStates??[]).includes(o.state),c={id:o.id,path:o.path,state:o.state,sinceFrom:"opened-rev",atFrom:"working-tree",reasons:[]},u=a(s.openedRev);if(u===null&&(u=kk(t,o.path,["--diff-filter=A"])[0]??null,c.sinceFrom="history",u===null))throw new Op("since-rev-unknown",`session ${o.id} (${o.path}) names no commit it opened at${s.openedRev?` in ${s.openedRev}`:""}, and no commit added its file`);let d=null;if(e.at!==void 0)d=e.at,c.atFrom="at";else if(l){let p=a(s.closedRev);p!==null&&/^[0-9a-f]{40,64}$/.test(p)?(d=kk(t,o.path,[`${p}..HEAD`]).slice(-1)[0]??null,c.atFrom=d===null?"working-tree":"close-commit"):(d=kk(t,o.path,["-1"])[0]??null,c.atFrom=d===null?"working-tree":"history")}else c.reasons.push({code:"since-session-open",message:`session ${o.id} is ${o.state??"not closed"}, so it has no closing revision, and the comparison runs to the working tree`});return{since:u,at:d,session:c}}try{return Xc(t,e.since),null}catch(i){if(!(i instanceof Ve))throw i}if(n.length===0)return null;throw new Op("since-session-unknown",`--since ${e.since} names no commit, and no ${[...new Set(n.map(i=>i.kind.name))].join(" or ")} record has that id`)}function DTe(e,t,n){let i=e;try{i=ETe(e)}catch{}let r=Un(i);if(!r)throw new Ve("not-a-git-repository","--since reads git objects, and this directory is not in a git repository");try{return Xc(r,t)}catch(o){throw o instanceof Ve&&o.code==="revision-unknown"?new Op("since-rev-unknown",n?`session ${n} names ${t}, which is no commit in this repository`:`--since ${t} names no commit in this repository`):o}}function ete(e){let t=new Map;for(let n of e)n.id!==null&&!t.has(n.id)&&t.set(n.id,n);return t}function tte(e,t){let n=e.session?e.session.verdicts:e.reviews?.field??CTe,i=t.data?.[n];if(!Array.isArray(i))return[];let r=s=>typeof s=="string"?s:void 0,o=[];return i.forEach((s,a)=>{if(s===null||typeof s!="object"||Array.isArray(s))return;let l=s,c=r(e.session?l.principal:l.reviewer)??null,u=r(l.verdict)??null,d=r(l.record),p=r(l.session);o.push({key:JSON.stringify([c,u,r(l.on)??null,p??null,d??null]),index:a,principal:c,verdict:u,...d!==void 0?{record:d}:{},...p!==void 0?{session:p}:{}})}),o}function nte(e,t,n){let i=ete(t),r=ete(n),o=[...new Set([...i.keys(),...r.keys()])].sort(),s={new:[],removed:[],state:[],verdict:[],supersession:[],pin:[]};for(let a of o){let l=i.get(a),c=r.get(a);if(!l&&c&&s.new.push({change:"new",id:a,path:c.path,state:c.state}),l&&!c&&s.removed.push({change:"removed",id:a,path:l.path,state:l.state}),!c)continue;l&&l.state!==c.state&&s.state.push({change:"state",id:a,from:l.state,to:c.state});let u=new Map;for(let d of l?tte(e,l):[])u.set(d.key,(u.get(d.key)??0)+1);for(let d of tte(e,c)){let p=u.get(d.key)??0;if(p>0){u.set(d.key,p-1);continue}s.verdict.push({change:"verdict",id:a,principal:d.principal,verdict:d.verdict,index:d.index,...d.record!==void 0?{record:d.record}:{},...d.session!==void 0?{session:d.session}:{}})}if(c.supersededBy!==null&&(!l||l.supersededBy!==c.supersededBy)&&s.supersession.push({change:"supersession",id:c.supersededBy,supersedes:a}),l&&e.pins){let d=new Map(_m(l.data,e.pins.field).map(f=>[f.path,f.sha256])),p=new Map(_m(c.data,e.pins.field).map(f=>[f.path,f.sha256]));for(let f of[...new Set([...d.keys(),...p.keys()])].sort()){let g=d.get(f)??null,h=p.get(f)??null;g!==h&&s.pin.push({change:"pin",id:a,path:f,from:g,to:h})}}}return s.supersession.sort((a,l)=>a.id<l.id?-1:a.id>l.id?1:0),i1.flatMap(a=>s[a])}function NTe(e){let t=e.changes.map(i=>{switch(i.change){case"new":return`${i.id} new, ${i.state??"no state"} (${i.path})`;case"removed":return`${i.id} removed, was ${i.state??"no state"} (${i.path})`;case"state":return`${i.id} state ${i.from??"none"} to ${i.to??"none"}`;case"verdict":return`${i.id} verdict ${i.verdict??"-"} by ${i.principal??"-"}${i.record?` on ${i.record}`:""}${i.session?` in ${i.session}`:""}`;case"supersession":return`${i.id} supersedes ${i.supersedes}`;case"pin":return`${i.id} pin ${i.path} ${i.from?i.from.slice(0,12):"none"} to ${i.to?i.to.slice(0,12):"none"}`}}),n=e.summary;if(e.session){let i=e.session;t.unshift(`session ${i.id} (${i.state??"no state"}): opened at ${e.since.slice(0,8)} (${i.sinceFrom}), compared to ${e.at?`${e.at.slice(0,8)} (${i.atFrom})`:"the working tree"}`)}return t.push(`${e.changes.length} changes since ${e.since.slice(0,8)}${e.at?` to ${e.at.slice(0,8)}`:" to the working tree"}: ${n.new} new, ${n.removed} removed, ${n.state} state, ${n.verdict} verdicts, ${n.supersession} supersessions, ${n.pin} pins`),t.join(`
|
|
303
|
+
`)}var r1,PTe,OTe,i1,CTe,Op,s1=v(()=>{"use strict";po();go();mn();ko();xk();r1="https://intentius.io/chant/schemas/workspace/records-since/v1/records-since.schema.json",PTe=[...LK,"since-rev-unknown","since-session-unknown"],OTe=["since-session-open"],i1=["new","removed","state","verdict","supersession","pin"],CTe="reviews",Op=class extends Error{constructor(n,i){super(i);this.code=n}}});var zee={};_e(zee,{AGENT_ROLE:()=>q$,EXIT_BELOW_REQUIRED:()=>l1,RECORDS_CONTRACT_VERSION:()=>Ls,RECORDS_OUTPUT_SCHEMA_ID:()=>Jh,belowRequired:()=>u1,declaredKindFiles:()=>li,pinFile:()=>ite,pinRoot:()=>Ek,queryDeclaredRecords:()=>E$,queryRecords:()=>Vh,quorumOptionsFor:()=>Rg,readRecordsFor:()=>Ns,realpathOr:()=>Tn,runWorkspaceRecords:()=>HTe,runWorkspaceUnknown:()=>JTe,specOf:()=>rte});import{execFileSync as jTe}from"node:child_process";import{readFileSync as LTe,realpathSync as MTe}from"node:fs";import{dirname as Kh,join as a1,relative as Cp,resolve as c1,sep as qh}from"node:path";function FTe(e){try{return LTe(e,"utf-8")}catch{return null}}function rte(e){let t={kinds:[],records:[]};for(let n of e)if(!("error"in n||!n.kind.spec)){t.kinds.push(n.declared);for(let i of n.records)t.records.push({kind:n.kind.name,id:i.id,path:i.path,state:i.state,valid:i.valid,digest:i.digest,assets:i.assets})}return t}function li(e,t){let n;try{n=Qt(e,t)}catch(i){if(i instanceof ve&&i.code==="declaration-missing")return[];throw i}return Ni(Lt(n.tree)).map(i=>({declared:i,file:Ma(i,n.rootOnDisk)}))}async function E$(e,t){let n=[];for(let i of e){let r=await Vh({...t,kind:i.file});n.push({...r,declared:{member:i.declared.member,path:i.declared.path,name:i.declared.name}})}return{$schema:Jh,contract:Ls,kinds:n,...t.current&&!t.uncommitted?{spec:rte(n)}:{}}}function BTe(e){try{let t=Lt(e).quorum;if(t!==null)return{need:t,needFrom:"declaration"}}catch{}return{need:BK,needFrom:"default"}}async function Rg(e,t,n){if(!e.kind.reviews)return;let{checkVerdictSeal:i}=await Promise.resolve().then(()=>(Hd(),Ud));return{...BTe(t),agents:new Set((n.roles[q$]??[]).map(cn)),attestation:n.active,verifySeal:r=>i(n,r)}}function Ek(e,t){let n=gr(Kh(e));if(!n)return".";let i=Cp(t,Tn(n.dir)).split(qh).join("/");return i===""||i.startsWith("..")?".":i}function GTe(e,t,n){let i=r=>{try{return jTe("git",r,{cwd:e,encoding:"utf-8",stdio:["ignore","pipe","pipe"]}).split(`
|
|
304
|
+
`).filter(Boolean).map(Number)}catch{return[]}};return{fileChanged:r=>i(["log","-1","--format=%ct",t,"--",n==="."?r:`${n}/${r}`])[0]??null,recorded:r=>i(["log","--diff-filter=A","--format=%ct",t,"--",r])[0]??null}}async function Ns(e){let t=Tn(e.cwd),n=Un(t),i=n??t,r=await gn(e.kind,t),o=Ek(r.file,i),s=null,a=Od(i),l=$n(o==="."?i:a1(i,...o.split("/")));if(e.at!==void 0){if(!n)throw new Ve("not-a-git-repository","--at reads git objects, and this directory is not in a git repository");s=Xc(n,e.at),a=Ea(n,s),l=Iu(n,s,o==="."?"":o)}s===null&&e.overlay&&(a=await e.overlay(a,{loaded:r,root:i}));let c=n?GTe(n,s??"HEAD",o):void 0,u=await Rv(r,i,a),d=await $a(r,{root:i,source:a,current:!!e.current,assets:l,workspaceRoot:o,...c?{history:c}:{},...u?{subjects:u}:{}});return{loaded:r,root:i,top:n,at:s,workspaceRoot:o,tree:l,result:d}}async function Vh(e){if(e.uncommitted&&e.at!==void 0)throw new Error("--uncommitted reads the working tree and takes no --at");try{let t,{loaded:n,root:i,top:r,at:o,workspaceRoot:s,tree:a,result:l}=await Ns({...e,overlay:async(k,{loaded:R,root:$})=>{if(!R.kind.answers)return k;let{readLedgerAnswers:_,refreshLedger:T,withLedgerAnswers:C}=await Promise.resolve().then(()=>(Ag(),bD));e.fetchLedger&&await T(R.file);let K=await _({file:R.file,name:R.kind.name,dirRel:Cp($,R.dir).split(qh).join("/")||"."});return t=new Map([...K.byPath.values()].map(O=>[O.path,O.ledger])),C(k,K)}}),c=r?Gr(r,e.base):{commit:null,from:null},u=r?ai(r,c):ai(i,c),d=u.active?await zm():[],p=u6({repo:r,policy:u,at:o,paths:l.records.map(k=>k.path),attestors:d,...u.active?{revisit:await WTe(a,s,u,d)}:{}}),f=n.kind.reviews?await Promise.resolve().then(()=>(Hd(),Ud)):void 0,g=await Rg(n,a,u),h=[];for(let k of l.records){let R=p.get(k.path),$=R.returned?_v(u,R.returned.id):u,_=R.returned?await Rg(n,a,$):g;h.push({...k,provenance:R,..._?{quorum:Ev(n.kind,k,_)}:{},...f?zTe(n.kind,k,$,f.checkRecordSeal):{}})}if(t)for(let k of h)k.ledger=t.get(k.path)??null;if(n.kind.approval&&!n.kind.work&&r){let k=Q4(r,o??"HEAD",h.map(R=>R.path),n.kind);for(let R of h)R.decidedIn=k.get(R.path)??null}if(n.kind.work&&e.workGaps!==!1&&r&&await UTe(n,h,{root:i,workspaceRoot:s,at:e.at}),n.kind.work&&o===null&&r){let{activeWorkLeases:k}=await Promise.resolve().then(()=>(hl(),ZJ)),R=await k(n.file);for(let $ of h)$.id!==null&&($.lease=R.get($.id)??null)}if(n.kind.work?.answers){let[{workAnswers:k},{readLedgerAnswers:R,withLedgerAnswers:$}]=await Promise.all([Promise.resolve().then(()=>(xd(),TI)),Promise.resolve().then(()=>(Ag(),bD))]),_=await Ns({kind:c1(Kh(n.file),n.kind.work.answers),cwd:e.cwd,...e.at!==void 0?{at:e.at}:{},overlay:async(T,{loaded:C,root:K})=>$(T,await R({file:C.file,name:C.kind.name,dirRel:Cp(K,C.dir).split(qh).join("/")||"."}))}).catch(T=>{if(!(T instanceof Ve))throw T});if(_){let T=k(_.result.records,h.flatMap(C=>C.id!==null?[C.id]:[]));for(let C of h)C.id!==null&&(C.answers=T.get(C.id)??[])}}let b,w=h,x=l.summary;if(o===null&&r){let{head:k,...R}=XT(r,e.base),$=Cp(i,n.dir).split(qh).join("/")||".",_=h.filter(O=>!O.ledger),{states:T,deleted:C}=nJ(r,k,$,h.map(O=>O.path),new RegExp(n.kind.location.match));for(let O of _)O.worktree=T.get(O.path)??"new";let K=bk(r);for(let O of _)O.lastWrite=K(O.path,FTe(a1(r,...O.path.split("/"))));b={branch:R.branch,head:k,base:R.base,baseFrom:R.baseFrom,deleted:C},e.uncommitted&&(w=_.filter(O=>O.worktree!=="committed"),x={...x,total:w.length,valid:w.filter(O=>O.valid).length,invalid:w.filter(O=>!O.valid).length})}else if(e.uncommitted&&!r)throw new Ve("not-a-git-repository","--uncommitted compares the working tree with HEAD, and this directory is not in a git repository");return{$schema:Jh,contract:Ls,kind:{name:n.kind.name,schema:n.kind.schema.id,file:Cp(i,n.file).split("\\").join("/"),format:n.kind.format,spec:n.kind.spec===!0},at:o,workspaceRoot:s,current:!!e.current,uncommitted:!!e.uncommitted,...b?{checkout:b}:{},trust:{base:c.commit,baseFrom:c.from,active:u.active,signersPath:u.signersPath,problems:u.problems},records:w,summary:x,...l.decisions?{decisions:l.decisions}:{}}}catch(t){if(!(t instanceof Ve))throw t;return{$schema:Jh,contract:Ls,error:{code:t.code,message:t.message}}}}async function WTe(e,t,n,i){let{readReturns:r,returnedProvenance:o}=await Promise.resolve().then(()=>(lZ(),cZ)),{returns:s}=r(e);if(s.length===0)return;let a=t==="."?"":`${t}/`;return(l,c)=>{if(!l.startsWith(a))return;let u=l.slice(a.length),d=s.filter(f=>f.paths[u]!==void 0);if(d.length===0||e.stat(u)!=="file")return;let p=Buffer.from(e.bytes?e.bytes(u):e.read(u));for(let f of d){let g=o(n,i,f,u,p,c);if(g)return g}}}function zTe(e,t,n,i){if(t.data===null)return{};let r=e.reviews.decider,o=typeof t.data[r]=="string"&&t.data[r].trim()!==""?t.data[r]:null,{attested:s,...a}=i(n,{record:t.id,digest:t.digest,author:o,authorField:r,state:t.state,seal:t.data[on]});return n.active&&o!==null&&s!==!0&&t.warnings.push({code:"record-unattested",message:`an attestation policy is active at base, and ${a.message}`}),{attested:s,attestation:a}}async function UTe(e,t,n){let i=e.kind.work,r=new Map;for(let u of t){if(u.id===null||u.state!==i.done)continue;let d=u.data?.source;if(d===null||typeof d!="object"||Array.isArray(d))continue;let{finding:p,region:f}=d;typeof p!="string"||typeof f!="string"||r.set(f,[...r.get(f)??[],u])}if(r.size===0)return;let o=n.workspaceRoot==="."?n.root:a1(n.root,...n.workspaceRoot.split("/")),s;try{s=li(o,n.at).map(u=>u.file)}catch(u){if(u instanceof ve)return;throw u}let a=[],l=new Set;for(let u of[...s,c1(Kh(e.file),i.decisions),e.file]){let d=Tn(u);l.has(d)||(l.add(d),a.push(u))}let{intentGraph:c}=await Promise.resolve().then(()=>(z$(),Qee));for(let[u,d]of r){let{doc:p}=await c({cwd:o,region:u,at:n.at,kinds:a});if(!("error"in p))for(let f of d){let g=p.nodes.find(b=>b.kind==="work"&&b.id===`record:${e.kind.name}/${f.id}`),h=g?.kind==="work"?g.warnings.find(b=>b.code==="work-done-gap-open"):void 0;h&&!f.warnings.some(b=>b.code===h.code)&&f.warnings.push(h)}}}function ite(e,t){let n=Tn(c1(t,e)),i=Un(Kh(n)),r=gr(Kh(n)),o=Tn(r?r.dir:i||t),s=Cp(o,n).split(qh).join("/");if(s.startsWith("..")||!_n(s))return{error:`${e} is not a file path inside the workspace at ${o}`};let a=PI($n(o),s);return a===void 0?{error:`${e} is not a file`}:{path:s,sha256:a}}async function HTe(e){let{args:t}=e;if(t.extraPositional==="new"||t.extraPositional==="amend"||t.extraPositional==="review"||t.extraPositional==="close")return(await Promise.resolve().then(()=>(vg(),DJ))).runRecordsWrite(e);if(t.extraPositional==="pin"){if(!t.extraPositional2)return console.error(fe({message:"pin needs the path of a file",hint:Ar})),1;let r=ite(t.extraPositional2,process.cwd());return"error"in r?(console.error(fe({message:r.error,hint:Ar})),1):(console.log(JSON.stringify(r,null,2)),0)}if(t.extraPositional)return console.error(fe({message:`chant workspace records takes no argument but pin, new, amend, review or close (got ${t.extraPositional})`,hint:Ar})),1;let n=KTe(t);if(n)return console.error(fe({message:n,hint:Ar})),1;if(!t.kind)return VTe(t);if(t.require!==void 0&&t.require!=="attested")return console.error(fe({message:`--require takes one level, attested, not ${JSON.stringify(t.require)}`,hint:Ar})),1;if(t.since!==void 0){if(t.current||t.require!==void 0||t.base!==void 0)return console.error(fe({message:"--since compares two revisions and takes no --current, --require or --base",hint:Ar})),1;let{formatSince:r,queryRecordsSince:o}=await Promise.resolve().then(()=>(s1(),o1)),s=await o({kind:t.kind,since:t.since,at:t.at,cwd:process.cwd()});return t.json?console.log(JSON.stringify(s,null,2)):"error"in s?console.error(fe({message:`${s.error.code}: ${s.error.message}`,hint:Ar})):console.log(r(s)),"error"in s?1:0}let i=await Vh({kind:t.kind,current:t.current,uncommitted:t.uncommitted,at:t.at,base:t.base,cwd:process.cwd(),fetchLedger:!0});if(t.json?console.log(JSON.stringify(i,null,2)):"error"in i?console.error(fe({message:`${i.error.code}: ${i.error.message}`,hint:Ar})):console.log(ote(i.records,i.summary,i.at,i.checkout)),"error"in i)return 1;if(t.require){let r=u1(i.records,t.require);if(r.length>0)return console.error(fe({message:`${r.length} of ${i.records.length} records are not ${t.require}: ${r.slice(0,5).map(o=>`${o.path} (${o.provenance.level})`).join(", ")}${r.length>5?", ...":""}`,hint:i.trust.active?"run with --json to see each record's reason":`there is no signers file (${i.trust.signersPath}) at base`})),l1}return 0}async function VTe(e){if(e.require!==void 0&&e.require!=="attested")return console.error(fe({message:`--require takes one level, attested, not ${JSON.stringify(e.require)}`,hint:Ar})),1;let t;try{t=li(process.cwd(),e.at)}catch(i){if(!(i instanceof ve))throw i;let r=`${i.describe()}; without --kind, the declaration names the record kinds`;return e.json&&(i.code==="not-a-git-repository"||i.code==="revision-unknown")?console.log(JSON.stringify({$schema:Jh,contract:Ls,error:{code:i.code,message:r}},null,2)):console.error(fe({message:`${i.code}: ${r}`,hint:Ar})),1}if(t.length===0)return console.error(fe({message:"--kind <kind file> is required",hint:Ar})),1;if(e.since!==void 0)return qTe(t,e);let n=await E$(t,{current:e.current,uncommitted:e.uncommitted,at:e.at,base:e.base,cwd:process.cwd(),fetchLedger:!0});e.json&&console.log(JSON.stringify(n,null,2));for(let i of e.json?[]:n.kinds){if("error"in i){console.error(fe({message:`${i.declared.path}: ${i.error.code}: ${i.error.message}`,hint:Ar}));continue}console.log(`${i.declared.name??i.kind.name} (${i.declared.path})`),console.log(ote(i.records,i.summary,i.at,i.checkout))}if(n.kinds.some(i=>"error"in i))return 1;if(e.require){let i=n.kinds.filter(s=>!("error"in s)),r=i.flatMap(s=>s.records),o=u1(r,e.require);if(o.length>0){let s=i.find(a=>!a.trust.active);return console.error(fe({message:`${o.length} of ${r.length} records are not ${e.require}: ${o.slice(0,5).map(a=>`${a.path} (${a.provenance.level})`).join(", ")}${o.length>5?", ...":""}`,hint:s?`there is no signers file (${s.trust.signersPath}) at base`:"run with --json to see each record's reason"})),l1}}return 0}async function qTe(e,t){if(t.current||t.require!==void 0||t.base!==void 0)return console.error(fe({message:"--since compares two revisions and takes no --current, --require or --base",hint:Ar})),1;let{formatSince:n,queryRecordsSince:i,RECORDS_SINCE_OUTPUT_SCHEMA_ID:r}=await Promise.resolve().then(()=>(s1(),o1)),o=[];for(let s of e){let a=await i({kind:s.file,since:t.since,at:t.at,cwd:process.cwd()});o.push({...a,declared:{member:s.declared.member,path:s.declared.path,name:s.declared.name}})}t.json&&console.log(JSON.stringify({$schema:r,contract:Ls,kinds:o},null,2));for(let s of t.json?[]:o){if("error"in s){console.error(fe({message:`${s.declared.path}: ${s.error.code}: ${s.error.message}`,hint:Ar}));continue}console.log(`${s.declared.name??s.kind.name} (${s.declared.path})`),console.log(n(s))}return o.some(s=>"error"in s)?1:0}function Tn(e){try{return MTe(e)}catch{return e}}function u1(e,t){return e.filter(n=>n.provenance.level!==t)}function KTe(e){if(e.uncommitted){if(e.at!==void 0)return"--uncommitted reads the working tree against HEAD, and takes no --at";if(e.since!==void 0)return"--uncommitted takes no --since: --since compares two revisions"}}function ote(e,t,n,i){let r=[],o=Math.max(2,...e.map(a=>(a.id??"-").length)),s=Math.max(5,...e.map(a=>(a.state??"-").length));for(let a of e){let l=typeof a.data?.title=="string"?a.data.title:a.path,c=a.valid?"":" INVALID",u=a.supersededBy?` superseded by ${a.supersededBy}`:"",d=a.remediatedBy.length>0?` remediated by ${a.remediatedBy.join(", ")}`:"",p=a.provenance.level==="attested"?` attested by ${a.provenance.principal}`:"",f=a.attested===!0?` sealed by ${(a.data?.[on]).signer}`:"",g=a.worktree==="new"||a.worktree==="modified"?` (${a.worktree}, uncommitted)`:"",h=a.ledger?` (held on ${a.ledger})`:"";if(r.push(`${(a.id??"-").padEnd(o)} ${(a.state??"-").padEnd(s)} ${l}${u}${d}${p}${f}${g}${h}${c}`),a.ready!==void 0){let w=(a.blockedBy??[]).map($=>`${$.id} (${$.state??"unknown"})`).join(", "),x=(a.implements??[]).map($=>`${$.id} (${$.state??"unknown"})`).join(", "),k=a.lease?`held by ${a.lease.holder} until ${a.lease.expiresAt}`:"",R=[a.ready?"ready":w?`blocked by ${w}`:"",x?`implements ${x}`:"",k].filter(Boolean).join("; ");R&&r.push(`${" ".repeat(o+2)}${R}`)}for(let w of a.reasons)r.push(`${" ".repeat(o+2)}${w.code}: ${w.message} (${a.path})`);for(let w of a.warnings)r.push(`${" ".repeat(o+2)}warning ${w.code}: ${w.message} (${a.path})`);let b=a.quorum;if(b&&b.counted.length+b.notCounted.length>0){let w=b.metWithObjections?"met with objections":b.met?"met":"not met",x=b.openConcerns.length>0?`, ${b.openConcerns.length} open ${b.openConcerns.length===1?"concern":"concerns"}`:"";r.push(`${" ".repeat(o+2)}quorum ${b.agreed} of ${b.need} agreed, ${w}; ${b.notCounted.length} not counted${x}`)}}for(let a of i?.deleted??[])r.push(`${"-".padEnd(o)} ${"-".padEnd(s)} ${a} (deleted, uncommitted)`);if(r.push(`${t.total} records${n?` at ${n.slice(0,8)}`:""}: ${t.valid} valid, ${t.invalid} invalid, ${t.superseded} superseded`),i){let a=i.branch??"a detached HEAD",l=i.head?` at ${i.head.slice(0,8)}`:" with no commits",c=i.base?`, forked from ${i.base.slice(0,8)} of ${i.baseFrom}`:"";r.push(`working tree on ${a}${l}${c}`)}return r.join(`
|
|
305
|
+
`)}async function JTe(e){let t=e.args.path&&e.args.path!=="."?e.args.path:"";return console.error(fe({message:t?`Unknown workspace subcommand: ${t}`:"chant workspace needs a subcommand",hint:'Workspace subcommands: adopt-lineage, audit, build, check, evidence, graph, hash-index, init, lineage, lint, ls, pin, records, signers, status, upgrade, verify, versions, work. Run "chant --help" for their options.'})),1}var Ls,Jh,Ar,l1,q$,ko=v(()=>{"use strict";Kn();Si();po();eJ();go();_t();zd();ci();mn();QT();mg();Zt();Dd();Qc();fs();Ls=1,Jh="https://intentius.io/chant/schemas/workspace/records/v1/records.schema.json",Ar="chant workspace records [--kind <kind file>] [--current] [--uncommitted | --at <rev>] [--base <rev>] [--require attested] [--json] | chant workspace records [--kind <kind file>] --since <rev|session id> [--at <rev>] [--json] | chant workspace records pin <path> | chant workspace records new|amend|review|close (#2670, #2693)",l1=2,q$="agent"});var cM={};_e(cM,{POINTS_WRITE_CONTRACT_VERSION:()=>Fo,POINTS_WRITE_ERROR_CODES:()=>YTe,POINTS_WRITE_SCHEMA_ID:()=>Bo,PointsWriteError:()=>bt,STEWARD_HARNESS:()=>p1,answerFields:()=>Zh,answerKindFiles:()=>f1,answerPoint:()=>eM,askPoint:()=>QL,askedByOf:()=>K$,questionView:()=>xp,reasonFields:()=>J$,retractAnswer:()=>tM,tallyQuorum:()=>cte});import{writeFileSync as ZTe}from"node:fs";function XTe(e){if(!Array.isArray(e.retractions))return[];let t=i=>typeof i=="string"?i:null,n=i=>Array.isArray(i)?i.filter(r=>typeof r=="string"):[];return e.retractions.filter(i=>i!==null&&typeof i=="object"&&!Array.isArray(i)).map(i=>({answer:typeof i.answer=="string"||typeof i.answer=="boolean"?i.answer:null,decider:i.decider!==null&&typeof i.decider=="object"&&!Array.isArray(i.decider)?i.decider:{},answeredBy:n(i.answered_by),answeredOn:t(i.answered_on),answerNote:t(i.answer_note),answerRelayedBy:t(i.answer_relayed_by),by:n(i.by),on:t(i.on),note:t(i.note)}))}function K$(e){let t=e.source;if(t===null||typeof t!="object"||Array.isArray(t))return null;let n=t;if(n.harness!==p1)return null;let i=n.client,r=i&&typeof i.name=="string"?i.name:null;if(r===null)return null;let o=n.session,s=typeof o=="string"?o:o&&typeof o=="object"&&typeof o.id=="string"?o.id:null;return{steward:r,run:s}}function xp(e,t,n=null){let i=e.data;if(i===null||e.id===null)return null;let r=p=>typeof p=="string"?p:null,o=p=>typeof p=="number"?p:null,s=["escalated","proposed","answered"].find(p=>p===e.state)??"escalated",a=i.decider!==null&&typeof i.decider=="object"&&!Array.isArray(i.decider)?i.decider:{},l=Array.isArray(i.escalations)?i.escalations:[],c=typeof i.answer=="string"||typeof i.answer=="boolean"?i.answer:null,u=null;if(a.kind==="model")u={answer:c,confidence:o(i.confidence),threshold:o(i.threshold),model:r(a.model),backend:r(a.backend),observed:!0,reason:r(i.reason)};else{let p=[...l].reverse().find(f=>f.kind==="model"&&f.answer!==void 0&&f.answer!==null);p&&(u={answer:p.answer??null,confidence:p.confidence??null,threshold:p.threshold??null,model:p.model??null,backend:p.backend??null,observed:!1,reason:typeof p.model_reason=="string"?p.model_reason:null})}let d=Array.isArray(i.constrains)?i.constrains.filter(p=>typeof p=="string"):[];return{id:e.id,path:e.path,point:r(i.point)??"",title:r(i.title)??"",subject:d[0]??null,state:s,open:s!=="answered",questionType:r(i.question_type)??"",candidates:Array.isArray(i.candidates)?i.candidates:[],inputs:i.inputs!==null&&typeof i.inputs=="object"&&!Array.isArray(i.inputs)?i.inputs:{},inputsHash:r(i.inputs_hash)??"",pointVersion:r(i.point_version)??"",current:t?Ra(t)===i.point_version:null,answer:c,decider:a,probabilities:i.probabilities!==null&&typeof i.probabilities=="object"?i.probabilities:null,confidence:o(i.confidence),threshold:o(i.threshold),reason:a.kind==="model"?r(i.reason):null,model:u,escalations:l,answeredBy:Array.isArray(i.answered_by)?i.answered_by.filter(p=>typeof p=="string"):[],askedOn:r(i.asked_on),answeredOn:r(i.answered_on),note:r(i.note),relayedBy:r(i.relayed_by),retractions:XTe(i),asked:Nm(i)??null,askedBy:K$(i),ledger:n,valid:e.valid,warnings:e.warnings}}function _p(e,t){if(t instanceof bt||t instanceof he||t instanceof Ve||t instanceof hs||t instanceof ja)return{$schema:Bo,contract:Fo,verb:e,error:{code:t.code,message:t.message}};if(t instanceof ve)return{$schema:Bo,contract:Fo,verb:e,error:{code:"points-undeclared",message:`the declaration can't be read: ${t.code}: ${t.message}`}};throw t}async function f1(e,t){if(t!==void 0)return[Kd(t,e)];let n=[];for(let i of li(e))try{(await gn(i.file)).kind.answers&&n.push(i.file)}catch(r){if(!(r instanceof Ve))throw r}return n}async function ste(e,t){let n=await $s(e,t);if(!n.loaded.kind.answers)throw new bt("points-undeclared",`the ${n.loaded.kind.name} kind has no answers block, so it holds no answers to decision points`);let i=Ad(n.loaded,n.root),r=Pd(n.source,i);if("error"in r)throw new bt("points-invalid",r.error);return{o:n,points:r.points,pointsFile:i}}function g1(e,t,n,i,r){let o=n==="escalated"?"open for people":n==="proposed"?`${ac(i,e.question.type)}, proposed`:ac(i,e.question.type);return`${r?r.question:e.title}${t?` (${t})`:""}: ${o}`}function h1(e,t,n){let i=Sd(e,n),r=s=>i.type==="score"?"":i.criteria?.[String(s)]??"",o=mo(i).map(s=>`- ${ac(s,i.type)}${r(s)?`: ${r(s)}`:""}`);return["",`# ${t}`,"",i.instructions.trim(),"",...o,""].join(`
|
|
306
|
+
`)}async function QTe(e,t,n){if(e.length===0)throw new bt("points-undeclared","no record kind with an answers block is declared: name one with --kind, or declare one in chant.workspace.json");let i=[];for(let r of e){let o=await ste(r,n),s=Rd(o.points,t);if(s)return{...o,point:s};i.push(...Object.keys(o.points))}throw new bt("point-unknown",`no points file declares ${JSON.stringify(t)}${i.length?` (the points are ${i.join(", ")})`:""}`)}function eDe(e,t,n,i){if(!t.adhoc){if(n!==void 0)throw new bt("point-candidates-invalid",`${e} declares its candidates, so the ask gives none: --candidates is for an ad-hoc point`);return}if(n===void 0)throw new bt("point-candidates-invalid",`${e} is an ad-hoc point, so each ask gives the question and its candidates: --candidates <file|-|json>`);let r=MI(t,n);if("problems"in r)throw new bt("point-candidates-invalid",`the candidates for ${e}, a ${t.question.type} question: ${r.problems.join("; ")}`);if(!Zh(i.schema).asked)throw new bt("answer-field-unsupported",`the ${i.kind.name} kind's schema has no asked field, so an ad-hoc question's text and candidates can't be kept: copy point-answer.schema.json from @intentius/chant anew`);return r.asked}function tDe(e,t,n){if(n===null||typeof n!="object"||Array.isArray(n))throw new bt("point-inputs-invalid",`the inputs to ${e} must be a JSON object`);let i=Object.keys(t.inputs),r=Object.keys(n).filter(o=>!i.includes(o));if(r.length>0)throw new bt("point-inputs-invalid",`${e} reads ${i.join(", ")}, and the inputs also give ${r.join(", ")}`);return n}async function y1(e,t,n,i,r,o,s){let a=await Sk(e,t,n,i,s.source),l=s.ledger.byPath.get(n);if(s.onLedger){if(o)return{warnings:a,ledger:l?.ledger??null};try{let{ledger:c}=await yD(s.ledger,n,i,s.message,l?.sha??null);return{warnings:a,ledger:c}}catch(c){throw c instanceof Vt?new bt("record-id-taken",`${n} was written on chant/lifecycle by another ask or answer at the same time: ask again to read it`):c}}if(!o)try{ZTe($o(e,n),i,r?{flag:"wx"}:void 0),ks(e.root,[{path:n,text:i}],s.who)}catch(c){throw c.code==="EEXIST"?new bt("record-id-taken",`${n} was written by another ask at the same time: ask again to read it`):c}return{warnings:a,ledger:null}}async function ate(e){let t=await Sg({file:e.loaded.file,name:e.loaded.kind.name,dirRel:e.dirRel}),n=Eg(e.source,t);return{ledger:t,source:n,before:await zi(e,n)}}function b1(e,t){let n=Object.fromEntries(Object.entries(t).filter(([,i])=>i!==void 0));return Wa(n,Zd(n,{properties:e.loaded.schema.properties}))}function J$(e){let t=(i,r)=>i!==null&&typeof i=="object"&&Object.prototype.hasOwnProperty.call(i,r),n=e.definitions??e.$defs;return{top:t(e.properties,"reason"),escalation:t(n?.escalation?.properties,"model_reason")}}function nDe(e,t){return t.escalation?e:e.map(({model_reason:n,...i})=>i)}function rDe(e,t){let n=e.escalations.length>0?nDe(e.escalations,t):void 0;if(e.status==="proposed"){let i=t.top?e.reason:void 0;return{state:"proposed",answer:e.answer,decider:e.decider,probabilities:e.probabilities,confidence:e.confidence,threshold:e.threshold,reason:i,escalations:n}}return e.status==="answered"?{state:"answered",answer:e.answer,decider:e.decider,escalations:n}:{state:"escalated",decider:e.decider,escalations:n}}async function QL(e){try{return await vo(e.cwd,{verb:"points ask",by:e.steward?.name??null},e.dryRun,()=>iDe(e))}catch(t){return _p("ask",t)}}async function iDe(e){try{let t=e.steward?void 0:wo(),n=e.steward??(t?{name:t.steward,...t.run?{run:t.run}:{}}:void 0),i=e.store!==void 0?e.store==="ledger":n!==void 0,r=await f1(e.cwd,e.kind),{o,point:s}=await QTe(r,e.point,e.cwd),a=tDe(e.point,s,e.inputs),l=eDe(e.point,s,e.candidates,o.loaded),c=Ra(s),u=LI(e.point,c,a,l),d=FI(e.point,u);i&&!e.dryRun&&await Ak(o.loaded.file);let{ledger:p,source:f,before:g}=await ate(o),h=g.find(xe=>xe.id===d),b=xe=>p.byPath.get(xe.path)?.ledger??null,w=(xe,we)=>({$schema:Bo,contract:Fo,verb:"ask",kind:o.view,id:d,path:xe.path,reused:we.reused,written:we.written,dryRun:!!e.dryRun,question:xp(xe,s,we.ledger!==void 0?we.ledger:b(xe)),...we.text!==void 0?{text:we.text}:{}});if(h&&h.data!==null&&(h.state==="answered"||h.state==="proposed"))return w(h,{reused:!0,written:!1});if(h&&h.data!==null&&Array.isArray(h.data.retractions)&&h.data.retractions.length>0)return w(h,{reused:!0,written:!1});let x;try{x=await BI(e.point,{...s,question:Sd(s,l)},a,e.ask)}catch(xe){throw xe instanceof $d?new bt("point-decider-failed",xe.message):xe}if(h&&h.data!==null&&x.status==="escalated")return w(h,{reused:!0,written:!1});let k=e.on??m1(),R=x.status,$=x.status==="escalated"?void 0:x.answer,_=g1(s,e.subject,R,$,l),T=x.status==="proposed"?x.decider.model:void 0,C=n?{name:n.name}:e.client,K={via:e.via??"cli",...n?{harness:p1}:{},...C?{client:C}:{},...T?{model:T}:{},...n?.run?{session:{id:n.run}}:{}},O=b1(o,{id:d,title:_,point:e.point,point_version:c,question_type:s.question.type,candidates:mo(Sd(s,l)),asked:l,inputs:a,inputs_hash:u,constrains:e.subject!==void 0?[e.subject]:h?.data?.constrains,...rDe(x,J$(o.loaded.schema)),asked_on:k,answered_on:R==="answered"?k:void 0,source:K}),pe=h?h.path:o.dirRel==="."?`${d}.md`:`${o.dirRel}/${d}.md`,F=gl(O,h1(s,_,l)),Q=i||p.byPath.has(pe),I=`Decision point ${e.point}: ${R}${e.subject?` (${e.subject})`:""}${n?`, asked by ${n.name}`:""}`,B=await y1(o,g,pe,F,!h,!!e.dryRun,{source:f,ledger:p,onLedger:Q,message:I,who:{verb:"points ask",by:n?.name??null}}),Z={...h??oDe(pe),id:d,path:pe,state:R,data:O,valid:!0,reasons:[],warnings:B.warnings};return w(Z,{reused:!1,written:!e.dryRun,ledger:B.ledger,...e.dryRun?{text:F}:{}})}catch(t){return _p("ask",t)}}function oDe(e){return{id:null,path:e,state:null,valid:!0,reasons:[],supersededBy:null,remediatedBy:[],data:null,assets:[],warnings:[],digest:""}}function Zh(e){let t=e.properties,n=i=>t!=null&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,i);return{note:n("note"),retractions:n("retractions"),relayedBy:n("relayed_by"),asked:n("asked")}}function sDe(e){if(!Un(e))return ps(null);try{return ai(e,Gr(e))}catch{return ps(null)}}function cte(e,t,n,i){let r=u=>new Set((n.roles[u]??[]).map(cn)),o=r(q$),s=i!==void 0?cn(i):void 0,a=[],l=new Set,c=[];for(let u of e){let d=cn(u);if(!(d===""||l.has(d))){if(l.add(d),s!==void 0&&d===s){c.push({name:u,why:"is the steward that asked"});continue}if(o.has(d)){c.push({name:u,why:"holds the agent role"});continue}if(t.roles&&!t.roles.some(p=>r(p).has(d))){c.push({name:u,why:`holds none of the roles ${t.roles.join(", ")}`});continue}a.push(u)}}return{counted:a,left:c,met:a.length>=t.count}}function lte(e,t){let n=wo();if(n)throw new bt("answer-in-steward-turn",`this is the steward ${n.steward}'s turn, and a steward never ${t} a decision point: a person ${t==="answers"?"answers":"retracts the answer to"} ${e} through hud or \`chant workspace points ${t==="answers"?"answer":"retract"}\` at a shell`)}async function ute(e,t,n){let i=await f1(e,t);if(i.length===0)throw new bt("points-undeclared","no record kind with an answers block is declared: name one with --kind, or declare one in chant.workspace.json");for(let r of i){let o=await ste(r,e);await Ak(o.o.loaded.file);let s=await ate(o.o),a=s.before.find(l=>l.id===n);if(a&&a.data!==null)return{opened:o,before:s.before,read:s,target:a}}throw new bt("record-not-found",`no answer record has id ${n}`)}function pte(e,t,n,i,r,o,s){let a=Xr(s),l=a?{counted:[],left:t.map(c=>({name:c,why:`was named over ${dte(s)}, where an answer is an agent's`})),met:!1}:cte(t,n,sDe(i),r);if(!l.met){let c=l.counted.length,u=l.left.length?`; not counted: ${l.left.map(p=>`${p.name}, who ${p.why}`).join("; ")}`:"",d=a?`: a person ${o==="answer"?"answers":"retracts it"} at a shell with \`chant workspace points ${o}\`, or through hud`:"";throw new bt("quorum-not-met",`${e} needs ${n.count} ${n.count===1?"person":"people"}${n.roles?` holding ${n.roles.join(" or ")}`:""} to ${o==="answer"?"answer":"retract an answer"}, and ${c} ${c===1?"counts":"count"}${c?` (${l.counted.join(", ")})`:""}${u}${d}`)}return l}function aDe(e){let t=[];for(let n of Array.isArray(e.constrains)?e.constrains:[]){if(typeof n!="string"||!n.startsWith("gate:"))continue;let i=n.slice(5),r=i.lastIndexOf("@"),o=r>0?i.slice(0,r):i,s=o.indexOf("/");s>0&&s<o.length-1&&t.push({op:o.slice(0,s),gate:o.slice(s+1)})}return t}async function fte(e,t,n,i,r){if(!Xr(i))return;let o=aDe(t);if(o.length===0)return;let{isNeverOverMcpGateOp:s}=await Promise.resolve().then(()=>(Oi(),Xz)),{readGateLedger:a}=await Promise.resolve().then(()=>(Mi(),oq)),l;for(let{op:c,gate:u}of o){let d=s(c);if(!d){let{pending:p}=await a(c,{cwd:n}).catch(()=>({pending:[]}));d=p.some(f=>f.gate===u&&f.neverOverMcp===!0)}if(!d){if(l===void 0){let{discoverOps:p}=await Promise.resolve().then(()=>(Wi(),HT));l=await p({cwd:n}).then(f=>f.ops).catch(()=>new Map)}d=!!l.get(c)?.config.neverOverMcp}if(d)throw new bt("answer-never-over-mcp",`${e} constrains gate "${u}" on "${c}", which is never resolved over ${dte(i)}, so its question is not ${r==="answers"?"answered":"retracted"} there either: a person ${r==="answers"?"answers":"retracts the answer to"} it at a shell with \`chant workspace points ${r==="answers"?"answer":"retract"} ${e}\`, or through hud`)}}async function eM(e){try{return await vo(e.cwd,{verb:"points answer",by:(e.by??[]).join(", ")||null},e.dryRun,()=>cDe(e))}catch(t){return _p("answer",t)}}async function cDe(e){try{lte(e.id,"answers"),ys(ho(e.cwd),e.by,"--by");let t=d1(e.relayedBy);t!==void 0&&ys(ho(e.cwd),[t],"--relayed-by");let n=await ute(e.cwd,e.kind,e.id),{opened:i,before:r,target:o}=n,s=n.read.ledger,{o:a}=i,l=o.data;if(o.state==="answered")throw new bt("record-closed",`${e.id} is answered, and an answer never changes in place: retract it with \`points retract ${e.id}\` and answer again, ask again with other inputs, or change the point, which asks the question anew`);let c=d1(e.note);if(c!==void 0&&!Zh(a.loaded.schema).note)throw new bt("answer-field-unsupported",`the ${a.loaded.kind.name} kind's schema has no note field, so ${e.id} can't keep the note: copy point-answer.schema.json from @intentius/chant anew`);if(t!==void 0&&!Zh(a.loaded.schema).relayedBy)throw new bt("answer-field-unsupported",`the ${a.loaded.kind.name} kind's schema has no relayed_by field, so ${e.id} can't record who relayed the answer: copy point-answer.schema.json from @intentius/chant anew`);let u=String(l.point),d=Rd(i.points,u);if(!d)throw new bt("point-unknown",`${e.id} answers ${u}, which ${i.pointsFile} no longer declares`);let p=Nm(l),f=p?mo(Sd(d,p)):Array.isArray(l.candidates)?l.candidates:mo(d.question),g=String(l.question_type),h=g==="noul"&&typeof e.answer=="string"?{true:!0,yes:!0,false:!1,no:!1}[e.answer.toLowerCase()]:e.answer;if(h===void 0||!f.includes(h))throw new bt("answer-not-candidate",`${e.id} takes one of ${f.map(B=>JSON.stringify(B)).join(", ")}, not ${JSON.stringify(e.answer)}`);let b=e.origin??ts();await fte(e.id,l,a.root,b,"answers");let w=Ed(d),x=pte(u,e.by,w,a.root,K$(l)?.steward,"answer",b),k=e.on??m1(),R=l.decider,$=o.state==="proposed"&&R.kind==="model"&&l.answer===h,_=Array.isArray(l.escalations)?[...l.escalations]:[],T;$?T={...l,state:"answered",answered_by:x.counted,answered_on:k,note:c,relayed_by:t}:(o.state==="proposed"&&R.kind==="model"&&_.push({kind:"model",backend:String(R.backend),model:String(R.model),answer:l.answer,...l.probabilities?{probabilities:l.probabilities}:{},...typeof l.confidence=="number"?{confidence:l.confidence}:{},...typeof l.threshold=="number"?{threshold:l.threshold}:{},reason:`proposed ${ac(l.answer,g)}, and people answered ${ac(h,g)}`,...typeof l.reason=="string"&&J$(a.loaded.schema).escalation?{model_reason:l.reason}:{}}),T={...Object.fromEntries(Object.entries(l).filter(([Z])=>Z!=="probabilities"&&Z!=="confidence"&&Z!=="threshold"&&Z!=="reason")),state:"answered",answer:h,decider:{kind:"quorum",count:w.count,...w.roles?{roles:w.roles}:{},by:x.counted},escalations:_.length>0?_:void 0,answered_by:x.counted,answered_on:k,note:c,relayed_by:t});let C=Array.isArray(l.constrains)&&typeof l.constrains[0]=="string"?l.constrains[0]:void 0;T.title=g1(d,C,"answered",h,p);let K=b1(a,T),O=gl(K,h1(d,String(T.title),p)),pe=s.byPath.has(o.path),F=`Decision point ${u}: answered ${ac(h,g)} by ${x.counted.join(", ")}${t?`, relayed by ${t}`:""}`,Q=await y1(a,r,o.path,O,!1,!!e.dryRun,{source:n.read.source,ledger:s,onLedger:pe,message:F,who:{verb:"points answer",by:x.counted.join(", ")}}),I={...o,state:"answered",data:K,valid:!0,reasons:[],warnings:Q.warnings};return{$schema:Bo,contract:Fo,verb:"answer",kind:a.view,id:e.id,path:o.path,reused:!1,written:!e.dryRun,dryRun:!!e.dryRun,question:xp(I,d,pe?Q.ledger??s.byPath.get(o.path)?.ledger??null:null),...e.dryRun?{text:O}:{}}}catch(t){return _p("answer",t)}}async function tM(e){try{return await vo(e.cwd,{verb:"points retract",by:(e.by??[]).join(", ")||null},e.dryRun,()=>lDe(e))}catch(t){return _p("retract",t)}}async function lDe(e){try{lte(e.id,"retracts"),ys(ho(e.cwd),e.by,"--by");let t=await ute(e.cwd,e.kind,e.id),{opened:n,before:i,target:r}=t,o=t.read.ledger,{o:s}=n,a=r.data;if(r.state!=="answered")throw new bt("answer-not-answered",`${e.id} is ${r.state??"not answered"}, so there is no answer to retract: answer it with \`points answer ${e.id}\``);if(!Zh(s.loaded.schema).retractions)throw new bt("answer-field-unsupported",`the ${s.loaded.kind.name} kind's schema has no retractions field, so ${e.id} can't keep the answer it would retract: copy point-answer.schema.json from @intentius/chant anew`);let l=String(a.point),c=Rd(n.points,l);if(!c)throw new bt("point-unknown",`${e.id} answers ${l}, which ${n.pointsFile} no longer declares, so no quorum can take the answer back: ask the point as it is declared now`);let u=e.origin??ts();await fte(e.id,a,s.root,u,"retracts");let d=Ed(c),p=pte(l,e.by,d,s.root,K$(a)?.steward,"retract",u),f=e.on??m1(),g=String(a.question_type),h=a.decider!==null&&typeof a.decider=="object"&&!Array.isArray(a.decider)?a.decider:{kind:"quorum"},b=a.answer,w=d1(e.note),x={answer:b,decider:h,answered_by:Array.isArray(a.answered_by)&&a.answered_by.length>0?a.answered_by:void 0,answered_on:typeof a.answered_on=="string"?a.answered_on:void 0,answer_note:typeof a.note=="string"?a.note:void 0,answer_relayed_by:typeof a.relayed_by=="string"?a.relayed_by:void 0,by:p.counted,on:f,note:w},k=Array.isArray(a.escalations)?[...a.escalations]:[];h.kind==="model"&&k.push({kind:"model",backend:String(h.backend),model:String(h.model),answer:b,...a.probabilities?{probabilities:a.probabilities}:{},...typeof a.confidence=="number"?{confidence:a.confidence}:{},...typeof a.threshold=="number"?{threshold:a.threshold}:{},reason:`proposed ${ac(b,g)}, which people confirmed and then retracted`,...typeof a.reason=="string"&&J$(s.loaded.schema).escalation?{model_reason:a.reason}:{}});let R=new Set(["answer","answered_by","answered_on","note","relayed_by","probabilities","confidence","threshold","reason"]),$=Object.fromEntries(Object.entries(a).filter(([Z])=>!R.has(Z))),_=Array.isArray(a.retractions)?a.retractions:[],T=Array.isArray(a.constrains)&&typeof a.constrains[0]=="string"?a.constrains[0]:void 0,C=Nm(a),K=g1(c,T,"escalated",void 0,C),O=b1(s,{...$,title:K,state:"escalated",decider:{kind:"quorum",count:d.count,...d.roles?{roles:d.roles}:{}},escalations:k.length>0?k:void 0,retractions:[..._,Object.fromEntries(Object.entries(x).filter(([,Z])=>Z!==void 0))]}),pe=gl(O,h1(c,K,C)),F=o.byPath.has(r.path),Q=`Decision point ${l}: ${ac(b,g)} retracted by ${p.counted.join(", ")}`,I=await y1(s,i,r.path,pe,!1,!!e.dryRun,{source:t.read.source,ledger:o,onLedger:F,message:Q,who:{verb:"points retract",by:p.counted.join(", ")}}),B={...r,state:"escalated",data:O,valid:!0,reasons:[],warnings:I.warnings};return{$schema:Bo,contract:Fo,verb:"retract",kind:s.view,id:e.id,path:r.path,reused:!1,written:!e.dryRun,dryRun:!!e.dryRun,question:xp(B,c,F?I.ledger??o.byPath.get(r.path)?.ledger??null:null),...e.dryRun?{text:pe}:{}}}catch(t){return _p("retract",t)}}var Fo,Bo,YTe,bt,p1,m1,ac,d1,dte,$$=v(()=>{"use strict";mg();go();mn();ko();vg();jm();_t();Qc();fs();ko();cl();nl();gs();$t();Ag();Rc();Fo=1,Bo="https://intentius.io/chant/schemas/workspace/points-write/v1/points-write.schema.json",YTe=[...Fa,"write-usage-invalid","write-input-invalid","points-undeclared","points-invalid","point-unknown","point-inputs-invalid","point-decider-failed","answer-not-candidate","quorum-not-met","record-not-found","record-closed","record-id-taken","answer-in-steward-turn","answer-never-over-mcp","principal-unidentified","answer-not-answered","answer-field-unsupported","point-candidates-invalid",...La,...Sa],bt=class extends Error{constructor(n,i){super(i);this.code=n;this.name="PointsWriteError"}};p1="chant-steward";m1=()=>new Date().toISOString().slice(0,10),ac=(e,t)=>t==="noul"?e?"yes":"no":String(e);d1=e=>{let t=e?.trim();return t||void 0};dte=e=>e==="acp"?"ACP":"MCP"});function $p(e){return!!e&&typeof e=="object"&&e[hte]===!0&&"question"in e}async function uDe(e,t){if(e.capabilities!==void 0)return{capabilities:e.capabilities,vault:e.vault??null};let{discoverStewards:n}=await Promise.resolve().then(()=>(Wi(),HT)),i=(await n({cwd:t})).stewards.get(e.steward)?.declaration;return{capabilities:i?.capabilities??[],vault:i?.vault??null}}async function A$(e,t){let n=t.capability??tQ,i={capability:n,broker:t.broker??null},r=t.turn===void 0?wo():t.turn;if(!r)return a=>e(a,i);let{capabilities:o,vault:s}=await uDe(r,t.cwd);if(!o.includes(n)){let a=s!==null?`the steward ${r.steward} holds the vault ${s} and names no brokered capabilities, and a steward's model call goes through the broker`:`the steward ${r.steward} does not name the brokered capability ${n}`+(o.length?` (it names ${o.join(", ")})`:"")+", and a steward holds no credential of its own";return async()=>{throw new Error(a)}}return a=>e(a,i)}async function lM(e){let t=e.turn===void 0?wo():e.turn,n=e.ask?await A$(e.ask,{capability:e.capability,broker:e.broker,turn:t,cwd:e.cwd}):void 0,{askPoint:i}=await Promise.resolve().then(()=>($$(),cM)),r=await i({cwd:e.cwd,point:e.point,inputs:e.inputs,...e.subject!==void 0?{subject:e.subject}:{},...e.kind!==void 0?{kind:e.kind}:{},...n?{ask:n}:{},...e.on!==void 0?{on:e.on}:{},...e.store!==void 0?{store:e.store}:{},...t?{steward:{name:t.steward,...t.run?{run:t.run}:{}}}:{}});if("error"in r)throw new Error(`decision point ${e.point}: ${r.error.code}: ${r.error.message}`);let o=r.question;if(o.state==="answered"&&o.answer!==null)return{answer:o.answer,question:o};throw new _$({id:o.id,point:o.point,state:o.state==="proposed"?"proposed":"escalated",path:o.path,subject:o.subject,steward:o.askedBy?.steward??null})}var tQ,hte,mte,gte,_$,Oh=v(()=>{"use strict";cl();tQ="inference",hte=Symbol.for("chant.op.PointWait"),_$=class extends(gte=Error,mte=hte,gte){constructor(n){super(`waiting on decision point ${n.point} (${n.id}, ${n.state}): a person answers it through hud or \`chant workspace points answer ${n.id}\``);this.question=n;this[mte]=!0;this.name="PointWait"}}});var yte={};_e(yte,{evaluatePointGate:()=>ag,pointGateResumable:()=>cg,workspaceGatePointAsker:()=>fM});function fM(e){return{async ask(t){let{workspacePoints:n}=await Promise.resolve().then(()=>(Ph(),x$)),i=await n({cwd:e});if("error"in i)throw new Error(`decision point ${t.point}: ${i.error.code}: ${i.error.message}`);let r=i.points.find(l=>l.name===t.point);if(!r){let l=i.sources.find(c=>c.reason);throw new Error(`gate "${t.facts.name}" asks decision point ${t.point}, and no points file declares it${l?` (${l.kind}: ${l.reason.message})`:""}`)}let o=al(t.point,r.inputs.map(l=>l.name),t.facts,t.inputs),{runDecide:s}=await Promise.resolve().then(()=>(aM(),O7)),a=r.deciders.some(l=>l.kind==="model");try{let l=t.store??Ld(),c=await s({point:t.point,inputs:o,subject:t.subject,cwd:e,...l?{store:l}:{},...a?{}:{backends:{}}});return{id:c.id,point:t.point,path:c.path,state:c.state,answer:c.answer,decider:c.decider,answeredBy:c.answeredBy,subject:t.subject,steward:null}}catch(l){if(!$p(l))throw l;let c=l.question;return{id:c.id,point:c.point,path:c.path,state:c.state,answer:null,decider:"quorum",answeredBy:[],subject:c.subject,steward:c.steward}}}}}var C$=v(()=>{"use strict";ws();Oh();ck()});import{execFileSync as Z$,spawnSync as dDe}from"node:child_process";import{existsSync as $te,mkdirSync as Q$,readFileSync as Fl,rmSync as Yh,writeFileSync as k1}from"node:fs";import{dirname as x1,isAbsolute as fvt,join as bn,posix as pDe}from"node:path";function _h(e,t){let n;try{n=JSON.parse(e)}catch(o){throw new Error(`${t}: ${o instanceof Error?o.message:String(o)}`)}let i=n?.waves,r=Array.isArray(i)?n:i;if(!r||typeof r!="object"||!Array.isArray(r.waves))throw new Error(`${t} must hold an Op waves spec: { "name", "op", "plan", "waves": [...] }, or { "waves": <that>, "options": {...} }`);return r}function nQ(e,t,n,i,r=mDe){let{sha:o,text:s}=r(n,e.replace(/^\.\//,"").split("\\").join(pDe.sep),i),a={policy:"always",approval:"ledger",source:"absent-at-base",base:o,hooks:bte(),spend:!1,applyHooksRunBy:"chant",neverOverMcp:!1};if(s===null)return a;let l;try{l=_h(s,`${e} at ${n}`)}catch{return a}let c=l.approvals?.spend===!0,u=l.neverOverMcp===!0,d=gDe(l,t,`${e} at ${o.slice(0,12)}`),p=l.waves.find(b=>b.name===t);if(!p)return{...a,spend:c,neverOverMcp:u,...d};let f=p.gate??"always",g=p.approval===void 0?"ledger":Ia.includes(p.approval)?p.approval:"sealed",h={policy:Jm.includes(f)?f:"always",approval:g,source:"base",base:o,hooks:bte(),spend:c,applyHooksRunBy:"chant",neverOverMcp:u,...d};try{Fd(`${e} at ${o.slice(0,12)}`,l.hooks),Fd(`${e} at ${o.slice(0,12)}, wave "${t}"`,p.hooks),h.hooks=tk(l,t),h.applyHooksRunBy=nk(l,t)}catch(b){h.hooksRefused=`the hooks at base cannot be run (${b instanceof Error?b.message:String(b)})`}return h}function gDe(e,t,n){let i=e.waves.find(o=>o.name===t)?.point??e.point;if(i===void 0)return{};let r=Xv(i);return r.length>0?{pointRefused:`the decision point at base cannot be asked (${n}: ${r.join("; ")})`}:{point:kT(e,t)}}function Ip(e,t){let n=[["{op}",t.op],["{target}",t.target],["{wave}",t.wave],["{plans}",t.plans],["{plan}",t.plan],["{runs}",t.runs]];return e.map(i=>n.reduce((r,[o,s])=>s===void 0?r:r.replaceAll(o,s),i))}function eR(e,t,n){return`.chant/op-waves/${e.name}/wave-${t}/${n.replace(/[^A-Za-z0-9._-]/g,"_")}.plan.json`}function kM(e,t){return`.chant/op-waves/${e.name}/wave-${t}/runs.json`}function xM(e,t){return`.chant/op-waves/${e.name}/wave-${t}/plans.json`}function hDe(e,t,n){let i=n.op??e.spec.op,r=eR(e.spec,e.wave,n.target);Q$(x1(bn(e.cwd,r)),{recursive:!0});let o=e.exec(Ip(e.spec.plan,{op:i,target:n.target,wave:t,plan:r}),e.cwd);if(o!==0)throw new Error(`planning ${n.target} exited ${o}`);let s;try{s=JSON.parse(Fl(bn(e.cwd,r),"utf-8"))}catch(a){throw new Error(`planning ${n.target} wrote no readable plan file at ${r}: ${a instanceof Error?a.message:String(a)}`)}if(typeof s.planDigest!="string"||s.planDigest==="")throw new Error(`the plan file for ${n.target} (${r}) has no planDigest`);return Ste(n.target,i,s)}function Ste(e,t,n){let i=n.denied;if(i!==void 0){let r=i;if(!r||typeof r!="object"||!Array.isArray(r.rules)||r.rules.length===0||!r.rules.every(o=>typeof o=="string"&&o.trim()!=="")||r.reason!==void 0&&typeof r.reason!="string")throw new Error(`the plan of ${e} has denied ${JSON.stringify(i)}; a denial is { "rules": ["<rule id>", ...], "reason"?: "<text>" }`)}return{member:e,planDigest:n.planDigest,op:t,...n.destructive===!0?{destructive:!0}:{},...n.empty===!0?{empty:!0}:{},...n.denied?{denied:{rules:n.denied.rules,...n.denied.reason?{reason:n.denied.reason}:{}}}:{}}}function Y$(e,t,n,i,r=kM(e.spec,e.k),o=!1){let s={wave:e.wave.name,number:e.k,...i?{digest:i}:{},...o?{discover:!0}:{},runs:t.map(a=>{let l=n?.get(a.target);return{target:a.target,op:a.op??e.spec.op,...l?{planDigest:l.planDigest,...l.destructive?{destructive:!0}:{},...l.empty?{empty:!0}:{}}:{}}})};return Q$(x1(bn(e.cwd,r)),{recursive:!0}),k1(bn(e.cwd,r),JSON.stringify(s,null,2)+`
|
|
307
|
+
`),r}function v1(e,t,n=!1){let{spec:i,k:r,wave:o,cwd:s,exec:a}=e;if(!i.planWave)return{members:t.map(T=>hDe({spec:i,wave:r,cwd:s,exec:a},o.name,T))};let l=Y$(e,t,void 0,void 0,void 0,n),c=xM(i,r);Yh(bn(s,c),{force:!0});let u=a(Ip(i.planWave,{op:i.op,wave:o.name,runs:l,plans:c}),s);if(u!==0)throw new Error(`planning wave ${r} (${o.name}) exited ${u}`);let d;try{d=JSON.parse(Fl(bn(s,c),"utf-8"))}catch(T){throw new Error(`planning wave ${r} (${o.name}) wrote no readable plans file at ${c}: ${T instanceof Error?T.message:String(T)}`)}let p=Array.isArray(d)?d:d?.runs;if(!Array.isArray(p))throw new Error(`the plans file of wave ${r} (${c}) must hold { "runs": [{ "target", "planDigest" }] }`);let f=new Set(t.map(T=>T.target)),g=new Map,h=[];for(let T of p){let C=T?.target;if(n&&typeof C=="string"&&C!==""&&!g.has(C)){if(T.op!==void 0&&(typeof T.op!="string"||T.op===""))throw new Error(`the plans file of wave ${r} (${c}) gives ${C} an op that is not a name`);h.push({target:C,...T.op&&T.op!==i.op?{op:T.op}:{}}),f.add(C)}if(typeof C!="string"||!f.has(C))throw new Error(`the plans file of wave ${r} (${c}) plans ${JSON.stringify(C)}, which is not a run it was asked to plan`);if(g.has(C))throw new Error(`the plans file of wave ${r} (${c}) plans ${C} twice`);if(typeof T.planDigest!="string"||T.planDigest==="")throw new Error(`the plans file of wave ${r} (${c}) has no planDigest for ${C}`);g.set(C,T)}let b=t.filter(T=>!g.has(T.target)).map(T=>T.target);if(b.length>0)throw new Error(`the plans file of wave ${r} (${c}) has no plan for ${b.join(", ")}`);n&&(t=h);let w=Array.isArray(d)?void 0:yDe(d.members,new Set(t.map(T=>T.target)),`the plans file of wave ${r} (${c})`),x=Array.isArray(d)?void 0:d.waves;if(x!==void 0&&(!Number.isInteger(x)||x<0))throw new Error(`the plans file of wave ${r} (${c}): \`waves\` must be the number of waves found, a whole number`);let k=Array.isArray(d)?void 0:Ete(d.pending,`the plans file of wave ${r} (${c})`),R=t.map(T=>{let C=Ste(T.target,T.op??i.op,g.get(T.target)),K=bn(s,eR(i,r,T.target));return k1(K,JSON.stringify({planDigest:C.planDigest,...C.destructive?{destructive:!0}:{},...C.empty?{empty:!0}:{},...C.denied?{denied:C.denied}:{}})+`
|
|
308
|
+
`),C}),$=Array.isArray(d)?void 0:d.overriders,_=Array.isArray(d)?void 0:d.overridersSource;if(_!==void 0&&(typeof _!="string"||_.trim()===""))throw new Error(`the plans file of wave ${r} (${c}): \`overridersSource\` must be a label for where the overriders come from, such as "policy.override in terragucci.yml"`);if($!==void 0&&(!Array.isArray($)||!$.every(T=>typeof T=="string")))throw new Error(`the plans file of wave ${r} (${c}): \`overriders\` must be a list of principals`);return{members:R,...k?{pending:k}:{},...$?{overriders:$}:{},...$&&_?{overridersSource:_}:{},...w?{extras:w}:{},...x!==void 0?{waves:x}:{}}}function yDe(e,t,n){if(e===void 0)return;if(!Array.isArray(e))throw new Error(`${n}: \`members\` must be a list of { "member", "planDigest" }`);let i=new Set,r=[];for(let o of e){if(!o||typeof o.member!="string"||o.member===""||typeof o.planDigest!="string"||o.planDigest==="")throw new Error(`${n}: each of \`members\` needs a member and a planDigest`);if(t.has(o.member))throw new Error(`${n}: member ${o.member} is also a run's target; a digest member that is no run needs a name of its own`);if(i.has(o.member))throw new Error(`${n}: names member ${o.member} twice`);i.add(o.member),r.push({member:o.member,planDigest:o.planDigest})}return r.length>0?r:void 0}function Ete(e,t){if(e===void 0)return;if(e===null||typeof e!="object"||Array.isArray(e))throw new Error(`${t}: \`pending\` must be an object of fields for the pending fact`);let n=Object.keys(e).filter(i=>fDe.includes(i));if(n.length>0)throw new Error(`${t}: \`pending\` sets ${n.join(", ")}, which chant writes itself`);if("description"in e&&typeof e.description!="string")throw new Error(`${t}: pending.description must be a string`);return Object.keys(e).length>0?e:void 0}function $M(e,t,n=[]){return yT(bT(t,{...e.digest?.over?{over:e.digest.over}:{},extras:n}))}function Ate(e,t,n){if($te(e))try{let i=JSON.parse(Fl(e,"utf-8"));if(typeof i.gate!="string"||i.gate===""||typeof i.digest!="string"||i.digest==="")throw new Error("it names no gate and digest");if(i.op!==void 0&&(typeof i.op!="string"||i.op===""))throw new Error("its op is not a name");return{gate:i.gate,digest:i.digest,...i.op?{op:i.op}:{},...typeof i.description=="string"?{description:i.description}:{},...i.pending?{pending:Ete(i.pending,`the hold ${n} wrote`)??{}}:{}}}catch(i){t(`${n} wrote a hold file that cannot be read (${i instanceof Error?i.message:String(i)}), so it holds the wave on its set digest`);return}}function bDe(e,t,n,i,r,o={}){let s={holds:[],outcomes:[],otherGates:[]};if(!n||n.length===0)return s;let{name:a,op:l,waveName:c,k:u,cwd:d,exec:p,log:f}=e,g=`.chant/op-waves/${a}/wave-${u}/hold.json`,h={CHANT_OP_WAVES:a,CHANT_WAVE:c,CHANT_WAVE_NUMBER:String(u),CHANT_HOOK:t,CHANT_RUNS:r,CHANT_HOLD:g,...o};for(let b of n){let w=b.name??(b.command.join(" ").length>60?`${b.command.join(" ").slice(0,57)}...`:b.command.join(" ")),x=b.perRun?i.map(k=>({target:k.target,argv:Ip(b.command,{op:k.op,wave:c,target:k.target,runs:r,...k.plan?{plan:k.plan}:{}}),env:{...h,CHANT_TARGET:k.target,...k.plan?{CHANT_PLAN:k.plan}:{}}})):[{target:void 0,argv:Ip(b.command,{op:l,wave:c,runs:r}),env:h}];for(let k of x){let R=`${t} hook ${w}${k.target?` (${k.target})`:""}`,$;Yh(bn(d,g),{force:!0});try{$=p(k.argv,d,k.env)}catch(T){f(`${R} did not run: ${T instanceof Error?T.message:String(T)}`),$=127}let _={moment:t,name:w,...k.target?{target:k.target}:{},exit:$};if($===0){s.outcomes.push({..._,outcome:"passed"});continue}if(b.onFailure==="approve"){s.outcomes.push({..._,outcome:"held"});let T=Ate(bn(d,g),f,R);if(T){s.otherGates.push({label:R,name:w,moment:t,...k.target?{target:k.target}:{},argv:k.argv,env:k.env,request:T}),f(`${R} exited ${$} and holds wave ${u} (${c}) on gate ${T.op??a} / ${T.gate}, digest ${T.digest}`);continue}s.holds.push(R),f(`${R} exited ${$}, so wave ${u} (${c}) waits for an approval of its set digest`);continue}return s.outcomes.push({..._,outcome:"failed"}),s.failed=`${R} exited ${$}`,f(s.failed),s}}return s}async function Ml(e,t,n,i,r,o,s={}){if(!n||n.length===0)return{holds:[]};let a=Y$(e,i,r,o),l=bDe(wDe(e),t,n,Pte(e.spec,e.k,i,r),a,s);e.result.hooks.push(...l.outcomes);let c={holds:l.holds,...l.failed?{failed:l.failed}:{}};if(l.failed)return c;for(let u of l.otherGates){let d=u,p=[];for(;;){let f=await vDe(e,d);if(f.status==="waiting"){p.length>0&&(f.after=p),c.waitingOn??=f;break}let g={op:f.op,gate:f.gate,digest:f.digest,approvedBy:f.approvedBy,approvedAt:f.approvedAt};p.push(g);let h={...d.env,CHANT_HOLD_APPROVED:JSON.stringify(g),CHANT_HOLDS_APPROVED:JSON.stringify(p)},b=bn(e.cwd,d.env.CHANT_HOLD);Yh(b,{force:!0});let w;try{w=e.exec(d.argv,e.cwd,h)}catch($){e.log(`${d.label} did not run: ${$ instanceof Error?$.message:String($)}`),w=127}let x=d.target?{target:d.target}:{};if(w===0){e.result.hooks.push({moment:t,name:d.name,...x,exit:w,outcome:"passed"}),e.log(`${d.label}: ${f.approvedBy} approved ${f.op} / ${f.gate} at ${f.digest}, and the hook ran again and passed`);break}let k=Ate(b,e.log,d.label),R=k?p.some($=>$.op===(k.op??e.spec.name)&&$.gate===k.gate&&$.digest===k.digest)?`${d.label} exited ${w} after ${f.approvedBy} approved ${f.gate}, and holds the wave again on ${k.op??e.spec.name} / ${k.gate} at ${k.digest}, which is already approved`:p.length>=wte?`${d.label} held the wave on ${p.length} gates in turn and asks for one more; a hook call holds on at most ${wte}`:void 0:`${d.label} exited ${w} after ${f.approvedBy} approved ${f.gate}`;if(R)return e.result.hooks.push({moment:t,name:d.name,...x,exit:w,outcome:"failed"}),c.failed=R,e.log(c.failed),c;e.result.hooks.push({moment:t,name:d.name,...x,exit:w,outcome:"held"}),e.log(`${d.label}: ${f.approvedBy} approved ${f.op} / ${f.gate}; the hook ran again, exited ${w} and holds wave ${e.k} (${e.wave.name}) on gate ${k.op??e.spec.name} / ${k.gate}, digest ${k.digest}`),d={...d,request:k}}}return c}async function Ote(e,t,n,i,r){let o=e.gates??bs({cwd:t}),s=c=>o.approvalRule?.(c,{base:r})??Promise.resolve(null);if(i!=="sealed")return{ledger:o,port:o.approvalRule?{...o,approvalRule:s}:o};let a=await Promise.resolve().then(()=>(ig(),rg)),l=a.sealedApprovalRule(n,(e.trust??(c=>a.trustPolicyAt(t,c)))(r));return{ledger:o,port:{...o,async approvalRule(c){let u=await s(c);return c===n?a.bothRules(u,l):u}}}}function Cte(e,t,n){if(!n.satisfied)for(let{resolution:i,reason:r}of n.refused??[])e(`${t}: the approval by ${i.resolvedBy} at ${i.timestamp} does not count: ${r}`)}async function vDe(e,t){let{spec:n,k:i,wave:r,log:o}=e,s=e.gateRule,a=t.request.op??n.name,l=s.approval==="sealed"?"sealed":"ledger",{port:c}=await Ote(e.options,e.cwd,t.request.gate,l,s.base),u=s.neverOverMcp,d=e.options.now??new Date().toISOString(),p=await ol(c,{op:a,gate:t.request.gate,planDigest:t.request.digest,description:t.request.description??`wave ${i} (${r.name}) of ${n.name} is held on it by ${t.label}`,now:d,fields:{...t.request.pending,approvalMode:s.approval,wave:{number:i,name:r.name,op:n.name},heldBy:{hook:t.name,moment:t.moment,...t.target?{target:t.target}:{}}},...u?{neverOverMcp:!0}:{}}),f={op:a,gate:t.request.gate,digest:t.request.digest,hook:t.label};if(Cte(o,`${a} / ${t.request.gate}`,p),p.satisfied)return{...f,status:"approved",approvedBy:p.resolution.resolvedBy,approvedAt:p.resolution.timestamp};let g=jd(a,t.request.gate,void 0,t.request.digest,l==="sealed");return o(`wave ${i} (${r.name}) waits on ${a} / ${t.request.gate}, which ${t.label} holds it on: nobody approved ${t.request.digest}. Approve: ${g}`),{...f,status:"waiting",approve:g,waitingSince:p.pending.timestamp,recorded:p.recorded,...p.mismatch?{mismatch:p.mismatch}:{}}}function rQ(e,t){return e==="never"||t.every(n=>n.empty===!0)?!1:e==="on-destructive"?t.some(n=>n.destructive===!0):!0}function kDe(e,t){let{hooks:n,base:i}=t,r=tk(e.spec,e.wave.name);(JSON.stringify(r)!==JSON.stringify(n)||nk(e.spec,e.wave.name)!==t.applyHooksRunBy)&&e.log(`wave ${e.k} (${e.wave.name}): its hooks are read at ${i.slice(0,12)}, and this change's differ; the ones at base run`)}async function RM(e){let{spec:t}=e;Zm(t);let n=e.log??(s=>console.error(s)),i=t.waves[t.waves.length-1],r=[],o=[];for(let s=e.wave;;s++){let a,l;for(let d=0;a=await xDe(e,s,l,d),!!a.replan;d++){if(d+1>=SM){n(`wave ${s}: its apply asked to plan again ${SM} times, so the wave stops here`),a.exitCode=1;break}n(`wave ${s}: the apply applied nothing and asks to plan again${a.replan.reason?` (${a.replan.reason})`:""}; planning again`),l=a.decision}r.push(...a.applied);let c=a.decision?.discovered?.waves,u=s>=t.waves.length&&i.rest===!0&&e.share===void 0&&!e.decide&&a.exitCode===0&&c!==void 0&&s<c;if((o.length>0||u)&&o.push({wave:s,exitCode:a.exitCode,...a.decision?{digest:a.decision.digest}:{}}),!u)return{...a,applied:r,...o.length>0?{rest:o}:{}};n(`wave ${s} applied; the plan found ${c} waves, so this job goes on to wave ${s+1}`)}}async function xDe(e,t,n,i){let{spec:r}=e,o=e.cwd??process.cwd(),s=e.exec??Rte,a=e.log??($e=>console.error($e)),l=r.waves[r.waves.length-1],c=r.waves[t-1]??(l.rest?l:void 0);if(!c)throw new Error(`Op waves "${r.name}" has ${r.waves.length} waves; there is no wave ${t}.`);let u=c.shares??1;if(e.share!==void 0&&(e.share<1||e.share>u))throw new Error(`wave ${t} (${c.name}) has ${u} share${u===1?"":"s"}; there is no share ${e.share}.`);let d=bn(o,ek(r,t)),p={exitCode:0,applied:[],failed:[],moved:[],hooks:[]},f={spec:r,k:t,wave:c,cwd:o,exec:s,log:a,result:p,options:e,gateRule:{approval:"ledger",base:"HEAD",neverOverMcp:r.neverOverMcp===!0}};if(i>0&&a(`wave ${t} (${c.name}): plan ${i+1}`),e.share!==void 0){let $e;try{$e=JSON.parse(Fl(d,"utf-8"))}catch{throw new Error(`share ${e.share} of wave ${t} (${c.name}) found no decision at ${ek(r,t)}. Run the deciding job first.`)}if(p.decision=$e,f.gateRule={approval:$e.approval,base:$e.base,neverOverMcp:$e.neverOverMcp===!0},$e.status==="waiting"||$e.status==="refused")return a(`wave ${t} (${c.name}) is ${$e.status==="refused"?"refused by its policy":`waiting on ${$e.heldOn?.gate??$e.gate}`}; nothing applied. ${$e.approve??""}`.trim()),{...p,exitCode:$e.status==="refused"?R1($e):3};c.discover&&(c={...c,runs:$e.members.map(Re=>({target:Re.member,...Re.op!==r.op?{op:Re.op}:{}}))},f.wave=c);let Te=RT(c.runs,e.share,u),nt=await Ml(f,"before-plan",$e.hooks?.["before-plan"],Te);if(nt.failed)return Uo(f,`a hook before the plan failed, so nothing in share ${e.share} of wave ${t} was planned or applied`);if(nt.waitingOn)return vte(f,$e,nt.waitingOn);let{members:St}=v1(f,Te),Ee=new Map(St.map(Re=>[Re.member,Re])),zt=await Ml(f,"after-plan",$e.hooks?.["after-plan"],Te,Ee);if(zt.failed)return Uo(f,`a hook after the plan failed, so nothing in share ${e.share} of wave ${t} was applied`);if(zt.waitingOn)return vte(f,$e,zt.waitingOn);let Vn=new Map($e.members.map(Re=>[Re.member,Re.planDigest])),ne=[];for(let Re of Te){let X=Ee.get(Re.target);if(Vn.get(Re.target)!==X.planDigest){a(`${Re.target}: its plan moved since wave ${t} was decided, so it was not applied. decided: ${Vn.get(Re.target)??"(not in the decision)"}; planned now: ${X.planDigest}`),p.moved.push(Re.target);continue}ne.push(Re)}return await xte(e,f,$e,ne,Ee,[...nt.holds,...zt.holds]),p.exitCode===0&&p.moved.length>0&&(p.exitCode=4),p}let g=nQ(e.specFile,c.name,e.base??r.base??"HEAD^1",o,e.show),{policy:h,approval:b,source:w,base:x}=g,k=g.neverOverMcp||r.neverOverMcp===!0;if(f.gateRule={approval:b,base:x,neverOverMcp:k},kDe(f,g),g.pointRefused)return Uo(f,`wave ${t} (${c.name}): ${g.pointRefused}, so nothing in it was planned or applied`);let R=kT(r,c.name);JSON.stringify(R)!==JSON.stringify(g.point)&&a(`wave ${t} (${c.name}): its gate's decision point is read at ${x.slice(0,12)} (${g.point?.name??"none"}), and this change's differs (${R?.name??"none"}); the one at base holds`);let $=[];g.hooksRefused&&($.push(g.hooksRefused),a(`wave ${t} (${c.name}): ${g.hooksRefused}, so none run and the wave waits for an approval`));let _=xT(r,t),T=Object.fromEntries(Object.entries(g.hooks).filter(([,$e])=>$e.length>0)),C={wave:t,name:c.name,op:r.name,gate:_,policy:h,approval:b,policySource:w,base:x,digest:"",members:[],status:"not-required",...Object.keys(T).length>0?{hooks:T}:{},...g.spend?{spend:"base"}:r.approvals?.spend===!0?{spend:"change"}:{},...g.applyHooksRunBy==="apply"?{applyHooksRunBy:"apply"}:{},...r.digest?.over==="changing"?{digestOver:"changing"}:{},...k?{neverOverMcp:!0}:{},...g.point?{point:{...g.point}}:{}},K=await Ml(f,"before-plan",g.hooks["before-plan"],c.runs);if(K.failed)return Uo(f,`a hook before the plan failed, so nothing in wave ${t} was planned or applied`);if(K.waitingOn)return w1(f,C,d,K.waitingOn);let{members:O,pending:pe,overriders:F,overridersSource:Q,extras:I,waves:B}=v1(f,c.runs,c.discover===!0);c.discover&&(c={...c,runs:O.map($e=>({target:$e.member,...$e.op!==r.op?{op:$e.op}:{}}))},f.wave=c,C.discovered={...B!==void 0?{waves:B}:{}},a(`wave ${t} (${c.name}): the plan found ${O.length} run${O.length===1?"":"s"}${B!==void 0?` of ${B} waves`:""}${O.length?`: ${O.map($e=>$e.member).join(", ")}`:""}`));let Z=new Map(O.map($e=>[$e.member,$e])),xe=$M(r,O,I);C.digest=xe,C.members=O,I&&(C.extras=I),pe&&(C.pending=pe);let we=await Ml(f,"after-plan",g.hooks["after-plan"],c.runs,Z,xe);if(we.failed)return Uo(f,`a hook after the plan failed, so nothing in wave ${t} was applied`);if($.push(...K.holds,...we.holds),$.length>0&&(C.heldBy=$),we.waitingOn)return w1(f,C,d,we.waitingOn);let Ct=n!==void 0&&(n.status==="approved"||n.status==="not-required")&&n.digest===xe;if(Ct){let $e=new Map(n.members.map(Te=>[Te.member,Te.override]));for(let Te of O)Te.denied&&$e.get(Te.member)&&(Te.override=$e.get(Te.member));n.overridesSpentAt&&(C.overridesSpentAt=n.overridesSpentAt)}if(O.some($e=>$e.denied&&!$e.override)&&await RDe(f,C,F,Q),Ct&&n.status==="approved"&&C.status!=="refused"){for(let $e of["via","approvedBy","approvedAt","review","spentAt"])n[$e]!==void 0&&(C[$e]=n[$e]);C.status="approved",a(`wave ${t} (${c.name}): planned again to the same digest, so the approval by ${n.approvedBy} still holds`)}else C.status!=="refused"&&(rQ(h,O)||$.length>0)&&await Ite(e,f,C);let at=await w1(f,C,d);return at.exitCode!==0?at:(a(`wave ${t} (${c.name}): gate ${h} (read at ${x.slice(0,12)}${w==="absent-at-base"?", where the wave is absent":""}), digest ${xe}: ${C.status}${C.approvedBy?` by ${C.approvedBy}`:""}`+(C.via==="pr-review"?` (review of #${C.review?.pr})`:"")+($.length>0?`; held by ${$.join(", ")}`:"")),e.decide?!await S1(e,f,C)||!await _te(f,C)?f.result:((C.spentAt||C.overridesSpentAt)&&Ho(d,C,p),p):(await xte(e,f,C,c.runs,Z,[],d),p))}async function w1(e,t,n,i){let{k:r,wave:o,log:s,result:a}=e;i&&$1(t,i),Q$(x1(n),{recursive:!0}),Ho(n,t,a),a.decision=t,t.approval==="pr-review"&&t.status==="waiting"&&t.review?.reason&&s(`The pull request's review does not approve wave ${r}: ${t.review.reason}`);let l=await X$(e,t,n);return t.status==="waiting"?(s(`Nothing in wave ${r} or after it ran. ${t.heldOn?`It waits on ${t.heldOn.op} / ${t.heldOn.gate}.`:"Read the plans, then"} approve: ${t.approve} (with --resume, the approval also starts this job again)`),{...a,exitCode:3}):t.status==="refused"&&t.refused?.reason==="point"?(s(`Nothing in wave ${r} (${o.name}) or after it ran: ${t.refused.message}`),{...a,exitCode:8}):t.status==="refused"?(s(`Nothing in wave ${r} (${o.name}) or after it ran: the policy denied ${t.refused?.runs.join(", ")}, and no override counts for ${t.refused?.runs.length===1?"it":"them"}.`),{...a,exitCode:7}):l.failed?Uo(e,`wave ${r} (${o.name}): ${l.failed}, so nothing in it was applied`):a}function $1(e,t){e.heldOn=t,e.status="waiting",e.approve=t.approve,t.waitingSince&&(e.waitingSince=t.waitingSince),t.recorded!==void 0&&(e.recorded=t.recorded)}async function vte(e,t,n){return $1(t,n),e.log(`share ${e.options.share} of wave ${e.k} (${e.wave.name}) waits on ${n.op} / ${n.gate}; nothing in it applied. Approve: ${n.approve}`),{...e.result,decision:t,exitCode:3}}async function X$(e,t,n){let i=t.hooks?.["after-gate"];if(!i?.length)return{holds:[]};let r=t.heldOn,o={CHANT_GATE_STATUS:t.status,CHANT_GATE_OP:r?.op??t.op,CHANT_GATE:r?.gate??t.gate,CHANT_GATE_DIGEST:r?.digest??t.digest,CHANT_DECISION:$De(e.cwd,n),...t.approve?{CHANT_GATE_APPROVE:t.approve}:{},...t.waitingSince?{CHANT_GATE_WAITING_SINCE:t.waitingSince}:{},...t.recorded!==void 0?{CHANT_GATE_RECORDED:String(t.recorded)}:{}},s=new Map(t.members.map(l=>[l.member,l])),a=await Ml(e,"after-gate",i,e.wave.runs,s.size>0?s:void 0,t.digest||void 0,o);return Ho(n,t,e.result),a.failed&&t.status!=="approved"&&t.status!=="not-required"&&e.log(`${a.failed}; the wave is ${t.status} whatever the hook came to`),a}function $De(e,t){return t.startsWith(e+"/")?t.slice(e.length+1):t}async function RDe(e,t,n,i){let{spec:r,k:o,wave:s,cwd:a,log:l,options:c}=e,u=await Promise.resolve().then(()=>(og(),DT)),d=c.gates??bs({cwd:a}),p=r.override?.overriders??u.OVERRIDERS_PATH,f=n??u.overridersAt(a,t.base,p).principals,g=t.approval==="sealed",h=g?(c.signers??(await Promise.resolve().then(()=>(jT(),NT))).gateSignersAt.bind(null,a))(t.base):void 0,b=await d.read(u.OVERRIDE_OP),w=await d.readApplied?.(u.OVERRIDE_OP)??[],x=c.now??new Date().toISOString(),k=[],R=!1;for(let $ of t.members){if(!$.denied||$.override)continue;let _=u.decideOverride({ledger:b,applied:w,subject:$.member,planDigest:$.planDigest,rules:$.denied.rules,overriders:f,overridersPath:n?i??"the overriders the plans file names":p,mode:g?"sealed":"ledger",...h?{signers:h}:{},now:x});if(_.status==="overridden"){let T=_.override;$.override={by:T.by,at:T.at,digest:T.digest,reason:T.reason},l(`${$.member}: the policy denial (${T.rules.join(", ")}) is overridden by ${T.by} at ${T.at}${T.sealed?", sealed":""}: ${T.reason}`);continue}k.push($.member);for(let T of _.refusals)l(`${$.member}: an override does not count: ${T}`);if(_.status==="moved"&&(R=!0,l(`${$.member}: ${_.by} overrode an earlier plan or other rules (${_.was??"no digest"}); this plan and its rules give ${_.digest}, so that override counts for nothing`)),!_.standing){let{version:T,kind:C,...K}=u.overridePending({subject:$.member,planDigest:$.planDigest,rules:$.denied.rules,timestamp:x,expiresAt:new Date(new Date(x).getTime()+1728e5).toISOString(),description:$.denied.reason??`wave ${o} (${s.name}) of ${r.name}: ${$.member}: plan ${$.planDigest} denied by ${u.sortedRules($.denied.rules).join(", ")}`});try{await d.appendPending({...K,members:[{member:$.member,planDigest:$.planDigest}],wave:{number:o,name:s.name,op:r.name}})}catch(O){l(`${$.member}: the denial was not recorded for an override: ${O instanceof Error?O.message:String(O)}`)}}l(`${$.member}: ${f.length?`${f.join(", ")} may`:"nobody listed may"} override it with: ${u.overrideCommand($.member,$.denied.rules,g)}`)}k.length>0&&(t.status="refused",t.refused={reason:R?"override-moved":"policy",runs:k.sort(),...n&&i?{overridersSource:i}:{}})}async function _te(e,t){let n=t.members.filter(d=>d.override);if(n.length===0||t.overridesSpentAt)return!0;let{k:i,wave:r,cwd:o,log:s,options:a}=e,l=await Promise.resolve().then(()=>(og(),DT)),c=a.gates??bs({cwd:o}),u=a.now??new Date().toISOString();try{if(!c.appendApplied)throw new Error("this gate ledger cannot record an applied override");for(let d of n){let p=l.appliedOverride({subject:d.member,digest:d.override.digest,at:d.override.at,by:d.override.by},{timestamp:u});await c.appendApplied(p)}}catch(d){return Uo(e,`wave ${i} (${r.name}) could not record the overrides it applies under, so nothing applied: ${d instanceof Error?d.message:String(d)}`),!1}return t.overridesSpentAt=u,s(`wave ${i} (${r.name}) applies ${n.map(d=>d.member).join(", ")} under their overrides, which are now spent`),!0}function R1(e){return e.refused?.reason==="point"?8:7}function Uo(e,t){return e.log(t),e.result.exitCode=1,e.result}async function Ite(e,t,n){if(n.point)return SDe(e,t,n,n.point);let{spec:i,k:r,wave:o,cwd:s}=t,{gate:a,digest:l,approval:c,base:u,policy:d,members:p}=n,{ledger:f,port:g}=await Ote(e,s,a,c,u),h=e.now??new Date().toISOString(),b=n.spend==="base"?(await f.readApplied?.(i.name)??[]).filter(R=>R.gate===a):void 0,w=n.heldBy?.length?`, held by ${n.heldBy.join(", ")}`:"",x=await L6(g,{op:i.name,gate:a,digest:l,description:(typeof n.pending?.description=="string"?n.pending.description:void 0)??`wave ${r} (${o.name}): ${p.length} run${p.length===1?"":"s"}, gate ${d}, approval ${c}${w}`,now:h,...b?{spent:b}:{},fields:{...n.pending,approvalMode:c},...n.neverOverMcp?{neverOverMcp:!0}:{}});if(x.satisfied){n.status="approved",n.via="ledger",n.approvedBy=x.resolution.resolvedBy,n.approvedAt=x.resolution.timestamp;return}Cte(t.log,`wave ${r} (${o.name})`,x),n.pendingFact=x.pending,n.recorded=x.recorded,n.waitingSince=x.pending.timestamp,x.mismatch&&(n.mismatch=x.mismatch);let k=b?.filter(R=>Mr([R],{gate:a,planDigest:l,timestamp:R.approvedAt})).pop();if(k&&t.log(`wave ${r} (${o.name}): the approval of ${l} by ${k.approvedBy} at ${k.approvedAt} is spent: a wave applied under it at ${k.timestamp}. Applying it again needs a new approval`),c==="pr-review"){let R=await ADe(e,{op:i.name,gate:a,k:r,digest:l,cwd:s,now:h,port:f,...b?{spent:b}:{}});if(n.review=R.review,R.approved){for(let $ of["pendingFact","recorded","waitingSince","mismatch"])delete n[$];n.status="approved",n.via="pr-review",n.approvedBy=R.review.approvers.join(", "),n.approvedAt=h;return}n.status="waiting",n.approve=jd(i.name,a,void 0,l);return}n.status="waiting",n.approve=jd(i.name,a,void 0,l,c==="sealed")}async function SDe(e,t,n,i){let{spec:r,k:o,wave:s,cwd:a,log:l}=t,{gate:c,digest:u,policy:d,members:p}=n;n.approval!=="ledger"&&l(`wave ${o} (${s.name}): its gate asks decision point ${i.name}, so its approval mode (${n.approval}) does not apply`);let{evaluatePointGate:f}=await Promise.resolve().then(()=>(ck(),$4)),g=e.points??(await Promise.resolve().then(()=>(C$(),yte))).workspaceGatePointAsker(a),h=n.heldBy?.length?`, held by ${n.heldBy.join(", ")}`:"",b=await f(e.gates??bs({cwd:a}),g,{op:r.name,gate:c,point:{name:i.name,...i.pass?{pass:i.pass}:{},...i.store?{store:i.store}:{}},...i.inputs?{inputs:i.inputs}:{},description:(typeof n.pending?.description=="string"?n.pending.description:void 0)??`wave ${o} (${s.name}): ${p.length} run${p.length===1?"":"s"}, gate ${d}, decision point ${i.name}${h}`,...i.timeout?{timeout:i.timeout}:{},planDigest:u,...e.now?{now:e.now}:{},fields:{...n.pending,approvalMode:n.approval},...n.neverOverMcp?{neverOverMcp:!0}:{}});if(b.satisfied){n.status="approved",n.via="point",n.approvedBy=b.resolution.resolvedBy,n.approvedAt=b.resolution.timestamp,i.answer=b.answer;return}if("refused"in b){n.status="refused",n.refused={reason:"point",runs:p.map(w=>w.member),message:b.refused},i.answer=b.answer;return}n.status="waiting",n.pendingFact=b.pending,n.recorded=b.recorded,n.waitingSince=b.pending.timestamp,i.question=b.waiting,n.approve=`chant workspace points answer ${b.waiting.id} --answer <answer> --by <your name>`,l(`wave ${o} (${s.name}) asks decision point ${i.name} about ${u}: question ${b.waiting.id} is ${b.waiting.state}`)}function Ho(e,t,n){n.hooks.length>0&&(t.outcomes=[...n.hooks]),M6(e,t)}async function Tte(e,t,n,i,r){let{k:o,wave:s,log:a,result:l}=t;return i.length===0||n.status==="approved"?!0:(n.heldBy=[...n.heldBy??[],...i],await Ite(e,t,n),r&&Ho(r,n,l),n.status==="refused"?(r&&await X$(t,n,r),a(`wave ${o} (${s.name}) is held by ${i.join(", ")}; nothing applied: ${n.refused?.message??"refused"}`),l.exitCode=R1(n),!1):n.status==="waiting"?(r&&await X$(t,n,r),a(`wave ${o} (${s.name}) is held by ${i.join(", ")}, and nobody approved ${n.digest}; nothing applied. Approve: ${n.approve}`),l.exitCode=3,!1):(a(`wave ${o} (${s.name}) is held by ${i.join(", ")}, and ${n.approvedBy} approved its digest`),!0))}function EDe(e,t,n){if($te(e))try{let i=JSON.parse(Fl(e,"utf-8"));if(!vM.includes(i.outcome))throw new Error(`outcome ${JSON.stringify(i.outcome)} is none of ${vM.join(", ")}`);if(i.reason!==void 0&&typeof i.reason!="string")throw new Error("its reason is not text");let r=i.holder&&typeof i.holder=="object"&&typeof i.holder.run=="string"?{run:i.holder.run,...typeof i.holder.url=="string"?{url:i.holder.url}:{}}:void 0;return{outcome:i.outcome,...i.reason?{reason:i.reason}:{},...r?{holder:r}:{}}}catch(i){n(`${t}: the apply wrote an outcome that cannot be read (${i instanceof Error?i.message:String(i)}), so its exit code decides`);return}}async function kte(e,t,n,i,r,o,s,a){let{spec:l,k:c,wave:u,cwd:d,exec:p,log:f,result:g}=t,h=n.applyHooksRunBy==="apply",b=`.chant/op-waves/${l.name}/wave-${c}`,w=`${b}/${s.key}.json`,x=`${b}/${s.key}-result.json`,k=`${b}/${s.key}-outcome.json`,R={};if(h)for(let $ of["before-apply","after-apply"])n.hooks?.[$]?.length&&(R[$]=n.hooks[$]);for(let $=0;$<2;$++){let _=n.status==="approved",T={version:1,opWaves:l.name,op:l.op,wave:u.name,number:c,base:n.base,digest:n.digest,approved:_,...n.heldBy?.length?{heldBy:n.heldBy}:{},runBy:h?"apply":"chant",runs:Pte(l,c,i,r),runsFile:s.runsPath,hooks:R,outcomes:[...g.hooks],...h?{result:x}:{}};Q$(bn(d,b),{recursive:!0}),k1(bn(d,w),JSON.stringify(T,null,2)+`
|
|
309
|
+
`),Yh(bn(d,x),{force:!0}),Yh(bn(d,k),{force:!0});let C;try{C=p(o,d,{CHANT_HOOKS:w,CHANT_APPLY_OUTCOME:k,...h?{CHANT_HOOKS_RESULT:x}:{}})}catch(Z){f(`${s.label}: the apply did not run: ${Z instanceof Error?Z.message:String(Z)}`),C=127}let K=EDe(bn(d,k),s.label,f);if(K){if(h)try{let Z=JSON.parse(Fl(bn(d,x),"utf-8"));Array.isArray(Z?.outcomes)&&g.hooks.push(...Z.outcomes)}catch{}return f(`${s.label}: the apply applied nothing: ${K.outcome}${K.reason?` (${K.reason})`:""}${K.holder?`, held by run ${K.holder.run}`:""}`),{outcome:"applied-nothing",said:K}}if(!h)return{outcome:C===0?"applied":"failed"};let O=null;try{O=JSON.parse(Fl(bn(d,x),"utf-8"))}catch{O=null}let pe=Array.isArray(O?.outcomes)?O.outcomes:[],F=Array.isArray(O?.moments)?O.moments:[];g.hooks.push(...pe);let Q=pe.filter(Z=>Z.moment==="before-apply"&&Z.outcome==="held").map(Z=>`${Z.moment} hook ${Z.name}${Z.target?` (${Z.target})`:""}`);if(Q.length>0&&!_){if(C===0)return f(`${s.label}: the apply exited 0 although ${Q.join(", ")} held it and no approval stood; an apply applies nothing on a hold`),{outcome:"failed"};if($>0||!await Tte(e,t,n,Q,a))return{outcome:"waiting"};if(!await S1(e,t,n))return{outcome:"failed"};a&&n.spentAt&&Ho(a,n,g);continue}let I=pe.find(Z=>Z.moment==="after-apply"&&Z.outcome==="failed");if(I)return{outcome:"applied",problem:`${s.label} applied, and then the after-apply hook ${I.name} failed`};if(C!==0)return{outcome:"failed"};let B=["before-apply","after-apply"].filter(Z=>R[Z]&&!F.includes(Z));return B.length>0?{outcome:"applied",problem:`${s.label}: the apply exited 0 without running its ${B.join(" and ")} hooks (runOpWaveApplyHooks with CHANT_HOOKS), which the spec at base hands it`}:{outcome:"applied"}}return{outcome:"failed"}}async function xte(e,t,n,i,r,o,s){let{spec:a,k:l,wave:c,log:u,result:d}=t;if(i.length===0)return;let p=n.applyHooksRunBy==="apply",f=[...o];if(!p){let w=await Ml(t,"before-apply",n.hooks?.["before-apply"],i,r,n.digest);if(w.failed){Uo(t,`a hook before the apply failed, so nothing in wave ${l} was applied`);return}if(w.waitingOn){$1(n,w.waitingOn),s&&(Ho(s,n,d),await X$(t,n,s)),d.decision=n,d.exitCode=3;return}f.push(...w.holds)}if(!await Tte(e,t,n,f,s)||!await S1(e,t,n)||!await _te(t,n))return;s&&(n.spentAt||n.overridesSpentAt)&&Ho(s,n,d);let g=[],h=!1,b;if(a.applyWave){let w=Y$(t,i,r,n.digest),x=Ip(a.applyWave,{op:a.op,wave:c.name,runs:w,plans:xM(a,l)}),k=await kte(e,t,n,i,r,x,{label:`wave ${l} (${c.name})`,key:"hooks",runsPath:w},s);k.outcome==="applied-nothing"?b=k.said:k.outcome==="applied"?(d.applied.push(...i.map(R=>R.target)),k.problem&&g.push(k.problem)):k.outcome==="waiting"?h=!0:(u(`wave ${l} (${c.name}): apply failed, so none of ${i.map(R=>R.target).join(", ")} counts as applied`),d.failed.push(...i.map(R=>R.target)))}else for(let w of i){let x=w.target.replace(/[^A-Za-z0-9._-]/g,"_"),k=p?Y$(t,[w],r,n.digest,`.chant/op-waves/${a.name}/wave-${l}/${x}.runs.json`):kM(a,l),R=Ip(a.apply??$T,{op:w.op??a.op,target:w.target,wave:c.name,plan:eR(a,l,w.target)}),$=await kte(e,t,n,[w],r,R,{label:w.target,key:`${x}.hooks`,runsPath:k},s);if($.outcome==="applied-nothing"){b=$.said;break}if($.outcome==="waiting"){h=!0;break}$.outcome==="applied"?(d.applied.push(w.target),$.problem&&g.push($.problem)):(u(`${w.target}: apply failed`),d.failed.push(w.target))}if(s&&p&&Ho(s,n,d),b){if(b.outcome==="replan"){d.replan={...b.reason?{reason:b.reason}:{}};return}d.outcome=b,d.exitCode=b.outcome==="stood-down"?6:5,s&&Ho(s,n,d);return}if(h){d.exitCode=n.status==="refused"?R1(n):3;return}if(d.failed.length>0){d.exitCode=1;return}if(g.length>0){for(let w of g)u(w);d.exitCode=1;return}p||(await Ml(t,"after-apply",n.hooks?.["after-apply"],i,r,n.digest)).failed&&Uo(t,`wave ${l} (${c.name}) applied, and then a hook after the apply failed`),s&&d.hooks.length>0&&Ho(s,n,d)}async function S1(e,t,n){if(!n.spend||n.status!=="approved"||n.spentAt||!n.approvedAt)return!0;let{spec:i,k:r,wave:o,cwd:s,log:a}=t,l=e.gates??bs({cwd:s}),c=e.now??new Date().toISOString(),u={version:1,kind:"applied",op:i.name,gate:n.gate,planDigest:n.digest,approvedAt:n.approvedAt,approvedBy:n.approvedBy??"",timestamp:c,wave:{number:r,name:o.name},...n.via==="pr-review"&&n.review?{review:{...n.review.pr!==void 0?{pr:n.review.pr}:{},...n.review.head?{head:n.review.head}:{}}}:{}};try{if(!l.appendApplied)throw new Error("this gate ledger cannot record an applied approval");let d=await l.appendApplied(u);!d.pushed&&d.pushWarning&&a(`wave ${r} (${o.name}): ${d.pushWarning}`)}catch(d){return Uo(t,`wave ${r} (${o.name}) could not record that it applies under the approval by ${u.approvedBy}, so nothing applied: ${d instanceof Error?d.message:String(d)}`),!1}return n.spentAt=c,a(`wave ${r} (${o.name}) applies under the approval by ${u.approvedBy} at ${u.approvedAt}, which is now spent`),!0}async function ADe(e,t){let n=await Promise.resolve().then(()=>(ig(),rg)),i=e.head??Z$("git",["rev-parse","HEAD"],{cwd:t.cwd,encoding:"utf-8"}).trim(),r;try{r=await(e.reviews??n.reviewSourceFromEnv()).mergedReview(i)}catch(c){return{approved:!1,review:{reason:`the forge's review could not be read: ${c instanceof Error?c.message:String(c)}`}}}if(!r)return{approved:!1,review:{reason:`no merged pull request produced ${i.slice(0,12)}`}};let o=r.approvers.length===0?null:await(e.headPlans??((c,u)=>PDe(c,u,t.cwd)))(e.spec.name,r.head),{reviewApproval:s}=await Promise.resolve().then(()=>(jT(),NT)),a=s(r,o?.waves.find(c=>c.wave===t.k)?.digest,t.digest);if(!a.approved)return a;if(t.spent&&Mr(t.spent,{gate:t.gate,planDigest:t.digest,review:{head:r.head}}))return{approved:!1,review:{...a.review,reason:`a wave already applied ${t.digest} under the review of #${r.pr} at ${r.head.slice(0,12)}, so the review is spent`}};let l=`approved by the review of #${r.pr} at ${r.head.slice(0,12)}: ${r.approvers.join(", ")}`;return await t.port.appendResolution?.({op:t.op,gate:t.gate,resolvedBy:r.approvers[0],timestamp:t.now,planDigest:t.digest,approver:{kind:"human"},note:l,...r.url?{url:r.url}:{},review:{pr:r.pr,head:r.head,approvers:r.approvers}}),a}async function PDe(e,t,n){let{gitLedgerReadPort:i,requireLifecycleLedger:r}=await Promise.resolve().then(()=>($t(),H0)),{readHeadPlans:o}=await Promise.resolve().then(()=>(CT(),o4));return await r({cwd:n}),o(i({cwd:n}),e,t)}async function EM(e){let{spec:t}=e;Zm(t);let n=e.cwd??process.cwd(),i=e.exec??Rte,r=await Promise.resolve().then(()=>(ig(),rg)),o=e.head??r.pullRequestHeadFromEnv()??Z$("git",["rev-parse","HEAD"],{cwd:n,encoding:"utf-8"}).trim(),s={version:1,name:t.name,head:o,timestamp:e.now??new Date().toISOString(),waves:[]},a=t.waves[t.waves.length-1];for(let l=1;;l++){let c=t.waves[l-1]??a,{members:u,extras:d,waves:p}=v1({spec:t,k:l,wave:c,cwd:n,exec:i},c.runs,c.discover===!0);if(s.waves.push({wave:l,name:c.name,digest:$M(t,u,d)}),l>=t.waves.length&&!(a.rest&&p!==void 0&&l<p))break}return await(e.write??(l=>ODe(l,n)))(s),s}async function ODe(e,t){let{pushLifecycle:n,requireLifecycleLedger:i,writeBlobToPath:r}=await Promise.resolve().then(()=>($t(),H0)),{headPlansPath:o}=await Promise.resolve().then(()=>(ig(),rg));await i({cwd:t});let{dir:s,file:a}=o(e.name,e.head);if(await r(s,a,JSON.stringify(e,null,2)+`
|
|
310
|
+
`,`Op waves plans of ${e.name} at ${e.head.slice(0,12)}`,{cwd:t}),!await n({cwd:t}))throw new Error("the plans were recorded locally only: chant/lifecycle has no remote to push to")}var fDe,vM,Rte,mDe,bte,wDe,Pte,wte,SM,AM=v(()=>{"use strict";F6();Gi();Hc();Bd();fDe=["version","kind","op","gate","timestamp","expiresAt","planDigest","runId","url","resume","environment","origin","neverOverMcp","approval","approvalMode","answer","wave","heldBy"],vM=["stood-down","held","replan"],Rte=(e,t,n)=>{let i=dDe(e[0],e.slice(1),{cwd:t,stdio:"inherit",...n?{env:{...process.env,...n}}:{}});if(i.error)throw i.error;return i.status??1},mDe=(e,t,n)=>{let i;try{i=Z$("git",["rev-parse","--verify",`${e}^{commit}`],{cwd:n,encoding:"utf-8",stdio:["ignore","pipe","pipe"]}).trim()}catch{throw new Error(`the gate policy is read at ${e}, which this checkout does not have. Check out the full history (fetch-depth: 0 on GitHub and Forgejo, GIT_DEPTH: "0" on GitLab), or set the spec's base.`)}try{let r=Z$("git",["show",`${i}:./${t}`],{cwd:n,encoding:"utf-8",stdio:["ignore","pipe","pipe"]});return{sha:i,text:r}}catch{return{sha:i,text:null}}};bte=()=>Object.fromEntries(Qv.map(e=>[e,[]]));wDe=e=>({name:e.spec.name,op:e.spec.op,waveName:e.wave.name,k:e.k,cwd:e.cwd,exec:e.exec,log:e.log}),Pte=(e,t,n,i)=>n.map(r=>({target:r.target,op:r.op??e.op,...i?.has(r.target)?{plan:eR(e,t,r.target)}:{}}));wte=10;SM=10});var Lte=v(()=>{"use strict";On()});var E1,Mte=v(()=>{"use strict";Lte();E1=/^pr-\d+(?:-[a-z0-9][a-z0-9-]*)?$/});async function Fte(e){let{resolutions:t,pending:n}=await Lr(In,e),i=await rn(_De,IDe,e);return{resolutions:t,pending:n,applied:i?TT(i):[]}}var _De,IDe,Bte=v(()=>{"use strict";Wt();Mi();$t();og();_De=`_gates/${In}`,IDe="applied.jsonl"});var Wte={};_e(Wte,{runOverrideApprove:()=>TDe});async function TDe(e){let t=e.args.extraPositional,n=ok(t,e.args.rules?.length?e.args.rules:["<id>"]);if(e.args.reason!==void 0&&e.args.note!==void 0&&e.args.reason.trim()!==e.args.note.trim())return console.error(fe({message:"Give the override's reason once: --reason <text> (--note is the same field)",hint:n})),1;let i=(e.args.reason??e.args.note)?.trim(),r=Ta(e.args.rules??[]);if(r.length===0)return console.error(fe({message:"An override names each rule it overrides with --rule <id>",hint:n})),1;if(!i)return console.error(fe({message:"An override needs --reason <text>: why this plan goes out although the policy denies it",hint:n})),1;if(e.args.agent||Xr(ts()))return console.error(fe({message:"An override is a person's: it is never recorded by an agent or over MCP or ACP",hint:`${n}, at a shell.`})),1;try{await si()}catch(d){return console.error(fe({message:`Cannot record the override: ${d instanceof Error?d.message:String(d)}`})),1}let o=await Fte(),s=sk(o.pending),a=s.find(d=>d.gate===t);if(!a)return console.error(fe({message:`No denial of ${t} is recorded on ${In}`+(s.length?`; denied: ${s.map(d=>d.gate).join(", ")}`:""),hint:"A run records one when its policy denies the plan. An override answers that denial, for that plan."})),1;if(a.rules.join(`
|
|
311
|
+
`)!==r.join(`
|
|
312
|
+
`))return console.error(fe({message:`${t} was denied by ${a.rules.join(", ")||"no rule it named"}; an override names exactly those rules, and --rule gave ${r.join(", ")}`,hint:ok(t,a.rules)})),1;if(e.args.plan!==void 0&&!mt(e.args.plan,a.plan)&&!mt(e.args.plan,a.planDigest))return console.error(fe({message:`--plan ${e.args.plan} is not the plan denied for ${t}: the newest denial is of ${a.plan||a.planDigest}`,hint:"Run the plan again, or override the denial that stands."})),1;let l=await A1(In,t,{actor:e.args.approver??e.args.actor,note:i,url:e.args.url,plan:a.planDigest,allowSameOrigin:e.args.allowSameOrigin,...e.args.roles?{roles:e.args.roles}:{},...e.args.sign!==void 0?{sign:e.args.sign}:{},...e.args.relayedBy!==void 0?{relayedBy:e.args.relayedBy}:{}});if(!l.ok)return 1;if(console.error(ur(`This overrides the denial of ${t} by ${r.join(", ")} for the plan ${a.plan||a.planDigest}. The next run that plans it applies it once; a plan that moves, or rules that change, need their own override.`)),process.env.CHANT_OVERRIDERS_FROM?.trim())return 0;let u=IT(process.cwd(),"HEAD");return u.active?u.principals.map(Gte).includes(Gte(l.record.resolvedBy))||console.error(Vr({message:`${l.record.resolvedBy} is not in ${Gd} here (${u.principals.join(", ")||"nobody"}), so a run that reads it at base does not count this override`})):console.error(Vr({message:`This checkout has no ${Gd}: unless the run reads its overriders from elsewhere at base, no override counts (a tool that does sets CHANT_OVERRIDERS_FROM to say so)`})),0}var Gte,zte=v(()=>{"use strict";Rc();$t();Bte();On();og();Kn();P1();Gte=e=>e.normalize("NFKC").trim().toLowerCase()});async function Hte(e){let{pushed:t,pushWarning:n}=await ba();return t?{pushed:t,suffix:""}:L0(n)?{pushed:t,suffix:` (${od})`}:(console.error(Vr({message:`The push to the remote did not land: ${n??"no reason given"}`,hint:e})),{pushed:t,suffix:" (local only \u2014 the push did not land)"})}async function Vte(e){let t=e.args.path,n=e.args.extraPositional;if(!t||t==="."||!n)return console.error(fe({message:"Usage: chant approve <op> <gate>"})),1;if(e.args.expire){try{await si()}catch(a){return console.error(fe({message:`Cannot expire the gate: ${a instanceof Error?a.message:String(a)}`})),1}let r=new Date().toISOString(),o=Cn((await Lr(t)).pending,n);if(!o||Wn(o,r))return console.error(Vr({message:`Gate "${n}" on "${t}" has no standing pending fact \u2014 nothing to expire`})),0;await md({op:t,gate:n,timestamp:r,expiresAt:r,...o.description?{description:o.description}:{}});let s=await Hte(`The expiry is recorded locally on ${Ute}. Until it reaches the remote, a run in another checkout still sees the old pending fact.`);return console.error(Dp(`Gate "${n}" on "${t}" expired at ${r} \u2014 not approved`+s.suffix)),console.error(ur(t===Au?"The next `chant components fan-out` decides this gate from scratch and records a fresh pending fact.":E1.test(t)?"The next `chant components pr-apply` decides this gate from scratch and records a fresh pending fact.":t===Pu?`The next \`chant workspace upgrade ${n}\` 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===ea){let{runOverrideApprove:r}=await Promise.resolve().then(()=>(zte(),Wte));return r(e)}if(e.args.rules!==void 0||e.args.reason!==void 0)return console.error(fe({message:`--rule and --reason override a denied plan: chant approve ${ea} <subject> --rule <id> --reason <text>`,hint:`To approve gate "${n}" on "${t}", put any prose in --note.`})),1;let i=await A1(t,n,{actor:e.args.approver??e.args.actor,note:e.args.note,url:e.args.url,plan:e.args.plan,...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.relayedBy!==void 0?{relayedBy:e.args.relayedBy}:{}});if(!i.ok)return 1;if(e.args.resumeRun||e.args.resume!==void 0){let{resumeAfterApproval:r}=await Promise.resolve().then(()=>(k$(),JL));return r(t,n,i.record.environment,i.pushed)}return console.error(ur("This records the resolution as a fact; it does not itself re-run anything. "+(t===Au?`Repeat the \`chant components fan-out\` command and it walks through gate "${n}".`:E1.test(t)?`The pull request's apply (\`chant components pr-apply\`) walks through gate "${n}" when it plans this same digest.`:t===Pu?`Repeat \`chant workspace upgrade ${n}\` with the same target, and it applies the patch this approval names.`:`Run \`chant run ${t}\` and it walks through gate "${n}".`))),0}async function A1(e,t,n){let{ops:i}=await vs();!i.has(e)&&e!==Au&&e!==Pu&&e!==ea&&console.error(Vr({message:`Op "${e}" was not found among discovered *.op.ts declarations \u2014 recording the resolution anyway`}));try{await si()}catch(F){return console.error(fe({message:`Cannot record the approval: ${F instanceof Error?F.message:String(F)}`,hint:"The pending fact this answers lives on that branch; appending without it would drop it."})),{ok:!1}}let r=n.url??ss();if(r&&!cv(r))return console.error(fe({message:`--url must be an absolute http/https URL (got "${r}")`,hint:"Pass the PR/MR link, or omit --url and put prose in --note."})),{ok:!1};let o=await Lr(e),s=F=>F.some(I=>I.gate===t&&I.environment!==void 0)&&n.environment!==void 0?F.filter(I=>I.environment===n.environment):F,a=Cn(s(o.pending),t),l=a?.environment,c;if(n.plan!==void 0){if(!Y0(n.plan))return console.error(fe({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};c=n.plan}else{if(!a)return console.error(fe({message:n.environment!==void 0&&o.pending.some(F=>F.gate===t&&F.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};c=a.planDigest}let u=n.origin??ts(),d=await Lr(e),p=Cn(s(d.pending),t);if(Xr(u)&&(p?.neverOverMcp||i.get(e)?.config.neverOverMcp))return console.error(fe({message:`Gate "${t}" on "${e}" is never resolved over ${u==="acp"?"ACP":"MCP"}`,hint:`Approvals belong to people: \`chant approve ${e} ${t}\` at a shell.`})),{ok:!1};if(p?.answer)return console.error(fe({message:`Gate "${t}" on "${e}" asks decision point ${p.answer.point}, so its answer passes the gate, not an approval`,hint:`Answer the question: \`chant workspace points answer ${p.answer.id} --answer <value> --by <name>\`, then run \`chant run ${e}\` again.`})),{ok:!1};let f=tU(p?.origin,u);if(f&&!n.allowSameOrigin)return console.error(fe({message:`Gate "${t}" on "${e}" cannot be resolved from here: ${f}`,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 g=n.relayedBy?.trim();if(n.relayedBy!==void 0&&(!g||/[\r\n]/.test(g)))return console.error(fe({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 h=n.actor??(Xr(u)?dw:process.env.GITHUB_ACTOR??process.env.GITLAB_USER_LOGIN??process.env.USER??"unknown"),b={kind:n.agent||Xr(u)?"agent":"human",...n.roles&&n.roles.length>0?{roles:[...new Set(n.roles)]}:{}},w=n.cwd??process.cwd(),x=await Promise.resolve().then(()=>(nl(),dT)),{scopeSource:k}=await Promise.resolve().then(()=>(gs(),C6)),R=k(w);try{x.refuseUnidentified(R,[h],n.actor!==void 0?"--actor":"the approver"),g&&x.refuseUnidentified(R,[g],"--relayed-by")}catch(F){if(!(F instanceof x.IdentityError))throw F;return console.error(fe({message:`Gate "${t}" on "${e}" was not approved: ${F.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 $=x.gateAdmissionFrom(R,t);if($&&n.sign===void 0)return console.error(fe({message:`Gate "${t}" needs a signed approval: chant.workspace.json at base names it in identity.gates`+($.requirement.class!==null?`, from the class ${$.requirement.class}`:"")+", and this approval is not signed",hint:`chant approve ${e} ${t} --actor <principal> --sign [<key file>], with a key ${R.policy.signersPath} at base lists for that principal.`})),{ok:!1};let _=new Date().toISOString(),T;if(n.sign!==void 0){let{resolveSigningKey:F,sealGateApproval:Q,SealError:I}=await Promise.resolve().then(()=>(Hd(),Ud));try{let B=F(n.sign,w);try{T=Q(B.file,{op:e,gate:t,...l!==void 0?{environment:l}:{},...c!==void 0?{planDigest:c}:{},resolvedBy:h,...g?{relayedBy:g}:{},timestamp:_})}finally{B.cleanup()}}catch(B){if(!(B instanceof I))throw B;return console.error(fe({message:`Gate "${t}" on "${e}" was not approved: ${B.message}`})),{ok:!1}}}if($){let F=$.refuses({op:e,gate:t,...l!==void 0?{environment:l}:{},...c!==void 0?{planDigest:c}:{},resolvedBy:h,...g?{relayedBy:g}:{},timestamp:_,seal:T});if(F!==null)return console.error(fe({message:`Gate "${t}" on "${e}" was not approved: ${F}`,hint:`identity.gates.${t} in chant.workspace.json at base counts only an approval signed by a key ${R.policy.signersPath} lists for the approver`+($.requirement.class!==null?`, who holds the role of the class ${$.requirement.class}`:"")+"."})),{ok:!1}}let C=p?.approval,K;if(C?.policy)try{let Q=await(n.evaluator??await Q0(C.policy.lexicon)).evaluateGatePolicy(C.policy,eI({op:e,gate:t,resolvedBy:h,approver:b,...c!==void 0?{planDigest:c}:{},...C.context?{context:C.context}:{}}));K={policy:C.policy.name,version:C.policy.version,mode:C.mode,contextDigest:Sm(C.context),decision:Q.decision,determining:Q.determining,errors:Q.errors}}catch(F){return console.error(fe({message:`Gate "${t}" on "${e}" declares policy "${C.policy.name}", which could not be evaluated: ${F instanceof Error?F.message:String(F)}`,hint:`Install the ${C.policy.lexicon} lexicon in this project, or approve from a checkout that has it.`})),{ok:!1}}let{record:O}=await $m({op:e,gate:t,resolvedBy:h,...g?{relayedBy:g}:{},timestamp:_,...T?{seal:T}:{},approver:b,...K?{policyDecision:K}:{},...n.note?{note:n.note}:{},...r?{url:r}:{},...c!==void 0?{planDigest:c}:{},...l!==void 0?{environment:l}:{},origin:u,...f&&n.allowSameOrigin?{sameOriginOverride:!0}:{}}),pe=await Hte(`The resolution is recorded locally on ${Ute}. Until it reaches the remote, a run in another checkout will not see it.`);if(console.error(Dp(`Gate "${t}" on "${e}" resolved by ${O.resolvedBy}`+(O.relayedBy?`, relayed by ${O.relayedBy},`:"")+` at ${O.timestamp}`+(O.url?` (${O.url})`:"")+(O.seal?`, signed with ${O.seal.key}`:"")+pe.suffix)),O.planDigest&&console.error(ur(`This approves the plan ${O.planDigest}`+(O.environment!==void 0?` in environment "${O.environment}"`:"")+", and only that plan. A run whose fresh plan differs refuses rather than applying it.")),C)for(let F of DDe(C,O,d.resolutions,p,d.pending))console.error(ur(F));return{ok:!0,record:O,pushed:pe.pushed}}function DDe(e,t,n,i,r=i?[i]:[]){let o=[],s=t.policyDecision;if(s){let p=s.determining.length>0?` (${s.determining.join(", ")})`:"",f=e.mode==="enforce"?s.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.";o.push(`Policy "${s.policy}" ${s.version}: ${s.decision}${p}. ${f}`);for(let g of s.errors)o.push(`Policy evaluation error: ${g}`)}let a=i?.timestamp??new Date(0).toISOString(),l=i&&mt(i.planDigest,t.planDigest)?il(r,i):a,c=rl([...n,t],t.gate,a,t.planDigest,e,l),u=e.quorum?.roles?` with role ${e.quorum.roles.join(" or ")}`:"",d=c.counted.map(p=>p.resolvedBy).join(", ")||"none yet";return o.push(`Quorum: ${c.counted.length} of ${c.need} human approval(s)${u} for this plan (${d}).`),c.counted.includes(t)||o.push(Kv(t).kind==="agent"?"An agent's approval does not count toward the quorum.":`This approval does not count toward the quorum: the approver claims none of its roles (${e.quorum?.roles?.join(", ")}).`),o}var Ute,P1=v(()=>{"use strict";Wi();Rc();Mi();On();Em();Gi();Oi();Mte();$t();iv();Kn();Ute="chant/lifecycle"});rR();var Qte=new Set(["--help","--open","--version","--agents","--agent","--all-projects","--force","--fix","--watch","--verbose","--live","--overlay","--explain","--owned","--verbatim","--apply-rewrites","--write","--strict","--validate","--use-composites","--composites","--stacks","--components","--up","--down","--include-dependents","--local","--json","--progress-json","--update-snapshot","--update-baseline","--run-examples","--check","--bump","--no-release-record","--fold","--no-fold","--no-cache","--sandbox","--yes","--confirm-prod","--once","--expire","--check-live","--check-snapshot","--fail-on-drift","--durable-requests","--skip-mcp","--current","--uncommitted","--allow-code","--root-only","--generated","--decide","--record-plans"]);function C1(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,src:void 0,env:void 0};e=O1(e,Qte);let n=0;for(;n<e.length;){let i=e[n];if(i==="--help"||i==="-h")t.help=!0;else if(i==="--version"||i==="-V")t.version=!0;else if(i==="--output"||i==="-o")t.output=e[++n];else if(i==="--format"||i==="-f")t.format=e[++n];else if(i==="--lexicon"||i==="-d")t.lexicon=e[++n];else if(i==="--template"||i==="-t")t.template=e[++n];else if(i==="--force")t.force=!0;else if(i==="--fix")t.fix=!0;else if(i==="--watch"||i==="-w")t.watch=!0;else if(i==="--verbose"||i==="-v")t.verbose=!0;else if(i==="--profile"||i==="-p")t.profile=e[++n];else if(i==="--report"){let r=e[n+1];r&&!r.startsWith("-")?(t.reportFile=r,n++):t.report=!0}else if(i==="--live")t.live=!0;else if(i==="--overlay")t.overlay=!0;else if(i==="--between"){if(t.betweenA=e[++n],t.betweenB=e[++n],!t.betweenA||!t.betweenB)throw new Error("--between needs two snapshot refs: --between <refA> <refB>")}else if(i==="--traffic"){let r=e[++n];if(!r)throw new Error('--traffic needs a level, passed to the engine verbatim: --traffic "100 rps, p50"');t.traffic=r}else if(i==="--overlay-anchor"){let r=e[++n];if(r!=="source"&&r!=="live")throw new Error(`--overlay-anchor must be 'source' or 'live', got '${r}'`);t.overlayAnchor=r}else if(i==="--from")t.migrateFrom=e[++n];else if(i==="--kustomize")t.kustomize=e[++n];else if(i==="--parser-option"){let r=e[++n];if(!r||r.startsWith("-"))throw new Error("--parser-option needs key or key=value: --parser-option acceptLossyV1");(t.parserOption??=[]).push(r)}else if(i==="--type")t.selectType=e[++n];else if(i==="--name")t.selectName=e[++n];else if(i==="--owned")t.owned=!0;else if(i==="--namespace"){if(t.namespace=e[++n],!t.namespace||t.namespace.startsWith("-"))throw new Error("--namespace needs a namespace: --namespace <ns>")}else if(i==="--verbatim")t.verbatim=!0;else if(i==="--state")t.statePath=e[++n];else if(i==="--select")t.selectAddress=e[++n];else if(i==="--live-name")t.liveName=e[++n];else if(i==="--apply-rewrites")t.applyRewrites=!0;else if(i==="--stack")t.carveStack=e[++n];else if(i==="--write")t.write=!0;else if(i==="--write-source")t.writeSource=!0;else if(i==="--to")t.migrateTo=e[++n];else if(i==="--emit")t.emit=e[++n];else if(i==="--dry-run")t.dryRun=!0;else if(i==="--yes")t.yes=!0;else if(i==="--confirm-prod")t.confirmProd=!0;else if(i==="--strict")t.strict=!0;else if(i==="--validate")t.validate=!0;else if(i==="--use-composites")t.useComposites=!0;else if(i==="--skill")t.skill=e[++n];else if(i==="--skip-mcp")t.skipMcp=!0;else if(i==="--src")t.src=e[++n];else if(i==="--env")t.env=e[++n];else if(i==="--port"){let r=e[++n];if(!r||r.startsWith("-"))throw new Error("--port needs a port: --port <container-port>=<host-port>");(t.port??=[]).push(r)}else if(i==="--promote-to"){if(t.promoteTo=e[++n],!t.promoteTo||t.promoteTo.startsWith("-"))throw new Error("--promote-to needs an environment: --promote-to <env>")}else if(i==="--tier")t.tier=e[++n];else if(i==="--agents")t.agents=!0;else if(i==="--scope")t.scope=e[++n];else if(i==="--all-projects")t.allProjects=!0;else if(i==="--runtime")t.runtime=e[++n];else if(i==="--fail-on")t.failOn=e[++n];else if(i==="--max-files")t.maxFiles=Number(e[++n]);else if(i==="--theme")t.theme=e[++n];else if(i==="--stacks")t.stacks=!0;else if(i==="--components")t.components=!0;else if(i==="--generate")t.generate=e[++n];else if(i==="--spec")t.opsSpec=e[++n];else if(i==="--dump-outputs")t.dumpOutputs=e[++n];else if(i==="--digest-file")t.digestFile=e[++n];else if(i==="--seed-outputs")(t.seedOutputs??=[]).push(e[++n]);else if(i==="--detail")t.detail=Number(e[++n]);else if(i==="--lens")t.lens=e[++n];else if(i==="--explain")t.explain=!0;else if(i==="--show")t.show=e[++n];else if(i==="--up")t.up=!0;else if(i==="--down")t.down=!0;else if(i==="--node-sizes")t.nodeSizes=e[++n];else if(i==="--layout-engine")t.layoutEngine=e[++n];else if(i==="--base")t.base=e[++n];else if(i==="--head")t.head=e[++n];else if(i==="--include-dependents")t.includeDependents=!0;else if(i==="--from-affected")t.fromAffected=e[++n];else if(i==="--gate")t.gate=e[++n];else if(i==="--wave-gate"){if(t.waveGate=e[++n],!t.waveGate||t.waveGate.startsWith("-"))throw new Error("--wave-gate needs a gate name: --wave-gate <name>")}else if(i==="--wave"){let r=e[++n],o=Number(r);if(!Number.isInteger(o)||o<1)throw new Error(`--wave needs a wave number from 1: got "${r??""}"`);t.wave=o}else if(i==="--decide")t.decide=!0;else if(i==="--record-plans")t.recordPlans=!0;else if(i==="--share"){let r=e[++n],o=Number(r);if(!Number.isInteger(o)||o<1)throw new Error(`--share needs a share number from 1: got "${r??""}"`);t.share=o}else if(i==="--canary"){let r=e[++n];if(!r||r.startsWith("-"))throw new Error("--canary needs a component name: --canary <name>[,<name>...]");(t.canary??=[]).push(...r.split(",").map(o=>o.trim()).filter(Boolean))}else if(i==="--pr"){let r=e[++n],o=Number(r);if(!Number.isInteger(o)||o<1)throw new Error(`--pr needs a pull or merge request number: got "${r??""}"`);t.pr=o}else if(i==="--forge"){if(t.forge=e[++n],!t.forge||t.forge.startsWith("-"))throw new Error("--forge needs a forge: --forge github|gitlab|forgejo")}else if(i==="--require-review")t.requireReview=!0;else if(i==="--pr-loop")t.prLoop=!0;else if(i==="--resume"){let r=e[n+1];r===void 0||r.startsWith("-")?t.resumeRun=!0:t.resume=e[++n]}else if(i==="--local")t.local=!0;else if(i==="--json")t.json=!0;else if(i==="--progress-json")t.progressJson=!0;else if(i==="--gated-exit")t.gatedExit=Number(e[++n]);else if(i==="--durable-requests")t.durableRequests=!0;else if(i==="--update-snapshot")t.updateSnapshot=!0;else if(i==="--update-baseline")t.updateBaseline=!0;else if(i==="--deep")t.deep=!0;else if(i==="--at")t.at=e[++n];else if(i==="--kind"){if(t.kind=e[++n],!t.kind||t.kind.startsWith("-"))throw new Error("--kind needs a kind file: --kind <path>");(t.kinds??=[]).push(t.kind)}else if(i==="--composites")t.composites=!0;else if(i==="--intent"){let r=e[n+1];if(r!==void 0&&!r.startsWith("-"))t.intent=e[++n];else if(e.includes("--record"))t.intent="";else throw new Error("--intent needs a region: --intent <path[:start-end]|path#symbol>, or --intent --record <id>")}else if(i==="--follow-squash")t.followSquash=!0;else if(i==="--record"){if(t.record=e[++n],!t.record||t.record.startsWith("-"))throw new Error("--record needs a record id: --record <id>")}else if(i==="--path"){let r=e[++n];if(!r||r.startsWith("-"))throw new Error("--path needs a path: --path <path>");(t.paths??=[]).push(r)}else if(i==="--worktree")t.worktree=!0;else if(i==="--max-bytes"){let r=Number(e[++n]);if(!Number.isInteger(r)||r<1)throw new Error("--max-bytes needs a whole number of bytes above 0");t.maxBytes=r}else if(i==="--changes"){if(t.changes=e[++n],!t.changes||t.changes.startsWith("-"))throw new Error("--changes needs a range: --changes <base>..<head>")}else if(i==="--severity"){if(t.severity=e[++n],!t.severity||t.severity.startsWith("-"))throw new Error("--severity needs off, warn or fail")}else if(i==="--current")t.current=!0;else if(i==="--uncommitted")t.uncommitted=!0;else if(i==="--set"){if(t.set=e[++n],!t.set||t.set.startsWith("-")&&t.set!=="-")throw new Error("--set needs a JSON file, or - for standard input: --set <file|->")}else if(i==="--cover"){if(t.cover=e[++n],!t.cover||t.cover.startsWith("-"))throw new Error("--cover needs a PNG, JPEG or WebP file: --cover <image>")}else if(i==="--cover-path"){if(t.coverPath=e[++n],!t.coverPath||t.coverPath.startsWith("-"))throw new Error("--cover-path needs a path from the workspace root: --cover-path <path>")}else if(i==="--records")t.records=!0;else if(i==="--expect"){if(t.expect=e[++n],!t.expect||t.expect.startsWith("-"))throw new Error("--expect needs the record's digest, as records --json prints it: --expect <digest>")}else if(i==="--label"){if(t.label=e[++n],!t.label||t.label.startsWith("-"))throw new Error("--label needs the snapshot's name, such as a turn id: --label <text>")}else if(i==="--branch"){if(t.branch=e[++n],!t.branch||t.branch.startsWith("-"))throw new Error("--branch needs a branch name: --branch <branch>")}else if(i==="--workflow"){let r=e[++n];if(!r||r.startsWith("-"))throw new Error("--workflow needs a workflow's name: --workflow <name>");t.ciWorkflows=[...t.ciWorkflows??[],r]}else if(i==="--chant"){if(t.ciChant=e[++n],!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(i==="--install"){if(t.ciInstall=e[++n],!t.ciInstall||t.ciInstall.startsWith("-"))throw new Error('--install needs the install command, such as "npm install": --install <command>')}else if(i==="--token-secret"){if(t.ciTokenSecret=e[++n],!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(i==="--app-id-var"){if(t.ciAppIdVar=e[++n],!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(i==="--app-key-secret"){if(t.ciAppKeySecret=e[++n],!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(i==="--verdict"){if(t.verdict=e[++n],!t.verdict||t.verdict.startsWith("-"))throw new Error("--verdict needs agree, dissent or abstain")}else if(i==="--by"){if(t.by=e[++n],!t.by||t.by.startsWith("-"))throw new Error("--by needs the reviewer: --by <principal>");(t.bys??=[]).push(t.by)}else if(i==="--open")t.open=!0;else if(i==="--inputs"){if(t.inputs=e[++n],!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(i==="--candidates"){if(t.candidates=e[++n],!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(i==="--response"){if(t.response=e[++n],!t.response||t.response.startsWith("-"))throw new Error("--response needs a JSON file: --response <file>")}else if(i==="--subject"){if(t.subject=e[++n],!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(i==="--store"){let r=e[++n];if(r!=="tree"&&r!=="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=r}else if(i==="--answer"){if(t.answer=e[++n],t.answer===void 0||t.answer==="")throw new Error("--answer needs one of the question's candidates: --answer <value>")}else if(i==="--sign"){let r=e[n+1];t.sign=r!==void 0&&!r.startsWith("-")?e[++n]:!0}else if(i==="--session"){if(t.session=e[++n],!t.session||t.session.startsWith("-"))throw new Error("--session needs a session id: --session <id>")}else if(i==="--prefix"){if(t.prefix=e[++n],!t.prefix||t.prefix.startsWith("-"))throw new Error("--prefix needs an id prefix: --prefix <prefix>")}else if(i==="--key"||i==="--check-id"||i==="--claim"||i==="--environment"||i==="--envelope"||i==="--threshold"){let r=e[++n];if(r===void 0||r.startsWith("-"))throw new Error(`${i} needs a value`);let o={"--key":"key","--check-id":"checkId","--claim":"claim","--environment":"environment","--envelope":"envelope","--threshold":"threshold"}[i];t[o]=r}else if(i==="--require"){if(t.require=e[++n],!t.require||t.require.startsWith("-"))throw new Error("--require needs a provenance level: --require attested")}else if(i==="--ambient")t.ambient=!0;else if(i==="--check-live")t.checkLive=!0;else if(i==="--check-snapshot")t.checkSnapshot=!0;else if(i==="--fail-on-drift")t.failOnDrift=!0;else if(i==="--run-examples")t.runExamples=!0;else if(i==="--pinned-digest")t.pinnedDigest=e[++n];else if(i==="--check")t.check=!0;else if(i==="--bump")t.bump=!0;else if(i==="--component")t.component=e[++n];else if(i==="--digest")t.digest=e[++n],t.digest!==void 0&&(t.digests??=[]).push(t.digest);else if(i==="--release-plan")t.releasePlanFile=e[++n];else if(i==="--git-sha")t.gitSha=e[++n];else if(i==="--run-id")t.runId=e[++n];else if(i==="--actor")t.actor=e[++n];else if(i==="--approver")t.approver=e[++n];else if(i==="--relayed-by"){if(t.relayedBy=e[++n],!t.relayedBy||t.relayedBy.startsWith("-"))throw new Error("--relayed-by needs the principal that relayed it: --relayed-by <principal>")}else if(i==="--on"){if(t.on=e[++n],!t.on||t.on.startsWith("-"))throw new Error("--on needs a runtime name: --on <lexicon>")}else if(i==="--compare-to")t.compareTo=e[++n];else if(i==="--no-release-record")t.noReleaseRecord=!0;else if(i==="--fold")t.fold=!0;else if(i==="--no-cache")t.noCache=!0;else if(i==="--no-fold")t.fold=!1;else if(i==="--sandbox")t.sandbox=!0;else if(i==="--fold-rank"){let r=e[n+1];r&&!r.startsWith("-")?(t.foldRankCollapsedFile=r,n++):t.foldRank=!0}else if(i==="--param")(t.param??=[]).push(e[++n]);else if(i==="--lexicon-output")(t.lexiconOutput??=[]).push(e[++n]);else if(i==="--params-file")t.paramsFile=e[++n];else if(i==="--projection")t.projection=e[++n];else if(i==="--interval")t.interval=e[++n];else if(i==="--lease-ttl")t.leaseTtl=e[++n];else if(i==="--steward"){let r=e[n+1];r!==void 0&&!r.startsWith("-")?(t.steward=r,n++):t.steward=""}else if(i==="--once")t.once=!0;else if(i==="--work"){let r=e[++n];if(!r||r.startsWith("-"))throw new Error("--work needs a work item id: --work <id>");t.work=r}else if(i==="--holder"||i==="--ttl"||i==="--token"||i==="--outcome"){let r=e[++n];if(!r||r.startsWith("-"))throw new Error(`${i} needs a value: ${i} <${i.slice(2)}>`);t[i.slice(2)]=r}else if(i==="--signer"){let r=e[++n];if(!r||r.startsWith("-"))throw new Error("--signer needs a principal: --signer <principal>");t.signer=r}else if(i==="--unit"||i==="--decision"){let r=e[++n];if(!r||r.startsWith("-"))throw new Error(`${i} needs an id: ${i} <id>`);t[i.slice(2)]=r}else if(i==="--note")t.note=e[++n];else if(i==="--reason"){if(t.reason=e[++n],t.reason===void 0||t.reason.startsWith("-"))throw new Error("--reason needs the text of the reason: --reason <text>")}else if(i==="--rule"){let r=e[++n];if(!r||r.startsWith("-"))throw new Error("--rule needs a rule id: --rule <id>");(t.rules??=[]).push(r)}else if(i==="--expire")t.expire=!0;else if(i==="--role"){let r=e[++n]??"";t.roles=[...t.roles??[],...r.split(",").map(o=>o.trim()).filter(Boolean)]}else if(i==="--agent")t.agent=!0;else if(i==="--allow-code")t.allowCode=!0;else if(i==="--source"){if(t.source=e[++n],!t.source||t.source.startsWith("-"))throw new Error("--source needs a template: --source <repo>[#<member>]")}else if(i==="--tags"){if(t.tags=e[++n],!t.tags||t.tags.startsWith("-"))throw new Error("--tags needs a tag glob: --tags 'v*'")}else if(i==="--index"){if(t.index=e[++n],!t.index||t.index.startsWith("-"))throw new Error("--index needs a hash index file: --index <file>")}else if(i==="--remove")t.remove=!0;else if(i==="--available")t.available=!0;else if(i==="--root-only")t.rootOnly=!0;else if(i==="--generated")t.generated=!0;else if(i==="--member"){let r=e[++n];if(!r||r.startsWith("-"))throw new Error("--member needs a member or group name: --member <name>");t.members=[...t.members??[],...r.split(",").map(o=>o.trim()).filter(Boolean)]}else if(i==="--allow-same-origin")t.allowSameOrigin=!0;else if(i==="--plan")t.plan=e[++n];else if(i==="--url")t.url=e[++n];else if(i==="--op")t.op=e[++n];else if(i==="--since")t.since=e[++n];else if(i==="--limit")t.limit=Number(e[++n]);else{if(i.startsWith("--"))throw new Error(`Unknown flag: ${i}
|
|
313
|
+
Run "chant --help" to see supported flags.`);i.startsWith("-")||(t.command&&(t.positionals??=[]).push(i),t.command?t.path==="."?t.path=i:t.extraPositional?t.extraPositional2=i:t.extraPositional=i:t.command=i)}n++}if(t.promoteTo&&!(t.command==="build"&&t.components&&t.generate))throw new Error("--promote-to needs build --components --generate <lexicon>: it adds a promote job to the generated CI pipeline, and only generate mode emits one.");return t}var ene={lc:"lifecycle"};function _1(e,t){let n=ene[e.command]??e.command,i=`${n} ${e.path}`,r=t.find(s=>s.name===i);if(r)return{def:r,compound:!0};let o=t.find(s=>s.name===n);return o?{def:o,compound:!1}:null}Kn();function I1(e){return new Promise(t=>{let n=()=>{if(e.writableLength===0||e.writableEnded||e.destroyed){r(),t();return}e.once("drain",n)},i=()=>{r(),t()},r=()=>{e.off("drain",n),e.off("error",i),e.off("close",i)};e.once("error",i),e.once("close",i),n()})}async function iR(e){await I1(process.stdout),await I1(process.stderr),process.exit(e)}Qh();import{realpathSync as T1}from"node:fs";import{fileURLToPath as nne}from"node:url";function D1(e,t){if(!e)return!1;try{return T1(e)===T1(nne(t))}catch{return!1}}vu();no();YO();AM();Kn();import{readFileSync as Dte}from"node:fs";import{relative as CDe,resolve as Nte}from"node:path";async function jte(e){let{args:t}=e,n=t.opsSpec;if(n&&t.recordPlans)try{let o=_h(Dte(Nte(n),"utf-8"),`--spec ${n}`),s=await EM({spec:o});if(t.json)console.log(JSON.stringify(s,null,2));else for(let a of s.waves)console.error(`wave ${a.wave} (${a.name}) at ${s.head.slice(0,12)}: ${a.digest}`);return 0}catch(o){return console.error(fe({message:o instanceof Error?o.message:String(o)})),1}if(!n||t.wave===void 0)return console.error(fe({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>]"})),1;if(t.decide&&t.share!==void 0)return console.error(fe({message:"--decide and --share are two different jobs; pass one"})),1;let i,r=t.share!==void 0?{share:t.share}:{};try{let o=Nte(n);i=_h(Dte(o,"utf-8"),`--spec ${n}`);let s=await RM({spec:i,specFile:CDe(process.cwd(),o),wave:t.wave,...t.decide?{decide:!0}:{},...t.share!==void 0?{share:t.share}:{},...t.base?{base:t.base}:{}});return t.json&&console.log(JSON.stringify(s,null,2)),await uw(i,t.wave,{result:s},r),s.exitCode}catch(o){let s=o instanceof Error?o.message:String(o);return console.error(fe({message:s})),i&&await uw(i,t.wave,{error:s},r),1}}k$();P1();Ph();var NDe=[{name:"run wave",handler:jte},{name:"run resume",handler:KL},{name:"approve",handler:Vte},{name:"workspace points",handler:XL}],jDe=`
|
|
314
|
+
chant runtime ${Np} - the wave-job commands of chant, in one file
|
|
315
|
+
|
|
316
|
+
Usage: node wave-runtime.mjs <command> [options]
|
|
317
|
+
|
|
318
|
+
Commands:
|
|
319
|
+
run wave --spec <file> --wave <k> Plan, gate and apply wave k of an Op waves spec
|
|
320
|
+
(--decide, --share <i>, --record-plans, --base <ref>, --json)
|
|
321
|
+
run resume Start the CI jobs that wait at gates whose approval arrived
|
|
322
|
+
(--gate <op>/<gate>, --dry-run, --json)
|
|
323
|
+
approve <op> <gate> Record a gate's resolution on the lifecycle ledger
|
|
324
|
+
(--actor, --plan, --note, --url, --sign, --expire, --resume, ...)
|
|
325
|
+
workspace points <verb> Ask, answer and list decision points
|
|
326
|
+
|
|
327
|
+
Flags, output, exit codes and ledger formats are the full chant CLI's;
|
|
328
|
+
see "chant --help" in @intentius/chant for every flag. This runtime does
|
|
329
|
+
not evaluate chant.config.ts, so --env is not checked against the
|
|
330
|
+
declared environments.
|
|
331
|
+
`;async function LDe(e){let t;try{t=C1(e)}catch(i){return console.error(fe({message:i instanceof Error?i.message:String(i)})),1}let n=_1(t,NDe);if(t.version&&(!t.command||n))return console.log(Np),0;if(t.help||!t.command)return console.log(jDe),t.help?0:1;if(!n){let i=t.path&&t.path!=="."?`${t.command} ${t.path}`:t.command;return console.error(fe({message:`"${i}" is not part of chant's wave-job runtime`,hint:"It runs run wave, run resume, approve and workspace points. Every other command needs the full @intentius/chant CLI."})),1}return t.env&&(process.env[wu]=t.env),VO(),n.def.handler({args:t,plugins:[],serializers:[]})}D1(process.argv[1],import.meta.url)&&LDe(process.argv.slice(2)).then(iR,async e=>{(process.argv.includes("--verbose")||process.argv.includes("-v"))&&e instanceof Error&&e.stack?console.error(e.stack):console.error(fe({message:e instanceof Error?e.message:String(e)})),await iR(1)});export{NDe as RUNTIME_COMMANDS,LDe as runRuntime};
|