@tripwire-sh/cli 0.1.7 → 0.1.8

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.
Files changed (2) hide show
  1. package/dist/tripwire.js +1 -1
  2. package/package.json +1 -1
package/dist/tripwire.js CHANGED
@@ -225,7 +225,7 @@ ${t.join(`
225
225
  }
226
226
  `)}return y.write("payload.value = newResult;"),y.write("return payload;"),y.compile()},i,a=co,c=!rt.jitless,l=c&&Jw.value,d=t.catchall,f;e._zod.parse=(m,h)=>{f??(f=n.value);let g=m.value;if(!a(g))return m.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),m;if(c&&l&&h?.async===!1&&h.jitless!==!0){if(!i)i=s(t.shape);if(m=i(m,h),!d)return m;return iv([],g,m,h,f,e,h?.abortEarly===!0)}return r(m,h)}});function f_(e,t,r,n){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let o=e.filter((s)=>!Pt(s));if(o.length===1)return t.value=o[0].value,o[0];return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map((s)=>s.issues.map((i)=>er(i,n,at())))}),t}var bp=O("$ZodUnion",(e,t)=>{fe.init(e,t),re(e,"optin",(n)=>n.def.options.some((o)=>o._zod.optin==="defaulted")?"defaulted":n.def.options.some((o)=>o._zod.optin!==void 0)?"optional":void 0),re(e,"optout",(n)=>n.def.options.some((o)=>o._zod.optout==="optional")?"optional":void 0),re(e,"values",(n)=>{if(n.def.options.every((o)=>o._zod.values))return new Set(n.def.options.flatMap((o)=>Array.from(o._zod.values)));return}),re(e,"pattern",(n)=>{if(n.def.options.every((o)=>o._zod.pattern)){let o=n.def.options.map((s)=>s._zod.pattern);return new RegExp(`^(${o.map((s)=>Fr(s.source)).join("|")})$`)}return});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,o)=>{if(r)return r(n,o);let s=!1,i=[];for(let a of t.options){let c=a._zod.run({value:n.value,issues:[]},o);if(c instanceof Promise)i.push(c),s=!0;else{if(c.issues.length===0)return c;i.push(c)}}if(!s)return f_(i,n,e,o);return Promise.all(i).then((a)=>f_(a,n,e,o))}});function lL(e){let t=new Map;for(let r of e.options){let n=r._zod.propValues?.[e.discriminator];if(!n||n.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(r)}"`);for(let o of n)if(t.has(o)){if(o!==void 0)throw Error(`Duplicate discriminator value "${String(o)}"`);t.set(o,null)}else t.set(o,r)}return t}var cv=O("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,bp.init(e,t);let r=e._zod.parse;re(e,"propValues",(o)=>{let s={},i=0;for(let a of o.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw Error(`Invalid discriminated union option at index "${o.def.options.indexOf(a)}"`);if(c[o.def.discriminator]?.has(void 0))i++;for(let[u,l]of Object.entries(c)){if(!Object.prototype.hasOwnProperty.call(s,u))bt(s,u,new Set);for(let d of l)s[u].add(d)}}if(!o.def.unionFallback&&i>1)s[o.def.discriminator]?.delete(void 0);return s}),t.options.forEach((o,s)=>{let i=Ps(o._zod.def);if(i&&!Object.prototype.hasOwnProperty.call(i,t.discriminator))throw Error(`Invalid discriminated union option at index "${s}"`)});let n=Es(()=>lL(t));e._zod.parse=(o,s)=>{let i=o.value;if(!co(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),o;let a=i?.[t.discriminator],c=n.value.get(a);if(c&&(a!==void 0||s.direction!=="backward"))return c._zod.run(o,s);if(t.unionFallback||s.direction==="backward")return r(o,s);return o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(n.value.keys()).filter((u)=>n.value.get(u)!==null),input:i,path:[t.discriminator],inst:e}),o}}),uv=O("$ZodIntersection",(e,t)=>{fe.init(e,t),e._zod.parse=(r,n)=>{let o=r.value,s=t.left._zod.run({value:o,issues:[]},n),i=t.right._zod.run({value:o,issues:[]},n);if(s instanceof Promise||i instanceof Promise)return Promise.all([s,i]).then(([c,u])=>m_(r,c,u));return m_(r,s,i)}});function mp(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(Rn(e)&&Rn(t)){let r=Object.keys(t),n=Object.keys(e).filter((s)=>r.indexOf(s)!==-1),o={...e,...t};if(Object.prototype.hasOwnProperty.call(o,"__proto__"))delete o.__proto__;for(let s of n){if(s==="__proto__")continue;let i=mp(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let o=e[n],s=t[n],i=mp(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function m_(e,t,r){let n=new Map,o,s=new Map,i=(u,l)=>{let d;if(u.code==="unrecognized_keys"&&!u.path?.length)o??(o=u),d=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);d=[f]}else return!1;for(let f of d){if(!n.has(f))n.set(f,{});n.get(f)[l]=!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 a=[...n].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(a.length){let u=o?a.filter((l)=>o.keys.includes(l)):[];if(u.length)e.issues.push({...o,keys:u});for(let l of a)if(!u.includes(l)&&s.has(l))e.issues.push(s.get(l))}let c=mp(t.value,r.value);if(!c.valid){if(Pt(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var lv=O("$ZodTuple",(e,t)=>{fe.init(e,t);let r=t.items,n=rt.memoizer;n?.attach(e),e._zod.parse=(o,s)=>{let i=o.value;if(!Array.isArray(i))return o.issues.push({input:i,inst:e,expected:"tuple",code:"invalid_type"}),o;o.value=n?n.alloc(e,o,[],s):[];let a=[],c=h_(r,"optin"),u=h_(r,"optout");if(!t.rest){if(i.length<c)return o.issues.push({code:"too_small",minimum:c,inclusive:!0,input:i,inst:e,origin:"array"}),o;if(i.length>r.length)o.issues.push({code:"too_big",maximum:r.length,inclusive:!0,input:i,inst:e,origin:"array"})}let l=Array(r.length),d=t.rest?s?.abortEarly:void 0,f=!1;for(let m=0;m<r.length;m++){let h=r[m]._zod.run({value:i[m],issues:[]},s);if(h instanceof Promise)a.push(h.then((g)=>{l[m]=g}));else if(l[m]=h,d&&!f&&h.issues.length)f=Pt(h)}if(t.rest&&!f){let m=r.length-1,h=i.slice(r.length),g=o.issues.length;for(let y of h){if(d&&o.issues.length!==g){if(Pt(o,g))break;g=o.issues.length}m++;let b=t.rest._zod.run({value:y,issues:[]},s);if(b instanceof Promise)a.push(b.then((T)=>g_(T,o,m)));else g_(b,o,m)}}if(a.length)return Promise.all(a).then(()=>y_(l,o,r,i,u));return y_(l,o,r,i,u)}});function h_(e,t){for(let r=e.length-1;r>=0;r--)if(!(t==="optin"?e[r]._zod.optin!==void 0:e[r]._zod.optout==="optional"))return r+1;return 0}function g_(e,t,r){if(e.issues.length)t.issues.push(...Qt(r,e.issues));t.value[r]=e.value}function y_(e,t,r,n,o){for(let s=0;s<r.length;s++){let i=e[s],a=s<n.length;if(!a&&s>=o&&r[s]._zod.optin==="optional"){t.value.length=s;break}if(i.issues.length){if(!a&&s>=o){t.value.length=s;break}t.issues.push(...Qt(s,i.issues))}t.value[s]=i.value}for(let s=t.value.length-1;s>=n.length;s--)if(r[s]._zod.optout==="optional"&&t.value[s]===void 0)t.value.length=s;else break;return t}var dv=O("$ZodRecord",(e,t)=>{fe.init(e,t);let r=rt.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!Rn(s))return n.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),n;let i=[],a=t.keyType._zod.values;if(a&&!t.partial){n.value=r?r.alloc(e,n,{},o):{};let c=new Set;for(let l of a)if(typeof l==="string"||typeof l==="number"||typeof l==="symbol"){if(c.add(typeof l==="number"?l.toString():l),l==="__proto__")continue;let d=t.keyType._zod.run({value:l,issues:[]},o);if(d instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(d.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map((h)=>er(h,o,at())),input:l,path:[l],inst:e});continue}let f=d.value;if(f==="__proto__")continue;let m=t.valueType._zod.run({value:s[l],issues:[]},o);if(m instanceof Promise)i.push(m.then((h)=>{if(h.issues.length)n.issues.push(...Qt(l,h.issues));n.value[f]=h.value}));else{if(m.issues.length)n.issues.push(...Qt(l,m.issues));n.value[f]=m.value}}let u;for(let l in s)if(!c.has(l))if(t.mode==="loose"){if(l==="__proto__")continue;n.value[l]=s[l]}else u=u??[],u.push(l);if(u&&u.length>0)n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:u,continue:!0})}else{n.value=r?r.alloc(e,n,{},o):{};let c;for(let u of Reflect.ownKeys(s)){if(u==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(s,u))continue;let l=t.keyType._zod.run({value:u,issues:[]},o);if(l instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof u==="string"&&uo.test(u)&&l.issues.length){let h=t.keyType._zod.run({value:Number(u),issues:[]},o);if(h instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(h.issues.length===0)l=h}if(l.issues.length){if(t.mode==="loose")n.value[u]=s[u];else if(a)c=c??[],c.push(u);else n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map((h)=>er(h,o,at())),input:u,path:[u],inst:e});continue}let f=l.value;if(f==="__proto__")continue;let m=t.valueType._zod.run({value:s[u],issues:[]},o);if(m instanceof Promise)i.push(m.then((h)=>{if(h.issues.length)n.issues.push(...Qt(u,h.issues));n.value[f]=h.value}));else{if(m.issues.length)n.issues.push(...Qt(u,m.issues));n.value[f]=m.value}}if(c&&c.length>0)n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}if(i.length)return Promise.all(i).then(()=>n);return n}});var pv=O("$ZodEnum",(e,t)=>{fe.init(e,t);let r=$s(t.entries),n=new Set(r);e._zod.values=n,re(e,"pattern",(o)=>{let s=$s(o.def.entries).filter((i)=>Yw.has(typeof i));return new RegExp(s.length?`^(${s.map((i)=>Tr(i.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,s)=>{let i=o.value;if(n.has(i))return o;return o.issues.push({code:"invalid_value",values:r,input:i,inst:e}),o}}),fv=O("$ZodLiteral",(e,t)=>{fe.init(e,t);let r=new Set(t.values);e._zod.values=r,re(e,"pattern",(n)=>{let o=n.def.values;return new RegExp(o.length?`^(${o.map((s)=>typeof s==="string"?Tr(s):s?Tr(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(n,o)=>{let s=n.value;if(r.has(s))return n;return n.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),n}});var mv=O("$ZodTransform",(e,t)=>{fe.init(e,t),e._zod.optin="optional",rt.memoizer?.guard(e),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Os(e.constructor.name);let o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then((i)=>(r.value=i,r));if(o instanceof Promise)throw new tr;return r.value=o,r}});function w_(e,t){return e.value=t.issues.length?void 0:t.value,e}var _p=O("$ZodOptional",(e,t)=>{fe.init(e,t),re(e,"optin",(r)=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",re(e,"values",(r)=>{let n=r.def.innerType._zod.values;return n?new Set([...n,void 0]):void 0}),re(e,"pattern",(r)=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${Fr(n.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(r.value===void 0){if(t.innerType._zod.optin!=="defaulted")return r;let o=t.innerType._zod.run({value:r.value,issues:[]},n);if(o instanceof Promise)return o.then((s)=>w_(r,s));return w_(r,o)}return t.innerType._zod.run(r,n)}}),hv=O("$ZodExactOptional",(e,t)=>{_p.init(e,t),re(e,"values",(r)=>r.def.innerType._zod.values),re(e,"pattern",(r)=>r.def.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),gv=O("$ZodNullable",(e,t)=>{fe.init(e,t),re(e,"optin",(r)=>r.def.innerType._zod.optin),re(e,"optout",(r)=>r.def.innerType._zod.optout),re(e,"pattern",(r)=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${Fr(n.source)}|null)$`):void 0}),re(e,"values",(r)=>r.def.innerType._zod.values?new Set([...r.def.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>{if(r.value===null)return r;return t.innerType._zod.run(r,n)}}),yv=O("$ZodDefault",(e,t)=>{fe.init(e,t),e._zod.optin="defaulted",re(e,"values",(r)=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then((s)=>b_(s,t));return b_(o,t)}});function b_(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var wv=O("$ZodPrefault",(e,t)=>{fe.init(e,t),e._zod.optin="defaulted",re(e,"values",(r)=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)r.value=t.defaultValue;return t.innerType._zod.run(r,n)}}),bv=O("$ZodNonOptional",(e,t)=>{fe.init(e,t),re(e,"values",(r)=>{let n=r.def.innerType._zod.values;return n?new Set([...n].filter((o)=>o!==void 0)):void 0}),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then((s)=>__(s,e));return __(o,e)}});function __(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 v_(e,t,r,n){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((o)=>er(o,n,at()))},input:e.value}),e}var _v=O("$ZodCatch",(e,t)=>{fe.init(e,t),re(e,"optin",(r)=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),re(e,"optout",(r)=>r.def.innerType._zod.optout),re(e,"values",(r)=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run({value:r.value,issues:[]},n);if(o instanceof Promise)return o.then((s)=>v_(r,s,t,n));return v_(r,o,t,n)}});var vp=O("$ZodPipe",(e,t)=>{fe.init(e,t),re(e,"values",(r)=>r.def.in._zod.values),re(e,"optin",(r)=>r.def.in._zod.optin),re(e,"optout",(r)=>r.def.out._zod.optout),re(e,"propValues",(r)=>r.def.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){let s=t.out._zod.run(r,n);if(s instanceof Promise)return s.then((i)=>Za(i,t.in,n));return Za(s,t.in,n)}let o=t.in._zod.run(r,n);if(o instanceof Promise)return o.then((s)=>Za(s,t.out,n));return Za(o,t.out,n)}});function Za(e,t,r){if(e.issues.some((n)=>n.code!=="unrecognized_keys"))return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},r)}var vv=O("$ZodPreprocess",(e,t)=>{vp.init(e,t)}),Sv=O("$ZodReadonly",(e,t)=>{fe.init(e,t),re(e,"propValues",(r)=>r.def.innerType._zod.propValues),re(e,"values",(r)=>r.def.innerType._zod.values),re(e,"optin",(r)=>r.def.innerType?._zod?.optin),re(e,"optout",(r)=>r.def.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then(S_);return S_(o)}});function S_(e){if(!e.memo)e.value=Object.freeze(e.value);return e}function dL(e){let t=e._zod.def,r=t.pattern,n=!!t.format?.includes("int"),o,s;for(let a of t.checks??[]){let c=a._zod.def;if(c.pattern)r=c.pattern;n||(n=!!c.format?.includes("int"));let u=c.minimum??c.length,l=c.maximum??c.length;if(u!==void 0&&(o===void 0||u>o))o=u;if(l!==void 0&&(s===void 0||l<s))s=l}if(r)return r.source;if(o!==void 0&&s!==void 0&&o>s)return"(?!)";if(o!==void 0||s!==void 0)return Bb({minimum:o,maximum:s}).source;let i=e._zod.pattern;return(n&&i===uo?Wa:i)?.source}function hp(e){let t=e._zod.def,r=e._zod.pattern?.source,n=t.innerType??e._zod.innerType;if(n){let o=n._zod.pattern?.source,s=hp(n);if(r&&o&&s&&s!==o)return r.replace(Fr(o),()=>Fr(s));return r}if(t.options){let o=t.options.map(hp);if(o.every(Boolean))return`^(${o.map((s)=>Fr(s)).join("|")})$`}return dL(e)}var kv=O("$ZodTemplateLiteral",(e,t)=>{fe.init(e,t);let r=[];for(let n of t.parts)if(typeof n==="object"&&n!==null){let o=hp(n);if(!o)throw Error(`Invalid template literal part, no pattern found: ${[...n._zod.traits].shift()}`);r.push(Fr(o))}else if(n===null||Xw.has(typeof n))r.push(Tr(`${n}`));else throw Error(`Invalid template literal part: ${n}`);e._zod.pattern=new RegExp(`^${r.join("")}$`),e._zod.parse=(n,o)=>{if(typeof n.value!=="string")return n.issues.push({input:n.value,inst:e,expected:"string",code:"invalid_type"}),n;if(e._zod.pattern.lastIndex=0,!e._zod.pattern.test(n.value))return n.issues.push({input:n.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),n;return n}});var xv=O("$ZodLazy",(e,t)=>{fe.init(e,t),Zw(e._zod,"innerType",()=>{let r=t;if(!r._cachedInner)r._cachedInner=t.getter();return r._cachedInner}),re(e,"pattern",(r)=>r.innerType?._zod?.pattern),re(e,"propValues",(r)=>r.innerType?._zod?.propValues),re(e,"optin",(r)=>r.innerType?._zod?.optin??void 0),re(e,"optout",(r)=>r.innerType?._zod?.optout??void 0),e._zod.parse=(r,n)=>e._zod.innerType._zod.run(r,n)}),$v=O("$ZodCustom",(e,t)=>{He.init(e,t),fe.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=(r)=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then((s)=>k_(s,r,n,e));k_(o,r,n,e);return}});function k_(e,t,r,n){if(!e){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};if(n._zod.def.params)o.params=n._zod.def.params;t.issues.push(Cn(o))}}class Ev extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var kp="~memo",Tv=[];function Pv(e){return e!==null&&typeof e==="object"}function Sp(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var Ov=new WeakMap,Rs=0,Xa=1,Cs=2;function Qa(e,t,r){let n=Ov.get(e);if(n!==void 0)return n?Cs:Rs;if(t.has(e))return Cs;t.add(e);let o=Rs,s=(l)=>{if(o!==Cs&&l?._zod){let d=Qa(l,t,r);if(d>o)o=d}},i=(l,d)=>{let f=Rs;for(let m of Reflect.ownKeys(l)){let h=Object.getOwnPropertyDescriptor(l,m);if(d&&!h.enumerable)continue;let g=h.get?Xa:h.value?._zod?Qa(h.value,t,r):Rs;if(g>f)f=g}return f},a=(l)=>{if(l>o)o=l},c=e._zod.def,u=c.type;switch(u){case"object":{let l=Ps(c);a(l?i(l,!0):Xa),s(c.catchall);break}case"array":s(c.element);break;case"tuple":for(let l of c.items)s(l);s(c.rest);break;case"record":case"map":s(c.keyType),s(c.valueType);break;case"set":s(c.valueType);break;case"union":for(let l of c.options)s(l);break;case"intersection":s(c.left),s(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(c.innerType);break;case"pipe":s(c.in),s(c.out);break;case"function":s(c.input),s(c.output);break;case"lazy":{let l=c._cachedInner??(r?e._zod.innerType:void 0);a(l?Qa(l,t,!1):Xa);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 l in c){let d=Object.getOwnPropertyDescriptor(c,l);if(!d||d.get)continue;let f=d.value;if(!f||typeof f!=="object")continue;if(f._zod)s(f);else if(Array.isArray(f))for(let m of f)s(m)}}return t.delete(e),pL(e,o)}function pL(e,t){if(t!==Xa)Ov.set(e,t===Cs);return t}function fL(e,t){let r=e.buckets.get(t);if(!r)r=new WeakMap,e.buckets.set(t,r);return r}var Ja,Ya=[],mL={alloc(e,t,r){let n=Ja;if(!n)return r;Ja=void 0;let o={value:r,issues:null};return n.set(t.value,o),Ya.push(o),r},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let r=e._zod.parse,n=(o,s)=>{if(s.direction!=="backward"&&hL(s,o.value))throw new Ev;return r(o,s)};if(e._zod.parse=n,e._zod.run===r)e._zod.run=n})},attach(e){var t;let r,n=!1,o,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let i=e._zod.parse,a=(c,u)=>{if(r===void 0){let b=Qa(e,new Set,!1);if(b===Rs){if(e._zod.parse=i,e._zod.run===a)e._zod.run=i;return i(c,u)}if(b===Cs||n)r=!0;else n=!0}let l=c.value;if(!Pv(l))return i(c,u);let d=u[kp];if(!d)d={buckets:new WeakMap,backEdges:void 0},u[kp]=d;let f;if(o===u)f=s;else f=fL(d,e),o=u,s=f;let m=f.get(l);if(m){if(c.value=m.value,m.issues){if(m.issues.length)c.issues.push(...Sp(m.issues))}else c.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(m.value);return c}Ja=f;let h=Ya.length,g=i(c,u);Ja=void 0;let y=Ya.length>h?Ya.pop():void 0;if(g instanceof Promise)return g.then((b)=>{if(y)y.issues=b.issues.length?Sp(b.issues):Tv;return b});if(y)y.issues=g.issues.length?Sp(g.issues):Tv;return g};if(e._zod.parse=a,e._zod.run===i)e._zod.run=a})}};function xp(){return mL}function hL(e,t){let r=e[kp]?.backEdges;return r!==void 0&&Pv(t)&&r.has(t)}var gL=()=>{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"},n={nan:"NaN"};function o(s,i){if(s==="number"&&typeof i==="number"&&!Number.isFinite(i))return String(i);return n[s]??s}return(s)=>{switch(s.code){case"invalid_type":{let i=o(s.expected),a=nb(s.input),c=o(a,s.input);return`Invalid input: expected ${i}, received ${c}`}case"invalid_value":if(s.values.length===1)return`Invalid input: expected ${Xd(s.values[0])}`;return`Invalid option: expected one of ${Gd(s.values,"|")}`;case"too_big":{let i=s.exact?"exactly ":s.inclusive?"<=":"<",a=t(s.origin);if(a)return`Too big: expected ${s.origin??"value"} to have ${i}${s.maximum.toString()} ${a.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?">=":">",a=t(s.origin);if(a)return`Too small: expected ${s.origin} to have ${i}${s.minimum.toString()} ${a.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":""}: ${Gd(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((a)=>`'${a}'`).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 $p(){return{localeError:gL()}}var Iv;class Av{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 n={...r,...this._map.get(e)};return Object.keys(n).length?n:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function Rv(){return new Av}(Iv=globalThis).__zod_globalRegistry??(Iv.__zod_globalRegistry=Rv());var Ur=globalThis.__zod_globalRegistry;function Tp(e){if(e.checks)e.checks=[...e.checks];return e}function Cv(e,t){return new e(Tp({type:"string",...U(t)}))}function zv(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...U(t)})}function Nv(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...U(t)})}function Lv(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...U(t)})}function jv(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...U(t)})}function Dv(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...U(t)})}function Mv(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...U(t)})}function Ep(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...U(t)})}function qv(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...U(t)})}function Fv(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...U(t)})}function Uv(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...U(t)})}function Wv(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...U(t)})}function Vv(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...U(t)})}function Zv(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...U(t)})}function Bv(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...U(t)})}function Kv(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...U(t)})}function Hv(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...U(t)})}function Gv(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...U(t)})}function Jv(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...U(t)})}function Yv(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...U(t)})}function Xv(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...U(t)})}function Qv(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...U(t)})}function eS(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...U(t)})}function ec(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...U(t)})}function tc(e,t){return new e({type:"string",format:"date",check:"string_format",...U(t)})}function rc(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...U(t)})}function nc(e,t){return new e({type:"string",format:"duration",check:"string_format",...U(t)})}function tS(e,t){return new e(Tp({type:"number",checks:[],...U(t)}))}function rS(e,t){return new e(Tp({type:"number",coerce:!0,checks:[],...U(t)}))}function nS(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...U(t)})}function oS(e,t){return new e({type:"boolean",...U(t)})}function sS(e,t){return new e({type:"null",...U(t)})}function iS(e){return new e({type:"any"})}function aS(e){return new e({type:"unknown"})}function cS(e,t){return new e({type:"never",...U(t)})}function oc(e,t){return new dp({check:"less_than",...U(t),value:e,inclusive:!1})}function zs(e,t){return new dp({check:"less_than",...U(t),value:e,inclusive:!0})}function sc(e,t){return new pp({check:"greater_than",...U(t),value:e,inclusive:!1})}function Ns(e,t){return new pp({check:"greater_than",...U(t),value:e,inclusive:!0})}function ic(e,t){return new Yb({check:"multiple_of",...U(t),value:e})}function ac(e,t){return new Qb({check:"max_length",...U(t),maximum:e})}function po(e,t){return new e_({check:"min_length",...U(t),minimum:e})}function cc(e,t){return new t_({check:"length_equals",...U(t),length:e})}function Pp(e,t){return new r_({check:"string_format",format:"regex",...U(t),pattern:e})}function Op(e){return new n_({check:"string_format",format:"lowercase",...U(e)})}function Ip(e){return new o_({check:"string_format",format:"uppercase",...U(e)})}function Ap(e,t){return new s_({check:"string_format",format:"includes",...U(t),includes:e})}function Rp(e,t){return new i_({check:"string_format",format:"starts_with",...U(t),prefix:e})}function Cp(e,t){return new a_({check:"string_format",format:"ends_with",...U(t),suffix:e})}function Wr(e){return new c_({check:"overwrite",tx:e})}function zp(e){return Wr((t)=>t.normalize(e))}function Np(){return Wr((e)=>e.trim())}function Lp(){return Wr((e)=>e.toLowerCase())}function jp(){return Wr((e)=>e.toUpperCase())}function Dp(){return Wr((e)=>Gw(e))}function uS(e,t,r){return new e({type:"array",element:t,...U(r)})}function lS(e,t,r){let n=U(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function dS(e,t,r){return new e({type:"custom",check:"custom",fn:t,...U(r)})}function pS(e,t){let r=yL((n)=>(n.addIssue=(o)=>{if(typeof o==="string")n.issues.push(Cn(o,n.value,r._zod.def));else{let s=o;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=n.value;s.inst??(s.inst=r),s.continue??(s.continue=!r._zod.def.abort),n.issues.push(Cn(s))}},e(n.value,n)),t);return r}function yL(e,t){let r=new He({check:"custom",...U(t)});return r._zod.check=e,r}function Ls(e,...t){for(let r of t)for(let n of Reflect.ownKeys(r))if(Object.prototype.propertyIsEnumerable.call(r,n))bt(e,n,r[n]);return e}function Ds(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??Ur,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 Ve(e,t,r,n,o){let s=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:n.path,message:o}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw Error(o);return Object.assign(r,s),!0}function _e(e,t,r={path:[],schemaPath:[]}){var n;let o=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 a=e._zod.toJSONSchema?.();if(a)i.schema=a;else{let l={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,l);else{let f=i.schema,m=t.processors[o.type];if(!m)throw Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);m(e,t,f,l)}let d=e._zod.parent;if(d){if(!i.ref)i.ref=d;_e(d,t,l),t.seen.get(d).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)Ls(i.schema,c);if(t.io==="input"&&nt(e))delete i.schema.examples,delete i.schema.default;if(t.io==="input"&&"_prefault"in i.schema)(n=i.schema).default??(n.default=i.schema._prefault);return delete i.schema._prefault,t.seen.get(e).schema}function fS(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Ms(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 n=new Map;for(let i of e.seen.entries()){let a=e.metadataRegistry.get(i[0])?.id;if(a){let c=n.get(a);if(c&&c!==i[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(a,i[0])}}let o=(i)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(i[0])?.id,f=e.external.uri??((h)=>h);if(d)return{ref:f(d)};let m=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=m,{defId:m,ref:`${f("__shared")}#/${a}/${fS(m)}`}}let c="#",u=`${c}/${a}/`;if(i[1]===r&&!i[1].schema.id)return{ref:c};let l=i[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+fS(l)}},s=(i)=>{if(i[1].schema.$ref)return;let a=i[1],{ref:c,defId:u}=o(i);if(a.def={...a.schema},u)a.defId=u;let l=a.schema;for(let d in l)delete l[d];l.$ref=c};if(e.cycles==="throw")for(let i of e.seen.entries()){let a=i[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
227
227
 
228
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of e.seen.entries()){let a=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(a.cycle){s(i);continue}if(a.count>1){if(e.reused==="ref")s(i)}}if(e.external)e.sharedDefsExtractedFor=e.external}function gS(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let n of t){if(!n||typeof n!=="object")return;gS(n);let o=Object.keys(n);if(o.length!==1||o[0]!=="type")return;let s=n.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 yS=new Set(["type","properties","required","additionalProperties"]),mS=["oneOf","anyOf"];function hS(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 Mp(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let i in s)if(!yS.has(i))return null;t.push(s)}let r={},n=new Set;for(let s of t){for(let i in s.properties){if(Object.prototype.hasOwnProperty.call(r,i))continue;let a=[];for(let u of t){let l=u.properties?.[i]??hS(u);if(l===null||l===void 0)continue;if(!a.some((d)=>JSON.stringify(d)===JSON.stringify(l)))a.push(l)}let c=a.length===1?a[0]:Mp(a)??{allOf:a};bt(r,i,c)}for(let i of s.required??[])n.add(i)}let o={type:"object",properties:r};if(n.size)o.required=[...n];if(t.every((s)=>s.additionalProperties===!1))o.additionalProperties=!1;else{let s=[];for(let i of t){let a=hS(i);if(a&&!s.some((c)=>JSON.stringify(c)===JSON.stringify(a)))s.push(a)}if(s.length===1)o.additionalProperties=s[0];else if(s.length>1)o.additionalProperties={allOf:s}}return o}function wL(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of yS)if(o in e)return;let r=t.filter((o)=>mS.some((s)=>Array.isArray(o[s]))),n=null;if(!r.length)n=Mp(t);else{let o=r[0],s=mS.find((c)=>Array.isArray(o[c]));if(Object.keys(o).length!==1)return;let i=t.filter((c)=>c!==o),a=o[s].map((c)=>Mp([...i,c]));if(a.some((c)=>!c))return;n={[s]:a}}if(!n)return;delete e.allOf,Ls(e,n)}function qs(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let n=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,l={...u},d=c.ref;if(c.ref=null,d){n(d);let m=e.seen.get(d),h=m.schema;if(h.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))u.allOf=u.allOf??[],u.allOf.push(h);else Ls(u,h);if(Ls(u,l),a._zod.parent===d)for(let y in u){if(y==="$ref"||y==="allOf")continue;if(!(y in l))delete u[y]}if(h.$ref&&m.def)for(let y in u){if(y==="$ref"||y==="allOf")continue;if(y in m.def&&JSON.stringify(u[y])===JSON.stringify(m.def[y]))delete u[y]}}let f=a._zod.parent;if(f&&f!==d){n(f);let m=e.seen.get(f);if(m?.schema.$ref){if(u.$ref=m.schema.$ref,m.def)for(let h in u){if(h==="$ref"||h==="allOf")continue;if(h in m.def&&JSON.stringify(u[h])===JSON.stringify(m.def[h]))delete u[h]}}}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())n(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())gS(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let u of[c.schema,c.def]){let l=u?.allOf;if(!Array.isArray(l))continue;let d=a.get(l);if(d)d.push(u);else a.set(l,[u])}for(let c of e.intersections)for(let u of a.get(c)??[])wL(u)}}let o={};if(e.target==="draft-2020-12")o.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")o.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")o.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}Ls(o,r.defId?r.schema:r.def??r.schema);let s=e.metadataRegistry.get(t)?.id;if(s!==void 0&&o.id===s)delete o.id;let i=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;bt(i,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(i).length>0)if(e.target==="draft-2020-12")o.$defs=i;else o.definitions=i;try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:js(t,"input",e.processors),output:js(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function nt(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return nt(n.element,r);if(n.type==="set")return nt(n.valueType,r);if(n.type==="lazy")return nt(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault"||n.type==="catch")return nt(n.innerType,r);if(n.type==="intersection")return nt(n.left,r)||nt(n.right,r);if(n.type==="record"||n.type==="map")return nt(n.keyType,r)||nt(n.valueType,r);if(n.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return nt(n.in,r)||nt(n.out,r)}if(n.type==="object"){for(let o in n.shape)if(nt(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(nt(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(nt(o,r))return!0;if(n.rest&&nt(n.rest,r))return!0;return!1}return!1}var wS=(e,t={})=>(r)=>{let n=Ds({...r,processors:t});return _e(e,n),Ms(n,e),qs(n,e)},js=(e,t,r={})=>(n)=>{let{libraryOptions:o,target:s}=n??{},i=Ds({...o??{},target:s,io:t,processors:r});return _e(e,i),Ms(i,e),qs(i,e)};var fo=(e,t,r)=>{if(e[t]===void 0||r>e[t])e[t]=r},mo=(e,t,r)=>{if(e[t]===void 0||r<e[t])e[t]=r},bS=(e,t)=>{fo(e,"minimum",t),mo(e,"maximum",t)},xS=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},$S=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},TS=(e,t)=>{e.mime=e.mime?e.mime.filter((r)=>t.includes(r)):[...t]},ES=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},_S=(e,t)=>fo(e,"minimum",t.minimum),vS=(e,t)=>mo(e,"maximum",t.maximum),SS=(e)=>(t,r)=>{ES(t,r.format);let[n,o]=e[r.format];fo(t,"minimum",n),mo(t,"maximum",o)},bL={greater_than:(e,t)=>fo(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>mo(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>xS(e,t.value),number_format:SS(Aa),bigint_format:SS(Qd),min_length:_S,max_length:vS,length_equals:(e,t)=>bS(e,t.length),min_size:_S,max_size:vS,size_equals:(e,t)=>bS(e,t.size),string_format:(e,t)=>{if(ES(e,t.format),t.pattern)$S(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)=>TS(e,t.mime)};function ct(e){let t={},r=e._zod.def,n=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let s of n)bL[s._zod.def.check]?.(t,s._zod.def);let o=e._zod.bag;if(o.minimum!==void 0)fo(t,"minimum",o.minimum);if(o.exclusiveMinimum!==void 0)fo(t,"exclusiveMinimum",o.exclusiveMinimum);if(o.maximum!==void 0)mo(t,"maximum",o.maximum);if(o.exclusiveMaximum!==void 0)mo(t,"exclusiveMaximum",o.exclusiveMaximum);if(o.multipleOf!==void 0)xS(t,o.multipleOf);if(o.format!==void 0){if(t.format??(t.format=o.format),o.format.includes("int"))t.isInt=!0}if(o.mime)TS(t,o.mime);for(let s of o.patterns??[])$S(t,s);return t}var _L={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},vL=new Map([[yp,jb],[Ga,Db]]),PS=(e)=>vL.get(e)??e,Up=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u,laxFormat:l}=ct(e);if(typeof s==="number")o.minLength=s;if(typeof i==="number")o.maxLength=i;if(a){if(o.format=_L[a]??a,o.format==="")delete o.format;if(a==="time"||l)delete o.format}if(u)o.contentEncoding=u;if(c&&c.size>0){let d=[...c].map(PS);if(d.length===1)o.pattern=d[0].source;else if(d.length>1)o.allOf=[...d.map((f)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))]}},Wp=(e,t,r,n)=>{let o=r,{minimum:s,maximum:i,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:l}=ct(e);o.type=l?"integer":"number";let d=typeof u==="number"&&u>=(s??Number.NEGATIVE_INFINITY),f=typeof c==="number"&&c<=(i??Number.POSITIVE_INFINITY),m=t.target==="draft-04"||t.target==="openapi-3.0";if(d)if(m)o.minimum=u,o.exclusiveMinimum=!0;else o.exclusiveMinimum=u;else if(typeof s==="number")o.minimum=s;if(f)if(m)o.maximum=c,o.exclusiveMaximum=!0;else o.exclusiveMaximum=c;else if(typeof i==="number")o.maximum=i;if(a){let h=new Set;for(let b of a)if(Number.isFinite(b)&&b!==0)h.add(Math.abs(b));else Ve(e,t,o,n,`A multipleOf divisor of ${b} cannot be represented in JSON Schema`);let[g,...y]=h;if(g!==void 0)o.multipleOf=g;if(y.length)o.allOf=[...o.allOf??[],...y.map((b)=>({multipleOf:b}))]}},Vp=(e,t,r,n)=>{r.type="boolean"},OS=(e,t,r,n)=>{Ve(e,t,r,n,"BigInt cannot be represented in JSON Schema")},IS=(e,t,r,n)=>{Ve(e,t,r,n,"Symbols cannot be represented in JSON Schema")},Zp=(e,t,r,n)=>{if(t.target==="openapi-3.0")r.type="string",r.nullable=!0,r.enum=[null];else r.type="null"},AS=(e,t,r,n)=>{Ve(e,t,r,n,"Undefined cannot be represented in JSON Schema")},RS=(e,t,r,n)=>{Ve(e,t,r,n,"Void cannot be represented in JSON Schema")},Bp=(e,t,r,n)=>{r.not={}},Kp=(e,t,r,n)=>{},Hp=(e,t,r,n)=>{},CS=(e,t,r,n)=>{Ve(e,t,r,n,"Date cannot be represented in JSON Schema")},Gp=(e,t,r,n)=>{let o=e._zod.def,s=$s(o.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},Jp=(e,t,r,n)=>{let o=e._zod.def;if(o.values.length===0){r.not={};return}let s=[];for(let i of o.values)if(i===void 0){if(Ve(e,t,r,n,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i==="bigint"){if(Ve(e,t,r,n,"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}},zS=(e,t,r,n)=>{Ve(e,t,r,n,"NaN cannot be represented in JSON Schema")},Yp=(e,t,r,n)=>{let o=r,s=e._zod.pattern;if(!s)throw Error("Pattern not found in template literal");o.type="string",o.pattern=s.source},NS=(e,t,r,n)=>{let o=r;o.type="string",o.format="binary",o.contentEncoding="binary";let{minimum:s,maximum:i,mime:a}=ct(e);if(s!==void 0)o.minLength=s;if(i!==void 0)o.maxLength=i;if(!a)return;if(a.length===0)o.not={};else if(a.length===1)o.contentMediaType=a[0];else o.anyOf=a.map((c)=>({contentMediaType:c}))},LS=(e,t,r,n)=>{r.type="boolean"},Xp=(e,t,r,n)=>{Ve(e,t,r,n,"Custom types cannot be represented in JSON Schema")},jS=(e,t,r,n)=>{Ve(e,t,r,n,"Function types cannot be represented in JSON Schema")},Qp=(e,t,r,n)=>{Ve(e,t,r,n,"Transforms cannot be represented in JSON Schema")},DS=(e,t,r,n)=>{Ve(e,t,r,n,"Map cannot be represented in JSON Schema")},MS=(e,t,r,n)=>{Ve(e,t,r,n,"Set cannot be represented in JSON Schema")},ef=(e,t,r,n)=>{let o=r,s=e._zod.def,{minimum:i,maximum:a}=ct(e);if(typeof i==="number")o.minItems=i;if(typeof a==="number")o.maxItems=a;o.type="array",o.items=_e(s.element,t,{...n,path:[...n.path,"items"]})};function Fs(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return Fs(t.out);if(t.type==="catch")return Fs(t.innerType);return e._zod.optin}var tf=(e,t,r,n)=>{let o=r,s=e._zod.def,i=s.shape;if(Object.getOwnPropertySymbols(i).length&&Ve(e,t,o,n,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let u in i)bt(o.properties,u,_e(i[u],t,{...n,path:[...n.path,"properties",u]}));let c=[];for(let u of Object.keys(i)){let l=s.shape[u];if(t.io==="input"?Fs(l)===void 0:l._zod.optout===void 0)c.push(u)}if(c.length>0)o.required=c;if(s.catchall?._zod.def.type==="never")o.additionalProperties=!1;else if(!s.catchall){if(t.io==="output")o.additionalProperties=!1}else if(s.catchall)o.additionalProperties=_e(s.catchall,t,{...n,path:[...n.path,"additionalProperties"]})},rf=(e,t,r,n)=>{let o=e._zod.def,s=o.inclusive===!1,i=o.options.map((a,c)=>_e(a,t,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));if(s)r.oneOf=i;else r.anyOf=i},nf=(e,t,r,n)=>{let o=e._zod.def,s=_e(o.left,t,{...n,path:[...n.path,"allOf",0]}),i=_e(o.right,t,{...n,path:[...n.path,"allOf",1]}),a=(u)=>("allOf"in u)&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];r.allOf=c,t.intersections.push(c)},of=(e,t,r,n)=>{let o=r,s=e._zod.def;o.type="array";let i=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",c=s.items.map((g,y)=>_e(g,t,{...n,path:[...n.path,i,y]})),u=s.rest?_e(s.rest,t,{...n,path:[...n.path,a,...t.target==="openapi-3.0"?[s.items.length]:[]]}):null,l=s.items.length;while(l>0){let g=s.items[l-1];if(!(t.io==="input"?Fs(g)!==void 0:g._zod.optout==="optional"))break;l--}let d=s.items.length,f=!s.rest;if(t.target==="draft-2020-12"){if(o.prefixItems=c,f)o.items=!1;else if(u)o.items=u;if(l>0)o.minItems=l;if(f)o.maxItems=d}else if(t.target==="openapi-3.0"){if(o.items={anyOf:c},u)o.items.anyOf.push(u);if(l>0)o.minItems=l;if(f)o.maxItems=d}else{if(o.items=c,f)o.additionalItems=!1;else if(u)o.additionalItems=u;if(l>0)o.minItems=l;if(f)o.maxItems=d}let{minimum:m,maximum:h}=ct(e);if(typeof m==="number")o.minItems=m;if(typeof h==="number")o.maxItems=h};function qp(e,t,r){if(t.$ref){if(r.has(t))return t;r.add(t);let h=e.get(t)?.def;if(!h)return t;let g=qp(e,h,r);return g===h?t:g}for(let h of["anyOf","oneOf"]){let g=t[h];if(!Array.isArray(g))continue;let y=g.map((b)=>qp(e,b,r));if(y.some((b,T)=>b!==g[T]))t={...t,[h]:y}}let n=Array.isArray(t.type)?t.type:[t.type],o=!n.includes("string")&&n.some((h)=>h==="number"||h==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!o&&!s?.some((h)=>typeof h==="number"))return t;let{minimum:i,maximum:a,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:l,format:d,id:f,...m}=t;if(m.enum)m.enum=m.enum.map((h)=>typeof h==="number"?String(h):h);else if(typeof m.const==="number")m.const=String(m.const);if(!o)return m;if(m.type="string",!s)m.pattern=(n.includes("number")?uo:Wa).source;return m}var Fp=new WeakMap;function SL(e){let t=new Map;for(let n of e.seen.values())if(n.def&&!t.has(n.schema))t.set(n.schema,n);let r=new Map;for(let n of Fp.get(e)??[]){let o=e.seen.get(n),s=(o?.def??o?.schema)?.propertyNames;if(!s||s===!0||r.has(s))continue;let i=qp(t,s,new Set);if(i!==s)r.set(s,i)}if(!r.size)return;for(let n of e.seen.values())for(let o of[n.schema,n.def]){let s=o&&r.get(o.propertyNames);if(s)o.propertyNames=s}}var sf=(e,t,r,n)=>{let o=r,s=e._zod.def;o.type="object";let i=s.keyType,a=ct(i).patterns;if(s.mode==="loose"&&a&&a.size>0){let l=_e(s.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let d of a)bt(o.patternProperties,PS(d).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=_e(s.keyType,t,{...n,path:[...n.path,"propertyNames"]});let l=Fp.get(t);if(!l)l=[],Fp.set(t,l),t.deferred.push(()=>SL(t));l.push(e)}o.additionalProperties=_e(s.valueType,t,{...n,path:[...n.path,"additionalProperties"]})}let c=i._zod.values,u=t.io==="input"&&Fs(s.valueType)!==void 0;if(c&&!s.partial&&!u){let l=[...c].filter((d)=>typeof d==="string"||typeof d==="number");if(l.length>0)o.required=l.map(String)}},af=(e,t,r,n)=>{let o=e._zod.def,s=_e(o.innerType,t,n),i=t.seen.get(e);if(t.target==="openapi-3.0")i.ref=o.innerType,r.nullable=!0;else r.anyOf=[s,{type:"null"}]},cf=(e,t,r,n)=>{let o=e._zod.def;_e(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},uf=Symbol();function qS(e,t,r,n,o){let s=!1,i=JSON.stringify(e,(a,c)=>{if(typeof c!=="bigint")return c;return s=!0,null});if(!s)return JSON.parse(i);return Ve(t,r,n,o,"BigInt defaults cannot be represented in JSON Schema"),uf}var lf=(e,t,r,n)=>{let o=e._zod.def;_e(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i=qS(o.defaultValue,e,t,r,n);if(i!==uf)r.default=i},df=(e,t,r,n)=>{let o=e._zod.def;_e(o.innerType,t,n);let s=t.seen.get(e);if(s.ref=o.innerType,t.io!=="input")return;let i=qS(o.defaultValue,e,t,r,n);if(i!==uf)r._prefault=i},pf=(e,t,r,n)=>{let o=e._zod.def;_e(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{Ve(e,t,r,n,"Dynamic catch values are not supported in JSON Schema");return}r.default=i},ff=(e,t,r,n)=>{let o=e._zod.def,s=o.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?s?o.out:o.in:o.out;_e(i,t,n);let a=t.seen.get(e);a.ref=i},mf=(e,t,r,n)=>{let o=e._zod.def;_e(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType,r.readOnly=!0},FS=(e,t,r,n)=>{let o=e._zod.def;_e(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},uc=(e,t,r,n)=>{let o=e._zod.def;_e(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},hf=(e,t,r,n)=>{let o=e._zod.innerType;_e(o,t,n);let s=t.seen.get(e);s.ref=o},kS={string:Up,number:Wp,boolean:Vp,bigint:OS,symbol:IS,null:Zp,undefined:AS,void:RS,never:Bp,any:Kp,unknown:Hp,date:CS,enum:Gp,literal:Jp,nan:zS,template_literal:Yp,file:NS,success:LS,custom:Xp,function:jS,transform:Qp,map:DS,set:MS,array:ef,object:tf,union:rf,intersection:nf,tuple:of,record:sf,nullable:af,nonoptional:cf,default:lf,prefault:df,catch:pf,pipe:ff,readonly:mf,promise:FS,optional:uc,lazy:hf};function US(e,t){if("_idmap"in e){let n=e,o=Ds({...t,processors:kS}),s={};for(let c of n._idmap.entries()){let[u,l]=c;_e(l,o)}let i={},a={registry:n,uri:t?.uri,defs:s};o.external=a;for(let c of n._idmap.entries()){let[u,l]=c;Ms(o,l),bt(i,u,qs(o,l))}if(Object.keys(s).length>0){let c=o.target==="draft-2020-12"?"$defs":"definitions";i.__shared={[c]:s}}return{schemas:i}}let r=Ds({...t,processors:kS});return _e(e,r),Ms(r,e),qs(r,e)}var WS=new WeakSet([Object.prototype,Error.prototype]);function lc(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let n=r(this);return Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0})}})}var AL=(e,t)=>{db.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);if(WS.has(r))return;WS.add(r),lc(r,"format",(n)=>(o)=>ip(n,o)),lc(r,"flatten",(n)=>(o)=>sp(n,o)),lc(r,"addIssue",(n)=>(o)=>{n.issues.push(o),n.message=JSON.stringify(n.issues,Ts,2)}),lc(r,"addIssues",(n)=>(o)=>{n.issues.push(...o),n.message=JSON.stringify(n.issues,Ts,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var vt=O("ZodError",AL,void 0,{Parent:Error});var VS=Da(vt),ZS=Ma(vt),BS=Is(vt),KS=qa(vt),HS=mb(vt),GS=hb(vt),JS=gb(vt),YS=yb(vt),XS=wb(vt),QS=bb(vt),ek=_b(vt),tk=vb(vt);function CL(){if(!rt.localeError)at($p())}function Us(){if(!rt.memoizer)at({memoizer:xp()})}var ge=O("ZodType",(e,t)=>(CL(),fe.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(_t(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 Zt(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check($j(e,t))},superRefine(e,t){return this.check(Tj(e,t))},overwrite(e){return this.check(Wr(e))},optional(){return Te(this)},exactOptional(){return lj(this)},nullable(){return nk(this)},nullish(){return Te(nk(this))},nonoptional(e){return gj(this,e)},array(){return k(this)},or(e){return te([this,e])},and(e){return fc(this,e)},transform(e){return ok(this,dk(e))},default(e){return fj(this,e)},prefault(e){return hj(this,e)},catch(e){return wj(this,e)},pipe(e){return ok(this,e)},readonly(){return vj(this)},describe(e){let t=this.clone();return Ur.add(t,{description:e}),t},meta(...e){if(e.length===0)return Ur.get(this);let t=this.clone();return Ur.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 La(this,"~standard",{...gp(this),jsonSchema:{input:js(this,"input"),output:js(this,"output")}})},set "~standard"(e){$r(this,"~standard",e)},parse:function e(t,r){return VS(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await ZS(this,t,r,{callee:e})},safeParse(e,t){return BS(this,e,t)},async safeParseAsync(e,t){return KS(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){$r(this,"spa",e)},validate(e,t){return Fa(this,e,t)},validateAsync(e,t){return Ua(this,e,t)},encode:function e(t,r){return HS(this,t,r,{callee:e})},decode:function e(t,r){return GS(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await JS(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await YS(this,t,r,{callee:e})},safeEncode(e,t){return XS(this,e,t)},safeDecode(e,t){return QS(this,e,t)},async safeEncodeAsync(e,t){return ek(this,e,t)},async safeDecodeAsync(e,t){return tk(this,e,t)},toJSONSchema(e){return wS(this,{})(e)},get description(){return Ur.get(this)?.description},get _def(){return this._zod.def}}),sk=O("_ZodString",(e,t)=>{Ha.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Up(e,r,n,o)},sb({format:(e)=>ct(e).format??null,minLength:(e)=>ct(e).minimum??null,maxLength:(e)=>ct(e).maximum??null},{regex(...e){return this.check(Pp(...e))},includes(...e){return this.check(Ap(...e))},startsWith(...e){return this.check(Rp(...e))},endsWith(...e){return this.check(Cp(...e))},min(...e){return this.check(po(...e))},max(...e){return this.check(ac(...e))},length(...e){return this.check(cc(...e))},nonempty(...e){return this.check(po(1,...e))},lowercase(e){return this.check(Op(e))},uppercase(e){return this.check(Ip(e))},trim(){return this.check(Np())},normalize(...e){return this.check(zp(...e))},toLowerCase(){return this.check(Lp())},toUpperCase(){return this.check(jp())},slugify(){return this.check(Dp())}})),ik=O("ZodString",(e,t)=>{Ha.init(e,t),sk.init(e,t)},{email(e){return this.check(zv(zL,e))},url(e){return this.check(Ep(ak,e))},jwt(e){return this.check(eS(JL,e))},emoji(e){return this.check(qv(LL,e))},guid(e){return this.check(Nv(NL,e))},uuid(e){return this.check(Lv(dc,e))},uuidv4(e){return this.check(jv(dc,e))},uuidv6(e){return this.check(Dv(dc,e))},uuidv7(e){return this.check(Mv(dc,e))},nanoid(e){return this.check(Fv(jL,e))},cuid(e){return this.check(Uv(DL,e))},cuid2(e){return this.check(Wv(ML,e))},ulid(e){return this.check(Vv(qL,e))},base64(e){return this.check(Yv(KL,e))},base64url(e){return this.check(Xv(HL,e))},xid(e){return this.check(Zv(FL,e))},ksuid(e){return this.check(Bv(UL,e))},ipv4(e){return this.check(Kv(WL,e))},ipv6(e){return this.check(Hv(VL,e))},cidrv4(e){return this.check(Gv(ZL,e))},cidrv6(e){return this.check(Jv(BL,e))},e164(e){return this.check(Qv(GL,e))},datetime(e){return this.check(ec(Ws,e))},date(e){return this.check(tc(Vs,e))},time(e){return this.check(rc(Zs,e))},duration(e){return this.check(nc(Bs,e))}});function p(e){return Cv(ik,e)}var Oe=O("ZodStringFormat",(e,t)=>{xe.init(e,t),sk.init(e,t)}),Ws=O("ZodISODateTime",(e,t)=>{D_.init(e,t),Oe.init(e,t)}),Vs=O("ZodISODate",(e,t)=>{M_.init(e,t),Oe.init(e,t)}),Zs=O("ZodISOTime",(e,t)=>{q_.init(e,t),Oe.init(e,t)}),Bs=O("ZodISODuration",(e,t)=>{F_.init(e,t),Oe.init(e,t)}),zL=O("ZodEmail",(e,t)=>{E_.init(e,t),Oe.init(e,t)});var NL=O("ZodGUID",(e,t)=>{$_.init(e,t),Oe.init(e,t)});var dc=O("ZodUUID",(e,t)=>{T_.init(e,t),Oe.init(e,t)});var ak=O("ZodURL",(e,t)=>{I_.init(e,t),Oe.init(e,t)});function Ks(e){return Ep(ak,e)}var LL=O("ZodEmoji",(e,t)=>{A_.init(e,t),Oe.init(e,t)});var jL=O("ZodNanoID",(e,t)=>{R_.init(e,t),Oe.init(e,t)});var DL=O("ZodCUID",(e,t)=>{C_.init(e,t),Oe.init(e,t)});var ML=O("ZodCUID2",(e,t)=>{z_.init(e,t),Oe.init(e,t)});var qL=O("ZodULID",(e,t)=>{N_.init(e,t),Oe.init(e,t)});var FL=O("ZodXID",(e,t)=>{L_.init(e,t),Oe.init(e,t)});var UL=O("ZodKSUID",(e,t)=>{j_.init(e,t),Oe.init(e,t)});var WL=O("ZodIPv4",(e,t)=>{U_.init(e,t),Oe.init(e,t)});var VL=O("ZodIPv6",(e,t)=>{V_.init(e,t),Oe.init(e,t)});var ZL=O("ZodCIDRv4",(e,t)=>{Z_.init(e,t),Oe.init(e,t)});var BL=O("ZodCIDRv6",(e,t)=>{B_.init(e,t),Oe.init(e,t)});var KL=O("ZodBase64",(e,t)=>{H_.init(e,t),Oe.init(e,t)});var HL=O("ZodBase64URL",(e,t)=>{G_.init(e,t),Oe.init(e,t)});var GL=O("ZodE164",(e,t)=>{J_.init(e,t),Oe.init(e,t)});var JL=O("ZodJWT",(e,t)=>{Y_.init(e,t),Oe.init(e,t)});var pc=O("ZodNumber",(e,t)=>{wp.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Wp(e,r,n,o),e.isFinite=!0},sb({minValue:(e)=>{let{minimum:t,exclusiveMinimum:r}=ct(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:r}=ct(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:r}=ct(e);return!!t||!!r?.some(Number.isSafeInteger)},format:(e)=>ct(e).format??null},{gt(e,t){return this.check(sc(e,t))},gte(e,t){return this.check(Ns(e,t))},min(e,t){return this.check(Ns(e,t))},lt(e,t){return this.check(oc(e,t))},lte(e,t){return this.check(zs(e,t))},max(e,t){return this.check(zs(e,t))},int(e){return this.check(rk(e))},safe(e){return this.check(rk(e))},positive(e){return this.check(sc(0,e))},nonnegative(e){return this.check(Ns(0,e))},negative(e){return this.check(oc(0,e))},nonpositive(e){return this.check(zs(0,e))},multipleOf(e,t){return this.check(ic(e,t))},step(e,t){return this.check(ic(e,t))},finite(){return this}}));function P(e){return tS(pc,e)}var YL=O("ZodNumberFormat",(e,t)=>{X_.init(e,t),pc.init(e,t)});function rk(e){return nS(YL,e)}var ck=O("ZodBoolean",(e,t)=>{Q_.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Vp(e,r,n,o)});function D(e){return oS(ck,e)}var XL=O("ZodNull",(e,t)=>{ev.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Zp(e,r,n,o)});function Hs(e){return sS(XL,e)}var QL=O("ZodAny",(e,t)=>{tv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Kp(e,r,n,o)});function uk(){return iS(QL)}var ej=O("ZodUnknown",(e,t)=>{rv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Hp(e,r,n,o)});function ne(){return aS(ej)}var tj=O("ZodNever",(e,t)=>{nv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Bp(e,r,n,o)});function rj(e){return cS(tj,e)}var nj=O("ZodArray",(e,t)=>{Us(),ov.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ef(e,r,n,o),e.element=t.element},{min(e,t){return this.check(po(e,t))},nonempty(e){return this.check(po(1,e))},max(e,t){return this.check(ac(e,t))},length(e,t){return this.check(cc(e,t))},unwrap(){return this.element}});function k(e,t){return uS(nj,e,t)}var wf=O("ZodObject",(e,t)=>{Us(),av.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>tf(e,r,n,o),jN(e,"shape",(r)=>r._zod.def.shape,!1)},{keyof(){return z(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(_t(this._zod.def,{catchall:e}))},passthrough(){return this.clone(_t(this._zod.def,{catchall:ne()}))},loose(){return this.clone(_t(this._zod.def,{catchall:ne()}))},strict(){return this.clone(_t(this._zod.def,{catchall:rj()}))},strip(){return this.clone(_t(this._zod.def,{catchall:void 0}))},extend(e){return ON(this,e)},safeExtend(e){return IN(this,e)},merge(e){return AN(this,e)},pick(e){return EN(this,e)},omit(e){return PN(this,e)},partial(...e){return tb(_f,this,e[0])},exactPartial(...e){return tb(pk,this,e[0],"exactPartial")},required(...e){return RN(fk,this,e[0])}});function w(e,t){let r={type:"object",shape:e??{},...U(t)};return new wf(r)}function ve(e,t){return new wf({type:"object",shape:e,catchall:ne(),...U(t)})}var lk=O("ZodUnion",(e,t)=>{bp.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>rf(e,r,n,o),e.options=t.options});function te(e,t){return new lk({type:"union",options:e,...U(t)})}var oj=O("ZodDiscriminatedUnion",(e,t)=>{lk.init(e,t),cv.init(e,t)});function It(e,t,r){return new oj({type:"union",options:t,discriminator:e,...U(r)})}var sj=O("ZodIntersection",(e,t)=>{uv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>nf(e,r,n,o)});function fc(e,t){return new sj({type:"intersection",left:e,right:t})}var ij=O("ZodTuple",(e,t)=>{Us(),lv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>of(e,r,n,o)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map((t)=>new _f({type:"optional",innerType:t}))})}});function aj(e,t,r){let n=t instanceof fe,o=n?r:t;return new ij({type:"tuple",items:e,rest:n?t:null,...U(o)})}var gf=O("ZodRecord",(e,t)=>{Us(),dv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>sf(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function K(e,t,r){if(!t||!t._zod)return new gf({type:"record",keyType:p(),valueType:e,...U(t)});return new gf({type:"record",keyType:e,valueType:t,...U(r)})}function bf(e,t,r){return new gf({type:"record",keyType:e,valueType:t,...U(r),partial:!0})}var yf=O("ZodEnum",(e,t)=>{pv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,o,s)=>Gp(e,n,o,s),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{let s={};for(let i of n)if(r.has(i))s[i]=t.entries[i];else throw Error(`Key ${i} not found in enum`);return new yf({...t,checks:[],...U(o),entries:s})},e.exclude=(n,o)=>{let s={...t.entries};for(let i of n)if(r.has(i))delete s[i];else throw Error(`Key ${i} not found in enum`);return new yf({...t,checks:[],...U(o),entries:s})}});function z(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map((n)=>[n,n])):e;return new yf({type:"enum",entries:r,...U(t)})}var cj=O("ZodLiteral",(e,t)=>{fv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Jp(e,r,n,o),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 C(e,t){return new cj({type:"literal",values:Array.isArray(e)?e:[e],...U(t)})}var uj=O("ZodTransform",(e,t)=>{Us(),mv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Qp(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Os(e.constructor.name);r.addIssue=(s)=>{if(typeof s==="string")r.issues.push(Cn(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(Cn(i))}};let o=t.transform(r.value,r);if(o instanceof Promise)return o.then((s)=>(r.value=s,r));return r.value=o,r}});function dk(e){return new uj({type:"transform",transform:e})}var _f=O("ZodOptional",(e,t)=>{_p.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>uc(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Te(e){return new _f({type:"optional",innerType:e})}var pk=O("ZodExactOptional",(e,t)=>{hv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>uc(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function lj(e){return new pk({type:"optional",innerType:e})}var dj=O("ZodNullable",(e,t)=>{gv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>af(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function nk(e){return new dj({type:"nullable",innerType:e})}var pj=O("ZodDefault",(e,t)=>{yv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>lf(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function fj(e,t){return new pj({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():Yd(t)}})}var mj=O("ZodPrefault",(e,t)=>{wv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>df(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function hj(e,t){return new mj({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():Yd(t)}})}var fk=O("ZodNonOptional",(e,t)=>{bv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>cf(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function gj(e,t){return new fk({type:"nonoptional",innerType:e,...U(t)})}var yj=O("ZodCatch",(e,t)=>{_v.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>pf(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function wj(e,t){return new yj({type:"catch",innerType:e,catchValue:typeof t==="function"?t:ib(t)})}var mk=O("ZodPipe",(e,t)=>{vp.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ff(e,r,n,o),e.in=t.in,e.out=t.out});function ok(e,t){return new mk({type:"pipe",in:e,out:t})}var bj=O("ZodPreprocess",(e,t)=>{mk.init(e,t),vv.init(e,t)}),_j=O("ZodReadonly",(e,t)=>{Sv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>mf(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function vj(e){return new _j({type:"readonly",innerType:e})}var Sj=O("ZodTemplateLiteral",(e,t)=>{kv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Yp(e,r,n,o)});function kj(e,t){return new Sj({type:"template_literal",parts:e,...U(t)})}var xj=O("ZodLazy",(e,t)=>{xv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>hf(e,r,n,o),e.unwrap=()=>e._zod.def.getter()});function vf(e){return new xj({type:"lazy",getter:e})}var hk=O("ZodCustom",(e,t)=>{$v.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Xp(e,r,n,o)});function mc(e,t){return lS(hk,e??(()=>!0),t)}function $j(e,t={}){return dS(hk,e,t)}function Tj(e,t){return pS(e,t)}function At(e){let t=vf(()=>te([p(e),P(),D(),Hs(),k(t),K(p(),t)]));return t}function hc(e,t){return new bj({type:"pipe",in:dk(e),out:t})}var yk={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};var gk;(function(e){})(gk||(gk={}));function wk(e){return ec(Ws,e)}function Pj(e){return tc(Vs,e)}function Oj(e){return rc(Zs,e)}function Ij(e){return nc(Bs,e)}function Aj(e){return rS(pc,e)}var _k={name:"@tripwire-sh/cli",version:"0.1.7",description:"Set up Tripwire in your coding agents and manage it from the terminal",type:"module",imports:{"#/*":"./src/*"},license:"MIT",repository:{type:"git",url:"git+https://github.com/Boring-Software-Inc/v2.git",directory:"apps/cli"},homepage:"https://tripwire.sh",bin:{tripwire:"dist/tripwire.js"},files:["dist"],engines:{node:">=20.12"},publishConfig:{access:"public"},scripts:{build:"bun build src/index.ts --target node --format esm --minify --outfile dist/tripwire.js",typecheck:"tsc --noEmit"},devDependencies:{"@clack/prompts":"^1.7.0","@modelcontextprotocol/sdk":"^1.32.1","@tripwire/contracts":"workspace:*",commander:"^14.0.3","jsonc-parser":"^3.3.1",picocolors:"^1.1.1",yaml:"^2.9.0",zod:"^4.0.0"}};var gc=_k.version,q="tripwire",Gs="tripwire-get-started",vk="tripwire-workflows",Js="tripwire-cli",Cj="https://mcp.tripwire.sh/mcp",zj="https://app.tripwire.sh/api/auth",Sk="offline_access tripwire:read tripwire:configure tripwire:moderate tripwire:admin";function go(e){return e.TRIPWIRE_MCP_URL||Cj}function kk(e){return(e.TRIPWIRE_AUTH_URL||zj).replace(/\/+$/,"")}var Nj="urn:ietf:params:oauth:grant-type:device_code",Lj=w({device_code:p(),user_code:p(),verification_uri:p(),verification_uri_complete:p().optional(),expires_in:P(),interval:P().optional()}),$k=w({access_token:p().min(1),refresh_token:p().min(1).optional(),expires_in:P().optional(),token_type:p().optional()}),kf=w({error:p(),error_description:p().optional()});class Sf extends Error{constructor(){super("Session expired. Run tripwire login.");this.name="SessionExpiredError"}}class Ys extends Error{constructor(){super("Tripwire is not reachable right now. Try again in a minute.");this.name="AuthUnreachableError"}}var Tk={fetch:(e,t)=>fetch(e,t),sleep:(e)=>new Promise((t)=>setTimeout(t,e)),now:()=>Date.now()};async function yc(e,t,r){let n=await e.fetch(t,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded",accept:"application/json"},body:new URLSearchParams(r).toString()}),o=await n.text(),s={error:"invalid_response",error_description:o.slice(0,200)};try{let i=At().safeParse(JSON.parse(o));return{status:n.status,body:i.success?i.data:s,headers:n.headers}}catch{return{status:n.status,body:s,headers:n.headers}}}function Ek(e,t){let r=kf.safeParse(e);if(!r.success)return Error(t);return Error(r.data.error_description?`${r.data.error}: ${r.data.error_description}`:r.data.error)}async function Pk(e,t,r){let{status:n,body:o}=await yc(e,`${t}/device/code`,{client_id:Js,scope:Sk,resource:r}),s=Lj.safeParse(o);if(n>=400||!s.success)throw Ek(o,`Device authorization failed (HTTP ${n})`);return s.data}function Ok(e,t,r,n,o){let s=t.refresh_token??o;return{accessToken:t.access_token,refreshToken:s,expiresAt:t.expires_in?e.now()+t.expires_in*1000:void 0,mcpUrl:n,authUrl:r}}var xk=5000;function jj(e,t){let r=(e.get("retry-after")??e.get("x-retry-after"))?.trim();if(!r)return null;if(/^\d+$/.test(r))return Number(r)*1000;let n=Date.parse(r);return Number.isNaN(n)?null:Math.max(0,n-t)}async function Ik(e,t,r,n){let o=(n.interval??5)*1000,s=null,i=e.now()+n.expires_in*1000;while(e.now()<i){await e.sleep(Math.min(Math.max(o,s??0),i-e.now())),s=null;let{status:a,body:c,headers:u}=await yc(e,`${t}/oauth2/token`,{grant_type:Nj,device_code:n.device_code,client_id:Js,resource:r}),l=$k.safeParse(c);if(a<400&&l.success)return Ok(e,l.data,t,r);if(a===429){if(s=jj(u,e.now()),s===null)o+=xk;continue}let d=kf.safeParse(c),f=d.success?d.data.error:"";if(f==="authorization_pending")continue;if(f==="slow_down"){o+=xk;continue}if(f==="access_denied")throw Error("Sign-in was denied in the browser");if(f==="expired_token")throw Error("The code expired. Run tripwire login again.");throw Ek(c,`Token request failed (HTTP ${a})`)}throw Error("The code expired. Run tripwire login again.")}async function Ak(e,t){if(!t.refreshToken)throw new Sf;let{status:r,body:n}=await yc(e,`${t.authUrl}/oauth2/token`,{grant_type:"refresh_token",refresh_token:t.refreshToken,client_id:Js,resource:t.mcpUrl}).catch(()=>{throw new Ys}),o=$k.safeParse(n);if(r>=400||!o.success){let s=kf.safeParse(n);throw(r===400||r===401)&&s.success&&s.data.error!=="invalid_response"?new Sf:new Ys}return Ok(e,o.data,t.authUrl,t.mcpUrl,t.refreshToken)}async function Rk(e,t){let r=t.refreshToken??t.accessToken;await yc(e,`${t.authUrl}/oauth2/revoke`,{token:r,client_id:Js}).catch(()=>{return})}import{stripVTControlCharacters as MF}from"node:util";var Dj=z(["pending","approved","rejected"]),Aie=Dj.options;var Xs=[{id:"github",label:"GitHub",status:"live",signIn:"social",reviews:!0},{id:"opengit",label:"OpenGit",status:"live",paused:!0},{id:"gitlab",label:"GitLab",status:"planned"},{id:"origin",label:"ORIGIN",status:"planned"}];function Ck(e){return e.status==="live"}var Qs=z(Xs.filter(Ck).map((e)=>e.id)),zie=Xs.filter((e)=>Ck(e)&&!("paused"in e)).map((e)=>e.label),Nie=Xs.filter((e)=>e.status==="planned").map((e)=>e.label),Lie=Xs.filter((e)=>("signIn"in e)).map((e)=>e.id);var Mj=Object.fromEntries(Xs.map((e)=>[e.id,e]));var wc=w({owner:p(),name:p(),fullName:p()}),qj=w({id:p(),login:p(),name:p(),type:z(["Organization","User"]),avatarUrl:p(),repoAccess:z(["all","selected"]),repoCount:P(),installedAt:pe.datetime()}),Fj=w({id:p(),owner:p(),name:p(),fullName:p(),private:D(),pushedAt:pe.datetime(),openFlags:P(),stars:P()}),Mie=w({accounts:k(qj),repos:k(Fj)});var ei=z(["change-request.opened","change-request.updated","change-request.closed","comment.created","push","schedule.matched","installation.created","installation.deleted","installation-repositories.added","installation-repositories.removed"]),zk=w({login:p(),externalId:p(),avatarUrl:p().optional()}),xf=w({number:P().int(),title:p(),headSha:p(),baseRef:p().optional(),headRef:p().optional(),draft:D().optional(),url:p()}),Uj=w({externalId:p(),body:p(),url:p(),subjectNumber:P().int(),byTripwire:D().optional()}),Wj=w({ref:p(),headSha:p(),commitCount:P().int(),url:p().optional()}),_c=z(["issue","change-request"]),Vj=w({kind:_c,number:P().int(),title:p(),url:p(),state:z(["open","closed"]),author:p(),labels:k(p()),locked:D(),updatedAt:pe.datetime()}),Zj=w({workflowId:p(),nodeId:p(),tickId:p()}),yo={id:p(),forge:Qs,deliveryId:p(),repo:wc,repoExternalId:p().optional(),installationExternalId:p().optional(),actor:zk,occurredAt:pe.datetime(),receivedAt:pe.datetime()},bc={id:p(),forge:Qs,deliveryId:p(),actor:zk,occurredAt:pe.datetime(),receivedAt:pe.datetime(),installation:w({externalId:p(),account:p(),accountType:z(["User","Organization"]).optional()}),repositories:k(w({externalId:p(),owner:p(),name:p(),fullName:p(),private:D()}))},Nk=It("kind",[w({...yo,kind:C("change-request.opened"),changeRequest:xf}),w({...yo,kind:C("change-request.updated"),changeRequest:xf}),w({...yo,kind:C("change-request.closed"),changeRequest:xf}),w({...yo,kind:C("comment.created"),comment:Uj}),w({...yo,kind:C("push"),push:Wj}),w({...yo,kind:C("schedule.matched"),schedule:Zj,thread:Vj}),w({...bc,kind:C("installation.created")}),w({...bc,kind:C("installation.deleted")}),w({...bc,kind:C("installation-repositories.added")}),w({...bc,kind:C("installation-repositories.removed")})]),Bj=ei.extract(["change-request.opened","change-request.updated","change-request.closed"]),Vie=Bj.options;var Kj=["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"],Hj=["sun","mon","tue","wed","thu","fri","sat"],Gj=[{name:"minute",range:"0 to 59",min:0,max:59},{name:"hour",range:"0 to 23",min:0,max:23},{name:"day of month",range:"1 to 31",min:1,max:31},{name:"month",range:"1 to 12 or jan to dec",min:1,max:12,names:Kj,nameBase:1},{name:"day of week",range:"0 to 7 or sun to sat",min:0,max:7,names:Hj,nameBase:0}];function $f(e,t){let r=e.toLowerCase(),n=t.names?.indexOf(r)??-1;if(n>=0)return n+(t.nameBase??0);if(!/^\d+$/.test(e))return null;let o=Number(e);return o>=t.min&&o<=t.max?o:null}function Jj(e,t){let r=new Set;for(let n of e.split(",")){let o=n.split("/"),[s="",i]=o;if(o.length>2||s.split("-").length>2)return{ok:!1,error:`${t.name} must be a number, a range like 1-5 or a step like */15`};let a=i===void 0?1:Number(i);if(!(Number.isInteger(a)&&a>=1))return{ok:!1,error:`${t.name} step must be a whole number of 1 or more, like */15`};let c,u;if(s==="*")c=t.min,u=t.max;else if(s.includes("-")){let[l="",d=""]=s.split("-");c=$f(l,t),u=$f(d,t)}else c=$f(s,t),u=i===void 0?c:t.max;if(c===null||u===null)return{ok:!1,error:`${t.name} must be ${t.range}`};if(c>u)return{ok:!1,error:`${t.name} range must go from low to high, like 1-5`};for(let l=c;l<=u;l+=a)r.add(l)}return{ok:!0,values:[...r].sort((n,o)=>n-o)}}function zn(e){let t=e.trim().split(/\s+/);if(t.length!==5)return{ok:!1,error:"use five fields: minute hour day month weekday"};let r=[];for(let[u,l]of Gj.entries()){let d=Jj(t[u]??"",l);if(!d.ok)return d;r.push(d.values)}let[n=[],o=[],s=[],i=[],a=[]]=r,c=[...new Set(a.map((u)=>u===7?0:u))].sort((u,l)=>u-l);return{ok:!0,spec:{minutes:n,hours:o,days:s,months:i,weekdays:c,daysRestricted:!(t[2]??"*").startsWith("*"),weekdaysRestricted:!(t[4]??"*").startsWith("*")}}}function ti(e){try{return new Intl.DateTimeFormat("en-US",{timeZone:e}),!0}catch{return!1}}var Lk=new Map;function Yj(e){let t=Lk.get(e);if(t)return t;let r=new Intl.DateTimeFormat("en-US",{timeZone:e,hourCycle:"h23",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"});return Lk.set(e,r),r}function Pf(e,t){let r=Yj(t).formatToParts(e),n=(o)=>Number(r.find((s)=>s.type===o)?.value??"0");return{year:n("year"),month:n("month"),day:n("day"),hour:n("hour"),minute:n("minute")}}function Tf(e,t){let r=Pf(new Date(e),t),n=Date.UTC(r.year,r.month-1,r.day,r.hour,r.minute),o=e-(e%60000+60000)%60000;return n-o}function jk(e,t){let r=Date.UTC(e.year,e.month-1,e.day,e.hour,e.minute),n=[r-Tf(r-129600000,t),r-Tf(r+129600000,t),r-Tf(r,t)].sort((o,s)=>o-s);for(let o of n){let s=Pf(new Date(o),t);if(s.year===e.year&&s.month===e.month&&s.day===e.day&&s.hour===e.hour&&s.minute===e.minute)return new Date(o)}return null}function vc(e,t,r){let n=e.days.includes(t),o=e.weekdays.includes(r);if(e.daysRestricted&&e.weekdaysRestricted)return n||o;return n&&o}function Xj(e,t){return vc(e,t.getUTCDate(),t.getUTCDay())}var Qj=Array.from({length:217},(e,t)=>({day:t%31+1,weekday:Math.floor(t/31)}));function Ef(e){let t=Qj.map(({day:r,weekday:n})=>vc(e,r,n)?"1":"0").join("");return[e.minutes,e.hours,e.months].map((r)=>r.join(",")).concat(t).join(" ")}function Dk(e,t){let r=zn(e),n=zn(t);return r.ok&&n.ok&&Ef(r.spec)===Ef(n.spec)}var eD=1830,tD=180;function rD(e,t){let r=jk(e,t);if(r)return r;let n=Date.UTC(e.year,e.month-1,e.day,e.hour,e.minute);for(let o=1;o<=tD;o++){let s=new Date(n+o*60000),i=jk({year:s.getUTCFullYear(),month:s.getUTCMonth()+1,day:s.getUTCDate(),hour:s.getUTCHours(),minute:s.getUTCMinutes()},t);if(i)return i}return null}function Mk(e){let{minutes:t,hours:r}=e,n=t.slice(1).map((s,i)=>s-(t[i]??0));if(r.some((s)=>r.includes((s+1)%24)))n.push(60-(t.at(-1)??0)+(t[0]??0));return n.length>0?Math.min(...n):1440}function Of(e,t,r){let n=Pf(r,t),o=new Date(Date.UTC(n.year,n.month-1,n.day));for(let s=0;s<=eD;s++){if(e.months.includes(o.getUTCMonth()+1)&&Xj(e,o))for(let i of e.hours)for(let a of e.minutes){let c=rD({year:o.getUTCFullYear(),month:o.getUTCMonth()+1,day:o.getUTCDate(),hour:i,minute:a},t);if(c&&c.getTime()>r.getTime())return c}o.setUTCDate(o.getUTCDate()+1)}return null}var Rt=5,qe=vf(()=>te([p(),P(),D(),Hs(),k(qe),K(p(),qe)])),xc=w({x:P(),y:P()}),nD=z(["all-of","any-of","not"]),oD=z(["block","comment","label","request-review","send-to-moderation","webhook","discord","lock","close","remove-label","post-comment"]),sD=["comment"];function Fk(e){return sD.includes(e)}var Jie=w({url:Ks().meta({secret:!0}).describe("webhook url"),signingSecret:p().min(1).optional().meta({secret:!0}).describe("signing secret")}),Yie=w({url:Ks().meta({secret:!0}).describe("discord webhook url")}),wo=15,$c=p().regex(/^[A-Za-z0-9](?:[A-Za-z0-9]|-(?=[A-Za-z0-9])){0,38}$/,{error:(e)=>`${String(e.input)} is not a GitHub username`}),If=p().regex(/^[A-Za-z0-9][A-Za-z0-9_-]{0,99}$/,{error:(e)=>`${String(e.input)} is not a team slug`}),Af=w({id:P().int().positive().optional(),login:$c}),Xie=w({id:P().int().positive(),login:$c,avatarUrl:p(),permission:p().min(1)}),Qie=w({name:p().min(1),color:p().regex(/^[0-9a-fA-F]{6}$/),description:p().nullable()}),iD=hc((e)=>p().safeParse(e).success?{login:e}:e,Af);function Uk(e,t){return e.id!==void 0&&t.id!==void 0?e.id===t.id:e.login.toLowerCase()===t.login.toLowerCase()}var ri=w({reviewers:k(iD).max(wo,`ask at most ${wo} people`).default([]),teamReviewers:k(If).max(wo,`ask at most ${wo} teams`).default([])}),Wk=ri.superRefine((e,t)=>{let r=e.reviewers.length+e.teamReviewers.length;if(r===0)t.addIssue({code:"custom",message:"add at least one person or team to ask"});if(r>wo)t.addIssue({code:"custom",message:`ask at most ${wo} people and teams`})}),Zr=w({labels:k(p().trim().min(1)).min(1,"choose at least one label")}),qk=5000,Tc=w({message:p().trim().min(1,"write a message").max(qk,`keep it under ${qk} characters`)}),aD=z(["resolved","off-topic","too heated","spam"]),Vk=w({reason:aD.optional()}),ni={hours:3600000,days:86400000,weeks:604800000,months:2592000000};function Rf(e){return e.n*ni[e.unit]}var Ec=52*ni.weeks,cD=3650*ni.days,uD=z(["hours","days","weeks"]),lD=z(["hours","days","weeks","months"]),dD=w({n:P().int().min(1),unit:uD}).refine((e)=>Rf(e)<=Ec,{message:"runs at least once a year"}),rr="UTC",Zk=p().min(1).refine(ti,{error:(e)=>`${String(e.input)} is not an IANA timezone, like Europe/Berlin`}),Sc=p().regex(/^([01]\d|2[0-3]):[0-5]\d$/,"use 24-hour HH:MM, like 07:30"),Cf=z(["sunday","monday","tuesday","wednesday","thursday","friday","saturday"]),pD=It("preset",[w({preset:C("hourly"),minute:P().int().min(0).max(59)}),w({preset:C("daily"),at:Sc}),w({preset:C("weekdays"),at:Sc}),w({preset:C("weekly"),on:Cf,at:Sc}),w({preset:C("monthly"),day:P().int().min(1).max(28),at:Sc})]),Pc=w({cron:p().trim().superRefine((e,t)=>{let r=zn(e);if(!r.ok){t.addIssue({code:"custom",message:r.error});return}if(Of(r.spec,"UTC",new Date(Date.UTC(2026,0,1)))===null)t.addIssue({code:"custom",message:"this cron never runs. Pick a day the month has"});if(Mk(r.spec)<Rt)t.addIssue({code:"custom",message:`runs must be at least ${Rt} minutes apart`})})}),Bk=te([dD,pD,Pc]),Kk=w({n:P().int().min(1),unit:lD}).refine((e)=>Rf(e)<=cD,{message:"10 years at most"}),Hk=z(["open","closed","any"]),kc=k(p().min(1)),fD=w({subjects:k(_c).min(1),state:Hk,inactiveFor:Kk,labels:kc.optional(),excludeLabels:kc.optional(),skipLocked:D().default(!0)}),bo=w({every:Bk,timezone:Zk.optional(),match:fD}),mD=w({every:Bk.optional(),timezone:Zk.optional(),match:w({subjects:k(_c).optional(),state:Hk.optional(),inactiveFor:Kk.optional(),labels:kc.optional(),excludeLabels:kc.optional(),skipLocked:D().optional()}).default({})});var hD=["every","subjects","state","inactiveFor"];function Gk(e){return hD.filter((t)=>{if(!e)return!0;if(t==="every")return e.every===void 0;let r=e.match[t];return Array.isArray(r)?r.length===0:r===void 0})}var Vr=p(),gD=w({id:Vr,type:C("trigger"),kinds:k(ei).min(1),schedule:mD.optional(),position:xc.optional()});function Oc(e){return e.type==="trigger"&&(e.kinds??[]).includes("schedule.matched")}var yD=w({id:Vr,type:C("rule"),ref:p().regex(/^[a-z][a-z0-9-]*@\d+$/),config:qe,position:xc.optional()}),wD=w({id:Vr,type:C("gate"),mode:nD,position:xc.optional()}),bD=w({id:Vr,type:C("action"),action:oD,params:K(p(),qe).optional(),position:xc.optional()}),zf=It("type",[gD,yD,wD,bD]),Jk=z(["pass","fail","approve","deny"]),_D=w({id:p(),from:Vr,to:Vr,when:Jk.optional()}),ut=w({id:p(),name:p(),version:P().int().min(1),nodes:k(zf).min(1),edges:k(_D)}),Yk={id:"default@1",name:"default gate",version:1,nodes:[{id:"trigger",type:"trigger",kinds:["change-request.opened","change-request.updated"]},{id:"account-age",type:"rule",ref:"account-age@1",config:{minDays:7}},{id:"crypto",type:"rule",ref:"crypto-address@1",config:{}},{id:"honeypot",type:"rule",ref:"honeypot@1",config:{paths:[".github/workflows/**"]}},{id:"max-files",type:"rule",ref:"max-files-changed@1",config:{max:200}},{id:"english",type:"rule",ref:"english-only@1",config:{maxNonLatinRatio:0.5}},{id:"gate",type:"gate",mode:"all-of"},{id:"block",type:"action",action:"block"}],edges:[{id:"e1",from:"trigger",to:"account-age"},{id:"e2",from:"trigger",to:"crypto"},{id:"e3",from:"trigger",to:"honeypot"},{id:"e4",from:"trigger",to:"max-files"},{id:"e5",from:"trigger",to:"english"},{id:"e6",from:"account-age",to:"gate"},{id:"e7",from:"crypto",to:"gate"},{id:"e8",from:"honeypot",to:"gate"},{id:"e9",from:"max-files",to:"gate"},{id:"e10",from:"english",to:"gate"},{id:"e11",from:"gate",to:"block",when:"fail"}]};var Xk=[{kind:"change-request.opened",name:"Change request opened",description:"Runs when someone opens a change request.",toolbox:!0},{kind:"change-request.updated",name:"Change request updated",description:"Runs when a change request gets new commits or edits.",toolbox:!0},{kind:"change-request.closed",name:"Change request closed",description:"Runs when a change request is closed.",toolbox:!0},{kind:"comment.created",name:"Comment created",description:"Runs when someone comments on a change request or issue.",toolbox:!0},{kind:"push",name:"Push",description:"Runs when commits are pushed to the repo.",toolbox:!0},{kind:"schedule.matched",name:"On a schedule",description:"Runs on a timer for issues and change requests that match.",toolbox:!0},{kind:"installation.created",name:"Installation created",description:"Internal event. Installations sync outside workflows.",toolbox:!1},{kind:"installation.deleted",name:"Installation deleted",description:"Internal event. Installations sync outside workflows.",toolbox:!1},{kind:"installation-repositories.added",name:"Repos added",description:"Internal event. Installations sync outside workflows.",toolbox:!1},{kind:"installation-repositories.removed",name:"Repos removed",description:"Internal event. Installations sync outside workflows.",toolbox:!1}],Qk=[{mode:"all-of",name:"All of",description:"Passes only when every connected check passes. A check that was never reached does not pass."},{mode:"any-of",name:"Any of",description:"Passes when at least one connected check passes. A check that was never reached does not pass."},{mode:"not",name:"Not",description:"Flips its input: pass becomes fail, and fail becomes pass."}],ex=[{action:"block",name:"Block",description:"Fails the Tripwire check and requests changes. The change request stays open."},{action:"label",name:"Label",description:"Adds labels you choose to the change request."},{action:"request-review",name:"Request GitHub review",description:"Asks the people you choose to review on GitHub."},{action:"send-to-moderation",name:"Human review",description:"Waits for a maintainer to approve or block it in Tripwire."},{action:"webhook",name:"Webhook",description:"Posts the verdict as JSON to a URL you set."},{action:"lock",name:"Lock",description:"Locks the conversation so only maintainers can comment."},{action:"close",name:"Close",description:"Closes the issue or change request."},{action:"remove-label",name:"Remove label",description:"Removes labels you choose, if they are there."},{action:"post-comment",name:"Comment",description:"Posts a comment you write. It is separate from the verdict comment."},{action:"discord",name:"Discord",description:"Posts the verdict to a Discord channel you set."}];var nae=K(p(),qe).catch({});function Ic(e){if(e.length<=1)return e[0]??"";return`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`}function tx(e){let t=Zr.safeParse(e);return t.success?t.data.labels:[]}function rx(e){return`${e.length===1?"the label":"the labels"} ${Ic(e)}`}function vD(e){let t=ri.safeParse(e);if(!t.success)return[];return[...t.data.reviewers.map((r)=>r.login),...t.data.teamReviewers]}function nx(e,t){switch(e){case"block":return"blocks it";case"label":{let r=tx(t);return r.length>0?`adds ${rx(r)}`:"adds labels"}case"remove-label":{let r=tx(t);return r.length>0?`removes ${rx(r)}`:"removes labels"}case"request-review":{let r=vD(t);return r.length>0?`requests GitHub review from ${Ic(r)}`:"requests GitHub review"}case"send-to-moderation":return"sends it to human review";case"webhook":return"posts the verdict to a webhook";case"discord":return"posts the verdict to Discord";case"lock":return"locks the conversation";case"close":return"closes it";case"post-comment":return"posts your comment";default:return e}}var SD=w({runId:p(),verdict:p().nullable(),status:p(),reason:p().nullable()}),ox=w({event:Nk,run:SD.nullable(),pending:D().optional()}),kD=w({repoFullName:p(),subjectNumber:P().int(),title:p(),url:p().nullable(),actor:w({login:p(),avatarUrl:p().nullable()}),currentVerdict:p().nullable(),currentRunId:p().nullable(),latestActivityAt:pe.datetime(),eventCount:P().int(),timeline:k(ox)}),xD=It("type",[w({type:C("group"),group:kD}),w({type:C("event"),entry:ox})]),aae=w({items:k(xD)});var $D=["tripwire:read","tripwire:configure","tripwire:moderate","tripwire:admin"],lae=z($D);var TD="https://tripwire.sh/orgs";var dae=w({sub:p().min(1),azp:p().min(1).optional(),client_id:p().min(1).optional(),scope:p().optional(),[TD]:k(p()).optional()});var ED=["connect_mcp","install_app","sync_repos","pick_rules","turn_on_gate","verify_check"],sx=z(ED),ix=z(["active","waiting","completed","skipped","failed"]);var PD=p().regex(/^[A-Za-z0-9]{10}$/,"A run code is 10 letters or digits."),OD=/^([a-z0-9_-]+)#([A-Za-z0-9]{10})$/;function ax(e){let t=OD.exec(e.trim());if(!(t?.[1]&&t[2]))return null;return{org:t[1],code:t[2]}}var ID=w({status:ix,detail:p().max(256).nullable(),updatedAt:pe.datetime()}),AD=bf(sx,ID),mae=w({runCode:p().trim().min(1).max(200),stage:sx,status:ix,detail:p().trim().max(256).optional()}),cx=w({code:PD,stages:AD,completedAt:pe.datetime().nullable(),lastReportAt:pe.datetime().nullable()});function ux(e){return e?`Please help me set up Tripwire.
228
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of e.seen.entries()){let a=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(a.cycle){s(i);continue}if(a.count>1){if(e.reused==="ref")s(i)}}if(e.external)e.sharedDefsExtractedFor=e.external}function gS(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let n of t){if(!n||typeof n!=="object")return;gS(n);let o=Object.keys(n);if(o.length!==1||o[0]!=="type")return;let s=n.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 yS=new Set(["type","properties","required","additionalProperties"]),mS=["oneOf","anyOf"];function hS(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 Mp(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let i in s)if(!yS.has(i))return null;t.push(s)}let r={},n=new Set;for(let s of t){for(let i in s.properties){if(Object.prototype.hasOwnProperty.call(r,i))continue;let a=[];for(let u of t){let l=u.properties?.[i]??hS(u);if(l===null||l===void 0)continue;if(!a.some((d)=>JSON.stringify(d)===JSON.stringify(l)))a.push(l)}let c=a.length===1?a[0]:Mp(a)??{allOf:a};bt(r,i,c)}for(let i of s.required??[])n.add(i)}let o={type:"object",properties:r};if(n.size)o.required=[...n];if(t.every((s)=>s.additionalProperties===!1))o.additionalProperties=!1;else{let s=[];for(let i of t){let a=hS(i);if(a&&!s.some((c)=>JSON.stringify(c)===JSON.stringify(a)))s.push(a)}if(s.length===1)o.additionalProperties=s[0];else if(s.length>1)o.additionalProperties={allOf:s}}return o}function wL(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of yS)if(o in e)return;let r=t.filter((o)=>mS.some((s)=>Array.isArray(o[s]))),n=null;if(!r.length)n=Mp(t);else{let o=r[0],s=mS.find((c)=>Array.isArray(o[c]));if(Object.keys(o).length!==1)return;let i=t.filter((c)=>c!==o),a=o[s].map((c)=>Mp([...i,c]));if(a.some((c)=>!c))return;n={[s]:a}}if(!n)return;delete e.allOf,Ls(e,n)}function qs(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let n=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,l={...u},d=c.ref;if(c.ref=null,d){n(d);let m=e.seen.get(d),h=m.schema;if(h.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))u.allOf=u.allOf??[],u.allOf.push(h);else Ls(u,h);if(Ls(u,l),a._zod.parent===d)for(let y in u){if(y==="$ref"||y==="allOf")continue;if(!(y in l))delete u[y]}if(h.$ref&&m.def)for(let y in u){if(y==="$ref"||y==="allOf")continue;if(y in m.def&&JSON.stringify(u[y])===JSON.stringify(m.def[y]))delete u[y]}}let f=a._zod.parent;if(f&&f!==d){n(f);let m=e.seen.get(f);if(m?.schema.$ref){if(u.$ref=m.schema.$ref,m.def)for(let h in u){if(h==="$ref"||h==="allOf")continue;if(h in m.def&&JSON.stringify(u[h])===JSON.stringify(m.def[h]))delete u[h]}}}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())n(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())gS(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let u of[c.schema,c.def]){let l=u?.allOf;if(!Array.isArray(l))continue;let d=a.get(l);if(d)d.push(u);else a.set(l,[u])}for(let c of e.intersections)for(let u of a.get(c)??[])wL(u)}}let o={};if(e.target==="draft-2020-12")o.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")o.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")o.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}Ls(o,r.defId?r.schema:r.def??r.schema);let s=e.metadataRegistry.get(t)?.id;if(s!==void 0&&o.id===s)delete o.id;let i=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;bt(i,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(i).length>0)if(e.target==="draft-2020-12")o.$defs=i;else o.definitions=i;try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:js(t,"input",e.processors),output:js(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function nt(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return nt(n.element,r);if(n.type==="set")return nt(n.valueType,r);if(n.type==="lazy")return nt(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault"||n.type==="catch")return nt(n.innerType,r);if(n.type==="intersection")return nt(n.left,r)||nt(n.right,r);if(n.type==="record"||n.type==="map")return nt(n.keyType,r)||nt(n.valueType,r);if(n.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return nt(n.in,r)||nt(n.out,r)}if(n.type==="object"){for(let o in n.shape)if(nt(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(nt(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(nt(o,r))return!0;if(n.rest&&nt(n.rest,r))return!0;return!1}return!1}var wS=(e,t={})=>(r)=>{let n=Ds({...r,processors:t});return _e(e,n),Ms(n,e),qs(n,e)},js=(e,t,r={})=>(n)=>{let{libraryOptions:o,target:s}=n??{},i=Ds({...o??{},target:s,io:t,processors:r});return _e(e,i),Ms(i,e),qs(i,e)};var fo=(e,t,r)=>{if(e[t]===void 0||r>e[t])e[t]=r},mo=(e,t,r)=>{if(e[t]===void 0||r<e[t])e[t]=r},bS=(e,t)=>{fo(e,"minimum",t),mo(e,"maximum",t)},xS=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},$S=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},TS=(e,t)=>{e.mime=e.mime?e.mime.filter((r)=>t.includes(r)):[...t]},ES=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},_S=(e,t)=>fo(e,"minimum",t.minimum),vS=(e,t)=>mo(e,"maximum",t.maximum),SS=(e)=>(t,r)=>{ES(t,r.format);let[n,o]=e[r.format];fo(t,"minimum",n),mo(t,"maximum",o)},bL={greater_than:(e,t)=>fo(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>mo(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>xS(e,t.value),number_format:SS(Aa),bigint_format:SS(Qd),min_length:_S,max_length:vS,length_equals:(e,t)=>bS(e,t.length),min_size:_S,max_size:vS,size_equals:(e,t)=>bS(e,t.size),string_format:(e,t)=>{if(ES(e,t.format),t.pattern)$S(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)=>TS(e,t.mime)};function ct(e){let t={},r=e._zod.def,n=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let s of n)bL[s._zod.def.check]?.(t,s._zod.def);let o=e._zod.bag;if(o.minimum!==void 0)fo(t,"minimum",o.minimum);if(o.exclusiveMinimum!==void 0)fo(t,"exclusiveMinimum",o.exclusiveMinimum);if(o.maximum!==void 0)mo(t,"maximum",o.maximum);if(o.exclusiveMaximum!==void 0)mo(t,"exclusiveMaximum",o.exclusiveMaximum);if(o.multipleOf!==void 0)xS(t,o.multipleOf);if(o.format!==void 0){if(t.format??(t.format=o.format),o.format.includes("int"))t.isInt=!0}if(o.mime)TS(t,o.mime);for(let s of o.patterns??[])$S(t,s);return t}var _L={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},vL=new Map([[yp,jb],[Ga,Db]]),PS=(e)=>vL.get(e)??e,Up=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u,laxFormat:l}=ct(e);if(typeof s==="number")o.minLength=s;if(typeof i==="number")o.maxLength=i;if(a){if(o.format=_L[a]??a,o.format==="")delete o.format;if(a==="time"||l)delete o.format}if(u)o.contentEncoding=u;if(c&&c.size>0){let d=[...c].map(PS);if(d.length===1)o.pattern=d[0].source;else if(d.length>1)o.allOf=[...d.map((f)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))]}},Wp=(e,t,r,n)=>{let o=r,{minimum:s,maximum:i,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:l}=ct(e);o.type=l?"integer":"number";let d=typeof u==="number"&&u>=(s??Number.NEGATIVE_INFINITY),f=typeof c==="number"&&c<=(i??Number.POSITIVE_INFINITY),m=t.target==="draft-04"||t.target==="openapi-3.0";if(d)if(m)o.minimum=u,o.exclusiveMinimum=!0;else o.exclusiveMinimum=u;else if(typeof s==="number")o.minimum=s;if(f)if(m)o.maximum=c,o.exclusiveMaximum=!0;else o.exclusiveMaximum=c;else if(typeof i==="number")o.maximum=i;if(a){let h=new Set;for(let b of a)if(Number.isFinite(b)&&b!==0)h.add(Math.abs(b));else Ve(e,t,o,n,`A multipleOf divisor of ${b} cannot be represented in JSON Schema`);let[g,...y]=h;if(g!==void 0)o.multipleOf=g;if(y.length)o.allOf=[...o.allOf??[],...y.map((b)=>({multipleOf:b}))]}},Vp=(e,t,r,n)=>{r.type="boolean"},OS=(e,t,r,n)=>{Ve(e,t,r,n,"BigInt cannot be represented in JSON Schema")},IS=(e,t,r,n)=>{Ve(e,t,r,n,"Symbols cannot be represented in JSON Schema")},Zp=(e,t,r,n)=>{if(t.target==="openapi-3.0")r.type="string",r.nullable=!0,r.enum=[null];else r.type="null"},AS=(e,t,r,n)=>{Ve(e,t,r,n,"Undefined cannot be represented in JSON Schema")},RS=(e,t,r,n)=>{Ve(e,t,r,n,"Void cannot be represented in JSON Schema")},Bp=(e,t,r,n)=>{r.not={}},Kp=(e,t,r,n)=>{},Hp=(e,t,r,n)=>{},CS=(e,t,r,n)=>{Ve(e,t,r,n,"Date cannot be represented in JSON Schema")},Gp=(e,t,r,n)=>{let o=e._zod.def,s=$s(o.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},Jp=(e,t,r,n)=>{let o=e._zod.def;if(o.values.length===0){r.not={};return}let s=[];for(let i of o.values)if(i===void 0){if(Ve(e,t,r,n,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i==="bigint"){if(Ve(e,t,r,n,"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}},zS=(e,t,r,n)=>{Ve(e,t,r,n,"NaN cannot be represented in JSON Schema")},Yp=(e,t,r,n)=>{let o=r,s=e._zod.pattern;if(!s)throw Error("Pattern not found in template literal");o.type="string",o.pattern=s.source},NS=(e,t,r,n)=>{let o=r;o.type="string",o.format="binary",o.contentEncoding="binary";let{minimum:s,maximum:i,mime:a}=ct(e);if(s!==void 0)o.minLength=s;if(i!==void 0)o.maxLength=i;if(!a)return;if(a.length===0)o.not={};else if(a.length===1)o.contentMediaType=a[0];else o.anyOf=a.map((c)=>({contentMediaType:c}))},LS=(e,t,r,n)=>{r.type="boolean"},Xp=(e,t,r,n)=>{Ve(e,t,r,n,"Custom types cannot be represented in JSON Schema")},jS=(e,t,r,n)=>{Ve(e,t,r,n,"Function types cannot be represented in JSON Schema")},Qp=(e,t,r,n)=>{Ve(e,t,r,n,"Transforms cannot be represented in JSON Schema")},DS=(e,t,r,n)=>{Ve(e,t,r,n,"Map cannot be represented in JSON Schema")},MS=(e,t,r,n)=>{Ve(e,t,r,n,"Set cannot be represented in JSON Schema")},ef=(e,t,r,n)=>{let o=r,s=e._zod.def,{minimum:i,maximum:a}=ct(e);if(typeof i==="number")o.minItems=i;if(typeof a==="number")o.maxItems=a;o.type="array",o.items=_e(s.element,t,{...n,path:[...n.path,"items"]})};function Fs(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return Fs(t.out);if(t.type==="catch")return Fs(t.innerType);return e._zod.optin}var tf=(e,t,r,n)=>{let o=r,s=e._zod.def,i=s.shape;if(Object.getOwnPropertySymbols(i).length&&Ve(e,t,o,n,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let u in i)bt(o.properties,u,_e(i[u],t,{...n,path:[...n.path,"properties",u]}));let c=[];for(let u of Object.keys(i)){let l=s.shape[u];if(t.io==="input"?Fs(l)===void 0:l._zod.optout===void 0)c.push(u)}if(c.length>0)o.required=c;if(s.catchall?._zod.def.type==="never")o.additionalProperties=!1;else if(!s.catchall){if(t.io==="output")o.additionalProperties=!1}else if(s.catchall)o.additionalProperties=_e(s.catchall,t,{...n,path:[...n.path,"additionalProperties"]})},rf=(e,t,r,n)=>{let o=e._zod.def,s=o.inclusive===!1,i=o.options.map((a,c)=>_e(a,t,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));if(s)r.oneOf=i;else r.anyOf=i},nf=(e,t,r,n)=>{let o=e._zod.def,s=_e(o.left,t,{...n,path:[...n.path,"allOf",0]}),i=_e(o.right,t,{...n,path:[...n.path,"allOf",1]}),a=(u)=>("allOf"in u)&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];r.allOf=c,t.intersections.push(c)},of=(e,t,r,n)=>{let o=r,s=e._zod.def;o.type="array";let i=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",c=s.items.map((g,y)=>_e(g,t,{...n,path:[...n.path,i,y]})),u=s.rest?_e(s.rest,t,{...n,path:[...n.path,a,...t.target==="openapi-3.0"?[s.items.length]:[]]}):null,l=s.items.length;while(l>0){let g=s.items[l-1];if(!(t.io==="input"?Fs(g)!==void 0:g._zod.optout==="optional"))break;l--}let d=s.items.length,f=!s.rest;if(t.target==="draft-2020-12"){if(o.prefixItems=c,f)o.items=!1;else if(u)o.items=u;if(l>0)o.minItems=l;if(f)o.maxItems=d}else if(t.target==="openapi-3.0"){if(o.items={anyOf:c},u)o.items.anyOf.push(u);if(l>0)o.minItems=l;if(f)o.maxItems=d}else{if(o.items=c,f)o.additionalItems=!1;else if(u)o.additionalItems=u;if(l>0)o.minItems=l;if(f)o.maxItems=d}let{minimum:m,maximum:h}=ct(e);if(typeof m==="number")o.minItems=m;if(typeof h==="number")o.maxItems=h};function qp(e,t,r){if(t.$ref){if(r.has(t))return t;r.add(t);let h=e.get(t)?.def;if(!h)return t;let g=qp(e,h,r);return g===h?t:g}for(let h of["anyOf","oneOf"]){let g=t[h];if(!Array.isArray(g))continue;let y=g.map((b)=>qp(e,b,r));if(y.some((b,T)=>b!==g[T]))t={...t,[h]:y}}let n=Array.isArray(t.type)?t.type:[t.type],o=!n.includes("string")&&n.some((h)=>h==="number"||h==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!o&&!s?.some((h)=>typeof h==="number"))return t;let{minimum:i,maximum:a,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:l,format:d,id:f,...m}=t;if(m.enum)m.enum=m.enum.map((h)=>typeof h==="number"?String(h):h);else if(typeof m.const==="number")m.const=String(m.const);if(!o)return m;if(m.type="string",!s)m.pattern=(n.includes("number")?uo:Wa).source;return m}var Fp=new WeakMap;function SL(e){let t=new Map;for(let n of e.seen.values())if(n.def&&!t.has(n.schema))t.set(n.schema,n);let r=new Map;for(let n of Fp.get(e)??[]){let o=e.seen.get(n),s=(o?.def??o?.schema)?.propertyNames;if(!s||s===!0||r.has(s))continue;let i=qp(t,s,new Set);if(i!==s)r.set(s,i)}if(!r.size)return;for(let n of e.seen.values())for(let o of[n.schema,n.def]){let s=o&&r.get(o.propertyNames);if(s)o.propertyNames=s}}var sf=(e,t,r,n)=>{let o=r,s=e._zod.def;o.type="object";let i=s.keyType,a=ct(i).patterns;if(s.mode==="loose"&&a&&a.size>0){let l=_e(s.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let d of a)bt(o.patternProperties,PS(d).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=_e(s.keyType,t,{...n,path:[...n.path,"propertyNames"]});let l=Fp.get(t);if(!l)l=[],Fp.set(t,l),t.deferred.push(()=>SL(t));l.push(e)}o.additionalProperties=_e(s.valueType,t,{...n,path:[...n.path,"additionalProperties"]})}let c=i._zod.values,u=t.io==="input"&&Fs(s.valueType)!==void 0;if(c&&!s.partial&&!u){let l=[...c].filter((d)=>typeof d==="string"||typeof d==="number");if(l.length>0)o.required=l.map(String)}},af=(e,t,r,n)=>{let o=e._zod.def,s=_e(o.innerType,t,n),i=t.seen.get(e);if(t.target==="openapi-3.0")i.ref=o.innerType,r.nullable=!0;else r.anyOf=[s,{type:"null"}]},cf=(e,t,r,n)=>{let o=e._zod.def;_e(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},uf=Symbol();function qS(e,t,r,n,o){let s=!1,i=JSON.stringify(e,(a,c)=>{if(typeof c!=="bigint")return c;return s=!0,null});if(!s)return JSON.parse(i);return Ve(t,r,n,o,"BigInt defaults cannot be represented in JSON Schema"),uf}var lf=(e,t,r,n)=>{let o=e._zod.def;_e(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i=qS(o.defaultValue,e,t,r,n);if(i!==uf)r.default=i},df=(e,t,r,n)=>{let o=e._zod.def;_e(o.innerType,t,n);let s=t.seen.get(e);if(s.ref=o.innerType,t.io!=="input")return;let i=qS(o.defaultValue,e,t,r,n);if(i!==uf)r._prefault=i},pf=(e,t,r,n)=>{let o=e._zod.def;_e(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{Ve(e,t,r,n,"Dynamic catch values are not supported in JSON Schema");return}r.default=i},ff=(e,t,r,n)=>{let o=e._zod.def,s=o.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?s?o.out:o.in:o.out;_e(i,t,n);let a=t.seen.get(e);a.ref=i},mf=(e,t,r,n)=>{let o=e._zod.def;_e(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType,r.readOnly=!0},FS=(e,t,r,n)=>{let o=e._zod.def;_e(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},uc=(e,t,r,n)=>{let o=e._zod.def;_e(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},hf=(e,t,r,n)=>{let o=e._zod.innerType;_e(o,t,n);let s=t.seen.get(e);s.ref=o},kS={string:Up,number:Wp,boolean:Vp,bigint:OS,symbol:IS,null:Zp,undefined:AS,void:RS,never:Bp,any:Kp,unknown:Hp,date:CS,enum:Gp,literal:Jp,nan:zS,template_literal:Yp,file:NS,success:LS,custom:Xp,function:jS,transform:Qp,map:DS,set:MS,array:ef,object:tf,union:rf,intersection:nf,tuple:of,record:sf,nullable:af,nonoptional:cf,default:lf,prefault:df,catch:pf,pipe:ff,readonly:mf,promise:FS,optional:uc,lazy:hf};function US(e,t){if("_idmap"in e){let n=e,o=Ds({...t,processors:kS}),s={};for(let c of n._idmap.entries()){let[u,l]=c;_e(l,o)}let i={},a={registry:n,uri:t?.uri,defs:s};o.external=a;for(let c of n._idmap.entries()){let[u,l]=c;Ms(o,l),bt(i,u,qs(o,l))}if(Object.keys(s).length>0){let c=o.target==="draft-2020-12"?"$defs":"definitions";i.__shared={[c]:s}}return{schemas:i}}let r=Ds({...t,processors:kS});return _e(e,r),Ms(r,e),qs(r,e)}var WS=new WeakSet([Object.prototype,Error.prototype]);function lc(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let n=r(this);return Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0})}})}var AL=(e,t)=>{db.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);if(WS.has(r))return;WS.add(r),lc(r,"format",(n)=>(o)=>ip(n,o)),lc(r,"flatten",(n)=>(o)=>sp(n,o)),lc(r,"addIssue",(n)=>(o)=>{n.issues.push(o),n.message=JSON.stringify(n.issues,Ts,2)}),lc(r,"addIssues",(n)=>(o)=>{n.issues.push(...o),n.message=JSON.stringify(n.issues,Ts,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var vt=O("ZodError",AL,void 0,{Parent:Error});var VS=Da(vt),ZS=Ma(vt),BS=Is(vt),KS=qa(vt),HS=mb(vt),GS=hb(vt),JS=gb(vt),YS=yb(vt),XS=wb(vt),QS=bb(vt),ek=_b(vt),tk=vb(vt);function CL(){if(!rt.localeError)at($p())}function Us(){if(!rt.memoizer)at({memoizer:xp()})}var ge=O("ZodType",(e,t)=>(CL(),fe.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(_t(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 Zt(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check($j(e,t))},superRefine(e,t){return this.check(Tj(e,t))},overwrite(e){return this.check(Wr(e))},optional(){return Te(this)},exactOptional(){return lj(this)},nullable(){return nk(this)},nullish(){return Te(nk(this))},nonoptional(e){return gj(this,e)},array(){return k(this)},or(e){return te([this,e])},and(e){return fc(this,e)},transform(e){return ok(this,dk(e))},default(e){return fj(this,e)},prefault(e){return hj(this,e)},catch(e){return wj(this,e)},pipe(e){return ok(this,e)},readonly(){return vj(this)},describe(e){let t=this.clone();return Ur.add(t,{description:e}),t},meta(...e){if(e.length===0)return Ur.get(this);let t=this.clone();return Ur.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 La(this,"~standard",{...gp(this),jsonSchema:{input:js(this,"input"),output:js(this,"output")}})},set "~standard"(e){$r(this,"~standard",e)},parse:function e(t,r){return VS(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await ZS(this,t,r,{callee:e})},safeParse(e,t){return BS(this,e,t)},async safeParseAsync(e,t){return KS(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){$r(this,"spa",e)},validate(e,t){return Fa(this,e,t)},validateAsync(e,t){return Ua(this,e,t)},encode:function e(t,r){return HS(this,t,r,{callee:e})},decode:function e(t,r){return GS(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await JS(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await YS(this,t,r,{callee:e})},safeEncode(e,t){return XS(this,e,t)},safeDecode(e,t){return QS(this,e,t)},async safeEncodeAsync(e,t){return ek(this,e,t)},async safeDecodeAsync(e,t){return tk(this,e,t)},toJSONSchema(e){return wS(this,{})(e)},get description(){return Ur.get(this)?.description},get _def(){return this._zod.def}}),sk=O("_ZodString",(e,t)=>{Ha.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Up(e,r,n,o)},sb({format:(e)=>ct(e).format??null,minLength:(e)=>ct(e).minimum??null,maxLength:(e)=>ct(e).maximum??null},{regex(...e){return this.check(Pp(...e))},includes(...e){return this.check(Ap(...e))},startsWith(...e){return this.check(Rp(...e))},endsWith(...e){return this.check(Cp(...e))},min(...e){return this.check(po(...e))},max(...e){return this.check(ac(...e))},length(...e){return this.check(cc(...e))},nonempty(...e){return this.check(po(1,...e))},lowercase(e){return this.check(Op(e))},uppercase(e){return this.check(Ip(e))},trim(){return this.check(Np())},normalize(...e){return this.check(zp(...e))},toLowerCase(){return this.check(Lp())},toUpperCase(){return this.check(jp())},slugify(){return this.check(Dp())}})),ik=O("ZodString",(e,t)=>{Ha.init(e,t),sk.init(e,t)},{email(e){return this.check(zv(zL,e))},url(e){return this.check(Ep(ak,e))},jwt(e){return this.check(eS(JL,e))},emoji(e){return this.check(qv(LL,e))},guid(e){return this.check(Nv(NL,e))},uuid(e){return this.check(Lv(dc,e))},uuidv4(e){return this.check(jv(dc,e))},uuidv6(e){return this.check(Dv(dc,e))},uuidv7(e){return this.check(Mv(dc,e))},nanoid(e){return this.check(Fv(jL,e))},cuid(e){return this.check(Uv(DL,e))},cuid2(e){return this.check(Wv(ML,e))},ulid(e){return this.check(Vv(qL,e))},base64(e){return this.check(Yv(KL,e))},base64url(e){return this.check(Xv(HL,e))},xid(e){return this.check(Zv(FL,e))},ksuid(e){return this.check(Bv(UL,e))},ipv4(e){return this.check(Kv(WL,e))},ipv6(e){return this.check(Hv(VL,e))},cidrv4(e){return this.check(Gv(ZL,e))},cidrv6(e){return this.check(Jv(BL,e))},e164(e){return this.check(Qv(GL,e))},datetime(e){return this.check(ec(Ws,e))},date(e){return this.check(tc(Vs,e))},time(e){return this.check(rc(Zs,e))},duration(e){return this.check(nc(Bs,e))}});function p(e){return Cv(ik,e)}var Oe=O("ZodStringFormat",(e,t)=>{xe.init(e,t),sk.init(e,t)}),Ws=O("ZodISODateTime",(e,t)=>{D_.init(e,t),Oe.init(e,t)}),Vs=O("ZodISODate",(e,t)=>{M_.init(e,t),Oe.init(e,t)}),Zs=O("ZodISOTime",(e,t)=>{q_.init(e,t),Oe.init(e,t)}),Bs=O("ZodISODuration",(e,t)=>{F_.init(e,t),Oe.init(e,t)}),zL=O("ZodEmail",(e,t)=>{E_.init(e,t),Oe.init(e,t)});var NL=O("ZodGUID",(e,t)=>{$_.init(e,t),Oe.init(e,t)});var dc=O("ZodUUID",(e,t)=>{T_.init(e,t),Oe.init(e,t)});var ak=O("ZodURL",(e,t)=>{I_.init(e,t),Oe.init(e,t)});function Ks(e){return Ep(ak,e)}var LL=O("ZodEmoji",(e,t)=>{A_.init(e,t),Oe.init(e,t)});var jL=O("ZodNanoID",(e,t)=>{R_.init(e,t),Oe.init(e,t)});var DL=O("ZodCUID",(e,t)=>{C_.init(e,t),Oe.init(e,t)});var ML=O("ZodCUID2",(e,t)=>{z_.init(e,t),Oe.init(e,t)});var qL=O("ZodULID",(e,t)=>{N_.init(e,t),Oe.init(e,t)});var FL=O("ZodXID",(e,t)=>{L_.init(e,t),Oe.init(e,t)});var UL=O("ZodKSUID",(e,t)=>{j_.init(e,t),Oe.init(e,t)});var WL=O("ZodIPv4",(e,t)=>{U_.init(e,t),Oe.init(e,t)});var VL=O("ZodIPv6",(e,t)=>{V_.init(e,t),Oe.init(e,t)});var ZL=O("ZodCIDRv4",(e,t)=>{Z_.init(e,t),Oe.init(e,t)});var BL=O("ZodCIDRv6",(e,t)=>{B_.init(e,t),Oe.init(e,t)});var KL=O("ZodBase64",(e,t)=>{H_.init(e,t),Oe.init(e,t)});var HL=O("ZodBase64URL",(e,t)=>{G_.init(e,t),Oe.init(e,t)});var GL=O("ZodE164",(e,t)=>{J_.init(e,t),Oe.init(e,t)});var JL=O("ZodJWT",(e,t)=>{Y_.init(e,t),Oe.init(e,t)});var pc=O("ZodNumber",(e,t)=>{wp.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Wp(e,r,n,o),e.isFinite=!0},sb({minValue:(e)=>{let{minimum:t,exclusiveMinimum:r}=ct(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:r}=ct(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:r}=ct(e);return!!t||!!r?.some(Number.isSafeInteger)},format:(e)=>ct(e).format??null},{gt(e,t){return this.check(sc(e,t))},gte(e,t){return this.check(Ns(e,t))},min(e,t){return this.check(Ns(e,t))},lt(e,t){return this.check(oc(e,t))},lte(e,t){return this.check(zs(e,t))},max(e,t){return this.check(zs(e,t))},int(e){return this.check(rk(e))},safe(e){return this.check(rk(e))},positive(e){return this.check(sc(0,e))},nonnegative(e){return this.check(Ns(0,e))},negative(e){return this.check(oc(0,e))},nonpositive(e){return this.check(zs(0,e))},multipleOf(e,t){return this.check(ic(e,t))},step(e,t){return this.check(ic(e,t))},finite(){return this}}));function P(e){return tS(pc,e)}var YL=O("ZodNumberFormat",(e,t)=>{X_.init(e,t),pc.init(e,t)});function rk(e){return nS(YL,e)}var ck=O("ZodBoolean",(e,t)=>{Q_.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Vp(e,r,n,o)});function D(e){return oS(ck,e)}var XL=O("ZodNull",(e,t)=>{ev.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Zp(e,r,n,o)});function Hs(e){return sS(XL,e)}var QL=O("ZodAny",(e,t)=>{tv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Kp(e,r,n,o)});function uk(){return iS(QL)}var ej=O("ZodUnknown",(e,t)=>{rv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Hp(e,r,n,o)});function ne(){return aS(ej)}var tj=O("ZodNever",(e,t)=>{nv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Bp(e,r,n,o)});function rj(e){return cS(tj,e)}var nj=O("ZodArray",(e,t)=>{Us(),ov.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ef(e,r,n,o),e.element=t.element},{min(e,t){return this.check(po(e,t))},nonempty(e){return this.check(po(1,e))},max(e,t){return this.check(ac(e,t))},length(e,t){return this.check(cc(e,t))},unwrap(){return this.element}});function k(e,t){return uS(nj,e,t)}var wf=O("ZodObject",(e,t)=>{Us(),av.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>tf(e,r,n,o),jN(e,"shape",(r)=>r._zod.def.shape,!1)},{keyof(){return z(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(_t(this._zod.def,{catchall:e}))},passthrough(){return this.clone(_t(this._zod.def,{catchall:ne()}))},loose(){return this.clone(_t(this._zod.def,{catchall:ne()}))},strict(){return this.clone(_t(this._zod.def,{catchall:rj()}))},strip(){return this.clone(_t(this._zod.def,{catchall:void 0}))},extend(e){return ON(this,e)},safeExtend(e){return IN(this,e)},merge(e){return AN(this,e)},pick(e){return EN(this,e)},omit(e){return PN(this,e)},partial(...e){return tb(_f,this,e[0])},exactPartial(...e){return tb(pk,this,e[0],"exactPartial")},required(...e){return RN(fk,this,e[0])}});function w(e,t){let r={type:"object",shape:e??{},...U(t)};return new wf(r)}function ve(e,t){return new wf({type:"object",shape:e,catchall:ne(),...U(t)})}var lk=O("ZodUnion",(e,t)=>{bp.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>rf(e,r,n,o),e.options=t.options});function te(e,t){return new lk({type:"union",options:e,...U(t)})}var oj=O("ZodDiscriminatedUnion",(e,t)=>{lk.init(e,t),cv.init(e,t)});function It(e,t,r){return new oj({type:"union",options:t,discriminator:e,...U(r)})}var sj=O("ZodIntersection",(e,t)=>{uv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>nf(e,r,n,o)});function fc(e,t){return new sj({type:"intersection",left:e,right:t})}var ij=O("ZodTuple",(e,t)=>{Us(),lv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>of(e,r,n,o)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map((t)=>new _f({type:"optional",innerType:t}))})}});function aj(e,t,r){let n=t instanceof fe,o=n?r:t;return new ij({type:"tuple",items:e,rest:n?t:null,...U(o)})}var gf=O("ZodRecord",(e,t)=>{Us(),dv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>sf(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function K(e,t,r){if(!t||!t._zod)return new gf({type:"record",keyType:p(),valueType:e,...U(t)});return new gf({type:"record",keyType:e,valueType:t,...U(r)})}function bf(e,t,r){return new gf({type:"record",keyType:e,valueType:t,...U(r),partial:!0})}var yf=O("ZodEnum",(e,t)=>{pv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(n,o,s)=>Gp(e,n,o,s),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{let s={};for(let i of n)if(r.has(i))s[i]=t.entries[i];else throw Error(`Key ${i} not found in enum`);return new yf({...t,checks:[],...U(o),entries:s})},e.exclude=(n,o)=>{let s={...t.entries};for(let i of n)if(r.has(i))delete s[i];else throw Error(`Key ${i} not found in enum`);return new yf({...t,checks:[],...U(o),entries:s})}});function z(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map((n)=>[n,n])):e;return new yf({type:"enum",entries:r,...U(t)})}var cj=O("ZodLiteral",(e,t)=>{fv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Jp(e,r,n,o),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 C(e,t){return new cj({type:"literal",values:Array.isArray(e)?e:[e],...U(t)})}var uj=O("ZodTransform",(e,t)=>{Us(),mv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Qp(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Os(e.constructor.name);r.addIssue=(s)=>{if(typeof s==="string")r.issues.push(Cn(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(Cn(i))}};let o=t.transform(r.value,r);if(o instanceof Promise)return o.then((s)=>(r.value=s,r));return r.value=o,r}});function dk(e){return new uj({type:"transform",transform:e})}var _f=O("ZodOptional",(e,t)=>{_p.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>uc(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Te(e){return new _f({type:"optional",innerType:e})}var pk=O("ZodExactOptional",(e,t)=>{hv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>uc(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function lj(e){return new pk({type:"optional",innerType:e})}var dj=O("ZodNullable",(e,t)=>{gv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>af(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function nk(e){return new dj({type:"nullable",innerType:e})}var pj=O("ZodDefault",(e,t)=>{yv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>lf(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function fj(e,t){return new pj({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():Yd(t)}})}var mj=O("ZodPrefault",(e,t)=>{wv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>df(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function hj(e,t){return new mj({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():Yd(t)}})}var fk=O("ZodNonOptional",(e,t)=>{bv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>cf(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function gj(e,t){return new fk({type:"nonoptional",innerType:e,...U(t)})}var yj=O("ZodCatch",(e,t)=>{_v.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>pf(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function wj(e,t){return new yj({type:"catch",innerType:e,catchValue:typeof t==="function"?t:ib(t)})}var mk=O("ZodPipe",(e,t)=>{vp.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ff(e,r,n,o),e.in=t.in,e.out=t.out});function ok(e,t){return new mk({type:"pipe",in:e,out:t})}var bj=O("ZodPreprocess",(e,t)=>{mk.init(e,t),vv.init(e,t)}),_j=O("ZodReadonly",(e,t)=>{Sv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>mf(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function vj(e){return new _j({type:"readonly",innerType:e})}var Sj=O("ZodTemplateLiteral",(e,t)=>{kv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Yp(e,r,n,o)});function kj(e,t){return new Sj({type:"template_literal",parts:e,...U(t)})}var xj=O("ZodLazy",(e,t)=>{xv.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>hf(e,r,n,o),e.unwrap=()=>e._zod.def.getter()});function vf(e){return new xj({type:"lazy",getter:e})}var hk=O("ZodCustom",(e,t)=>{$v.init(e,t),ge.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Xp(e,r,n,o)});function mc(e,t){return lS(hk,e??(()=>!0),t)}function $j(e,t={}){return dS(hk,e,t)}function Tj(e,t){return pS(e,t)}function At(e){let t=vf(()=>te([p(e),P(),D(),Hs(),k(t),K(p(),t)]));return t}function hc(e,t){return new bj({type:"pipe",in:dk(e),out:t})}var yk={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};var gk;(function(e){})(gk||(gk={}));function wk(e){return ec(Ws,e)}function Pj(e){return tc(Vs,e)}function Oj(e){return rc(Zs,e)}function Ij(e){return nc(Bs,e)}function Aj(e){return rS(pc,e)}var _k={name:"@tripwire-sh/cli",version:"0.1.8",description:"Set up Tripwire in your coding agents and manage it from the terminal",type:"module",imports:{"#/*":"./src/*"},license:"MIT",repository:{type:"git",url:"git+https://github.com/Boring-Software-Inc/v2.git",directory:"apps/cli"},homepage:"https://tripwire.sh",bin:{tripwire:"dist/tripwire.js"},files:["dist"],engines:{node:">=20.12"},publishConfig:{access:"public"},scripts:{build:"bun build src/index.ts --target node --format esm --minify --outfile dist/tripwire.js",typecheck:"tsc --noEmit"},devDependencies:{"@clack/prompts":"^1.7.0","@modelcontextprotocol/sdk":"^1.32.1","@tripwire/contracts":"workspace:*",commander:"^14.0.3","jsonc-parser":"^3.3.1",picocolors:"^1.1.1",yaml:"^2.9.0",zod:"^4.0.0"}};var gc=_k.version,q="tripwire",Gs="tripwire-get-started",vk="tripwire-workflows",Js="tripwire-cli",Cj="https://mcp.tripwire.sh/mcp",zj="https://app.tripwire.sh/api/auth",Sk="offline_access tripwire:read tripwire:configure tripwire:moderate tripwire:admin";function go(e){return e.TRIPWIRE_MCP_URL||Cj}function kk(e){return(e.TRIPWIRE_AUTH_URL||zj).replace(/\/+$/,"")}var Nj="urn:ietf:params:oauth:grant-type:device_code",Lj=w({device_code:p(),user_code:p(),verification_uri:p(),verification_uri_complete:p().optional(),expires_in:P(),interval:P().optional()}),$k=w({access_token:p().min(1),refresh_token:p().min(1).optional(),expires_in:P().optional(),token_type:p().optional()}),kf=w({error:p(),error_description:p().optional()});class Sf extends Error{constructor(){super("Session expired. Run tripwire login.");this.name="SessionExpiredError"}}class Ys extends Error{constructor(){super("Tripwire is not reachable right now. Try again in a minute.");this.name="AuthUnreachableError"}}var Tk={fetch:(e,t)=>fetch(e,t),sleep:(e)=>new Promise((t)=>setTimeout(t,e)),now:()=>Date.now()};async function yc(e,t,r){let n=await e.fetch(t,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded",accept:"application/json"},body:new URLSearchParams(r).toString()}),o=await n.text(),s={error:"invalid_response",error_description:o.slice(0,200)};try{let i=At().safeParse(JSON.parse(o));return{status:n.status,body:i.success?i.data:s,headers:n.headers}}catch{return{status:n.status,body:s,headers:n.headers}}}function Ek(e,t){let r=kf.safeParse(e);if(!r.success)return Error(t);return Error(r.data.error_description?`${r.data.error}: ${r.data.error_description}`:r.data.error)}async function Pk(e,t,r){let{status:n,body:o}=await yc(e,`${t}/device/code`,{client_id:Js,scope:Sk,resource:r}),s=Lj.safeParse(o);if(n>=400||!s.success)throw Ek(o,`Device authorization failed (HTTP ${n})`);return s.data}function Ok(e,t,r,n,o){let s=t.refresh_token??o;return{accessToken:t.access_token,refreshToken:s,expiresAt:t.expires_in?e.now()+t.expires_in*1000:void 0,mcpUrl:n,authUrl:r}}var xk=5000;function jj(e,t){let r=(e.get("retry-after")??e.get("x-retry-after"))?.trim();if(!r)return null;if(/^\d+$/.test(r))return Number(r)*1000;let n=Date.parse(r);return Number.isNaN(n)?null:Math.max(0,n-t)}async function Ik(e,t,r,n){let o=(n.interval??5)*1000,s=null,i=e.now()+n.expires_in*1000;while(e.now()<i){await e.sleep(Math.min(Math.max(o,s??0),i-e.now())),s=null;let{status:a,body:c,headers:u}=await yc(e,`${t}/oauth2/token`,{grant_type:Nj,device_code:n.device_code,client_id:Js,resource:r}),l=$k.safeParse(c);if(a<400&&l.success)return Ok(e,l.data,t,r);if(a===429){if(s=jj(u,e.now()),s===null)o+=xk;continue}let d=kf.safeParse(c),f=d.success?d.data.error:"";if(f==="authorization_pending")continue;if(f==="slow_down"){o+=xk;continue}if(f==="access_denied")throw Error("Sign-in was denied in the browser");if(f==="expired_token")throw Error("The code expired. Run tripwire login again.");throw Ek(c,`Token request failed (HTTP ${a})`)}throw Error("The code expired. Run tripwire login again.")}async function Ak(e,t){if(!t.refreshToken)throw new Sf;let{status:r,body:n}=await yc(e,`${t.authUrl}/oauth2/token`,{grant_type:"refresh_token",refresh_token:t.refreshToken,client_id:Js,resource:t.mcpUrl}).catch(()=>{throw new Ys}),o=$k.safeParse(n);if(r>=400||!o.success){let s=kf.safeParse(n);throw(r===400||r===401)&&s.success&&s.data.error!=="invalid_response"?new Sf:new Ys}return Ok(e,o.data,t.authUrl,t.mcpUrl,t.refreshToken)}async function Rk(e,t){let r=t.refreshToken??t.accessToken;await yc(e,`${t.authUrl}/oauth2/revoke`,{token:r,client_id:Js}).catch(()=>{return})}import{stripVTControlCharacters as MF}from"node:util";var Dj=z(["pending","approved","rejected"]),Aie=Dj.options;var Xs=[{id:"github",label:"GitHub",status:"live",signIn:"social",reviews:!0},{id:"opengit",label:"OpenGit",status:"live",paused:!0},{id:"gitlab",label:"GitLab",status:"planned"},{id:"origin",label:"ORIGIN",status:"planned"}];function Ck(e){return e.status==="live"}var Qs=z(Xs.filter(Ck).map((e)=>e.id)),zie=Xs.filter((e)=>Ck(e)&&!("paused"in e)).map((e)=>e.label),Nie=Xs.filter((e)=>e.status==="planned").map((e)=>e.label),Lie=Xs.filter((e)=>("signIn"in e)).map((e)=>e.id);var Mj=Object.fromEntries(Xs.map((e)=>[e.id,e]));var wc=w({owner:p(),name:p(),fullName:p()}),qj=w({id:p(),login:p(),name:p(),type:z(["Organization","User"]),avatarUrl:p(),repoAccess:z(["all","selected"]),repoCount:P(),installedAt:pe.datetime()}),Fj=w({id:p(),owner:p(),name:p(),fullName:p(),private:D(),pushedAt:pe.datetime(),openFlags:P(),stars:P()}),Mie=w({accounts:k(qj),repos:k(Fj)});var ei=z(["change-request.opened","change-request.updated","change-request.closed","comment.created","push","schedule.matched","installation.created","installation.deleted","installation-repositories.added","installation-repositories.removed"]),zk=w({login:p(),externalId:p(),avatarUrl:p().optional()}),xf=w({number:P().int(),title:p(),headSha:p(),baseRef:p().optional(),headRef:p().optional(),draft:D().optional(),url:p()}),Uj=w({externalId:p(),body:p(),url:p(),subjectNumber:P().int(),byTripwire:D().optional()}),Wj=w({ref:p(),headSha:p(),commitCount:P().int(),url:p().optional()}),_c=z(["issue","change-request"]),Vj=w({kind:_c,number:P().int(),title:p(),url:p(),state:z(["open","closed"]),author:p(),labels:k(p()),locked:D(),updatedAt:pe.datetime()}),Zj=w({workflowId:p(),nodeId:p(),tickId:p()}),yo={id:p(),forge:Qs,deliveryId:p(),repo:wc,repoExternalId:p().optional(),installationExternalId:p().optional(),actor:zk,occurredAt:pe.datetime(),receivedAt:pe.datetime()},bc={id:p(),forge:Qs,deliveryId:p(),actor:zk,occurredAt:pe.datetime(),receivedAt:pe.datetime(),installation:w({externalId:p(),account:p(),accountType:z(["User","Organization"]).optional()}),repositories:k(w({externalId:p(),owner:p(),name:p(),fullName:p(),private:D()}))},Nk=It("kind",[w({...yo,kind:C("change-request.opened"),changeRequest:xf}),w({...yo,kind:C("change-request.updated"),changeRequest:xf}),w({...yo,kind:C("change-request.closed"),changeRequest:xf}),w({...yo,kind:C("comment.created"),comment:Uj}),w({...yo,kind:C("push"),push:Wj}),w({...yo,kind:C("schedule.matched"),schedule:Zj,thread:Vj}),w({...bc,kind:C("installation.created")}),w({...bc,kind:C("installation.deleted")}),w({...bc,kind:C("installation-repositories.added")}),w({...bc,kind:C("installation-repositories.removed")})]),Bj=ei.extract(["change-request.opened","change-request.updated","change-request.closed"]),Vie=Bj.options;var Kj=["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"],Hj=["sun","mon","tue","wed","thu","fri","sat"],Gj=[{name:"minute",range:"0 to 59",min:0,max:59},{name:"hour",range:"0 to 23",min:0,max:23},{name:"day of month",range:"1 to 31",min:1,max:31},{name:"month",range:"1 to 12 or jan to dec",min:1,max:12,names:Kj,nameBase:1},{name:"day of week",range:"0 to 7 or sun to sat",min:0,max:7,names:Hj,nameBase:0}];function $f(e,t){let r=e.toLowerCase(),n=t.names?.indexOf(r)??-1;if(n>=0)return n+(t.nameBase??0);if(!/^\d+$/.test(e))return null;let o=Number(e);return o>=t.min&&o<=t.max?o:null}function Jj(e,t){let r=new Set;for(let n of e.split(",")){let o=n.split("/"),[s="",i]=o;if(o.length>2||s.split("-").length>2)return{ok:!1,error:`${t.name} must be a number, a range like 1-5 or a step like */15`};let a=i===void 0?1:Number(i);if(!(Number.isInteger(a)&&a>=1))return{ok:!1,error:`${t.name} step must be a whole number of 1 or more, like */15`};let c,u;if(s==="*")c=t.min,u=t.max;else if(s.includes("-")){let[l="",d=""]=s.split("-");c=$f(l,t),u=$f(d,t)}else c=$f(s,t),u=i===void 0?c:t.max;if(c===null||u===null)return{ok:!1,error:`${t.name} must be ${t.range}`};if(c>u)return{ok:!1,error:`${t.name} range must go from low to high, like 1-5`};for(let l=c;l<=u;l+=a)r.add(l)}return{ok:!0,values:[...r].sort((n,o)=>n-o)}}function zn(e){let t=e.trim().split(/\s+/);if(t.length!==5)return{ok:!1,error:"use five fields: minute hour day month weekday"};let r=[];for(let[u,l]of Gj.entries()){let d=Jj(t[u]??"",l);if(!d.ok)return d;r.push(d.values)}let[n=[],o=[],s=[],i=[],a=[]]=r,c=[...new Set(a.map((u)=>u===7?0:u))].sort((u,l)=>u-l);return{ok:!0,spec:{minutes:n,hours:o,days:s,months:i,weekdays:c,daysRestricted:!(t[2]??"*").startsWith("*"),weekdaysRestricted:!(t[4]??"*").startsWith("*")}}}function ti(e){try{return new Intl.DateTimeFormat("en-US",{timeZone:e}),!0}catch{return!1}}var Lk=new Map;function Yj(e){let t=Lk.get(e);if(t)return t;let r=new Intl.DateTimeFormat("en-US",{timeZone:e,hourCycle:"h23",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"});return Lk.set(e,r),r}function Pf(e,t){let r=Yj(t).formatToParts(e),n=(o)=>Number(r.find((s)=>s.type===o)?.value??"0");return{year:n("year"),month:n("month"),day:n("day"),hour:n("hour"),minute:n("minute")}}function Tf(e,t){let r=Pf(new Date(e),t),n=Date.UTC(r.year,r.month-1,r.day,r.hour,r.minute),o=e-(e%60000+60000)%60000;return n-o}function jk(e,t){let r=Date.UTC(e.year,e.month-1,e.day,e.hour,e.minute),n=[r-Tf(r-129600000,t),r-Tf(r+129600000,t),r-Tf(r,t)].sort((o,s)=>o-s);for(let o of n){let s=Pf(new Date(o),t);if(s.year===e.year&&s.month===e.month&&s.day===e.day&&s.hour===e.hour&&s.minute===e.minute)return new Date(o)}return null}function vc(e,t,r){let n=e.days.includes(t),o=e.weekdays.includes(r);if(e.daysRestricted&&e.weekdaysRestricted)return n||o;return n&&o}function Xj(e,t){return vc(e,t.getUTCDate(),t.getUTCDay())}var Qj=Array.from({length:217},(e,t)=>({day:t%31+1,weekday:Math.floor(t/31)}));function Ef(e){let t=Qj.map(({day:r,weekday:n})=>vc(e,r,n)?"1":"0").join("");return[e.minutes,e.hours,e.months].map((r)=>r.join(",")).concat(t).join(" ")}function Dk(e,t){let r=zn(e),n=zn(t);return r.ok&&n.ok&&Ef(r.spec)===Ef(n.spec)}var eD=1830,tD=180;function rD(e,t){let r=jk(e,t);if(r)return r;let n=Date.UTC(e.year,e.month-1,e.day,e.hour,e.minute);for(let o=1;o<=tD;o++){let s=new Date(n+o*60000),i=jk({year:s.getUTCFullYear(),month:s.getUTCMonth()+1,day:s.getUTCDate(),hour:s.getUTCHours(),minute:s.getUTCMinutes()},t);if(i)return i}return null}function Mk(e){let{minutes:t,hours:r}=e,n=t.slice(1).map((s,i)=>s-(t[i]??0));if(r.some((s)=>r.includes((s+1)%24)))n.push(60-(t.at(-1)??0)+(t[0]??0));return n.length>0?Math.min(...n):1440}function Of(e,t,r){let n=Pf(r,t),o=new Date(Date.UTC(n.year,n.month-1,n.day));for(let s=0;s<=eD;s++){if(e.months.includes(o.getUTCMonth()+1)&&Xj(e,o))for(let i of e.hours)for(let a of e.minutes){let c=rD({year:o.getUTCFullYear(),month:o.getUTCMonth()+1,day:o.getUTCDate(),hour:i,minute:a},t);if(c&&c.getTime()>r.getTime())return c}o.setUTCDate(o.getUTCDate()+1)}return null}var Rt=5,qe=vf(()=>te([p(),P(),D(),Hs(),k(qe),K(p(),qe)])),xc=w({x:P(),y:P()}),nD=z(["all-of","any-of","not"]),oD=z(["block","comment","label","request-review","send-to-moderation","webhook","discord","lock","close","remove-label","post-comment"]),sD=["comment"];function Fk(e){return sD.includes(e)}var Jie=w({url:Ks().meta({secret:!0}).describe("webhook url"),signingSecret:p().min(1).optional().meta({secret:!0}).describe("signing secret")}),Yie=w({url:Ks().meta({secret:!0}).describe("discord webhook url")}),wo=15,$c=p().regex(/^[A-Za-z0-9](?:[A-Za-z0-9]|-(?=[A-Za-z0-9])){0,38}$/,{error:(e)=>`${String(e.input)} is not a GitHub username`}),If=p().regex(/^[A-Za-z0-9][A-Za-z0-9_-]{0,99}$/,{error:(e)=>`${String(e.input)} is not a team slug`}),Af=w({id:P().int().positive().optional(),login:$c}),Xie=w({id:P().int().positive(),login:$c,avatarUrl:p(),permission:p().min(1)}),Qie=w({name:p().min(1),color:p().regex(/^[0-9a-fA-F]{6}$/),description:p().nullable()}),iD=hc((e)=>p().safeParse(e).success?{login:e}:e,Af);function Uk(e,t){return e.id!==void 0&&t.id!==void 0?e.id===t.id:e.login.toLowerCase()===t.login.toLowerCase()}var ri=w({reviewers:k(iD).max(wo,`ask at most ${wo} people`).default([]),teamReviewers:k(If).max(wo,`ask at most ${wo} teams`).default([])}),Wk=ri.superRefine((e,t)=>{let r=e.reviewers.length+e.teamReviewers.length;if(r===0)t.addIssue({code:"custom",message:"add at least one person or team to ask"});if(r>wo)t.addIssue({code:"custom",message:`ask at most ${wo} people and teams`})}),Zr=w({labels:k(p().trim().min(1)).min(1,"choose at least one label")}),qk=5000,Tc=w({message:p().trim().min(1,"write a message").max(qk,`keep it under ${qk} characters`)}),aD=z(["resolved","off-topic","too heated","spam"]),Vk=w({reason:aD.optional()}),ni={hours:3600000,days:86400000,weeks:604800000,months:2592000000};function Rf(e){return e.n*ni[e.unit]}var Ec=52*ni.weeks,cD=3650*ni.days,uD=z(["hours","days","weeks"]),lD=z(["hours","days","weeks","months"]),dD=w({n:P().int().min(1),unit:uD}).refine((e)=>Rf(e)<=Ec,{message:"runs at least once a year"}),rr="UTC",Zk=p().min(1).refine(ti,{error:(e)=>`${String(e.input)} is not an IANA timezone, like Europe/Berlin`}),Sc=p().regex(/^([01]\d|2[0-3]):[0-5]\d$/,"use 24-hour HH:MM, like 07:30"),Cf=z(["sunday","monday","tuesday","wednesday","thursday","friday","saturday"]),pD=It("preset",[w({preset:C("hourly"),minute:P().int().min(0).max(59)}),w({preset:C("daily"),at:Sc}),w({preset:C("weekdays"),at:Sc}),w({preset:C("weekly"),on:Cf,at:Sc}),w({preset:C("monthly"),day:P().int().min(1).max(28),at:Sc})]),Pc=w({cron:p().trim().superRefine((e,t)=>{let r=zn(e);if(!r.ok){t.addIssue({code:"custom",message:r.error});return}if(Of(r.spec,"UTC",new Date(Date.UTC(2026,0,1)))===null)t.addIssue({code:"custom",message:"this cron never runs. Pick a day the month has"});if(Mk(r.spec)<Rt)t.addIssue({code:"custom",message:`runs must be at least ${Rt} minutes apart`})})}),Bk=te([dD,pD,Pc]),Kk=w({n:P().int().min(1),unit:lD}).refine((e)=>Rf(e)<=cD,{message:"10 years at most"}),Hk=z(["open","closed","any"]),kc=k(p().min(1)),fD=w({subjects:k(_c).min(1),state:Hk,inactiveFor:Kk,labels:kc.optional(),excludeLabels:kc.optional(),skipLocked:D().default(!0)}),bo=w({every:Bk,timezone:Zk.optional(),match:fD}),mD=w({every:Bk.optional(),timezone:Zk.optional(),match:w({subjects:k(_c).optional(),state:Hk.optional(),inactiveFor:Kk.optional(),labels:kc.optional(),excludeLabels:kc.optional(),skipLocked:D().optional()}).default({})});var hD=["every","subjects","state","inactiveFor"];function Gk(e){return hD.filter((t)=>{if(!e)return!0;if(t==="every")return e.every===void 0;let r=e.match[t];return Array.isArray(r)?r.length===0:r===void 0})}var Vr=p(),gD=w({id:Vr,type:C("trigger"),kinds:k(ei).min(1),schedule:mD.optional(),position:xc.optional()});function Oc(e){return e.type==="trigger"&&(e.kinds??[]).includes("schedule.matched")}var yD=w({id:Vr,type:C("rule"),ref:p().regex(/^[a-z][a-z0-9-]*@\d+$/),config:qe,position:xc.optional()}),wD=w({id:Vr,type:C("gate"),mode:nD,position:xc.optional()}),bD=w({id:Vr,type:C("action"),action:oD,params:K(p(),qe).optional(),position:xc.optional()}),zf=It("type",[gD,yD,wD,bD]),Jk=z(["pass","fail","approve","deny"]),_D=w({id:p(),from:Vr,to:Vr,when:Jk.optional()}),ut=w({id:p(),name:p(),version:P().int().min(1),nodes:k(zf).min(1),edges:k(_D)}),Yk={id:"default@1",name:"default gate",version:1,nodes:[{id:"trigger",type:"trigger",kinds:["change-request.opened","change-request.updated"]},{id:"account-age",type:"rule",ref:"account-age@1",config:{minDays:7}},{id:"crypto",type:"rule",ref:"crypto-address@1",config:{}},{id:"honeypot",type:"rule",ref:"honeypot@1",config:{paths:[".github/workflows/**"]}},{id:"max-files",type:"rule",ref:"max-files-changed@1",config:{max:200}},{id:"english",type:"rule",ref:"english-only@1",config:{maxNonLatinRatio:0.5}},{id:"gate",type:"gate",mode:"all-of"},{id:"block",type:"action",action:"block"}],edges:[{id:"e1",from:"trigger",to:"account-age"},{id:"e2",from:"trigger",to:"crypto"},{id:"e3",from:"trigger",to:"honeypot"},{id:"e4",from:"trigger",to:"max-files"},{id:"e5",from:"trigger",to:"english"},{id:"e6",from:"account-age",to:"gate"},{id:"e7",from:"crypto",to:"gate"},{id:"e8",from:"honeypot",to:"gate"},{id:"e9",from:"max-files",to:"gate"},{id:"e10",from:"english",to:"gate"},{id:"e11",from:"gate",to:"block",when:"fail"}]};var Xk=[{kind:"change-request.opened",name:"Change request opened",description:"Runs when someone opens a change request.",toolbox:!0},{kind:"change-request.updated",name:"Change request updated",description:"Runs when a change request gets new commits or edits.",toolbox:!0},{kind:"change-request.closed",name:"Change request closed",description:"Runs when a change request is closed.",toolbox:!0},{kind:"comment.created",name:"Comment created",description:"Runs when someone comments on a change request or issue.",toolbox:!0},{kind:"push",name:"Push",description:"Runs when commits are pushed to the repo.",toolbox:!0},{kind:"schedule.matched",name:"On a schedule",description:"Runs on a timer for issues and change requests that match.",toolbox:!0},{kind:"installation.created",name:"Installation created",description:"Internal event. Installations sync outside workflows.",toolbox:!1},{kind:"installation.deleted",name:"Installation deleted",description:"Internal event. Installations sync outside workflows.",toolbox:!1},{kind:"installation-repositories.added",name:"Repos added",description:"Internal event. Installations sync outside workflows.",toolbox:!1},{kind:"installation-repositories.removed",name:"Repos removed",description:"Internal event. Installations sync outside workflows.",toolbox:!1}],Qk=[{mode:"all-of",name:"All of",description:"Passes only when every connected check passes. A check that was never reached does not pass."},{mode:"any-of",name:"Any of",description:"Passes when at least one connected check passes. A check that was never reached does not pass."},{mode:"not",name:"Not",description:"Flips its input: pass becomes fail, and fail becomes pass."}],ex=[{action:"block",name:"Block",description:"Fails the Tripwire check and requests changes. The change request stays open."},{action:"label",name:"Label",description:"Adds labels you choose to the change request."},{action:"request-review",name:"Request GitHub review",description:"Asks the people you choose to review on GitHub."},{action:"send-to-moderation",name:"Human review",description:"Waits for a maintainer to approve or block it in Tripwire."},{action:"webhook",name:"Webhook",description:"Posts the verdict as JSON to a URL you set."},{action:"lock",name:"Lock",description:"Locks the conversation so only maintainers can comment."},{action:"close",name:"Close",description:"Closes the issue or change request."},{action:"remove-label",name:"Remove label",description:"Removes labels you choose, if they are there."},{action:"post-comment",name:"Comment",description:"Posts a comment you write. It is separate from the verdict comment."},{action:"discord",name:"Discord",description:"Posts the verdict to a Discord channel you set."}];var nae=K(p(),qe).catch({});function Ic(e){if(e.length<=1)return e[0]??"";return`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`}function tx(e){let t=Zr.safeParse(e);return t.success?t.data.labels:[]}function rx(e){return`${e.length===1?"the label":"the labels"} ${Ic(e)}`}function vD(e){let t=ri.safeParse(e);if(!t.success)return[];return[...t.data.reviewers.map((r)=>r.login),...t.data.teamReviewers]}function nx(e,t){switch(e){case"block":return"blocks it";case"label":{let r=tx(t);return r.length>0?`adds ${rx(r)}`:"adds labels"}case"remove-label":{let r=tx(t);return r.length>0?`removes ${rx(r)}`:"removes labels"}case"request-review":{let r=vD(t);return r.length>0?`requests GitHub review from ${Ic(r)}`:"requests GitHub review"}case"send-to-moderation":return"sends it to human review";case"webhook":return"posts the verdict to a webhook";case"discord":return"posts the verdict to Discord";case"lock":return"locks the conversation";case"close":return"closes it";case"post-comment":return"posts your comment";default:return e}}var SD=w({runId:p(),verdict:p().nullable(),status:p(),reason:p().nullable()}),ox=w({event:Nk,run:SD.nullable(),pending:D().optional()}),kD=w({repoFullName:p(),subjectNumber:P().int(),title:p(),url:p().nullable(),actor:w({login:p(),avatarUrl:p().nullable()}),currentVerdict:p().nullable(),currentRunId:p().nullable(),latestActivityAt:pe.datetime(),eventCount:P().int(),timeline:k(ox)}),xD=It("type",[w({type:C("group"),group:kD}),w({type:C("event"),entry:ox})]),aae=w({items:k(xD)});var $D=["tripwire:read","tripwire:configure","tripwire:moderate","tripwire:admin"],lae=z($D);var TD="https://tripwire.sh/orgs";var dae=w({sub:p().min(1),azp:p().min(1).optional(),client_id:p().min(1).optional(),scope:p().optional(),[TD]:k(p()).optional()});var ED=["connect_mcp","install_app","sync_repos","pick_rules","turn_on_gate","verify_check"],sx=z(ED),ix=z(["active","waiting","completed","skipped","failed"]);var PD=p().regex(/^[A-Za-z0-9]{10}$/,"A run code is 10 letters or digits."),OD=/^([a-z0-9_-]+)#([A-Za-z0-9]{10})$/;function ax(e){let t=OD.exec(e.trim());if(!(t?.[1]&&t[2]))return null;return{org:t[1],code:t[2]}}var ID=w({status:ix,detail:p().max(256).nullable(),updatedAt:pe.datetime()}),AD=bf(sx,ID),mae=w({runCode:p().trim().min(1).max(200),stage:sx,status:ix,detail:p().trim().max(256).optional()}),cx=w({code:PD,stages:AD,completedAt:pe.datetime().nullable(),lastReportAt:pe.datetime().nullable()});function ux(e){return e?`Please help me set up Tripwire.
229
229
 
230
230
  org slug: ${e.org}
231
231
  run code: ${e.code}`:"Please help me set up Tripwire."}var RD=200,CD=z(["read","write","edit","delete"]),zD=w({id:Vr,action:CD,at:pe.datetime()}),ND=k(zD).max(RD),oi=k(p()),LD=w({renamed:D(),nodes:w({added:oi,changed:oi,removed:oi}),edges:w({added:oi,removed:oi})}),jD=w({userId:p(),clientId:p(),name:p(),lastSignalAt:pe.datetime(),finishedAt:pe.datetime().nullable(),nodes:ND}),DD=z(["open","promoted","discarded"]),MD=w({id:p(),name:p(),status:DD,definition:ut.nullable(),revision:P().int().min(0),lastChange:LD.nullable(),createdAt:pe.datetime(),updatedAt:pe.datetime(),expiresAt:pe.datetime()}),qD=w({repoId:p(),definitionId:p(),workflowId:p().nullable(),draft:MD.nullable(),agents:k(jD)}),bae=It("type",[w({type:C("work"),repoFullName:p(),work:qD}),w({type:C("setup"),orgId:p(),run:cx})]),_ae=It("type",[w({type:C("work"),repoId:p(),definitionId:p()}),w({type:C("setup"),runId:p()})]);var kae=z(["ready","out"]),lx=z(["ai-out-of-credits"]);var xae=ve({statusCode:P().optional().catch(void 0),status:P().optional().catch(void 0),message:p().optional().catch(void 0),responseBody:p().optional().catch(void 0),lastError:ne().optional(),cause:ne().optional(),data:ne().optional(),error:ne().optional(),errors:k(ne()).optional().catch(void 0)});var $ae=w({data:w({total_credits:P(),total_usage:P()})}),Tae=w({data:w({limit:P().nullable().optional(),limit_remaining:P().nullable().optional(),usage:P().optional()})});var FD=z(["success","failure","neutral","pending"]),Oae=w({sha:p(),conclusion:FD,summary:p(),detailsUrl:p()});var UD=["matched-values","file-paths","ai-trace","ai-summary","reasons","rule-names","passed-count","failed-count"],WD=UD.length;var VD=P().int().min(0).max(WD),dx=z(["run-page","check","comment","review","webhook"]),Rae=dx.options,ZD=["run-page","check","comment","review"],Ac=w({level:VD.default(0),surfaces:k(dx).default(()=>[...ZD]),showHelp:D().default(!0)}),px=Ac.extend({inherit:D().default(!0)}),BD=Ac.parse({});var KD=z(["green","blue","purple","pink","orange","red","grey"]),Er=z(["issue","pull"]),si=z(["open","closed","merged"]),fx=w({key:p(),label:p(),value:P(),delta:P().optional(),invertDelta:D().optional(),sub:p().optional(),series:k(P()),color:KD,suffix:p().optional()}),HD=w({rule:p(),count:P()}),GD=w({kind:Er,number:P(),title:p(),comments:P(),blocked:P(),status:si}),JD=w({login:p(),count:P(),flagged:D().optional()}),YD=w({login:p(),reason:p(),caughtBy:p(),status:z(["Hidden","Removed"]),commentId:p().optional()}),XD=w({kind:z(["review","check"]),title:p(),detail:p(),status:z(["Approved","Changes","Passed","Failed"]),actor:p().optional()}),QD=w({kind:Er,number:P(),title:p(),status:si,meta:p(),metrics:k(fx),series:k(P()),byParticipant:k(JD),flagged:k(YD).optional(),checks:k(XD).optional()}),Nae=w({metrics:k(fx),blockedByRule:k(HD),activeThreads:k(GD),threads:K(p(),QD)});var vo=z(["issue","pull","comment"]),Nf=z(["spam","harassment","off-topic","automod","nsfw"]),Lf=z(["low","medium","high","critical"]),eM=z(["pending","resolved"]),_o=w({login:p(),avatarUrl:p()}),Mae=w({id:p(),type:vo,repository:wc,number:P(),title:p(),bodyPreview:p(),author:_o,reason:Nf,severity:Lf,reporter:_o.nullable(),automodRule:p().optional(),reportedAt:pe.datetime(),status:eM,comments:P(),reactions:P()}).superRefine((e,t)=>{if(e.reporter===null&&e.automodRule===void 0)t.addIssue({code:"custom",path:["automodRule"],message:"automod-sourced items (reporter: null) must name the automodRule that fired"});if(e.reporter!==null&&e.automodRule!==void 0)t.addIssue({code:"custom",path:["automodRule"],message:"human-reported items (reporter set) must not carry an automodRule"})}),Br=w({value:P(),delta:P(),series:k(P())}),qae=w({sentToReview:Br,blocked:Br,passed:Br}),Fae=z(["approve","remove","ban"]);var tM=z(["info","warn","critical"]),rM=w({severity:tM,file:p(),line:P().int().min(1).optional(),note:p().max(240)}),Vae=w({verdict:z(["pass","block","needs_review"]),confidence:P().min(0).max(1),summary:p().max(200),findings:k(rM).max(5)}),mx=w({model:p().optional(),maxSteps:P().int().min(1).max(15).default(12)});var nM=w({type:z(["reasoning","tool_call"]),toolName:p().optional(),excerpt:p(),truncated:D()}),Zae=w({model:p(),stepsUsed:P().int().min(0),maxSteps:P().int().min(0),trimmed:D(),costUsd:P().nullable().optional(),usage:w({input:P().int().min(0),output:P().int().min(0),cached:P().int().min(0).nullable()}),steps:k(nM)});var oM=z(["blocklist","heuristic","classifier","regex"]),sM=z(["flag","hide","close","require-review"]),iM=z(["pending","confirmed","false-positive"]),aM=w({id:p(),type:vo,repoFullName:p(),number:P(),author:w({login:p(),avatarUrl:p()}),snippet:p(),matchedAt:pe.datetime(),verdict:iM,threadKind:Er,commentId:p()}),ece=w({id:p(),name:p(),description:p(),category:oM,pattern:p(),scope:k(vo),action:sM,enabled:D(),matches24h:P(),matches30d:P(),falsePositiveRate:P().min(0).max(100),lastFiredAt:pe.datetime(),trend:k(P()),recentMatches:k(aM)}),tce=w({activeRules:Br,matches24h:Br,falsePositiveRate:Br,autoActioned24h:Br}),cM=w({ruleId:p(),version:P().int().min(1),status:z(["evaluated","skipped"]),passed:D(),evidence:ne(),reason:p().optional(),cause:lx.optional(),evaluatedAt:pe.datetime()}),rce=cM.pick({ruleId:!0});var uM=w({minDays:P().int().min(0)}),nce=w({min:P().int().min(0)}),lM=w({min:P().int().min(0).default(1).describe("minimum merged change requests in other people's repos"),trustedAfter:P().int().min(1).default(1).describe("merges in this repo that exempt a proven local contributor")}),dM=w({maxPerWindow:P().int().min(1),windowHours:P().min(0.1).default(24)}),pM=w({max:P().int().min(1)}),fM=w({maxNonLatinRatio:P().min(0).max(1).default(0.5)}),mM=w({}),hM=w({paths:k(p()).min(1)}),gM=w({minLength:P().int().min(1).default(32)}),Ge=[{ruleId:"account-age",forges:["github"],version:1,name:"Account age",blurb:"the contributor's forge account must be at least N days old.",configSchema:uM,defaultConfig:{minDays:7},optIn:!1,description:"Flags change requests from accounts younger than a threshold you set.",contributorLabel:"your account is too new for this repository."},{ruleId:"min-merged-prs",forges:["github"],version:2,name:"Merged change requests",blurb:"requires N merged change requests in OTHER people's repos, as proof that someone else accepted their work.",configSchema:lM,defaultConfig:{min:1,trustedAfter:1},optIn:!1,changeNote:"counts merges globally, not per-repo",description:"Requires N merged change requests in other people's repos, as proof that someone else accepted their work.",contributorLabel:"you need merged change requests in other people's repositories first."},{ruleId:"pr-rate-limit",forges:["github"],version:1,name:"Rate limit",blurb:"caps change requests per window; spray patterns surface in evidence.",configSchema:dM,defaultConfig:{maxPerWindow:5,windowHours:24},optIn:!1,description:"Caps how many change requests one person can open in a time window.",contributorLabel:"you opened too many change requests in a short time."},{ruleId:"max-files-changed",forges:["github"],version:1,name:"Max files changed",blurb:"caps the number of files a change request may touch.",configSchema:pM,defaultConfig:{max:200},optIn:!1,description:"Flags change requests that touch more files than you allow.",contributorLabel:"this change request changes too many files. Split it into smaller ones."},{ruleId:"english-only",version:1,name:"English only",blurb:"title/comment must be predominantly latin-script.",configSchema:fM,defaultConfig:{maxNonLatinRatio:0.5},optIn:!1,description:"Flags titles and comments that aren't mostly latin script.",contributorLabel:"write the title and comments in English.",evidenceRedaction:{"matched-values":["sample"]}},{ruleId:"crypto-address",forges:["github"],version:1,name:"Crypto address",blurb:"blocks cryptocurrency addresses in titles, comments, and diffs.",configSchema:mM,defaultConfig:{},optIn:!1,description:"Catches cryptocurrency addresses in titles, comments, and diffs.",contributorLabel:"this change request adds crypto wallet addresses. Remove them.",summaryReveals:["file-paths"],evidenceRedaction:{"matched-values":["matches.*.value"],"file-paths":["matches.*.location"]}},{ruleId:"honeypot",forges:["github"],version:1,name:"Honeypot paths",blurb:"no legitimate change request touches these paths.",configSchema:hM,defaultConfig:{paths:[".github/workflows/**"]},optIn:!1,description:"Catches change requests that touch paths no legitimate change would.",contributorLabel:"this change request changes protected files. Undo those changes.",evidenceRedaction:{"file-paths":["touched"]}},{ruleId:"profile-readme",forges:["github"],version:1,name:"Profile README",blurb:"requires a minimum of profile text, which shows identity investment.",configSchema:gM,defaultConfig:{minLength:32},optIn:!1,description:"Requires a minimum of profile text. Throwaway accounts rarely add one.",contributorLabel:"add a short bio to your profile."},{ruleId:"ai-review",forges:["github"],version:2,name:"AI review",blurb:"reads the change like a reviewer and flags slop.",configSchema:mx,defaultConfig:{maxSteps:12},optIn:!0,changeNote:"findings must quote code",description:"Reads the change like a reviewer and flags slop.",contributorLabel:"this change request has problems a reviewer would flag.",summaryReveals:["ai-summary"],evidenceRedaction:{"matched-values":["output.findings.*.note"],"file-paths":["output.findings.*.file","output.findings.*.line"]}}];var dce=K(p(),qe);var bM=z(["silent","ci-check","comment"]),hx=z(["comment","silent"]),_M=z(["full","one-liner-link","custom"]),jf=w({customText:p().max(4000).default(""),showDetailsButton:D().default(!0)}),vM=jf.extend({mode:_M.default("full"),template:p().max(4000).default("")}),SM=w({onSuccess:bM.default("ci-check"),passComment:jf.prefault({}),onBlock:hx.default("comment"),blockComment:vM.prefault({}),moderationQueued:hx.default("comment"),reviewComment:jf.prefault({}),failClosedFallback:D().default(!0),redaction:px.prefault({})}),kM=w({redaction:Ac.prefault({})}),hce=kM.parse({});var xM=SM.parse({});var gx="If you think this is wrong, say so in a comment. A maintainer will decide.",yx="If you think it should merge anyway, say so in a comment. A maintainer will decide.",Pce=`Push a commit that fixes the problems. Tripwire checks every push.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tripwire-sh/cli",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Set up Tripwire in your coding agents and manage it from the terminal",
5
5
  "type": "module",
6
6
  "imports": {