@apptoolkit/harness 1.0.2 → 1.0.4
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/harness.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var cp=Object.defineProperty;var ap=(e)=>e;function up(e,t){this[e]=ap.bind(null,t)}var Go=(e,t)=>{for(var r in t)cp(e,r,{get:t[r],enumerable:!0,configurable:!0,set:up.bind(t,r)})};var pp=(e,t,r)=>()=>{if(e)try{t=e(e=0)}catch(o){r=[o]}if(r)throw r[0];return t};var op={};Go(op,{selectChoice:()=>Qh,selectMany:()=>em});import{openSync as Bh}from"node:fs";import{WriteStream as Jh}from"node:tty";import{Box as Vh,Text as ir,render as Hh,useApp as Kh,useInput as Gh}from"ink";import{createElement as He,useRef as qh,useState as Xh}from"react";function Yh({question:e,choices:t,initiallySelected:r,select:o}){let n=r!==void 0,[s,i]=Xh(()=>({position:0,checked:new Set(r),selectionRequired:!1})),c=qh(s),{exit:a}=Kh();function u(l){c.current=l,i(l)}Gh((l,f)=>{let d=c.current;if(f.escape||l==="q")a();else if(f.upArrow)u({...d,position:Math.max(0,d.position-1)});else if(f.downArrow)u({...d,position:Math.min(t.length-1,d.position+1)});else if(n&&l===" "){let m=t[d.position];if(!m)return;let g=new Set(d.checked);if(g.has(m.value))g.delete(m.value);else g.add(m.value);u({...d,checked:g,selectionRequired:!1})}else if(f.return){let m=n?t.filter(({value:v})=>d.checked.has(v)):t.slice(d.position,d.position+1),[g,...y]=m;if(!g){u({...d,selectionRequired:!0});return}o([g.value,...y.map(({value:v})=>v)]),a()}});let p=n?"Use the arrow keys, Space to toggle, Enter to confirm, or Esc to cancel.":"Use the arrow keys, Enter to select, or Esc to cancel.";return He(Vh,{flexDirection:"column"},He(ir,{bold:!0},e),...t.map(({label:l,value:f},d)=>{let m=d===s.position,g=l;if(n)g=`[${s.checked.has(f)?"x":" "}] ${l}`;return He(ir,{key:f,color:m?"cyan":"white"},`${m?"›":" "} ${g}`)}),He(ir,{dimColor:!0},p),s.selectionRequired&&He(ir,{color:"yellow"},"Select at least one option to continue."))}async function rp(e,t,r){if(!t.length)throw Error("Provide at least one choice for the selection menu.");let o,n=process.stdout.isTTY?void 0:new Jh(Bh("/dev/tty","w"));try{await Hh(He(Yh,{question:e,choices:t,initiallySelected:r,select(i){o=i}}),n?{stdout:n}:{}).waitUntilExit()}finally{n?.destroy()}if(o===void 0)throw Error("The operation was cancelled.");return o}async function Qh(e,t){let[r]=await rp(e,t);return r}function em(e,t,r=[]){return rp(e,t,r)}var np=()=>{};import{resolve as cr}from"node:path";import{fileURLToPath as tm}from"node:url";function Ge(e){let t=Object.values(e).filter((o)=>typeof o==="number");return Object.entries(e).filter(([o,n])=>t.indexOf(+o)===-1).map(([o,n])=>n)}function lr(e,t="|"){return e.map((r)=>hr(r)).join(t)}function qe(e,t){if(typeof t==="bigint")return t.toString();return t}class qo{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;if(e!==void 0)this._value=e(),this._getter=void 0;return this._value}}function Xe(e){return new qo(e)}function Xo(e){return e===null||e===void 0}function wt(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Yo(e,t){let r=e/t,o=Math.round(r),n=4*Number.EPSILON*Math.max(Math.abs(r),1);if(Math.abs(r-o)<n)return 0;return r-o}function Q(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Ye(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function ue(e){return Ye(e._zod.def)??e._zod.def.shape}function Qo(e,t,r){Object.defineProperty(e,t,{get(){let o=r();return Q(this,t,o),o},enumerable:!0,configurable:!0})}function en(e,t,r){if(t in e)Q(e,t,r);else e[t]=r}function ke(e,t,r,o){let n=ue(t);for(let s of r){let i=Object.getOwnPropertyDescriptor(n,s);if(!i.enumerable)continue;if(i.get)Qo(e,s,()=>{let c=t._zod.def.shape[s];return o?o(c,s):c});else en(e,s,o?o(i.value,s):i.value)}}function lp(e,t){for(let r of Reflect.ownKeys(t)){let o=Object.getOwnPropertyDescriptor(t,r);if(!o.enumerable)continue;if(o.get)Qo(e,r,()=>t[r]);else en(e,r,o.value)}}function B(...e){let t={};for(let r of e){let o=Object.getOwnPropertyDescriptors(r);Object.assign(t,o)}return Object.defineProperties({},t)}function tn(e){return JSON.stringify(e)}function rn(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var fr="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ce(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var on=Xe(()=>{if(J.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function Ie(e){if(Ce(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let r=t.prototype;if(Ce(r)===!1)return!1;if(Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)return!1;return!0}function dr(e){if(Ie(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var nn=new Set(["string","number","symbol"]);function ye(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ne(e,t,r){let o=new e._zod.constr(t??e._zod.def);if(!t||r?.parent)o._zod.parent=e;return o}function x(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function hr(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function sn(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var _t=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),mr={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function fp(e,t){let r=e._zod.def,o=r.checks;if(o&&o.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let s={};return ke(s,e,bt(e,t)),ne(e,B(r,{shape:s,checks:[]}))}function bt(e,t){let r=ue(e),o=[];for(let n of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,n)?.enumerable)throw Error(`Unrecognized key: "${String(n)}"`);if(t[n])o.push(n)}return o}function dp(e,t){let r=e._zod.def,o=r.checks;if(o&&o.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let s=new Set(bt(e,t)),i={};return ke(i,e,Reflect.ownKeys(ue(e)).filter((c)=>!s.has(c))),ne(e,B(r,{shape:i,checks:[]}))}function hp(e,t){if(!Ie(t))throw Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let n=ue(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,s)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return ne(e,B(e._zod.def,{shape:cn(e,t)}))}function cn(e,t){let r={};return ke(r,e,Reflect.ownKeys(ue(e))),lp(r,t),r}function mp(e,t){if(!Ie(t))throw Error("Invalid input to safeExtend: expected a plain object");return ne(e,B(e._zod.def,{shape:cn(e,t)}))}function gp(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r={};ke(r,e,Reflect.ownKeys(ue(e))),ke(r,t,Reflect.ownKeys(ue(t)));let o=B(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ne(e,o)}function an(e,t,r,o="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw Error(`.${o}() cannot be used on object schemas containing refinements`);let c=r?new Set(bt(t,r)):void 0,a={};return ke(a,t,Reflect.ownKeys(ue(t)),e&&((u,p)=>c&&!c.has(p)?u:new e({type:"optional",innerType:u}))),ne(t,B(t._zod.def,{shape:a,checks:[]}))}function yp(e,t,r){let o=r?new Set(bt(t,r)):void 0,n={};return ke(n,t,Reflect.ownKeys(ue(t)),(s,i)=>o&&!o.has(i)?s:new e({type:"nonoptional",innerType:s})),ne(t,B(t._zod.def,{shape:n}))}function se(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function un(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function kt(e,t){return t.map((r)=>{var o;return(o=r).path??(o.path=[]),r.path.unshift(e),r})}function Ke(e){return typeof e==="string"?e:e?.message}function gr(e){let t=[];for(let r of e??[]){let o=r._zod.def;if(!/_(length|size)$|_equals$/.test(o.check))break;let n=o.maximum??o.length??o.size;if(n>=0)t.push([n,r])}return t}function $t(e,t,r){var o;for(let n=t;n<e.length;n++)(o=e[n]).schema??(o.schema=r)}function xe(e,t,r){var o;let n=e.inst?._zod?.traits;if(n?.has("$ZodType"))if(n.has("$ZodCheck"))(o=e).schema??(o.schema=e.inst);else e.schema=e.inst;let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,i=e.message?e.message:Ke(e.inst?._zod.def?.error?.(e))??Ke(s?.(e))??Ke(t?.error?.(e))??Ke(r.customError?.(e))??Ke(r.localeError?.(e))??"Invalid input",c={};for(let a of Object.keys(e)){if(a==="inst"||a==="schema"||a==="continue"||a==="input"||a==="__proto__")continue;c[a]=e[a]}if(c.path??(c.path=[]),c.message=i,t?.reportInput)c.input=e.input;return c}var xp=/[\uD800-\uDBFF]/;function St(e){let t=e.length;if(!xp.test(e))return t;let r=t;for(let o=0;o<t-1;o++)if((e.charCodeAt(o)&64512)===55296&&(e.charCodeAt(o+1)&64512)===56320)r--,o++;return r}function zt(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function pn(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 r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function $e(...e){let[t,r,o]=e;if(typeof t==="string")return{message:t,code:"custom",input:r,inst:o};return{...t}}function ln(e,t){for(let r in t){let o=Object.getOwnPropertyDescriptor(t,r);if(o.get)Object.defineProperty(e,r,{...o,enumerable:!1});else vp(e,r,o.value)}}function pe(e,t,r,o=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:o,value:r}),r}function Pt(e,t,r){return pe(e,t,r,!1)}function Et(e,t){for(let r in e){let o=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return pe(this,r,o(this))},set(n){pe(this,r,n)}})}return t}function vp(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:pe(this,t,r.bind(this))},set(o){pe(this,t,o)}})}function wp(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var pr,ge=!1,_p={configurable:!0,get(){ge=!0;return}};function b(e,t,r){let o=Object.getPrototypeOf(e._zod);if(t in o&&pr!==e._zod){pr=void 0;return}pr=e._zod,Object.defineProperty(o,t,{configurable:!0,get(){Object.defineProperty(this,t,_p);let n=ge;ge=!1;try{let s=r(this);if(ge)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s});return ge=ge||n,s}catch(s){throw delete this[t],ge=ge||n,s}},set(n){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:n})}})}function bp(e,t,r,o){let n=wp(e,t);if(!n)return;Object.defineProperty(n,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:o,value:void 0};return Object.defineProperty(this,t,s),s.value=r(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:o,value:s})}})}var kp="~constantCatch";function fn(e){let t=()=>e;return t[kp]=!0,t}var dn;var yr={value:void 0,enumerable:!1},hn="captureStackTrace"in Error?Error:null;function $p(e){let t=hn;if(t){let r=t.stackTraceLimit;if(typeof r==="number"){try{t.stackTraceLimit=0}catch{return hn=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function h(e,t,r,o){let n={};function s(f){this.def=f,this.constr=l,this.traits=new Set}s.prototype=n;let i=r,c=i&&new WeakSet;function a(f,d){if(!f._zod){yr.value=new s(d);try{Object.defineProperty(f,"_zod",yr)}finally{yr.value=void 0}}else if(f._zod.traits.has(e))return;if(f._zod.traits.add(e),t(f,d),c){let g=Object.getPrototypeOf(f),y=f._zod.constr.prototype,v=g;while(v&&v!==y)v=Object.getPrototypeOf(v);let k=v??g;if(!c.has(k))c.add(k),ln(k,i)}let m=l.prototype;for(let g in m){if(!Object.prototype.hasOwnProperty.call(m,g))continue;if(!(g in f))f[g]=m[g].bind(f)}}let u=o?.Parent??Object;class p extends u{}Object.defineProperty(p,"name",{value:e});function l(f){let d=o?.Parent?$p(p):this;a(d,f);let m=d._zod.deferred;if(m){for(let y of m)y();d._zod.deferred=void 0}let g=globalThis.__zod_globalConfig?.postProcessor;if(g)g(d);return d}return Object.defineProperty(l,"init",{value:a}),Object.defineProperty(l,Symbol.hasInstance,{value:(f)=>{if(o?.Parent&&f instanceof o.Parent)return!0;return f?._zod?.traits?.has(e)}}),Object.defineProperty(l,"name",{value:e}),l}class ie extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Qe extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(dn=globalThis).__zod_globalConfig??(dn.__zod_globalConfig={});var J=globalThis.__zod_globalConfig;function te(e){if(e)Object.assign(J,e);return J}function Sp(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,qe,2)),e.message}function zp(e){this._zod.message=e}var Pp={get:Sp,set:zp,enumerable:!0,configurable:!0},vr={value:void 0,enumerable:!1},mn=new WeakSet([Object.prototype,Error.prototype]),gn=(e,t)=>{e.name="$ZodError",vr.value=t,Object.defineProperty(e,"issues",vr),vr.value=void 0,Object.defineProperty(e,"message",Pp);let r=Object.getPrototypeOf(e);if(!mn.has(r))mn.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let o=()=>this.message;return Object.defineProperty(this,"toString",{value:o,configurable:!0,writable:!0}),o},set(o){Object.defineProperty(this,"toString",{value:o,configurable:!0,writable:!0})}})},yn=h("$ZodError",gn),pm=h("$ZodError",gn,void 0,{Parent:Error});function Ep(e,t,r){if(!Object.prototype.hasOwnProperty.call(e,t))if(t==="__proto__")Object.defineProperty(e,t,{value:r(),writable:!0,enumerable:!0,configurable:!0});else e[t]=r();return e[t]}function xn(e,t=(r)=>r.message){let r={},o=[];for(let n of e.issues)if(n.path.length>0)Ep(r,n.path[0],()=>[]).push(t(n));else o.push(t(n));return{formErrors:o,fieldErrors:r}}function vn(e,t=(r)=>r.message){let r={_errors:[]},o=(n,s=[])=>{for(let i of n.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map((c)=>o({issues:c},[...s,...i.path]));else if(i.code==="invalid_key")o({issues:i.issues},[...s,...i.path]);else if(i.code==="invalid_element")o({issues:i.issues},[...s,...i.path]);else{let c=[...s,...i.path];if(c.length===0)r._errors.push(t(i));else{let a=r,u=0;while(u<c.length){let p=c[u],l=u===c.length-1;if(p==="_errors"){if(l)a._errors.push(t(i));u++;continue}if(!Object.prototype.hasOwnProperty.call(a,p))Object.defineProperty(a,p,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let f=a[p];if(l)f._errors.push(t(i));a=f,u++}}}};return o(e),r}function Zt(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Ot=(e)=>{let t=(r,o,n,s)=>{let i=n?{...n,async:!1}:{async:!1},c=r._zod.run({value:o,issues:[]},i);if(c instanceof Promise)throw new ie;if(c.issues.length){let a=new(s?.Err??e)(c.issues.map((u)=>xe(u,i,te())));throw fr(a,s?.callee??t),a}return c.value};return t};var Rt=(e)=>{let t=async(r,o,n,s)=>{let i=n?{...n,async:!0}:{async:!0},c=r._zod.run({value:o,issues:[]},i);if(c instanceof Promise)c=await c;if(c.issues.length){let a=new(s?.Err??e)(c.issues.map((u)=>xe(u,i,te())));throw fr(a,s?.callee??t),a}return c.value};return t};var Ct=(e)=>(t,r,o)=>{let n=o?{...o,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},n);if(s instanceof Promise)throw new ie;return s.issues.length?wn(e,s.issues,n):{success:!0,data:s.value}};function wn(e,t,r){let o;return{success:!1,get error(){if(!o)o=new e(t.map((n)=>xe(n,r,te()))),t=void 0,r=void 0;return o},set error(n){o=n,t=void 0,r=void 0}}}var It=(e)=>async(t,r,o)=>{let n=o?{...o,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},n);if(s instanceof Promise)s=await s;return s.issues.length?wn(e,s.issues,n):{success:!0,data:s.value}};var Zp=Symbol.for("zod.compile.invalid"),Op=Symbol.for("zod.compile.fallback"),wr=(e,t,r)=>{let o=e._zod.bag.validator;if(o!==void 0){if(o(t)!==Zp)return!0;if(o.definite===!0&&r===void 0)return!1}return Rp(e,t,r)};function Rp(e,t,r){let o=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},n=e._zod.bag.fallbackRun,s;if(n)o[Op]=!0,s=n({value:t,issues:[]},o);else s=e._zod.run({value:t,issues:[]},o);if(s instanceof Promise)throw new ie;return s.issues.length===0}var _r=async(e,t,r)=>{let o=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},n=e._zod.run({value:t,issues:[]},o);if(n instanceof Promise)n=await n;return n.issues.length===0},_n=(e)=>{let t=Ot(e),r=(o,n,s,i)=>{let c=s?{...s,direction:"backward"}:{direction:"backward"};return t(o,n,c,Zt(r,i))};return r};var bn=(e)=>{let t=Ot(e),r=(o,n,s,i)=>t(o,n,s,Zt(r,i));return r};var kn=(e)=>{let t=Rt(e),r=async(o,n,s,i)=>{let c=s?{...s,direction:"backward"}:{direction:"backward"};return await t(o,n,c,Zt(r,i))};return r};var $n=(e)=>{let t=Rt(e),r=async(o,n,s,i)=>await t(o,n,s,Zt(r,i));return r};var Sn=(e)=>(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return Ct(e)(t,r,n)};var zn=(e)=>(t,r,o)=>Ct(e)(t,r,o);var Pn=(e)=>async(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return It(e)(t,r,n)};var En=(e)=>async(t,r,o)=>It(e)(t,r,o);var Zn=/^[cC][0-9a-z]{6,}$/,On=/^[0-9a-z]+$/,Rn=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Cn=/^[0-9a-vA-V]{20}$/,In=/^[A-Za-z0-9]{27}$/,An=/^[a-zA-Z0-9_-]{21}$/;function Tn(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var Nn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var jn=/^([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})$/,kr=(e)=>{if(!e)return/^([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)$/;return 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})$`)};var Dn=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Cp="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Fn(){return new RegExp(Cp,"u")}var Ln=/^(?:(?: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])$/,Mn=/^(([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}|:))$/;var Wn=/^((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])$/,Un=/^(([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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Bn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Jn=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var Vn=/^https?$/,Hn=/^\+[1-9]\d{6,14}$/;var Kn="(?:(?:\\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])))";function Ip(e){return new RegExp(`^${e}$`)}var Gn=Ip(Kn);function br(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function qn(e){return new RegExp(`^${br(e)}$`)}function Xn(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${br({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,o=e.local?`${r}|${br({precision:e.precision})}`:r;return new RegExp(`^${Kn}T(?:${o})$`)}var Yn=/^[\s\S]{0,}$/;var Qn=/^-?\d+n?$/;var $r=/^-?\d+(?:\.\d+)?$/,es=/^(?:true|false)$/i;var ts=/^[^A-Z]*$/,rs=/^[^a-z]*$/;var T=h("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var Sr=(e)=>{let t=e.value;return!Xo(t)&&t.length!==void 0},At={number:"number",bigint:"bigint",object:"date"},zr=h("$ZodCheckLessThan",(e,t)=>{T.init(e,t);let r=At[typeof t.value];e._zod.check=(o)=>{if(t.inclusive?o.value<=t.value:o.value<t.value)return;o.issues.push({origin:At[typeof o.value]??r,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Pr=h("$ZodCheckGreaterThan",(e,t)=>{T.init(e,t);let r=At[typeof t.value];e._zod.check=(o)=>{if(t.inclusive?o.value>=t.value:o.value>t.value)return;o.issues.push({origin:At[typeof o.value]??r,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),os=h("$ZodCheckMultipleOf",(e,t)=>{T.init(e,t),e._zod.check=(r)=>{if(typeof r.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof r.value==="bigint"?t.value!==BigInt(0)&&r.value%t.value===BigInt(0):Yo(r.value,t.value)===0)return;r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),ns=h("$ZodCheckNumberFormat",(e,t)=>{T.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),o=r?"int":"number",[n,s]=_t[t.format];e._zod.check=(i)=>{let c=i.value;if(r){if(!Number.isInteger(c)){i.issues.push({expected:o,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){if(c>0)i.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort});else i.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort});return}}if(c<n)i.issues.push({origin:"number",input:c,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort});if(c>s)i.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var ss=h("$ZodCheckMaxLength",(e,t)=>{var r;T.init(e,t),(r=e._zod.def).when??(r.when=Sr),e._zod.check=(o)=>{let n=o.value,s=n.length;if((typeof n==="string"&&s>t.maximum?St(n):s)<=t.maximum)return;let c=zt(n);o.issues.push({origin:c,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),is=h("$ZodCheckMinLength",(e,t)=>{var r;T.init(e,t),(r=e._zod.def).when??(r.when=Sr),e._zod.check=(o)=>{let n=o.value,s=n.length;if((typeof n==="string"&&s>=t.minimum&&s<t.minimum*2?St(n):s)>=t.minimum)return;let c=zt(n);o.issues.push({origin:c,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),cs=h("$ZodCheckLengthEquals",(e,t)=>{var r;T.init(e,t),(r=e._zod.def).when??(r.when=Sr),e._zod.check=(o)=>{let n=o.value,s=n.length,i=typeof n==="string"&&s>=t.length&&s<=t.length*2?St(n):s;if(i===t.length)return;let c=zt(n),a=i>t.length;o.issues.push({origin:c,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),tt=h("$ZodCheckStringFormat",(e,t)=>{var r,o;if(T.init(e,t),t.pattern)(r=e._zod).check??(r.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(o=e._zod).check??(o.check=()=>{})}),as=h("$ZodCheckRegex",(e,t)=>{tt.init(e,t),e._zod.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),us=h("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=ts),tt.init(e,t)}),ps=h("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=rs),tt.init(e,t)}),ls=h("$ZodCheckIncludes",(e,t)=>{T.init(e,t);let r=ye(t.includes),o=new RegExp(typeof t.position==="number"?`^.{${t.position},}${r}`:r);t.pattern=o,e._zod.check=(n)=>{if(n.value.includes(t.includes,t.position))return;n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),fs=h("$ZodCheckStartsWith",(e,t)=>{T.init(e,t);let r=new RegExp(`^${ye(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.check=(o)=>{if(o.value.startsWith(t.prefix))return;o.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:o.value,inst:e,continue:!t.abort})}}),ds=h("$ZodCheckEndsWith",(e,t)=>{T.init(e,t);let r=new RegExp(`.*${ye(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.check=(o)=>{if(o.value.endsWith(t.suffix))return;o.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:o.value,inst:e,continue:!t.abort})}});var hs=h("$ZodCheckOverwrite",(e,t)=>{T.init(e,t),e._zod.check=(r)=>{r.value=t.tx(r.value)}});class Er{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let r=e.split(`
|
|
2
|
+
var cp=Object.defineProperty;var ap=(e)=>e;function up(e,t){this[e]=ap.bind(null,t)}var Go=(e,t)=>{for(var r in t)cp(e,r,{get:t[r],enumerable:!0,configurable:!0,set:up.bind(t,r)})};var pp=(e,t,r)=>()=>{if(e)try{t=e(e=0)}catch(o){r=[o]}if(r)throw r[0];return t};var op={};Go(op,{selectChoice:()=>Qh,selectMany:()=>em});import{openSync as Bh}from"node:fs";import{WriteStream as Jh}from"node:tty";import{Box as Vh,Text as ir,render as Hh,useApp as Kh,useInput as Gh}from"ink";import{createElement as Ke,useRef as qh,useState as Xh}from"react";function Yh({question:e,choices:t,initiallySelected:r,select:o}){let n=r!==void 0,[s,i]=Xh(()=>({position:0,checked:new Set(r),selectionRequired:!1})),c=qh(s),{exit:a}=Kh();function u(l){c.current=l,i(l)}Gh((l,f)=>{let d=c.current;if(f.escape||l==="q")a();else if(f.upArrow)u({...d,position:Math.max(0,d.position-1)});else if(f.downArrow)u({...d,position:Math.min(t.length-1,d.position+1)});else if(n&&l===" "){let m=t[d.position];if(!m)return;let y=new Set(d.checked);if(y.has(m.value))y.delete(m.value);else y.add(m.value);u({...d,checked:y,selectionRequired:!1})}else if(f.return){let m=n?t.filter(({value:v})=>d.checked.has(v)):t.slice(d.position,d.position+1),[y,...g]=m;if(!y){u({...d,selectionRequired:!0});return}o([y.value,...g.map(({value:v})=>v)]),a()}});let p=n?"Use the arrow keys, Space to toggle, Enter to confirm, or Esc to cancel.":"Use the arrow keys, Enter to select, or Esc to cancel.";return Ke(Vh,{flexDirection:"column"},Ke(ir,{bold:!0},e),...t.map(({label:l,value:f},d)=>{let m=d===s.position,y=l;if(n)y=`[${s.checked.has(f)?"x":" "}] ${l}`;return Ke(ir,{key:f,color:m?"cyan":"white"},`${m?"›":" "} ${y}`)}),Ke(ir,{dimColor:!0},p),s.selectionRequired&&Ke(ir,{color:"yellow"},"Select at least one option to continue."))}async function rp(e,t,r){if(!t.length)throw Error("Provide at least one choice for the selection menu.");let o,n=process.stdout.isTTY?void 0:new Jh(Bh("/dev/tty","w"));try{await Hh(Ke(Yh,{question:e,choices:t,initiallySelected:r,select(i){o=i}}),n?{stdout:n}:{}).waitUntilExit()}finally{n?.destroy()}if(o===void 0)throw Error("The operation was cancelled.");return o}async function Qh(e,t){let[r]=await rp(e,t);return r}function em(e,t,r=[]){return rp(e,t,r)}var np=()=>{};import{resolve as cr}from"node:path";import{fileURLToPath as tm}from"node:url";function qe(e){let t=Object.values(e).filter((o)=>typeof o==="number");return Object.entries(e).filter(([o,n])=>t.indexOf(+o)===-1).map(([o,n])=>n)}function lr(e,t="|"){return e.map((r)=>hr(r)).join(t)}function Xe(e,t){if(typeof t==="bigint")return t.toString();return t}class qo{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;if(e!==void 0)this._value=e(),this._getter=void 0;return this._value}}function Ye(e){return new qo(e)}function Xo(e){return e===null||e===void 0}function _t(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Yo(e,t){let r=e/t,o=Math.round(r),n=4*Number.EPSILON*Math.max(Math.abs(r),1);if(Math.abs(r-o)<n)return 0;return r-o}function Y(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Qe(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function ue(e){return Qe(e._zod.def)??e._zod.def.shape}function Qo(e,t,r){Object.defineProperty(e,t,{get(){let o=r();return Y(this,t,o),o},enumerable:!0,configurable:!0})}function en(e,t,r){if(t in e)Y(e,t,r);else e[t]=r}function ke(e,t,r,o){let n=ue(t);for(let s of r){let i=Object.getOwnPropertyDescriptor(n,s);if(!i.enumerable)continue;if(i.get)Qo(e,s,()=>{let c=t._zod.def.shape[s];return o?o(c,s):c});else en(e,s,o?o(i.value,s):i.value)}}function lp(e,t){for(let r of Reflect.ownKeys(t)){let o=Object.getOwnPropertyDescriptor(t,r);if(!o.enumerable)continue;if(o.get)Qo(e,r,()=>t[r]);else en(e,r,o.value)}}function B(...e){let t={};for(let r of e){let o=Object.getOwnPropertyDescriptors(r);Object.assign(t,o)}return Object.defineProperties({},t)}function tn(e){return JSON.stringify(e)}function rn(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var fr="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ie(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var on=Ye(()=>{if(J.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function Ae(e){if(Ie(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let r=t.prototype;if(Ie(r)===!1)return!1;if(Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)return!1;return!0}function dr(e){if(Ae(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var nn=new Set(["string","number","symbol"]);function ye(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function oe(e,t,r){let o=new e._zod.constr(t??e._zod.def);if(!t||r?.parent)o._zod.parent=e;return o}function x(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function hr(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function sn(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var bt=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),mr={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function fp(e,t){let r=e._zod.def,o=r.checks;if(o&&o.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let s={};return ke(s,e,kt(e,t)),oe(e,B(r,{shape:s,checks:[]}))}function kt(e,t){let r=ue(e),o=[];for(let n of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,n)?.enumerable)throw Error(`Unrecognized key: "${String(n)}"`);if(t[n])o.push(n)}return o}function dp(e,t){let r=e._zod.def,o=r.checks;if(o&&o.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let s=new Set(kt(e,t)),i={};return ke(i,e,Reflect.ownKeys(ue(e)).filter((c)=>!s.has(c))),oe(e,B(r,{shape:i,checks:[]}))}function hp(e,t){if(!Ae(t))throw Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let n=ue(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,s)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return oe(e,B(e._zod.def,{shape:cn(e,t)}))}function cn(e,t){let r={};return ke(r,e,Reflect.ownKeys(ue(e))),lp(r,t),r}function mp(e,t){if(!Ae(t))throw Error("Invalid input to safeExtend: expected a plain object");return oe(e,B(e._zod.def,{shape:cn(e,t)}))}function gp(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r={};ke(r,e,Reflect.ownKeys(ue(e))),ke(r,t,Reflect.ownKeys(ue(t)));let o=B(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return oe(e,o)}function an(e,t,r,o="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw Error(`.${o}() cannot be used on object schemas containing refinements`);let c=r?new Set(kt(t,r)):void 0,a={};return ke(a,t,Reflect.ownKeys(ue(t)),e&&((u,p)=>c&&!c.has(p)?u:new e({type:"optional",innerType:u}))),oe(t,B(t._zod.def,{shape:a,checks:[]}))}function yp(e,t,r){let o=r?new Set(kt(t,r)):void 0,n={};return ke(n,t,Reflect.ownKeys(ue(t)),(s,i)=>o&&!o.has(i)?s:new e({type:"nonoptional",innerType:s})),oe(t,B(t._zod.def,{shape:n}))}function ne(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function un(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function $t(e,t){return t.map((r)=>{var o;return(o=r).path??(o.path=[]),r.path.unshift(e),r})}function Ge(e){return typeof e==="string"?e:e?.message}function gr(e){let t=[];for(let r of e??[]){let o=r._zod.def;if(!/_(length|size)$|_equals$/.test(o.check))break;let n=o.maximum??o.length??o.size;if(n>=0)t.push([n,r])}return t}function St(e,t,r){var o;for(let n=t;n<e.length;n++)(o=e[n]).schema??(o.schema=r)}function xe(e,t,r){var o;let n=e.inst?._zod?.traits;if(n?.has("$ZodType"))if(n.has("$ZodCheck"))(o=e).schema??(o.schema=e.inst);else e.schema=e.inst;let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,i=e.message?e.message:Ge(e.inst?._zod.def?.error?.(e))??Ge(s?.(e))??Ge(t?.error?.(e))??Ge(r.customError?.(e))??Ge(r.localeError?.(e))??"Invalid input",c={};for(let a of Object.keys(e)){if(a==="inst"||a==="schema"||a==="continue"||a==="input"||a==="__proto__")continue;c[a]=e[a]}if(c.path??(c.path=[]),c.message=i,t?.reportInput)c.input=e.input;return c}var xp=/[\uD800-\uDBFF]/;function zt(e){let t=e.length;if(!xp.test(e))return t;let r=t;for(let o=0;o<t-1;o++)if((e.charCodeAt(o)&64512)===55296&&(e.charCodeAt(o+1)&64512)===56320)r--,o++;return r}function Pt(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function pn(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 r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function $e(...e){let[t,r,o]=e;if(typeof t==="string")return{message:t,code:"custom",input:r,inst:o};return{...t}}function ln(e,t){for(let r in t){let o=Object.getOwnPropertyDescriptor(t,r);if(o.get)Object.defineProperty(e,r,{...o,enumerable:!1});else vp(e,r,o.value)}}function pe(e,t,r,o=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:o,value:r}),r}function Et(e,t,r){return pe(e,t,r,!1)}function Zt(e,t){for(let r in e){let o=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return pe(this,r,o(this))},set(n){pe(this,r,n)}})}return t}function vp(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:pe(this,t,r.bind(this))},set(o){pe(this,t,o)}})}function wp(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var pr,ge=!1,_p={configurable:!0,get(){ge=!0;return}};function S(e,t,r){let o=Object.getPrototypeOf(e._zod);if(t in o&&pr!==e._zod){pr=void 0;return}pr=e._zod,Object.defineProperty(o,t,{configurable:!0,get(){Object.defineProperty(this,t,_p);let n=ge;ge=!1;try{let s=r(this);if(ge)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s});return ge=ge||n,s}catch(s){throw delete this[t],ge=ge||n,s}},set(n){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:n})}})}function bp(e,t,r,o){let n=wp(e,t);if(!n)return;Object.defineProperty(n,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:o,value:void 0};return Object.defineProperty(this,t,s),s.value=r(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:o,value:s})}})}var kp="~constantCatch";function fn(e){let t=()=>e;return t[kp]=!0,t}var dn;var yr={value:void 0,enumerable:!1},hn="captureStackTrace"in Error?Error:null;function $p(e){let t=hn;if(t){let r=t.stackTraceLimit;if(typeof r==="number"){try{t.stackTraceLimit=0}catch{return hn=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function h(e,t,r,o){let n={};function s(f){this.def=f,this.constr=l,this.traits=new Set}s.prototype=n;let i=r,c=i&&new WeakSet;function a(f,d){if(!f._zod){yr.value=new s(d);try{Object.defineProperty(f,"_zod",yr)}finally{yr.value=void 0}}else if(f._zod.traits.has(e))return;if(f._zod.traits.add(e),t(f,d),c){let y=Object.getPrototypeOf(f),g=f._zod.constr.prototype,v=y;while(v&&v!==g)v=Object.getPrototypeOf(v);let b=v??y;if(!c.has(b))c.add(b),ln(b,i)}let m=l.prototype;for(let y in m){if(!Object.prototype.hasOwnProperty.call(m,y))continue;if(!(y in f))f[y]=m[y].bind(f)}}let u=o?.Parent??Object;class p extends u{}Object.defineProperty(p,"name",{value:e});function l(f){let d=o?.Parent?$p(p):this;a(d,f);let m=d._zod.deferred;if(m){for(let g of m)g();d._zod.deferred=void 0}let y=globalThis.__zod_globalConfig?.postProcessor;if(y)y(d);return d}return Object.defineProperty(l,"init",{value:a}),Object.defineProperty(l,Symbol.hasInstance,{value:(f)=>{if(o?.Parent&&f instanceof o.Parent)return!0;return f?._zod?.traits?.has(e)}}),Object.defineProperty(l,"name",{value:e}),l}class se extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class et extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(dn=globalThis).__zod_globalConfig??(dn.__zod_globalConfig={});var J=globalThis.__zod_globalConfig;function ee(e){if(e)Object.assign(J,e);return J}function Sp(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Xe,2)),e.message}function zp(e){this._zod.message=e}var Pp={get:Sp,set:zp,enumerable:!0,configurable:!0},vr={value:void 0,enumerable:!1},mn=new WeakSet([Object.prototype,Error.prototype]),gn=(e,t)=>{e.name="$ZodError",vr.value=t,Object.defineProperty(e,"issues",vr),vr.value=void 0,Object.defineProperty(e,"message",Pp);let r=Object.getPrototypeOf(e);if(!mn.has(r))mn.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let o=()=>this.message;return Object.defineProperty(this,"toString",{value:o,configurable:!0,writable:!0}),o},set(o){Object.defineProperty(this,"toString",{value:o,configurable:!0,writable:!0})}})},yn=h("$ZodError",gn),pm=h("$ZodError",gn,void 0,{Parent:Error});function Ep(e,t,r){if(!Object.prototype.hasOwnProperty.call(e,t))if(t==="__proto__")Object.defineProperty(e,t,{value:r(),writable:!0,enumerable:!0,configurable:!0});else e[t]=r();return e[t]}function xn(e,t=(r)=>r.message){let r={},o=[];for(let n of e.issues)if(n.path.length>0)Ep(r,n.path[0],()=>[]).push(t(n));else o.push(t(n));return{formErrors:o,fieldErrors:r}}function vn(e,t=(r)=>r.message){let r={_errors:[]},o=(n,s=[])=>{for(let i of n.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map((c)=>o({issues:c},[...s,...i.path]));else if(i.code==="invalid_key")o({issues:i.issues},[...s,...i.path]);else if(i.code==="invalid_element")o({issues:i.issues},[...s,...i.path]);else{let c=[...s,...i.path];if(c.length===0)r._errors.push(t(i));else{let a=r,u=0;while(u<c.length){let p=c[u],l=u===c.length-1;if(p==="_errors"){if(l)a._errors.push(t(i));u++;continue}if(!Object.prototype.hasOwnProperty.call(a,p))Object.defineProperty(a,p,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let f=a[p];if(l)f._errors.push(t(i));a=f,u++}}}};return o(e),r}function Ot(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Rt=(e)=>{let t=(r,o,n,s)=>{let i=n?{...n,async:!1}:{async:!1},c=r._zod.run({value:o,issues:[]},i);if(c instanceof Promise)throw new se;if(c.issues.length){let a=new(s?.Err??e)(c.issues.map((u)=>xe(u,i,ee())));throw fr(a,s?.callee??t),a}return c.value};return t};var Ct=(e)=>{let t=async(r,o,n,s)=>{let i=n?{...n,async:!0}:{async:!0},c=r._zod.run({value:o,issues:[]},i);if(c instanceof Promise)c=await c;if(c.issues.length){let a=new(s?.Err??e)(c.issues.map((u)=>xe(u,i,ee())));throw fr(a,s?.callee??t),a}return c.value};return t};var It=(e)=>(t,r,o)=>{let n=o?{...o,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},n);if(s instanceof Promise)throw new se;return s.issues.length?wn(e,s.issues,n):{success:!0,data:s.value}};function wn(e,t,r){let o;return{success:!1,get error(){if(!o)o=new e(t.map((n)=>xe(n,r,ee()))),t=void 0,r=void 0;return o},set error(n){o=n,t=void 0,r=void 0}}}var At=(e)=>async(t,r,o)=>{let n=o?{...o,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},n);if(s instanceof Promise)s=await s;return s.issues.length?wn(e,s.issues,n):{success:!0,data:s.value}};var Zp=Symbol.for("zod.compile.invalid"),Op=Symbol.for("zod.compile.fallback"),wr=(e,t,r)=>{let o=e._zod.bag.validator;if(o!==void 0){if(o(t)!==Zp)return!0;if(o.definite===!0&&r===void 0)return!1}return Rp(e,t,r)};function Rp(e,t,r){let o=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},n=e._zod.bag.fallbackRun,s;if(n)o[Op]=!0,s=n({value:t,issues:[]},o);else s=e._zod.run({value:t,issues:[]},o);if(s instanceof Promise)throw new se;return s.issues.length===0}var _r=async(e,t,r)=>{let o=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},n=e._zod.run({value:t,issues:[]},o);if(n instanceof Promise)n=await n;return n.issues.length===0},_n=(e)=>{let t=Rt(e),r=(o,n,s,i)=>{let c=s?{...s,direction:"backward"}:{direction:"backward"};return t(o,n,c,Ot(r,i))};return r};var bn=(e)=>{let t=Rt(e),r=(o,n,s,i)=>t(o,n,s,Ot(r,i));return r};var kn=(e)=>{let t=Ct(e),r=async(o,n,s,i)=>{let c=s?{...s,direction:"backward"}:{direction:"backward"};return await t(o,n,c,Ot(r,i))};return r};var $n=(e)=>{let t=Ct(e),r=async(o,n,s,i)=>await t(o,n,s,Ot(r,i));return r};var Sn=(e)=>(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return It(e)(t,r,n)};var zn=(e)=>(t,r,o)=>It(e)(t,r,o);var Pn=(e)=>async(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return At(e)(t,r,n)};var En=(e)=>async(t,r,o)=>At(e)(t,r,o);var Zn=/^[cC][0-9a-z]{6,}$/,On=/^[0-9a-z]+$/,Rn=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Cn=/^[0-9a-vA-V]{20}$/,In=/^[A-Za-z0-9]{27}$/,An=/^[a-zA-Z0-9_-]{21}$/;function Tn(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var Nn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var jn=/^([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})$/,kr=(e)=>{if(!e)return/^([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)$/;return 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})$`)};var Dn=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Cp="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Fn(){return new RegExp(Cp,"u")}var Ln=/^(?:(?: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])$/,Mn=/^(([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}|:))$/;var Wn=/^((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])$/,Un=/^(([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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Bn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Jn=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var Vn=/^https?$/,Hn=/^\+[1-9]\d{6,14}$/;var Kn="(?:(?:\\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])))";function Ip(e){return new RegExp(`^${e}$`)}var Gn=Ip(Kn);function br(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function qn(e){return new RegExp(`^${br(e)}$`)}function Xn(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${br({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,o=e.local?`${r}|${br({precision:e.precision})}`:r;return new RegExp(`^${Kn}T(?:${o})$`)}var Yn=/^[\s\S]{0,}$/;var Qn=/^-?\d+n?$/;var $r=/^-?\d+(?:\.\d+)?$/,es=/^(?:true|false)$/i;var ts=/^[^A-Z]*$/,rs=/^[^a-z]*$/;var A=h("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var Sr=(e)=>{let t=e.value;return!Xo(t)&&t.length!==void 0},Tt={number:"number",bigint:"bigint",object:"date"},zr=h("$ZodCheckLessThan",(e,t)=>{A.init(e,t);let r=Tt[typeof t.value];e._zod.check=(o)=>{if(t.inclusive?o.value<=t.value:o.value<t.value)return;o.issues.push({origin:Tt[typeof o.value]??r,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Pr=h("$ZodCheckGreaterThan",(e,t)=>{A.init(e,t);let r=Tt[typeof t.value];e._zod.check=(o)=>{if(t.inclusive?o.value>=t.value:o.value>t.value)return;o.issues.push({origin:Tt[typeof o.value]??r,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),os=h("$ZodCheckMultipleOf",(e,t)=>{A.init(e,t),e._zod.check=(r)=>{if(typeof r.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof r.value==="bigint"?t.value!==BigInt(0)&&r.value%t.value===BigInt(0):Yo(r.value,t.value)===0)return;r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),ns=h("$ZodCheckNumberFormat",(e,t)=>{A.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),o=r?"int":"number",[n,s]=bt[t.format];e._zod.check=(i)=>{let c=i.value;if(r){if(!Number.isInteger(c)){i.issues.push({expected:o,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){if(c>0)i.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort});else i.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort});return}}if(c<n)i.issues.push({origin:"number",input:c,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort});if(c>s)i.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var ss=h("$ZodCheckMaxLength",(e,t)=>{var r;A.init(e,t),(r=e._zod.def).when??(r.when=Sr),e._zod.check=(o)=>{let n=o.value,s=n.length;if((typeof n==="string"&&s>t.maximum?zt(n):s)<=t.maximum)return;let c=Pt(n);o.issues.push({origin:c,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),is=h("$ZodCheckMinLength",(e,t)=>{var r;A.init(e,t),(r=e._zod.def).when??(r.when=Sr),e._zod.check=(o)=>{let n=o.value,s=n.length;if((typeof n==="string"&&s>=t.minimum&&s<t.minimum*2?zt(n):s)>=t.minimum)return;let c=Pt(n);o.issues.push({origin:c,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),cs=h("$ZodCheckLengthEquals",(e,t)=>{var r;A.init(e,t),(r=e._zod.def).when??(r.when=Sr),e._zod.check=(o)=>{let n=o.value,s=n.length,i=typeof n==="string"&&s>=t.length&&s<=t.length*2?zt(n):s;if(i===t.length)return;let c=Pt(n),a=i>t.length;o.issues.push({origin:c,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),rt=h("$ZodCheckStringFormat",(e,t)=>{var r,o;if(A.init(e,t),t.pattern)(r=e._zod).check??(r.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(o=e._zod).check??(o.check=()=>{})}),as=h("$ZodCheckRegex",(e,t)=>{rt.init(e,t),e._zod.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),us=h("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=ts),rt.init(e,t)}),ps=h("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=rs),rt.init(e,t)}),ls=h("$ZodCheckIncludes",(e,t)=>{A.init(e,t);let r=ye(t.includes),o=new RegExp(typeof t.position==="number"?`^.{${t.position},}${r}`:r);t.pattern=o,e._zod.check=(n)=>{if(n.value.includes(t.includes,t.position))return;n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),fs=h("$ZodCheckStartsWith",(e,t)=>{A.init(e,t);let r=new RegExp(`^${ye(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.check=(o)=>{if(o.value.startsWith(t.prefix))return;o.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:o.value,inst:e,continue:!t.abort})}}),ds=h("$ZodCheckEndsWith",(e,t)=>{A.init(e,t);let r=new RegExp(`.*${ye(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.check=(o)=>{if(o.value.endsWith(t.suffix))return;o.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:o.value,inst:e,continue:!t.abort})}});var hs=h("$ZodCheckOverwrite",(e,t)=>{A.init(e,t),e._zod.check=(r)=>{r.value=t.tx(r.value)}});class Er{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let r=e.split(`
|
|
3
3
|
`).filter((s)=>s),o=Math.min(...r.map((s)=>s.length-s.trimStart().length)),n=r.map((s)=>s.slice(o)).map((s)=>" ".repeat(this.indent*2)+s);for(let s of n)this.content.push(s)}compile(){let e=Function,t=this?.content??[""];return new e(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
|
|
4
4
|
${t.join(`
|
|
5
5
|
`)}
|
|
6
|
-
};`)(...Object.values(this.closed))}}var gs={major:4,minor:6,patch:7};var E=h("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=gs;let o=e._zod.def.checks,n=e._zod.traits.has("$ZodCheck")?[e,...o??[]]:o?.length?[...o]:[];for(let s of n)for(let i of s._zod.onattach)i(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(c,a,u)=>{if(c.memo)return c;let p=se(c),l;for(let f of a){if(f._zod.def.when){if(un(c))continue;if(!f._zod.def.when(c))continue}else if(p)continue;let d=c.issues.length,m=f._zod.check(c);if(m instanceof Promise&&u?.async===!1)throw new ie;if(l||m instanceof Promise)l=(l??Promise.resolve()).then(async()=>{if(await m,c.issues.length===d)return;if($t(c.issues,d,e),!p)p=se(c,d)});else{if(c.issues.length===d)continue;if($t(c.issues,d,e),!p)p=se(c,d)}}if(l)return l.then(()=>c);return c},i=(c,a,u)=>{if(se(c))return c.aborted=!0,c;let p=s(a,n,u);if(p instanceof Promise){if(u.async===!1)throw new ie;return p.then((l)=>e._zod.parse(l,u))}return e._zod.parse(p,u)};e._zod.run=(c,a)=>{if(a.skipChecks)return e._zod.parse(c,a);if(a.direction==="backward"){let p=e._zod.parse({value:c.value,issues:[]},{...a,skipChecks:!0});if(p instanceof Promise)return p.then((l)=>i(l,c,a));return i(p,c,a)}let u=e._zod.parse(c,a);if(u instanceof Promise){if(a.async===!1)throw new ie;return u.then((p)=>s(p,n,a))}return s(u,n,a)}}},{get "~standard"(){return Pt(this,"~standard",Or(this))},set "~standard"(e){pe(this,"~standard",e)}}),Ps=(e,t)=>e.issues.length?{issues:e.issues.map((r)=>xe(r,t,te()))}:{value:e.value};async function Tp(e,t){let r={async:!0};return Ps(await e._zod.run({value:t,issues:[]},r),r)}function Or(e){return{validate:(t)=>{let r={async:!1};try{let o=e._zod.run({value:t,issues:[]},r);if(!(o instanceof Promise))return Ps(o,r)}catch(o){}return Tp(e,t)},vendor:"zod",version:1}}var Dt=h("$ZodString",(e,t)=>{E.init(e,t),e._zod.pattern=t.pattern??Yn,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=String(r.value)}catch(n){}if(typeof r.value==="string")return r;return r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),Z=h("$ZodStringFormat",(e,t)=>{tt.init(e,t),Dt.init(e,t)}),Es=h("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=jn),Z.init(e,t)}),Zs=h("$ZodUUID",(e,t)=>{if(t.version){let o={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(o===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=kr(o))}else t.pattern??(t.pattern=kr());Z.init(e,t)}),Os=h("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Dn),Z.init(e,t)}),Rs=1,Nt=2;function Cs(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function Np(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return Cs(e)||Nt;return jp(e,t)}function jp(e,t){if(!t.normalize&&t.protocol?.source===Vn.source&&!/^https?:\/\//i.test(e))return Rs;try{if(typeof URL<"u"){let r=URL;if(typeof r.parse==="function")return r.parse(e)??Nt}return new URL(e)}catch{return Nt}}var Dp=/[\t\n\r]/g;function ys(e){return e.replace(Dp,"")}function Fp(e,t){return t.lastIndex=0,t.test(e.hostname)}function Lp(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var Is=h("$ZodURL",(e,t)=>{Z.init(e,t),e._zod.check=(r)=>{try{let o=r.value.trim(),n=Np(o,t);if(n===Rs){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(n===Nt){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}if(n===!0){r.value=ys(o);return}if(t.hostname&&!Fp(n,t.hostname))r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort});if(t.protocol&&!Lp(n,t.protocol))r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort});r.value=t.normalize?n.href:ys(o);return}catch(o){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),As=h("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Fn()),Z.init(e,t)}),Ts=h("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?An:Tn(t.length)),Z.init(e,t)}),Ns=h("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Zn),Z.init(e,t)}),js=h("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=On),Z.init(e,t)}),Ds=h("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Rn),Z.init(e,t)}),Fs=h("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Cn),Z.init(e,t)}),Ls=h("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=In),Z.init(e,t)}),Ms=h("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Xn(t)),Z.init(e,t)}),Ws=h("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Gn),Z.init(e,t)}),Us=h("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=qn(t)),Z.init(e,t)}),Bs=h("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Nn),Z.init(e,t)}),Js=h("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Ln),Z.init(e,t)}),Mp=/^[0-9a-fA-F:.]+$/;function Vs(e){if(!Mp.test(e))return!1;return Cs(`http://[${e}]`)}var Hs=h("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Mn),Z.init(e,t),e._zod.check=(r)=>{if(!Vs(r.value))r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}});var Ks=h("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Wn),Z.init(e,t)});function Wp(e){let t=e.split("/");if(t.length!==2)return!1;let[r,o]=t;if(!o)return!1;let n=Number(o);if(`${n}`!==o)return!1;if(n<0||n>128)return!1;return Vs(r)}var Gs=h("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Un),Z.init(e,t),e._zod.check=(r)=>{if(!Wp(r.value))r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function qs(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Rr=/^[0-9a-zA-Z+/]*={0,2}$/,Xs=h("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Rr),Z.init(e,t),e._zod.check=(r)=>{if(qs(r.value))return;r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),Ft=/^[A-Za-z0-9_-]*$/;function Up(e){if(!Ft.test(e))return!1;let t=e.replace(/[-_]/g,(o)=>o==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return qs(r)}var Ys=h("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Ft),Z.init(e,t),e._zod.check=(r)=>{if(Up(r.value))return;r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Qs=h("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Hn),Z.init(e,t)});function Bp(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[o]=r;if(!o)return!1;let n=JSON.parse(atob(o));if("typ"in n&&n?.typ!=="JWT")return!1;if(!n.alg)return!1;if(t&&(!("alg"in n)||n.alg!==t))return!1;return!0}catch{return!1}}var ei=h("$ZodJWT",(e,t)=>{Z.init(e,t),e._zod.check=(r)=>{if(Bp(r.value,t.alg))return;r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var Cr=h("$ZodNumber",(e,t)=>{E.init(e,t),e._zod.pattern=$r,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=Number(r.value)}catch(i){}let n=r.value;if(typeof n==="number"&&!Number.isNaN(n)&&Number.isFinite(n))return r;let s=typeof n==="number"?Number.isNaN(n)?"NaN":!Number.isFinite(n)?String(n):void 0:void 0;return r.issues.push({expected:"number",code:"invalid_type",input:n,inst:e,...s?{received:s}:{}}),r}}),ti=h("$ZodNumberFormat",(e,t)=>{ns.init(e,t),Cr.init(e,t)}),ri=h("$ZodBoolean",(e,t)=>{E.init(e,t),e._zod.pattern=es,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=Boolean(r.value)}catch(s){}let n=r.value;if(typeof n==="boolean")return r;return r.issues.push({expected:"boolean",code:"invalid_type",input:n,inst:e}),r}}),oi=h("$ZodBigInt",(e,t)=>{E.init(e,t),e._zod.pattern=Qn,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch(n){}if(typeof r.value==="bigint")return r;return r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}});var ni=h("$ZodUnknown",(e,t)=>{E.init(e,t),e._zod.parse=(r)=>r}),si=h("$ZodNever",(e,t)=>{E.init(e,t),e._zod.parse=(r,o)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});var ii=h("$ZodDate",(e,t)=>{E.init(e,t),e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=new Date(r.value)}catch(c){}let n=r.value,s=n instanceof Date;if(s&&!Number.isNaN(n.getTime()))return r;return r.issues.push({expected:"date",code:"invalid_type",input:n,...s?{received:"Invalid Date"}:{},inst:e}),r}});function Jp(e,t){let r=gr(e._zod.def.checks);if(!r.length)return;let o=Math.min(...r.map((s)=>s[0])),n=e._zod.parse;e._zod.parse=(s,i)=>{let c=t(s.value);if(c>o&&!i?.skipChecks&&i?.direction!=="backward"){for(let[a,u]of gr(e._zod.def.checks))if(c>a&&u._zod.def.when(s)){let p=s.issues.length;return u._zod.check(s),s.issues[p].continue=!1,$t(s.issues,p,e),s}}return n(s,i)}}var Vp=(e)=>Array.isArray(e)?e.length:-1;function xs(e,t,r){if(e.issues.length)t.issues.push(...kt(r,e.issues));t.value[r]=e.value}var ci=h("$ZodArray",(e,t)=>{E.init(e,t);let r=J.memoizer;r?.attach(e),e._zod.parse=(o,n)=>{let s=o.value;if(!Array.isArray(s))return o.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),o;o.value=r?r.alloc(e,o,Array(s.length),n):Array(s.length);let i=[],c=n?.abortEarly;for(let a=0;a<s.length;a++){let u=s[a],p=t.element._zod.run({value:u,issues:[]},n);if(p instanceof Promise)i.push(p.then((l)=>xs(l,o,a)));else if(xs(p,o,a),c&&p.issues.length!==0&&se(p))break}if(i.length)return Promise.all(i).then(()=>o);return o},Jp(e,Vp)});function jt(e,t,r,o,n,s){let i=r in o,c=s==="optional";if(!i&&c&&n==="optional")return;if(e.issues.length){if(n!==void 0&&c&&!i)return;t.issues.push(...kt(r,e.issues))}if(!i&&n===void 0){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}if(e.value===void 0){if(i||n==="defaulted"&&!c)t.value[r]=void 0}else t.value[r]=e.value}var Hp=[];function ai(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),o=r.length?r:Hp,n=o.length?[...t,...o]:t;for(let i of n)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(i)}": expected a Zod schema`);let s=sn(e.shape);return{...e,allKeys:n,symbolKeys:o,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function ui(e,t,r,o,n,s,i){let c=[],a=n.keySet,u=n.catchall._zod,p=u.def.type,{optin:l,optout:f}=u,d=0;for(let m in t){if(i&&r.issues.length!==d){if(se(r,d))break;d=r.issues.length}if(a.has(m))continue;if(m==="__proto__"){if(p==="never")c.push(m);continue}if(p==="never"){c.push(m);continue}let g=u.run({value:t[m],issues:[]},o);if(g instanceof Promise)e.push(g.then((y)=>jt(y,r,m,t,l,f)));else jt(g,r,m,t,l,f)}if(c.length)r.issues.push({code:"unrecognized_keys",keys:c,input:t,inst:s,continue:!0});if(!e.length)return r;return Promise.all(e).then(()=>r)}var Kp=h("$ZodObject",(e,t)=>{E.init(e,t);let r=Object.getOwnPropertyDescriptor(t,"shape"),o=r?.get?r.get.raw:t.shape??{};if(o){let u=()=>{let p={...o};return Object.defineProperty(t,"shape",{value:p}),u.raw=p,p};u.raw=o,Object.defineProperty(t,"shape",{get:u})}let n=Xe(()=>ai(t));b(e,"propValues",(u)=>{let p=u.def.shape,l={};for(let f in p){let d=p[f]._zod;if(d.values){if(!Object.prototype.hasOwnProperty.call(l,f))Q(l,f,new Set);for(let m of d.values)l[f].add(m);if(d.optin!==void 0)l[f].add(void 0)}}return l});let s=Ce,i=t.catchall,c,a=J.memoizer;a?.attach(e),e._zod.parse=(u,p)=>{c??(c=n.value);let l=u.value;if(!s(l))return u.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),u;u.value=a?a.alloc(e,u,{},p):{};let f=[],d=c.shape,m=p?.abortEarly,g=u.issues.length;for(let y of c.allKeys){if(m&&u.issues.length!==g){if(se(u,g))break;g=u.issues.length}if(y==="__proto__")continue;let v=d[y],k=v._zod.optin,G=v._zod.optout,S=v._zod.run({value:l[y],issues:[]},p);if(S instanceof Promise)f.push(S.then((I)=>jt(I,u,y,l,k,G)));else jt(S,u,y,l,k,G)}if(!i)return f.length?Promise.all(f).then(()=>u):u;return ui(f,l,u,p,n.value,e,m===!0)}}),pi=h("$ZodObjectJIT",(e,t)=>{Kp.init(e,t);let r=e._zod.parse,o=Xe(()=>ai(t)),n=J.memoizer,s=(d)=>{let m=o.value,g=m.symbolKeys,y=new Er(["payload","ctx"],{shape:d,inst:e,memo:n,syms:g}),v=(I)=>`shape[${I}]._zod.run({ value: input[${I}], issues: [] }, ctx)`,k=(I,z)=>`
|
|
7
|
-
let ${
|
|
8
|
-
for (let i = 0; i < ${
|
|
9
|
-
const iss = ${
|
|
10
|
-
iss.path = iss.path ? [${
|
|
6
|
+
};`)(...Object.values(this.closed))}}var gs={major:4,minor:6,patch:7};var P=h("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=gs;let o=e._zod.def.checks,n=e._zod.traits.has("$ZodCheck")?[e,...o??[]]:o?.length?[...o]:[];for(let s of n)for(let i of s._zod.onattach)i(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(c,a,u)=>{if(c.memo)return c;let p=ne(c),l;for(let f of a){if(f._zod.def.when){if(un(c))continue;if(!f._zod.def.when(c))continue}else if(p)continue;let d=c.issues.length,m=f._zod.check(c);if(m instanceof Promise&&u?.async===!1)throw new se;if(l||m instanceof Promise)l=(l??Promise.resolve()).then(async()=>{if(await m,c.issues.length===d)return;if(St(c.issues,d,e),!p)p=ne(c,d)});else{if(c.issues.length===d)continue;if(St(c.issues,d,e),!p)p=ne(c,d)}}if(l)return l.then(()=>c);return c},i=(c,a,u)=>{if(ne(c))return c.aborted=!0,c;let p=s(a,n,u);if(p instanceof Promise){if(u.async===!1)throw new se;return p.then((l)=>e._zod.parse(l,u))}return e._zod.parse(p,u)};e._zod.run=(c,a)=>{if(a.skipChecks)return e._zod.parse(c,a);if(a.direction==="backward"){let p=e._zod.parse({value:c.value,issues:[]},{...a,skipChecks:!0});if(p instanceof Promise)return p.then((l)=>i(l,c,a));return i(p,c,a)}let u=e._zod.parse(c,a);if(u instanceof Promise){if(a.async===!1)throw new se;return u.then((p)=>s(p,n,a))}return s(u,n,a)}}},{get "~standard"(){return Et(this,"~standard",Or(this))},set "~standard"(e){pe(this,"~standard",e)}}),Ps=(e,t)=>e.issues.length?{issues:e.issues.map((r)=>xe(r,t,ee()))}:{value:e.value};async function Tp(e,t){let r={async:!0};return Ps(await e._zod.run({value:t,issues:[]},r),r)}function Or(e){return{validate:(t)=>{let r={async:!1};try{let o=e._zod.run({value:t,issues:[]},r);if(!(o instanceof Promise))return Ps(o,r)}catch(o){}return Tp(e,t)},vendor:"zod",version:1}}var Ft=h("$ZodString",(e,t)=>{P.init(e,t),e._zod.pattern=t.pattern??Yn,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=String(r.value)}catch(n){}if(typeof r.value==="string")return r;return r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),E=h("$ZodStringFormat",(e,t)=>{rt.init(e,t),Ft.init(e,t)}),Es=h("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=jn),E.init(e,t)}),Zs=h("$ZodUUID",(e,t)=>{if(t.version){let o={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(o===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=kr(o))}else t.pattern??(t.pattern=kr());E.init(e,t)}),Os=h("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Dn),E.init(e,t)}),Rs=1,jt=2;function Cs(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function Np(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return Cs(e)||jt;return jp(e,t)}function jp(e,t){if(!t.normalize&&t.protocol?.source===Vn.source&&!/^https?:\/\//i.test(e))return Rs;try{if(typeof URL<"u"){let r=URL;if(typeof r.parse==="function")return r.parse(e)??jt}return new URL(e)}catch{return jt}}var Dp=/[\t\n\r]/g;function ys(e){return e.replace(Dp,"")}function Fp(e,t){return t.lastIndex=0,t.test(e.hostname)}function Lp(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var Is=h("$ZodURL",(e,t)=>{E.init(e,t),e._zod.check=(r)=>{try{let o=r.value.trim(),n=Np(o,t);if(n===Rs){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(n===jt){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}if(n===!0){r.value=ys(o);return}if(t.hostname&&!Fp(n,t.hostname))r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort});if(t.protocol&&!Lp(n,t.protocol))r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort});r.value=t.normalize?n.href:ys(o);return}catch(o){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),As=h("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Fn()),E.init(e,t)}),Ts=h("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?An:Tn(t.length)),E.init(e,t)}),Ns=h("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Zn),E.init(e,t)}),js=h("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=On),E.init(e,t)}),Ds=h("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Rn),E.init(e,t)}),Fs=h("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Cn),E.init(e,t)}),Ls=h("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=In),E.init(e,t)}),Ms=h("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Xn(t)),E.init(e,t)}),Ws=h("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Gn),E.init(e,t)}),Us=h("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=qn(t)),E.init(e,t)}),Bs=h("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Nn),E.init(e,t)}),Js=h("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Ln),E.init(e,t)}),Mp=/^[0-9a-fA-F:.]+$/;function Vs(e){if(!Mp.test(e))return!1;return Cs(`http://[${e}]`)}var Hs=h("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Mn),E.init(e,t),e._zod.check=(r)=>{if(!Vs(r.value))r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}});var Ks=h("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Wn),E.init(e,t)});function Wp(e){let t=e.split("/");if(t.length!==2)return!1;let[r,o]=t;if(!o)return!1;let n=Number(o);if(`${n}`!==o)return!1;if(n<0||n>128)return!1;return Vs(r)}var Gs=h("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Un),E.init(e,t),e._zod.check=(r)=>{if(!Wp(r.value))r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function qs(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Rr=/^[0-9a-zA-Z+/]*={0,2}$/,Xs=h("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Rr),E.init(e,t),e._zod.check=(r)=>{if(qs(r.value))return;r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),Lt=/^[A-Za-z0-9_-]*$/;function Up(e){if(!Lt.test(e))return!1;let t=e.replace(/[-_]/g,(o)=>o==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return qs(r)}var Ys=h("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Lt),E.init(e,t),e._zod.check=(r)=>{if(Up(r.value))return;r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Qs=h("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Hn),E.init(e,t)});function Bp(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[o]=r;if(!o)return!1;let n=JSON.parse(atob(o));if("typ"in n&&n?.typ!=="JWT")return!1;if(!n.alg)return!1;if(t&&(!("alg"in n)||n.alg!==t))return!1;return!0}catch{return!1}}var ei=h("$ZodJWT",(e,t)=>{E.init(e,t),e._zod.check=(r)=>{if(Bp(r.value,t.alg))return;r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var Cr=h("$ZodNumber",(e,t)=>{P.init(e,t),e._zod.pattern=$r,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=Number(r.value)}catch(i){}let n=r.value;if(typeof n==="number"&&!Number.isNaN(n)&&Number.isFinite(n))return r;let s=typeof n==="number"?Number.isNaN(n)?"NaN":!Number.isFinite(n)?String(n):void 0:void 0;return r.issues.push({expected:"number",code:"invalid_type",input:n,inst:e,...s?{received:s}:{}}),r}}),ti=h("$ZodNumberFormat",(e,t)=>{ns.init(e,t),Cr.init(e,t)}),ri=h("$ZodBoolean",(e,t)=>{P.init(e,t),e._zod.pattern=es,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=Boolean(r.value)}catch(s){}let n=r.value;if(typeof n==="boolean")return r;return r.issues.push({expected:"boolean",code:"invalid_type",input:n,inst:e}),r}}),oi=h("$ZodBigInt",(e,t)=>{P.init(e,t),e._zod.pattern=Qn,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch(n){}if(typeof r.value==="bigint")return r;return r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}});var ni=h("$ZodUnknown",(e,t)=>{P.init(e,t),e._zod.parse=(r)=>r}),si=h("$ZodNever",(e,t)=>{P.init(e,t),e._zod.parse=(r,o)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});var ii=h("$ZodDate",(e,t)=>{P.init(e,t),e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=new Date(r.value)}catch(c){}let n=r.value,s=n instanceof Date;if(s&&!Number.isNaN(n.getTime()))return r;return r.issues.push({expected:"date",code:"invalid_type",input:n,...s?{received:"Invalid Date"}:{},inst:e}),r}});function Jp(e,t){let r=gr(e._zod.def.checks);if(!r.length)return;let o=Math.min(...r.map((s)=>s[0])),n=e._zod.parse;e._zod.parse=(s,i)=>{let c=t(s.value);if(c>o&&!i?.skipChecks&&i?.direction!=="backward"){for(let[a,u]of gr(e._zod.def.checks))if(c>a&&u._zod.def.when(s)){let p=s.issues.length;return u._zod.check(s),s.issues[p].continue=!1,St(s.issues,p,e),s}}return n(s,i)}}var Vp=(e)=>Array.isArray(e)?e.length:-1;function xs(e,t,r){if(e.issues.length)t.issues.push(...$t(r,e.issues));t.value[r]=e.value}var ci=h("$ZodArray",(e,t)=>{P.init(e,t);let r=J.memoizer;r?.attach(e),e._zod.parse=(o,n)=>{let s=o.value;if(!Array.isArray(s))return o.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),o;o.value=r?r.alloc(e,o,Array(s.length),n):Array(s.length);let i=[],c=n?.abortEarly;for(let a=0;a<s.length;a++){let u=s[a],p=t.element._zod.run({value:u,issues:[]},n);if(p instanceof Promise)i.push(p.then((l)=>xs(l,o,a)));else if(xs(p,o,a),c&&p.issues.length!==0&&ne(p))break}if(i.length)return Promise.all(i).then(()=>o);return o},Jp(e,Vp)});function Dt(e,t,r,o,n,s){let i=r in o,c=s==="optional";if(!i&&c&&n==="optional")return;if(e.issues.length){if(n!==void 0&&c&&!i)return;t.issues.push(...$t(r,e.issues))}if(!i&&n===void 0){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}if(e.value===void 0){if(i||n==="defaulted"&&!c)t.value[r]=void 0}else t.value[r]=e.value}var Hp=[];function ai(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),o=r.length?r:Hp,n=o.length?[...t,...o]:t;for(let i of n)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(i)}": expected a Zod schema`);let s=sn(e.shape);return{...e,allKeys:n,symbolKeys:o,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function ui(e,t,r,o,n,s,i){let c=[],a=n.keySet,u=n.catchall._zod,p=u.def.type,{optin:l,optout:f}=u,d=0;for(let m in t){if(i&&r.issues.length!==d){if(ne(r,d))break;d=r.issues.length}if(a.has(m))continue;if(m==="__proto__"){if(p==="never")c.push(m);continue}if(p==="never"){c.push(m);continue}let y=u.run({value:t[m],issues:[]},o);if(y instanceof Promise)e.push(y.then((g)=>Dt(g,r,m,t,l,f)));else Dt(y,r,m,t,l,f)}if(c.length)r.issues.push({code:"unrecognized_keys",keys:c,input:t,inst:s,continue:!0});if(!e.length)return r;return Promise.all(e).then(()=>r)}var Kp=h("$ZodObject",(e,t)=>{P.init(e,t);let r=Object.getOwnPropertyDescriptor(t,"shape"),o=r?.get?r.get.raw:t.shape??{};if(o){let u=()=>{let p={...o};return Object.defineProperty(t,"shape",{value:p}),u.raw=p,p};u.raw=o,Object.defineProperty(t,"shape",{get:u})}let n=Ye(()=>ai(t));S(e,"propValues",(u)=>{let p=u.def.shape,l={};for(let f in p){let d=p[f]._zod;if(d.values){if(!Object.prototype.hasOwnProperty.call(l,f))Y(l,f,new Set);for(let m of d.values)l[f].add(m);if(d.optin!==void 0)l[f].add(void 0)}}return l});let s=Ie,i=t.catchall,c,a=J.memoizer;a?.attach(e),e._zod.parse=(u,p)=>{c??(c=n.value);let l=u.value;if(!s(l))return u.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),u;u.value=a?a.alloc(e,u,{},p):{};let f=[],d=c.shape,m=p?.abortEarly,y=u.issues.length;for(let g of c.allKeys){if(m&&u.issues.length!==y){if(ne(u,y))break;y=u.issues.length}if(g==="__proto__")continue;let v=d[g],b=v._zod.optin,U=v._zod.optout,ae=v._zod.run({value:l[g],issues:[]},p);if(ae instanceof Promise)f.push(ae.then((Z)=>Dt(Z,u,g,l,b,U)));else Dt(ae,u,g,l,b,U)}if(!i)return f.length?Promise.all(f).then(()=>u):u;return ui(f,l,u,p,n.value,e,m===!0)}}),pi=h("$ZodObjectJIT",(e,t)=>{Kp.init(e,t);let r=e._zod.parse,o=Ye(()=>ai(t)),n=J.memoizer,s=(d)=>{let m=o.value,y=m.symbolKeys,g=new Er(["payload","ctx"],{shape:d,inst:e,memo:n,syms:y}),v=(Z)=>`shape[${Z}]._zod.run({ value: input[${Z}], issues: [] }, ctx)`,b=(Z,w)=>`
|
|
7
|
+
let ${Z}_ab = false;
|
|
8
|
+
for (let i = 0; i < ${Z}.issues.length; i++) {
|
|
9
|
+
const iss = ${Z}.issues[i];
|
|
10
|
+
iss.path = iss.path ? [${w}, ...iss.path] : [${w}];
|
|
11
11
|
payload.issues.push(iss);
|
|
12
|
-
if (iss.continue !== true) ${
|
|
12
|
+
if (iss.continue !== true) ${Z}_ab = true;
|
|
13
13
|
}
|
|
14
|
-
if (${
|
|
14
|
+
if (${Z}_ab && ctx && ctx.abortEarly) {
|
|
15
15
|
payload.value = newResult;
|
|
16
16
|
return payload;
|
|
17
|
-
}`;
|
|
18
|
-
const ${
|
|
19
|
-
if (!${
|
|
20
|
-
if (${
|
|
17
|
+
}`;g.write("const input = payload.value;");let U=Object.create(null),ae=0;for(let Z of m.allKeys)U[Z]=`key_${ae++}`;g.write(n?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let Z of m.allKeys){if(Z==="__proto__")continue;let w=U[Z],G=typeof Z==="symbol"?`syms[${y.indexOf(Z)}]`:tn(Z),ar=`${G} in input`,Ho=d[Z],ur=Ho?._zod?.optin,Ko=ur!==void 0,sp=Ho?._zod?.optout==="optional";if(g.write(`const ${w} = ${v(G)};`),Ko&&sp){let ip=ur==="optional"?`${w}_present`:`${w}.value !== undefined || ${w}_present`;g.write(`
|
|
18
|
+
const ${w}_present = ${ar};
|
|
19
|
+
if (!${w}.issues.length || ${w}_present) {
|
|
20
|
+
if (${w}.issues.length) {${b(w,G)}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
if (${ip}) {
|
|
24
|
-
newResult[${
|
|
24
|
+
newResult[${G}] = ${w}.value;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
`)}else if(!Ko)
|
|
29
|
-
const ${
|
|
30
|
-
if (${
|
|
28
|
+
`)}else if(!Ko)g.write(`
|
|
29
|
+
const ${w}_present = ${ar};
|
|
30
|
+
if (${w}.issues.length) {${b(w,G)}
|
|
31
31
|
}
|
|
32
|
-
if (!${
|
|
32
|
+
if (!${w}_present && !${w}.issues.length) {
|
|
33
33
|
payload.issues.push({
|
|
34
34
|
code: "invalid_type",
|
|
35
35
|
expected: "nonoptional",
|
|
36
36
|
input: undefined,
|
|
37
|
-
path: [${
|
|
37
|
+
path: [${G}]
|
|
38
38
|
});
|
|
39
39
|
if (ctx && ctx.abortEarly) {
|
|
40
40
|
payload.value = newResult;
|
|
@@ -42,39 +42,39 @@ ${t.join(`
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
if (${
|
|
46
|
-
newResult[${
|
|
45
|
+
if (${w}_present) {
|
|
46
|
+
newResult[${G}] = ${w}.value;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
`);else if(
|
|
50
|
-
if (${
|
|
49
|
+
`);else if(g.write(`
|
|
50
|
+
if (${w}.issues.length) {${b(w,G)}
|
|
51
51
|
}
|
|
52
|
-
`),ur==="defaulted")
|
|
53
|
-
if (${
|
|
54
|
-
newResult[${
|
|
52
|
+
`),ur==="defaulted")g.write(`newResult[${G}] = ${w}.value;`);else g.write(`
|
|
53
|
+
if (${w}.value !== undefined || ${ar}) {
|
|
54
|
+
newResult[${G}] = ${w}.value;
|
|
55
55
|
}
|
|
56
|
-
`)}return y.write("payload.value = newResult;"),y.write("return payload;"),y.compile()},i,c=Ce,a=!J.jitless,p=a&&on.value,l=t.catchall,f;e._zod.parse=(d,m)=>{f??(f=o.value);let g=d.value;if(!c(g))return d.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),d;if(a&&p&&m?.async===!1&&m.jitless!==!0){if(!i)i=s(t.shape);if(d=i(d,m),!l)return d;return ui([],g,d,m,f,e,m?.abortEarly===!0)}return r(d,m)}});function vs(e,t,r,o){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let n=e.filter((s)=>!se(s));if(n.length===1)return t.value=n[0].value,n[0];return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map((s)=>s.issues.map((i)=>xe(i,o,te())))}),t}var Ir=h("$ZodUnion",(e,t)=>{E.init(e,t),b(e,"optin",(o)=>o.def.options.some((n)=>n._zod.optin==="defaulted")?"defaulted":o.def.options.some((n)=>n._zod.optin!==void 0)?"optional":void 0),b(e,"optout",(o)=>o.def.options.some((n)=>n._zod.optout==="optional")?"optional":void 0),b(e,"values",(o)=>{if(o.def.options.every((n)=>n._zod.values))return new Set(o.def.options.flatMap((n)=>Array.from(n._zod.values)));return}),b(e,"pattern",(o)=>{if(o.def.options.every((n)=>n._zod.pattern)){let n=o.def.options.map((s)=>s._zod.pattern);return new RegExp(`^(${n.map((s)=>wt(s.source)).join("|")})$`)}return});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(o,n)=>{if(r)return r(o,n);let s=!1,i=[];for(let c of t.options){let a=c._zod.run({value:o.value,issues:[]},n);if(a instanceof Promise)i.push(a),s=!0;else{if(a.issues.length===0)return a;i.push(a)}}if(!s)return vs(i,o,e,n);return Promise.all(i).then((c)=>vs(c,o,e,n))}});function Gp(e){let t=new Map;for(let r of e.options){let o=r._zod.propValues?.[e.discriminator];if(!o||o.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(r)}"`);for(let n of o)if(t.has(n)){if(n!==void 0)throw Error(`Duplicate discriminator value "${String(n)}"`);t.set(n,null)}else t.set(n,r)}return t}var li=h("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Ir.init(e,t);let r=e._zod.parse;b(e,"propValues",(n)=>{let s={},i=0;for(let c of n.def.options){let a=c._zod.propValues;if(!a||Object.keys(a).length===0)throw Error(`Invalid discriminated union option at index "${n.def.options.indexOf(c)}"`);if(a[n.def.discriminator]?.has(void 0))i++;for(let[u,p]of Object.entries(a)){if(!Object.prototype.hasOwnProperty.call(s,u))Q(s,u,new Set);for(let l of p)s[u].add(l)}}if(!n.def.unionFallback&&i>1)s[n.def.discriminator]?.delete(void 0);return s}),t.options.forEach((n,s)=>{let i=Ye(n._zod.def);if(i&&!Object.prototype.hasOwnProperty.call(i,t.discriminator))throw Error(`Invalid discriminated union option at index "${s}"`)});let o=Xe(()=>Gp(t));e._zod.parse=(n,s)=>{let i=n.value;if(!Ce(i))return n.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),n;let c=i?.[t.discriminator],a=o.value.get(c);if(a&&(c!==void 0||s.direction!=="backward"))return a._zod.run(n,s);if(t.unionFallback||s.direction==="backward")return r(n,s);return n.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(o.value.keys()).filter((u)=>o.value.get(u)!==null),input:i,path:[t.discriminator],inst:e}),n}}),fi=h("$ZodIntersection",(e,t)=>{E.init(e,t),e._zod.parse=(r,o)=>{let n=r.value,s=t.left._zod.run({value:n,issues:[]},o),i=t.right._zod.run({value:n,issues:[]},o);if(s instanceof Promise||i instanceof Promise)return Promise.all([s,i]).then(([a,u])=>ws(r,a,u));return ws(r,s,i)}});function Zr(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(Ie(e)&&Ie(t)){let r=Object.keys(t),o=Object.keys(e).filter((s)=>r.indexOf(s)!==-1),n={...e,...t};if(Object.prototype.hasOwnProperty.call(n,"__proto__"))delete n.__proto__;for(let s of o){if(s==="__proto__")continue;let i=Zr(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};n[s]=i.data}return{valid:!0,data:n}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let o=0;o<e.length;o++){let n=e[o],s=t[o],i=Zr(n,s);if(!i.valid)return{valid:!1,mergeErrorPath:[o,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function ws(e,t,r){let o=new Map,n,s=new Map,i=(u,p)=>{let l;if(u.code==="unrecognized_keys"&&!u.path?.length)n??(n=u),l=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){let f=String(u.path[0]);if(!s.has(f))s.set(f,u);l=[f]}else return!1;for(let f of l){if(!o.has(f))o.set(f,{});o.get(f)[p]=!0}return!0};for(let u of t.issues)if(!i(u,"l"))e.issues.push(u);for(let u of r.issues)if(!i(u,"r"))e.issues.push(u);let c=[...o].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(c.length){let u=n?c.filter((p)=>n.keys.includes(p)):[];if(u.length)e.issues.push({...n,keys:u});for(let p of c)if(!u.includes(p)&&s.has(p))e.issues.push(s.get(p))}let a=Zr(t.value,r.value);if(!a.valid){if(se(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`)}return e.value=a.data,e}var di=h("$ZodEnum",(e,t)=>{E.init(e,t);let r=Ge(t.entries),o=new Set(r);e._zod.values=o,b(e,"pattern",(n)=>{let s=Ge(n.def.entries).filter((i)=>nn.has(typeof i));return new RegExp(s.length?`^(${s.map((i)=>ye(i.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(n,s)=>{let i=n.value;if(o.has(i))return n;return n.issues.push({code:"invalid_value",values:r,input:i,inst:e}),n}}),hi=h("$ZodLiteral",(e,t)=>{E.init(e,t);let r=new Set(t.values);e._zod.values=r,b(e,"pattern",(o)=>{let n=o.def.values;return new RegExp(n.length?`^(${n.map((s)=>typeof s==="string"?ye(s):s?ye(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,n)=>{let s=o.value;if(r.has(s))return o;return o.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),o}});var mi=h("$ZodTransform",(e,t)=>{E.init(e,t),e._zod.optin="optional",J.memoizer?.guard(e),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new Qe(e.constructor.name);let n=t.transform(r.value,r);if(o.async)return(n instanceof Promise?n:Promise.resolve(n)).then((i)=>(r.value=i,r));if(n instanceof Promise)throw new ie;return r.value=n,r}});function _s(e,t){return e.value=t.issues.length?void 0:t.value,e}var Ar=h("$ZodOptional",(e,t)=>{E.init(e,t),b(e,"optin",(r)=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",b(e,"values",(r)=>{let o=r.def.innerType._zod.values;return o?new Set([...o,void 0]):void 0}),b(e,"pattern",(r)=>{let o=r.def.innerType._zod.pattern;return o?new RegExp(`^(${wt(o.source)})?$`):void 0}),e._zod.parse=(r,o)=>{if(r.value===void 0){if(t.innerType._zod.optin!=="defaulted")return r;let n=t.innerType._zod.run({value:r.value,issues:[]},o);if(n instanceof Promise)return n.then((s)=>_s(r,s));return _s(r,n)}return t.innerType._zod.run(r,o)}}),gi=h("$ZodExactOptional",(e,t)=>{Ar.init(e,t),b(e,"values",(r)=>r.def.innerType._zod.values),b(e,"pattern",(r)=>r.def.innerType._zod.pattern),e._zod.parse=(r,o)=>t.innerType._zod.run(r,o)}),yi=h("$ZodNullable",(e,t)=>{E.init(e,t),b(e,"optin",(r)=>r.def.innerType._zod.optin),b(e,"optout",(r)=>r.def.innerType._zod.optout),b(e,"pattern",(r)=>{let o=r.def.innerType._zod.pattern;return o?new RegExp(`^(${wt(o.source)}|null)$`):void 0}),b(e,"values",(r)=>r.def.innerType._zod.values?new Set([...r.def.innerType._zod.values,null]):void 0),e._zod.parse=(r,o)=>{if(r.value===null)return r;return t.innerType._zod.run(r,o)}}),xi=h("$ZodDefault",(e,t)=>{E.init(e,t),e._zod.optin="defaulted",b(e,"values",(r)=>r.def.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);if(r.value===void 0)return r.value=t.defaultValue,r;let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then((s)=>bs(s,t));return bs(n,t)}});function bs(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var vi=h("$ZodPrefault",(e,t)=>{E.init(e,t),e._zod.optin="defaulted",b(e,"values",(r)=>r.def.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);if(r.value===void 0)r.value=t.defaultValue;return t.innerType._zod.run(r,o)}}),wi=h("$ZodNonOptional",(e,t)=>{E.init(e,t),b(e,"values",(r)=>{let o=r.def.innerType._zod.values;return o?new Set([...o].filter((n)=>n!==void 0)):void 0}),e._zod.parse=(r,o)=>{let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then((s)=>ks(s,e));return ks(n,e)}});function ks(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}function $s(e,t,r,o){if(!t.issues.length){if(e.value=t.value,t.memo)e.memo=!0;return e}return e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map((n)=>xe(n,o,te()))},input:e.value}),e}var _i=h("$ZodCatch",(e,t)=>{E.init(e,t),b(e,"optin",(r)=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),b(e,"optout",(r)=>r.def.innerType._zod.optout),b(e,"values",(r)=>r.def.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);let n=t.innerType._zod.run({value:r.value,issues:[]},o);if(n instanceof Promise)return n.then((s)=>$s(r,s,t,o));return $s(r,n,t,o)}});var bi=h("$ZodPipe",(e,t)=>{E.init(e,t),b(e,"values",(r)=>r.def.in._zod.values),b(e,"optin",(r)=>r.def.in._zod.optin),b(e,"optout",(r)=>r.def.out._zod.optout),b(e,"propValues",(r)=>r.def.in._zod.propValues),e._zod.parse=(r,o)=>{if(o.direction==="backward"){let s=t.out._zod.run(r,o);if(s instanceof Promise)return s.then((i)=>Tt(i,t.in,o));return Tt(s,t.in,o)}let n=t.in._zod.run(r,o);if(n instanceof Promise)return n.then((s)=>Tt(s,t.out,o));return Tt(n,t.out,o)}});function Tt(e,t,r){if(e.issues.some((o)=>o.code!=="unrecognized_keys"))return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},r)}var ki=h("$ZodReadonly",(e,t)=>{E.init(e,t),b(e,"propValues",(r)=>r.def.innerType._zod.propValues),b(e,"values",(r)=>r.def.innerType._zod.values),b(e,"optin",(r)=>r.def.innerType?._zod?.optin),b(e,"optout",(r)=>r.def.innerType?._zod?.optout),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then(Ss);return Ss(n)}});function Ss(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var $i=h("$ZodCustom",(e,t)=>{T.init(e,t),E.init(e,t),e._zod.parse=(r,o)=>r,e._zod.check=(r)=>{let o=r.value,n=t.fn(o);if(n instanceof Promise)return n.then((s)=>zs(s,r,o,e));zs(n,r,o,e);return}});function zs(e,t,r,o){if(!e){let n={code:"custom",input:r,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};if(o._zod.def.params)n.params=o._zod.def.params;t.issues.push($e(n))}}class zi extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var Nr="~memo",Si=[];function Pi(e){return e!==null&&typeof e==="object"}function Tr(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var Ei=new WeakMap,rt=0,Wt=1,ot=2;function Ut(e,t,r){let o=Ei.get(e);if(o!==void 0)return o?ot:rt;if(t.has(e))return ot;t.add(e);let n=rt,s=(p)=>{if(n!==ot&&p?._zod){let l=Ut(p,t,r);if(l>n)n=l}},i=(p,l)=>{let f=rt;for(let d of Reflect.ownKeys(p)){let m=Object.getOwnPropertyDescriptor(p,d);if(l&&!m.enumerable)continue;let g=m.get?Wt:m.value?._zod?Ut(m.value,t,r):rt;if(g>f)f=g}return f},c=(p)=>{if(p>n)n=p},a=e._zod.def,u=a.type;switch(u){case"object":{let p=Ye(a);c(p?i(p,!0):Wt),s(a.catchall);break}case"array":s(a.element);break;case"tuple":for(let p of a.items)s(p);s(a.rest);break;case"record":case"map":s(a.keyType),s(a.valueType);break;case"set":s(a.valueType);break;case"union":for(let p of a.options)s(p);break;case"intersection":s(a.left),s(a.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(a.innerType);break;case"pipe":s(a.in),s(a.out);break;case"function":s(a.input),s(a.output);break;case"lazy":{let p=a._cachedInner??(r?e._zod.innerType:void 0);c(p?Ut(p,t,!1):Wt);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let p in a){let l=Object.getOwnPropertyDescriptor(a,p);if(!l||l.get)continue;let f=l.value;if(!f||typeof f!=="object")continue;if(f._zod)s(f);else if(Array.isArray(f))for(let d of f)s(d)}}return t.delete(e),qp(e,n)}function qp(e,t){if(t!==Wt)Ei.set(e,t===ot);return t}function Xp(e,t){let r=e.buckets.get(t);if(!r)r=new WeakMap,e.buckets.set(t,r);return r}var Lt,Mt=[],Yp={alloc(e,t,r){let o=Lt;if(!o)return r;Lt=void 0;let n={value:r,issues:null};return o.set(t.value,n),Mt.push(n),r},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let r=e._zod.parse,o=(n,s)=>{if(s.direction!=="backward"&&Qp(s,n.value))throw new zi;return r(n,s)};if(e._zod.parse=o,e._zod.run===r)e._zod.run=o})},attach(e){var t;let r,o=!1,n,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let i=e._zod.parse,c=(a,u)=>{if(r===void 0){let v=Ut(e,new Set,!1);if(v===rt){if(e._zod.parse=i,e._zod.run===c)e._zod.run=i;return i(a,u)}if(v===ot||o)r=!0;else o=!0}let p=a.value;if(!Pi(p))return i(a,u);let l=u[Nr];if(!l)l={buckets:new WeakMap,backEdges:void 0},u[Nr]=l;let f;if(n===u)f=s;else f=Xp(l,e),n=u,s=f;let d=f.get(p);if(d){if(a.value=d.value,d.issues){if(d.issues.length)a.issues.push(...Tr(d.issues))}else a.memo=!0,l.backEdges??(l.backEdges=new WeakSet),l.backEdges.add(d.value);return a}Lt=f;let m=Mt.length,g=i(a,u);Lt=void 0;let y=Mt.length>m?Mt.pop():void 0;if(g instanceof Promise)return g.then((v)=>{if(y)y.issues=v.issues.length?Tr(v.issues):Si;return v});if(y)y.issues=g.issues.length?Tr(g.issues):Si;return g};if(e._zod.parse=c,e._zod.run===i)e._zod.run=c})}};function Zi(){return Yp}function Qp(e,t){let r=e[Nr]?.backEdges;return r!==void 0&&Pi(t)&&r.has(t)}var el=()=>{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(s){return e[s]??null}let r={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",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},o={nan:"NaN"};function n(s,i){if(s==="number"&&typeof i==="number"&&!Number.isFinite(i))return String(i);return o[s]??s}return(s)=>{switch(s.code){case"invalid_type":{let i=n(s.expected),c=pn(s.input),a=n(c,s.input);return`Invalid input: expected ${i}, received ${a}`}case"invalid_value":if(s.values.length===1)return`Invalid input: expected ${hr(s.values[0])}`;return`Invalid option: expected one of ${lr(s.values,"|")}`;case"too_big":{let i=s.exact?"exactly ":s.inclusive?"<=":"<",c=t(s.origin);if(c)return`Too big: expected ${s.origin??"value"} to have ${i}${s.maximum.toString()} ${c.unit??"elements"}`;return`Too big: expected ${s.origin??"value"} to be ${i}${s.maximum.toString()}`}case"too_small":{let i=s.exact?"exactly ":s.inclusive?">=":">",c=t(s.origin);if(c)return`Too small: expected ${s.origin} to have ${i}${s.minimum.toString()} ${c.unit}`;return`Too small: expected ${s.origin} to be ${i}${s.minimum.toString()}`}case"invalid_format":{let i=s;if(i.format==="starts_with")return`Invalid string: must start with "${i.prefix}"`;if(i.format==="ends_with")return`Invalid string: must end with "${i.suffix}"`;if(i.format==="includes")return`Invalid string: must include "${i.includes}"`;if(i.format==="regex")return`Invalid string: must match pattern ${i.pattern}`;return`Invalid ${r[i.format]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${lr(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":if(s.options&&Array.isArray(s.options)&&s.options.length>0)return`Invalid discriminator value. Expected ${s.options.map((c)=>`'${c}'`).join(" | ")}`;if(s.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function jr(){return{localeError:el()}}var Oi;class Ri{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let r=t[0];if(this._map.set(e,r),r&&typeof r==="object"&&"id"in r)this._idmap.set(r.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let r={...this.get(t)??{}};delete r.id;let o={...r,...this._map.get(e)};return Object.keys(o).length?o:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function tl(){return new Ri}(Oi=globalThis).__zod_globalRegistry??(Oi.__zod_globalRegistry=tl());var Se=globalThis.__zod_globalRegistry;function Bt(e){if(e.checks)e.checks=[...e.checks];return e}function Ci(e,t){return new e(Bt({type:"string",...x(t)}))}function Ii(e,t){return new e(Bt({type:"string",coerce:!0,...x(t)}))}function Ai(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...x(t)})}function Ti(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...x(t)})}function Dr(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...x(t)})}function Ni(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...x(t)})}function ji(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...x(t)})}function Di(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...x(t)})}function Fr(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...x(t)})}function Fi(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...x(t)})}function Li(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...x(t)})}function Mi(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...x(t)})}function Wi(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...x(t)})}function Ui(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...x(t)})}function Bi(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...x(t)})}function Ji(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...x(t)})}function Vi(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...x(t)})}function Hi(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...x(t)})}function Ki(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...x(t)})}function Gi(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...x(t)})}function qi(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...x(t)})}function Xi(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...x(t)})}function Yi(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...x(t)})}function Qi(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...x(t)})}function ec(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...x(t)})}function tc(e,t){return new e({type:"string",format:"date",check:"string_format",...x(t)})}function rc(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...x(t)})}function oc(e,t){return new e({type:"string",format:"duration",check:"string_format",...x(t)})}function nc(e,t){return new e(Bt({type:"number",checks:[],...x(t)}))}function sc(e,t){return new e(Bt({type:"number",coerce:!0,checks:[],...x(t)}))}function ic(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...x(t)})}function cc(e,t){return new e({type:"boolean",...x(t)})}function ac(e,t){return new e({type:"boolean",coerce:!0,...x(t)})}function uc(e,t){return new e({type:"bigint",coerce:!0,...x(t)})}function pc(e){return new e({type:"unknown"})}function lc(e,t){return new e({type:"never",...x(t)})}function fc(e,t){return new e({type:"date",coerce:!0,...x(t)})}function Ae(e,t){return new zr({check:"less_than",...x(t),value:e,inclusive:!1})}function le(e,t){return new zr({check:"less_than",...x(t),value:e,inclusive:!0})}function Te(e,t){return new Pr({check:"greater_than",...x(t),value:e,inclusive:!1})}function fe(e,t){return new Pr({check:"greater_than",...x(t),value:e,inclusive:!0})}function nt(e,t){return new os({check:"multiple_of",...x(t),value:e})}function Jt(e,t){return new ss({check:"max_length",...x(t),maximum:e})}function Ne(e,t){return new is({check:"min_length",...x(t),minimum:e})}function Vt(e,t){return new cs({check:"length_equals",...x(t),length:e})}function Lr(e,t){return new as({check:"string_format",format:"regex",...x(t),pattern:e})}function Mr(e){return new us({check:"string_format",format:"lowercase",...x(e)})}function Wr(e){return new ps({check:"string_format",format:"uppercase",...x(e)})}function Ur(e,t){return new ls({check:"string_format",format:"includes",...x(t),includes:e})}function Br(e,t){return new fs({check:"string_format",format:"starts_with",...x(t),prefix:e})}function Jr(e,t){return new ds({check:"string_format",format:"ends_with",...x(t),suffix:e})}function ve(e){return new hs({check:"overwrite",tx:e})}function Vr(e){return ve((t)=>t.normalize(e))}function Hr(){return ve((e)=>e.trim())}function Kr(){return ve((e)=>e.toLowerCase())}function Gr(){return ve((e)=>e.toUpperCase())}function qr(){return ve((e)=>rn(e))}function dc(e,t,r){return new e({type:"array",element:t,...x(r)})}function hc(e,t,r){return new e({type:"custom",check:"custom",fn:t,...x(r)})}function mc(e,t){let r=rl((o)=>(o.addIssue=(n)=>{if(typeof n==="string")o.issues.push($e(n,o.value,r._zod.def));else{let s=n;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=o.value;s.inst??(s.inst=r),s.continue??(s.continue=!r._zod.def.abort),o.issues.push($e(s))}},e(o.value,o)),t);return r}function rl(e,t){let r=new T({check:"custom",...x(t)});return r._zod.check=e,r}function st(e,...t){for(let r of t)for(let o of Reflect.ownKeys(r))if(Object.prototype.propertyIsEnumerable.call(r,o))Q(e,o,r[o]);return e}function Yr(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??Se,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function re(e,t,r,o,n){let s=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:o.path,message:n}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw Error(n);return Object.assign(r,s),!0}function A(e,t,r={path:[],schemaPath:[]}){var o;let n=e._zod.def,s=t.seen.get(e);if(s){if(s.count++,r.schemaPath.includes(e))s.cycle=r.path;return s.schema}let i={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,i),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let c=e._zod.toJSONSchema?.();if(c)i.schema=c;else{let p={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,p);else{let f=i.schema,d=t.processors[n.type];if(!d)throw Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);d(e,t,f,p)}let l=e._zod.parent;if(l){if(!i.ref)i.ref=l;A(l,t,p),t.seen.get(l).isParent=!0}}let a=t.metadataRegistry.get(e);if(a)st(i.schema,a);if(t.io==="input"&&L(e))delete i.schema.examples,delete i.schema.default;if(t.io==="input"&&"_prefault"in i.schema)(o=i.schema).default??(o.default=i.schema._prefault);return delete i.schema._prefault,t.seen.get(e).schema}function gc(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Qr(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let o=new Map;for(let i of e.seen.entries()){let c=e.metadataRegistry.get(i[0])?.id;if(c){let a=o.get(c);if(a&&a!==i[0])throw Error(`Duplicate schema id "${c}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(c,i[0])}}let n=(i)=>{let c=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let l=e.external.registry.get(i[0])?.id,f=e.external.uri??((m)=>m);if(l)return{ref:f(l)};let d=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=d,{defId:d,ref:`${f("__shared")}#/${c}/${gc(d)}`}}let a="#",u=`${a}/${c}/`;if(i[1]===r&&!i[1].schema.id)return{ref:a};let p=i[1].schema.id??`__schema${e.counter++}`;return{defId:p,ref:u+gc(p)}},s=(i)=>{if(i[1].schema.$ref)return;let c=i[1],{ref:a,defId:u}=n(i);if(c.def={...c.schema},u)c.defId=u;let p=c.schema;for(let l in p)delete p[l];p.$ref=a};if(e.cycles==="throw")for(let i of e.seen.entries()){let c=i[1];if(c.cycle)throw Error(`Cycle detected: #/${c.cycle?.join("/")}/<root>
|
|
56
|
+
`)}return g.write("payload.value = newResult;"),g.write("return payload;"),g.compile()},i,c=Ie,a=!J.jitless,p=a&&on.value,l=t.catchall,f;e._zod.parse=(d,m)=>{f??(f=o.value);let y=d.value;if(!c(y))return d.issues.push({expected:"object",code:"invalid_type",input:y,inst:e}),d;if(a&&p&&m?.async===!1&&m.jitless!==!0){if(!i)i=s(t.shape);if(d=i(d,m),!l)return d;return ui([],y,d,m,f,e,m?.abortEarly===!0)}return r(d,m)}});function vs(e,t,r,o){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let n=e.filter((s)=>!ne(s));if(n.length===1)return t.value=n[0].value,n[0];return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map((s)=>s.issues.map((i)=>xe(i,o,ee())))}),t}var Ir=h("$ZodUnion",(e,t)=>{P.init(e,t),S(e,"optin",(o)=>o.def.options.some((n)=>n._zod.optin==="defaulted")?"defaulted":o.def.options.some((n)=>n._zod.optin!==void 0)?"optional":void 0),S(e,"optout",(o)=>o.def.options.some((n)=>n._zod.optout==="optional")?"optional":void 0),S(e,"values",(o)=>{if(o.def.options.every((n)=>n._zod.values))return new Set(o.def.options.flatMap((n)=>Array.from(n._zod.values)));return}),S(e,"pattern",(o)=>{if(o.def.options.every((n)=>n._zod.pattern)){let n=o.def.options.map((s)=>s._zod.pattern);return new RegExp(`^(${n.map((s)=>_t(s.source)).join("|")})$`)}return});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(o,n)=>{if(r)return r(o,n);let s=!1,i=[];for(let c of t.options){let a=c._zod.run({value:o.value,issues:[]},n);if(a instanceof Promise)i.push(a),s=!0;else{if(a.issues.length===0)return a;i.push(a)}}if(!s)return vs(i,o,e,n);return Promise.all(i).then((c)=>vs(c,o,e,n))}});function Gp(e){let t=new Map;for(let r of e.options){let o=r._zod.propValues?.[e.discriminator];if(!o||o.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(r)}"`);for(let n of o)if(t.has(n)){if(n!==void 0)throw Error(`Duplicate discriminator value "${String(n)}"`);t.set(n,null)}else t.set(n,r)}return t}var li=h("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Ir.init(e,t);let r=e._zod.parse;S(e,"propValues",(n)=>{let s={},i=0;for(let c of n.def.options){let a=c._zod.propValues;if(!a||Object.keys(a).length===0)throw Error(`Invalid discriminated union option at index "${n.def.options.indexOf(c)}"`);if(a[n.def.discriminator]?.has(void 0))i++;for(let[u,p]of Object.entries(a)){if(!Object.prototype.hasOwnProperty.call(s,u))Y(s,u,new Set);for(let l of p)s[u].add(l)}}if(!n.def.unionFallback&&i>1)s[n.def.discriminator]?.delete(void 0);return s}),t.options.forEach((n,s)=>{let i=Qe(n._zod.def);if(i&&!Object.prototype.hasOwnProperty.call(i,t.discriminator))throw Error(`Invalid discriminated union option at index "${s}"`)});let o=Ye(()=>Gp(t));e._zod.parse=(n,s)=>{let i=n.value;if(!Ie(i))return n.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),n;let c=i?.[t.discriminator],a=o.value.get(c);if(a&&(c!==void 0||s.direction!=="backward"))return a._zod.run(n,s);if(t.unionFallback||s.direction==="backward")return r(n,s);return n.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(o.value.keys()).filter((u)=>o.value.get(u)!==null),input:i,path:[t.discriminator],inst:e}),n}}),fi=h("$ZodIntersection",(e,t)=>{P.init(e,t),e._zod.parse=(r,o)=>{let n=r.value,s=t.left._zod.run({value:n,issues:[]},o),i=t.right._zod.run({value:n,issues:[]},o);if(s instanceof Promise||i instanceof Promise)return Promise.all([s,i]).then(([a,u])=>ws(r,a,u));return ws(r,s,i)}});function Zr(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(Ae(e)&&Ae(t)){let r=Object.keys(t),o=Object.keys(e).filter((s)=>r.indexOf(s)!==-1),n={...e,...t};if(Object.prototype.hasOwnProperty.call(n,"__proto__"))delete n.__proto__;for(let s of o){if(s==="__proto__")continue;let i=Zr(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};n[s]=i.data}return{valid:!0,data:n}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let o=0;o<e.length;o++){let n=e[o],s=t[o],i=Zr(n,s);if(!i.valid)return{valid:!1,mergeErrorPath:[o,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function ws(e,t,r){let o=new Map,n,s=new Map,i=(u,p)=>{let l;if(u.code==="unrecognized_keys"&&!u.path?.length)n??(n=u),l=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){let f=String(u.path[0]);if(!s.has(f))s.set(f,u);l=[f]}else return!1;for(let f of l){if(!o.has(f))o.set(f,{});o.get(f)[p]=!0}return!0};for(let u of t.issues)if(!i(u,"l"))e.issues.push(u);for(let u of r.issues)if(!i(u,"r"))e.issues.push(u);let c=[...o].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(c.length){let u=n?c.filter((p)=>n.keys.includes(p)):[];if(u.length)e.issues.push({...n,keys:u});for(let p of c)if(!u.includes(p)&&s.has(p))e.issues.push(s.get(p))}let a=Zr(t.value,r.value);if(!a.valid){if(ne(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`)}return e.value=a.data,e}var di=h("$ZodEnum",(e,t)=>{P.init(e,t);let r=qe(t.entries),o=new Set(r);e._zod.values=o,S(e,"pattern",(n)=>{let s=qe(n.def.entries).filter((i)=>nn.has(typeof i));return new RegExp(s.length?`^(${s.map((i)=>ye(i.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(n,s)=>{let i=n.value;if(o.has(i))return n;return n.issues.push({code:"invalid_value",values:r,input:i,inst:e}),n}}),hi=h("$ZodLiteral",(e,t)=>{P.init(e,t);let r=new Set(t.values);e._zod.values=r,S(e,"pattern",(o)=>{let n=o.def.values;return new RegExp(n.length?`^(${n.map((s)=>typeof s==="string"?ye(s):s?ye(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,n)=>{let s=o.value;if(r.has(s))return o;return o.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),o}});var mi=h("$ZodTransform",(e,t)=>{P.init(e,t),e._zod.optin="optional",J.memoizer?.guard(e),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new et(e.constructor.name);let n=t.transform(r.value,r);if(o.async)return(n instanceof Promise?n:Promise.resolve(n)).then((i)=>(r.value=i,r));if(n instanceof Promise)throw new se;return r.value=n,r}});function _s(e,t){return e.value=t.issues.length?void 0:t.value,e}var Ar=h("$ZodOptional",(e,t)=>{P.init(e,t),S(e,"optin",(r)=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",S(e,"values",(r)=>{let o=r.def.innerType._zod.values;return o?new Set([...o,void 0]):void 0}),S(e,"pattern",(r)=>{let o=r.def.innerType._zod.pattern;return o?new RegExp(`^(${_t(o.source)})?$`):void 0}),e._zod.parse=(r,o)=>{if(r.value===void 0){if(t.innerType._zod.optin!=="defaulted")return r;let n=t.innerType._zod.run({value:r.value,issues:[]},o);if(n instanceof Promise)return n.then((s)=>_s(r,s));return _s(r,n)}return t.innerType._zod.run(r,o)}}),gi=h("$ZodExactOptional",(e,t)=>{Ar.init(e,t),S(e,"values",(r)=>r.def.innerType._zod.values),S(e,"pattern",(r)=>r.def.innerType._zod.pattern),e._zod.parse=(r,o)=>t.innerType._zod.run(r,o)}),yi=h("$ZodNullable",(e,t)=>{P.init(e,t),S(e,"optin",(r)=>r.def.innerType._zod.optin),S(e,"optout",(r)=>r.def.innerType._zod.optout),S(e,"pattern",(r)=>{let o=r.def.innerType._zod.pattern;return o?new RegExp(`^(${_t(o.source)}|null)$`):void 0}),S(e,"values",(r)=>r.def.innerType._zod.values?new Set([...r.def.innerType._zod.values,null]):void 0),e._zod.parse=(r,o)=>{if(r.value===null)return r;return t.innerType._zod.run(r,o)}}),xi=h("$ZodDefault",(e,t)=>{P.init(e,t),e._zod.optin="defaulted",S(e,"values",(r)=>r.def.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);if(r.value===void 0)return r.value=t.defaultValue,r;let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then((s)=>bs(s,t));return bs(n,t)}});function bs(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var vi=h("$ZodPrefault",(e,t)=>{P.init(e,t),e._zod.optin="defaulted",S(e,"values",(r)=>r.def.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);if(r.value===void 0)r.value=t.defaultValue;return t.innerType._zod.run(r,o)}}),wi=h("$ZodNonOptional",(e,t)=>{P.init(e,t),S(e,"values",(r)=>{let o=r.def.innerType._zod.values;return o?new Set([...o].filter((n)=>n!==void 0)):void 0}),e._zod.parse=(r,o)=>{let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then((s)=>ks(s,e));return ks(n,e)}});function ks(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}function $s(e,t,r,o){if(!t.issues.length){if(e.value=t.value,t.memo)e.memo=!0;return e}return e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map((n)=>xe(n,o,ee()))},input:e.value}),e}var _i=h("$ZodCatch",(e,t)=>{P.init(e,t),S(e,"optin",(r)=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),S(e,"optout",(r)=>r.def.innerType._zod.optout),S(e,"values",(r)=>r.def.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);let n=t.innerType._zod.run({value:r.value,issues:[]},o);if(n instanceof Promise)return n.then((s)=>$s(r,s,t,o));return $s(r,n,t,o)}});var bi=h("$ZodPipe",(e,t)=>{P.init(e,t),S(e,"values",(r)=>r.def.in._zod.values),S(e,"optin",(r)=>r.def.in._zod.optin),S(e,"optout",(r)=>r.def.out._zod.optout),S(e,"propValues",(r)=>r.def.in._zod.propValues),e._zod.parse=(r,o)=>{if(o.direction==="backward"){let s=t.out._zod.run(r,o);if(s instanceof Promise)return s.then((i)=>Nt(i,t.in,o));return Nt(s,t.in,o)}let n=t.in._zod.run(r,o);if(n instanceof Promise)return n.then((s)=>Nt(s,t.out,o));return Nt(n,t.out,o)}});function Nt(e,t,r){if(e.issues.some((o)=>o.code!=="unrecognized_keys"))return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},r)}var ki=h("$ZodReadonly",(e,t)=>{P.init(e,t),S(e,"propValues",(r)=>r.def.innerType._zod.propValues),S(e,"values",(r)=>r.def.innerType._zod.values),S(e,"optin",(r)=>r.def.innerType?._zod?.optin),S(e,"optout",(r)=>r.def.innerType?._zod?.optout),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then(Ss);return Ss(n)}});function Ss(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var $i=h("$ZodCustom",(e,t)=>{A.init(e,t),P.init(e,t),e._zod.parse=(r,o)=>r,e._zod.check=(r)=>{let o=r.value,n=t.fn(o);if(n instanceof Promise)return n.then((s)=>zs(s,r,o,e));zs(n,r,o,e);return}});function zs(e,t,r,o){if(!e){let n={code:"custom",input:r,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};if(o._zod.def.params)n.params=o._zod.def.params;t.issues.push($e(n))}}class zi extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var Nr="~memo",Si=[];function Pi(e){return e!==null&&typeof e==="object"}function Tr(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var Ei=new WeakMap,ot=0,Ut=1,nt=2;function Bt(e,t,r){let o=Ei.get(e);if(o!==void 0)return o?nt:ot;if(t.has(e))return nt;t.add(e);let n=ot,s=(p)=>{if(n!==nt&&p?._zod){let l=Bt(p,t,r);if(l>n)n=l}},i=(p,l)=>{let f=ot;for(let d of Reflect.ownKeys(p)){let m=Object.getOwnPropertyDescriptor(p,d);if(l&&!m.enumerable)continue;let y=m.get?Ut:m.value?._zod?Bt(m.value,t,r):ot;if(y>f)f=y}return f},c=(p)=>{if(p>n)n=p},a=e._zod.def,u=a.type;switch(u){case"object":{let p=Qe(a);c(p?i(p,!0):Ut),s(a.catchall);break}case"array":s(a.element);break;case"tuple":for(let p of a.items)s(p);s(a.rest);break;case"record":case"map":s(a.keyType),s(a.valueType);break;case"set":s(a.valueType);break;case"union":for(let p of a.options)s(p);break;case"intersection":s(a.left),s(a.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(a.innerType);break;case"pipe":s(a.in),s(a.out);break;case"function":s(a.input),s(a.output);break;case"lazy":{let p=a._cachedInner??(r?e._zod.innerType:void 0);c(p?Bt(p,t,!1):Ut);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let p in a){let l=Object.getOwnPropertyDescriptor(a,p);if(!l||l.get)continue;let f=l.value;if(!f||typeof f!=="object")continue;if(f._zod)s(f);else if(Array.isArray(f))for(let d of f)s(d)}}return t.delete(e),qp(e,n)}function qp(e,t){if(t!==Ut)Ei.set(e,t===nt);return t}function Xp(e,t){let r=e.buckets.get(t);if(!r)r=new WeakMap,e.buckets.set(t,r);return r}var Mt,Wt=[],Yp={alloc(e,t,r){let o=Mt;if(!o)return r;Mt=void 0;let n={value:r,issues:null};return o.set(t.value,n),Wt.push(n),r},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let r=e._zod.parse,o=(n,s)=>{if(s.direction!=="backward"&&Qp(s,n.value))throw new zi;return r(n,s)};if(e._zod.parse=o,e._zod.run===r)e._zod.run=o})},attach(e){var t;let r,o=!1,n,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let i=e._zod.parse,c=(a,u)=>{if(r===void 0){let v=Bt(e,new Set,!1);if(v===ot){if(e._zod.parse=i,e._zod.run===c)e._zod.run=i;return i(a,u)}if(v===nt||o)r=!0;else o=!0}let p=a.value;if(!Pi(p))return i(a,u);let l=u[Nr];if(!l)l={buckets:new WeakMap,backEdges:void 0},u[Nr]=l;let f;if(n===u)f=s;else f=Xp(l,e),n=u,s=f;let d=f.get(p);if(d){if(a.value=d.value,d.issues){if(d.issues.length)a.issues.push(...Tr(d.issues))}else a.memo=!0,l.backEdges??(l.backEdges=new WeakSet),l.backEdges.add(d.value);return a}Mt=f;let m=Wt.length,y=i(a,u);Mt=void 0;let g=Wt.length>m?Wt.pop():void 0;if(y instanceof Promise)return y.then((v)=>{if(g)g.issues=v.issues.length?Tr(v.issues):Si;return v});if(g)g.issues=y.issues.length?Tr(y.issues):Si;return y};if(e._zod.parse=c,e._zod.run===i)e._zod.run=c})}};function Zi(){return Yp}function Qp(e,t){let r=e[Nr]?.backEdges;return r!==void 0&&Pi(t)&&r.has(t)}var el=()=>{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(s){return e[s]??null}let r={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",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},o={nan:"NaN"};function n(s,i){if(s==="number"&&typeof i==="number"&&!Number.isFinite(i))return String(i);return o[s]??s}return(s)=>{switch(s.code){case"invalid_type":{let i=n(s.expected),c=pn(s.input),a=n(c,s.input);return`Invalid input: expected ${i}, received ${a}`}case"invalid_value":if(s.values.length===1)return`Invalid input: expected ${hr(s.values[0])}`;return`Invalid option: expected one of ${lr(s.values,"|")}`;case"too_big":{let i=s.exact?"exactly ":s.inclusive?"<=":"<",c=t(s.origin);if(c)return`Too big: expected ${s.origin??"value"} to have ${i}${s.maximum.toString()} ${c.unit??"elements"}`;return`Too big: expected ${s.origin??"value"} to be ${i}${s.maximum.toString()}`}case"too_small":{let i=s.exact?"exactly ":s.inclusive?">=":">",c=t(s.origin);if(c)return`Too small: expected ${s.origin} to have ${i}${s.minimum.toString()} ${c.unit}`;return`Too small: expected ${s.origin} to be ${i}${s.minimum.toString()}`}case"invalid_format":{let i=s;if(i.format==="starts_with")return`Invalid string: must start with "${i.prefix}"`;if(i.format==="ends_with")return`Invalid string: must end with "${i.suffix}"`;if(i.format==="includes")return`Invalid string: must include "${i.includes}"`;if(i.format==="regex")return`Invalid string: must match pattern ${i.pattern}`;return`Invalid ${r[i.format]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${lr(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":if(s.options&&Array.isArray(s.options)&&s.options.length>0)return`Invalid discriminator value. Expected ${s.options.map((c)=>`'${c}'`).join(" | ")}`;if(s.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function jr(){return{localeError:el()}}var Oi;class Ri{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let r=t[0];if(this._map.set(e,r),r&&typeof r==="object"&&"id"in r)this._idmap.set(r.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let r={...this.get(t)??{}};delete r.id;let o={...r,...this._map.get(e)};return Object.keys(o).length?o:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function tl(){return new Ri}(Oi=globalThis).__zod_globalRegistry??(Oi.__zod_globalRegistry=tl());var Se=globalThis.__zod_globalRegistry;function Jt(e){if(e.checks)e.checks=[...e.checks];return e}function Ci(e,t){return new e(Jt({type:"string",...x(t)}))}function Ii(e,t){return new e(Jt({type:"string",coerce:!0,...x(t)}))}function Ai(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...x(t)})}function Ti(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...x(t)})}function Dr(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...x(t)})}function Ni(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...x(t)})}function ji(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...x(t)})}function Di(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...x(t)})}function Fr(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...x(t)})}function Fi(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...x(t)})}function Li(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...x(t)})}function Mi(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...x(t)})}function Wi(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...x(t)})}function Ui(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...x(t)})}function Bi(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...x(t)})}function Ji(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...x(t)})}function Vi(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...x(t)})}function Hi(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...x(t)})}function Ki(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...x(t)})}function Gi(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...x(t)})}function qi(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...x(t)})}function Xi(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...x(t)})}function Yi(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...x(t)})}function Qi(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...x(t)})}function ec(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...x(t)})}function tc(e,t){return new e({type:"string",format:"date",check:"string_format",...x(t)})}function rc(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...x(t)})}function oc(e,t){return new e({type:"string",format:"duration",check:"string_format",...x(t)})}function nc(e,t){return new e(Jt({type:"number",checks:[],...x(t)}))}function sc(e,t){return new e(Jt({type:"number",coerce:!0,checks:[],...x(t)}))}function ic(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...x(t)})}function cc(e,t){return new e({type:"boolean",...x(t)})}function ac(e,t){return new e({type:"boolean",coerce:!0,...x(t)})}function uc(e,t){return new e({type:"bigint",coerce:!0,...x(t)})}function pc(e){return new e({type:"unknown"})}function lc(e,t){return new e({type:"never",...x(t)})}function fc(e,t){return new e({type:"date",coerce:!0,...x(t)})}function Te(e,t){return new zr({check:"less_than",...x(t),value:e,inclusive:!1})}function le(e,t){return new zr({check:"less_than",...x(t),value:e,inclusive:!0})}function Ne(e,t){return new Pr({check:"greater_than",...x(t),value:e,inclusive:!1})}function fe(e,t){return new Pr({check:"greater_than",...x(t),value:e,inclusive:!0})}function st(e,t){return new os({check:"multiple_of",...x(t),value:e})}function Vt(e,t){return new ss({check:"max_length",...x(t),maximum:e})}function je(e,t){return new is({check:"min_length",...x(t),minimum:e})}function Ht(e,t){return new cs({check:"length_equals",...x(t),length:e})}function Lr(e,t){return new as({check:"string_format",format:"regex",...x(t),pattern:e})}function Mr(e){return new us({check:"string_format",format:"lowercase",...x(e)})}function Wr(e){return new ps({check:"string_format",format:"uppercase",...x(e)})}function Ur(e,t){return new ls({check:"string_format",format:"includes",...x(t),includes:e})}function Br(e,t){return new fs({check:"string_format",format:"starts_with",...x(t),prefix:e})}function Jr(e,t){return new ds({check:"string_format",format:"ends_with",...x(t),suffix:e})}function ve(e){return new hs({check:"overwrite",tx:e})}function Vr(e){return ve((t)=>t.normalize(e))}function Hr(){return ve((e)=>e.trim())}function Kr(){return ve((e)=>e.toLowerCase())}function Gr(){return ve((e)=>e.toUpperCase())}function qr(){return ve((e)=>rn(e))}function dc(e,t,r){return new e({type:"array",element:t,...x(r)})}function hc(e,t,r){return new e({type:"custom",check:"custom",fn:t,...x(r)})}function mc(e,t){let r=rl((o)=>(o.addIssue=(n)=>{if(typeof n==="string")o.issues.push($e(n,o.value,r._zod.def));else{let s=n;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=o.value;s.inst??(s.inst=r),s.continue??(s.continue=!r._zod.def.abort),o.issues.push($e(s))}},e(o.value,o)),t);return r}function rl(e,t){let r=new A({check:"custom",...x(t)});return r._zod.check=e,r}function it(e,...t){for(let r of t)for(let o of Reflect.ownKeys(r))if(Object.prototype.propertyIsEnumerable.call(r,o))Y(e,o,r[o]);return e}function Yr(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??Se,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function te(e,t,r,o,n){let s=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:o.path,message:n}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw Error(n);return Object.assign(r,s),!0}function I(e,t,r={path:[],schemaPath:[]}){var o;let n=e._zod.def,s=t.seen.get(e);if(s){if(s.count++,r.schemaPath.includes(e))s.cycle=r.path;return s.schema}let i={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,i),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let c=e._zod.toJSONSchema?.();if(c)i.schema=c;else{let p={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,p);else{let f=i.schema,d=t.processors[n.type];if(!d)throw Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);d(e,t,f,p)}let l=e._zod.parent;if(l){if(!i.ref)i.ref=l;I(l,t,p),t.seen.get(l).isParent=!0}}let a=t.metadataRegistry.get(e);if(a)it(i.schema,a);if(t.io==="input"&&F(e))delete i.schema.examples,delete i.schema.default;if(t.io==="input"&&"_prefault"in i.schema)(o=i.schema).default??(o.default=i.schema._prefault);return delete i.schema._prefault,t.seen.get(e).schema}function gc(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Qr(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let o=new Map;for(let i of e.seen.entries()){let c=e.metadataRegistry.get(i[0])?.id;if(c){let a=o.get(c);if(a&&a!==i[0])throw Error(`Duplicate schema id "${c}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(c,i[0])}}let n=(i)=>{let c=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let l=e.external.registry.get(i[0])?.id,f=e.external.uri??((m)=>m);if(l)return{ref:f(l)};let d=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=d,{defId:d,ref:`${f("__shared")}#/${c}/${gc(d)}`}}let a="#",u=`${a}/${c}/`;if(i[1]===r&&!i[1].schema.id)return{ref:a};let p=i[1].schema.id??`__schema${e.counter++}`;return{defId:p,ref:u+gc(p)}},s=(i)=>{if(i[1].schema.$ref)return;let c=i[1],{ref:a,defId:u}=n(i);if(c.def={...c.schema},u)c.defId=u;let p=c.schema;for(let l in p)delete p[l];p.$ref=a};if(e.cycles==="throw")for(let i of e.seen.entries()){let c=i[1];if(c.cycle)throw Error(`Cycle detected: #/${c.cycle?.join("/")}/<root>
|
|
57
57
|
|
|
58
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of e.seen.entries()){let c=i[1];if(t===i[0]){s(i);continue}if(e.external){let u=e.external.registry.get(i[0])?.id;if(t!==i[0]&&u){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(c.cycle){s(i);continue}if(c.count>1){if(e.reused==="ref")s(i)}}if(e.external)e.sharedDefsExtractedFor=e.external}function vc(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let o of t){if(!o||typeof o!=="object")return;vc(o);let n=Object.keys(o);if(n.length!==1||n[0]!=="type")return;let s=o.type;for(let i of Array.isArray(s)?s:[s]){if(typeof i!=="string")return;if(!r.includes(i))r.push(i)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var wc=new Set(["type","properties","required","additionalProperties"]),yc=["oneOf","anyOf"];function xc(e){let t=e.additionalProperties;if(t===void 0||t===!1||typeof t!=="object"||t===null)return null;return Object.keys(t).length?t:null}function Xr(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let i in s)if(!wc.has(i))return null;t.push(s)}let r={},o=new Set;for(let s of t){for(let i in s.properties){if(Object.prototype.hasOwnProperty.call(r,i))continue;let c=[];for(let u of t){let p=u.properties?.[i]??xc(u);if(p===null||p===void 0)continue;if(!c.some((l)=>JSON.stringify(l)===JSON.stringify(p)))c.push(p)}let a=c.length===1?c[0]:Xr(c)??{allOf:c};Q(r,i,a)}for(let i of s.required??[])o.add(i)}let n={type:"object",properties:r};if(o.size)n.required=[...o];if(t.every((s)=>s.additionalProperties===!1))n.additionalProperties=!1;else{let s=[];for(let i of t){let c=xc(i);if(c&&!s.some((a)=>JSON.stringify(a)===JSON.stringify(c)))s.push(c)}if(s.length===1)n.additionalProperties=s[0];else if(s.length>1)n.additionalProperties={allOf:s}}return n}function ol(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let n of wc)if(n in e)return;let r=t.filter((n)=>yc.some((s)=>Array.isArray(n[s]))),o=null;if(!r.length)o=Xr(t);else{let n=r[0],s=yc.find((a)=>Array.isArray(n[a]));if(Object.keys(n).length!==1)return;let i=t.filter((a)=>a!==n),c=n[s].map((a)=>Xr([...i,a]));if(c.some((a)=>!a))return;o={[s]:c}}if(!o)return;delete e.allOf,st(e,o)}function eo(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let o=(c)=>{let a=e.seen.get(c);if(a.ref===null)return;let u=a.def??a.schema,p={...u},l=a.ref;if(a.ref=null,l){o(l);let d=e.seen.get(l),m=d.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))u.allOf=u.allOf??[],u.allOf.push(m);else st(u,m);if(st(u,p),c._zod.parent===l)for(let y in u){if(y==="$ref"||y==="allOf")continue;if(!(y in p))delete u[y]}if(m.$ref&&d.def)for(let y in u){if(y==="$ref"||y==="allOf")continue;if(y in d.def&&JSON.stringify(u[y])===JSON.stringify(d.def[y]))delete u[y]}}let f=c._zod.parent;if(f&&f!==l){o(f);let d=e.seen.get(f);if(d?.schema.$ref){if(u.$ref=d.schema.$ref,d.def)for(let m in u){if(m==="$ref"||m==="allOf")continue;if(m in d.def&&JSON.stringify(u[m])===JSON.stringify(d.def[m]))delete u[m]}}}e.override({zodSchema:c,jsonSchema:u,path:a.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let c of[...e.seen.entries()].reverse())o(c[0]);if(e.target!=="openapi-3.0")for(let c of e.seen.entries())vc(c[1].def??c[1].schema);for(let c of e.deferred)c();if(e.intersections.length){let c=new Map;for(let a of e.seen.values())for(let u of[a.schema,a.def]){let p=u?.allOf;if(!Array.isArray(p))continue;let l=c.get(p);if(l)l.push(u);else c.set(p,[u])}for(let a of e.intersections)for(let u of c.get(a)??[])ol(u)}}let n={};if(e.target==="draft-2020-12")n.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")n.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")n.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let c=e.external.registry.get(t)?.id;if(!c)throw Error("Schema is missing an `id` property");n.$id=e.external.uri(c)}st(n,r.defId?r.schema:r.def??r.schema);let s=e.metadataRegistry.get(t)?.id;if(s!==void 0&&n.id===s)delete n.id;let i=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let c of e.seen.entries()){let a=c[1];if(a.def&&a.defId){if(a.def.id===a.defId)delete a.def.id;Q(i,a.defId,a.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(i).length>0)if(e.target==="draft-2020-12")n.$defs=i;else n.definitions=i;try{let c=JSON.parse(JSON.stringify(n));return Object.defineProperty(c,"~standard",{value:{...t["~standard"],jsonSchema:{input:it(t,"input",e.processors),output:it(t,"output",e.processors)}},enumerable:!1,writable:!1}),c}catch(c){throw Error("Error converting schema to JSON.")}}function L(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return L(o.element,r);if(o.type==="set")return L(o.valueType,r);if(o.type==="lazy")return L(o.getter(),r);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault"||o.type==="catch")return L(o.innerType,r);if(o.type==="intersection")return L(o.left,r)||L(o.right,r);if(o.type==="record"||o.type==="map")return L(o.keyType,r)||L(o.valueType,r);if(o.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return L(o.in,r)||L(o.out,r)}if(o.type==="object"){for(let n in o.shape)if(L(o.shape[n],r))return!0;return!1}if(o.type==="union"){for(let n of o.options)if(L(n,r))return!0;return!1}if(o.type==="tuple"){for(let n of o.items)if(L(n,r))return!0;if(o.rest&&L(o.rest,r))return!0;return!1}return!1}var _c=(e,t={})=>(r)=>{let o=Yr({...r,processors:t});return A(e,o),Qr(o,e),eo(o,e)},it=(e,t,r={})=>(o)=>{let{libraryOptions:n,target:s}=o??{},i=Yr({...n??{},target:s,io:t,processors:r});return A(e,i),Qr(i,e),eo(i,e)};var je=(e,t,r)=>{if(e[t]===void 0||r>e[t])e[t]=r},De=(e,t,r)=>{if(e[t]===void 0||r<e[t])e[t]=r},bc=(e,t)=>{je(e,"minimum",t),De(e,"maximum",t)},zc=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},Pc=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Ec=(e,t)=>{e.mime=e.mime?e.mime.filter((r)=>t.includes(r)):[...t]},Zc=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},kc=(e,t)=>je(e,"minimum",t.minimum),$c=(e,t)=>De(e,"maximum",t.maximum),Sc=(e)=>(t,r)=>{Zc(t,r.format);let[o,n]=e[r.format];je(t,"minimum",o),De(t,"maximum",n)},nl={greater_than:(e,t)=>je(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>De(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>zc(e,t.value),number_format:Sc(_t),bigint_format:Sc(mr),min_length:kc,max_length:$c,length_equals:(e,t)=>bc(e,t.length),min_size:kc,max_size:$c,size_equals:(e,t)=>bc(e,t.size),string_format:(e,t)=>{if(Zc(e,t.format),t.pattern)Pc(e,t.pattern);if(t.format==="base64"||t.format==="base64url")e.contentEncoding=t.format;if(t.local||t.precision===-1)e.laxFormat=!0},mime_type:(e,t)=>Ec(e,t.mime)};function j(e){let t={},r=e._zod.def,o=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let s of o)nl[s._zod.def.check]?.(t,s._zod.def);let n=e._zod.bag;if(n.minimum!==void 0)je(t,"minimum",n.minimum);if(n.exclusiveMinimum!==void 0)je(t,"exclusiveMinimum",n.exclusiveMinimum);if(n.maximum!==void 0)De(t,"maximum",n.maximum);if(n.exclusiveMaximum!==void 0)De(t,"exclusiveMaximum",n.exclusiveMaximum);if(n.multipleOf!==void 0)zc(t,n.multipleOf);if(n.format!==void 0){if(t.format??(t.format=n.format),n.format.includes("int"))t.isInt=!0}if(n.mime)Ec(t,n.mime);for(let s of n.patterns??[])Pc(t,s);return t}var sl={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},il=new Map([[Rr,Bn],[Ft,Jn]]),cl=(e)=>il.get(e)??e,Oc=(e,t,r,o)=>{let n=r;n.type="string";let{minimum:s,maximum:i,format:c,patterns:a,contentEncoding:u,laxFormat:p}=j(e);if(typeof s==="number")n.minLength=s;if(typeof i==="number")n.maxLength=i;if(c){if(n.format=sl[c]??c,n.format==="")delete n.format;if(c==="time"||p)delete n.format}if(u)n.contentEncoding=u;if(a&&a.size>0){let l=[...a].map(cl);if(l.length===1)n.pattern=l[0].source;else if(l.length>1)n.allOf=[...l.map((f)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))]}},Rc=(e,t,r,o)=>{let n=r,{minimum:s,maximum:i,multipleOf:c,exclusiveMaximum:a,exclusiveMinimum:u,isInt:p}=j(e);n.type=p?"integer":"number";let l=typeof u==="number"&&u>=(s??Number.NEGATIVE_INFINITY),f=typeof a==="number"&&a<=(i??Number.POSITIVE_INFINITY),d=t.target==="draft-04"||t.target==="openapi-3.0";if(l)if(d)n.minimum=u,n.exclusiveMinimum=!0;else n.exclusiveMinimum=u;else if(typeof s==="number")n.minimum=s;if(f)if(d)n.maximum=a,n.exclusiveMaximum=!0;else n.exclusiveMaximum=a;else if(typeof i==="number")n.maximum=i;if(c){let m=new Set;for(let v of c)if(Number.isFinite(v)&&v!==0)m.add(Math.abs(v));else re(e,t,n,o,`A multipleOf divisor of ${v} cannot be represented in JSON Schema`);let[g,...y]=m;if(g!==void 0)n.multipleOf=g;if(y.length)n.allOf=[...n.allOf??[],...y.map((v)=>({multipleOf:v}))]}},Cc=(e,t,r,o)=>{r.type="boolean"},Ic=(e,t,r,o)=>{re(e,t,r,o,"BigInt cannot be represented in JSON Schema")};var Ac=(e,t,r,o)=>{r.not={}};var Tc=(e,t,r,o)=>{},Nc=(e,t,r,o)=>{re(e,t,r,o,"Date cannot be represented in JSON Schema")},jc=(e,t,r,o)=>{let n=e._zod.def,s=Ge(n.entries);if(s.length===0){r.not={};return}if(s.every((i)=>typeof i==="number"))r.type="number";if(s.every((i)=>typeof i==="string"))r.type="string";r.enum=s},Dc=(e,t,r,o)=>{let n=e._zod.def;if(n.values.length===0){r.not={};return}let s=[];for(let i of n.values)if(i===void 0){if(re(e,t,r,o,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i==="bigint"){if(re(e,t,r,o,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(i))}else s.push(i);if(s.length===0);else if(s.length===1){let i=s[0];if(r.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0")r.enum=[i];else r.const=i}else{if(s.every((i)=>typeof i==="number"))r.type="number";if(s.every((i)=>typeof i==="string"))r.type="string";if(s.every((i)=>typeof i==="boolean"))r.type="boolean";if(s.every((i)=>i===null))r.type="null";r.enum=s}};var Fc=(e,t,r,o)=>{re(e,t,r,o,"Custom types cannot be represented in JSON Schema")};var Lc=(e,t,r,o)=>{re(e,t,r,o,"Transforms cannot be represented in JSON Schema")};var Mc=(e,t,r,o)=>{let n=r,s=e._zod.def,{minimum:i,maximum:c}=j(e);if(typeof i==="number")n.minItems=i;if(typeof c==="number")n.maxItems=c;n.type="array",n.items=A(s.element,t,{...o,path:[...o.path,"items"]})};function to(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return to(t.out);if(t.type==="catch")return to(t.innerType);return e._zod.optin}var Wc=(e,t,r,o)=>{let n=r,s=e._zod.def,i=s.shape;if(Object.getOwnPropertySymbols(i).length&&re(e,t,n,o,"Symbol keys cannot be represented in JSON Schema"))return;n.type="object",n.properties={};for(let u in i)Q(n.properties,u,A(i[u],t,{...o,path:[...o.path,"properties",u]}));let a=[];for(let u of Object.keys(i)){let p=s.shape[u];if(t.io==="input"?to(p)===void 0:p._zod.optout===void 0)a.push(u)}if(a.length>0)n.required=a;if(s.catchall?._zod.def.type==="never")n.additionalProperties=!1;else if(!s.catchall){if(t.io==="output")n.additionalProperties=!1}else if(s.catchall)n.additionalProperties=A(s.catchall,t,{...o,path:[...o.path,"additionalProperties"]})},Uc=(e,t,r,o)=>{let n=e._zod.def,s=n.inclusive===!1,i=n.options.map((c,a)=>A(c,t,{...o,path:[...o.path,s?"oneOf":"anyOf",a]}));if(s)r.oneOf=i;else r.anyOf=i},Bc=(e,t,r,o)=>{let n=e._zod.def,s=A(n.left,t,{...o,path:[...o.path,"allOf",0]}),i=A(n.right,t,{...o,path:[...o.path,"allOf",1]}),c=(u)=>("allOf"in u)&&Object.keys(u).length===1,a=[...c(s)?s.allOf:[s],...c(i)?i.allOf:[i]];r.allOf=a,t.intersections.push(a)};var Jc=(e,t,r,o)=>{let n=e._zod.def,s=A(n.innerType,t,o),i=t.seen.get(e);if(t.target==="openapi-3.0")i.ref=n.innerType,r.nullable=!0;else r.anyOf=[s,{type:"null"}]},Vc=(e,t,r,o)=>{let n=e._zod.def;A(n.innerType,t,o);let s=t.seen.get(e);s.ref=n.innerType},ro=Symbol();function Hc(e,t,r,o,n){let s=!1,i=JSON.stringify(e,(c,a)=>{if(typeof a!=="bigint")return a;return s=!0,null});if(!s)return JSON.parse(i);return re(t,r,o,n,"BigInt defaults cannot be represented in JSON Schema"),ro}var Kc=(e,t,r,o)=>{let n=e._zod.def;A(n.innerType,t,o);let s=t.seen.get(e);s.ref=n.innerType;let i=Hc(n.defaultValue,e,t,r,o);if(i!==ro)r.default=i},Gc=(e,t,r,o)=>{let n=e._zod.def;A(n.innerType,t,o);let s=t.seen.get(e);if(s.ref=n.innerType,t.io!=="input")return;let i=Hc(n.defaultValue,e,t,r,o);if(i!==ro)r._prefault=i},qc=(e,t,r,o)=>{let n=e._zod.def;A(n.innerType,t,o);let s=t.seen.get(e);s.ref=n.innerType;let i;try{i=n.catchValue(void 0)}catch{re(e,t,r,o,"Dynamic catch values are not supported in JSON Schema");return}r.default=i},Xc=(e,t,r,o)=>{let n=e._zod.def,s=n.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?s?n.out:n.in:n.out;A(i,t,o);let c=t.seen.get(e);c.ref=i},Yc=(e,t,r,o)=>{let n=e._zod.def;A(n.innerType,t,o);let s=t.seen.get(e);s.ref=n.innerType,r.readOnly=!0};var oo=(e,t,r,o)=>{let n=e._zod.def;A(n.innerType,t,o);let s=t.seen.get(e);s.ref=n.innerType};var Qc=new WeakSet([Object.prototype,Error.prototype]);function Ht(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let o=r(this);return Object.defineProperty(this,t,{value:o,configurable:!0,writable:!0}),o},set(o){Object.defineProperty(this,t,{value:o,configurable:!0,writable:!0})}})}var gl=(e,t)=>{yn.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);if(Qc.has(r))return;Qc.add(r),Ht(r,"format",(o)=>(n)=>vn(o,n)),Ht(r,"flatten",(o)=>(n)=>xn(o,n)),Ht(r,"addIssue",(o)=>(n)=>{o.issues.push(n),o.message=JSON.stringify(o.issues,qe,2)}),Ht(r,"addIssues",(o)=>(n)=>{o.issues.push(...n),o.message=JSON.stringify(o.issues,qe,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var V=h("ZodError",gl,void 0,{Parent:Error});var ea=Ot(V),ta=Rt(V),ra=Ct(V),oa=It(V),na=_n(V),sa=bn(V),ia=kn(V),ca=$n(V),aa=Sn(V),ua=zn(V),pa=Pn(V),la=En(V);function xl(){if(!J.localeError)te(jr())}function so(){if(!J.memoizer)te({memoizer:Zi()})}var O=h("ZodType",(e,t)=>(xl(),E.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(B(t,{checks:[...t.checks??[],...e.map((r)=>typeof r==="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return ne(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(lf(e,t))},superRefine(e,t){return this.check(ff(e,t))},overwrite(e){return this.check(ve(e))},optional(){return ha(this)},exactOptional(){return Xl(this)},nullable(){return ma(this)},nullish(){return ha(ma(this))},nonoptional(e){return of(this,e)},array(){return _(this)},or(e){return uo([this,e])},and(e){return Hl(this,e)},transform(e){return ga(this,ql(e))},default(e){return ef(this,e)},prefault(e){return rf(this,e)},catch(e){return sf(this,e)},pipe(e){return ga(this,e)},readonly(){return uf(this)},describe(e){let t=this.clone();return Se.add(t,{description:e}),t},meta(...e){if(e.length===0)return Se.get(this);let t=this.clone();return Se.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get "~standard"(){return Pt(this,"~standard",{...Or(this),jsonSchema:{input:it(this,"input"),output:it(this,"output")}})},set "~standard"(e){pe(this,"~standard",e)},parse:function e(t,r){return ea(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await ta(this,t,r,{callee:e})},safeParse(e,t){return ra(this,e,t)},async safeParseAsync(e,t){return oa(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){pe(this,"spa",e)},validate(e,t){return wr(this,e,t)},validateAsync(e,t){return _r(this,e,t)},encode:function e(t,r){return na(this,t,r,{callee:e})},decode:function e(t,r){return sa(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await ia(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await ca(this,t,r,{callee:e})},safeEncode(e,t){return aa(this,e,t)},safeDecode(e,t){return ua(this,e,t)},async safeEncodeAsync(e,t){return pa(this,e,t)},async safeDecodeAsync(e,t){return la(this,e,t)},toJSONSchema(e){return _c(this,{})(e)},get description(){return Se.get(this)?.description},get _def(){return this._zod.def}}),ya=h("_ZodString",(e,t)=>{Dt.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Oc(e,r,o,n)},Et({format:(e)=>j(e).format??null,minLength:(e)=>j(e).minimum??null,maxLength:(e)=>j(e).maximum??null},{regex(...e){return this.check(Lr(...e))},includes(...e){return this.check(Ur(...e))},startsWith(...e){return this.check(Br(...e))},endsWith(...e){return this.check(Jr(...e))},min(...e){return this.check(Ne(...e))},max(...e){return this.check(Jt(...e))},length(...e){return this.check(Vt(...e))},nonempty(...e){return this.check(Ne(1,...e))},lowercase(e){return this.check(Mr(e))},uppercase(e){return this.check(Wr(e))},trim(){return this.check(Hr())},normalize(...e){return this.check(Vr(...e))},toLowerCase(){return this.check(Kr())},toUpperCase(){return this.check(Gr())},slugify(){return this.check(qr())}})),io=h("ZodString",(e,t)=>{Dt.init(e,t),ya.init(e,t)},{email(e){return this.check(Ai(kl,e))},url(e){return this.check(Fr(xa,e))},jwt(e){return this.check(Qi(Ll,e))},emoji(e){return this.check(Fi(zl,e))},guid(e){return this.check(Ti($l,e))},uuid(e){return this.check(Dr(at,e))},uuidv4(e){return this.check(Ni(at,e))},uuidv6(e){return this.check(ji(at,e))},uuidv7(e){return this.check(Di(at,e))},nanoid(e){return this.check(Li(Pl,e))},cuid(e){return this.check(Mi(El,e))},cuid2(e){return this.check(Wi(Zl,e))},ulid(e){return this.check(Ui(Ol,e))},base64(e){return this.check(qi(jl,e))},base64url(e){return this.check(Xi(Dl,e))},xid(e){return this.check(Bi(Rl,e))},ksuid(e){return this.check(Ji(Cl,e))},ipv4(e){return this.check(Vi(Il,e))},ipv6(e){return this.check(Hi(Al,e))},cidrv4(e){return this.check(Ki(Tl,e))},cidrv6(e){return this.check(Gi(Nl,e))},e164(e){return this.check(Yi(Fl,e))},datetime(e){return this.check(ec(vl,e))},date(e){return this.check(tc(wl,e))},time(e){return this.check(rc(_l,e))},duration(e){return this.check(oc(bl,e))}});function w(e){return Ci(io,e)}var R=h("ZodStringFormat",(e,t)=>{Z.init(e,t),ya.init(e,t)}),vl=h("ZodISODateTime",(e,t)=>{Ms.init(e,t),R.init(e,t)}),wl=h("ZodISODate",(e,t)=>{Ws.init(e,t),R.init(e,t)}),_l=h("ZodISOTime",(e,t)=>{Us.init(e,t),R.init(e,t)}),bl=h("ZodISODuration",(e,t)=>{Bs.init(e,t),R.init(e,t)}),kl=h("ZodEmail",(e,t)=>{Os.init(e,t),R.init(e,t)});var $l=h("ZodGUID",(e,t)=>{Es.init(e,t),R.init(e,t)});var at=h("ZodUUID",(e,t)=>{Zs.init(e,t),R.init(e,t)});function co(e){return Dr(at,e)}var xa=h("ZodURL",(e,t)=>{Is.init(e,t),R.init(e,t)});function Sl(e){return Fr(xa,e)}var zl=h("ZodEmoji",(e,t)=>{As.init(e,t),R.init(e,t)});var Pl=h("ZodNanoID",(e,t)=>{Ts.init(e,t),R.init(e,t)});var El=h("ZodCUID",(e,t)=>{Ns.init(e,t),R.init(e,t)});var Zl=h("ZodCUID2",(e,t)=>{js.init(e,t),R.init(e,t)});var Ol=h("ZodULID",(e,t)=>{Ds.init(e,t),R.init(e,t)});var Rl=h("ZodXID",(e,t)=>{Fs.init(e,t),R.init(e,t)});var Cl=h("ZodKSUID",(e,t)=>{Ls.init(e,t),R.init(e,t)});var Il=h("ZodIPv4",(e,t)=>{Js.init(e,t),R.init(e,t)});var Al=h("ZodIPv6",(e,t)=>{Hs.init(e,t),R.init(e,t)});var Tl=h("ZodCIDRv4",(e,t)=>{Ks.init(e,t),R.init(e,t)});var Nl=h("ZodCIDRv6",(e,t)=>{Gs.init(e,t),R.init(e,t)});var jl=h("ZodBase64",(e,t)=>{Xs.init(e,t),R.init(e,t)});var Dl=h("ZodBase64URL",(e,t)=>{Ys.init(e,t),R.init(e,t)});var Fl=h("ZodE164",(e,t)=>{Qs.init(e,t),R.init(e,t)});var Ll=h("ZodJWT",(e,t)=>{ei.init(e,t),R.init(e,t)});var Kt=h("ZodNumber",(e,t)=>{Cr.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Rc(e,r,o,n),e.isFinite=!0},Et({minValue:(e)=>{let{minimum:t,exclusiveMinimum:r}=j(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:r}=j(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:r}=j(e);return!!t||!!r?.some(Number.isSafeInteger)},format:(e)=>j(e).format??null},{gt(e,t){return this.check(Te(e,t))},gte(e,t){return this.check(fe(e,t))},min(e,t){return this.check(fe(e,t))},lt(e,t){return this.check(Ae(e,t))},lte(e,t){return this.check(le(e,t))},max(e,t){return this.check(le(e,t))},int(e){return this.check(fa(e))},safe(e){return this.check(fa(e))},positive(e){return this.check(Te(0,e))},nonnegative(e){return this.check(fe(0,e))},negative(e){return this.check(Ae(0,e))},nonpositive(e){return this.check(le(0,e))},multipleOf(e,t){return this.check(nt(e,t))},step(e,t){return this.check(nt(e,t))},finite(){return this}}));function va(e){return nc(Kt,e)}var Ml=h("ZodNumberFormat",(e,t)=>{ti.init(e,t),Kt.init(e,t)});function fa(e){return ic(Ml,e)}var ao=h("ZodBoolean",(e,t)=>{ri.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Cc(e,r,o,n)});function Fe(e){return cc(ao,e)}var wa=h("ZodBigInt",(e,t)=>{oi.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ic(e,r,o,n)},Et({minValue:(e)=>j(e).minimum??null,maxValue:(e)=>j(e).maximum??null,format:(e)=>j(e).format??null},{gte(e,t){return this.check(fe(e,t))},min(e,t){return this.check(fe(e,t))},gt(e,t){return this.check(Te(e,t))},lt(e,t){return this.check(Ae(e,t))},lte(e,t){return this.check(le(e,t))},max(e,t){return this.check(le(e,t))},positive(e){return this.check(Te(BigInt(0),e))},negative(e){return this.check(Ae(BigInt(0),e))},nonpositive(e){return this.check(le(BigInt(0),e))},nonnegative(e){return this.check(fe(BigInt(0),e))},multipleOf(e,t){return this.check(nt(e,t))}}));var Wl=h("ZodUnknown",(e,t)=>{ni.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Tc(e,r,o,n)});function da(){return pc(Wl)}var Ul=h("ZodNever",(e,t)=>{si.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ac(e,r,o,n)});function _a(e){return lc(Ul,e)}var ba=h("ZodDate",(e,t)=>{ii.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Nc(e,r,o,n),e.min=(r,o)=>e.check(fe(r,o)),e.max=(r,o)=>e.check(le(r,o))},Et({minDate:(e)=>{let{minimum:t}=j(e);return t?new Date(t):null},maxDate:(e)=>{let{maximum:t}=j(e);return t?new Date(t):null}},{}));var Bl=h("ZodArray",(e,t)=>{so(),ci.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Mc(e,r,o,n),e.element=t.element},{min(e,t){return this.check(Ne(e,t))},nonempty(e){return this.check(Ne(1,e))},max(e,t){return this.check(Jt(e,t))},length(e,t){return this.check(Vt(e,t))},unwrap(){return this.element}});function _(e,t){return dc(Bl,e,t)}var ka=h("ZodObject",(e,t)=>{so(),pi.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Wc(e,r,o,n),bp(e,"shape",(r)=>r._zod.def.shape,!1)},{keyof(){return X(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(B(this._zod.def,{catchall:e}))},passthrough(){return this.clone(B(this._zod.def,{catchall:da()}))},loose(){return this.clone(B(this._zod.def,{catchall:da()}))},strict(){return this.clone(B(this._zod.def,{catchall:_a()}))},strip(){return this.clone(B(this._zod.def,{catchall:void 0}))},extend(e){return hp(this,e)},safeExtend(e){return mp(this,e)},merge(e){return gp(this,e)},pick(e){return fp(this,e)},omit(e){return dp(this,e)},partial(...e){return an(Sa,this,e[0])},exactPartial(...e){return an(za,this,e[0],"exactPartial")},required(...e){return yp(Pa,this,e[0])}});function ut(e,t){let r={type:"object",shape:e??{},...x(t)};return new ka(r)}function P(e,t){return new ka({type:"object",shape:e,catchall:_a(),...x(t)})}var $a=h("ZodUnion",(e,t)=>{Ir.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Uc(e,r,o,n),e.options=t.options});function uo(e,t){return new $a({type:"union",options:e,...x(t)})}var Jl=h("ZodDiscriminatedUnion",(e,t)=>{$a.init(e,t),li.init(e,t)});function po(e,t,r){return new Jl({type:"union",options:t,discriminator:e,...x(r)})}var Vl=h("ZodIntersection",(e,t)=>{fi.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Bc(e,r,o,n)});function Hl(e,t){return new Vl({type:"intersection",left:e,right:t})}var no=h("ZodEnum",(e,t)=>{di.init(e,t),O.init(e,t),e._zod.processJSONSchema=(o,n,s)=>jc(e,o,n,s),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(o,n)=>{let s={};for(let i of o)if(r.has(i))s[i]=t.entries[i];else throw Error(`Key ${i} not found in enum`);return new no({...t,checks:[],...x(n),entries:s})},e.exclude=(o,n)=>{let s={...t.entries};for(let i of o)if(r.has(i))delete s[i];else throw Error(`Key ${i} not found in enum`);return new no({...t,checks:[],...x(n),entries:s})}});function X(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map((o)=>[o,o])):e;return new no({type:"enum",entries:r,...x(t)})}var Kl=h("ZodLiteral",(e,t)=>{hi.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Dc(e,r,o,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function H(e,t){return new Kl({type:"literal",values:Array.isArray(e)?e:[e],...x(t)})}var Gl=h("ZodTransform",(e,t)=>{so(),mi.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Lc(e,r,o,n),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new Qe(e.constructor.name);r.addIssue=(s)=>{if(typeof s==="string")r.issues.push($e(s,r.value,t));else{let i=s;if(i.fatal)i.continue=!1;if(i.code??(i.code="custom"),!("input"in i))i.input=r.value;i.inst??(i.inst=e),r.issues.push($e(i))}};let n=t.transform(r.value,r);if(n instanceof Promise)return n.then((s)=>(r.value=s,r));return r.value=n,r}});function ql(e){return new Gl({type:"transform",transform:e})}var Sa=h("ZodOptional",(e,t)=>{Ar.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>oo(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function ha(e){return new Sa({type:"optional",innerType:e})}var za=h("ZodExactOptional",(e,t)=>{gi.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>oo(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Xl(e){return new za({type:"optional",innerType:e})}var Yl=h("ZodNullable",(e,t)=>{yi.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Jc(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function ma(e){return new Yl({type:"nullable",innerType:e})}var Ql=h("ZodDefault",(e,t)=>{xi.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Kc(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ef(e,t){return new Ql({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():dr(t)}})}var tf=h("ZodPrefault",(e,t)=>{vi.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Gc(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function rf(e,t){return new tf({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():dr(t)}})}var Pa=h("ZodNonOptional",(e,t)=>{wi.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Vc(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function of(e,t){return new Pa({type:"nonoptional",innerType:e,...x(t)})}var nf=h("ZodCatch",(e,t)=>{_i.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>qc(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function sf(e,t){return new nf({type:"catch",innerType:e,catchValue:typeof t==="function"?t:fn(t)})}var cf=h("ZodPipe",(e,t)=>{bi.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Xc(e,r,o,n),e.in=t.in,e.out=t.out});function ga(e,t){return new cf({type:"pipe",in:e,out:t})}var af=h("ZodReadonly",(e,t)=>{ki.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Yc(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function uf(e){return new af({type:"readonly",innerType:e})}var pf=h("ZodCustom",(e,t)=>{$i.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Fc(e,r,o,n)});function lf(e,t={}){return hc(pf,e,t)}function ff(e,t){return mc(e,t)}var lo={};Go(lo,{bigint:()=>yf,boolean:()=>gf,date:()=>xf,number:()=>mf,string:()=>hf});function hf(e){return Ii(io,e)}function mf(e){return sc(Kt,e)}function gf(e){return ac(ao,e)}function yf(e){return uc(wa,e)}function xf(e){return fc(ba,e)}var fo=X(["codex","claude","opencode"]),vf=w().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/),wf="Initialize an AppToolkit workspace, register an existing checkout, or find the approved project workflow.",_f={codex:".agents/skills/apptoolkit/SKILL.md",claude:".claude/skills/apptoolkit/SKILL.md",opencode:".opencode/commands/apptoolkit.md"},Ea=["For requests involving this workspace, read `llm/HARNESS.md` and use its workflow index to open the relevant procedure. Follow the established rules for the project and target repository.","","For a request like “Dame mi lista de pendientes”, open W01. For a new feature, use W16 to establish requirements before W18 implementation."].join(`
|
|
59
|
-
`);function ho(e){let t=new Set(
|
|
60
|
-
`)}function mo(e,t){let r=
|
|
61
|
-
`,{mode:384,flag:"wx"})}catch(o){try{La(t,{recursive:!0})}catch(n){throw AggregateError([o,n],`Cannot record or remove the installation lock at ${t}.`)}throw Error(`Cannot record the installation lock owner at ${r}.`,{cause:o})}return t}function Bf(e){let t=new Map;for(let r of e){let n=t.get(r.git.root)??
|
|
62
|
-
${s.scope.toLowerCase()}`;if(r.has(i))t.addIssue({code:"custom",path:["routes",n],message:"Choose one authority for this category and scope."});r.add(i)}let o=new Set;for(let[n,s]of e.services.entries()){if(o.has(s.provider))t.addIssue({code:"custom",path:["services",n],message:"Configure each built-in service once per project."});o.add(s.provider)}}),
|
|
63
|
-
`}function ld(e,t){let r=cd(e),o=Je(r,`.project.${td()}.json`);try{id(o,$o(t),{flag:"wx",mode:384}),nd(o,e)}catch(n){try{sd(o,{force:!0})}catch(s){throw AggregateError([n,s],`Write project settings and clean the draft at ${e}.`)}throw Error(`Write project settings at ${e}.`,{cause:n})}}async function Eo(e){let{root:t}=ft(e.root),r=tu(t,Qa(e.configPath));if(!r)throw Error("Provide the approved project settings JSON file.");return Ba(t,()=>{let{receipt:o}=ft(t),n=new Set([".",...o.repositories.map((u)=>u.path)]);for(let u of r.projects){if(!n.has(u.path))throw Error(`Register ${u.path} before initializing its settings.`);for(let p of u.services){if(!o.services.includes(p.provider))throw Error(`Select ${p.provider} during workspace installation before connecting it.`);if(p.snapshots==="versioned"&&!o.workspaceVersioned)throw Error("Versioned service snapshots require a versioned workspace harness.")}}let s=Je(t,So);if(!o.workspaceVersioned){let u=M(t);if(u)Qt({git:u,path:ad(u.root,s)},!1)}let i=Ee(t),c=new Map(i?.projects.map((u)=>[u.path,u]));for(let u of r.projects)c.set(u.path,u);let a=Pe.parse({schema:1,projects:[...c.values()]});if(i&&$o(i)===$o(a))return{path:s,changed:!1,projects:a.projects.length};return ld(s,a),{path:s,changed:!0,projects:a.projects.length}})}var fd=P({root:w().min(1),project:Ue,service:Be,verifyHealth:Fe().optional(),verifyRead:Fe()}),dd=ut({results:_(ut({id:co()})).max(1)}),hd=ut({name:w().min(1)}),md=131072;class _e extends Error{}function Oo(e){let{root:t,receipt:r}=ft(e.root);if(!r.services.includes(e.service))throw Error(`${e.service} is not selected in the installed workspace.`);if(e.project!=="."&&!r.repositories.some((s)=>s.path===e.project))throw Error(`Register ${e.project} before using its service connections.`);let n=Ee(t)?.projects.find((s)=>s.path===e.project)?.services.find((s)=>s.provider===e.service);if(!n)throw Error(`Initialize the ${e.service} connection for ${e.project} first.`);return{root:t,receipt:r,connection:n}}function Zo(e,t){let r=new URL(e);if(!r.pathname.endsWith("/"))r.pathname+="/";return new URL(t,r)}function gd(e){if(e.provider==="plane"){let r=`api/v1/workspaces/${e.workspace}/projects/${e.projectId}/work-items/`,o=Zo(e.baseUrl,r);return o.searchParams.set("per_page","1"),o.searchParams.set("fields","id"),o}let t=Zo(e.baseUrl,"api/rpc/command/get-file-summary");return t.searchParams.set("id",e.fileId),t}function yd(e,t){let r=new Headers({Accept:"application/json"});if(e.provider==="penpot")r.set("Authorization",`Token ${t}`);else if(e.auth==="oauth")r.set("Authorization",`Bearer ${t}`);else r.set("X-API-Key",t);return r}async function xd(e){if(!e.headers.get("content-type")?.toLowerCase().startsWith("application/json"))throw await e.body?.cancel(),new _e("Expected an application/json response from the service.");let r=e.body?.getReader();if(!r)throw new _e("The service response has no body.");let o=[],n=0;try{for(;;){let s=await r.read();if(s.done)return Buffer.concat(o,n).toString("utf8");if(n+=s.value.byteLength,n>md)throw await r.cancel(),new _e("The service response exceeded the 128 KiB verification limit.");o.push(s.value)}}finally{r.releaseLock()}}async function vd(e,t){let r=await t(Zo(e.baseUrl,"./"),{method:"HEAD",redirect:"manual",signal:AbortSignal.timeout(1e4)});return await r.body?.cancel(),r.status}async function wd(e,t,r){let o=await r(gd(e),{method:"GET",headers:yd(e,t),redirect:"error",signal:AbortSignal.timeout(1e4)});if(!o.ok)throw await o.body?.cancel(),new _e(`The selected resource returned HTTP ${o.status}. Confirm the target and its read permission.`);let n=await xd(o),s=e.provider==="plane"?dd:hd,i=!1;try{i=s.safeParse(JSON.parse(n)).success}catch(c){throw new _e("The service returned invalid JSON.",{cause:c})}if(!i)throw new _e("The response does not match the expected resource read.");return o.status}async function Ro(e,t={}){let r=fd.parse(e),{connection:o}=Oo(r),s=(t.environment??process.env)[o.tokenEnv],i=typeof s==="string"&&/^[\x21-\x7e]+$/.test(s),c={provider:o.provider,project:r.project,baseUrl:o.baseUrl,credentialEnv:o.tokenEnv,credentialAvailable:i,snapshots:o.snapshots,connectivity:"unchecked",read:"unchecked"},a=t.fetch??fetch;if(r.verifyRead){if(!i)throw Error(`Provide ${o.tokenEnv} in the process environment before verifying access.`);try{let u=await wd(o,s,a);return{...c,connectivity:"reachable",read:"verified",httpStatus:u}}catch(u){let p=u instanceof _e?u.message:"Check the configured host and retry.";throw Error(`Verify ${o.provider} read for ${r.project}. ${p}`,{cause:u})}}if(r.verifyHealth)try{let u=await vd(o,a);return{...c,connectivity:u>=500?"service-error":"reachable",httpStatus:u}}catch(u){throw Error(`Check ${o.provider} connectivity for ${r.project}.`,{cause:u})}return c}import{createHash as _d}from"node:crypto";import{constants as ru,createReadStream as bd,openSync as kd}from"node:fs";import{join as $d,relative as ou,resolve as Sd}from"node:path";var nu=We.refine((e)=>e.startsWith("harness-snapshots/"),{message:"Keep native service exports in the workspace harness-snapshots directory."}),zd=w().regex(/^[a-f0-9]{64}$/),Pd=P({path:nu,bytes:va().int().positive(),sha256:zd}),Ed=P({root:w().min(1),project:Ue,service:Be}),su=P({schema:H(1),project:Ue,service:Be,files:_(Pd).min(1).max(30)}).refine((e)=>new Set(e.files.map((t)=>t.path)).size===e.files.length,"Duplicate snapshot paths.");function iu(e,t){let r=Sd(e,t),o=nu.parse(ou(e,r)),n=e,s=o.split("/");for(let[i,c]of s.entries()){n=$d(n,c);let a=me(n);if(!(i===s.length-1?a?.isFile():a?.isDirectory()))throw Error(`Expected a regular nonsymlink snapshot path at ${n}.`)}return r}async function cu(e,t){let r=iu(e,t),o=me(r);if(!o?.isFile()||o.size===0)throw Error(`Expected a nonempty snapshot file at ${r}.`);let n=_d("sha256");try{let i=kd(r,ru.O_RDONLY|ru.O_NOFOLLOW),c=bd(r,{fd:i});for await(let a of c)n.update(a)}catch(i){throw Error(`Read snapshot bytes at ${r}.`,{cause:i})}let s=me(r);if(!s||o.dev!==s.dev||o.ino!==s.ino||o.mtimeMs!==s.mtimeMs||o.size!==s.size)throw Error(`Snapshot changed while reading ${r}. Retry with a stable export.`);return{path:ou(e,r),bytes:o.size,sha256:n.digest("hex")}}function au(e){let{root:t,receipt:r,connection:o}=Oo(Ed.parse(e));if(!r.workspaceVersioned||o.snapshots!=="versioned")throw Error("Enable versioned snapshots for this project and provider before working with a snapshot.");return t}async function Co(e){let t=au({root:e.root,project:e.project,service:e.service}),r=_(w().min(1)).min(1).max(30).parse(e.paths),o=[];for(let n of r)o.push(await cu(t,n));return su.parse({schema:1,project:e.project,service:e.service,files:o})}async function Io(e){let t=au({root:e.root,project:e.project,service:e.service}),r=iu(t,e.manifestPath),o=su.parse(zo(r));if(o.project!==e.project||o.service!==e.service)throw Error("The snapshot manifest belongs to a different project or service.");for(let n of o.files){let s=await cu(t,n.path);if(s.bytes!==n.bytes||s.sha256!==n.sha256)throw Error(`Snapshot integrity check failed for ${n.path}.`)}return{manifestPath:r,project:o.project,service:o.service,files:o.files.length}}import{closeSync as uu,constants as Ao,fstatSync as pu,lstatSync as lu,openSync as Zd,readSync as Od,realpathSync as Rd}from"node:fs";import{isAbsolute as du,join as Cd}from"node:path";var Id=262144,Ad=new Set([".aws",".git",".gnupg",".npm",".ssh","credentials","node_modules","passwords","private","processing","raw","secret","secrets"]);function hu(e){let t=e.toLowerCase(),r=t.replace(/(?:\.llm)?\.md$/,"");return t.startsWith(".env")||Ad.has(r)}function Td(e){if(du(e)||/[\\:\x00-\x1f\x7f]/.test(e))throw Error("Provide a relative path inside the project root.");let t=e.split("/");for(let r of t){if(r===""||r==="."||r==="..")throw Error("Paths must use explicit project-relative segments.");if(hu(r))throw Error(`The path crosses a protected location at "${r}".`)}return t}function fu(e,t){if(!du(e))throw Error("Provide an absolute project root.");if(!lu(e).isDirectory())throw Error("The project root must be a directory.");let r=Rd(e);if(r.split("/").filter(Boolean).some((s,i)=>(i!==0||s!=="private")&&hu(s)))throw Error("The project root crosses a protected location.");let n;for(let[s,i]of t.entries()){if(r=Cd(r,i),n=lu(r),n.isSymbolicLink())throw Error(`Symbolic links are not allowed in the project path at "${i}".`);if(s<t.length-1&&!n.isDirectory())throw Error(`Expected a directory at "${i}".`)}if(!n?.isFile())throw Error("The project path must resolve to a regular file.");return{path:r,info:n}}function Nd(e,t,r,o){let n=pu(e);if(!n.isFile()||n.ino!==t.ino||n.dev!==t.dev)throw Error("The file changed while opening. Retry after checking its path.");if(n.size>r)throw Error(`${o} source exceeds ${r} bytes. Use a narrower input.`);let s=Buffer.alloc(n.size+1),i=0;while(i<s.length){let a=Od(e,s,i,s.length-i,i);if(a===0)break;i+=a}if(i>r)throw Error(`${o} source exceeds ${r} bytes. Use a narrower input.`);let c=pu(e);if(c.size!==i||n.size!==c.size||n.mtimeMs!==c.mtimeMs||n.ctimeMs!==c.ctimeMs)throw Error("The source changed during the read. Retry with a stable file.");return s.subarray(0,i)}function jd(e,t,r,o){let n;try{n=Nd(e,t,r,o)}catch(s){try{uu(e)}catch(i){throw AggregateError([s,i],"Reading and closing the file both failed.")}throw s}return uu(e),n}function tr(e,t,r,o){try{let n=Td(t),{path:s,info:i}=fu(e,n),c=Zd(s,Ao.O_RDONLY|Ao.O_NOFOLLOW|Ao.O_NONBLOCK),a=jd(c,i,r,o),u=fu(e,n);if(u.path!==s||u.info.ino!==i.ino||u.info.dev!==i.dev)throw Error("The file path changed during the read. Retry after verifying the current path.");return new TextDecoder("utf-8",{fatal:!0}).decode(a)}catch(n){let s=n instanceof Error?n.message:String(n);throw Error(`Unable to read ${o} "${t}". ${s}`,{cause:n})}}function dt(e,t){if(!t.toLowerCase().endsWith(".md"))throw Error("Provide a relative Markdown path inside the project root.");return tr(e,t,Id,"Markdown context")}function mu(e){return e.match(/[^\n]*\n|[^\n]+$/g)??[]}function gu(e,t,r){let o=e.toLowerCase().replace(/[^\p{L}\p{M}\p{N}_\s-]/gu,"").trim().replace(/\s+/g,"-");return{title:e,level:t,line:r,locator:`line:${r}`,anchor:`#${o}`}}function Dd(e){let t=/^ {0,3}(`{3,}|~{3,})/.exec(e)?.[1];if(t)return{marker:t.charAt(0),length:t.length};return}function Fd(e,t){let r=/^ {0,3}(`{3,}|~{3,})[ \t]*$/.exec(e)?.[1];return r!==void 0&&r.startsWith(t.marker)&&r.length>=t.length}function Ld(e,t){let r=/^ {0,3}(#{1,6})[ \t]+(.*)$/.exec(e),o=r?.[1],n=r?.[2];if(o&&n){let s=n.replace(/(?:^|[ \t]+)#+[ \t]*$/,"").trim();if(s)return gu(s,o.length,t)}return}function Md(e){if(!e.trim()||/^(?: {4}|\t)/.test(e))return!1;return!/^ {0,3}(?:[>#<]|[-+*][ \t]|\d+[.)][ \t]|\[[^\]]+\]:|(?:[*_-][ \t]*){3,})/.test(e)}function yu(e){let t=[],r,o,n=!1,s=-1;if(e[0]?.trim()==="---")s=e.findIndex((i,c)=>c>0&&/^(---|\.\.\.)$/.test(i.trim()));for(let[i,c]of e.entries()){if(i<=s)continue;let a=c.replace(/\r?\n$/,""),u=i+1;if(r){if(Fd(a,r))r=void 0;continue}if(n||a.trimStart().startsWith("<!--")){n=!a.includes("-->"),o=void 0;continue}if(r=Dd(a),r){o=void 0;continue}let p=Ld(a,u);if(p){t.push(p),o=void 0;continue}let l=/^ {0,3}(=+|-+)[ \t]*$/.exec(a)?.[1];if(l&&o){let f=o.lines.join(" "),d=l.startsWith("=")?1:2;t.push(gu(f,d,o.line)),o=void 0;continue}if(!Md(a)){o=void 0;continue}if(!o)o={line:u,lines:[]};o.lines.push(a.trim())}return t}var To=w().min(1).refine((e)=>!/[\x00-\x1f\x7f]/.test(e),"Control characters are not allowed."),Wd=P({root:To.max(4096),file:To.max(4096),section:To.max(512).optional()}),xu=128,vu=16384;function Ud(e,t){let r=e.filter((n)=>{if(/^line:[1-9][0-9]*$/.test(t))return n.locator===t;if(t.startsWith("#"))return n.anchor===t;return n.title===t}),[o]=r;if(!o)throw Error(`No heading matches "${t}". List the heading index and use an exact locator.`);if(r.length>1){let n=r.slice(0,8).map((i)=>i.locator),s=r.length>n.length?", or another locator from the index":"";throw Error(`Heading "${t}" is ambiguous. Use one of ${n.join(", ")}${s}.`)}return o}function wu(e,t){if(Buffer.byteLength(e)>vu)throw Error(`Context output exceeds ${vu} bytes. ${t}`)}function _u(e){let t=Wd.parse(e),r=mu(dt(t.root,t.file)),o=yu(r);if(t.section===void 0){if(o.length>xu)throw Error(`Heading index exceeds ${xu} entries. Request a known section or use a narrower map.`);let u={kind:"index",file:t.file,headings:o};return wu(JSON.stringify(u),"Request a known section or use a narrower map."),u}let n=Ud(o,t.section),s=o.find((u)=>u.line>n.line&&u.level<=n.level),i=s?s.line-1:r.length,c=r.slice(n.line-1,i).join(""),a={kind:"section",file:t.file,heading:n,startLine:n.line,endLine:i,text:c};return wu(JSON.stringify(a),"Choose a smaller child section or a narrower map."),a}import{realpathSync as Xd}from"node:fs";import{isAbsolute as Do,normalize as Yd,relative as Qd,resolve as eh}from"node:path";var ku=X(["lines","functions","branches"]),Bd=X(["LF","LH","FNF","FNH","BRF","BRH"]),Jd={lines:{found:"LF",hit:"LH"},functions:{found:"FNF",hit:"FNH"},branches:{found:"BRF",hit:"BRH"}};function $u(e){return{source:e,summaries:new Map,lines:new Map,branches:new Map,functionNames:new Set,functionHits:new Map,groupIds:new Set,aliasHits:new Map,versionSeen:!1}}function N(e,t){let r=Number(e);if(!/^\d+$/.test(e)||!Number.isSafeInteger(r)||r<t)throw Error("Expected an integer within the supported range.");return r}function ht(e,t,r){if(e.has(t))throw Error("Duplicate coverage entry.");e.set(t,r)}function bu(e,t){if(e.has(t))throw Error("Duplicate coverage identity.");e.add(t)}function Vd(e,t){let[r,o,,n,s]=t.split(",");if(!r||!o||s!==void 0)throw Error("Expected a line number and execution count.");let i=N(r,1);if(n!==void 0)N(n,i);ht(e.lines,String(i),N(o,0)>0)}function Hd(e,t){let r=/^([^,]+),([ef]?u?\d+(?:\^\d+)?),(.+),([^,]+)$/.exec(t),o=r?.[1],n=r?.[2],s=r?.[3],i=r?.[4];if(!o||!n||!s||!i)throw Error("Expected a branch line, block, identity and hit count.");let[,c,a]=/^[ef]?u?(\d+)(?:\^(\d+))?$/.exec(n)??[];if(!c)throw Error("Expected a numeric branch block.");let u=JSON.stringify([N(o,1),N(c,0),a===void 0?null:N(a,0),/^\d+$/.test(s)?N(s,0):s]);ht(e.branches,u,i!=="-"&&N(i,0)>0)}function Kd(e,t,r){let o=t==="FN"?/^(\d+),(?:(\d+),)?(.+)$/:/^(\d+),(\d+)(?:,(\d+))?$/,[,n,s,i]=o.exec(r)??[];if(n===void 0)throw Error("Malformed function definition.");if(t==="FN"&&i){let c=N(n,1);if(s)N(s,c);bu(e.functionNames,i);return}if(t==="FNL"&&s){let c=N(s,1);if(i)N(i,c);bu(e.groupIds,String(N(n,0)));return}throw Error("Malformed function definition.")}function Gd(e,t,r){if(t==="FNDA"){let[,a,u]=/^(\d+),(.+)$/.exec(r)??[];if(!a||!u)throw Error("Expected a function hit count and name.");ht(e.functionHits,u,N(a,0)>0);return}let[,o,n,s]=/^(\d+),(\d+),(.+)$/.exec(r)??[];if(!o||!n||!s)throw Error("Expected an alias group, hit count and name.");let i=String(N(o,0)),c=e.aliasHits.get(i)??new Map;ht(c,s,N(n,0)>0),e.aliasHits.set(i,c)}function Su(e,t,r){let o=Bd.safeParse(t);if(o.success){ht(e.summaries,o.data,N(r,0));return}switch(t){case"VER":if(e.versionSeen||!r)throw Error("Expected one source version per record.");e.versionSeen=!0;return;case"DA":return Vd(e,r);case"BRDA":return Hd(e,r);case"FN":case"FNL":return Kd(e,t,r);case"FNDA":case"FNA":return Gd(e,t,r);default:throw Error("Unsupported LCOV field. Export a line, function and branch report.")}}function No(e){let t=0;for(let r of e.values())if(r)t+=1;return{found:e.size,hit:t}}function qd(e){let t=e.functionNames.size>0||e.functionHits.size>0,r=e.groupIds.size>0||e.aliasHits.size>0;if(t&&r)throw Error("Function records mix classic names and alias groups.");if(r){let o=0;if(e.groupIds.size!==e.aliasHits.size)throw Error("Missing function group or alias records.");for(let n of e.groupIds){let s=e.aliasHits.get(n);if(!s?.size)throw Error("Function group is missing execution records.");if(Array.from(s.values()).some(Boolean))o+=1}return{found:e.groupIds.size,hit:o}}if(e.functionNames.size!==e.functionHits.size)throw Error("Missing function names or execution records.");for(let o of e.functionNames)if(!e.functionHits.has(o))throw Error("A function definition has no matching execution record.");return No(e.functionHits)}function zu(e,t){let r=Jd[t],o=e.summaries.get(r.found),n=e.summaries.get(r.hit);if(o===void 0||n===void 0)throw Error(`Missing ${r.found} or ${r.hit} summary.`);let s;switch(t){case"lines":s=No(e.lines);break;case"functions":s=qd(e);break;case"branches":s=No(e.branches);break}if(s.found!==o||s.hit!==n)throw Error(`Summary ${n}/${o} differs from measured entries ${s.hit}/${s.found}.`);if(n!==o)throw Error(`Only ${n}/${o} were covered. The requirement is 100 percent.`);return s}var rr=w().min(1).max(4096).refine((e)=>!/[\x00-\x1f\x7f]/.test(e)),th=P({root:rr,file:rr,config:rr}),rh=P({files:_(rr).min(1).max(1e4),metrics:_(ku).min(1).max(3)});function jo(e){if(Do(e)||/[\\:\x00-\x1f\x7f]/.test(e)||e.split("/").some((t)=>!t||t==="."||t===".."))throw Error(`Use a project-relative source path in the coverage configuration. Received "${e}".`);return e}function Pu(e,t){let r=Qd(e,t);if(!r||r===".."||r.startsWith("../")||Do(r))return;return r}function oh(e,t,r){if(!e||/[\\:\x00-\x1f\x7f]/.test(e))throw Error("Expected a valid source path in the LCOV record.");if(Do(e)){let o=Pu(t,e)??Pu(r,e);if(o)return jo(o);throw Error("An LCOV source is outside the project root.")}return jo(Yd(e))}function nh(e,t){for(let[r,o]of t)try{let n=zu(e,r);o.found+=n.found,o.hit+=n.hit}catch(n){let s=n instanceof Error?n.message:String(n);throw Error(`${e.source} ${r}. ${s}`,{cause:n})}}function sh(e,t,r,o){let n=Xd(t),s=new Set,i=new Set,c,a=!1;for(let[p,l]of e.split(/\r?\n/).entries()){if(!l.trim()||l.startsWith("#"))continue;try{if(/[\x00-\x08\x0b-\x1f\x7f]/.test(l))throw Error("Control characters are not allowed in coverage records.");if(l.startsWith("TN:")&&!c&&!a)a=!0;else if((l.startsWith("SF:")||l.startsWith("KF:"))&&!c){let f=l.slice(3),[,d,m]=/^(\d+),(.*)$/.exec(f)??[],g=oh(m??f,t,n);if(d!==void 0){let y=Number(d);if(!Number.isSafeInteger(y)||i.has(y))throw Error("Expected a distinct safe integer source index.");i.add(y)}if(s.has(g))throw Error(`Duplicate LCOV source "${g}".`);if(!r.has(g))throw Error(`Unexpected LCOV source "${g}".`);c=$u(g),a=!1}else if(l==="end_of_record"&&c)nh(c,o),s.add(c.source),c=void 0;else if(c){let f=l.indexOf(":");if(f<1)throw Error("Malformed LCOV field.");Su(c,l.slice(0,f),l.slice(f+1))}else throw Error("Expected an LCOV source record.")}catch(f){let d=f instanceof Error?f.message:String(f);throw Error(`LCOV line ${p+1}. ${d}`,{cause:f})}}if(c||a)throw Error("The final LCOV record is incomplete.");let u=Array.from(r).filter((p)=>!s.has(p));if(u.length)throw Error(`LCOV is missing ${u.length} expected source files. First missing path is "${u[0]}".`)}function Eu(e){let t=th.parse(e),r=tr(t.root,t.config,262144,"coverage configuration"),o;try{o=rh.parse(JSON.parse(r))}catch(a){throw Error(`Invalid coverage configuration "${t.config}". Provide JSON arrays for files and metrics.`,{cause:a})}let n=new Set(o.files.map(jo)),s=new Map;for(let a of o.metrics)s.set(a,{found:0,hit:0});if(n.size!==o.files.length||s.size!==o.metrics.length)throw Error("Coverage configuration contains duplicate files or metrics.");let i=tr(t.root,t.file,16777216,"LCOV report");sh(i,eh(t.root),n,s);let c=Array.from(s,([a,u])=>{if(u.found===0)throw Error(`No measurable ${a} were found for the selected scope.`);return{metric:a,...u,percent:100}});return{file:t.file,config:t.config,sources:n.size,metrics:c}}import{lstatSync as Vu}from"node:fs";import{relative as Ju,resolve as be}from"node:path";import{lstatSync as ih,readdirSync as Ou}from"node:fs";import{basename as Zu,resolve as mt}from"node:path";var ch=ut({name:w().optional(),workspaces:uo([_(w()),ut({packages:_(w())})]).optional()}),ah=new Set(["package.json","pnpm-workspace.yaml","Cargo.toml","go.mod","pyproject.toml","Gemfile","pom.xml","composer.json"]),Ru=new Set([".git",".DS_Store",".agents",".claude",".opencode","llm","node_modules","dist","vendor"]);function uh(e){let t=C(e,"package.json");if(!t)return;try{return ch.parse(JSON.parse(t.bytes.toString("utf8")))}catch(r){throw Error(`Cannot read ${mt(e,"package.json")}. Correct the manifest and retry.`,{cause:r})}}function Ve(e,t){if(t===".")return e;oe(t);let r=de(mt(e,t));if(!go(e,r)||r!==mt(e,t))throw Error(`Choose a real directory inside ${e}. The repository path resolves through a symbolic link: ${t}.`);if(M(r)?.root!==r)throw Error(`Choose the Git repository root at ${r} before registering it.`);return r}function ph(e){let t=Ou(e,{withFileTypes:!0});if(t.length>2048)throw Error(`Workspace discovery is limited to 2048 entries at ${e}. Choose a narrower directory.`);let r=[];for(let o of t.sort((n,s)=>n.name.localeCompare(s.name,"en"))){if(!o.isDirectory()||o.name.startsWith(".")||Ru.has(o.name))continue;let n=mt(e,o.name);if(!ih(mt(n,".git"),{throwIfNoEntry:!1}))continue;if(M(n)?.root!==n)throw Error(`The Git metadata in ${n} does not identify that checkout as a repository root.`);oe(o.name),r.push({path:o.name,name:o.name,gitRoot:n})}return r}function Ze(e){let t=de(e),r=M(t),o=ph(t),n=new Set(Ou(t)),s=uh(t),i=Boolean(s?.workspaces||n.has("pnpm-workspace.yaml")||n.has("lerna.json")),c=[...ah].some((l)=>n.has(l)),a=r?{gitRoot:r.root}:{};if(o.length&&!i){let l=[...o];if(c)l.unshift({path:".",name:s?.name??Zu(t),...a});return{root:t,kind:"workspace",monorepo:i,repositories:l,...a}}let u=[...n].every((l)=>Ru.has(l)),p={path:".",name:s?.name??Zu(t),...a};return{root:t,kind:u?"blank":"existing",monorepo:i,repositories:[p],...a}}import{lstatSync as Au}from"node:fs";import{resolve as gt}from"node:path";function lh(e,t,r,o=!1){let n=`# appToolkit harness ${t} begin`,s=`# appToolkit harness ${t} end`,i=e.includes(`\r
|
|
58
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of e.seen.entries()){let c=i[1];if(t===i[0]){s(i);continue}if(e.external){let u=e.external.registry.get(i[0])?.id;if(t!==i[0]&&u){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(c.cycle){s(i);continue}if(c.count>1){if(e.reused==="ref")s(i)}}if(e.external)e.sharedDefsExtractedFor=e.external}function vc(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let o of t){if(!o||typeof o!=="object")return;vc(o);let n=Object.keys(o);if(n.length!==1||n[0]!=="type")return;let s=o.type;for(let i of Array.isArray(s)?s:[s]){if(typeof i!=="string")return;if(!r.includes(i))r.push(i)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var wc=new Set(["type","properties","required","additionalProperties"]),yc=["oneOf","anyOf"];function xc(e){let t=e.additionalProperties;if(t===void 0||t===!1||typeof t!=="object"||t===null)return null;return Object.keys(t).length?t:null}function Xr(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let i in s)if(!wc.has(i))return null;t.push(s)}let r={},o=new Set;for(let s of t){for(let i in s.properties){if(Object.prototype.hasOwnProperty.call(r,i))continue;let c=[];for(let u of t){let p=u.properties?.[i]??xc(u);if(p===null||p===void 0)continue;if(!c.some((l)=>JSON.stringify(l)===JSON.stringify(p)))c.push(p)}let a=c.length===1?c[0]:Xr(c)??{allOf:c};Y(r,i,a)}for(let i of s.required??[])o.add(i)}let n={type:"object",properties:r};if(o.size)n.required=[...o];if(t.every((s)=>s.additionalProperties===!1))n.additionalProperties=!1;else{let s=[];for(let i of t){let c=xc(i);if(c&&!s.some((a)=>JSON.stringify(a)===JSON.stringify(c)))s.push(c)}if(s.length===1)n.additionalProperties=s[0];else if(s.length>1)n.additionalProperties={allOf:s}}return n}function ol(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let n of wc)if(n in e)return;let r=t.filter((n)=>yc.some((s)=>Array.isArray(n[s]))),o=null;if(!r.length)o=Xr(t);else{let n=r[0],s=yc.find((a)=>Array.isArray(n[a]));if(Object.keys(n).length!==1)return;let i=t.filter((a)=>a!==n),c=n[s].map((a)=>Xr([...i,a]));if(c.some((a)=>!a))return;o={[s]:c}}if(!o)return;delete e.allOf,it(e,o)}function eo(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let o=(c)=>{let a=e.seen.get(c);if(a.ref===null)return;let u=a.def??a.schema,p={...u},l=a.ref;if(a.ref=null,l){o(l);let d=e.seen.get(l),m=d.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))u.allOf=u.allOf??[],u.allOf.push(m);else it(u,m);if(it(u,p),c._zod.parent===l)for(let g in u){if(g==="$ref"||g==="allOf")continue;if(!(g in p))delete u[g]}if(m.$ref&&d.def)for(let g in u){if(g==="$ref"||g==="allOf")continue;if(g in d.def&&JSON.stringify(u[g])===JSON.stringify(d.def[g]))delete u[g]}}let f=c._zod.parent;if(f&&f!==l){o(f);let d=e.seen.get(f);if(d?.schema.$ref){if(u.$ref=d.schema.$ref,d.def)for(let m in u){if(m==="$ref"||m==="allOf")continue;if(m in d.def&&JSON.stringify(u[m])===JSON.stringify(d.def[m]))delete u[m]}}}e.override({zodSchema:c,jsonSchema:u,path:a.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let c of[...e.seen.entries()].reverse())o(c[0]);if(e.target!=="openapi-3.0")for(let c of e.seen.entries())vc(c[1].def??c[1].schema);for(let c of e.deferred)c();if(e.intersections.length){let c=new Map;for(let a of e.seen.values())for(let u of[a.schema,a.def]){let p=u?.allOf;if(!Array.isArray(p))continue;let l=c.get(p);if(l)l.push(u);else c.set(p,[u])}for(let a of e.intersections)for(let u of c.get(a)??[])ol(u)}}let n={};if(e.target==="draft-2020-12")n.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")n.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")n.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let c=e.external.registry.get(t)?.id;if(!c)throw Error("Schema is missing an `id` property");n.$id=e.external.uri(c)}it(n,r.defId?r.schema:r.def??r.schema);let s=e.metadataRegistry.get(t)?.id;if(s!==void 0&&n.id===s)delete n.id;let i=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let c of e.seen.entries()){let a=c[1];if(a.def&&a.defId){if(a.def.id===a.defId)delete a.def.id;Y(i,a.defId,a.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(i).length>0)if(e.target==="draft-2020-12")n.$defs=i;else n.definitions=i;try{let c=JSON.parse(JSON.stringify(n));return Object.defineProperty(c,"~standard",{value:{...t["~standard"],jsonSchema:{input:ct(t,"input",e.processors),output:ct(t,"output",e.processors)}},enumerable:!1,writable:!1}),c}catch(c){throw Error("Error converting schema to JSON.")}}function F(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return F(o.element,r);if(o.type==="set")return F(o.valueType,r);if(o.type==="lazy")return F(o.getter(),r);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault"||o.type==="catch")return F(o.innerType,r);if(o.type==="intersection")return F(o.left,r)||F(o.right,r);if(o.type==="record"||o.type==="map")return F(o.keyType,r)||F(o.valueType,r);if(o.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return F(o.in,r)||F(o.out,r)}if(o.type==="object"){for(let n in o.shape)if(F(o.shape[n],r))return!0;return!1}if(o.type==="union"){for(let n of o.options)if(F(n,r))return!0;return!1}if(o.type==="tuple"){for(let n of o.items)if(F(n,r))return!0;if(o.rest&&F(o.rest,r))return!0;return!1}return!1}var _c=(e,t={})=>(r)=>{let o=Yr({...r,processors:t});return I(e,o),Qr(o,e),eo(o,e)},ct=(e,t,r={})=>(o)=>{let{libraryOptions:n,target:s}=o??{},i=Yr({...n??{},target:s,io:t,processors:r});return I(e,i),Qr(i,e),eo(i,e)};var De=(e,t,r)=>{if(e[t]===void 0||r>e[t])e[t]=r},Fe=(e,t,r)=>{if(e[t]===void 0||r<e[t])e[t]=r},bc=(e,t)=>{De(e,"minimum",t),Fe(e,"maximum",t)},zc=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},Pc=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Ec=(e,t)=>{e.mime=e.mime?e.mime.filter((r)=>t.includes(r)):[...t]},Zc=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},kc=(e,t)=>De(e,"minimum",t.minimum),$c=(e,t)=>Fe(e,"maximum",t.maximum),Sc=(e)=>(t,r)=>{Zc(t,r.format);let[o,n]=e[r.format];De(t,"minimum",o),Fe(t,"maximum",n)},nl={greater_than:(e,t)=>De(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Fe(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>zc(e,t.value),number_format:Sc(bt),bigint_format:Sc(mr),min_length:kc,max_length:$c,length_equals:(e,t)=>bc(e,t.length),min_size:kc,max_size:$c,size_equals:(e,t)=>bc(e,t.size),string_format:(e,t)=>{if(Zc(e,t.format),t.pattern)Pc(e,t.pattern);if(t.format==="base64"||t.format==="base64url")e.contentEncoding=t.format;if(t.local||t.precision===-1)e.laxFormat=!0},mime_type:(e,t)=>Ec(e,t.mime)};function N(e){let t={},r=e._zod.def,o=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let s of o)nl[s._zod.def.check]?.(t,s._zod.def);let n=e._zod.bag;if(n.minimum!==void 0)De(t,"minimum",n.minimum);if(n.exclusiveMinimum!==void 0)De(t,"exclusiveMinimum",n.exclusiveMinimum);if(n.maximum!==void 0)Fe(t,"maximum",n.maximum);if(n.exclusiveMaximum!==void 0)Fe(t,"exclusiveMaximum",n.exclusiveMaximum);if(n.multipleOf!==void 0)zc(t,n.multipleOf);if(n.format!==void 0){if(t.format??(t.format=n.format),n.format.includes("int"))t.isInt=!0}if(n.mime)Ec(t,n.mime);for(let s of n.patterns??[])Pc(t,s);return t}var sl={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},il=new Map([[Rr,Bn],[Lt,Jn]]),cl=(e)=>il.get(e)??e,Oc=(e,t,r,o)=>{let n=r;n.type="string";let{minimum:s,maximum:i,format:c,patterns:a,contentEncoding:u,laxFormat:p}=N(e);if(typeof s==="number")n.minLength=s;if(typeof i==="number")n.maxLength=i;if(c){if(n.format=sl[c]??c,n.format==="")delete n.format;if(c==="time"||p)delete n.format}if(u)n.contentEncoding=u;if(a&&a.size>0){let l=[...a].map(cl);if(l.length===1)n.pattern=l[0].source;else if(l.length>1)n.allOf=[...l.map((f)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))]}},Rc=(e,t,r,o)=>{let n=r,{minimum:s,maximum:i,multipleOf:c,exclusiveMaximum:a,exclusiveMinimum:u,isInt:p}=N(e);n.type=p?"integer":"number";let l=typeof u==="number"&&u>=(s??Number.NEGATIVE_INFINITY),f=typeof a==="number"&&a<=(i??Number.POSITIVE_INFINITY),d=t.target==="draft-04"||t.target==="openapi-3.0";if(l)if(d)n.minimum=u,n.exclusiveMinimum=!0;else n.exclusiveMinimum=u;else if(typeof s==="number")n.minimum=s;if(f)if(d)n.maximum=a,n.exclusiveMaximum=!0;else n.exclusiveMaximum=a;else if(typeof i==="number")n.maximum=i;if(c){let m=new Set;for(let v of c)if(Number.isFinite(v)&&v!==0)m.add(Math.abs(v));else te(e,t,n,o,`A multipleOf divisor of ${v} cannot be represented in JSON Schema`);let[y,...g]=m;if(y!==void 0)n.multipleOf=y;if(g.length)n.allOf=[...n.allOf??[],...g.map((v)=>({multipleOf:v}))]}},Cc=(e,t,r,o)=>{r.type="boolean"},Ic=(e,t,r,o)=>{te(e,t,r,o,"BigInt cannot be represented in JSON Schema")};var Ac=(e,t,r,o)=>{r.not={}};var Tc=(e,t,r,o)=>{},Nc=(e,t,r,o)=>{te(e,t,r,o,"Date cannot be represented in JSON Schema")},jc=(e,t,r,o)=>{let n=e._zod.def,s=qe(n.entries);if(s.length===0){r.not={};return}if(s.every((i)=>typeof i==="number"))r.type="number";if(s.every((i)=>typeof i==="string"))r.type="string";r.enum=s},Dc=(e,t,r,o)=>{let n=e._zod.def;if(n.values.length===0){r.not={};return}let s=[];for(let i of n.values)if(i===void 0){if(te(e,t,r,o,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i==="bigint"){if(te(e,t,r,o,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(i))}else s.push(i);if(s.length===0);else if(s.length===1){let i=s[0];if(r.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0")r.enum=[i];else r.const=i}else{if(s.every((i)=>typeof i==="number"))r.type="number";if(s.every((i)=>typeof i==="string"))r.type="string";if(s.every((i)=>typeof i==="boolean"))r.type="boolean";if(s.every((i)=>i===null))r.type="null";r.enum=s}};var Fc=(e,t,r,o)=>{te(e,t,r,o,"Custom types cannot be represented in JSON Schema")};var Lc=(e,t,r,o)=>{te(e,t,r,o,"Transforms cannot be represented in JSON Schema")};var Mc=(e,t,r,o)=>{let n=r,s=e._zod.def,{minimum:i,maximum:c}=N(e);if(typeof i==="number")n.minItems=i;if(typeof c==="number")n.maxItems=c;n.type="array",n.items=I(s.element,t,{...o,path:[...o.path,"items"]})};function to(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return to(t.out);if(t.type==="catch")return to(t.innerType);return e._zod.optin}var Wc=(e,t,r,o)=>{let n=r,s=e._zod.def,i=s.shape;if(Object.getOwnPropertySymbols(i).length&&te(e,t,n,o,"Symbol keys cannot be represented in JSON Schema"))return;n.type="object",n.properties={};for(let u in i)Y(n.properties,u,I(i[u],t,{...o,path:[...o.path,"properties",u]}));let a=[];for(let u of Object.keys(i)){let p=s.shape[u];if(t.io==="input"?to(p)===void 0:p._zod.optout===void 0)a.push(u)}if(a.length>0)n.required=a;if(s.catchall?._zod.def.type==="never")n.additionalProperties=!1;else if(!s.catchall){if(t.io==="output")n.additionalProperties=!1}else if(s.catchall)n.additionalProperties=I(s.catchall,t,{...o,path:[...o.path,"additionalProperties"]})},Uc=(e,t,r,o)=>{let n=e._zod.def,s=n.inclusive===!1,i=n.options.map((c,a)=>I(c,t,{...o,path:[...o.path,s?"oneOf":"anyOf",a]}));if(s)r.oneOf=i;else r.anyOf=i},Bc=(e,t,r,o)=>{let n=e._zod.def,s=I(n.left,t,{...o,path:[...o.path,"allOf",0]}),i=I(n.right,t,{...o,path:[...o.path,"allOf",1]}),c=(u)=>("allOf"in u)&&Object.keys(u).length===1,a=[...c(s)?s.allOf:[s],...c(i)?i.allOf:[i]];r.allOf=a,t.intersections.push(a)};var Jc=(e,t,r,o)=>{let n=e._zod.def,s=I(n.innerType,t,o),i=t.seen.get(e);if(t.target==="openapi-3.0")i.ref=n.innerType,r.nullable=!0;else r.anyOf=[s,{type:"null"}]},Vc=(e,t,r,o)=>{let n=e._zod.def;I(n.innerType,t,o);let s=t.seen.get(e);s.ref=n.innerType},ro=Symbol();function Hc(e,t,r,o,n){let s=!1,i=JSON.stringify(e,(c,a)=>{if(typeof a!=="bigint")return a;return s=!0,null});if(!s)return JSON.parse(i);return te(t,r,o,n,"BigInt defaults cannot be represented in JSON Schema"),ro}var Kc=(e,t,r,o)=>{let n=e._zod.def;I(n.innerType,t,o);let s=t.seen.get(e);s.ref=n.innerType;let i=Hc(n.defaultValue,e,t,r,o);if(i!==ro)r.default=i},Gc=(e,t,r,o)=>{let n=e._zod.def;I(n.innerType,t,o);let s=t.seen.get(e);if(s.ref=n.innerType,t.io!=="input")return;let i=Hc(n.defaultValue,e,t,r,o);if(i!==ro)r._prefault=i},qc=(e,t,r,o)=>{let n=e._zod.def;I(n.innerType,t,o);let s=t.seen.get(e);s.ref=n.innerType;let i;try{i=n.catchValue(void 0)}catch{te(e,t,r,o,"Dynamic catch values are not supported in JSON Schema");return}r.default=i},Xc=(e,t,r,o)=>{let n=e._zod.def,s=n.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?s?n.out:n.in:n.out;I(i,t,o);let c=t.seen.get(e);c.ref=i},Yc=(e,t,r,o)=>{let n=e._zod.def;I(n.innerType,t,o);let s=t.seen.get(e);s.ref=n.innerType,r.readOnly=!0};var oo=(e,t,r,o)=>{let n=e._zod.def;I(n.innerType,t,o);let s=t.seen.get(e);s.ref=n.innerType};var Qc=new WeakSet([Object.prototype,Error.prototype]);function Kt(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let o=r(this);return Object.defineProperty(this,t,{value:o,configurable:!0,writable:!0}),o},set(o){Object.defineProperty(this,t,{value:o,configurable:!0,writable:!0})}})}var gl=(e,t)=>{yn.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);if(Qc.has(r))return;Qc.add(r),Kt(r,"format",(o)=>(n)=>vn(o,n)),Kt(r,"flatten",(o)=>(n)=>xn(o,n)),Kt(r,"addIssue",(o)=>(n)=>{o.issues.push(n),o.message=JSON.stringify(o.issues,Xe,2)}),Kt(r,"addIssues",(o)=>(n)=>{o.issues.push(...n),o.message=JSON.stringify(o.issues,Xe,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var V=h("ZodError",gl,void 0,{Parent:Error});var ea=Rt(V),ta=Ct(V),ra=It(V),oa=At(V),na=_n(V),sa=bn(V),ia=kn(V),ca=$n(V),aa=Sn(V),ua=zn(V),pa=Pn(V),la=En(V);function xl(){if(!J.localeError)ee(jr())}function so(){if(!J.memoizer)ee({memoizer:Zi()})}var O=h("ZodType",(e,t)=>(xl(),P.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(B(t,{checks:[...t.checks??[],...e.map((r)=>typeof r==="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return oe(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(lf(e,t))},superRefine(e,t){return this.check(ff(e,t))},overwrite(e){return this.check(ve(e))},optional(){return ha(this)},exactOptional(){return Xl(this)},nullable(){return ma(this)},nullish(){return ha(ma(this))},nonoptional(e){return of(this,e)},array(){return k(this)},or(e){return uo([this,e])},and(e){return Hl(this,e)},transform(e){return ga(this,ql(e))},default(e){return ef(this,e)},prefault(e){return rf(this,e)},catch(e){return sf(this,e)},pipe(e){return ga(this,e)},readonly(){return uf(this)},describe(e){let t=this.clone();return Se.add(t,{description:e}),t},meta(...e){if(e.length===0)return Se.get(this);let t=this.clone();return Se.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get "~standard"(){return Et(this,"~standard",{...Or(this),jsonSchema:{input:ct(this,"input"),output:ct(this,"output")}})},set "~standard"(e){pe(this,"~standard",e)},parse:function e(t,r){return ea(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await ta(this,t,r,{callee:e})},safeParse(e,t){return ra(this,e,t)},async safeParseAsync(e,t){return oa(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){pe(this,"spa",e)},validate(e,t){return wr(this,e,t)},validateAsync(e,t){return _r(this,e,t)},encode:function e(t,r){return na(this,t,r,{callee:e})},decode:function e(t,r){return sa(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await ia(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await ca(this,t,r,{callee:e})},safeEncode(e,t){return aa(this,e,t)},safeDecode(e,t){return ua(this,e,t)},async safeEncodeAsync(e,t){return pa(this,e,t)},async safeDecodeAsync(e,t){return la(this,e,t)},toJSONSchema(e){return _c(this,{})(e)},get description(){return Se.get(this)?.description},get _def(){return this._zod.def}}),ya=h("_ZodString",(e,t)=>{Ft.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Oc(e,r,o,n)},Zt({format:(e)=>N(e).format??null,minLength:(e)=>N(e).minimum??null,maxLength:(e)=>N(e).maximum??null},{regex(...e){return this.check(Lr(...e))},includes(...e){return this.check(Ur(...e))},startsWith(...e){return this.check(Br(...e))},endsWith(...e){return this.check(Jr(...e))},min(...e){return this.check(je(...e))},max(...e){return this.check(Vt(...e))},length(...e){return this.check(Ht(...e))},nonempty(...e){return this.check(je(1,...e))},lowercase(e){return this.check(Mr(e))},uppercase(e){return this.check(Wr(e))},trim(){return this.check(Hr())},normalize(...e){return this.check(Vr(...e))},toLowerCase(){return this.check(Kr())},toUpperCase(){return this.check(Gr())},slugify(){return this.check(qr())}})),io=h("ZodString",(e,t)=>{Ft.init(e,t),ya.init(e,t)},{email(e){return this.check(Ai(kl,e))},url(e){return this.check(Fr(xa,e))},jwt(e){return this.check(Qi(Ll,e))},emoji(e){return this.check(Fi(zl,e))},guid(e){return this.check(Ti($l,e))},uuid(e){return this.check(Dr(ut,e))},uuidv4(e){return this.check(Ni(ut,e))},uuidv6(e){return this.check(ji(ut,e))},uuidv7(e){return this.check(Di(ut,e))},nanoid(e){return this.check(Li(Pl,e))},cuid(e){return this.check(Mi(El,e))},cuid2(e){return this.check(Wi(Zl,e))},ulid(e){return this.check(Ui(Ol,e))},base64(e){return this.check(qi(jl,e))},base64url(e){return this.check(Xi(Dl,e))},xid(e){return this.check(Bi(Rl,e))},ksuid(e){return this.check(Ji(Cl,e))},ipv4(e){return this.check(Vi(Il,e))},ipv6(e){return this.check(Hi(Al,e))},cidrv4(e){return this.check(Ki(Tl,e))},cidrv6(e){return this.check(Gi(Nl,e))},e164(e){return this.check(Yi(Fl,e))},datetime(e){return this.check(ec(vl,e))},date(e){return this.check(tc(wl,e))},time(e){return this.check(rc(_l,e))},duration(e){return this.check(oc(bl,e))}});function _(e){return Ci(io,e)}var R=h("ZodStringFormat",(e,t)=>{E.init(e,t),ya.init(e,t)}),vl=h("ZodISODateTime",(e,t)=>{Ms.init(e,t),R.init(e,t)}),wl=h("ZodISODate",(e,t)=>{Ws.init(e,t),R.init(e,t)}),_l=h("ZodISOTime",(e,t)=>{Us.init(e,t),R.init(e,t)}),bl=h("ZodISODuration",(e,t)=>{Bs.init(e,t),R.init(e,t)}),kl=h("ZodEmail",(e,t)=>{Os.init(e,t),R.init(e,t)});var $l=h("ZodGUID",(e,t)=>{Es.init(e,t),R.init(e,t)});var ut=h("ZodUUID",(e,t)=>{Zs.init(e,t),R.init(e,t)});function co(e){return Dr(ut,e)}var xa=h("ZodURL",(e,t)=>{Is.init(e,t),R.init(e,t)});function Sl(e){return Fr(xa,e)}var zl=h("ZodEmoji",(e,t)=>{As.init(e,t),R.init(e,t)});var Pl=h("ZodNanoID",(e,t)=>{Ts.init(e,t),R.init(e,t)});var El=h("ZodCUID",(e,t)=>{Ns.init(e,t),R.init(e,t)});var Zl=h("ZodCUID2",(e,t)=>{js.init(e,t),R.init(e,t)});var Ol=h("ZodULID",(e,t)=>{Ds.init(e,t),R.init(e,t)});var Rl=h("ZodXID",(e,t)=>{Fs.init(e,t),R.init(e,t)});var Cl=h("ZodKSUID",(e,t)=>{Ls.init(e,t),R.init(e,t)});var Il=h("ZodIPv4",(e,t)=>{Js.init(e,t),R.init(e,t)});var Al=h("ZodIPv6",(e,t)=>{Hs.init(e,t),R.init(e,t)});var Tl=h("ZodCIDRv4",(e,t)=>{Ks.init(e,t),R.init(e,t)});var Nl=h("ZodCIDRv6",(e,t)=>{Gs.init(e,t),R.init(e,t)});var jl=h("ZodBase64",(e,t)=>{Xs.init(e,t),R.init(e,t)});var Dl=h("ZodBase64URL",(e,t)=>{Ys.init(e,t),R.init(e,t)});var Fl=h("ZodE164",(e,t)=>{Qs.init(e,t),R.init(e,t)});var Ll=h("ZodJWT",(e,t)=>{ei.init(e,t),R.init(e,t)});var Gt=h("ZodNumber",(e,t)=>{Cr.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Rc(e,r,o,n),e.isFinite=!0},Zt({minValue:(e)=>{let{minimum:t,exclusiveMinimum:r}=N(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:r}=N(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:r}=N(e);return!!t||!!r?.some(Number.isSafeInteger)},format:(e)=>N(e).format??null},{gt(e,t){return this.check(Ne(e,t))},gte(e,t){return this.check(fe(e,t))},min(e,t){return this.check(fe(e,t))},lt(e,t){return this.check(Te(e,t))},lte(e,t){return this.check(le(e,t))},max(e,t){return this.check(le(e,t))},int(e){return this.check(fa(e))},safe(e){return this.check(fa(e))},positive(e){return this.check(Ne(0,e))},nonnegative(e){return this.check(fe(0,e))},negative(e){return this.check(Te(0,e))},nonpositive(e){return this.check(le(0,e))},multipleOf(e,t){return this.check(st(e,t))},step(e,t){return this.check(st(e,t))},finite(){return this}}));function va(e){return nc(Gt,e)}var Ml=h("ZodNumberFormat",(e,t)=>{ti.init(e,t),Gt.init(e,t)});function fa(e){return ic(Ml,e)}var ao=h("ZodBoolean",(e,t)=>{ri.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Cc(e,r,o,n)});function Le(e){return cc(ao,e)}var wa=h("ZodBigInt",(e,t)=>{oi.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ic(e,r,o,n)},Zt({minValue:(e)=>N(e).minimum??null,maxValue:(e)=>N(e).maximum??null,format:(e)=>N(e).format??null},{gte(e,t){return this.check(fe(e,t))},min(e,t){return this.check(fe(e,t))},gt(e,t){return this.check(Ne(e,t))},lt(e,t){return this.check(Te(e,t))},lte(e,t){return this.check(le(e,t))},max(e,t){return this.check(le(e,t))},positive(e){return this.check(Ne(BigInt(0),e))},negative(e){return this.check(Te(BigInt(0),e))},nonpositive(e){return this.check(le(BigInt(0),e))},nonnegative(e){return this.check(fe(BigInt(0),e))},multipleOf(e,t){return this.check(st(e,t))}}));var Wl=h("ZodUnknown",(e,t)=>{ni.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Tc(e,r,o,n)});function da(){return pc(Wl)}var Ul=h("ZodNever",(e,t)=>{si.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ac(e,r,o,n)});function _a(e){return lc(Ul,e)}var ba=h("ZodDate",(e,t)=>{ii.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Nc(e,r,o,n),e.min=(r,o)=>e.check(fe(r,o)),e.max=(r,o)=>e.check(le(r,o))},Zt({minDate:(e)=>{let{minimum:t}=N(e);return t?new Date(t):null},maxDate:(e)=>{let{maximum:t}=N(e);return t?new Date(t):null}},{}));var Bl=h("ZodArray",(e,t)=>{so(),ci.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Mc(e,r,o,n),e.element=t.element},{min(e,t){return this.check(je(e,t))},nonempty(e){return this.check(je(1,e))},max(e,t){return this.check(Vt(e,t))},length(e,t){return this.check(Ht(e,t))},unwrap(){return this.element}});function k(e,t){return dc(Bl,e,t)}var ka=h("ZodObject",(e,t)=>{so(),pi.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Wc(e,r,o,n),bp(e,"shape",(r)=>r._zod.def.shape,!1)},{keyof(){return q(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(B(this._zod.def,{catchall:e}))},passthrough(){return this.clone(B(this._zod.def,{catchall:da()}))},loose(){return this.clone(B(this._zod.def,{catchall:da()}))},strict(){return this.clone(B(this._zod.def,{catchall:_a()}))},strip(){return this.clone(B(this._zod.def,{catchall:void 0}))},extend(e){return hp(this,e)},safeExtend(e){return mp(this,e)},merge(e){return gp(this,e)},pick(e){return fp(this,e)},omit(e){return dp(this,e)},partial(...e){return an(Sa,this,e[0])},exactPartial(...e){return an(za,this,e[0],"exactPartial")},required(...e){return yp(Pa,this,e[0])}});function pt(e,t){let r={type:"object",shape:e??{},...x(t)};return new ka(r)}function z(e,t){return new ka({type:"object",shape:e,catchall:_a(),...x(t)})}var $a=h("ZodUnion",(e,t)=>{Ir.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Uc(e,r,o,n),e.options=t.options});function uo(e,t){return new $a({type:"union",options:e,...x(t)})}var Jl=h("ZodDiscriminatedUnion",(e,t)=>{$a.init(e,t),li.init(e,t)});function po(e,t,r){return new Jl({type:"union",options:t,discriminator:e,...x(r)})}var Vl=h("ZodIntersection",(e,t)=>{fi.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Bc(e,r,o,n)});function Hl(e,t){return new Vl({type:"intersection",left:e,right:t})}var no=h("ZodEnum",(e,t)=>{di.init(e,t),O.init(e,t),e._zod.processJSONSchema=(o,n,s)=>jc(e,o,n,s),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(o,n)=>{let s={};for(let i of o)if(r.has(i))s[i]=t.entries[i];else throw Error(`Key ${i} not found in enum`);return new no({...t,checks:[],...x(n),entries:s})},e.exclude=(o,n)=>{let s={...t.entries};for(let i of o)if(r.has(i))delete s[i];else throw Error(`Key ${i} not found in enum`);return new no({...t,checks:[],...x(n),entries:s})}});function q(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map((o)=>[o,o])):e;return new no({type:"enum",entries:r,...x(t)})}var Kl=h("ZodLiteral",(e,t)=>{hi.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Dc(e,r,o,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function H(e,t){return new Kl({type:"literal",values:Array.isArray(e)?e:[e],...x(t)})}var Gl=h("ZodTransform",(e,t)=>{so(),mi.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Lc(e,r,o,n),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new et(e.constructor.name);r.addIssue=(s)=>{if(typeof s==="string")r.issues.push($e(s,r.value,t));else{let i=s;if(i.fatal)i.continue=!1;if(i.code??(i.code="custom"),!("input"in i))i.input=r.value;i.inst??(i.inst=e),r.issues.push($e(i))}};let n=t.transform(r.value,r);if(n instanceof Promise)return n.then((s)=>(r.value=s,r));return r.value=n,r}});function ql(e){return new Gl({type:"transform",transform:e})}var Sa=h("ZodOptional",(e,t)=>{Ar.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>oo(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function ha(e){return new Sa({type:"optional",innerType:e})}var za=h("ZodExactOptional",(e,t)=>{gi.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>oo(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Xl(e){return new za({type:"optional",innerType:e})}var Yl=h("ZodNullable",(e,t)=>{yi.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Jc(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function ma(e){return new Yl({type:"nullable",innerType:e})}var Ql=h("ZodDefault",(e,t)=>{xi.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Kc(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ef(e,t){return new Ql({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():dr(t)}})}var tf=h("ZodPrefault",(e,t)=>{vi.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Gc(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function rf(e,t){return new tf({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():dr(t)}})}var Pa=h("ZodNonOptional",(e,t)=>{wi.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Vc(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function of(e,t){return new Pa({type:"nonoptional",innerType:e,...x(t)})}var nf=h("ZodCatch",(e,t)=>{_i.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>qc(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function sf(e,t){return new nf({type:"catch",innerType:e,catchValue:typeof t==="function"?t:fn(t)})}var cf=h("ZodPipe",(e,t)=>{bi.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Xc(e,r,o,n),e.in=t.in,e.out=t.out});function ga(e,t){return new cf({type:"pipe",in:e,out:t})}var af=h("ZodReadonly",(e,t)=>{ki.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Yc(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function uf(e){return new af({type:"readonly",innerType:e})}var pf=h("ZodCustom",(e,t)=>{$i.init(e,t),O.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Fc(e,r,o,n)});function lf(e,t={}){return hc(pf,e,t)}function ff(e,t){return mc(e,t)}var lo={};Go(lo,{bigint:()=>yf,boolean:()=>gf,date:()=>xf,number:()=>mf,string:()=>hf});function hf(e){return Ii(io,e)}function mf(e){return sc(Gt,e)}function gf(e){return ac(ao,e)}function yf(e){return uc(wa,e)}function xf(e){return fc(ba,e)}var fo=q(["codex","claude","opencode"]),vf=_().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/),wf="Initialize an AppToolkit workspace, register an existing checkout, or find the approved project workflow.",_f={codex:".agents/skills/apptoolkit/SKILL.md",claude:".claude/skills/apptoolkit/SKILL.md",opencode:".opencode/commands/apptoolkit.md"},Ea=["For requests involving this workspace, read `llm/HARNESS.md` and use its workflow index to open the relevant procedure. Follow the established rules for the project and target repository.","","For a request like “Dame mi lista de pendientes”, open W01. For a new feature, use W16 to establish requirements before W18 implementation."].join(`
|
|
59
|
+
`);function ho(e){let t=new Set(k(fo).parse(e)),r=[];if(t.has("codex")||t.has("opencode"))r.push({path:"AGENTS.md",content:Ea});if(t.has("claude"))r.push({path:"CLAUDE.md",content:Ea});return r}function bf(e,t){let r=["---"];if(e!=="opencode")r.push("name: apptoolkit");if(r.push(`description: ${wf}`),e==="claude")r.push('argument-hint: "[init | add repo <path> | workflow <request>]"');if(r.push("---","",`# AppToolkit Harness ${t}`,""),e!=="codex")r.push("Treat the following as user arguments, never as shell source.","","$ARGUMENTS","");return r.push("Find the installed workspace root using `llm/harness/workspace.json`. Open the session from that root when discovery is ambiguous.","Read `llm/HARNESS.md`, the project settings, and relevant repository instructions before choosing a workflow. Read the indexed workflow by ID instead of loading every workflow.","","Use `rtk proxy bun --no-env-file <workspace>/llm/harness/runtime/harness.mjs` for deterministic operations. If only Node.js is available, replace `bun --no-env-file` with `node`. Substitute absolute paths with individually quoted arguments.","","- For `init`, use `init --root <workspace> --json` to load the configuration template. Ask about budgets and discover approved project rules, tool routes, authority, and documentation conventions. Keep service connections and snapshots opt-in. Save the agreed answers as an explicit JSON input with credential references only. Apply it with `init --root <workspace> --config <input>`.","- For `add repo <path>`, identify the existing checkout and ask whether harness files there may be versioned. Preview `add repo <path> --root <workspace>` with the agreed `--repo-versioned` or `--repo-local` choice. Apply with `--yes` only after the user approves that plan. Keep shared knowledge in the workspace and scope repository-specific instructions to the checkout.","- For feature requests, use W16 to settle the definition before W18 implementation. In existing projects, an authoritative ticket or approved specification may satisfy that gate.","- For other requests, resolve the closest workflow from the index. Obtain separate authority for external writes and Git writes. Do not grant tool access or move credentials into the workspace.",""),r.join(`
|
|
60
|
+
`)}function mo(e,t){let r=k(fo).parse(e),o=vf.parse(t);return[...new Set(r)].map((n)=>({path:_f[n],content:bf(n,o)}))}import{randomUUID as td}from"node:crypto";import{lstatSync as rd,readFileSync as od,realpathSync as Ya,renameSync as nd,rmSync as sd,writeFileSync as id}from"node:fs";import{dirname as cd,join as Ve,relative as ad,resolve as Qa}from"node:path";import{mkdirSync as Df,readFileSync as Ff,rmSync as La,writeFileSync as Lf}from"node:fs";import{tmpdir as Mf}from"node:os";import{resolve as xo}from"node:path";import{createHash as kf,randomUUID as $f}from"node:crypto";import{chmodSync as Sf,linkSync as zf,lstatSync as qt,mkdirSync as Pf,readFileSync as Ef,realpathSync as Ra,renameSync as Zf,rmSync as Of,unlinkSync as Rf,writeFileSync as Cf}from"node:fs";import{dirname as Za,isAbsolute as Ca,relative as Ia,resolve as lt,sep as If}from"node:path";var Oa=16777216;class Xt extends Error{}function Aa(e){return"code"in e&&e.code==="ENOENT"}function de(e){let t=Ra(lt(e));if(!qt(t).isDirectory())throw Error(`Expected an existing directory at ${t}.`);return t}function go(e,t){let r=Ia(e,t);return r!==".."&&!r.startsWith(`..${If}`)&&!Ca(r)}function we(e,t){if(!go(e,t))throw Error(`Path ${t} is outside ${e}.`);return Ia(e,t)||"."}function re(e){let t=e.split("/");if(Ca(e)||/[\\\u0000-\u001f\u007f]/u.test(e)||t.some((r)=>!r||r==="."||r===".."||r===".git"))throw Error(`Expected a safe relative path. Received ${JSON.stringify(e)}.`)}function Yt(e,t){if(re(t),Ra(e)!==e||!qt(e).isDirectory())throw Error(`The installation base changed. Inspect ${e} before retrying.`);let r=t.split("/"),o=e;for(let[n,s]of r.entries()){o=lt(o,s);let i=qt(o,{throwIfNoEntry:!1});if(!i)break;let c=n===r.length-1;if(i.isSymbolicLink()||!c&&!i.isDirectory()||c&&!i.isFile())throw new Xt(`Expected a regular file path. Inspect ${o} before retrying.`)}return lt(e,t)}function M(e){return kf("sha256").update(e).digest("hex")}function W(e,t=420){let r=Buffer.isBuffer(e)?e:Buffer.from(e);return{bytes:r,hash:M(r),mode:t}}function C(e,t){let r=Yt(e,t),o=qt(r,{throwIfNoEntry:!1});if(!o)return null;if(o.size>Oa)throw Error(`The file at ${r} exceeds the ${Oa}-byte installation limit.`);return W(Ef(r),o.mode&511)}function ie(e,t){return e?.hash===t?.hash&&e?.mode===t?.mode}function ze(e){if(!ie(C(e.base,e.path),e.before))throw Error(`File changed after planning. Replan before applying ${lt(e.base,e.path)}.`)}function ft(e){ze(e);let t=Yt(e.base,e.path);if(!e.after){Rf(t);return}Pf(Za(t),{recursive:!0}),ze(e);let r=lt(Za(t),`.apptoolkit-${$f()}.tmp`),o=e.after;try{if(Cf(r,o.bytes,{flag:"wx",mode:o.mode}),Sf(r,o.mode),e.before)ze(e),Zf(r,t);else zf(r,t)}finally{Of(r,{force:!0})}}import{spawnSync as Af}from"node:child_process";import{lstatSync as Tf,realpathSync as Ta}from"node:fs";import{dirname as Na,resolve as yo}from"node:path";function Nf(){let e={};for(let[t,r]of Object.entries(process.env))if(!t.startsWith("GIT_"))e[t]=r;return{...e,GIT_OPTIONAL_LOCKS:"0",LC_ALL:"C"}}function Me(e,t,r=[0],o=!1){let s=Af("rtk",["proxy","git",...o?["--literal-pathspecs"]:[],"-C",e,...t],{encoding:"utf8",env:Nf(),maxBuffer:1048576,timeout:1e4});if(s.error)throw Error(`Cannot run Git ${t[0]} in ${e}. Verify RTK and Git are installed.`,{cause:s.error});if(s.status===null||!r.includes(s.status))throw Error(`Git ${t[0]} failed in ${e}: ${s.stderr.trim()||`exit ${s.status}`}`);return{output:s.stdout,status:s.status}}function ja(e){let t=e;while(!0){let r=Tf(yo(t,".git"),{throwIfNoEntry:!1});if(r?.isDirectory()||r?.isFile())return t;if(r)throw Error(`Unsupported Git metadata at ${yo(t,".git")}. Inspect the repository before retrying.`);let o=Na(t);if(o===t)return;t=o}}function L(e){if(!ja(e))return;let t=Ta(Me(e,["rev-parse","--show-toplevel"]).output.trimEnd()),r=Ta(Me(e,["rev-parse","--path-format=absolute","--git-common-dir"]).output.trimEnd()),o=Me(e,["rev-parse","--path-format=absolute","--git-path","info/exclude"]).output.trimEnd();if(yo(r,"info/exclude")!==o)throw Error(`Git returned a local exclude path outside the expected metadata directory for ${e}.`);return{root:t,commonDirectory:r,exclude:"info/exclude"}}function Pe(e,t){if(ja(Na(e))!==t)throw Error(`The path ${e} belongs to a different Git checkout. Select that checkout explicitly before retrying.`)}function We(e,t){let r=we(e.root,t);return Me(e.root,["ls-files","--cached","-z","--",r],[0],!0).output.split("\x00").includes(r)}function Qt(e,t){let r=Me(e.git.root,["check-ignore","--quiet","--",`./${e.path}`],[0,1]);if(!t&&r.status!==0)throw Error(`Git did not ignore ${e.path} in ${e.git.root}. Check for an existing tracked file or a higher-priority rule before retrying.`);if(t&&r.status===0)throw Error(`Git ignores ${e.path} in ${e.git.root}. Choose local mode or resolve the existing exclusion before retrying.`)}function jf(e){if(e.includes("://")){try{let n=new URL(e);if(n.hostname&&n.pathname!=="/")return`${n.host.toLowerCase()}${n.pathname.replace(/\.git\/?$/,"").replace(/\/$/,"")}`}catch(n){throw Error("Git returned an invalid origin URL. Correct the local repository configuration before retrying.",{cause:n})}return}let t=/^(?:[^@/:\s]+@)?([^/:\s]+):([^\s]+)$/.exec(e),r=t?.[1],o=t?.[2];if(r&&o)return`${r.toLowerCase()}/${o.replace(/^\//,"").replace(/\.git\/?$/,"").replace(/\/$/,"")}`;return}function Da(e){let t=Me(e,["config","--local","--get","remote.origin.url"],[0,1]);if(t.status===1)return;let r=jf(t.output.trimEnd());if(!r)return;return M(r)}function er(e){return`/${e.replace(/[\\[\]*? #!]/gu,"\\$&")}`}var Wf=lo.number().int().positive(),Ma=new WeakMap;function Wa(e,t){Ma.set(e,t)}function Uf(e){let t=xo(Mf(),`apptoolkit-${M(e).slice(0,24)}.lock`),r=xo(t,"owner");try{Df(t,{mode:448})}catch(o){if(!(o instanceof Error)||!("code"in o)||o.code!=="EEXIST")throw Error(`Cannot acquire the installation lock ${t}.`,{cause:o});let n;try{n=Wf.parse(Ff(r,"utf8"))}catch(s){throw Error(`An installation lock already exists at ${t}. If no install is running, remove the stale lock directory and retry.`,{cause:s})}try{process.kill(n,0)}catch(s){if(s instanceof Error&&"code"in s&&s.code==="ESRCH")throw Error(`The previous installation stopped. Remove its stale lock at ${t} and rerun the same installation to resume.`,{cause:s});throw Error(`Cannot confirm whether the installation holding ${t} is still running.`,{cause:s})}throw Error(`Another installation is running for ${e} with process ID ${n}. Retry after it finishes.`)}try{Lf(r,`${process.pid}
|
|
61
|
+
`,{mode:384,flag:"wx"})}catch(o){try{La(t,{recursive:!0})}catch(n){throw AggregateError([o,n],`Cannot record or remove the installation lock at ${t}.`)}throw Error(`Cannot record the installation lock owner at ${r}.`,{cause:o})}return t}function Bf(e){let t=new Map;for(let r of e){let n=t.get(r.git.root)??L(r.git.root)?.commonDirectory;if(n!==r.git.commonDirectory)throw Error(`Git metadata changed after planning in ${r.git.root}. Replan the installation.`);if(t.set(r.git.root,n),!r.versioned&&We(r.git,r.absolute))throw Error(`Git started tracking ${r.absolute} after planning. Replan before applying local mode.`)}}function Jf(e,t){let r=[t];for(let o of e.reverse())try{ft({...o,before:o.after,after:o.before})}catch(n){r.push(Error(`Cannot restore ${xo(o.base,o.path)} after the installation failed.`,{cause:n}))}if(r.length>1)throw AggregateError(r,"Installation stopped and some files could not be restored. Inspect the reported paths and replan.");throw t}function Vf(e){let{exclusions:t,files:r,checks:o,guards:n=[],receipt:s}=e,i=[];for(let c of[...n,...t,...r])ze(c);for(let c of e.boundaries??[])Pe(c.absolute,c.gitRoot);Bf(o);try{for(let c of t)ft(c),i.push(c);for(let c of o)Qt(c,c.versioned);for(let c of r)ft(c),i.push(c);if(s){for(let c of n)ze(c);for(let c of r)ze({...c,before:c.after});ft(s),i.push(s)}}catch(c){Jf(i,Error("Could not apply the workspace installation. Inspect the cause and replan before retrying.",{cause:c}))}return i.length}function Fa(e){let t=[];for(let r of e.reverse())try{La(r,{recursive:!0})}catch(o){if(!(o instanceof Error)||!Aa(o))t.push(Error(`Cannot remove the installation lock at ${r}. Inspect it before retrying.`,{cause:o}))}return t}function Ua(e,t){let r=[],o;try{for(let s of[...new Set(e)].sort())r.push(Uf(s));o=t()}catch(s){let i=Fa(r);if(i.length)throw AggregateError([s,...i],"The installation failed and some locks could not be removed.");throw s}let n=Fa(r);if(n.length)throw AggregateError(n,"The installation completed and some locks could not be removed.");return o}function Ba(e,t){return Ua([e],t)}function vo(e,t){let r=[e,...t.exclusions.map((o)=>o.base),...t.checks.map((o)=>o.git.commonDirectory)];return Ua(r,()=>Vf(t))}function wo(e){let t=Ma.get(e);if(!t)throw Error("Apply requires a plan created by this process. Run the workspace planner again.");if(e.conflicts.length)throw Error(`Resolve the workspace conflicts before applying: ${e.conflicts.map((o)=>o.path).join(", ")}.`);return{changed:vo(e.root,t),receipt:e.receipt}}import{resolve as Hf}from"node:path";var Ja=q(["codex","claude","opencode"]),Va=q(["plane","penpot"]),_o=_().regex(/^[a-f0-9]{64}$/),Ha=z({path:_().min(1),versioned:Le(),identity:_o.optional()}),Ka=z({schema:H(1),version:_().min(1),hosts:k(Ja),workspaceVersioned:Le(),repositories:k(Ha),services:k(Va),installation:_().regex(/^[a-f0-9]{16}$/).optional(),files:k(z({path:_().min(1),hash:_o,versioned:Le(),fragment:_o.optional()}))}),Ga=z({root:_().min(1),action:q(["install","update","add-repo"]),version:_().regex(/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/),contentDirectory:_(),hosts:k(Ja).min(1),workspaceVersioned:Le(),repositories:k(Ha),services:k(Va),repository:_().min(1).optional()}),D="llm/harness/workspace.json";var Kf=new Set([".agents/skills/apptoolkit/SKILL.md",".claude/skills/apptoolkit/SKILL.md",".opencode/commands/apptoolkit.md","AGENTS.md","CLAUDE.md",".claude/rules/apptoolkit.md"]);function bo(e,t){if(e.startsWith("llm/harness/")||e.startsWith("llm/author-style/")||Kf.has(e))return e!==D&&e!=="llm/harness/project.json";if(e==="llm/HARNESS.md"||e==="llm/README.md")return!0;return t.some((r)=>e===he(r.path))}function he(e){if(e===".")return"llm/harness-context.llm.md";return`${e}/llm/harness-context.llm.md`}function X(e){let t=de(e),r=C(t,D);if(!r)return;try{let o=Ka.parse(JSON.parse(r.bytes.toString("utf8"))),n=new Set,s=new Set;for(let i of o.repositories){if(i.path!==".")re(i.path);if(n.has(i.path))throw Error(`Repeated repository path ${i.path}.`);n.add(i.path)}for(let i of o.files){if(re(i.path),!bo(i.path,o.repositories)||s.has(i.path))throw Error(`Unexpected managed file ${i.path}.`);s.add(i.path)}return o}catch(o){throw Error(`Cannot read the installation receipt at ${Hf(t,D)}. Restore a valid receipt before retrying.`,{cause:o})}}var ce=_().trim().min(1).max(120).regex(/^[\p{L}\p{N}][\p{L}\p{N} ./_:+-]*$/u),Xa=_().regex(/^[A-Z_][A-Z0-9_]*$/).max(120),Ue=_().min(1).max(512).refine((e)=>{if(/^[A-Za-z]:|[\\\u0000-\u001f\u007f]/u.test(e))return!1;return e.split("/").every((t)=>t!==""&&t!=="."&&t!==".."&&t!==".git")},"Use a workspace-relative path without traversal."),Be=uo([H("."),Ue]),Je=q(["plane","penpot"]),Gf=new Set(["localhost","127.0.0.1","[::1]"]),ko=Sl().max(512).pipe(_().refine((e)=>{let t=new URL(e);return(t.protocol==="https:"||t.protocol==="http:"&&Gf.has(t.hostname))&&!t.username&&!t.password&&!t.search&&!t.hash},"Use HTTPS or loopback HTTP without credentials, query, or fragment.")),qa={baseUrl:ko,tokenEnv:Xa,snapshots:q(["off","versioned"])},qf=po("provider",[z({...qa,provider:H("plane"),workspace:_().regex(/^[A-Za-z0-9][A-Za-z0-9_-]{0,119}$/),projectId:co(),auth:q(["api-key","oauth"]).default("api-key")}),z({...qa,provider:H("penpot"),fileId:co()})]),Xf=po("mode",[z({mode:H("unlimited")}),z({mode:H("limited"),limits:k(z({category:ce,maximum:va().positive(),unit:ce})).min(1).max(12)})]),Yf=z({category:ce,scope:ce,authority:ce,provider:ce,access:po("method",[z({method:H("local"),path:Ue}),z({method:H("cli"),command:ce}),z({method:H("mcp"),server:ce}),z({method:H("api"),baseUrl:ko,tokenEnv:Xa.optional()}),z({method:H("web"),baseUrl:ko})])}),Qf=z({kind:ce,template:Ue.optional(),requiredSections:k(ce).max(30),checklist:k(_().trim().min(1).max(200)).max(30),prohibitedText:k(_().trim().min(1).max(120)).max(30)}),ed=z({path:Be,budget:Xf,rules:k(Ue).max(50),routes:k(Yf).max(50),documentation:k(Qf).max(50),services:k(qf).max(2)}).superRefine((e,t)=>{let r=new Set;for(let[n,s]of e.routes.entries()){let i=`${s.category.toLowerCase()}
|
|
62
|
+
${s.scope.toLowerCase()}`;if(r.has(i))t.addIssue({code:"custom",path:["routes",n],message:"Choose one authority for this category and scope."});r.add(i)}let o=new Set;for(let[n,s]of e.services.entries()){if(o.has(s.provider))t.addIssue({code:"custom",path:["services",n],message:"Configure each built-in service once per project."});o.add(s.provider)}}),Ee=z({schema:H(1),projects:k(ed).min(1).max(100)}).superRefine((e,t)=>{let r=new Set;for(let[o,n]of e.projects.entries()){if(r.has(n.path))t.addIssue({code:"custom",path:["projects",o,"path"],message:"Each project must appear once."});r.add(n.path)}});var So="llm/harness/project.json",ud=1048576;function me(e){try{return rd(e)}catch(t){if(t instanceof Error&&"code"in t&&t.code==="ENOENT")return;throw Error(`Inspect ${e}.`,{cause:t})}}function zo(e){let t=me(e);if(!t?.isFile()||t.size>ud)throw Error(`Expected a regular JSON file of at most 1 MiB at ${e}.`);try{return JSON.parse(od(e,"utf8"))}catch(r){throw Error(`Read JSON configuration at ${e}.`,{cause:r})}}function eu(e){let t=e;for(let r of["llm","harness"])if(t=Ve(t,r),!me(t)?.isDirectory())throw Error(`Expected an installed, nonsymlink workspace directory at ${t}.`);return t}function dt(e){let t=Ya(Qa(e));eu(t);let r=X(t);if(!r)throw Error("Install the harness in the selected workspace before configuring it.");return{root:t,receipt:r}}function tu(e,t){if(eu(e),!me(t))return;let r=Ee.safeParse(zo(t));if(!r.success){let o=r.error.issues.map((n)=>`${n.path.join(".")||"settings"} ${n.message}`);throw Error(`Invalid project settings in ${t}. ${o.join(" ")}`)}return r.data}function Ze(e){return tu(e,Ve(e,So))}function pd(e,t,r){if(r)return r;let o=Ve(e,t),n=[];if(me(o)?.isDirectory()&&Ya(o)===o){for(let s of["AGENTS.md","CLAUDE.md","CONTRIBUTING.md"])if(me(Ve(o,s))?.isFile())n.push(s)}return{path:t,budget:null,rules:n,routes:[],documentation:[],services:[]}}function Po(e){let{root:t,receipt:r}=dt(e),o=Ze(t);return{schema:1,projects:[...new Set([".",...r.repositories.map((s)=>s.path)])].map((s)=>{let i=o?.projects.find((c)=>c.path===s);return pd(t,s,i)})}}function $o(e){return`${JSON.stringify(e,null,2)}
|
|
63
|
+
`}function ld(e,t){let r=cd(e),o=Ve(r,`.project.${td()}.json`);try{id(o,$o(t),{flag:"wx",mode:384}),nd(o,e)}catch(n){try{sd(o,{force:!0})}catch(s){throw AggregateError([n,s],`Write project settings and clean the draft at ${e}.`)}throw Error(`Write project settings at ${e}.`,{cause:n})}}async function Eo(e){let{root:t}=dt(e.root),r=tu(t,Qa(e.configPath));if(!r)throw Error("Provide the approved project settings JSON file.");return Ba(t,()=>{let{receipt:o}=dt(t),n=new Set([".",...o.repositories.map((u)=>u.path)]);for(let u of r.projects){if(!n.has(u.path))throw Error(`Register ${u.path} before initializing its settings.`);for(let p of u.services){if(!o.services.includes(p.provider))throw Error(`Select ${p.provider} during workspace installation before connecting it.`);if(p.snapshots==="versioned"&&!o.workspaceVersioned)throw Error("Versioned service snapshots require a versioned workspace harness.")}}let s=Ve(t,So);if(!o.workspaceVersioned){let u=L(t);if(u)Qt({git:u,path:ad(u.root,s)},!1)}let i=Ze(t),c=new Map(i?.projects.map((u)=>[u.path,u]));for(let u of r.projects)c.set(u.path,u);let a=Ee.parse({schema:1,projects:[...c.values()]});if(i&&$o(i)===$o(a))return{path:s,changed:!1,projects:a.projects.length};return ld(s,a),{path:s,changed:!0,projects:a.projects.length}})}var fd=z({root:_().min(1),project:Be,service:Je,verifyHealth:Le().optional(),verifyRead:Le()}),dd=pt({results:k(pt({id:co()})).max(1)}),hd=pt({name:_().min(1)}),md=131072;class _e extends Error{}function Oo(e){let{root:t,receipt:r}=dt(e.root);if(!r.services.includes(e.service))throw Error(`${e.service} is not selected in the installed workspace.`);if(e.project!=="."&&!r.repositories.some((s)=>s.path===e.project))throw Error(`Register ${e.project} before using its service connections.`);let n=Ze(t)?.projects.find((s)=>s.path===e.project)?.services.find((s)=>s.provider===e.service);if(!n)throw Error(`Initialize the ${e.service} connection for ${e.project} first.`);return{root:t,receipt:r,connection:n}}function Zo(e,t){let r=new URL(e);if(!r.pathname.endsWith("/"))r.pathname+="/";return new URL(t,r)}function gd(e){if(e.provider==="plane"){let r=`api/v1/workspaces/${e.workspace}/projects/${e.projectId}/work-items/`,o=Zo(e.baseUrl,r);return o.searchParams.set("per_page","1"),o.searchParams.set("fields","id"),o}let t=Zo(e.baseUrl,"api/rpc/command/get-file-summary");return t.searchParams.set("id",e.fileId),t}function yd(e,t){let r=new Headers({Accept:"application/json"});if(e.provider==="penpot")r.set("Authorization",`Token ${t}`);else if(e.auth==="oauth")r.set("Authorization",`Bearer ${t}`);else r.set("X-API-Key",t);return r}async function xd(e){if(!e.headers.get("content-type")?.toLowerCase().startsWith("application/json"))throw await e.body?.cancel(),new _e("Expected an application/json response from the service.");let r=e.body?.getReader();if(!r)throw new _e("The service response has no body.");let o=[],n=0;try{for(;;){let s=await r.read();if(s.done)return Buffer.concat(o,n).toString("utf8");if(n+=s.value.byteLength,n>md)throw await r.cancel(),new _e("The service response exceeded the 128 KiB verification limit.");o.push(s.value)}}finally{r.releaseLock()}}async function vd(e,t){let r=await t(Zo(e.baseUrl,"./"),{method:"HEAD",redirect:"manual",signal:AbortSignal.timeout(1e4)});return await r.body?.cancel(),r.status}async function wd(e,t,r){let o=await r(gd(e),{method:"GET",headers:yd(e,t),redirect:"error",signal:AbortSignal.timeout(1e4)});if(!o.ok)throw await o.body?.cancel(),new _e(`The selected resource returned HTTP ${o.status}. Confirm the target and its read permission.`);let n=await xd(o),s=e.provider==="plane"?dd:hd,i=!1;try{i=s.safeParse(JSON.parse(n)).success}catch(c){throw new _e("The service returned invalid JSON.",{cause:c})}if(!i)throw new _e("The response does not match the expected resource read.");return o.status}async function Ro(e,t={}){let r=fd.parse(e),{connection:o}=Oo(r),s=(t.environment??process.env)[o.tokenEnv],i=typeof s==="string"&&/^[\x21-\x7e]+$/.test(s),c={provider:o.provider,project:r.project,baseUrl:o.baseUrl,credentialEnv:o.tokenEnv,credentialAvailable:i,snapshots:o.snapshots,connectivity:"unchecked",read:"unchecked"},a=t.fetch??fetch;if(r.verifyRead){if(!i)throw Error(`Provide ${o.tokenEnv} in the process environment before verifying access.`);try{let u=await wd(o,s,a);return{...c,connectivity:"reachable",read:"verified",httpStatus:u}}catch(u){let p=u instanceof _e?u.message:"Check the configured host and retry.";throw Error(`Verify ${o.provider} read for ${r.project}. ${p}`,{cause:u})}}if(r.verifyHealth)try{let u=await vd(o,a);return{...c,connectivity:u>=500?"service-error":"reachable",httpStatus:u}}catch(u){throw Error(`Check ${o.provider} connectivity for ${r.project}.`,{cause:u})}return c}import{createHash as _d}from"node:crypto";import{constants as ru,createReadStream as bd,openSync as kd}from"node:fs";import{join as $d,relative as ou,resolve as Sd}from"node:path";var nu=Ue.refine((e)=>e.startsWith("harness-snapshots/"),{message:"Keep native service exports in the workspace harness-snapshots directory."}),zd=_().regex(/^[a-f0-9]{64}$/),Pd=z({path:nu,bytes:va().int().positive(),sha256:zd}),Ed=z({root:_().min(1),project:Be,service:Je}),su=z({schema:H(1),project:Be,service:Je,files:k(Pd).min(1).max(30)}).refine((e)=>new Set(e.files.map((t)=>t.path)).size===e.files.length,"Duplicate snapshot paths.");function iu(e,t){let r=Sd(e,t),o=nu.parse(ou(e,r)),n=e,s=o.split("/");for(let[i,c]of s.entries()){n=$d(n,c);let a=me(n);if(!(i===s.length-1?a?.isFile():a?.isDirectory()))throw Error(`Expected a regular nonsymlink snapshot path at ${n}.`)}return r}async function cu(e,t){let r=iu(e,t),o=me(r);if(!o?.isFile()||o.size===0)throw Error(`Expected a nonempty snapshot file at ${r}.`);let n=_d("sha256");try{let i=kd(r,ru.O_RDONLY|ru.O_NOFOLLOW),c=bd(r,{fd:i});for await(let a of c)n.update(a)}catch(i){throw Error(`Read snapshot bytes at ${r}.`,{cause:i})}let s=me(r);if(!s||o.dev!==s.dev||o.ino!==s.ino||o.mtimeMs!==s.mtimeMs||o.size!==s.size)throw Error(`Snapshot changed while reading ${r}. Retry with a stable export.`);return{path:ou(e,r),bytes:o.size,sha256:n.digest("hex")}}function au(e){let{root:t,receipt:r,connection:o}=Oo(Ed.parse(e));if(!r.workspaceVersioned||o.snapshots!=="versioned")throw Error("Enable versioned snapshots for this project and provider before working with a snapshot.");return t}async function Co(e){let t=au({root:e.root,project:e.project,service:e.service}),r=k(_().min(1)).min(1).max(30).parse(e.paths),o=[];for(let n of r)o.push(await cu(t,n));return su.parse({schema:1,project:e.project,service:e.service,files:o})}async function Io(e){let t=au({root:e.root,project:e.project,service:e.service}),r=iu(t,e.manifestPath),o=su.parse(zo(r));if(o.project!==e.project||o.service!==e.service)throw Error("The snapshot manifest belongs to a different project or service.");for(let n of o.files){let s=await cu(t,n.path);if(s.bytes!==n.bytes||s.sha256!==n.sha256)throw Error(`Snapshot integrity check failed for ${n.path}.`)}return{manifestPath:r,project:o.project,service:o.service,files:o.files.length}}import{closeSync as uu,constants as Ao,fstatSync as pu,lstatSync as lu,openSync as Zd,readSync as Od,realpathSync as Rd}from"node:fs";import{isAbsolute as du,join as Cd}from"node:path";var Id=262144,Ad=new Set([".aws",".git",".gnupg",".npm",".ssh","credentials","node_modules","passwords","private","processing","raw","secret","secrets"]);function hu(e){let t=e.toLowerCase(),r=t.replace(/(?:\.llm)?\.md$/,"");return t.startsWith(".env")||Ad.has(r)}function Td(e){if(du(e)||/[\\:\x00-\x1f\x7f]/.test(e))throw Error("Provide a relative path inside the project root.");let t=e.split("/");for(let r of t){if(r===""||r==="."||r==="..")throw Error("Paths must use explicit project-relative segments.");if(hu(r))throw Error(`The path crosses a protected location at "${r}".`)}return t}function fu(e,t){if(!du(e))throw Error("Provide an absolute project root.");if(!lu(e).isDirectory())throw Error("The project root must be a directory.");let r=Rd(e);if(r.split("/").filter(Boolean).some((s,i)=>(i!==0||s!=="private")&&hu(s)))throw Error("The project root crosses a protected location.");let n;for(let[s,i]of t.entries()){if(r=Cd(r,i),n=lu(r),n.isSymbolicLink())throw Error(`Symbolic links are not allowed in the project path at "${i}".`);if(s<t.length-1&&!n.isDirectory())throw Error(`Expected a directory at "${i}".`)}if(!n?.isFile())throw Error("The project path must resolve to a regular file.");return{path:r,info:n}}function Nd(e,t,r,o){let n=pu(e);if(!n.isFile()||n.ino!==t.ino||n.dev!==t.dev)throw Error("The file changed while opening. Retry after checking its path.");if(n.size>r)throw Error(`${o} source exceeds ${r} bytes. Use a narrower input.`);let s=Buffer.alloc(n.size+1),i=0;while(i<s.length){let a=Od(e,s,i,s.length-i,i);if(a===0)break;i+=a}if(i>r)throw Error(`${o} source exceeds ${r} bytes. Use a narrower input.`);let c=pu(e);if(c.size!==i||n.size!==c.size||n.mtimeMs!==c.mtimeMs||n.ctimeMs!==c.ctimeMs)throw Error("The source changed during the read. Retry with a stable file.");return s.subarray(0,i)}function jd(e,t,r,o){let n;try{n=Nd(e,t,r,o)}catch(s){try{uu(e)}catch(i){throw AggregateError([s,i],"Reading and closing the file both failed.")}throw s}return uu(e),n}function tr(e,t,r,o){try{let n=Td(t),{path:s,info:i}=fu(e,n),c=Zd(s,Ao.O_RDONLY|Ao.O_NOFOLLOW|Ao.O_NONBLOCK),a=jd(c,i,r,o),u=fu(e,n);if(u.path!==s||u.info.ino!==i.ino||u.info.dev!==i.dev)throw Error("The file path changed during the read. Retry after verifying the current path.");return new TextDecoder("utf-8",{fatal:!0}).decode(a)}catch(n){let s=n instanceof Error?n.message:String(n);throw Error(`Unable to read ${o} "${t}". ${s}`,{cause:n})}}function ht(e,t){if(!t.toLowerCase().endsWith(".md"))throw Error("Provide a relative Markdown path inside the project root.");return tr(e,t,Id,"Markdown context")}function mu(e){return e.match(/[^\n]*\n|[^\n]+$/g)??[]}function gu(e,t,r){let o=e.toLowerCase().replace(/[^\p{L}\p{M}\p{N}_\s-]/gu,"").trim().replace(/\s+/g,"-");return{title:e,level:t,line:r,locator:`line:${r}`,anchor:`#${o}`}}function Dd(e){let t=/^ {0,3}(`{3,}|~{3,})/.exec(e)?.[1];if(t)return{marker:t.charAt(0),length:t.length};return}function Fd(e,t){let r=/^ {0,3}(`{3,}|~{3,})[ \t]*$/.exec(e)?.[1];return r!==void 0&&r.startsWith(t.marker)&&r.length>=t.length}function Ld(e,t){let r=/^ {0,3}(#{1,6})[ \t]+(.*)$/.exec(e),o=r?.[1],n=r?.[2];if(o&&n){let s=n.replace(/(?:^|[ \t]+)#+[ \t]*$/,"").trim();if(s)return gu(s,o.length,t)}return}function Md(e){if(!e.trim()||/^(?: {4}|\t)/.test(e))return!1;return!/^ {0,3}(?:[>#<]|[-+*][ \t]|\d+[.)][ \t]|\[[^\]]+\]:|(?:[*_-][ \t]*){3,})/.test(e)}function yu(e){let t=[],r,o,n=!1,s=-1;if(e[0]?.trim()==="---")s=e.findIndex((i,c)=>c>0&&/^(---|\.\.\.)$/.test(i.trim()));for(let[i,c]of e.entries()){if(i<=s)continue;let a=c.replace(/\r?\n$/,""),u=i+1;if(r){if(Fd(a,r))r=void 0;continue}if(n||a.trimStart().startsWith("<!--")){n=!a.includes("-->"),o=void 0;continue}if(r=Dd(a),r){o=void 0;continue}let p=Ld(a,u);if(p){t.push(p),o=void 0;continue}let l=/^ {0,3}(=+|-+)[ \t]*$/.exec(a)?.[1];if(l&&o){let f=o.lines.join(" "),d=l.startsWith("=")?1:2;t.push(gu(f,d,o.line)),o=void 0;continue}if(!Md(a)){o=void 0;continue}if(!o)o={line:u,lines:[]};o.lines.push(a.trim())}return t}var To=_().min(1).refine((e)=>!/[\x00-\x1f\x7f]/.test(e),"Control characters are not allowed."),Wd=z({root:To.max(4096),file:To.max(4096),section:To.max(512).optional()}),xu=128,vu=16384;function Ud(e,t){let r=e.filter((n)=>{if(/^line:[1-9][0-9]*$/.test(t))return n.locator===t;if(t.startsWith("#"))return n.anchor===t;return n.title===t}),[o]=r;if(!o)throw Error(`No heading matches "${t}". List the heading index and use an exact locator.`);if(r.length>1){let n=r.slice(0,8).map((i)=>i.locator),s=r.length>n.length?", or another locator from the index":"";throw Error(`Heading "${t}" is ambiguous. Use one of ${n.join(", ")}${s}.`)}return o}function wu(e,t){if(Buffer.byteLength(e)>vu)throw Error(`Context output exceeds ${vu} bytes. ${t}`)}function _u(e){let t=Wd.parse(e),r=mu(ht(t.root,t.file)),o=yu(r);if(t.section===void 0){if(o.length>xu)throw Error(`Heading index exceeds ${xu} entries. Request a known section or use a narrower map.`);let u={kind:"index",file:t.file,headings:o};return wu(JSON.stringify(u),"Request a known section or use a narrower map."),u}let n=Ud(o,t.section),s=o.find((u)=>u.line>n.line&&u.level<=n.level),i=s?s.line-1:r.length,c=r.slice(n.line-1,i).join(""),a={kind:"section",file:t.file,heading:n,startLine:n.line,endLine:i,text:c};return wu(JSON.stringify(a),"Choose a smaller child section or a narrower map."),a}import{realpathSync as Xd}from"node:fs";import{isAbsolute as Do,normalize as Yd,relative as Qd,resolve as eh}from"node:path";var ku=q(["lines","functions","branches"]),Bd=q(["LF","LH","FNF","FNH","BRF","BRH"]),Jd={lines:{found:"LF",hit:"LH"},functions:{found:"FNF",hit:"FNH"},branches:{found:"BRF",hit:"BRH"}};function $u(e){return{source:e,summaries:new Map,lines:new Map,branches:new Map,functionNames:new Set,functionHits:new Map,groupIds:new Set,aliasHits:new Map,versionSeen:!1}}function T(e,t){let r=Number(e);if(!/^\d+$/.test(e)||!Number.isSafeInteger(r)||r<t)throw Error("Expected an integer within the supported range.");return r}function mt(e,t,r){if(e.has(t))throw Error("Duplicate coverage entry.");e.set(t,r)}function bu(e,t){if(e.has(t))throw Error("Duplicate coverage identity.");e.add(t)}function Vd(e,t){let[r,o,,n,s]=t.split(",");if(!r||!o||s!==void 0)throw Error("Expected a line number and execution count.");let i=T(r,1);if(n!==void 0)T(n,i);mt(e.lines,String(i),T(o,0)>0)}function Hd(e,t){let r=/^([^,]+),([ef]?u?\d+(?:\^\d+)?),(.+),([^,]+)$/.exec(t),o=r?.[1],n=r?.[2],s=r?.[3],i=r?.[4];if(!o||!n||!s||!i)throw Error("Expected a branch line, block, identity and hit count.");let[,c,a]=/^[ef]?u?(\d+)(?:\^(\d+))?$/.exec(n)??[];if(!c)throw Error("Expected a numeric branch block.");let u=JSON.stringify([T(o,1),T(c,0),a===void 0?null:T(a,0),/^\d+$/.test(s)?T(s,0):s]);mt(e.branches,u,i!=="-"&&T(i,0)>0)}function Kd(e,t,r){let o=t==="FN"?/^(\d+),(?:(\d+),)?(.+)$/:/^(\d+),(\d+)(?:,(\d+))?$/,[,n,s,i]=o.exec(r)??[];if(n===void 0)throw Error("Malformed function definition.");if(t==="FN"&&i){let c=T(n,1);if(s)T(s,c);bu(e.functionNames,i);return}if(t==="FNL"&&s){let c=T(s,1);if(i)T(i,c);bu(e.groupIds,String(T(n,0)));return}throw Error("Malformed function definition.")}function Gd(e,t,r){if(t==="FNDA"){let[,a,u]=/^(\d+),(.+)$/.exec(r)??[];if(!a||!u)throw Error("Expected a function hit count and name.");mt(e.functionHits,u,T(a,0)>0);return}let[,o,n,s]=/^(\d+),(\d+),(.+)$/.exec(r)??[];if(!o||!n||!s)throw Error("Expected an alias group, hit count and name.");let i=String(T(o,0)),c=e.aliasHits.get(i)??new Map;mt(c,s,T(n,0)>0),e.aliasHits.set(i,c)}function Su(e,t,r){let o=Bd.safeParse(t);if(o.success){mt(e.summaries,o.data,T(r,0));return}switch(t){case"VER":if(e.versionSeen||!r)throw Error("Expected one source version per record.");e.versionSeen=!0;return;case"DA":return Vd(e,r);case"BRDA":return Hd(e,r);case"FN":case"FNL":return Kd(e,t,r);case"FNDA":case"FNA":return Gd(e,t,r);default:throw Error("Unsupported LCOV field. Export a line, function and branch report.")}}function No(e){let t=0;for(let r of e.values())if(r)t+=1;return{found:e.size,hit:t}}function qd(e){let t=e.functionNames.size>0||e.functionHits.size>0,r=e.groupIds.size>0||e.aliasHits.size>0;if(t&&r)throw Error("Function records mix classic names and alias groups.");if(r){let o=0;if(e.groupIds.size!==e.aliasHits.size)throw Error("Missing function group or alias records.");for(let n of e.groupIds){let s=e.aliasHits.get(n);if(!s?.size)throw Error("Function group is missing execution records.");if(Array.from(s.values()).some(Boolean))o+=1}return{found:e.groupIds.size,hit:o}}if(e.functionNames.size!==e.functionHits.size)throw Error("Missing function names or execution records.");for(let o of e.functionNames)if(!e.functionHits.has(o))throw Error("A function definition has no matching execution record.");return No(e.functionHits)}function zu(e,t){let r=Jd[t],o=e.summaries.get(r.found),n=e.summaries.get(r.hit);if(o===void 0||n===void 0)throw Error(`Missing ${r.found} or ${r.hit} summary.`);let s;switch(t){case"lines":s=No(e.lines);break;case"functions":s=qd(e);break;case"branches":s=No(e.branches);break}if(s.found!==o||s.hit!==n)throw Error(`Summary ${n}/${o} differs from measured entries ${s.hit}/${s.found}.`);if(n!==o)throw Error(`Only ${n}/${o} were covered. The requirement is 100 percent.`);return s}var rr=_().min(1).max(4096).refine((e)=>!/[\x00-\x1f\x7f]/.test(e)),th=z({root:rr,file:rr,config:rr}),rh=z({files:k(rr).min(1).max(1e4),metrics:k(ku).min(1).max(3)});function jo(e){if(Do(e)||/[\\:\x00-\x1f\x7f]/.test(e)||e.split("/").some((t)=>!t||t==="."||t===".."))throw Error(`Use a project-relative source path in the coverage configuration. Received "${e}".`);return e}function Pu(e,t){let r=Qd(e,t);if(!r||r===".."||r.startsWith("../")||Do(r))return;return r}function oh(e,t,r){if(!e||/[\\:\x00-\x1f\x7f]/.test(e))throw Error("Expected a valid source path in the LCOV record.");if(Do(e)){let o=Pu(t,e)??Pu(r,e);if(o)return jo(o);throw Error("An LCOV source is outside the project root.")}return jo(Yd(e))}function nh(e,t){for(let[r,o]of t)try{let n=zu(e,r);o.found+=n.found,o.hit+=n.hit}catch(n){let s=n instanceof Error?n.message:String(n);throw Error(`${e.source} ${r}. ${s}`,{cause:n})}}function sh(e,t,r,o){let n=Xd(t),s=new Set,i=new Set,c,a=!1;for(let[p,l]of e.split(/\r?\n/).entries()){if(!l.trim()||l.startsWith("#"))continue;try{if(/[\x00-\x08\x0b-\x1f\x7f]/.test(l))throw Error("Control characters are not allowed in coverage records.");if(l.startsWith("TN:")&&!c&&!a)a=!0;else if((l.startsWith("SF:")||l.startsWith("KF:"))&&!c){let f=l.slice(3),[,d,m]=/^(\d+),(.*)$/.exec(f)??[],y=oh(m??f,t,n);if(d!==void 0){let g=Number(d);if(!Number.isSafeInteger(g)||i.has(g))throw Error("Expected a distinct safe integer source index.");i.add(g)}if(s.has(y))throw Error(`Duplicate LCOV source "${y}".`);if(!r.has(y))throw Error(`Unexpected LCOV source "${y}".`);c=$u(y),a=!1}else if(l==="end_of_record"&&c)nh(c,o),s.add(c.source),c=void 0;else if(c){let f=l.indexOf(":");if(f<1)throw Error("Malformed LCOV field.");Su(c,l.slice(0,f),l.slice(f+1))}else throw Error("Expected an LCOV source record.")}catch(f){let d=f instanceof Error?f.message:String(f);throw Error(`LCOV line ${p+1}. ${d}`,{cause:f})}}if(c||a)throw Error("The final LCOV record is incomplete.");let u=Array.from(r).filter((p)=>!s.has(p));if(u.length)throw Error(`LCOV is missing ${u.length} expected source files. First missing path is "${u[0]}".`)}function Eu(e){let t=th.parse(e),r=tr(t.root,t.config,262144,"coverage configuration"),o;try{o=rh.parse(JSON.parse(r))}catch(a){throw Error(`Invalid coverage configuration "${t.config}". Provide JSON arrays for files and metrics.`,{cause:a})}let n=new Set(o.files.map(jo)),s=new Map;for(let a of o.metrics)s.set(a,{found:0,hit:0});if(n.size!==o.files.length||s.size!==o.metrics.length)throw Error("Coverage configuration contains duplicate files or metrics.");let i=tr(t.root,t.file,16777216,"LCOV report");sh(i,eh(t.root),n,s);let c=Array.from(s,([a,u])=>{if(u.found===0)throw Error(`No measurable ${a} were found for the selected scope.`);return{metric:a,...u,percent:100}});return{file:t.file,config:t.config,sources:n.size,metrics:c}}import{lstatSync as Vu}from"node:fs";import{relative as Ju,resolve as be}from"node:path";import{lstatSync as ih,readdirSync as Ou}from"node:fs";import{basename as Zu,resolve as gt}from"node:path";var ch=pt({name:_().optional(),workspaces:uo([k(_()),pt({packages:k(_())})]).optional()}),ah=new Set(["package.json","pnpm-workspace.yaml","Cargo.toml","go.mod","pyproject.toml","Gemfile","pom.xml","composer.json"]),Ru=new Set([".git",".DS_Store",".agents",".claude",".opencode","llm","node_modules","dist","vendor"]);function uh(e){let t=C(e,"package.json");if(!t)return;try{return ch.parse(JSON.parse(t.bytes.toString("utf8")))}catch(r){throw Error(`Cannot read ${gt(e,"package.json")}. Correct the manifest and retry.`,{cause:r})}}function He(e,t){if(t===".")return e;re(t);let r=de(gt(e,t));if(!go(e,r)||r!==gt(e,t))throw Error(`Choose a real directory inside ${e}. The repository path resolves through a symbolic link: ${t}.`);if(L(r)?.root!==r)throw Error(`Choose the Git repository root at ${r} before registering it.`);return r}function ph(e){let t=Ou(e,{withFileTypes:!0});if(t.length>2048)throw Error(`Workspace discovery is limited to 2048 entries at ${e}. Choose a narrower directory.`);let r=[];for(let o of t.sort((n,s)=>n.name.localeCompare(s.name,"en"))){if(!o.isDirectory()||o.name.startsWith(".")||Ru.has(o.name))continue;let n=gt(e,o.name);if(!ih(gt(n,".git"),{throwIfNoEntry:!1}))continue;if(L(n)?.root!==n)throw Error(`The Git metadata in ${n} does not identify that checkout as a repository root.`);re(o.name),r.push({path:o.name,name:o.name,gitRoot:n})}return r}function Oe(e){let t=de(e),r=L(t),o=ph(t),n=new Set(Ou(t)),s=uh(t),i=Boolean(s?.workspaces||n.has("pnpm-workspace.yaml")||n.has("lerna.json")),c=[...ah].some((l)=>n.has(l)),a=r?{gitRoot:r.root}:{};if(o.length&&!i){let l=[...o];if(c)l.unshift({path:".",name:s?.name??Zu(t),...a});return{root:t,kind:"workspace",monorepo:i,repositories:l,...a}}let u=[...n].every((l)=>Ru.has(l)),p={path:".",name:s?.name??Zu(t),...a};return{root:t,kind:u?"blank":"existing",monorepo:i,repositories:[p],...a}}import{lstatSync as Au}from"node:fs";import{resolve as yt}from"node:path";function lh(e,t,r,o=!1){let n=`# appToolkit harness ${t} begin`,s=`# appToolkit harness ${t} end`,i=e.includes(`\r
|
|
64
64
|
`)?`\r
|
|
65
65
|
`:`
|
|
66
|
-
`,c=e.split(i),a=c.indexOf(n),u=c.indexOf(s);if(a===-1!==(u===-1)||a!==-1&&u<=a||c.lastIndexOf(n)!==a||c.lastIndexOf(s)!==u)throw Error(`The existing appToolkit local exclusion block ${t} is malformed. Repair it before retrying.`);let p=new Set(r);if(o&&a!==-1)for(let d of c.slice(a+1,u)){if(!d.startsWith("/"))throw Error(`The existing appToolkit local exclusion block ${t} contains an unsupported pattern.`);p.add(d)}let l=p.size?[n,...[...p].sort(),s]:[];if(a!==-1)return c.splice(a,u-a+1,...l),c.join(i);if(!l.length)return e;return`${e&&!e.endsWith(i)?`${e}${i}`:e}${l.join(i)}${i}`}function Fo(e,t,r,o=!1){let n=C(e.commonDirectory,e.exclude),s=n?.bytes.toString("utf8")??"";if(n&&!Buffer.from(s).equals(n.bytes))throw Error(`Cannot update the non-UTF-8 local exclusions at ${
|
|
67
|
-
`,i.mode);return{base:e,path:or,before:i,after:u}}catch(c){throw Error(`Cannot reassign the project settings in ${or}. Restore a valid settings file before retrying.`,{cause:c})}}import{lstatSync as gh}from"node:fs";import{resolve as yh}from"node:path";var Lo="<!-- apptoolkit-harness:begin -->",nr="<!-- apptoolkit-harness:end -->";function sr(e){return["AGENTS.md","CLAUDE.md",".claude/rules/apptoolkit.md"].includes(e)}function xh(e,t){let r=e.indexOf(Lo),o=e.indexOf(nr);if(r===-1&&o===-1)return;if(r<0||o<=r||e.lastIndexOf(Lo)!==r||e.lastIndexOf(nr)!==o)throw Error(`The AppToolkit router block in ${t} is malformed. Review its markers before retrying.`);let n=o+nr.length;return{prefix:e.slice(0,r),old:e.slice(r,n),suffix:e.slice(n)}}function Lu(e,t,r,o,n,s,i){let c;try{c=C(e,t)}catch(
|
|
66
|
+
`,c=e.split(i),a=c.indexOf(n),u=c.indexOf(s);if(a===-1!==(u===-1)||a!==-1&&u<=a||c.lastIndexOf(n)!==a||c.lastIndexOf(s)!==u)throw Error(`The existing appToolkit local exclusion block ${t} is malformed. Repair it before retrying.`);let p=new Set(r);if(o&&a!==-1)for(let d of c.slice(a+1,u)){if(!d.startsWith("/"))throw Error(`The existing appToolkit local exclusion block ${t} contains an unsupported pattern.`);p.add(d)}let l=p.size?[n,...[...p].sort(),s]:[];if(a!==-1)return c.splice(a,u-a+1,...l),c.join(i);if(!l.length)return e;return`${e&&!e.endsWith(i)?`${e}${i}`:e}${l.join(i)}${i}`}function Fo(e,t,r,o=!1){let n=C(e.commonDirectory,e.exclude),s=n?.bytes.toString("utf8")??"";if(n&&!Buffer.from(s).equals(n.bytes))throw Error(`Cannot update the non-UTF-8 local exclusions at ${yt(e.commonDirectory,e.exclude)}.`);let i=lh(s,t,r,o),c=i||n?W(i,n?.mode):null;if(ie(n,c))return;return{base:e.commonDirectory,path:e.exclude,before:n,after:c}}function Cu(e,t){let r=new Map,o=L(e);if(o)r.set(".",o);for(let n of t){if(n.path===".")continue;let s=yt(e,n.path);if(!Au(s,{throwIfNoEntry:!1})?.isDirectory())continue;let c=L(s);if(c?.root===s)r.set(n.path,c)}return r}function Iu(e,t){let r=[...t.keys()].filter((n)=>n!=="."&&e.startsWith(`${n}/`));r.sort((n,s)=>s.length-n.length);let o=r[0]??".";return t.get(o)}function Tu(e,t,r,o,n){let s=Cu(e,t.repositories),i=new Map,c=[],a=[];if(r){let d=Cu(e,r.repositories);for(let m of d.values())i.set(m.commonDirectory,{scope:m,patterns:new Set});for(let m of n){let y=yt(e,m),g=Iu(m,d);Pe(y,g?.root),a.push(g?{absolute:y,gitRoot:g.root}:{absolute:y})}}let u=[...t.files,{path:"llm/harness/workspace.json",versioned:t.workspaceVersioned},{path:"llm/harness/project.json",versioned:t.workspaceVersioned}],p=new Set(t.repositories.filter((d)=>!Au(yt(e,d.path),{throwIfNoEntry:!1})).map((d)=>he(d.path)));for(let d of u){if(p.has(d.path))continue;let m=Iu(d.path,s),y=yt(e,d.path);if(Pe(y,m?.root),a.push(m?{absolute:y,gitRoot:m.root}:{absolute:y}),!m)continue;let g=we(m.root,y);if(c.push({git:m,path:g,absolute:y,versioned:d.versioned}),d.versioned)continue;if(We(m,y)){o.push({path:d.path,reason:"Git already tracks this file. Choose versioned mode or separately remove it from the index before retrying."});continue}let v=i.get(m.commonDirectory)??{scope:m,patterns:new Set};v.patterns.add(er(g)),i.set(m.commonDirectory,v)}let l=[],f=t.installation??M(e).slice(0,16);for(let{scope:d,patterns:m}of i.values()){let y=Fo(d,f,m);if(y)l.push(y)}return{operations:l,checks:c,boundaries:a}}import{lstatSync as fh,readdirSync as dh}from"node:fs";import{resolve as Nu}from"node:path";var ju=4096,hh=67108864,mh=new Set([".git","node_modules","raw","processing",".npmrc"]);function Du(e){if(!e)throw Error("The release content directory is required for install and update.");let t=de(e),r=new Map,o=["."],n=0;while(o.length){let s=o.pop();if(!s)break;let i=dh(Nu(t,s),{withFileTypes:!0});for(let c of i.sort((a,u)=>a.name.localeCompare(u.name,"en"))){let a=s==="."?c.name:`${s}/${c.name}`;if(re(a),mh.has(c.name)||/^\.env(?:$|\.(?!example$))/u.test(c.name))throw Error(`The release payload includes an unsupported private path: ${a}.`);if(c.isDirectory()&&!fh(Nu(t,a)).isSymbolicLink()){if(o.length+r.size>=ju||a.split("/").length>12)throw Error(`Release content exceeds the directory limits at ${a}.`);o.push(a);continue}let u=`llm/${a}`;if(!c.isFile()||!bo(u,[]))throw Error(`The release payload includes an unsupported file: ${a}.`);let p=C(t,a);if(!p)throw Error(`The release payload changed while reading ${a}.`);if(n+=p.bytes.length,r.size>=ju||n>hh)throw Error(`The release payload exceeds the installation limits at ${a}.`);r.set(u,p)}}if(!r.has("llm/HARNESS.md"))throw Error("The release payload is missing the harness index HARNESS.md.");return r}var or="llm/harness/project.json";function Fu(e,t,r,o){let n=t.repositories.find((c)=>!r.repositories.some((a)=>a.path===c.path));if(!n)return;let s=r.repositories.find((c)=>c.identity&&c.identity===n.identity);if(!s)return;let i=C(e,or);if(!i)return;try{let c=Ee.parse(JSON.parse(i.bytes.toString("utf8")));if(!c.projects.some((p)=>p.path===n.path))return;if(c.projects.some((p)=>p.path===s.path)){o.push({path:or,reason:"Both the old and new checkout paths already have project settings. Reconcile them before registering the move."});return}let a=c.projects.map((p)=>{if(p.path===n.path)return{...p,path:s.path};return p}),u=W(`${JSON.stringify(Ee.parse({...c,projects:a}),null,2)}
|
|
67
|
+
`,i.mode);return{base:e,path:or,before:i,after:u}}catch(c){throw Error(`Cannot reassign the project settings in ${or}. Restore a valid settings file before retrying.`,{cause:c})}}import{lstatSync as gh}from"node:fs";import{resolve as yh}from"node:path";var Lo="<!-- apptoolkit-harness:begin -->",nr="<!-- apptoolkit-harness:end -->";function sr(e){return["AGENTS.md","CLAUDE.md",".claude/rules/apptoolkit.md"].includes(e)}function xh(e,t){let r=e.indexOf(Lo),o=e.indexOf(nr);if(r===-1&&o===-1)return;if(r<0||o<=r||e.lastIndexOf(Lo)!==r||e.lastIndexOf(nr)!==o)throw Error(`The AppToolkit router block in ${t} is malformed. Review its markers before retrying.`);let n=o+nr.length;return{prefix:e.slice(0,r),old:e.slice(r,n),suffix:e.slice(n)}}function Lu(e,t,r,o,n,s,i){let c;try{c=C(e,t)}catch(y){if(!(y instanceof Xt))throw y;i.push(`Preserved the existing native instructions path ${t}. Use the installed apptoolkit command to open the harness explicitly.`);return}let a=c?.bytes.toString("utf8")??"",u=n?.files.find((y)=>y.path===t)?.fragment,p=a.includes(`\r
|
|
68
68
|
`)?`\r
|
|
69
69
|
`:`
|
|
70
70
|
`,l=[Lo,r.trimEnd().replaceAll(`
|
|
71
|
-
`,p),nr].join(p),f=
|
|
72
|
-
`)}function Sh(e,t,r,o,n,s){let i=new Map;if(t.action!=="add-repo"){for(let[l,f]of Du(t.contentDirectory))i.set(l,{content:f,versioned:r.workspaceVersioned});for(let l of mo(r.hosts,r.version))i.set(l.path,{content:
|
|
71
|
+
`,p),nr].join(p),f=M(l);if(c&&!Buffer.from(a).equals(c.bytes)){s.push({path:t,reason:"The native project instructions are not UTF-8. Open the harness explicitly from the agent instead."});return}let d=xh(a,t);if(u&&!d){s.push({path:t,reason:"The previously installed router block was removed. Restore or reconcile it before updating."});return}if(d){let y=M(d.old);if(y!==u&&y!==f){s.push({path:t,reason:"The existing router block has local edits. Reconcile it before applying the release."});return}if(!u&&!o&&(d.prefix||d.suffix!==p)){i.push(`Preserved the existing ${t}. Use the installed apptoolkit command to open the harness explicitly.`);return}return{content:W(`${d.prefix}${l}${d.suffix}`,c?.mode),versioned:o,fragment:f,observed:c}}if(c&&!o){i.push(`Preserved the existing ${t} in local mode. Use the installed apptoolkit command to open the harness explicitly.`);return}let m=a;if(a&&!a.endsWith(`${p}${p}`))m=a.endsWith(p)?`${a}${p}`:`${a}${p}${p}`;return{content:W(`${m}${l}${p}`,c?.mode),versioned:o,fragment:f,observed:c}}function Mu(e,t,r,o,n){let s=new Map;if(t.hosts.includes("codex")&&gh(yh(e,"AGENTS.override.md"),{throwIfNoEntry:!1}))n.push("Codex may prioritize the existing AGENTS.override.md. Use $apptoolkit explicitly to open the harness.");for(let{path:i,content:c}of ho(t.hosts)){let p=i==="CLAUDE.md"&&r?.files.some((d)=>d.path===".claude/rules/apptoolkit.md")?".claude/rules/apptoolkit.md":i,l=[],f=Lu(e,p,c,t.workspaceVersioned,r,o,l);if(f)s.set(p,f);else if(p==="CLAUDE.md"&&!t.workspaceVersioned&&l.length){let d=Lu(e,".claude/rules/apptoolkit.md",c,!1,r,o,n);if(d)s.set(".claude/rules/apptoolkit.md",d),n.push("Claude uses .claude/rules/apptoolkit.md alongside the preserved CLAUDE.md.");else n.push(...l)}else n.push(...l)}return s}import{lstatSync as vh}from"node:fs";import{basename as wh,resolve as Wu}from"node:path";function xt(e,t){return!vh(Wu(e,t),{throwIfNoEntry:!1})}function Mo(e,t){let r=we(e,Wu(e,t));if(r!==".")re(r);return r}function Uu(e,t,r){let o=He(e,t),n=L(o);if(r&&!n)throw Error(`Cannot version files in ${o} because Git does not manage this directory.`);let s=n&&Da(n.root);return s?{path:t,versioned:r,identity:s}:{path:t,versioned:r}}function _h(e,t,r){let o=t.repository;if(!o)throw Error("Specify the directory of the Git repository to register.");let n=Mo(e,o);if(r.repositories.find((p)=>p.path===n)&&!xt(e,n))return He(e,n),r.repositories;if(xt(e,n)){let p=r.repositories.filter((f)=>wh(f.path)===o),l=p[0];if(l&&p.length===1&&!xt(e,l.path))return He(e,l.path),r.repositories}if(n===".")throw Error("Select the directory of a Git checkout inside the workspace.");let i=t.repositories.find((p)=>Mo(e,p.path)===n)?.versioned;if(i===void 0)throw Error(`Choose whether generated files inside ${n} should be versioned before registering it.`);let c=Uu(e,n,i),a=r.repositories.filter((p)=>c.identity&&p.identity===c.identity&&xt(e,p.path)),u=a[0];if(a.length>1)throw Error(`More than one missing registration matches ${n}. Resolve the ambiguous repository paths before retrying.`);return[...r.repositories.filter((p)=>p.path!==u?.path),c]}function Bu(e,t,r){let{root:o}=e;if(t.action==="add-repo"){if(!r)throw Error("Install the workspace harness before registering an additional repository.");return _h(o,t,r).sort((c,a)=>c.path.localeCompare(a.path,"en"))}let n=t.workspaceVersioned&&Boolean(e.gitRoot),s=t.repositories;if(!s.length&&r)s=r.repositories;if(!s.length&&e.kind==="workspace")throw Error("Select the repositories to register in this workspace.");if(!s.length)s=[{path:".",versioned:n}];let i=new Map;for(let c of s){let a=Mo(o,c.path);if(i.has(a))throw Error(`Repository ${a} was selected more than once.`);let u=r?.repositories.find((p)=>p.path===a);if(u&&xt(o,a))i.set(a,{...u,versioned:c.versioned});else i.set(a,Uu(o,a,c.versioned))}if(r?.repositories.some((c)=>!i.has(c.path)))throw Error("The new selection omits a registered repository. Keep the existing selection when reinstalling or updating.");return[...i.values()].sort((c,a)=>c.path.localeCompare(a.path,"en"))}import{resolve as bh}from"node:path";var kh=z({root:_().min(1),repository:_().min(1),file:_().endsWith(".llm.md")}),Wo=new WeakMap;function Uo(e){let t=kh.parse(e),r=de(t.root),o=C(r,D),n=X(r),s=n?.repositories.find((g)=>g.path===t.repository);if(!n||!s)throw Error(`Register repository ${t.repository} in the workspace before excluding generated files.`);if(s.versioned)throw Error(`Repository ${t.repository} is configured to version its generated files.`);let i=He(r,s.path),c=Yt(i,t.file),a=L(i);Pe(c,a?.root);let u={root:r,writes:[],conflicts:[]},p=[{base:r,path:D,before:o,after:o}],l=[a?{absolute:c,gitRoot:a.root}:{absolute:c}];if(!ie(o,C(r,D)))throw Error("The installation receipt changed while planning. Retry the artifact command.");if(!a)return Wo.set(u,{exclusions:[],files:[],checks:[],guards:p,boundaries:l}),u;if(We(a,c))u.conflicts.push({path:t.file,reason:"Git already tracks this file. Resolve its index status before choosing local mode."});let f=we(a.root,c),d=n.installation??M(r).slice(0,16),m=Fo(a,`${d} artifacts`,new Set([er(f)]),!0),y=m?[m]:[];if(m)u.writes.push({path:bh(m.base,m.path),before:m.before?.hash??null,after:m.after?.hash??null});return Wo.set(u,{exclusions:y,files:[],checks:[{git:a,path:f,absolute:c,versioned:!1}],guards:p,boundaries:l}),u}function Bo(e){let t=Wo.get(e);if(!t||e.conflicts.length)throw Error("Resolve the artifact conflicts and create a new plan in this process before applying.");return{changed:vo(e.root,t)}}function $h(e,t){let r=be(e,t,"llm"),o=Ju(r,be(e,"llm/HARNESS.md"));return["# Harness context","",`Start from the workspace folder at \`${Ju(be(e,t),e)||"."}\` and open the [harness index](${encodeURI(o)}).`,"Read the workspace profile and this repository’s own instructions before changing code.","Use the repository-specific settings for services, documentation conventions and validation.",""].join(`
|
|
72
|
+
`)}function Sh(e,t,r,o,n,s){let i=new Map;if(t.action!=="add-repo"){for(let[l,f]of Du(t.contentDirectory))i.set(l,{content:f,versioned:r.workspaceVersioned});for(let l of mo(r.hosts,r.version))i.set(l.path,{content:W(l.content),versioned:r.workspaceVersioned});for(let[l,f]of Mu(e,r,o,n,s))i.set(l,f);let c="llm/README.md",a=C(e,c),u=o?.files.some((l)=>l.path===c),p=W(`# LLM workspace
|
|
73
73
|
|
|
74
74
|
Open the [harness index](HARNESS.md) for workspace rules, project routing, workflows and tools.
|
|
75
|
-
`);if(!a||u||a.hash===p.hash)i.set(c,{content:p,versioned:r.workspaceVersioned})}for(let c of r.repositories){if(!Vu(be(e,c.path),{throwIfNoEntry:!1}))continue;let a=he(c.path);i.set(a,{content:
|
|
76
|
-
`,n?.mode);if(!
|
|
77
|
-
`),i=o.toLowerCase(),c=n.flatMap((l)=>{let f=/^ {0,3}#{1,6}[ \t]+(.+?)\s*$/.exec(l);return f?.[1]?[f[1].replace(/[ \t]+#+[ \t]*$/,"")]:[]}),a=new Set(n.flatMap((l)=>{let f=/^\s*[-+*]\s+\[[xX]\]\s+(.+?)\s*$/.exec(l);return f?.[1]?[f[1]]:[]})),u=[],p=-1;if(r.title&&c[0]!==r.title)u.push(`Expected the first heading to be ${r.title}.`);for(let l of r.headings){let f=c.indexOf(l,p+1);if(f<0)u.push(`Missing or out-of-order heading: ${l}.`);else p=f}for(let l of r.checkedItems)if(!a.has(l))u.push(`Checklist item must be checked: ${l}.`);for(let l of r.requiredText)if(!s.includes(l))u.push(`Required text is absent: ${l}.`);for(let[l,f]of r.forbiddenText.entries())if(i.includes(f.toLowerCase()))u.push(`Forbidden text rule ${l+1} matched.`);return{kind:r.kind,valid:u.length===0,issues:u}}import{resolve as Jo}from"node:path";import{basename as Oh,isAbsolute as Rh,relative as Ch,resolve as Ih}from"node:path";var
|
|
75
|
+
`);if(!a||u||a.hash===p.hash)i.set(c,{content:p,versioned:r.workspaceVersioned})}for(let c of r.repositories){if(!Vu(be(e,c.path),{throwIfNoEntry:!1}))continue;let a=he(c.path);i.set(a,{content:W($h(e,c.path)),versioned:c.versioned})}return i}function zh(e,t,r,o,n,s){let i=[],c=[],a=new Map(o?.files.map((l)=>[l.path,l])),u=new Set(o?.repositories.map((l)=>he(l.path))),p=new Set(r.repositories.filter((l)=>!Vu(be(e,l.path),{throwIfNoEntry:!1})).map((l)=>he(l.path)));for(let[l,{content:f,versioned:d,fragment:m,observed:y}]of t){let g=C(e,l),v=a.get(l),b=W(f.bytes,g?.mode??f.mode);if(y!==void 0&&!ie(g,y))throw Error(`The native router ${l} changed while planning. Retry the workspace command.`);if(!m&&g&&g.hash!==b.hash&&g.hash!==v?.hash)s.push({path:l,reason:"A different local file is present. Review or move it before applying this release."});else if(!ie(g,b))i.push({base:e,path:l,before:g,after:b});else c.push({base:e,path:l,before:g,after:g});r.files.push({path:l,hash:b.hash,versioned:d,...m?{fragment:m}:{}})}for(let l of a.values()){if(t.has(l.path))continue;if(sr(l.path)||p.has(l.path)||n==="add-repo"&&!u.has(l.path)){r.files.push(l);continue}let f=C(e,l.path);if(!f)continue;if(f.hash!==l.hash){s.push({path:l.path,reason:"The release retires this file, but it has local edits. Preserve the changes before updating."});continue}i.push({base:e,path:l.path,before:f,after:null})}return r.files.sort((l,f)=>l.path.localeCompare(f.path,"en")),{files:i,guards:c}}function Hu(e){let t=Ga.parse(e),r=Oe(t.root),{root:o}=r,n=C(o,D),s=X(o);if(t.action==="update"&&!s)throw Error("Install the workspace harness before updating it.");if(t.action==="install"&&s&&s.version!==t.version)throw Error(`This workspace already has harness ${s.version}. Use update to select ${t.version}.`);let i=t.action==="add-repo"&&s,c=Bu(r,t,s),a=i?s.workspaceVersioned:t.workspaceVersioned;if(a&&!r.gitRoot)throw Error(`The workspace at ${o} does not have Git. Choose local workspace mode before retrying.`);let u={schema:1,version:i?s.version:t.version,hosts:i?s.hosts:[...new Set(t.hosts)].sort(),workspaceVersioned:a,repositories:c,services:i?s.services:[...new Set(t.services)].sort(),installation:s?.installation??M(o).slice(0,16),files:[]},p=[],l=[],f=Sh(o,t,u,s,p,l),{files:d,guards:m}=zh(o,f,u,s,t.action,p);if(i){let w=Fu(o,s,u,p);if(w)d.push(w)}let y=d.filter((w)=>w.after===null).map((w)=>w.path),g=Tu(o,u,s,p,y),v=new Set(g.checks.filter((w)=>!w.versioned&&w.git.commonDirectory!==be(w.git.root,".git")).map((w)=>w.git.commonDirectory));for(let w of v)l.push(`Local Git exclusions use ${be(w,"info/exclude")}. Linked worktrees that share this Git directory use the same exclusions.`);let b=W(`${JSON.stringify(u,null,2)}
|
|
76
|
+
`,n?.mode);if(!ie(n,C(o,D)))throw Error("The installation receipt changed while planning. Retry the workspace command.");let U=ie(n,b)?[]:[{base:o,path:D,before:n,after:b}],ae=[...g.operations,...d,...U].map((w)=>({path:w.base===o?w.path:be(w.base,w.path),before:w.before?.hash??null,after:w.after?.hash??null})),Z={root:o,...r.gitRoot?{gitRoot:r.gitRoot}:{},action:t.action,writes:ae,conflicts:p,notices:l,receipt:u};return Wa(Z,{exclusions:g.operations,files:d,checks:g.checks,guards:[{base:o,path:D,before:n,after:n},...m],...U[0]?{receipt:U[0]}:{},boundaries:g.boundaries}),Z}import{parseArgs as Ph}from"node:util";var Re=q(["codex","claude","opencode"]),vt={codex:"Codex",claude:"Claude Code",opencode:"OpenCode"},Ce=q(["plane","penpot"]);function Ku(e){let t=Ph({args:e,allowPositionals:!0,options:{help:{type:"boolean",short:"h"},version:{type:"boolean",short:"v"},root:{type:"string"},json:{type:"boolean"},yes:{type:"boolean",short:"y"},plan:{type:"boolean"},hosts:{type:"string"},versioned:{type:"boolean"},local:{type:"boolean"},repo:{type:"string",multiple:!0},"repo-mode":{type:"string",multiple:!0},"repo-versioned":{type:"boolean"},"repo-local":{type:"boolean"},"enable-service":{type:"string",multiple:!0},config:{type:"string"},project:{type:"string"},"verify-read":{type:"boolean"},"verify-health":{type:"boolean"},manifest:{type:"string"},file:{type:"string",multiple:!0},section:{type:"string"}}}),{values:r}=t;if(r.versioned&&r.local||r["repo-versioned"]&&r["repo-local"])throw Error("Choose exactly one Git storage mode for each scope.");if(r.plan&&r.yes)throw Error("Choose --plan to preview or --yes to apply.");return t}function K(e,t){return _().min(1,`Supply ${t}.`).parse(e??"")}function Gu(e){let t=new Map;for(let r of e){let o=r.lastIndexOf("="),n=r.slice(0,o),s=r.slice(o+1);if(o<1||s!=="local"&&s!=="versioned"||t.has(n))throw Error(`Invalid or duplicate --repo-mode ${r}. Use <path>=local or <path>=versioned.`);t.set(n,s==="versioned")}return t}import{readFileSync as qu}from"node:fs";var Eh=z({kind:_().min(1),title:_().min(1).optional(),headings:k(_().min(1)).default([]),checkedItems:k(_().min(1)).default([]),requiredText:k(_().min(1)).default([]),forbiddenText:k(_().min(1)).default([])});function Zh(e){let t,r=[];for(let o of e.split(/\r?\n/)){let n=/^ {0,3}(`{3,}|~{3,})(.*)$/.exec(o),s=n?.[1];if(t){if(s?.startsWith(t)&&!n?.[2]?.trim())t=void 0}else if(s)t=s;else r.push(o)}return r}function Xu(e,t){let r=Eh.parse(JSON.parse(qu(e,"utf8"))),o=qu(t,"utf8"),n=Zh(o),s=n.join(`
|
|
77
|
+
`),i=o.toLowerCase(),c=n.flatMap((l)=>{let f=/^ {0,3}#{1,6}[ \t]+(.+?)\s*$/.exec(l);return f?.[1]?[f[1].replace(/[ \t]+#+[ \t]*$/,"")]:[]}),a=new Set(n.flatMap((l)=>{let f=/^\s*[-+*]\s+\[[xX]\]\s+(.+?)\s*$/.exec(l);return f?.[1]?[f[1]]:[]})),u=[],p=-1;if(r.title&&c[0]!==r.title)u.push(`Expected the first heading to be ${r.title}.`);for(let l of r.headings){let f=c.indexOf(l,p+1);if(f<0)u.push(`Missing or out-of-order heading: ${l}.`);else p=f}for(let l of r.checkedItems)if(!a.has(l))u.push(`Checklist item must be checked: ${l}.`);for(let l of r.requiredText)if(!s.includes(l))u.push(`Required text is absent: ${l}.`);for(let[l,f]of r.forbiddenText.entries())if(i.includes(f.toLowerCase()))u.push(`Forbidden text rule ${l+1} matched.`);return{kind:r.kind,valid:u.length===0,issues:u}}import{resolve as Jo}from"node:path";import{basename as Oh,isAbsolute as Rh,relative as Ch,resolve as Ih}from"node:path";var wt=new Intl.ListFormat("en"),Yu={plane:"Plane for work items",penpot:"Penpot for design"};function Ah(e,t,r){let o=e.receipt.version;if(e.action==="add-repo"){if(!e.writes.length&&!e.conflicts.length)return`Review the AppToolkit Harness registration for ${r} in ${e.root}.`;return`Register ${r} with the shared AppToolkit Harness in ${e.root}.`}if(e.action==="update"){if(t&&t.version!==o)return`Update AppToolkit Harness from ${t.version} to ${o} in ${e.root}.`;return`Update the AppToolkit Harness ${o} setup in ${e.root}.`}return`Install AppToolkit Harness ${o} in ${e.root}.`}function Th(e,t){let{workspaceVersioned:r,repositories:o}=e.receipt,n=Boolean(e.gitRoot),i=(o.length===1&&o[0]?.path==="."?o[0]:void 0)?.versioned===r,c=i?"the harness, its settings and generated project guidance":"the shared harness and its settings",a=e.action==="add-repo"?o.filter(({path:p})=>p===t):o,u=[];if(r)u.push(`Make ${c} available to commit in the workspace Git repository.`);else if(n)u.push(`Keep ${c} on this machine using local Git ignore rules.`);else u.push(`Keep ${c} in this folder outside Git.`);for(let p of a){if(i&&p.path===".")continue;let l=p.path==="."?"this project":p.path;if(p.versioned)u.push(`Make the harness files generated for ${l} available to commit.`);else if(p.path!=="."||n)u.push(`Keep the harness files generated for ${l} local using Git ignore rules.`);else u.push(`Keep the harness files generated for ${l} in the project folder outside Git.`)}if(r||a.some(({versioned:p})=>p))u.push("You decide what to stage and commit in Git.");return u}function Nh(e,t){let{services:r}=e.receipt,o=r.filter((i)=>!t?.services.includes(i)),n=r.filter((i)=>t?.services.includes(i)),s=[];if(o.length){let i=wt.format(o.map((c)=>Yu[c]));s.push(`Offer ${i} during agent setup. Each connection is configured separately.`)}if(n.length){let i=wt.format(n.map((c)=>Yu[c]));s.push(`Optional services selected for this workspace are ${i}.`)}if(!r.length)s.push("Skip the optional Plane and Penpot setup.");return s}function jh(e){let{writes:t}=e,r=t.filter(({after:f})=>f!==null),o=r.filter(({path:f})=>sr(f)),n=o.filter(({before:f})=>f===null).map(({path:f})=>f),s=o.filter(({before:f})=>f!==null).map(({path:f})=>f),i=new Set(e.receipt.repositories.map(({path:f})=>he(f))),c=new Set(["llm/HARNESS.md","llm/README.md"]),a="llm/harness/project.json",u=[],p=r.filter(({path:f})=>{let d=f.startsWith("llm/harness/")&&f!==D&&f!=="llm/harness/project.json";return c.has(f)||f.startsWith("llm/author-style/")||d});if(p.length){let f=p.every(({before:d})=>d===null)?"Add":"Refresh";u.push(`${f} shared workflows, project guidance, and tools for verification and code style in llm/.`)}if(r.some(({path:f})=>f.startsWith(".agents/")||f.startsWith(".claude/skills/")||f.startsWith(".opencode/commands/")))u.push("Set up the shortcuts your selected agents use to open the harness.");if(n.length)u.push(`Create agent guidance in ${wt.format(n)} so your agents can find the harness.`);if(s.length)u.push(`Update the harness section in ${wt.format(s)} and preserve the project guidance.`);if(r.some(({path:f})=>i.has(f)))u.push("Write project context that points agents to the shared harness and the relevant project rules.");if(r.some(({path:f})=>f==="llm/harness/project.json"))u.push("Update the saved project settings for the checkout path.");if(r.some(({path:f})=>Rh(f)))u.push("Update the local Git ignore rules for the generated harness files.");if(r.some(({path:f})=>f===D))u.push("Save the harness version and workspace choices.");if(t.some(({after:f})=>f===null))u.push("Remove harness files retired by this plan.");return u}function Dh(e,t,r){let o=e.receipt.repositories.map(({path:i})=>i),n=o.find((i)=>!t?.repositories.some((c)=>c.path===i));if(n)return n;if(!r)return"the checkout";let s=Ch(e.root,Ih(e.root,r))||".";if(o.includes(s))return s;return o.find((i)=>Oh(i)===r)??s}function Qu(e,t,r){let o=e.action==="add-repo"?Dh(e,t,r):"",n=Re.options.filter((a)=>e.receipt.hosts.includes(a)),s=wt.format(n.map((a)=>vt[a])),i=e.action==="add-repo"?[]:Nh(e,t),c=[Ah(e,t,o),`The harness will be available in ${s}.`,...Th(e,o),...i,...jh(e)];for(let a of e.notices)c.push(a);if(e.conflicts.length){c.push("Resolve these conflicts before applying the plan.");for(let{path:a,reason:u}of e.conflicts)c.push(` ${a}. ${u}`)}else if(!e.writes.length)c.push("The current setup already matches this plan.");return c}var Fh=[{label:"Keep harness files local",value:"local"},{label:"Make harness files available to commit",value:"versioned"}],ep=[{label:"No",value:"no"},{label:"Yes",value:"yes"}];async function Vo(e,t,r){if(!e)throw Error(`Supply ${r} for a noninteractive run.`);return await e(t,Fh)==="versioned"}async function Lh(e){let{options:t,selectMany:r}=e;if(t.hosts)return[...new Set(k(Re).min(1).parse(t.hosts.split(",")))];if(!r)throw Error("Supply --hosts codex,claude,opencode or a subset for a noninteractive install.");let o=Re.options.map((s)=>({label:vt[s],value:s})),n=await r("Which agent hosts should this workspace support?",o,Re.options);return k(Re).min(1).parse(n)}async function Mh(e,t){let{options:r,select:o}=e,n=Gu(r["repo-mode"]??[]),s=new Set(t.repositories.map(({path:a})=>a)),i=new Set(r.repo??[]),c=[];for(let a of[...i,...n.keys()])if(!s.has(a))throw Error(`No repository was detected at ${a}. Inspect the workspace for accepted relative paths.`);for(let a of t.repositories){if(i.size&&!i.has(a.path))continue;if(t.kind==="workspace"&&o&&!i.size&&!n.has(a.path)){if(await o(`Register ${a.path}?`,[{label:"Register",value:"yes"},{label:"Skip",value:"no"}])==="no")continue}let u=`--repo-mode ${a.path}=local or ${a.path}=versioned`,p=a.gitRoot?n.get(a.path)??await Vo(o,`Version files generated inside ${a.path}?`,u):!1;c.push({path:a.path,versioned:p})}if(t.kind==="workspace"&&c.length===0)throw Error("Select at least one repository for the shared workspace.");return c}async function Wh(e){let{root:t,options:r,select:o,emit:n}=e,s=Oe(t);if(!r.json){let p={blank:"an empty project",existing:"an existing project",workspace:"a parent workspace"};n(`Detected ${s.monorepo?"a monorepo":p[s.kind]} at ${s.root}.`)}let i=await Lh(e),c=s.gitRoot?r.versioned||!r.local&&await Vo(o,"Version the central harness with this Git repository?","--local or --versioned"):!1;if(r.versioned&&!s.gitRoot)throw Error("The workspace root has no Git repository. Use --local.");let a=await Mh(e,s),u=k(Ce).parse(r["enable-service"]??[]);if(o&&!r["enable-service"]){for(let p of Ce.options)if(await o(`Offer ${p==="plane"?"Plane for agent work items":"Penpot for design"} during setup?`,ep)==="yes")u.push(p)}return{hosts:i,workspaceVersioned:c,repositories:a,services:[...new Set(u)]}}function Uh(e){let t=X(e);if(!t)throw Error(`No harness is registered at ${e}. Run install first.`);return{hosts:t.hosts,workspaceVersioned:t.workspaceVersioned,repositories:t.repositories,services:t.services}}async function tp(e,t,r){let{root:o,version:n,options:s,emit:i,select:c,contentDirectory:a}=e;if(!a&&t!=="add-repo")throw Error("Run this command from a release package. Use bunx @apptoolkit/harness@latest update for an installed workspace.");let u=X(o),p=t==="install"&&!u?await Wh(e):Uh(o),l;if(t==="update"&&s["enable-service"]){let y=k(Ce).parse(s["enable-service"]);p.services=[...new Set([...p.services,...y])]}if(t==="add-repo"){l=K(r,"the checkout path");let y=Jo(o,l),g=p.repositories.find(({path:b})=>Jo(o,b)===y),v=s["repo-versioned"]||(s["repo-local"]?!1:g?.versioned??await Vo(c,`Version files generated inside ${l}?`,"--repo-local or --repo-versioned"));p.repositories=[...p.repositories.filter(({path:b})=>Jo(o,b)!==y),{path:l,versioned:v}]}let f=Hu({root:o,action:t,version:n,contentDirectory:a??"",...p,...l?{repository:l}:{}}),d={action:t,root:f.root,writes:f.writes.map(({path:y,before:g,after:v})=>({path:y,effect:v===null?"remove":g===null?"create":"update",before:g,after:v})),conflicts:f.conflicts,notices:f.notices};if(!s.json)for(let y of Qu(f,u,l))i(y);if(s.plan||!s.yes&&!c){if(s.json)i(d);return f.conflicts.length?1:0}if(f.conflicts.length){if(s.json)i(d);throw Error("Resolve the reported installation conflicts before applying the plan.")}if(!s.yes&&f.writes.length&&c&&await c("Apply this plan?",ep)!=="yes")return 0;let m=wo(f);if(s.json)i({...d,changed:m.changed,version:m.receipt.version,hosts:m.receipt.hosts});else if(i(`Applied ${m.changed} change(s) for @apptoolkit/harness ${m.receipt.version}.`),t==="install"){i(`Open ${f.root} in your selected agent host.`);for(let y of m.receipt.hosts)i(` ${vt[y]}: ${y==="codex"?"$":"/"}apptoolkit init`)}return 0}var rm=`@apptoolkit/harness 1.0.4
|
|
78
78
|
|
|
79
79
|
install Inspect and prepare a project or workspace
|
|
80
80
|
inspect Report workspace topology and installation state
|
|
@@ -97,8 +97,8 @@ Install options: --hosts codex,claude,opencode --local | --versioned
|
|
|
97
97
|
Add options: --repo-local | --repo-versioned
|
|
98
98
|
Service options: --project <repo> --verify-health --verify-read --manifest <file> | --file <export>
|
|
99
99
|
Use --plan to preview. Noninteractive workspace changes require --yes and explicit choices.
|
|
100
|
-
`;function om(){return tm(new URL("./payload/",import.meta.url))}function nm(e,t){if(t==="list")return
|
|
101
|
-
`),0;if(e.help||!r)return process.stdout.write(rm),0;let i=cr(e.root??process.cwd()),c=(
|
|
102
|
-
`);else process.stdout.write(`${JSON.stringify(
|
|
103
|
-
`)};if(r==="inspect"&&!o){let
|
|
100
|
+
`;function om(){return tm(new URL("./payload/",import.meta.url))}function nm(e,t){if(t==="list")return ht(e,"llm/harness/WORKFLOWS.md");let r=_().regex(/^W(?:0[1-9]|[12][0-9]|3[0-7])$/,"Choose W01 through W37 or list.").parse(t??""),o=ht(e,`llm/harness/workflows/${r}.md`);if(Buffer.byteLength(o)>32768)throw Error(`Workflow ${r} is larger than 32 KiB. Use context to read a section.`);return o}async function sm(){let{values:e,positionals:t}=Ku(process.argv.slice(2)),[r,o,n,s]=t;if(e.version)return process.stdout.write(`1.0.4
|
|
101
|
+
`),0;if(e.help||!r)return process.stdout.write(rm),0;let i=cr(e.root??process.cwd()),c=(g)=>{if(typeof g==="string")process.stdout.write(`${g.trimEnd()}
|
|
102
|
+
`);else process.stdout.write(`${JSON.stringify(g,null,2)}
|
|
103
|
+
`)};if(r==="inspect"&&!o){let g=Oe(i),v=X(g.root),U=(v?Ze(g.root):void 0)?.projects.map(({path:ae,budget:Z,services:w})=>({path:ae,budget:Z.mode,services:w.map(({provider:G})=>G)}))??[];return c({...g,installation:v??null,configuredProjects:U}),0}if(r==="init"&&!o){if(!e.config)return c(await Po(i)),0;if(e.plan)throw Error("Use init without --config to read the setup template. Applying a configuration requires a separate invocation.");return c(await Eo({root:i,configPath:cr(e.config)})),0}if(r==="workflow"&&!n){let g=nm(i,o);return c(e.json?{id:o,document:g}:g),0}if(r==="context"&&!n){let g=K(o,"the workspace-relative Markdown path");return c(_u({root:i,file:g,...e.section?{section:e.section}:{}})),0}if(r==="verify"&&o==="document"&&!s){let g=cr(K(e.config,"--config <policy.json>")),v=cr(K(n,"the document path")),b=Xu(g,v);return c(b),b.valid?0:1}if(r==="verify"&&o==="coverage"&&!s){let g=K(n,"the workspace-relative LCOV report"),v=K(e.config,"--config <coverage-policy.json>");return c(Eu({root:i,file:g,config:v})),0}if(r==="protect"&&!n){let g=K(e.project,"--project <repo>"),v=K(o,"the repository-relative source map path"),b=Uo({root:i,repository:g,file:v});if(e.yes&&!b.conflicts.length)c({...b,...Bo(b)});else c(b);return b.conflicts.length?1:0}if(r==="service"&&o==="status"&&!s){let g=Ce.parse(n),v=K(e.project,"--project <repo>");return c(await Ro({root:i,service:g,project:v,verifyRead:e["verify-read"]??!1,verifyHealth:e["verify-health"]??!1})),0}if(r==="service"&&o==="snapshot"&&!s){let g=Ce.parse(n),v=K(e.project,"--project <repo>"),b=e.file??[];if(b.length&&e.manifest)throw Error("Choose --file to prepare a manifest or --manifest to verify it.");if(b.length)c(await Co({root:i,service:g,project:v,paths:b}));else{let U=K(e.manifest,"--manifest <snapshot.json>");c(await Io({root:i,service:g,project:v,manifestPath:U}))}return 0}let a=r==="add"&&o==="repo"&&!s,u=r==="install"&&!o;if(!a&&!u&&!(r==="update"&&!o))throw Error("Unknown command or arguments. Run with --help for usage.");let f=process.stdin.isTTY&&!e.json&&!e.plan&&!e.yes?await Promise.resolve().then(() => (np(),op)):void 0,d={root:i,version:"1.0.4",options:e,emit:c},m={contentDirectory:om()},y=f?{select:f.selectChoice,selectMany:f.selectMany}:{};return tp({...d,...m,...y},a?"add-repo":u?"install":"update",n)}try{process.exitCode=await sm()}catch(e){let t=e instanceof Error?e.message:String(e);process.stderr.write(`apptoolkit: ${t}
|
|
104
104
|
`),process.exitCode=1}
|