@tripwire-sh/cli 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tripwire.js +1 -1
- 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=Kn,c=!et.jitless,l=c&&Gy.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 s_([],g,m,h,f,e,h?.abortEarly===!0)}return r(m,h)}});function pw(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)=>!$t(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)=>Bt(i,n,it())))}),t}var Rd=O("$ZodUnion",(e,t)=>{pe.init(e,t),te(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),te(e,"optout",(n)=>n.def.options.some((o)=>o._zod.optout==="optional")?"optional":void 0),te(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}),te(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)=>Rr(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 pw(i,n,e,o);return Promise.all(i).then((a)=>pw(a,n,e,o))}});function Ez(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 a_=O("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Rd.init(e,t);let r=e._zod.parse;te(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))gt(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=ds(()=>Ez(t));e._zod.parse=(o,s)=>{let i=o.value;if(!Kn(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}}),c_=O("$ZodIntersection",(e,t)=>{pe.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])=>fw(r,c,u));return fw(r,s,i)}});function Td(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(xn(e)&&xn(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=Td(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=Td(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 fw(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=Td(t.value,r.value);if(!c.valid){if($t(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var u_=O("$ZodTuple",(e,t)=>{pe.init(e,t);let r=t.items,n=et.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=mw(r,"optin"),u=mw(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=$t(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($t(o,g))break;g=o.issues.length}m++;let _=t.rest._zod.run({value:y,issues:[]},s);if(_ instanceof Promise)a.push(_.then((T)=>hw(T,o,m)));else hw(_,o,m)}}if(a.length)return Promise.all(a).then(()=>gw(l,o,r,i,u));return gw(l,o,r,i,u)}});function mw(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 hw(e,t,r){if(e.issues.length)t.issues.push(...Zt(r,e.issues));t.value[r]=e.value}function gw(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(...Zt(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 l_=O("$ZodRecord",(e,t)=>{pe.init(e,t);let r=et.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!xn(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)=>Bt(h,o,it())),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(...Zt(l,h.issues));n.value[f]=h.value}));else{if(m.issues.length)n.issues.push(...Zt(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"&&Gn.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)=>Bt(h,o,it())),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(...Zt(u,h.issues));n.value[f]=h.value}));else{if(m.issues.length)n.issues.push(...Zt(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 d_=O("$ZodEnum",(e,t)=>{pe.init(e,t);let r=us(t.entries),n=new Set(r);e._zod.values=n,te(e,"pattern",(o)=>{let s=us(o.def.entries).filter((i)=>Jy.has(typeof i));return new RegExp(s.length?`^(${s.map((i)=>gr(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}}),p_=O("$ZodLiteral",(e,t)=>{pe.init(e,t);let r=new Set(t.values);e._zod.values=r,te(e,"pattern",(n)=>{let o=n.def.values;return new RegExp(o.length?`^(${o.map((s)=>typeof s==="string"?gr(s):s?gr(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 f_=O("$ZodTransform",(e,t)=>{pe.init(e,t),e._zod.optin="optional",et.memoizer?.guard(e),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new fs(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 Ht;return r.value=o,r}});function yw(e,t){return e.value=t.issues.length?void 0:t.value,e}var Cd=O("$ZodOptional",(e,t)=>{pe.init(e,t),te(e,"optin",(r)=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",te(e,"values",(r)=>{let n=r.def.innerType._zod.values;return n?new Set([...n,void 0]):void 0}),te(e,"pattern",(r)=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${Rr(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)=>yw(r,s));return yw(r,o)}return t.innerType._zod.run(r,n)}}),m_=O("$ZodExactOptional",(e,t)=>{Cd.init(e,t),te(e,"values",(r)=>r.def.innerType._zod.values),te(e,"pattern",(r)=>r.def.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),h_=O("$ZodNullable",(e,t)=>{pe.init(e,t),te(e,"optin",(r)=>r.def.innerType._zod.optin),te(e,"optout",(r)=>r.def.innerType._zod.optout),te(e,"pattern",(r)=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${Rr(n.source)}|null)$`):void 0}),te(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)}}),g_=O("$ZodDefault",(e,t)=>{pe.init(e,t),e._zod.optin="defaulted",te(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)=>bw(s,t));return bw(o,t)}});function bw(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var y_=O("$ZodPrefault",(e,t)=>{pe.init(e,t),e._zod.optin="defaulted",te(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)}}),b_=O("$ZodNonOptional",(e,t)=>{pe.init(e,t),te(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)=>ww(s,e));return ww(o,e)}});function ww(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 _w(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)=>Bt(o,n,it()))},input:e.value}),e}var w_=O("$ZodCatch",(e,t)=>{pe.init(e,t),te(e,"optin",(r)=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),te(e,"optout",(r)=>r.def.innerType._zod.optout),te(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)=>_w(r,s,t,n));return _w(r,o,t,n)}});var zd=O("$ZodPipe",(e,t)=>{pe.init(e,t),te(e,"values",(r)=>r.def.in._zod.values),te(e,"optin",(r)=>r.def.in._zod.optin),te(e,"optout",(r)=>r.def.out._zod.optout),te(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)=>Sa(i,t.in,n));return Sa(s,t.in,n)}let o=t.in._zod.run(r,n);if(o instanceof Promise)return o.then((s)=>Sa(s,t.out,n));return Sa(o,t.out,n)}});function Sa(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 __=O("$ZodPreprocess",(e,t)=>{zd.init(e,t)}),v_=O("$ZodReadonly",(e,t)=>{pe.init(e,t),te(e,"propValues",(r)=>r.def.innerType._zod.propValues),te(e,"values",(r)=>r.def.innerType._zod.values),te(e,"optin",(r)=>r.def.innerType?._zod?.optin),te(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(vw);return vw(o)}});function vw(e){if(!e.memo)e.value=Object.freeze(e.value);return e}function Tz(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 Zb({minimum:o,maximum:s}).source;let i=e._zod.pattern;return(n&&i===Gn?_a:i)?.source}function Od(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=Od(n);if(r&&o&&s&&s!==o)return r.replace(Rr(o),()=>Rr(s));return r}if(t.options){let o=t.options.map(Od);if(o.every(Boolean))return`^(${o.map((s)=>Rr(s)).join("|")})$`}return Tz(e)}var S_=O("$ZodTemplateLiteral",(e,t)=>{pe.init(e,t);let r=[];for(let n of t.parts)if(typeof n==="object"&&n!==null){let o=Od(n);if(!o)throw Error(`Invalid template literal part, no pattern found: ${[...n._zod.traits].shift()}`);r.push(Rr(o))}else if(n===null||Yy.has(typeof n))r.push(gr(`${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 x_=O("$ZodLazy",(e,t)=>{pe.init(e,t),Vy(e._zod,"innerType",()=>{let r=t;if(!r._cachedInner)r._cachedInner=t.getter();return r._cachedInner}),te(e,"pattern",(r)=>r.innerType?._zod?.pattern),te(e,"propValues",(r)=>r.innerType?._zod?.propValues),te(e,"optin",(r)=>r.innerType?._zod?.optin??void 0),te(e,"optout",(r)=>r.innerType?._zod?.optout??void 0),e._zod.parse=(r,n)=>e._zod.innerType._zod.run(r,n)}),k_=O("$ZodCustom",(e,t)=>{Be.init(e,t),pe.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)=>Sw(s,r,n,e));Sw(o,r,n,e);return}});function Sw(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(kn(o))}}class E_ extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var Ld="~memo",$_=[];function T_(e){return e!==null&&typeof e==="object"}function Nd(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var O_=new WeakMap,gs=0,Pa=1,ys=2;function Aa(e,t,r){let n=O_.get(e);if(n!==void 0)return n?ys:gs;if(t.has(e))return ys;t.add(e);let o=gs,s=(l)=>{if(o!==ys&&l?._zod){let d=Aa(l,t,r);if(d>o)o=d}},i=(l,d)=>{let f=gs;for(let m of Reflect.ownKeys(l)){let h=Object.getOwnPropertyDescriptor(l,m);if(d&&!h.enumerable)continue;let g=h.get?Pa:h.value?._zod?Aa(h.value,t,r):gs;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):Pa),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?Aa(l,t,!1):Pa);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),Oz(e,o)}function Oz(e,t){if(t!==Pa)O_.set(e,t===ys);return t}function Pz(e,t){let r=e.buckets.get(t);if(!r)r=new WeakMap,e.buckets.set(t,r);return r}var Ta,Oa=[],Az={alloc(e,t,r){let n=Ta;if(!n)return r;Ta=void 0;let o={value:r,issues:null};return n.set(t.value,o),Oa.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"&&Iz(s,o.value))throw new E_;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 _=Aa(e,new Set,!1);if(_===gs){if(e._zod.parse=i,e._zod.run===a)e._zod.run=i;return i(c,u)}if(_===ys||n)r=!0;else n=!0}let l=c.value;if(!T_(l))return i(c,u);let d=u[Ld];if(!d)d={buckets:new WeakMap,backEdges:void 0},u[Ld]=d;let f;if(o===u)f=s;else f=Pz(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(...Nd(m.issues))}else c.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(m.value);return c}Ta=f;let h=Oa.length,g=i(c,u);Ta=void 0;let y=Oa.length>h?Oa.pop():void 0;if(g instanceof Promise)return g.then((_)=>{if(y)y.issues=_.issues.length?Nd(_.issues):$_;return _});if(y)y.issues=g.issues.length?Nd(g.issues):$_;return g};if(e._zod.parse=a,e._zod.run===i)e._zod.run=a})}};function jd(){return Az}function Iz(e,t){let r=e[Ld]?.backEdges;return r!==void 0&&T_(t)&&r.has(t)}var Rz=()=>{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=rb(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 ${dd(s.values[0])}`;return`Invalid option: expected one of ${cd(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":""}: ${cd(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 Dd(){return{localeError:Rz()}}var P_;class A_{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 I_(){return new A_}(P_=globalThis).__zod_globalRegistry??(P_.__zod_globalRegistry=I_());var Cr=globalThis.__zod_globalRegistry;function Md(e){if(e.checks)e.checks=[...e.checks];return e}function R_(e,t){return new e(Md({type:"string",...F(t)}))}function C_(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...F(t)})}function z_(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...F(t)})}function N_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...F(t)})}function L_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...F(t)})}function j_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...F(t)})}function D_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...F(t)})}function qd(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...F(t)})}function M_(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...F(t)})}function q_(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...F(t)})}function F_(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...F(t)})}function U_(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...F(t)})}function W_(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...F(t)})}function V_(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...F(t)})}function Z_(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...F(t)})}function B_(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...F(t)})}function H_(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...F(t)})}function K_(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...F(t)})}function G_(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...F(t)})}function J_(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...F(t)})}function Y_(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...F(t)})}function X_(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...F(t)})}function Q_(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...F(t)})}function Ia(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...F(t)})}function Ra(e,t){return new e({type:"string",format:"date",check:"string_format",...F(t)})}function Ca(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...F(t)})}function za(e,t){return new e({type:"string",format:"duration",check:"string_format",...F(t)})}function ev(e,t){return new e(Md({type:"number",checks:[],...F(t)}))}function tv(e,t){return new e(Md({type:"number",coerce:!0,checks:[],...F(t)}))}function rv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...F(t)})}function nv(e,t){return new e({type:"boolean",...F(t)})}function ov(e,t){return new e({type:"null",...F(t)})}function sv(e){return new e({type:"any"})}function iv(e){return new e({type:"unknown"})}function av(e,t){return new e({type:"never",...F(t)})}function Na(e,t){return new kd({check:"less_than",...F(t),value:e,inclusive:!1})}function bs(e,t){return new kd({check:"less_than",...F(t),value:e,inclusive:!0})}function La(e,t){return new $d({check:"greater_than",...F(t),value:e,inclusive:!1})}function ws(e,t){return new $d({check:"greater_than",...F(t),value:e,inclusive:!0})}function ja(e,t){return new Jb({check:"multiple_of",...F(t),value:e})}function Da(e,t){return new Xb({check:"max_length",...F(t),maximum:e})}function Yn(e,t){return new Qb({check:"min_length",...F(t),minimum:e})}function Ma(e,t){return new ew({check:"length_equals",...F(t),length:e})}function Fd(e,t){return new tw({check:"string_format",format:"regex",...F(t),pattern:e})}function Ud(e){return new rw({check:"string_format",format:"lowercase",...F(e)})}function Wd(e){return new nw({check:"string_format",format:"uppercase",...F(e)})}function Vd(e,t){return new ow({check:"string_format",format:"includes",...F(t),includes:e})}function Zd(e,t){return new sw({check:"string_format",format:"starts_with",...F(t),prefix:e})}function Bd(e,t){return new iw({check:"string_format",format:"ends_with",...F(t),suffix:e})}function zr(e){return new aw({check:"overwrite",tx:e})}function Hd(e){return zr((t)=>t.normalize(e))}function Kd(){return zr((e)=>e.trim())}function Gd(){return zr((e)=>e.toLowerCase())}function Jd(){return zr((e)=>e.toUpperCase())}function Yd(){return zr((e)=>Ky(e))}function cv(e,t,r){return new e({type:"array",element:t,...F(r)})}function uv(e,t,r){let n=F(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function lv(e,t,r){return new e({type:"custom",check:"custom",fn:t,...F(r)})}function dv(e,t){let r=Cz((n)=>(n.addIssue=(o)=>{if(typeof o==="string")n.issues.push(kn(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(kn(s))}},e(n.value,n)),t);return r}function Cz(e,t){let r=new Be({check:"custom",...F(t)});return r._zod.check=e,r}function _s(e,...t){for(let r of t)for(let n of Reflect.ownKeys(r))if(Object.prototype.propertyIsEnumerable.call(r,n))gt(e,n,r[n]);return e}function Ss(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??Cr,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 Fe(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 we(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;we(d,t,l),t.seen.get(d).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)_s(i.schema,c);if(t.io==="input"&&tt(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 pv(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function xs(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}/${pv(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+pv(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 hv(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;hv(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 gv=new Set(["type","properties","required","additionalProperties"]),fv=["oneOf","anyOf"];function mv(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 Xd(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let i in s)if(!gv.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]??mv(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]:Xd(a)??{allOf:a};gt(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=mv(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 zz(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of gv)if(o in e)return;let r=t.filter((o)=>fv.some((s)=>Array.isArray(o[s]))),n=null;if(!r.length)n=Xd(t);else{let o=r[0],s=fv.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)=>Xd([...i,c]));if(a.some((c)=>!c))return;n={[s]:a}}if(!n)return;delete e.allOf,_s(e,n)}function ks(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 _s(u,h);if(_s(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())hv(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)??[])zz(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)}_s(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;gt(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:vs(t,"input",e.processors),output:vs(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function tt(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 tt(n.element,r);if(n.type==="set")return tt(n.valueType,r);if(n.type==="lazy")return tt(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 tt(n.innerType,r);if(n.type==="intersection")return tt(n.left,r)||tt(n.right,r);if(n.type==="record"||n.type==="map")return tt(n.keyType,r)||tt(n.valueType,r);if(n.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return tt(n.in,r)||tt(n.out,r)}if(n.type==="object"){for(let o in n.shape)if(tt(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(tt(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(tt(o,r))return!0;if(n.rest&&tt(n.rest,r))return!0;return!1}return!1}var yv=(e,t={})=>(r)=>{let n=Ss({...r,processors:t});return we(e,n),xs(n,e),ks(n,e)},vs=(e,t,r={})=>(n)=>{let{libraryOptions:o,target:s}=n??{},i=Ss({...o??{},target:s,io:t,processors:r});return we(e,i),xs(i,e),ks(i,e)};var Xn=(e,t,r)=>{if(e[t]===void 0||r>e[t])e[t]=r},Qn=(e,t,r)=>{if(e[t]===void 0||r<e[t])e[t]=r},bv=(e,t)=>{Xn(e,"minimum",t),Qn(e,"maximum",t)},xv=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},kv=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},$v=(e,t)=>{e.mime=e.mime?e.mime.filter((r)=>t.includes(r)):[...t]},Ev=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},wv=(e,t)=>Xn(e,"minimum",t.minimum),_v=(e,t)=>Qn(e,"maximum",t.maximum),vv=(e)=>(t,r)=>{Ev(t,r.format);let[n,o]=e[r.format];Xn(t,"minimum",n),Qn(t,"maximum",o)},Nz={greater_than:(e,t)=>Xn(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Qn(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>xv(e,t.value),number_format:vv(ca),bigint_format:vv(pd),min_length:wv,max_length:_v,length_equals:(e,t)=>bv(e,t.length),min_size:wv,max_size:_v,size_equals:(e,t)=>bv(e,t.size),string_format:(e,t)=>{if(Ev(e,t.format),t.pattern)kv(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)=>$v(e,t.mime)};function at(e){let t={},r=e._zod.def,n=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let s of n)Nz[s._zod.def.check]?.(t,s._zod.def);let o=e._zod.bag;if(o.minimum!==void 0)Xn(t,"minimum",o.minimum);if(o.exclusiveMinimum!==void 0)Xn(t,"exclusiveMinimum",o.exclusiveMinimum);if(o.maximum!==void 0)Qn(t,"maximum",o.maximum);if(o.exclusiveMaximum!==void 0)Qn(t,"exclusiveMaximum",o.exclusiveMaximum);if(o.multipleOf!==void 0)xv(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)$v(t,o.mime);for(let s of o.patterns??[])kv(t,s);return t}var Lz={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},jz=new Map([[Ad,Lb],[Ea,jb]]),Tv=(e)=>jz.get(e)??e,tp=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u,laxFormat:l}=at(e);if(typeof s==="number")o.minLength=s;if(typeof i==="number")o.maxLength=i;if(a){if(o.format=Lz[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(Tv);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}))]}},rp=(e,t,r,n)=>{let o=r,{minimum:s,maximum:i,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:l}=at(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 _ of a)if(Number.isFinite(_)&&_!==0)h.add(Math.abs(_));else Fe(e,t,o,n,`A multipleOf divisor of ${_} 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((_)=>({multipleOf:_}))]}},np=(e,t,r,n)=>{r.type="boolean"},Ov=(e,t,r,n)=>{Fe(e,t,r,n,"BigInt cannot be represented in JSON Schema")},Pv=(e,t,r,n)=>{Fe(e,t,r,n,"Symbols cannot be represented in JSON Schema")},op=(e,t,r,n)=>{if(t.target==="openapi-3.0")r.type="string",r.nullable=!0,r.enum=[null];else r.type="null"},Av=(e,t,r,n)=>{Fe(e,t,r,n,"Undefined cannot be represented in JSON Schema")},Iv=(e,t,r,n)=>{Fe(e,t,r,n,"Void cannot be represented in JSON Schema")},sp=(e,t,r,n)=>{r.not={}},ip=(e,t,r,n)=>{},ap=(e,t,r,n)=>{},Rv=(e,t,r,n)=>{Fe(e,t,r,n,"Date cannot be represented in JSON Schema")},cp=(e,t,r,n)=>{let o=e._zod.def,s=us(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},up=(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(Fe(e,t,r,n,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i==="bigint"){if(Fe(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}},Cv=(e,t,r,n)=>{Fe(e,t,r,n,"NaN cannot be represented in JSON Schema")},lp=(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},zv=(e,t,r,n)=>{let o=r;o.type="string",o.format="binary",o.contentEncoding="binary";let{minimum:s,maximum:i,mime:a}=at(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}))},Nv=(e,t,r,n)=>{r.type="boolean"},dp=(e,t,r,n)=>{Fe(e,t,r,n,"Custom types cannot be represented in JSON Schema")},Lv=(e,t,r,n)=>{Fe(e,t,r,n,"Function types cannot be represented in JSON Schema")},pp=(e,t,r,n)=>{Fe(e,t,r,n,"Transforms cannot be represented in JSON Schema")},jv=(e,t,r,n)=>{Fe(e,t,r,n,"Map cannot be represented in JSON Schema")},Dv=(e,t,r,n)=>{Fe(e,t,r,n,"Set cannot be represented in JSON Schema")},fp=(e,t,r,n)=>{let o=r,s=e._zod.def,{minimum:i,maximum:a}=at(e);if(typeof i==="number")o.minItems=i;if(typeof a==="number")o.maxItems=a;o.type="array",o.items=we(s.element,t,{...n,path:[...n.path,"items"]})};function $s(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return $s(t.out);if(t.type==="catch")return $s(t.innerType);return e._zod.optin}var mp=(e,t,r,n)=>{let o=r,s=e._zod.def,i=s.shape;if(Object.getOwnPropertySymbols(i).length&&Fe(e,t,o,n,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let u in i)gt(o.properties,u,we(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"?$s(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=we(s.catchall,t,{...n,path:[...n.path,"additionalProperties"]})},hp=(e,t,r,n)=>{let o=e._zod.def,s=o.inclusive===!1,i=o.options.map((a,c)=>we(a,t,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));if(s)r.oneOf=i;else r.anyOf=i},gp=(e,t,r,n)=>{let o=e._zod.def,s=we(o.left,t,{...n,path:[...n.path,"allOf",0]}),i=we(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)},yp=(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)=>we(g,t,{...n,path:[...n.path,i,y]})),u=s.rest?we(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"?$s(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}=at(e);if(typeof m==="number")o.minItems=m;if(typeof h==="number")o.maxItems=h};function Qd(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=Qd(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((_)=>Qd(e,_,r));if(y.some((_,T)=>_!==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")?Gn:_a).source;return m}var ep=new WeakMap;function Dz(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 ep.get(e)??[]){let o=e.seen.get(n),s=(o?.def??o?.schema)?.propertyNames;if(!s||s===!0||r.has(s))continue;let i=Qd(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 bp=(e,t,r,n)=>{let o=r,s=e._zod.def;o.type="object";let i=s.keyType,a=at(i).patterns;if(s.mode==="loose"&&a&&a.size>0){let l=we(s.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let d of a)gt(o.patternProperties,Tv(d).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=we(s.keyType,t,{...n,path:[...n.path,"propertyNames"]});let l=ep.get(t);if(!l)l=[],ep.set(t,l),t.deferred.push(()=>Dz(t));l.push(e)}o.additionalProperties=we(s.valueType,t,{...n,path:[...n.path,"additionalProperties"]})}let c=i._zod.values,u=t.io==="input"&&$s(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)}},wp=(e,t,r,n)=>{let o=e._zod.def,s=we(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"}]},_p=(e,t,r,n)=>{let o=e._zod.def;we(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},vp=Symbol();function Mv(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 Fe(t,r,n,o,"BigInt defaults cannot be represented in JSON Schema"),vp}var Sp=(e,t,r,n)=>{let o=e._zod.def;we(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i=Mv(o.defaultValue,e,t,r,n);if(i!==vp)r.default=i},xp=(e,t,r,n)=>{let o=e._zod.def;we(o.innerType,t,n);let s=t.seen.get(e);if(s.ref=o.innerType,t.io!=="input")return;let i=Mv(o.defaultValue,e,t,r,n);if(i!==vp)r._prefault=i},kp=(e,t,r,n)=>{let o=e._zod.def;we(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{Fe(e,t,r,n,"Dynamic catch values are not supported in JSON Schema");return}r.default=i},$p=(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;we(i,t,n);let a=t.seen.get(e);a.ref=i},Ep=(e,t,r,n)=>{let o=e._zod.def;we(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType,r.readOnly=!0},qv=(e,t,r,n)=>{let o=e._zod.def;we(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},qa=(e,t,r,n)=>{let o=e._zod.def;we(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},Tp=(e,t,r,n)=>{let o=e._zod.innerType;we(o,t,n);let s=t.seen.get(e);s.ref=o},Sv={string:tp,number:rp,boolean:np,bigint:Ov,symbol:Pv,null:op,undefined:Av,void:Iv,never:sp,any:ip,unknown:ap,date:Rv,enum:cp,literal:up,nan:Cv,template_literal:lp,file:zv,success:Nv,custom:dp,function:Lv,transform:pp,map:jv,set:Dv,array:fp,object:mp,union:hp,intersection:gp,tuple:yp,record:bp,nullable:wp,nonoptional:_p,default:Sp,prefault:xp,catch:kp,pipe:$p,readonly:Ep,promise:qv,optional:qa,lazy:Tp};function Fv(e,t){if("_idmap"in e){let n=e,o=Ss({...t,processors:Sv}),s={};for(let c of n._idmap.entries()){let[u,l]=c;we(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;xs(o,l),gt(i,u,ks(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=Ss({...t,processors:Sv});return we(e,r),xs(r,e),ks(r,e)}var Uv=new WeakSet([Object.prototype,Error.prototype]);function Fa(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 Hz=(e,t)=>{lb.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);if(Uv.has(r))return;Uv.add(r),Fa(r,"format",(n)=>(o)=>wd(n,o)),Fa(r,"flatten",(n)=>(o)=>bd(n,o)),Fa(r,"addIssue",(n)=>(o)=>{n.issues.push(o),n.message=JSON.stringify(n.issues,ls,2)}),Fa(r,"addIssues",(n)=>(o)=>{n.issues.push(...o),n.message=JSON.stringify(n.issues,ls,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var bt=O("ZodError",Hz,void 0,{Parent:Error});var Wv=ha(bt),Vv=ga(bt),Zv=ms(bt),Bv=ya(bt),Hv=fb(bt),Kv=mb(bt),Gv=hb(bt),Jv=gb(bt),Yv=yb(bt),Xv=bb(bt),Qv=wb(bt),eS=_b(bt);function Gz(){if(!et.localeError)it(Dd())}function Es(){if(!et.memoizer)it({memoizer:jd()})}var he=O("ZodType",(e,t)=>(Gz(),pe.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(yt(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 Mt(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(FN(e,t))},superRefine(e,t){return this.check(UN(e,t))},overwrite(e){return this.check(zr(e))},optional(){return Se(this)},exactOptional(){return EN(this)},nullable(){return rS(this)},nullish(){return Se(rS(this))},nonoptional(e){return RN(this,e)},array(){return k(this)},or(e){return re([this,e])},and(e){return Za(this,e)},transform(e){return nS(this,lS(e))},default(e){return PN(this,e)},prefault(e){return IN(this,e)},catch(e){return zN(this,e)},pipe(e){return nS(this,e)},readonly(){return jN(this)},describe(e){let t=this.clone();return Cr.add(t,{description:e}),t},meta(...e){if(e.length===0)return Cr.get(this);let t=this.clone();return Cr.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 fa(this,"~standard",{...Pd(this),jsonSchema:{input:vs(this,"input"),output:vs(this,"output")}})},set "~standard"(e){hr(this,"~standard",e)},parse:function e(t,r){return Wv(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await Vv(this,t,r,{callee:e})},safeParse(e,t){return Zv(this,e,t)},async safeParseAsync(e,t){return Bv(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){hr(this,"spa",e)},validate(e,t){return ba(this,e,t)},validateAsync(e,t){return wa(this,e,t)},encode:function e(t,r){return Hv(this,t,r,{callee:e})},decode:function e(t,r){return Kv(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await Gv(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await Jv(this,t,r,{callee:e})},safeEncode(e,t){return Yv(this,e,t)},safeDecode(e,t){return Xv(this,e,t)},async safeEncodeAsync(e,t){return Qv(this,e,t)},async safeDecodeAsync(e,t){return eS(this,e,t)},toJSONSchema(e){return yv(this,{})(e)},get description(){return Cr.get(this)?.description},get _def(){return this._zod.def}}),oS=O("_ZodString",(e,t)=>{$a.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>tp(e,r,n,o)},ob({format:(e)=>at(e).format??null,minLength:(e)=>at(e).minimum??null,maxLength:(e)=>at(e).maximum??null},{regex(...e){return this.check(Fd(...e))},includes(...e){return this.check(Vd(...e))},startsWith(...e){return this.check(Zd(...e))},endsWith(...e){return this.check(Bd(...e))},min(...e){return this.check(Yn(...e))},max(...e){return this.check(Da(...e))},length(...e){return this.check(Ma(...e))},nonempty(...e){return this.check(Yn(1,...e))},lowercase(e){return this.check(Ud(e))},uppercase(e){return this.check(Wd(e))},trim(){return this.check(Kd())},normalize(...e){return this.check(Hd(...e))},toLowerCase(){return this.check(Gd())},toUpperCase(){return this.check(Jd())},slugify(){return this.check(Yd())}})),sS=O("ZodString",(e,t)=>{$a.init(e,t),oS.init(e,t)},{email(e){return this.check(C_(Jz,e))},url(e){return this.check(qd(iS,e))},jwt(e){return this.check(Q_(pN,e))},emoji(e){return this.check(M_(Xz,e))},guid(e){return this.check(z_(Yz,e))},uuid(e){return this.check(N_(Ua,e))},uuidv4(e){return this.check(L_(Ua,e))},uuidv6(e){return this.check(j_(Ua,e))},uuidv7(e){return this.check(D_(Ua,e))},nanoid(e){return this.check(q_(Qz,e))},cuid(e){return this.check(F_(eN,e))},cuid2(e){return this.check(U_(tN,e))},ulid(e){return this.check(W_(rN,e))},base64(e){return this.check(J_(uN,e))},base64url(e){return this.check(Y_(lN,e))},xid(e){return this.check(V_(nN,e))},ksuid(e){return this.check(Z_(oN,e))},ipv4(e){return this.check(B_(sN,e))},ipv6(e){return this.check(H_(iN,e))},cidrv4(e){return this.check(K_(aN,e))},cidrv6(e){return this.check(G_(cN,e))},e164(e){return this.check(X_(dN,e))},datetime(e){return this.check(Ia(Ts,e))},date(e){return this.check(Ra(Os,e))},time(e){return this.check(Ca(Ps,e))},duration(e){return this.check(za(As,e))}});function p(e){return R_(sS,e)}var $e=O("ZodStringFormat",(e,t)=>{_e.init(e,t),oS.init(e,t)}),Ts=O("ZodISODateTime",(e,t)=>{jw.init(e,t),$e.init(e,t)}),Os=O("ZodISODate",(e,t)=>{Dw.init(e,t),$e.init(e,t)}),Ps=O("ZodISOTime",(e,t)=>{Mw.init(e,t),$e.init(e,t)}),As=O("ZodISODuration",(e,t)=>{qw.init(e,t),$e.init(e,t)}),Jz=O("ZodEmail",(e,t)=>{Ew.init(e,t),$e.init(e,t)});var Yz=O("ZodGUID",(e,t)=>{kw.init(e,t),$e.init(e,t)});var Ua=O("ZodUUID",(e,t)=>{$w.init(e,t),$e.init(e,t)});var iS=O("ZodURL",(e,t)=>{Pw.init(e,t),$e.init(e,t)});function Is(e){return qd(iS,e)}var Xz=O("ZodEmoji",(e,t)=>{Aw.init(e,t),$e.init(e,t)});var Qz=O("ZodNanoID",(e,t)=>{Iw.init(e,t),$e.init(e,t)});var eN=O("ZodCUID",(e,t)=>{Rw.init(e,t),$e.init(e,t)});var tN=O("ZodCUID2",(e,t)=>{Cw.init(e,t),$e.init(e,t)});var rN=O("ZodULID",(e,t)=>{zw.init(e,t),$e.init(e,t)});var nN=O("ZodXID",(e,t)=>{Nw.init(e,t),$e.init(e,t)});var oN=O("ZodKSUID",(e,t)=>{Lw.init(e,t),$e.init(e,t)});var sN=O("ZodIPv4",(e,t)=>{Fw.init(e,t),$e.init(e,t)});var iN=O("ZodIPv6",(e,t)=>{Ww.init(e,t),$e.init(e,t)});var aN=O("ZodCIDRv4",(e,t)=>{Vw.init(e,t),$e.init(e,t)});var cN=O("ZodCIDRv6",(e,t)=>{Zw.init(e,t),$e.init(e,t)});var uN=O("ZodBase64",(e,t)=>{Hw.init(e,t),$e.init(e,t)});var lN=O("ZodBase64URL",(e,t)=>{Kw.init(e,t),$e.init(e,t)});var dN=O("ZodE164",(e,t)=>{Gw.init(e,t),$e.init(e,t)});var pN=O("ZodJWT",(e,t)=>{Jw.init(e,t),$e.init(e,t)});var Wa=O("ZodNumber",(e,t)=>{Id.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>rp(e,r,n,o),e.isFinite=!0},ob({minValue:(e)=>{let{minimum:t,exclusiveMinimum:r}=at(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:r}=at(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:r}=at(e);return!!t||!!r?.some(Number.isSafeInteger)},format:(e)=>at(e).format??null},{gt(e,t){return this.check(La(e,t))},gte(e,t){return this.check(ws(e,t))},min(e,t){return this.check(ws(e,t))},lt(e,t){return this.check(Na(e,t))},lte(e,t){return this.check(bs(e,t))},max(e,t){return this.check(bs(e,t))},int(e){return this.check(tS(e))},safe(e){return this.check(tS(e))},positive(e){return this.check(La(0,e))},nonnegative(e){return this.check(ws(0,e))},negative(e){return this.check(Na(0,e))},nonpositive(e){return this.check(bs(0,e))},multipleOf(e,t){return this.check(ja(e,t))},step(e,t){return this.check(ja(e,t))},finite(){return this}}));function P(e){return ev(Wa,e)}var fN=O("ZodNumberFormat",(e,t)=>{Yw.init(e,t),Wa.init(e,t)});function tS(e){return rv(fN,e)}var aS=O("ZodBoolean",(e,t)=>{Xw.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>np(e,r,n,o)});function D(e){return nv(aS,e)}var mN=O("ZodNull",(e,t)=>{Qw.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>op(e,r,n,o)});function Va(e){return ov(mN,e)}var hN=O("ZodAny",(e,t)=>{e_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ip(e,r,n,o)});function cS(){return sv(hN)}var gN=O("ZodUnknown",(e,t)=>{t_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ap(e,r,n,o)});function de(){return iv(gN)}var yN=O("ZodNever",(e,t)=>{r_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>sp(e,r,n,o)});function bN(e){return av(yN,e)}var wN=O("ZodArray",(e,t)=>{Es(),n_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>fp(e,r,n,o),e.element=t.element},{min(e,t){return this.check(Yn(e,t))},nonempty(e){return this.check(Yn(1,e))},max(e,t){return this.check(Da(e,t))},length(e,t){return this.check(Ma(e,t))},unwrap(){return this.element}});function k(e,t){return cv(wN,e,t)}var Ap=O("ZodObject",(e,t)=>{Es(),i_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>mp(e,r,n,o),Q1(e,"shape",(r)=>r._zod.def.shape,!1)},{keyof(){return z(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(yt(this._zod.def,{catchall:e}))},passthrough(){return this.clone(yt(this._zod.def,{catchall:de()}))},loose(){return this.clone(yt(this._zod.def,{catchall:de()}))},strict(){return this.clone(yt(this._zod.def,{catchall:bN()}))},strip(){return this.clone(yt(this._zod.def,{catchall:void 0}))},extend(e){return Z1(this,e)},safeExtend(e){return B1(this,e)},merge(e){return H1(this,e)},pick(e){return W1(this,e)},omit(e){return V1(this,e)},partial(...e){return eb(Rp,this,e[0])},exactPartial(...e){return eb(dS,this,e[0],"exactPartial")},required(...e){return K1(pS,this,e[0])}});function b(e,t){let r={type:"object",shape:e??{},...F(t)};return new Ap(r)}function Ee(e,t){return new Ap({type:"object",shape:e,catchall:de(),...F(t)})}var uS=O("ZodUnion",(e,t)=>{Rd.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>hp(e,r,n,o),e.options=t.options});function re(e,t){return new uS({type:"union",options:e,...F(t)})}var _N=O("ZodDiscriminatedUnion",(e,t)=>{uS.init(e,t),a_.init(e,t)});function yr(e,t,r){return new _N({type:"union",options:t,discriminator:e,...F(r)})}var vN=O("ZodIntersection",(e,t)=>{c_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>gp(e,r,n,o)});function Za(e,t){return new vN({type:"intersection",left:e,right:t})}var SN=O("ZodTuple",(e,t)=>{Es(),u_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>yp(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 Rp({type:"optional",innerType:t}))})}});function xN(e,t,r){let n=t instanceof pe,o=n?r:t;return new SN({type:"tuple",items:e,rest:n?t:null,...F(o)})}var Op=O("ZodRecord",(e,t)=>{Es(),l_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>bp(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function J(e,t,r){if(!t||!t._zod)return new Op({type:"record",keyType:p(),valueType:e,...F(t)});return new Op({type:"record",keyType:e,valueType:t,...F(r)})}function Ip(e,t,r){return new Op({type:"record",keyType:e,valueType:t,...F(r),partial:!0})}var Pp=O("ZodEnum",(e,t)=>{d_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(n,o,s)=>cp(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 Pp({...t,checks:[],...F(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 Pp({...t,checks:[],...F(o),entries:s})}});function z(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map((n)=>[n,n])):e;return new Pp({type:"enum",entries:r,...F(t)})}var kN=O("ZodLiteral",(e,t)=>{p_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>up(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 kN({type:"literal",values:Array.isArray(e)?e:[e],...F(t)})}var $N=O("ZodTransform",(e,t)=>{Es(),f_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>pp(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new fs(e.constructor.name);r.addIssue=(s)=>{if(typeof s==="string")r.issues.push(kn(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(kn(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 lS(e){return new $N({type:"transform",transform:e})}var Rp=O("ZodOptional",(e,t)=>{Cd.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>qa(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Se(e){return new Rp({type:"optional",innerType:e})}var dS=O("ZodExactOptional",(e,t)=>{m_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>qa(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function EN(e){return new dS({type:"optional",innerType:e})}var TN=O("ZodNullable",(e,t)=>{h_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>wp(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function rS(e){return new TN({type:"nullable",innerType:e})}var ON=O("ZodDefault",(e,t)=>{g_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Sp(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function PN(e,t){return new ON({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():ld(t)}})}var AN=O("ZodPrefault",(e,t)=>{y_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>xp(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function IN(e,t){return new AN({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():ld(t)}})}var pS=O("ZodNonOptional",(e,t)=>{b_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>_p(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function RN(e,t){return new pS({type:"nonoptional",innerType:e,...F(t)})}var CN=O("ZodCatch",(e,t)=>{w_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>kp(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function zN(e,t){return new CN({type:"catch",innerType:e,catchValue:typeof t==="function"?t:sb(t)})}var fS=O("ZodPipe",(e,t)=>{zd.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>$p(e,r,n,o),e.in=t.in,e.out=t.out});function nS(e,t){return new fS({type:"pipe",in:e,out:t})}var NN=O("ZodPreprocess",(e,t)=>{fS.init(e,t),__.init(e,t)}),LN=O("ZodReadonly",(e,t)=>{v_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ep(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function jN(e){return new LN({type:"readonly",innerType:e})}var DN=O("ZodTemplateLiteral",(e,t)=>{S_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>lp(e,r,n,o)});function MN(e,t){return new DN({type:"template_literal",parts:e,...F(t)})}var qN=O("ZodLazy",(e,t)=>{x_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Tp(e,r,n,o),e.unwrap=()=>e._zod.def.getter()});function Cp(e){return new qN({type:"lazy",getter:e})}var mS=O("ZodCustom",(e,t)=>{k_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>dp(e,r,n,o)});function Ba(e,t){return uv(mS,e??(()=>!0),t)}function FN(e,t={}){return lv(mS,e,t)}function UN(e,t){return dv(e,t)}function br(e){let t=Cp(()=>re([p(e),P(),D(),Va(),k(t),J(p(),t)]));return t}function Ha(e,t){return new NN({type:"pipe",in:lS(e),out:t})}var gS={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 hS;(function(e){})(hS||(hS={}));function yS(e){return Ia(Ts,e)}function VN(e){return Ra(Os,e)}function ZN(e){return Ca(Ps,e)}function BN(e){return za(As,e)}function HN(e){return tv(Wa,e)}var wS={name:"@tripwire-sh/cli",version:"0.1.2",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 Ka=wS.version,U="tripwire",Rs="tripwire-get-started",_S="tripwire-workflows",Cs="tripwire-cli",GN="https://mcp.tripwire.sh/mcp",JN="https://app.tripwire.sh/api/auth",vS="offline_access tripwire:read tripwire:configure tripwire:moderate tripwire:admin";function to(e){return e.TRIPWIRE_MCP_URL||GN}function SS(e){return(e.TRIPWIRE_AUTH_URL||JN).replace(/\/+$/,"")}var YN="urn:ietf:params:oauth:grant-type:device_code",XN=b({device_code:p(),user_code:p(),verification_uri:p(),verification_uri_complete:p().optional(),expires_in:P(),interval:P().optional()}),kS=b({access_token:p().min(1),refresh_token:p().min(1).optional(),expires_in:P().optional(),token_type:p().optional()}),Np=b({error:p(),error_description:p().optional()});class zp extends Error{constructor(){super("Session expired. Run tripwire login.");this.name="SessionExpiredError"}}class zs extends Error{constructor(){super("Tripwire is not reachable right now. Try again in a minute.");this.name="AuthUnreachableError"}}var $S={fetch:(e,t)=>fetch(e,t),sleep:(e)=>new Promise((t)=>setTimeout(t,e)),now:()=>Date.now()};async function Ga(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=br().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 ES(e,t){let r=Np.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 TS(e,t,r){let{status:n,body:o}=await Ga(e,`${t}/device/code`,{client_id:Cs,scope:vS,resource:r}),s=XN.safeParse(o);if(n>=400||!s.success)throw ES(o,`Device authorization failed (HTTP ${n})`);return s.data}function OS(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 xS=5000;function QN(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 PS(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 Ga(e,`${t}/oauth2/token`,{grant_type:YN,device_code:n.device_code,client_id:Cs,resource:r}),l=kS.safeParse(c);if(a<400&&l.success)return OS(e,l.data,t,r);if(a===429){if(s=QN(u,e.now()),s===null)o+=xS;continue}let d=Np.safeParse(c),f=d.success?d.data.error:"";if(f==="authorization_pending")continue;if(f==="slow_down"){o+=xS;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 ES(c,`Token request failed (HTTP ${a})`)}throw Error("The code expired. Run tripwire login again.")}async function AS(e,t){if(!t.refreshToken)throw new zp;let{status:r,body:n}=await Ga(e,`${t.authUrl}/oauth2/token`,{grant_type:"refresh_token",refresh_token:t.refreshToken,client_id:Cs,resource:t.mcpUrl}).catch(()=>{throw new zs}),o=kS.safeParse(n);if(r>=400||!o.success){let s=Np.safeParse(n);throw(r===400||r===401)&&s.success&&s.data.error!=="invalid_response"?new zp:new zs}return OS(e,o.data,t.authUrl,t.mcpUrl,t.refreshToken)}async function IS(e,t){let r=t.refreshToken??t.accessToken;await Ga(e,`${t.authUrl}/oauth2/revoke`,{token:r,client_id:Cs}).catch(()=>{return})}import{stripVTControlCharacters as eq}from"node:util";var eL=z(["pending","approved","rejected"]),bne=eL.options;var Ns=[{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 RS(e){return e.status==="live"}var Ls=z(Ns.filter(RS).map((e)=>e.id)),vne=Ns.filter((e)=>RS(e)&&!("paused"in e)).map((e)=>e.label),Sne=Ns.filter((e)=>e.status==="planned").map((e)=>e.label),xne=Ns.filter((e)=>("signIn"in e)).map((e)=>e.id);var tL=Object.fromEntries(Ns.map((e)=>[e.id,e]));var Ja=b({owner:p(),name:p(),fullName:p()}),rL=b({id:p(),login:p(),name:p(),type:z(["Organization","User"]),avatarUrl:p(),repoAccess:z(["all","selected"]),repoCount:P(),installedAt:ve.datetime()}),nL=b({id:p(),owner:p(),name:p(),fullName:p(),private:D(),pushedAt:ve.datetime(),openFlags:P(),stars:P()}),Ene=b({accounts:k(rL),repos:k(nL)});var js=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"]),CS=b({login:p(),externalId:p(),avatarUrl:p().optional()}),Lp=b({number:P().int(),title:p(),headSha:p(),baseRef:p().optional(),headRef:p().optional(),draft:D().optional(),url:p()}),oL=b({externalId:p(),body:p(),url:p(),subjectNumber:P().int(),byTripwire:D().optional()}),sL=b({ref:p(),headSha:p(),commitCount:P().int(),url:p().optional()}),Xa=z(["issue","change-request"]),iL=b({kind:Xa,number:P().int(),title:p(),url:p(),state:z(["open","closed"]),author:p(),labels:k(p()),locked:D(),updatedAt:ve.datetime()}),aL=b({workflowId:p(),nodeId:p(),tickId:p()}),ro={id:p(),forge:Ls,deliveryId:p(),repo:Ja,repoExternalId:p().optional(),installationExternalId:p().optional(),actor:CS,occurredAt:ve.datetime(),receivedAt:ve.datetime()},Ya={id:p(),forge:Ls,deliveryId:p(),actor:CS,occurredAt:ve.datetime(),receivedAt:ve.datetime(),installation:b({externalId:p(),account:p(),accountType:z(["User","Organization"]).optional()}),repositories:k(b({externalId:p(),owner:p(),name:p(),fullName:p(),private:D()}))},zS=yr("kind",[b({...ro,kind:C("change-request.opened"),changeRequest:Lp}),b({...ro,kind:C("change-request.updated"),changeRequest:Lp}),b({...ro,kind:C("change-request.closed"),changeRequest:Lp}),b({...ro,kind:C("comment.created"),comment:oL}),b({...ro,kind:C("push"),push:sL}),b({...ro,kind:C("schedule.matched"),schedule:aL,thread:iL}),b({...Ya,kind:C("installation.created")}),b({...Ya,kind:C("installation.deleted")}),b({...Ya,kind:C("installation-repositories.added")}),b({...Ya,kind:C("installation-repositories.removed")})]),cL=js.extract(["change-request.opened","change-request.updated","change-request.closed"]),Ine=cL.options;var uL=["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"],lL=["sun","mon","tue","wed","thu","fri","sat"],dL=[{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:uL,nameBase:1},{name:"day of week",range:"0 to 7 or sun to sat",min:0,max:7,names:lL,nameBase:0}];function jp(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 pL(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=jp(l,t),u=jp(d,t)}else c=jp(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 Qa(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 dL.entries()){let d=pL(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 jS(e){try{return new Intl.DateTimeFormat("en-US",{timeZone:e}),!0}catch{return!1}}var NS=new Map;function fL(e){let t=NS.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 NS.set(e,r),r}function Mp(e,t){let r=fL(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 Dp(e,t){let r=Mp(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 LS(e,t){let r=Date.UTC(e.year,e.month-1,e.day,e.hour,e.minute),n=[r-Dp(r-129600000,t),r-Dp(r+129600000,t),r-Dp(r,t)].sort((o,s)=>o-s);for(let o of n){let s=Mp(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 mL(e,t){let r=t.getUTCDate(),n=t.getUTCDay(),o=e.days.includes(r),s=e.weekdays.includes(n);if(e.daysRestricted&&e.weekdaysRestricted)return o||s;return o&&s}var hL=1830,gL=180;function yL(e,t){let r=LS(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<=gL;o++){let s=new Date(n+o*60000),i=LS({year:s.getUTCFullYear(),month:s.getUTCMonth()+1,day:s.getUTCDate(),hour:s.getUTCHours(),minute:s.getUTCMinutes()},t);if(i)return i}return null}function DS(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 qp(e,t,r){let n=Mp(r,t),o=new Date(Date.UTC(n.year,n.month-1,n.day));for(let s=0;s<=hL;s++){if(e.months.includes(o.getUTCMonth()+1)&&mL(e,o))for(let i of e.hours)for(let a of e.minutes){let c=yL({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 tc=5,je=Cp(()=>re([p(),P(),D(),Va(),k(je),J(p(),je)])),nc=b({x:P(),y:P()}),bL=z(["all-of","any-of","not"]),wL=z(["block","comment","label","request-review","send-to-moderation","webhook","discord","lock","close","remove-label","post-comment"]),_L=["comment"];function qS(e){return _L.includes(e)}var jne=b({url:Is().meta({secret:!0}).describe("webhook url"),signingSecret:p().min(1).optional().meta({secret:!0}).describe("signing secret")}),Dne=b({url:Is().meta({secret:!0}).describe("discord webhook url")}),no=15,oc=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`}),Fp=p().regex(/^[A-Za-z0-9][A-Za-z0-9_-]{0,99}$/,{error:(e)=>`${String(e.input)} is not a team slug`}),Up=b({id:P().int().positive().optional(),login:oc}),Mne=b({id:P().int().positive(),login:oc,avatarUrl:p(),permission:p().min(1)}),qne=b({name:p().min(1),color:p().regex(/^[0-9a-fA-F]{6}$/),description:p().nullable()}),vL=Ha((e)=>p().safeParse(e).success?{login:e}:e,Up);function FS(e,t){return e.id!==void 0&&t.id!==void 0?e.id===t.id:e.login.toLowerCase()===t.login.toLowerCase()}var Ds=b({reviewers:k(vL).max(no,`ask at most ${no} people`).default([]),teamReviewers:k(Fp).max(no,`ask at most ${no} teams`).default([])}),US=Ds.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>no)t.addIssue({code:"custom",message:`ask at most ${no} people and teams`})}),Nr=b({labels:k(p().trim().min(1)).min(1,"choose at least one label")}),MS=5000,sc=b({message:p().trim().min(1,"write a message").max(MS,`keep it under ${MS} characters`)}),SL=z(["resolved","off-topic","too heated","spam"]),WS=b({reason:SL.optional()}),Wp={hours:3600000,days:86400000,weeks:604800000,months:2592000000};function Vp(e){return e.n*Wp[e.unit]}var xL=52*Wp.weeks,kL=3650*Wp.days,$L=z(["hours","days","weeks"]),EL=z(["hours","days","weeks","months"]),TL=b({n:P().int().min(1),unit:$L}).refine((e)=>Vp(e)<=xL,{message:"runs at least once a year"}),VS="UTC",ZS=p().min(1).refine(jS,{error:(e)=>`${String(e.input)} is not an IANA timezone, like Europe/Berlin`}),ec=p().regex(/^([01]\d|2[0-3]):[0-5]\d$/,"use 24-hour HH:MM, like 07:30"),Zp=z(["sunday","monday","tuesday","wednesday","thursday","friday","saturday"]),OL=yr("preset",[b({preset:C("hourly"),minute:P().int().min(0).max(59)}),b({preset:C("daily"),at:ec}),b({preset:C("weekdays"),at:ec}),b({preset:C("weekly"),on:Zp,at:ec}),b({preset:C("monthly"),day:P().int().min(1).max(28),at:ec})]),PL=b({cron:p().trim().superRefine((e,t)=>{let r=Qa(e);if(!r.ok){t.addIssue({code:"custom",message:r.error});return}if(qp(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(DS(r.spec)<tc)t.addIssue({code:"custom",message:`runs must be at least ${tc} minutes apart`})})}),BS=re([TL,OL,PL]),HS=b({n:P().int().min(1),unit:EL}).refine((e)=>Vp(e)<=kL,{message:"10 years at most"}),KS=z(["open","closed","any"]),rc=k(p().min(1)),AL=b({subjects:k(Xa).min(1),state:KS,inactiveFor:HS,labels:rc.optional(),excludeLabels:rc.optional(),skipLocked:D().default(!0)}),oo=b({every:BS,timezone:ZS.optional(),match:AL}),IL=b({every:BS.optional(),timezone:ZS.optional(),match:b({subjects:k(Xa).optional(),state:KS.optional(),inactiveFor:HS.optional(),labels:rc.optional(),excludeLabels:rc.optional(),skipLocked:D().optional()}).default({})});var RL=["every","subjects","state","inactiveFor"];function GS(e){return RL.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 CL=b({id:p(),type:C("trigger"),kinds:k(js).min(1),schedule:IL.optional(),position:nc.optional()});function ic(e){return e.type==="trigger"&&(e.kinds??[]).includes("schedule.matched")}var zL=b({id:p(),type:C("rule"),ref:p().regex(/^[a-z][a-z0-9-]*@\d+$/),config:je,position:nc.optional()}),NL=b({id:p(),type:C("gate"),mode:bL,position:nc.optional()}),LL=b({id:p(),type:C("action"),action:wL,params:J(p(),je).optional(),position:nc.optional()}),Bp=yr("type",[CL,zL,NL,LL]),JS=z(["pass","fail","approve","deny"]),jL=b({id:p(),from:p(),to:p(),when:JS.optional()}),wr=b({id:p(),name:p(),version:P().int().min(1),nodes:k(Bp).min(1),edges:k(jL)}),YS={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 XS=[{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}],QS=[{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 Vne=J(p(),je).catch({});function ac(e){if(e.length<=1)return e[0]??"";return`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`}function tx(e){let t=Nr.safeParse(e);return t.success?t.data.labels:[]}function rx(e){return`${e.length===1?"the label":"the labels"} ${ac(e)}`}function DL(e){let t=Ds.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=DL(t);return r.length>0?`requests GitHub review from ${ac(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 ML=b({runId:p(),verdict:p().nullable(),status:p(),reason:p().nullable()}),ox=b({event:zS,run:ML.nullable(),pending:D().optional()}),qL=b({repoFullName:p(),subjectNumber:P().int(),title:p(),url:p().nullable(),actor:b({login:p(),avatarUrl:p().nullable()}),currentVerdict:p().nullable(),currentRunId:p().nullable(),latestActivityAt:ve.datetime(),eventCount:P().int(),timeline:k(ox)}),FL=yr("type",[b({type:C("group"),group:qL}),b({type:C("event"),entry:ox})]),Kne=b({items:k(FL)});var UL=["tripwire:read","tripwire:configure","tripwire:moderate","tripwire:admin"],Yne=z(UL);var WL="https://tripwire.sh/orgs";var Xne=b({sub:p().min(1),azp:p().min(1).optional(),client_id:p().min(1).optional(),scope:p().optional(),[WL]:k(p()).optional()});var VL=z(["success","failure","neutral","pending"]),toe=b({sha:p(),conclusion:VL,summary:p(),detailsUrl:p()});var ZL=["matched-values","file-paths","ai-trace","ai-summary","reasons","rule-names","passed-count","failed-count"],BL=ZL.length;var HL=P().int().min(0).max(BL),sx=z(["run-page","check","comment","review","webhook"]),ooe=sx.options,KL=["run-page","check","comment","review"],cc=b({level:HL.default(0),surfaces:k(sx).default(()=>[...KL]),showHelp:D().default(!0)}),ix=cc.extend({inherit:D().default(!0)}),GL=cc.parse({});var JL=z(["green","blue","purple","pink","orange","red","grey"]),_r=z(["issue","pull"]),Ms=z(["open","closed","merged"]),ax=b({key:p(),label:p(),value:P(),delta:P().optional(),invertDelta:D().optional(),sub:p().optional(),series:k(P()),color:JL,suffix:p().optional()}),YL=b({rule:p(),count:P()}),XL=b({kind:_r,number:P(),title:p(),comments:P(),blocked:P(),status:Ms}),QL=b({login:p(),count:P(),flagged:D().optional()}),ej=b({login:p(),reason:p(),caughtBy:p(),status:z(["Hidden","Removed"]),commentId:p().optional()}),tj=b({kind:z(["review","check"]),title:p(),detail:p(),status:z(["Approved","Changes","Passed","Failed"]),actor:p().optional()}),rj=b({kind:_r,number:P(),title:p(),status:Ms,meta:p(),metrics:k(ax),series:k(P()),byParticipant:k(QL),flagged:k(ej).optional(),checks:k(tj).optional()}),aoe=b({metrics:k(ax),blockedByRule:k(YL),activeThreads:k(XL),threads:J(p(),rj)});var io=z(["issue","pull","comment"]),Hp=z(["spam","harassment","off-topic","automod","nsfw"]),Kp=z(["low","medium","high","critical"]),nj=z(["pending","resolved"]),so=b({login:p(),avatarUrl:p()}),doe=b({id:p(),type:io,repository:Ja,number:P(),title:p(),bodyPreview:p(),author:so,reason:Hp,severity:Kp,reporter:so.nullable(),automodRule:p().optional(),reportedAt:ve.datetime(),status:nj,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"})}),Lr=b({value:P(),delta:P(),series:k(P())}),poe=b({sentToReview:Lr,blocked:Lr,passed:Lr}),foe=z(["approve","remove","ban"]);var oj=z(["info","warn","critical"]),sj=b({severity:oj,file:p(),line:P().int().min(1).optional(),note:p().max(240)}),goe=b({verdict:z(["pass","block","needs_review"]),confidence:P().min(0).max(1),summary:p().max(200),findings:k(sj).max(5)}),cx=b({model:p().optional(),maxSteps:P().int().min(1).max(15).default(12)});var ij=b({type:z(["reasoning","tool_call"]),toolName:p().optional(),excerpt:p(),truncated:D()}),yoe=b({model:p(),stepsUsed:P().int().min(0),maxSteps:P().int().min(0),trimmed:D(),costUsd:P().nullable().optional(),usage:b({input:P().int().min(0),output:P().int().min(0),cached:P().int().min(0).nullable()}),steps:k(ij)});var aj=z(["blocklist","heuristic","classifier","regex"]),cj=z(["flag","hide","close","require-review"]),uj=z(["pending","confirmed","false-positive"]),lj=b({id:p(),type:io,repoFullName:p(),number:P(),author:b({login:p(),avatarUrl:p()}),snippet:p(),matchedAt:ve.datetime(),verdict:uj,threadKind:_r,commentId:p()}),koe=b({id:p(),name:p(),description:p(),category:aj,pattern:p(),scope:k(io),action:cj,enabled:D(),matches24h:P(),matches30d:P(),falsePositiveRate:P().min(0).max(100),lastFiredAt:ve.datetime(),trend:k(P()),recentMatches:k(lj)}),$oe=b({activeRules:Lr,matches24h:Lr,falsePositiveRate:Lr,autoActioned24h:Lr}),Eoe=b({ruleId:p(),version:P().int().min(1),status:z(["evaluated","skipped"]),passed:D(),evidence:de(),reason:p().optional(),evaluatedAt:ve.datetime()}),dj=b({minDays:P().int().min(0)}),Toe=b({min:P().int().min(0)}),pj=b({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")}),fj=b({maxPerWindow:P().int().min(1),windowHours:P().min(0.1).default(24)}),mj=b({max:P().int().min(1)}),hj=b({maxNonLatinRatio:P().min(0).max(1).default(0.5)}),gj=b({}),yj=b({paths:k(p()).min(1)}),bj=b({minLength:P().int().min(1).default(32)}),He=[{ruleId:"account-age",forges:["github"],version:1,name:"Account age",blurb:"the contributor's forge account must be at least N days old.",configSchema:dj,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:pj,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:fj,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:mj,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:hj,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:gj,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:yj,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:bj,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:"off until you turn it on, because ai review costs tokens.",configSchema:cx,defaultConfig:{maxSteps:12},optIn:!0,changeNote:"findings must quote code",description:"Reads the change like a reviewer and flags slop. Off until you turn it on, because it costs tokens.",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 Noe=J(p(),je);var vj=z(["silent","ci-check","comment"]),ux=z(["comment","silent"]),Sj=z(["full","one-liner-link","custom"]),Gp=b({customText:p().max(4000).default(""),showDetailsButton:D().default(!0)}),xj=Gp.extend({mode:Sj.default("full"),template:p().max(4000).default("")}),kj=b({onSuccess:vj.default("ci-check"),passComment:Gp.prefault({}),onBlock:ux.default("comment"),blockComment:xj.prefault({}),moderationQueued:ux.default("comment"),reviewComment:Gp.prefault({}),failClosedFallback:D().default(!0),redaction:ix.prefault({})}),$j=b({redaction:cc.prefault({})}),Moe=$j.parse({});var Ej=kj.parse({});var lx="If you think this is wrong, say so in a comment. A maintainer will decide.",dx="If you think it should merge anyway, say so in a comment. A maintainer will decide.",Joe=`Push a commit that fixes the problems. Tripwire checks every push.
|
|
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 hv(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;hv(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 gv=new Set(["type","properties","required","additionalProperties"]),fv=["oneOf","anyOf"];function mv(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 Xd(e){let t=[];for(let s of e){if(typeof s!=="object"||s.type!=="object")return null;for(let i in s)if(!gv.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]??mv(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]:Xd(a)??{allOf:a};gt(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=mv(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 zz(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of gv)if(o in e)return;let r=t.filter((o)=>fv.some((s)=>Array.isArray(o[s]))),n=null;if(!r.length)n=Xd(t);else{let o=r[0],s=fv.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)=>Xd([...i,c]));if(a.some((c)=>!c))return;n={[s]:a}}if(!n)return;delete e.allOf,_s(e,n)}function ks(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 _s(u,h);if(_s(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())hv(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)??[])zz(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)}_s(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;gt(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:vs(t,"input",e.processors),output:vs(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function tt(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 tt(n.element,r);if(n.type==="set")return tt(n.valueType,r);if(n.type==="lazy")return tt(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 tt(n.innerType,r);if(n.type==="intersection")return tt(n.left,r)||tt(n.right,r);if(n.type==="record"||n.type==="map")return tt(n.keyType,r)||tt(n.valueType,r);if(n.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return tt(n.in,r)||tt(n.out,r)}if(n.type==="object"){for(let o in n.shape)if(tt(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(tt(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(tt(o,r))return!0;if(n.rest&&tt(n.rest,r))return!0;return!1}return!1}var yv=(e,t={})=>(r)=>{let n=Ss({...r,processors:t});return we(e,n),xs(n,e),ks(n,e)},vs=(e,t,r={})=>(n)=>{let{libraryOptions:o,target:s}=n??{},i=Ss({...o??{},target:s,io:t,processors:r});return we(e,i),xs(i,e),ks(i,e)};var Xn=(e,t,r)=>{if(e[t]===void 0||r>e[t])e[t]=r},Qn=(e,t,r)=>{if(e[t]===void 0||r<e[t])e[t]=r},bv=(e,t)=>{Xn(e,"minimum",t),Qn(e,"maximum",t)},xv=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},kv=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},$v=(e,t)=>{e.mime=e.mime?e.mime.filter((r)=>t.includes(r)):[...t]},Ev=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},wv=(e,t)=>Xn(e,"minimum",t.minimum),_v=(e,t)=>Qn(e,"maximum",t.maximum),vv=(e)=>(t,r)=>{Ev(t,r.format);let[n,o]=e[r.format];Xn(t,"minimum",n),Qn(t,"maximum",o)},Nz={greater_than:(e,t)=>Xn(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Qn(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>xv(e,t.value),number_format:vv(ca),bigint_format:vv(pd),min_length:wv,max_length:_v,length_equals:(e,t)=>bv(e,t.length),min_size:wv,max_size:_v,size_equals:(e,t)=>bv(e,t.size),string_format:(e,t)=>{if(Ev(e,t.format),t.pattern)kv(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)=>$v(e,t.mime)};function at(e){let t={},r=e._zod.def,n=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let s of n)Nz[s._zod.def.check]?.(t,s._zod.def);let o=e._zod.bag;if(o.minimum!==void 0)Xn(t,"minimum",o.minimum);if(o.exclusiveMinimum!==void 0)Xn(t,"exclusiveMinimum",o.exclusiveMinimum);if(o.maximum!==void 0)Qn(t,"maximum",o.maximum);if(o.exclusiveMaximum!==void 0)Qn(t,"exclusiveMaximum",o.exclusiveMaximum);if(o.multipleOf!==void 0)xv(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)$v(t,o.mime);for(let s of o.patterns??[])kv(t,s);return t}var Lz={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},jz=new Map([[Ad,Lb],[Ea,jb]]),Tv=(e)=>jz.get(e)??e,tp=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u,laxFormat:l}=at(e);if(typeof s==="number")o.minLength=s;if(typeof i==="number")o.maxLength=i;if(a){if(o.format=Lz[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(Tv);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}))]}},rp=(e,t,r,n)=>{let o=r,{minimum:s,maximum:i,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:l}=at(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 _ of a)if(Number.isFinite(_)&&_!==0)h.add(Math.abs(_));else Fe(e,t,o,n,`A multipleOf divisor of ${_} 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((_)=>({multipleOf:_}))]}},np=(e,t,r,n)=>{r.type="boolean"},Ov=(e,t,r,n)=>{Fe(e,t,r,n,"BigInt cannot be represented in JSON Schema")},Pv=(e,t,r,n)=>{Fe(e,t,r,n,"Symbols cannot be represented in JSON Schema")},op=(e,t,r,n)=>{if(t.target==="openapi-3.0")r.type="string",r.nullable=!0,r.enum=[null];else r.type="null"},Av=(e,t,r,n)=>{Fe(e,t,r,n,"Undefined cannot be represented in JSON Schema")},Iv=(e,t,r,n)=>{Fe(e,t,r,n,"Void cannot be represented in JSON Schema")},sp=(e,t,r,n)=>{r.not={}},ip=(e,t,r,n)=>{},ap=(e,t,r,n)=>{},Rv=(e,t,r,n)=>{Fe(e,t,r,n,"Date cannot be represented in JSON Schema")},cp=(e,t,r,n)=>{let o=e._zod.def,s=us(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},up=(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(Fe(e,t,r,n,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i==="bigint"){if(Fe(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}},Cv=(e,t,r,n)=>{Fe(e,t,r,n,"NaN cannot be represented in JSON Schema")},lp=(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},zv=(e,t,r,n)=>{let o=r;o.type="string",o.format="binary",o.contentEncoding="binary";let{minimum:s,maximum:i,mime:a}=at(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}))},Nv=(e,t,r,n)=>{r.type="boolean"},dp=(e,t,r,n)=>{Fe(e,t,r,n,"Custom types cannot be represented in JSON Schema")},Lv=(e,t,r,n)=>{Fe(e,t,r,n,"Function types cannot be represented in JSON Schema")},pp=(e,t,r,n)=>{Fe(e,t,r,n,"Transforms cannot be represented in JSON Schema")},jv=(e,t,r,n)=>{Fe(e,t,r,n,"Map cannot be represented in JSON Schema")},Dv=(e,t,r,n)=>{Fe(e,t,r,n,"Set cannot be represented in JSON Schema")},fp=(e,t,r,n)=>{let o=r,s=e._zod.def,{minimum:i,maximum:a}=at(e);if(typeof i==="number")o.minItems=i;if(typeof a==="number")o.maxItems=a;o.type="array",o.items=we(s.element,t,{...n,path:[...n.path,"items"]})};function $s(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return $s(t.out);if(t.type==="catch")return $s(t.innerType);return e._zod.optin}var mp=(e,t,r,n)=>{let o=r,s=e._zod.def,i=s.shape;if(Object.getOwnPropertySymbols(i).length&&Fe(e,t,o,n,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let u in i)gt(o.properties,u,we(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"?$s(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=we(s.catchall,t,{...n,path:[...n.path,"additionalProperties"]})},hp=(e,t,r,n)=>{let o=e._zod.def,s=o.inclusive===!1,i=o.options.map((a,c)=>we(a,t,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));if(s)r.oneOf=i;else r.anyOf=i},gp=(e,t,r,n)=>{let o=e._zod.def,s=we(o.left,t,{...n,path:[...n.path,"allOf",0]}),i=we(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)},yp=(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)=>we(g,t,{...n,path:[...n.path,i,y]})),u=s.rest?we(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"?$s(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}=at(e);if(typeof m==="number")o.minItems=m;if(typeof h==="number")o.maxItems=h};function Qd(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=Qd(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((_)=>Qd(e,_,r));if(y.some((_,T)=>_!==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")?Gn:_a).source;return m}var ep=new WeakMap;function Dz(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 ep.get(e)??[]){let o=e.seen.get(n),s=(o?.def??o?.schema)?.propertyNames;if(!s||s===!0||r.has(s))continue;let i=Qd(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 bp=(e,t,r,n)=>{let o=r,s=e._zod.def;o.type="object";let i=s.keyType,a=at(i).patterns;if(s.mode==="loose"&&a&&a.size>0){let l=we(s.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let d of a)gt(o.patternProperties,Tv(d).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=we(s.keyType,t,{...n,path:[...n.path,"propertyNames"]});let l=ep.get(t);if(!l)l=[],ep.set(t,l),t.deferred.push(()=>Dz(t));l.push(e)}o.additionalProperties=we(s.valueType,t,{...n,path:[...n.path,"additionalProperties"]})}let c=i._zod.values,u=t.io==="input"&&$s(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)}},wp=(e,t,r,n)=>{let o=e._zod.def,s=we(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"}]},_p=(e,t,r,n)=>{let o=e._zod.def;we(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},vp=Symbol();function Mv(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 Fe(t,r,n,o,"BigInt defaults cannot be represented in JSON Schema"),vp}var Sp=(e,t,r,n)=>{let o=e._zod.def;we(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i=Mv(o.defaultValue,e,t,r,n);if(i!==vp)r.default=i},xp=(e,t,r,n)=>{let o=e._zod.def;we(o.innerType,t,n);let s=t.seen.get(e);if(s.ref=o.innerType,t.io!=="input")return;let i=Mv(o.defaultValue,e,t,r,n);if(i!==vp)r._prefault=i},kp=(e,t,r,n)=>{let o=e._zod.def;we(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{Fe(e,t,r,n,"Dynamic catch values are not supported in JSON Schema");return}r.default=i},$p=(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;we(i,t,n);let a=t.seen.get(e);a.ref=i},Ep=(e,t,r,n)=>{let o=e._zod.def;we(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType,r.readOnly=!0},qv=(e,t,r,n)=>{let o=e._zod.def;we(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},qa=(e,t,r,n)=>{let o=e._zod.def;we(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},Tp=(e,t,r,n)=>{let o=e._zod.innerType;we(o,t,n);let s=t.seen.get(e);s.ref=o},Sv={string:tp,number:rp,boolean:np,bigint:Ov,symbol:Pv,null:op,undefined:Av,void:Iv,never:sp,any:ip,unknown:ap,date:Rv,enum:cp,literal:up,nan:Cv,template_literal:lp,file:zv,success:Nv,custom:dp,function:Lv,transform:pp,map:jv,set:Dv,array:fp,object:mp,union:hp,intersection:gp,tuple:yp,record:bp,nullable:wp,nonoptional:_p,default:Sp,prefault:xp,catch:kp,pipe:$p,readonly:Ep,promise:qv,optional:qa,lazy:Tp};function Fv(e,t){if("_idmap"in e){let n=e,o=Ss({...t,processors:Sv}),s={};for(let c of n._idmap.entries()){let[u,l]=c;we(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;xs(o,l),gt(i,u,ks(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=Ss({...t,processors:Sv});return we(e,r),xs(r,e),ks(r,e)}var Uv=new WeakSet([Object.prototype,Error.prototype]);function Fa(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 Hz=(e,t)=>{lb.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);if(Uv.has(r))return;Uv.add(r),Fa(r,"format",(n)=>(o)=>wd(n,o)),Fa(r,"flatten",(n)=>(o)=>bd(n,o)),Fa(r,"addIssue",(n)=>(o)=>{n.issues.push(o),n.message=JSON.stringify(n.issues,ls,2)}),Fa(r,"addIssues",(n)=>(o)=>{n.issues.push(...o),n.message=JSON.stringify(n.issues,ls,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var bt=O("ZodError",Hz,void 0,{Parent:Error});var Wv=ha(bt),Vv=ga(bt),Zv=ms(bt),Bv=ya(bt),Hv=fb(bt),Kv=mb(bt),Gv=hb(bt),Jv=gb(bt),Yv=yb(bt),Xv=bb(bt),Qv=wb(bt),eS=_b(bt);function Gz(){if(!et.localeError)it(Dd())}function Es(){if(!et.memoizer)it({memoizer:jd()})}var he=O("ZodType",(e,t)=>(Gz(),pe.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(yt(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 Mt(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(FN(e,t))},superRefine(e,t){return this.check(UN(e,t))},overwrite(e){return this.check(zr(e))},optional(){return Se(this)},exactOptional(){return EN(this)},nullable(){return rS(this)},nullish(){return Se(rS(this))},nonoptional(e){return RN(this,e)},array(){return k(this)},or(e){return re([this,e])},and(e){return Za(this,e)},transform(e){return nS(this,lS(e))},default(e){return PN(this,e)},prefault(e){return IN(this,e)},catch(e){return zN(this,e)},pipe(e){return nS(this,e)},readonly(){return jN(this)},describe(e){let t=this.clone();return Cr.add(t,{description:e}),t},meta(...e){if(e.length===0)return Cr.get(this);let t=this.clone();return Cr.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 fa(this,"~standard",{...Pd(this),jsonSchema:{input:vs(this,"input"),output:vs(this,"output")}})},set "~standard"(e){hr(this,"~standard",e)},parse:function e(t,r){return Wv(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await Vv(this,t,r,{callee:e})},safeParse(e,t){return Zv(this,e,t)},async safeParseAsync(e,t){return Bv(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){hr(this,"spa",e)},validate(e,t){return ba(this,e,t)},validateAsync(e,t){return wa(this,e,t)},encode:function e(t,r){return Hv(this,t,r,{callee:e})},decode:function e(t,r){return Kv(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await Gv(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await Jv(this,t,r,{callee:e})},safeEncode(e,t){return Yv(this,e,t)},safeDecode(e,t){return Xv(this,e,t)},async safeEncodeAsync(e,t){return Qv(this,e,t)},async safeDecodeAsync(e,t){return eS(this,e,t)},toJSONSchema(e){return yv(this,{})(e)},get description(){return Cr.get(this)?.description},get _def(){return this._zod.def}}),oS=O("_ZodString",(e,t)=>{$a.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>tp(e,r,n,o)},ob({format:(e)=>at(e).format??null,minLength:(e)=>at(e).minimum??null,maxLength:(e)=>at(e).maximum??null},{regex(...e){return this.check(Fd(...e))},includes(...e){return this.check(Vd(...e))},startsWith(...e){return this.check(Zd(...e))},endsWith(...e){return this.check(Bd(...e))},min(...e){return this.check(Yn(...e))},max(...e){return this.check(Da(...e))},length(...e){return this.check(Ma(...e))},nonempty(...e){return this.check(Yn(1,...e))},lowercase(e){return this.check(Ud(e))},uppercase(e){return this.check(Wd(e))},trim(){return this.check(Kd())},normalize(...e){return this.check(Hd(...e))},toLowerCase(){return this.check(Gd())},toUpperCase(){return this.check(Jd())},slugify(){return this.check(Yd())}})),sS=O("ZodString",(e,t)=>{$a.init(e,t),oS.init(e,t)},{email(e){return this.check(C_(Jz,e))},url(e){return this.check(qd(iS,e))},jwt(e){return this.check(Q_(pN,e))},emoji(e){return this.check(M_(Xz,e))},guid(e){return this.check(z_(Yz,e))},uuid(e){return this.check(N_(Ua,e))},uuidv4(e){return this.check(L_(Ua,e))},uuidv6(e){return this.check(j_(Ua,e))},uuidv7(e){return this.check(D_(Ua,e))},nanoid(e){return this.check(q_(Qz,e))},cuid(e){return this.check(F_(eN,e))},cuid2(e){return this.check(U_(tN,e))},ulid(e){return this.check(W_(rN,e))},base64(e){return this.check(J_(uN,e))},base64url(e){return this.check(Y_(lN,e))},xid(e){return this.check(V_(nN,e))},ksuid(e){return this.check(Z_(oN,e))},ipv4(e){return this.check(B_(sN,e))},ipv6(e){return this.check(H_(iN,e))},cidrv4(e){return this.check(K_(aN,e))},cidrv6(e){return this.check(G_(cN,e))},e164(e){return this.check(X_(dN,e))},datetime(e){return this.check(Ia(Ts,e))},date(e){return this.check(Ra(Os,e))},time(e){return this.check(Ca(Ps,e))},duration(e){return this.check(za(As,e))}});function p(e){return R_(sS,e)}var $e=O("ZodStringFormat",(e,t)=>{_e.init(e,t),oS.init(e,t)}),Ts=O("ZodISODateTime",(e,t)=>{jw.init(e,t),$e.init(e,t)}),Os=O("ZodISODate",(e,t)=>{Dw.init(e,t),$e.init(e,t)}),Ps=O("ZodISOTime",(e,t)=>{Mw.init(e,t),$e.init(e,t)}),As=O("ZodISODuration",(e,t)=>{qw.init(e,t),$e.init(e,t)}),Jz=O("ZodEmail",(e,t)=>{Ew.init(e,t),$e.init(e,t)});var Yz=O("ZodGUID",(e,t)=>{kw.init(e,t),$e.init(e,t)});var Ua=O("ZodUUID",(e,t)=>{$w.init(e,t),$e.init(e,t)});var iS=O("ZodURL",(e,t)=>{Pw.init(e,t),$e.init(e,t)});function Is(e){return qd(iS,e)}var Xz=O("ZodEmoji",(e,t)=>{Aw.init(e,t),$e.init(e,t)});var Qz=O("ZodNanoID",(e,t)=>{Iw.init(e,t),$e.init(e,t)});var eN=O("ZodCUID",(e,t)=>{Rw.init(e,t),$e.init(e,t)});var tN=O("ZodCUID2",(e,t)=>{Cw.init(e,t),$e.init(e,t)});var rN=O("ZodULID",(e,t)=>{zw.init(e,t),$e.init(e,t)});var nN=O("ZodXID",(e,t)=>{Nw.init(e,t),$e.init(e,t)});var oN=O("ZodKSUID",(e,t)=>{Lw.init(e,t),$e.init(e,t)});var sN=O("ZodIPv4",(e,t)=>{Fw.init(e,t),$e.init(e,t)});var iN=O("ZodIPv6",(e,t)=>{Ww.init(e,t),$e.init(e,t)});var aN=O("ZodCIDRv4",(e,t)=>{Vw.init(e,t),$e.init(e,t)});var cN=O("ZodCIDRv6",(e,t)=>{Zw.init(e,t),$e.init(e,t)});var uN=O("ZodBase64",(e,t)=>{Hw.init(e,t),$e.init(e,t)});var lN=O("ZodBase64URL",(e,t)=>{Kw.init(e,t),$e.init(e,t)});var dN=O("ZodE164",(e,t)=>{Gw.init(e,t),$e.init(e,t)});var pN=O("ZodJWT",(e,t)=>{Jw.init(e,t),$e.init(e,t)});var Wa=O("ZodNumber",(e,t)=>{Id.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>rp(e,r,n,o),e.isFinite=!0},ob({minValue:(e)=>{let{minimum:t,exclusiveMinimum:r}=at(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:r}=at(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:r}=at(e);return!!t||!!r?.some(Number.isSafeInteger)},format:(e)=>at(e).format??null},{gt(e,t){return this.check(La(e,t))},gte(e,t){return this.check(ws(e,t))},min(e,t){return this.check(ws(e,t))},lt(e,t){return this.check(Na(e,t))},lte(e,t){return this.check(bs(e,t))},max(e,t){return this.check(bs(e,t))},int(e){return this.check(tS(e))},safe(e){return this.check(tS(e))},positive(e){return this.check(La(0,e))},nonnegative(e){return this.check(ws(0,e))},negative(e){return this.check(Na(0,e))},nonpositive(e){return this.check(bs(0,e))},multipleOf(e,t){return this.check(ja(e,t))},step(e,t){return this.check(ja(e,t))},finite(){return this}}));function P(e){return ev(Wa,e)}var fN=O("ZodNumberFormat",(e,t)=>{Yw.init(e,t),Wa.init(e,t)});function tS(e){return rv(fN,e)}var aS=O("ZodBoolean",(e,t)=>{Xw.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>np(e,r,n,o)});function D(e){return nv(aS,e)}var mN=O("ZodNull",(e,t)=>{Qw.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>op(e,r,n,o)});function Va(e){return ov(mN,e)}var hN=O("ZodAny",(e,t)=>{e_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ip(e,r,n,o)});function cS(){return sv(hN)}var gN=O("ZodUnknown",(e,t)=>{t_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ap(e,r,n,o)});function de(){return iv(gN)}var yN=O("ZodNever",(e,t)=>{r_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>sp(e,r,n,o)});function bN(e){return av(yN,e)}var wN=O("ZodArray",(e,t)=>{Es(),n_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>fp(e,r,n,o),e.element=t.element},{min(e,t){return this.check(Yn(e,t))},nonempty(e){return this.check(Yn(1,e))},max(e,t){return this.check(Da(e,t))},length(e,t){return this.check(Ma(e,t))},unwrap(){return this.element}});function k(e,t){return cv(wN,e,t)}var Ap=O("ZodObject",(e,t)=>{Es(),i_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>mp(e,r,n,o),Q1(e,"shape",(r)=>r._zod.def.shape,!1)},{keyof(){return z(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(yt(this._zod.def,{catchall:e}))},passthrough(){return this.clone(yt(this._zod.def,{catchall:de()}))},loose(){return this.clone(yt(this._zod.def,{catchall:de()}))},strict(){return this.clone(yt(this._zod.def,{catchall:bN()}))},strip(){return this.clone(yt(this._zod.def,{catchall:void 0}))},extend(e){return Z1(this,e)},safeExtend(e){return B1(this,e)},merge(e){return H1(this,e)},pick(e){return W1(this,e)},omit(e){return V1(this,e)},partial(...e){return eb(Rp,this,e[0])},exactPartial(...e){return eb(dS,this,e[0],"exactPartial")},required(...e){return K1(pS,this,e[0])}});function b(e,t){let r={type:"object",shape:e??{},...F(t)};return new Ap(r)}function Ee(e,t){return new Ap({type:"object",shape:e,catchall:de(),...F(t)})}var uS=O("ZodUnion",(e,t)=>{Rd.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>hp(e,r,n,o),e.options=t.options});function re(e,t){return new uS({type:"union",options:e,...F(t)})}var _N=O("ZodDiscriminatedUnion",(e,t)=>{uS.init(e,t),a_.init(e,t)});function yr(e,t,r){return new _N({type:"union",options:t,discriminator:e,...F(r)})}var vN=O("ZodIntersection",(e,t)=>{c_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>gp(e,r,n,o)});function Za(e,t){return new vN({type:"intersection",left:e,right:t})}var SN=O("ZodTuple",(e,t)=>{Es(),u_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>yp(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 Rp({type:"optional",innerType:t}))})}});function xN(e,t,r){let n=t instanceof pe,o=n?r:t;return new SN({type:"tuple",items:e,rest:n?t:null,...F(o)})}var Op=O("ZodRecord",(e,t)=>{Es(),l_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>bp(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function J(e,t,r){if(!t||!t._zod)return new Op({type:"record",keyType:p(),valueType:e,...F(t)});return new Op({type:"record",keyType:e,valueType:t,...F(r)})}function Ip(e,t,r){return new Op({type:"record",keyType:e,valueType:t,...F(r),partial:!0})}var Pp=O("ZodEnum",(e,t)=>{d_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(n,o,s)=>cp(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 Pp({...t,checks:[],...F(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 Pp({...t,checks:[],...F(o),entries:s})}});function z(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map((n)=>[n,n])):e;return new Pp({type:"enum",entries:r,...F(t)})}var kN=O("ZodLiteral",(e,t)=>{p_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>up(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 kN({type:"literal",values:Array.isArray(e)?e:[e],...F(t)})}var $N=O("ZodTransform",(e,t)=>{Es(),f_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>pp(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new fs(e.constructor.name);r.addIssue=(s)=>{if(typeof s==="string")r.issues.push(kn(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(kn(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 lS(e){return new $N({type:"transform",transform:e})}var Rp=O("ZodOptional",(e,t)=>{Cd.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>qa(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Se(e){return new Rp({type:"optional",innerType:e})}var dS=O("ZodExactOptional",(e,t)=>{m_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>qa(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function EN(e){return new dS({type:"optional",innerType:e})}var TN=O("ZodNullable",(e,t)=>{h_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>wp(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function rS(e){return new TN({type:"nullable",innerType:e})}var ON=O("ZodDefault",(e,t)=>{g_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Sp(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function PN(e,t){return new ON({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():ld(t)}})}var AN=O("ZodPrefault",(e,t)=>{y_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>xp(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function IN(e,t){return new AN({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():ld(t)}})}var pS=O("ZodNonOptional",(e,t)=>{b_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>_p(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function RN(e,t){return new pS({type:"nonoptional",innerType:e,...F(t)})}var CN=O("ZodCatch",(e,t)=>{w_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>kp(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function zN(e,t){return new CN({type:"catch",innerType:e,catchValue:typeof t==="function"?t:sb(t)})}var fS=O("ZodPipe",(e,t)=>{zd.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>$p(e,r,n,o),e.in=t.in,e.out=t.out});function nS(e,t){return new fS({type:"pipe",in:e,out:t})}var NN=O("ZodPreprocess",(e,t)=>{fS.init(e,t),__.init(e,t)}),LN=O("ZodReadonly",(e,t)=>{v_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ep(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function jN(e){return new LN({type:"readonly",innerType:e})}var DN=O("ZodTemplateLiteral",(e,t)=>{S_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>lp(e,r,n,o)});function MN(e,t){return new DN({type:"template_literal",parts:e,...F(t)})}var qN=O("ZodLazy",(e,t)=>{x_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Tp(e,r,n,o),e.unwrap=()=>e._zod.def.getter()});function Cp(e){return new qN({type:"lazy",getter:e})}var mS=O("ZodCustom",(e,t)=>{k_.init(e,t),he.init(e,t),e._zod.processJSONSchema=(r,n,o)=>dp(e,r,n,o)});function Ba(e,t){return uv(mS,e??(()=>!0),t)}function FN(e,t={}){return lv(mS,e,t)}function UN(e,t){return dv(e,t)}function br(e){let t=Cp(()=>re([p(e),P(),D(),Va(),k(t),J(p(),t)]));return t}function Ha(e,t){return new NN({type:"pipe",in:lS(e),out:t})}var gS={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 hS;(function(e){})(hS||(hS={}));function yS(e){return Ia(Ts,e)}function VN(e){return Ra(Os,e)}function ZN(e){return Ca(Ps,e)}function BN(e){return za(As,e)}function HN(e){return tv(Wa,e)}var wS={name:"@tripwire-sh/cli",version:"0.1.3",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 Ka=wS.version,U="tripwire",Rs="tripwire-get-started",_S="tripwire-workflows",Cs="tripwire-cli",GN="https://mcp.tripwire.sh/mcp",JN="https://app.tripwire.sh/api/auth",vS="offline_access tripwire:read tripwire:configure tripwire:moderate tripwire:admin";function to(e){return e.TRIPWIRE_MCP_URL||GN}function SS(e){return(e.TRIPWIRE_AUTH_URL||JN).replace(/\/+$/,"")}var YN="urn:ietf:params:oauth:grant-type:device_code",XN=b({device_code:p(),user_code:p(),verification_uri:p(),verification_uri_complete:p().optional(),expires_in:P(),interval:P().optional()}),kS=b({access_token:p().min(1),refresh_token:p().min(1).optional(),expires_in:P().optional(),token_type:p().optional()}),Np=b({error:p(),error_description:p().optional()});class zp extends Error{constructor(){super("Session expired. Run tripwire login.");this.name="SessionExpiredError"}}class zs extends Error{constructor(){super("Tripwire is not reachable right now. Try again in a minute.");this.name="AuthUnreachableError"}}var $S={fetch:(e,t)=>fetch(e,t),sleep:(e)=>new Promise((t)=>setTimeout(t,e)),now:()=>Date.now()};async function Ga(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=br().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 ES(e,t){let r=Np.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 TS(e,t,r){let{status:n,body:o}=await Ga(e,`${t}/device/code`,{client_id:Cs,scope:vS,resource:r}),s=XN.safeParse(o);if(n>=400||!s.success)throw ES(o,`Device authorization failed (HTTP ${n})`);return s.data}function OS(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 xS=5000;function QN(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 PS(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 Ga(e,`${t}/oauth2/token`,{grant_type:YN,device_code:n.device_code,client_id:Cs,resource:r}),l=kS.safeParse(c);if(a<400&&l.success)return OS(e,l.data,t,r);if(a===429){if(s=QN(u,e.now()),s===null)o+=xS;continue}let d=Np.safeParse(c),f=d.success?d.data.error:"";if(f==="authorization_pending")continue;if(f==="slow_down"){o+=xS;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 ES(c,`Token request failed (HTTP ${a})`)}throw Error("The code expired. Run tripwire login again.")}async function AS(e,t){if(!t.refreshToken)throw new zp;let{status:r,body:n}=await Ga(e,`${t.authUrl}/oauth2/token`,{grant_type:"refresh_token",refresh_token:t.refreshToken,client_id:Cs,resource:t.mcpUrl}).catch(()=>{throw new zs}),o=kS.safeParse(n);if(r>=400||!o.success){let s=Np.safeParse(n);throw(r===400||r===401)&&s.success&&s.data.error!=="invalid_response"?new zp:new zs}return OS(e,o.data,t.authUrl,t.mcpUrl,t.refreshToken)}async function IS(e,t){let r=t.refreshToken??t.accessToken;await Ga(e,`${t.authUrl}/oauth2/revoke`,{token:r,client_id:Cs}).catch(()=>{return})}import{stripVTControlCharacters as eq}from"node:util";var eL=z(["pending","approved","rejected"]),bne=eL.options;var Ns=[{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 RS(e){return e.status==="live"}var Ls=z(Ns.filter(RS).map((e)=>e.id)),vne=Ns.filter((e)=>RS(e)&&!("paused"in e)).map((e)=>e.label),Sne=Ns.filter((e)=>e.status==="planned").map((e)=>e.label),xne=Ns.filter((e)=>("signIn"in e)).map((e)=>e.id);var tL=Object.fromEntries(Ns.map((e)=>[e.id,e]));var Ja=b({owner:p(),name:p(),fullName:p()}),rL=b({id:p(),login:p(),name:p(),type:z(["Organization","User"]),avatarUrl:p(),repoAccess:z(["all","selected"]),repoCount:P(),installedAt:ve.datetime()}),nL=b({id:p(),owner:p(),name:p(),fullName:p(),private:D(),pushedAt:ve.datetime(),openFlags:P(),stars:P()}),Ene=b({accounts:k(rL),repos:k(nL)});var js=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"]),CS=b({login:p(),externalId:p(),avatarUrl:p().optional()}),Lp=b({number:P().int(),title:p(),headSha:p(),baseRef:p().optional(),headRef:p().optional(),draft:D().optional(),url:p()}),oL=b({externalId:p(),body:p(),url:p(),subjectNumber:P().int(),byTripwire:D().optional()}),sL=b({ref:p(),headSha:p(),commitCount:P().int(),url:p().optional()}),Xa=z(["issue","change-request"]),iL=b({kind:Xa,number:P().int(),title:p(),url:p(),state:z(["open","closed"]),author:p(),labels:k(p()),locked:D(),updatedAt:ve.datetime()}),aL=b({workflowId:p(),nodeId:p(),tickId:p()}),ro={id:p(),forge:Ls,deliveryId:p(),repo:Ja,repoExternalId:p().optional(),installationExternalId:p().optional(),actor:CS,occurredAt:ve.datetime(),receivedAt:ve.datetime()},Ya={id:p(),forge:Ls,deliveryId:p(),actor:CS,occurredAt:ve.datetime(),receivedAt:ve.datetime(),installation:b({externalId:p(),account:p(),accountType:z(["User","Organization"]).optional()}),repositories:k(b({externalId:p(),owner:p(),name:p(),fullName:p(),private:D()}))},zS=yr("kind",[b({...ro,kind:C("change-request.opened"),changeRequest:Lp}),b({...ro,kind:C("change-request.updated"),changeRequest:Lp}),b({...ro,kind:C("change-request.closed"),changeRequest:Lp}),b({...ro,kind:C("comment.created"),comment:oL}),b({...ro,kind:C("push"),push:sL}),b({...ro,kind:C("schedule.matched"),schedule:aL,thread:iL}),b({...Ya,kind:C("installation.created")}),b({...Ya,kind:C("installation.deleted")}),b({...Ya,kind:C("installation-repositories.added")}),b({...Ya,kind:C("installation-repositories.removed")})]),cL=js.extract(["change-request.opened","change-request.updated","change-request.closed"]),Ine=cL.options;var uL=["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"],lL=["sun","mon","tue","wed","thu","fri","sat"],dL=[{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:uL,nameBase:1},{name:"day of week",range:"0 to 7 or sun to sat",min:0,max:7,names:lL,nameBase:0}];function jp(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 pL(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=jp(l,t),u=jp(d,t)}else c=jp(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 Qa(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 dL.entries()){let d=pL(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 jS(e){try{return new Intl.DateTimeFormat("en-US",{timeZone:e}),!0}catch{return!1}}var NS=new Map;function fL(e){let t=NS.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 NS.set(e,r),r}function Mp(e,t){let r=fL(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 Dp(e,t){let r=Mp(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 LS(e,t){let r=Date.UTC(e.year,e.month-1,e.day,e.hour,e.minute),n=[r-Dp(r-129600000,t),r-Dp(r+129600000,t),r-Dp(r,t)].sort((o,s)=>o-s);for(let o of n){let s=Mp(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 mL(e,t){let r=t.getUTCDate(),n=t.getUTCDay(),o=e.days.includes(r),s=e.weekdays.includes(n);if(e.daysRestricted&&e.weekdaysRestricted)return o||s;return o&&s}var hL=1830,gL=180;function yL(e,t){let r=LS(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<=gL;o++){let s=new Date(n+o*60000),i=LS({year:s.getUTCFullYear(),month:s.getUTCMonth()+1,day:s.getUTCDate(),hour:s.getUTCHours(),minute:s.getUTCMinutes()},t);if(i)return i}return null}function DS(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 qp(e,t,r){let n=Mp(r,t),o=new Date(Date.UTC(n.year,n.month-1,n.day));for(let s=0;s<=hL;s++){if(e.months.includes(o.getUTCMonth()+1)&&mL(e,o))for(let i of e.hours)for(let a of e.minutes){let c=yL({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 tc=5,je=Cp(()=>re([p(),P(),D(),Va(),k(je),J(p(),je)])),nc=b({x:P(),y:P()}),bL=z(["all-of","any-of","not"]),wL=z(["block","comment","label","request-review","send-to-moderation","webhook","discord","lock","close","remove-label","post-comment"]),_L=["comment"];function qS(e){return _L.includes(e)}var jne=b({url:Is().meta({secret:!0}).describe("webhook url"),signingSecret:p().min(1).optional().meta({secret:!0}).describe("signing secret")}),Dne=b({url:Is().meta({secret:!0}).describe("discord webhook url")}),no=15,oc=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`}),Fp=p().regex(/^[A-Za-z0-9][A-Za-z0-9_-]{0,99}$/,{error:(e)=>`${String(e.input)} is not a team slug`}),Up=b({id:P().int().positive().optional(),login:oc}),Mne=b({id:P().int().positive(),login:oc,avatarUrl:p(),permission:p().min(1)}),qne=b({name:p().min(1),color:p().regex(/^[0-9a-fA-F]{6}$/),description:p().nullable()}),vL=Ha((e)=>p().safeParse(e).success?{login:e}:e,Up);function FS(e,t){return e.id!==void 0&&t.id!==void 0?e.id===t.id:e.login.toLowerCase()===t.login.toLowerCase()}var Ds=b({reviewers:k(vL).max(no,`ask at most ${no} people`).default([]),teamReviewers:k(Fp).max(no,`ask at most ${no} teams`).default([])}),US=Ds.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>no)t.addIssue({code:"custom",message:`ask at most ${no} people and teams`})}),Nr=b({labels:k(p().trim().min(1)).min(1,"choose at least one label")}),MS=5000,sc=b({message:p().trim().min(1,"write a message").max(MS,`keep it under ${MS} characters`)}),SL=z(["resolved","off-topic","too heated","spam"]),WS=b({reason:SL.optional()}),Wp={hours:3600000,days:86400000,weeks:604800000,months:2592000000};function Vp(e){return e.n*Wp[e.unit]}var xL=52*Wp.weeks,kL=3650*Wp.days,$L=z(["hours","days","weeks"]),EL=z(["hours","days","weeks","months"]),TL=b({n:P().int().min(1),unit:$L}).refine((e)=>Vp(e)<=xL,{message:"runs at least once a year"}),VS="UTC",ZS=p().min(1).refine(jS,{error:(e)=>`${String(e.input)} is not an IANA timezone, like Europe/Berlin`}),ec=p().regex(/^([01]\d|2[0-3]):[0-5]\d$/,"use 24-hour HH:MM, like 07:30"),Zp=z(["sunday","monday","tuesday","wednesday","thursday","friday","saturday"]),OL=yr("preset",[b({preset:C("hourly"),minute:P().int().min(0).max(59)}),b({preset:C("daily"),at:ec}),b({preset:C("weekdays"),at:ec}),b({preset:C("weekly"),on:Zp,at:ec}),b({preset:C("monthly"),day:P().int().min(1).max(28),at:ec})]),PL=b({cron:p().trim().superRefine((e,t)=>{let r=Qa(e);if(!r.ok){t.addIssue({code:"custom",message:r.error});return}if(qp(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(DS(r.spec)<tc)t.addIssue({code:"custom",message:`runs must be at least ${tc} minutes apart`})})}),BS=re([TL,OL,PL]),HS=b({n:P().int().min(1),unit:EL}).refine((e)=>Vp(e)<=kL,{message:"10 years at most"}),KS=z(["open","closed","any"]),rc=k(p().min(1)),AL=b({subjects:k(Xa).min(1),state:KS,inactiveFor:HS,labels:rc.optional(),excludeLabels:rc.optional(),skipLocked:D().default(!0)}),oo=b({every:BS,timezone:ZS.optional(),match:AL}),IL=b({every:BS.optional(),timezone:ZS.optional(),match:b({subjects:k(Xa).optional(),state:KS.optional(),inactiveFor:HS.optional(),labels:rc.optional(),excludeLabels:rc.optional(),skipLocked:D().optional()}).default({})});var RL=["every","subjects","state","inactiveFor"];function GS(e){return RL.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 CL=b({id:p(),type:C("trigger"),kinds:k(js).min(1),schedule:IL.optional(),position:nc.optional()});function ic(e){return e.type==="trigger"&&(e.kinds??[]).includes("schedule.matched")}var zL=b({id:p(),type:C("rule"),ref:p().regex(/^[a-z][a-z0-9-]*@\d+$/),config:je,position:nc.optional()}),NL=b({id:p(),type:C("gate"),mode:bL,position:nc.optional()}),LL=b({id:p(),type:C("action"),action:wL,params:J(p(),je).optional(),position:nc.optional()}),Bp=yr("type",[CL,zL,NL,LL]),JS=z(["pass","fail","approve","deny"]),jL=b({id:p(),from:p(),to:p(),when:JS.optional()}),wr=b({id:p(),name:p(),version:P().int().min(1),nodes:k(Bp).min(1),edges:k(jL)}),YS={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 XS=[{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}],QS=[{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 Vne=J(p(),je).catch({});function ac(e){if(e.length<=1)return e[0]??"";return`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`}function tx(e){let t=Nr.safeParse(e);return t.success?t.data.labels:[]}function rx(e){return`${e.length===1?"the label":"the labels"} ${ac(e)}`}function DL(e){let t=Ds.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=DL(t);return r.length>0?`requests GitHub review from ${ac(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 ML=b({runId:p(),verdict:p().nullable(),status:p(),reason:p().nullable()}),ox=b({event:zS,run:ML.nullable(),pending:D().optional()}),qL=b({repoFullName:p(),subjectNumber:P().int(),title:p(),url:p().nullable(),actor:b({login:p(),avatarUrl:p().nullable()}),currentVerdict:p().nullable(),currentRunId:p().nullable(),latestActivityAt:ve.datetime(),eventCount:P().int(),timeline:k(ox)}),FL=yr("type",[b({type:C("group"),group:qL}),b({type:C("event"),entry:ox})]),Kne=b({items:k(FL)});var UL=["tripwire:read","tripwire:configure","tripwire:moderate","tripwire:admin"],Yne=z(UL);var WL="https://tripwire.sh/orgs";var Xne=b({sub:p().min(1),azp:p().min(1).optional(),client_id:p().min(1).optional(),scope:p().optional(),[WL]:k(p()).optional()});var VL=z(["success","failure","neutral","pending"]),toe=b({sha:p(),conclusion:VL,summary:p(),detailsUrl:p()});var ZL=["matched-values","file-paths","ai-trace","ai-summary","reasons","rule-names","passed-count","failed-count"],BL=ZL.length;var HL=P().int().min(0).max(BL),sx=z(["run-page","check","comment","review","webhook"]),ooe=sx.options,KL=["run-page","check","comment","review"],cc=b({level:HL.default(0),surfaces:k(sx).default(()=>[...KL]),showHelp:D().default(!0)}),ix=cc.extend({inherit:D().default(!0)}),GL=cc.parse({});var JL=z(["green","blue","purple","pink","orange","red","grey"]),_r=z(["issue","pull"]),Ms=z(["open","closed","merged"]),ax=b({key:p(),label:p(),value:P(),delta:P().optional(),invertDelta:D().optional(),sub:p().optional(),series:k(P()),color:JL,suffix:p().optional()}),YL=b({rule:p(),count:P()}),XL=b({kind:_r,number:P(),title:p(),comments:P(),blocked:P(),status:Ms}),QL=b({login:p(),count:P(),flagged:D().optional()}),ej=b({login:p(),reason:p(),caughtBy:p(),status:z(["Hidden","Removed"]),commentId:p().optional()}),tj=b({kind:z(["review","check"]),title:p(),detail:p(),status:z(["Approved","Changes","Passed","Failed"]),actor:p().optional()}),rj=b({kind:_r,number:P(),title:p(),status:Ms,meta:p(),metrics:k(ax),series:k(P()),byParticipant:k(QL),flagged:k(ej).optional(),checks:k(tj).optional()}),aoe=b({metrics:k(ax),blockedByRule:k(YL),activeThreads:k(XL),threads:J(p(),rj)});var io=z(["issue","pull","comment"]),Hp=z(["spam","harassment","off-topic","automod","nsfw"]),Kp=z(["low","medium","high","critical"]),nj=z(["pending","resolved"]),so=b({login:p(),avatarUrl:p()}),doe=b({id:p(),type:io,repository:Ja,number:P(),title:p(),bodyPreview:p(),author:so,reason:Hp,severity:Kp,reporter:so.nullable(),automodRule:p().optional(),reportedAt:ve.datetime(),status:nj,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"})}),Lr=b({value:P(),delta:P(),series:k(P())}),poe=b({sentToReview:Lr,blocked:Lr,passed:Lr}),foe=z(["approve","remove","ban"]);var oj=z(["info","warn","critical"]),sj=b({severity:oj,file:p(),line:P().int().min(1).optional(),note:p().max(240)}),goe=b({verdict:z(["pass","block","needs_review"]),confidence:P().min(0).max(1),summary:p().max(200),findings:k(sj).max(5)}),cx=b({model:p().optional(),maxSteps:P().int().min(1).max(15).default(12)});var ij=b({type:z(["reasoning","tool_call"]),toolName:p().optional(),excerpt:p(),truncated:D()}),yoe=b({model:p(),stepsUsed:P().int().min(0),maxSteps:P().int().min(0),trimmed:D(),costUsd:P().nullable().optional(),usage:b({input:P().int().min(0),output:P().int().min(0),cached:P().int().min(0).nullable()}),steps:k(ij)});var aj=z(["blocklist","heuristic","classifier","regex"]),cj=z(["flag","hide","close","require-review"]),uj=z(["pending","confirmed","false-positive"]),lj=b({id:p(),type:io,repoFullName:p(),number:P(),author:b({login:p(),avatarUrl:p()}),snippet:p(),matchedAt:ve.datetime(),verdict:uj,threadKind:_r,commentId:p()}),koe=b({id:p(),name:p(),description:p(),category:aj,pattern:p(),scope:k(io),action:cj,enabled:D(),matches24h:P(),matches30d:P(),falsePositiveRate:P().min(0).max(100),lastFiredAt:ve.datetime(),trend:k(P()),recentMatches:k(lj)}),$oe=b({activeRules:Lr,matches24h:Lr,falsePositiveRate:Lr,autoActioned24h:Lr}),Eoe=b({ruleId:p(),version:P().int().min(1),status:z(["evaluated","skipped"]),passed:D(),evidence:de(),reason:p().optional(),evaluatedAt:ve.datetime()}),dj=b({minDays:P().int().min(0)}),Toe=b({min:P().int().min(0)}),pj=b({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")}),fj=b({maxPerWindow:P().int().min(1),windowHours:P().min(0.1).default(24)}),mj=b({max:P().int().min(1)}),hj=b({maxNonLatinRatio:P().min(0).max(1).default(0.5)}),gj=b({}),yj=b({paths:k(p()).min(1)}),bj=b({minLength:P().int().min(1).default(32)}),He=[{ruleId:"account-age",forges:["github"],version:1,name:"Account age",blurb:"the contributor's forge account must be at least N days old.",configSchema:dj,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:pj,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:fj,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:mj,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:hj,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:gj,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:yj,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:bj,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:"off until you turn it on, because ai review costs tokens.",configSchema:cx,defaultConfig:{maxSteps:12},optIn:!0,changeNote:"findings must quote code",description:"Reads the change like a reviewer and flags slop. Off until you turn it on, because it costs tokens.",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 Noe=J(p(),je);var vj=z(["silent","ci-check","comment"]),ux=z(["comment","silent"]),Sj=z(["full","one-liner-link","custom"]),Gp=b({customText:p().max(4000).default(""),showDetailsButton:D().default(!0)}),xj=Gp.extend({mode:Sj.default("full"),template:p().max(4000).default("")}),kj=b({onSuccess:vj.default("ci-check"),passComment:Gp.prefault({}),onBlock:ux.default("comment"),blockComment:xj.prefault({}),moderationQueued:ux.default("comment"),reviewComment:Gp.prefault({}),failClosedFallback:D().default(!0),redaction:ix.prefault({})}),$j=b({redaction:cc.prefault({})}),Moe=$j.parse({});var Ej=kj.parse({});var lx="If you think this is wrong, say so in a comment. A maintainer will decide.",dx="If you think it should merge anyway, say so in a comment. A maintainer will decide.",Joe=`Push a commit that fixes the problems. Tripwire checks every push.
|
|
229
229
|
|
|
230
230
|
${lx}`,Yoe=`A new commit will not fix this.
|
|
231
231
|
|