@tripwire-sh/cli 0.1.16-staging.1 → 0.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/tripwire.js +1 -1
  2. package/package.json +1 -1
package/dist/tripwire.js CHANGED
@@ -225,7 +225,7 @@ ${t.join(`
225
225
  }
226
226
  `)}return b.write("payload.value = newResult;"),b.write("return payload;"),b.compile()},s,a=Do,c=!dt.jitless,d=c&&FS.value,p=t.catchall,f;e._zod.parse=(h,g)=>{f??(f=r.value);let y=h.value;if(!a(y))return h.issues.push({expected:"object",code:"invalid_type",input:y,inst:e}),h;if(c&&d&&g?.async===!1&&g.jitless!==!0){if(!s)s=i(t.shape);if(h=s(h,g),!p)return h;return o_([],y,h,g,f,e,g?.abortEarly===!0)}return n(h,g)}});function av(e,t,n,r){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let o=e.filter((i)=>!Lt(i));if(o.length===1)return t.value=o[0].value,o[0];return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map((i)=>i.issues.map((s)=>mn(s,r,bt())))}),t}var wf=I("$ZodUnion",(e,t)=>{ae.init(e,t),se(e,"optin",(r)=>r.def.options.some((o)=>o._zod.optin==="defaulted")?"defaulted":r.def.options.some((o)=>o._zod.optin!==void 0)?"optional":void 0),se(e,"optout",(r)=>r.def.options.some((o)=>o._zod.optout==="optional")?"optional":void 0),se(e,"values",(r)=>{if(r.def.options.every((o)=>o._zod.values))return new Set(r.def.options.flatMap((o)=>Array.from(o._zod.values)));return}),se(e,"pattern",(r)=>{if(r.def.options.every((o)=>o._zod.pattern)){let o=r.def.options.map((i)=>i._zod.pattern);return new RegExp(`^(${o.map((i)=>ur(i.source)).join("|")})$`)}return});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let i=!1,s=[];for(let a of t.options){let c=a._zod.run({value:r.value,issues:[]},o);if(c instanceof Promise)s.push(c),i=!0;else{if(c.issues.length===0)return c;s.push(c)}}if(!i)return av(s,r,e,o);return Promise.all(s).then((a)=>av(a,r,e,o))}});function LD(e){let t=new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let o of r)if(t.has(o)){if(o!==void 0)throw Error(`Duplicate discriminator value "${String(o)}"`);t.set(o,null)}else t.set(o,n)}return t}var s_=I("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,wf.init(e,t);let n=e._zod.parse;se(e,"propValues",(o)=>{let i={},s=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))s++;for(let[l,d]of Object.entries(c)){if(!Object.prototype.hasOwnProperty.call(i,l))It(i,l,new Set);for(let p of d)i[l].add(p)}}if(!o.def.unionFallback&&s>1)i[o.def.discriminator]?.delete(void 0);return i}),t.options.forEach((o,i)=>{let s=gs(o._zod.def);if(s&&!Object.prototype.hasOwnProperty.call(s,t.discriminator))throw Error(`Invalid discriminated union option at index "${i}"`)});let r=hs(()=>LD(t));e._zod.parse=(o,i)=>{let s=o.value;if(!Do(s))return o.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),o;let a=s?.[t.discriminator],c=r.value.get(a);if(c&&(a!==void 0||i.direction!=="backward"))return c._zod.run(o,i);if(t.unionFallback||i.direction==="backward")return n(o,i);return o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()).filter((l)=>r.value.get(l)!==null),input:s,path:[t.discriminator],inst:e}),o}}),a_=I("$ZodIntersection",(e,t)=>{ae.init(e,t),e._zod.parse=(n,r)=>{let o=n.value,i=t.left._zod.run({value:o,issues:[]},r),s=t.right._zod.run({value:o,issues:[]},r);if(i instanceof Promise||s instanceof Promise)return Promise.all([i,s]).then(([c,l])=>cv(n,c,l));return cv(n,i,s)}});function mf(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(io(e)&&io(t)){let n=Object.keys(t),r=Object.keys(e).filter((i)=>n.indexOf(i)!==-1),o={...e,...t};if(Object.prototype.hasOwnProperty.call(o,"__proto__"))delete o.__proto__;for(let i of r){if(i==="__proto__")continue;let s=mf(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};o[i]=s.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let o=e[r],i=t[r],s=mf(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function cv(e,t,n){let r=new Map,o,i=new Map,s=(l,d)=>{let p;if(l.code==="unrecognized_keys"&&!l.path?.length)o??(o=l),p=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&l.path?.length===1){let f=String(l.path[0]);if(!i.has(f))i.set(f,l);p=[f]}else return!1;for(let f of p){if(!r.has(f))r.set(f,{});r.get(f)[d]=!0}return!0};for(let l of t.issues)if(!s(l,"l"))e.issues.push(l);for(let l of n.issues)if(!s(l,"r"))e.issues.push(l);let a=[...r].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(a.length){let l=o?a.filter((d)=>o.keys.includes(d)):[];if(l.length)e.issues.push({...o,keys:l});for(let d of a)if(!l.includes(d)&&i.has(d))e.issues.push(i.get(d))}let c=mf(t.value,n.value);if(!c.valid){if(Lt(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Sf=I("$ZodTuple",(e,t)=>{ae.init(e,t);let n=t.items,r=dt.memoizer;r?.attach(e),e._zod.parse=(o,i)=>{let s=o.value;if(!Array.isArray(s))return o.issues.push({input:s,inst:e,expected:"tuple",code:"invalid_type"}),o;o.value=r?r.alloc(e,o,[],i):[];let a=[],c=lv(n,"optin"),l=lv(n,"optout");if(!t.rest){if(s.length<c)return o.issues.push({code:"too_small",minimum:c,inclusive:!0,input:s,inst:e,origin:"array"}),o;if(s.length>n.length)o.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:s,inst:e,origin:"array"})}let d=Array(n.length),p=t.rest?i?.abortEarly:void 0,f=!1;for(let h=0;h<n.length;h++){let g=n[h]._zod.run({value:s[h],issues:[]},i);if(g instanceof Promise)a.push(g.then((y)=>{d[h]=y}));else if(d[h]=g,p&&!f&&g.issues.length)f=Lt(g)}if(t.rest&&!f){let h=n.length-1,g=s.slice(n.length),y=o.issues.length;for(let b of g){if(p&&o.issues.length!==y){if(Lt(o,y))break;y=o.issues.length}h++;let w=t.rest._zod.run({value:b,issues:[]},i);if(w instanceof Promise)a.push(w.then((R)=>uv(R,o,h)));else uv(w,o,h)}}if(a.length)return Promise.all(a).then(()=>dv(d,o,n,s,l));return dv(d,o,n,s,l)}});function lv(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function uv(e,t,n){if(e.issues.length)t.issues.push(...nn(n,e.issues));t.value[n]=e.value}function dv(e,t,n,r,o){for(let i=0;i<n.length;i++){let s=e[i],a=i<r.length;if(!a&&i>=o&&n[i]._zod.optin==="optional"){t.value.length=i;break}if(s.issues.length){if(!a&&i>=o){t.value.length=i;break}t.issues.push(...nn(i,s.issues))}t.value[i]=s.value}for(let i=t.value.length-1;i>=r.length;i--)if(n[i]._zod.optout==="optional"&&t.value[i]===void 0)t.value.length=i;else break;return t}var c_=I("$ZodRecord",(e,t)=>{ae.init(e,t);let n=dt.memoizer;n?.attach(e),e._zod.parse=(r,o)=>{let i=r.value;if(!io(i))return r.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),r;let s=[],a=t.keyType._zod.values;if(a&&!t.partial){r.value=n?n.alloc(e,r,{},o):{};let c=new Set;for(let d of a)if(typeof d==="string"||typeof d==="number"||typeof d==="symbol"){if(c.add(typeof d==="number"?d.toString():d),d==="__proto__")continue;let p=t.keyType._zod.run({value:d,issues:[]},o);if(p instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(p.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:p.issues.map((g)=>mn(g,o,bt())),input:d,path:[d],inst:e});continue}let f=p.value;if(f==="__proto__")continue;let h=t.valueType._zod.run({value:i[d],issues:[]},o);if(h instanceof Promise)s.push(h.then((g)=>{if(g.issues.length)r.issues.push(...nn(d,g.issues));r.value[f]=g.value}));else{if(h.issues.length)r.issues.push(...nn(d,h.issues));r.value[f]=h.value}}let l;for(let d in i)if(!c.has(d))if(t.mode==="loose"){if(d==="__proto__")continue;r.value[d]=i[d]}else l=l??[],l.push(d);if(l&&l.length>0)r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},o):{};let c;for(let l of Reflect.ownKeys(i)){if(l==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(i,l))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(typeof l==="string"&&Mo.test(l)&&d.issues.length){let g=t.keyType._zod.run({value:Number(l),issues:[]},o);if(g instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(g.issues.length===0)d=g}if(d.issues.length){if(t.mode==="loose")r.value[l]=i[l];else if(a)c=c??[],c.push(l);else r.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map((g)=>mn(g,o,bt())),input:l,path:[l],inst:e});continue}let f=d.value;if(f==="__proto__")continue;let h=t.valueType._zod.run({value:i[l],issues:[]},o);if(h instanceof Promise)s.push(h.then((g)=>{if(g.issues.length)r.issues.push(...nn(l,g.issues));r.value[f]=g.value}));else{if(h.issues.length)r.issues.push(...nn(l,h.issues));r.value[f]=h.value}}if(c&&c.length>0)r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c,continue:!0})}if(s.length)return Promise.all(s).then(()=>r);return r}});var l_=I("$ZodEnum",(e,t)=>{ae.init(e,t);let n=fs(t.entries),r=new Set(n);e._zod.values=r,se(e,"pattern",(o)=>{let i=fs(o.def.entries).filter((s)=>WS.has(typeof s));return new RegExp(i.length?`^(${i.map((s)=>Vn(s.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,i)=>{let s=o.value;if(r.has(s))return o;return o.issues.push({code:"invalid_value",values:n,input:s,inst:e}),o}}),u_=I("$ZodLiteral",(e,t)=>{ae.init(e,t);let n=new Set(t.values);e._zod.values=n,se(e,"pattern",(r)=>{let o=r.def.values;return new RegExp(o.length?`^(${o.map((i)=>typeof i==="string"?Vn(i):i?Vn(i.toString()):String(i)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,o)=>{let i=r.value;if(n.has(i))return r;return r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}});var d_=I("$ZodTransform",(e,t)=>{ae.init(e,t),e._zod.optin="optional",dt.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new bs(e.constructor.name);let o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then((s)=>(n.value=s,n));if(o instanceof Promise)throw new hn;return n.value=o,n}});function pv(e,t){return e.value=t.issues.length?void 0:t.value,e}var xf=I("$ZodOptional",(e,t)=>{ae.init(e,t),se(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",se(e,"values",(n)=>{let r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),se(e,"pattern",(n)=>{let r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${ur(r.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;let o=t.innerType._zod.run({value:n.value,issues:[]},r);if(o instanceof Promise)return o.then((i)=>pv(n,i));return pv(n,o)}return t.innerType._zod.run(n,r)}}),p_=I("$ZodExactOptional",(e,t)=>{xf.init(e,t),se(e,"values",(n)=>n.def.innerType._zod.values),se(e,"pattern",(n)=>n.def.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),f_=I("$ZodNullable",(e,t)=>{ae.init(e,t),se(e,"optin",(n)=>n.def.innerType._zod.optin),se(e,"optout",(n)=>n.def.innerType._zod.optout),se(e,"pattern",(n)=>{let r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${ur(r.source)}|null)$`):void 0}),se(e,"values",(n)=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>{if(n.value===null)return n;return t.innerType._zod.run(n,r)}}),m_=I("$ZodDefault",(e,t)=>{ae.init(e,t),e._zod.optin="defaulted",se(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;let o=t.innerType._zod.run(n,r);if(o instanceof Promise)return o.then((i)=>fv(i,t));return fv(o,t)}});function fv(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var h_=I("$ZodPrefault",(e,t)=>{ae.init(e,t),e._zod.optin="defaulted",se(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)n.value=t.defaultValue;return t.innerType._zod.run(n,r)}}),g_=I("$ZodNonOptional",(e,t)=>{ae.init(e,t),se(e,"values",(n)=>{let r=n.def.innerType._zod.values;return r?new Set([...r].filter((o)=>o!==void 0)):void 0}),e._zod.parse=(n,r)=>{let o=t.innerType._zod.run(n,r);if(o instanceof Promise)return o.then((i)=>mv(i,e));return mv(o,e)}});function mv(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 hv(e,t,n,r){if(!t.issues.length){if(e.value=t.value,t.memo)e.memo=!0;return e}return e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map((o)=>mn(o,r,bt()))},input:e.value}),e}var y_=I("$ZodCatch",(e,t)=>{ae.init(e,t),se(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),se(e,"optout",(n)=>n.def.innerType._zod.optout),se(e,"values",(n)=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);let o=t.innerType._zod.run({value:n.value,issues:[]},r);if(o instanceof Promise)return o.then((i)=>hv(n,i,t,r));return hv(n,o,t,r)}}),b_=I("$ZodNaN",(e,t)=>{ae.init(e,t),e._zod.parse=(n,r)=>{if(typeof n.value!=="number"||!Number.isNaN(n.value))return n.issues.push({input:n.value,inst:e,expected:"nan",code:"invalid_type"}),n;return n}}),vf=I("$ZodPipe",(e,t)=>{ae.init(e,t),se(e,"values",(n)=>n.def.in._zod.values),se(e,"optin",(n)=>n.def.in._zod.optin),se(e,"optout",(n)=>n.def.out._zod.optout),se(e,"propValues",(n)=>n.def.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){let i=t.out._zod.run(n,r);if(i instanceof Promise)return i.then((s)=>Fc(s,t.in,r));return Fc(i,t.in,r)}let o=t.in._zod.run(n,r);if(o instanceof Promise)return o.then((i)=>Fc(i,t.out,r));return Fc(o,t.out,r)}});function Fc(e,t,n){if(e.issues.some((r)=>r.code!=="unrecognized_keys"))return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},n)}var w_=I("$ZodPreprocess",(e,t)=>{vf.init(e,t)}),S_=I("$ZodReadonly",(e,t)=>{ae.init(e,t),se(e,"propValues",(n)=>n.def.innerType._zod.propValues),se(e,"values",(n)=>n.def.innerType._zod.values),se(e,"optin",(n)=>n.def.innerType?._zod?.optin),se(e,"optout",(n)=>n.def.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);let o=t.innerType._zod.run(n,r);if(o instanceof Promise)return o.then(gv);return gv(o)}});function gv(e){if(!e.memo)e.value=Object.freeze(e.value);return e}function DD(e){let t=e._zod.def,n=t.pattern,r=!!t.format?.includes("int"),o,i;for(let a of t.checks??[]){let c=a._zod.def;if(c.pattern)n=c.pattern;r||(r=!!c.format?.includes("int"));let l=c.minimum??c.length,d=c.maximum??c.length;if(l!==void 0&&(o===void 0||l>o))o=l;if(d!==void 0&&(i===void 0||d<i))i=d}if(n)return n.source;if(o!==void 0&&i!==void 0&&o>i)return"(?!)";if(o!==void 0||i!==void 0)return jx({minimum:o,maximum:i}).source;let s=e._zod.pattern;return(r&&s===Mo?qc:s)?.source}function hf(e){let t=e._zod.def,n=e._zod.pattern?.source,r=t.innerType??e._zod.innerType;if(r){let o=r._zod.pattern?.source,i=hf(r);if(n&&o&&i&&i!==o)return n.replace(ur(o),()=>ur(i));return n}if(t.options){let o=t.options.map(hf);if(o.every(Boolean))return`^(${o.map((i)=>ur(i)).join("|")})$`}return DD(e)}var x_=I("$ZodTemplateLiteral",(e,t)=>{ae.init(e,t);let n=[];for(let r of t.parts)if(typeof r==="object"&&r!==null){let o=hf(r);if(!o)throw Error(`Invalid template literal part, no pattern found: ${[...r._zod.traits].shift()}`);n.push(ur(o))}else if(r===null||VS.has(typeof r))n.push(Vn(`${r}`));else throw Error(`Invalid template literal part: ${r}`);e._zod.pattern=new RegExp(`^${n.join("")}$`),e._zod.parse=(r,o)=>{if(typeof r.value!=="string")return r.issues.push({input:r.value,inst:e,expected:"string",code:"invalid_type"}),r;if(e._zod.pattern.lastIndex=0,!e._zod.pattern.test(r.value))return r.issues.push({input:r.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),r;return r}}),v_=I("$ZodFunction",(e,t)=>(ae.init(e,t),Object.defineProperty(e,"_def",{value:t}),e._zod.def=t,e.implement=(n)=>{if(typeof n!=="function")throw Error("implement() must be called with a function");return Object.defineProperty(function(...r){let o=e._def.input?Nc(e._def.input,r):r,i=Reflect.apply(n,this,o);if(e._def.output)return Nc(e._def.output,i);return i},"_zod",{value:e._zod,enumerable:!1})},e.implementAsync=(n)=>{if(typeof n!=="function")throw Error("implementAsync() must be called with a function");return Object.defineProperty(async function(...r){let o=e._def.input?await jc(e._def.input,r):r,i=await Reflect.apply(n,this,o);if(e._def.output)return await jc(e._def.output,i);return i},"_zod",{value:e._zod,enumerable:!1})},e._zod.parse=(n,r)=>{if(typeof n.value!=="function")return n.issues.push({code:"invalid_type",expected:"function",input:n.value,inst:e}),n;if(e._def.output&&e._def.output._zod.def.type==="promise")n.value=e.implementAsync(n.value);else n.value=e.implement(n.value);return n},e.input=(...n)=>{let r=e.constructor;if(Array.isArray(n[0]))return new r({type:"function",input:new Sf({type:"tuple",items:n[0],rest:n[1]}),output:e._def.output});return new r({type:"function",input:n[0],output:e._def.output})},e.output=(n)=>new e.constructor({type:"function",input:e._def.input,output:n}),e));var __=I("$ZodLazy",(e,t)=>{ae.init(e,t),LS(e._zod,"innerType",()=>{let n=t;if(!n._cachedInner)n._cachedInner=t.getter();return n._cachedInner}),se(e,"pattern",(n)=>n.innerType?._zod?.pattern),se(e,"propValues",(n)=>n.innerType?._zod?.propValues),se(e,"optin",(n)=>n.innerType?._zod?.optin??void 0),se(e,"optout",(n)=>n.innerType?._zod?.optout??void 0),e._zod.parse=(n,r)=>e._zod.innerType._zod.run(n,r)}),k_=I("$ZodCustom",(e,t)=>{He.init(e,t),ae.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=(n)=>{let r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then((i)=>yv(i,n,r,e));yv(o,n,r,e);return}});function yv(e,t,n,r){if(!e){let o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};if(r._zod.def.params)o.params=r._zod.def.params;t.issues.push(so(o))}}class C_ extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var kf="~memo",$_=[];function R_(e){return e!==null&&typeof e==="object"}function _f(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var E_=new WeakMap,_s=0,Kc=1,ks=2;function Jc(e,t,n){let r=E_.get(e);if(r!==void 0)return r?ks:_s;if(t.has(e))return ks;t.add(e);let o=_s,i=(d)=>{if(o!==ks&&d?._zod){let p=Jc(d,t,n);if(p>o)o=p}},s=(d,p)=>{let f=_s;for(let h of Reflect.ownKeys(d)){let g=Object.getOwnPropertyDescriptor(d,h);if(p&&!g.enumerable)continue;let y=g.get?Kc:g.value?._zod?Jc(g.value,t,n):_s;if(y>f)f=y}return f},a=(d)=>{if(d>o)o=d},c=e._zod.def,l=c.type;switch(l){case"object":{let d=gs(c);a(d?s(d,!0):Kc),i(c.catchall);break}case"array":i(c.element);break;case"tuple":for(let d of c.items)i(d);i(c.rest);break;case"record":case"map":i(c.keyType),i(c.valueType);break;case"set":i(c.valueType);break;case"union":for(let d of c.options)i(d);break;case"intersection":i(c.left),i(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":i(c.innerType);break;case"pipe":i(c.in),i(c.out);break;case"function":i(c.input),i(c.output);break;case"lazy":{let d=c._cachedInner??(n?e._zod.innerType:void 0);a(d?Jc(d,t,!1):Kc);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 d in c){let p=Object.getOwnPropertyDescriptor(c,d);if(!p||p.get)continue;let f=p.value;if(!f||typeof f!=="object")continue;if(f._zod)i(f);else if(Array.isArray(f))for(let h of f)i(h)}}return t.delete(e),MD(e,o)}function MD(e,t){if(t!==Kc)E_.set(e,t===ks);return t}function qD(e,t){let n=e.buckets.get(t);if(!n)n=new WeakMap,e.buckets.set(t,n);return n}var Bc,Hc=[],UD={alloc(e,t,n){let r=Bc;if(!r)return n;Bc=void 0;let o={value:n,issues:null};return r.set(t.value,o),Hc.push(o),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let n=e._zod.parse,r=(o,i)=>{if(i.direction!=="backward"&&FD(i,o.value))throw new C_;return n(o,i)};if(e._zod.parse=r,e._zod.run===n)e._zod.run=r})},attach(e){var t;let n,r=!1,o,i;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let s=e._zod.parse,a=(c,l)=>{if(n===void 0){let w=Jc(e,new Set,!1);if(w===_s){if(e._zod.parse=s,e._zod.run===a)e._zod.run=s;return s(c,l)}if(w===ks||r)n=!0;else r=!0}let d=c.value;if(!R_(d))return s(c,l);let p=l[kf];if(!p)p={buckets:new WeakMap,backEdges:void 0},l[kf]=p;let f;if(o===l)f=i;else f=qD(p,e),o=l,i=f;let h=f.get(d);if(h){if(c.value=h.value,h.issues){if(h.issues.length)c.issues.push(..._f(h.issues))}else c.memo=!0,p.backEdges??(p.backEdges=new WeakSet),p.backEdges.add(h.value);return c}Bc=f;let g=Hc.length,y=s(c,l);Bc=void 0;let b=Hc.length>g?Hc.pop():void 0;if(y instanceof Promise)return y.then((w)=>{if(b)b.issues=w.issues.length?_f(w.issues):$_;return w});if(b)b.issues=y.issues.length?_f(y.issues):$_;return y};if(e._zod.parse=a,e._zod.run===s)e._zod.run=a})}};function $f(){return UD}function FD(e,t){let n=e[kf]?.backEdges;return n!==void 0&&R_(t)&&n.has(t)}var WD=()=>{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(i){return e[i]??null}let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};function o(i,s){if(i==="number"&&typeof s==="number"&&!Number.isFinite(s))return String(s);return r[i]??i}return(i)=>{switch(i.code){case"invalid_type":{let s=o(i.expected),a=KS(i.input),c=o(a,i.input);return`Invalid input: expected ${s}, received ${c}`}case"invalid_value":if(i.values.length===1)return`Invalid input: expected ${Yp(i.values[0])}`;return`Invalid option: expected one of ${Hp(i.values,"|")}`;case"too_big":{let s=i.exact?"exactly ":i.inclusive?"<=":"<",a=t(i.origin);if(a)return`Too big: expected ${i.origin??"value"} to have ${s}${i.maximum.toString()} ${a.unit??"elements"}`;return`Too big: expected ${i.origin??"value"} to be ${s}${i.maximum.toString()}`}case"too_small":{let s=i.exact?"exactly ":i.inclusive?">=":">",a=t(i.origin);if(a)return`Too small: expected ${i.origin} to have ${s}${i.minimum.toString()} ${a.unit}`;return`Too small: expected ${i.origin} to be ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;if(s.format==="starts_with")return`Invalid string: must start with "${s.prefix}"`;if(s.format==="ends_with")return`Invalid string: must end with "${s.suffix}"`;if(s.format==="includes")return`Invalid string: must include "${s.includes}"`;if(s.format==="regex")return`Invalid string: must match pattern ${s.pattern}`;return`Invalid ${n[s.format]??i.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${i.divisor}`;case"unrecognized_keys":return`Unrecognized key${i.keys.length>1?"s":""}: ${Hp(i.keys,", ")}`;case"invalid_key":return`Invalid key in ${i.origin}`;case"invalid_union":if(i.options&&Array.isArray(i.options)&&i.options.length>0)return`Invalid discriminator value. Expected ${i.options.map((a)=>`'${a}'`).join(" | ")}`;if(i.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${i.origin}`;default:return"Invalid input"}}};function Cf(){return{localeError:WD()}}var I_;class P_{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==="object"&&"id"in n)this._idmap.set(n.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 n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function T_(){return new P_}(I_=globalThis).__zod_globalRegistry??(I_.__zod_globalRegistry=T_());var dr=globalThis.__zod_globalRegistry;function Rf(e){if(e.checks)e.checks=[...e.checks];return e}function O_(e,t){return new e(Rf({type:"string",...q(t)}))}function Ef(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...q(t)})}function A_(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...q(t)})}function If(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...q(t)})}function z_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...q(t)})}function N_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...q(t)})}function j_(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...q(t)})}function Pf(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...q(t)})}function L_(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...q(t)})}function D_(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...q(t)})}function M_(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...q(t)})}function q_(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...q(t)})}function U_(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...q(t)})}function F_(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...q(t)})}function W_(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...q(t)})}function V_(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...q(t)})}function G_(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...q(t)})}function Z_(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...q(t)})}function B_(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...q(t)})}function Tf(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...q(t)})}function H_(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...q(t)})}function K_(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...q(t)})}function J_(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...q(t)})}function Yc(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...q(t)})}function Xc(e,t){return new e({type:"string",format:"date",check:"string_format",...q(t)})}function Qc(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...q(t)})}function el(e,t){return new e({type:"string",format:"duration",check:"string_format",...q(t)})}function Y_(e,t){return new e(Rf({type:"number",checks:[],...q(t)}))}function X_(e,t){return new e(Rf({type:"number",coerce:!0,checks:[],...q(t)}))}function Q_(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...q(t)})}function ek(e,t){return new e({type:"boolean",...q(t)})}function tk(e,t){return new e({type:"bigint",...q(t)})}function nk(e,t){return new e({type:"symbol",...q(t)})}function rk(e,t){return new e({type:"undefined",...q(t)})}function ok(e,t){return new e({type:"null",...q(t)})}function ik(e){return new e({type:"any"})}function sk(e){return new e({type:"unknown"})}function ak(e,t){return new e({type:"never",...q(t)})}function ck(e,t){return new e({type:"date",...q(t)})}function lk(e,t){return new e({type:"nan",...q(t)})}function Uo(e,t){return new df({check:"less_than",...q(t),value:e,inclusive:!1})}function Gn(e,t){return new df({check:"less_than",...q(t),value:e,inclusive:!0})}function Fo(e,t){return new pf({check:"greater_than",...q(t),value:e,inclusive:!1})}function Zn(e,t){return new pf({check:"greater_than",...q(t),value:e,inclusive:!0})}function $s(e,t){return new Vx({check:"multiple_of",...q(t),value:e})}function tl(e,t){return new Zx({check:"max_length",...q(t),maximum:e})}function Wo(e,t){return new Bx({check:"min_length",...q(t),minimum:e})}function nl(e,t){return new Hx({check:"length_equals",...q(t),length:e})}function Of(e,t){return new Kx({check:"string_format",format:"regex",...q(t),pattern:e})}function Af(e){return new Jx({check:"string_format",format:"lowercase",...q(e)})}function zf(e){return new Yx({check:"string_format",format:"uppercase",...q(e)})}function Nf(e,t){return new Xx({check:"string_format",format:"includes",...q(t),includes:e})}function jf(e,t){return new Qx({check:"string_format",format:"starts_with",...q(t),prefix:e})}function Lf(e,t){return new ev({check:"string_format",format:"ends_with",...q(t),suffix:e})}function Df(e,t){return new tv({check:"properties",shape:e,...q(t)})}function pr(e){return new nv({check:"overwrite",tx:e})}function Mf(e){return pr((t)=>t.normalize(e))}function qf(){return pr((e)=>e.trim())}function Uf(){return pr((e)=>e.toLowerCase())}function Ff(){return pr((e)=>e.toUpperCase())}function Wf(){return pr((e)=>US(e))}function uk(e,t,n){return new e({type:"array",element:t,...q(n)})}function dk(e,t,n){let r=q(n);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}function pk(e,t,n){return new e({type:"custom",check:"custom",fn:t,...q(n)})}function fk(e,t){let n=VD((r)=>(r.addIssue=(o)=>{if(typeof o==="string")r.issues.push(so(o,r.value,n._zod.def));else{let i=o;if(i.fatal)i.continue=!1;if(i.code??(i.code="custom"),!("input"in i))i.input=r.value;i.inst??(i.inst=n),i.continue??(i.continue=!n._zod.def.abort),r.issues.push(so(i))}},e(r.value,r)),t);return n}function VD(e,t){let n=new He({check:"custom",...q(t)});return n._zod.check=e,n}function Cs(e,...t){for(let n of t)for(let r of Reflect.ownKeys(n))if(Object.prototype.propertyIsEnumerable.call(n,r))It(e,r,n[r]);return e}function Es(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??dr,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 Ke(e,t,n,r,o){let i=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:r.path,message:o}):t.unrepresentable;if(i==="any")return!1;if(i===void 0||i==="throw")throw Error(o);return Object.assign(n,i),!0}function _e(e,t,n={path:[],schemaPath:[]}){var r;let o=e._zod.def,i=t.seen.get(e);if(i){if(i.count++,n.schemaPath.includes(e))i.cycle=n.path;return i.schema}let s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{let d={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,d);else{let f=s.schema,h=t.processors[o.type];if(!h)throw Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);h(e,t,f,d)}let p=e._zod.parent;if(p){if(!s.ref)s.ref=p;_e(p,t,d),t.seen.get(p).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)Cs(s.schema,c);if(t.io==="input"&&pt(e))delete s.schema.examples,delete s.schema.default;if(t.io==="input"&&"_prefault"in s.schema)(r=s.schema).default??(r.default=s.schema._prefault);return delete s.schema._prefault,t.seen.get(e).schema}function mk(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Is(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let s of e.seen.entries()){let a=e.metadataRegistry.get(s[0])?.id;if(a){let c=r.get(a);if(c&&c!==s[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(a,s[0])}}let o=(s)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let p=e.external.registry.get(s[0])?.id,f=e.external.uri??((g)=>g);if(p)return{ref:f(p)};let h=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=h,{defId:h,ref:`${f("__shared")}#/${a}/${mk(h)}`}}let c="#",l=`${c}/${a}/`;if(s[1]===n&&!s[1].schema.id)return{ref:c};let d=s[1].schema.id??`__schema${e.counter++}`;return{defId:d,ref:l+mk(d)}},i=(s)=>{if(s[1].schema.$ref)return;let a=s[1],{ref:c,defId:l}=o(s);if(a.def={...a.schema},l)a.defId=l;let d=a.schema;for(let p in d)delete d[p];d.$ref=c};if(e.cycles==="throw")for(let s of e.seen.entries()){let a=s[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 s of e.seen.entries()){let a=s[1];if(t===s[0]){i(s);continue}if(e.external){let l=e.external.registry.get(s[0])?.id;if(t!==s[0]&&l){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(a.cycle){i(s);continue}if(a.count>1){if(e.reused==="ref")i(s)}}if(e.external)e.sharedDefsExtractedFor=e.external}function yk(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let r of t){if(!r||typeof r!=="object")return;yk(r);let o=Object.keys(r);if(o.length!==1||o[0]!=="type")return;let i=r.type;for(let s of Array.isArray(i)?i:[i]){if(typeof s!=="string")return;if(!n.includes(s))n.push(s)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var bk=new Set(["type","properties","required","additionalProperties"]),hk=["oneOf","anyOf"];function gk(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 Vf(e){let t=[];for(let i of e){if(typeof i!=="object"||i.type!=="object")return null;for(let s in i)if(!bk.has(s))return null;t.push(i)}let n={},r=new Set;for(let i of t){for(let s in i.properties){if(Object.prototype.hasOwnProperty.call(n,s))continue;let a=[];for(let l of t){let d=l.properties?.[s]??gk(l);if(d===null||d===void 0)continue;if(!a.some((p)=>JSON.stringify(p)===JSON.stringify(d)))a.push(d)}let c=a.length===1?a[0]:Vf(a)??{allOf:a};It(n,s,c)}for(let s of i.required??[])r.add(s)}let o={type:"object",properties:n};if(r.size)o.required=[...r];if(t.every((i)=>i.additionalProperties===!1))o.additionalProperties=!1;else{let i=[];for(let s of t){let a=gk(s);if(a&&!i.some((c)=>JSON.stringify(c)===JSON.stringify(a)))i.push(a)}if(i.length===1)o.additionalProperties=i[0];else if(i.length>1)o.additionalProperties={allOf:i}}return o}function GD(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of bk)if(o in e)return;let n=t.filter((o)=>hk.some((i)=>Array.isArray(o[i]))),r=null;if(!n.length)r=Vf(t);else{let o=n[0],i=hk.find((c)=>Array.isArray(o[c]));if(Object.keys(o).length!==1)return;let s=t.filter((c)=>c!==o),a=o[i].map((c)=>Vf([...s,c]));if(a.some((c)=>!c))return;r={[i]:a}}if(!r)return;delete e.allOf,Cs(e,r)}function Ps(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");let r=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let l=c.def??c.schema,d={...l},p=c.ref;if(c.ref=null,p){r(p);let h=e.seen.get(p),g=h.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))l.allOf=l.allOf??[],l.allOf.push(g);else Cs(l,g);if(Cs(l,d),a._zod.parent===p)for(let b in l){if(b==="$ref"||b==="allOf")continue;if(!(b in d))delete l[b]}if(g.$ref&&h.def)for(let b in l){if(b==="$ref"||b==="allOf")continue;if(b in h.def&&JSON.stringify(l[b])===JSON.stringify(h.def[b]))delete l[b]}}let f=a._zod.parent;if(f&&f!==p){r(f);let h=e.seen.get(f);if(h?.schema.$ref){if(l.$ref=h.schema.$ref,h.def)for(let g in l){if(g==="$ref"||g==="allOf")continue;if(g in h.def&&JSON.stringify(l[g])===JSON.stringify(h.def[g]))delete l[g]}}}e.override({zodSchema:a,jsonSchema:l,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())r(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())yk(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 l of[c.schema,c.def]){let d=l?.allOf;if(!Array.isArray(d))continue;let p=a.get(d);if(p)p.push(l);else a.set(d,[l])}for(let c of e.intersections)for(let l of a.get(c)??[])GD(l)}}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)}Cs(o,n.defId?n.schema:n.def??n.schema);let i=e.metadataRegistry.get(t)?.id;if(i!==void 0&&o.id===i)delete o.id;let s=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;It(s,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(s).length>0)if(e.target==="draft-2020-12")o.$defs=s;else o.definitions=s;try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Rs(t,"input",e.processors),output:Rs(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function pt(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return pt(r.element,n);if(r.type==="set")return pt(r.valueType,n);if(r.type==="lazy")return pt(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault"||r.type==="catch")return pt(r.innerType,n);if(r.type==="intersection")return pt(r.left,n)||pt(r.right,n);if(r.type==="record"||r.type==="map")return pt(r.keyType,n)||pt(r.valueType,n);if(r.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return pt(r.in,n)||pt(r.out,n)}if(r.type==="object"){for(let o in r.shape)if(pt(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(let o of r.options)if(pt(o,n))return!0;return!1}if(r.type==="tuple"){for(let o of r.items)if(pt(o,n))return!0;if(r.rest&&pt(r.rest,n))return!0;return!1}return!1}var wk=(e,t={})=>(n)=>{let r=Es({...n,processors:t});return _e(e,r),Is(r,e),Ps(r,e)},Rs=(e,t,n={})=>(r)=>{let{libraryOptions:o,target:i}=r??{},s=Es({...o??{},target:i,io:t,processors:n});return _e(e,s),Is(s,e),Ps(s,e)};var Vo=(e,t,n)=>{if(e[t]===void 0||n>e[t])e[t]=n},Go=(e,t,n)=>{if(e[t]===void 0||n<e[t])e[t]=n},Sk=(e,t)=>{Vo(e,"minimum",t),Go(e,"maximum",t)},$k=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},Ck=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Rk=(e,t)=>{e.mime=e.mime?e.mime.filter((n)=>t.includes(n)):[...t]},Ek=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},xk=(e,t)=>Vo(e,"minimum",t.minimum),vk=(e,t)=>Go(e,"maximum",t.maximum),_k=(e)=>(t,n)=>{Ek(t,n.format);let[r,o]=e[n.format];Vo(t,"minimum",r),Go(t,"maximum",o)},ZD={greater_than:(e,t)=>Vo(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Go(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>$k(e,t.value),number_format:_k(Rc),bigint_format:_k(Xp),min_length:xk,max_length:vk,length_equals:(e,t)=>Sk(e,t.length),min_size:xk,max_size:vk,size_equals:(e,t)=>Sk(e,t.size),string_format:(e,t)=>{if(Ek(e,t.format),t.pattern)Ck(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)=>Rk(e,t.mime)};function We(e){let t={},n=e._zod.def,r=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let i of r)ZD[i._zod.def.check]?.(t,i._zod.def);let o=e._zod.bag;if(o.minimum!==void 0)Vo(t,"minimum",o.minimum);if(o.exclusiveMinimum!==void 0)Vo(t,"exclusiveMinimum",o.exclusiveMinimum);if(o.maximum!==void 0)Go(t,"maximum",o.maximum);if(o.exclusiveMaximum!==void 0)Go(t,"exclusiveMaximum",o.exclusiveMaximum);if(o.multipleOf!==void 0)$k(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)Rk(t,o.mime);for(let i of o.patterns??[])Ck(t,i);return t}var BD={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},HD=new Map([[yf,Rx],[Zc,Ex]]),Ik=(e)=>HD.get(e)??e,Bf=(e,t,n,r)=>{let o=n;o.type="string";let{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:l,laxFormat:d}=We(e);if(typeof i==="number")o.minLength=i;if(typeof s==="number")o.maxLength=s;if(a){if(o.format=BD[a]??a,o.format==="")delete o.format;if(a==="time"||d)delete o.format}if(l)o.contentEncoding=l;if(c&&c.size>0){let p=[...c].map(Ik);if(p.length===1)o.pattern=p[0].source;else if(p.length>1)o.allOf=[...p.map((f)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))]}},Hf=(e,t,n,r)=>{let o=n,{minimum:i,maximum:s,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:l,isInt:d}=We(e);o.type=d?"integer":"number";let p=typeof l==="number"&&l>=(i??Number.NEGATIVE_INFINITY),f=typeof c==="number"&&c<=(s??Number.POSITIVE_INFINITY),h=t.target==="draft-04"||t.target==="openapi-3.0";if(p)if(h)o.minimum=l,o.exclusiveMinimum=!0;else o.exclusiveMinimum=l;else if(typeof i==="number")o.minimum=i;if(f)if(h)o.maximum=c,o.exclusiveMaximum=!0;else o.exclusiveMaximum=c;else if(typeof s==="number")o.maximum=s;if(a){let g=new Set;for(let w of a)if(Number.isFinite(w)&&w!==0)g.add(Math.abs(w));else Ke(e,t,o,r,`A multipleOf divisor of ${w} cannot be represented in JSON Schema`);let[y,...b]=g;if(y!==void 0)o.multipleOf=y;if(b.length)o.allOf=[...o.allOf??[],...b.map((w)=>({multipleOf:w}))]}},Kf=(e,t,n,r)=>{n.type="boolean"},Jf=(e,t,n,r)=>{Ke(e,t,n,r,"BigInt cannot be represented in JSON Schema")},Yf=(e,t,n,r)=>{Ke(e,t,n,r,"Symbols cannot be represented in JSON Schema")},Xf=(e,t,n,r)=>{if(t.target==="openapi-3.0")n.type="string",n.nullable=!0,n.enum=[null];else n.type="null"},Qf=(e,t,n,r)=>{Ke(e,t,n,r,"Undefined cannot be represented in JSON Schema")},Pk=(e,t,n,r)=>{Ke(e,t,n,r,"Void cannot be represented in JSON Schema")},em=(e,t,n,r)=>{n.not={}},tm=(e,t,n,r)=>{},nm=(e,t,n,r)=>{},rm=(e,t,n,r)=>{Ke(e,t,n,r,"Date cannot be represented in JSON Schema")},om=(e,t,n,r)=>{let o=e._zod.def,i=fs(o.entries);if(i.length===0){n.not={};return}if(i.every((s)=>typeof s==="number"))n.type="number";if(i.every((s)=>typeof s==="string"))n.type="string";n.enum=i},im=(e,t,n,r)=>{let o=e._zod.def;if(o.values.length===0){n.not={};return}let i=[];for(let s of o.values)if(s===void 0){if(Ke(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof s==="bigint"){if(Ke(e,t,n,r,"BigInt literals cannot be represented in JSON Schema"))return;i.push(Number(s))}else i.push(s);if(i.length===0);else if(i.length===1){let s=i[0];if(n.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0")n.enum=[s];else n.const=s}else{if(i.every((s)=>typeof s==="number"))n.type="number";if(i.every((s)=>typeof s==="string"))n.type="string";if(i.every((s)=>typeof s==="boolean"))n.type="boolean";if(i.every((s)=>s===null))n.type="null";n.enum=i}},sm=(e,t,n,r)=>{Ke(e,t,n,r,"NaN cannot be represented in JSON Schema")},am=(e,t,n,r)=>{let o=n,i=e._zod.pattern;if(!i)throw Error("Pattern not found in template literal");o.type="string",o.pattern=i.source},Tk=(e,t,n,r)=>{let o=n;o.type="string",o.format="binary",o.contentEncoding="binary";let{minimum:i,maximum:s,mime:a}=We(e);if(i!==void 0)o.minLength=i;if(s!==void 0)o.maxLength=s;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}))},Ok=(e,t,n,r)=>{n.type="boolean"},cm=(e,t,n,r)=>{Ke(e,t,n,r,"Custom types cannot be represented in JSON Schema")},lm=(e,t,n,r)=>{Ke(e,t,n,r,"Function types cannot be represented in JSON Schema")},um=(e,t,n,r)=>{Ke(e,t,n,r,"Transforms cannot be represented in JSON Schema")},Ak=(e,t,n,r)=>{Ke(e,t,n,r,"Map cannot be represented in JSON Schema")},zk=(e,t,n,r)=>{Ke(e,t,n,r,"Set cannot be represented in JSON Schema")},dm=(e,t,n,r)=>{let o=n,i=e._zod.def,{minimum:s,maximum:a}=We(e);if(typeof s==="number")o.minItems=s;if(typeof a==="number")o.maxItems=a;o.type="array",o.items=_e(i.element,t,{...r,path:[...r.path,"items"]})};function Ts(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return Ts(t.out);if(t.type==="catch")return Ts(t.innerType);return e._zod.optin}var pm=(e,t,n,r)=>{let o=n,i=e._zod.def,s=i.shape;if(Object.getOwnPropertySymbols(s).length&&Ke(e,t,o,r,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let l in s)It(o.properties,l,_e(s[l],t,{...r,path:[...r.path,"properties",l]}));let c=[];for(let l of Object.keys(s)){let d=i.shape[l];if(t.io==="input"?Ts(d)===void 0:d._zod.optout===void 0)c.push(l)}if(c.length>0)o.required=c;if(i.catchall?._zod.def.type==="never")o.additionalProperties=!1;else if(!i.catchall){if(t.io==="output")o.additionalProperties=!1}else if(i.catchall)o.additionalProperties=_e(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})},fm=(e,t,n,r)=>{let o=e._zod.def,i=o.inclusive===!1,s=o.options.map((a,c)=>_e(a,t,{...r,path:[...r.path,i?"oneOf":"anyOf",c]}));if(i)n.oneOf=s;else n.anyOf=s},mm=(e,t,n,r)=>{let o=e._zod.def,i=_e(o.left,t,{...r,path:[...r.path,"allOf",0]}),s=_e(o.right,t,{...r,path:[...r.path,"allOf",1]}),a=(l)=>("allOf"in l)&&Object.keys(l).length===1,c=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];n.allOf=c,t.intersections.push(c)},hm=(e,t,n,r)=>{let o=n,i=e._zod.def;o.type="array";let s=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",c=i.items.map((y,b)=>_e(y,t,{...r,path:[...r.path,s,b]})),l=i.rest?_e(i.rest,t,{...r,path:[...r.path,a,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null,d=i.items.length;while(d>0){let y=i.items[d-1];if(!(t.io==="input"?Ts(y)!==void 0:y._zod.optout==="optional"))break;d--}let p=i.items.length,f=!i.rest;if(t.target==="draft-2020-12"){if(o.prefixItems=c,f)o.items=!1;else if(l)o.items=l;if(d>0)o.minItems=d;if(f)o.maxItems=p}else if(t.target==="openapi-3.0"){if(o.items={anyOf:c},l)o.items.anyOf.push(l);if(d>0)o.minItems=d;if(f)o.maxItems=p}else{if(o.items=c,f)o.additionalItems=!1;else if(l)o.additionalItems=l;if(d>0)o.minItems=d;if(f)o.maxItems=p}let{minimum:h,maximum:g}=We(e);if(typeof h==="number")o.minItems=h;if(typeof g==="number")o.maxItems=g};function Gf(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let g=e.get(t)?.def;if(!g)return t;let y=Gf(e,g,n);return y===g?t:y}for(let g of["anyOf","oneOf"]){let y=t[g];if(!Array.isArray(y))continue;let b=y.map((w)=>Gf(e,w,n));if(b.some((w,R)=>w!==y[R]))t={...t,[g]:b}}let r=Array.isArray(t.type)?t.type:[t.type],o=!r.includes("string")&&r.some((g)=>g==="number"||g==="integer"),i=t.enum??(t.const!==void 0?[t.const]:void 0);if(!o&&!i?.some((g)=>typeof g==="number"))return t;let{minimum:s,maximum:a,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:d,format:p,id:f,...h}=t;if(h.enum)h.enum=h.enum.map((g)=>typeof g==="number"?String(g):g);else if(typeof h.const==="number")h.const=String(h.const);if(!o)return h;if(h.type="string",!i)h.pattern=(r.includes("number")?Mo:qc).source;return h}var Zf=new WeakMap;function KD(e){let t=new Map;for(let r of e.seen.values())if(r.def&&!t.has(r.schema))t.set(r.schema,r);let n=new Map;for(let r of Zf.get(e)??[]){let o=e.seen.get(r),i=(o?.def??o?.schema)?.propertyNames;if(!i||i===!0||n.has(i))continue;let s=Gf(t,i,new Set);if(s!==i)n.set(i,s)}if(!n.size)return;for(let r of e.seen.values())for(let o of[r.schema,r.def]){let i=o&&n.get(o.propertyNames);if(i)o.propertyNames=i}}var gm=(e,t,n,r)=>{let o=n,i=e._zod.def;o.type="object";let s=i.keyType,a=We(s).patterns;if(i.mode==="loose"&&a&&a.size>0){let d=_e(i.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(let p of a)It(o.patternProperties,Ik(p).source,d)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=_e(i.keyType,t,{...r,path:[...r.path,"propertyNames"]});let d=Zf.get(t);if(!d)d=[],Zf.set(t,d),t.deferred.push(()=>KD(t));d.push(e)}o.additionalProperties=_e(i.valueType,t,{...r,path:[...r.path,"additionalProperties"]})}let c=s._zod.values,l=t.io==="input"&&Ts(i.valueType)!==void 0;if(c&&!i.partial&&!l){let d=[...c].filter((p)=>typeof p==="string"||typeof p==="number");if(d.length>0)o.required=d.map(String)}},ym=(e,t,n,r)=>{let o=e._zod.def,i=_e(o.innerType,t,r),s=t.seen.get(e);if(t.target==="openapi-3.0")s.ref=o.innerType,n.nullable=!0;else n.anyOf=[i,{type:"null"}]},bm=(e,t,n,r)=>{let o=e._zod.def;_e(o.innerType,t,r);let i=t.seen.get(e);i.ref=o.innerType},wm=Symbol();function Nk(e,t,n,r,o){let i=!1,s=JSON.stringify(e,(a,c)=>{if(typeof c!=="bigint")return c;return i=!0,null});if(!i)return JSON.parse(s);return Ke(t,n,r,o,"BigInt defaults cannot be represented in JSON Schema"),wm}var Sm=(e,t,n,r)=>{let o=e._zod.def;_e(o.innerType,t,r);let i=t.seen.get(e);i.ref=o.innerType;let s=Nk(o.defaultValue,e,t,n,r);if(s!==wm)n.default=s},xm=(e,t,n,r)=>{let o=e._zod.def;_e(o.innerType,t,r);let i=t.seen.get(e);if(i.ref=o.innerType,t.io!=="input")return;let s=Nk(o.defaultValue,e,t,n,r);if(s!==wm)n._prefault=s},vm=(e,t,n,r)=>{let o=e._zod.def;_e(o.innerType,t,r);let i=t.seen.get(e);i.ref=o.innerType;let s;try{s=o.catchValue(void 0)}catch{Ke(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=s},_m=(e,t,n,r)=>{let o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?i?o.out:o.in:o.out;_e(s,t,r);let a=t.seen.get(e);a.ref=s},km=(e,t,n,r)=>{let o=e._zod.def;_e(o.innerType,t,r);let i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},jk=(e,t,n,r)=>{let o=e._zod.def;_e(o.innerType,t,r);let i=t.seen.get(e);i.ref=o.innerType},rl=(e,t,n,r)=>{let o=e._zod.def;_e(o.innerType,t,r);let i=t.seen.get(e);i.ref=o.innerType},$m=(e,t,n,r)=>{let o=e._zod.innerType;_e(o,t,r);let i=t.seen.get(e);i.ref=o},kk={string:Bf,number:Hf,boolean:Kf,bigint:Jf,symbol:Yf,null:Xf,undefined:Qf,void:Pk,never:em,any:tm,unknown:nm,date:rm,enum:om,literal:im,nan:sm,template_literal:am,file:Tk,success:Ok,custom:cm,function:lm,transform:um,map:Ak,set:zk,array:dm,object:pm,union:fm,intersection:mm,tuple:hm,record:gm,nullable:ym,nonoptional:bm,default:Sm,prefault:xm,catch:vm,pipe:_m,readonly:km,promise:jk,optional:rl,lazy:$m};function Lk(e,t){if("_idmap"in e){let r=e,o=Es({...t,processors:kk}),i={};for(let c of r._idmap.entries()){let[l,d]=c;_e(d,o)}let s={},a={registry:r,uri:t?.uri,defs:i};o.external=a;for(let c of r._idmap.entries()){let[l,d]=c;Is(o,d),It(s,l,Ps(o,d))}if(Object.keys(i).length>0){let c=o.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[c]:i}}return{schemas:s}}let n=Es({...t,processors:kk});return _e(e,n),Is(n,e),Ps(n,e)}var Dk=new WeakSet([Object.prototype,Error.prototype]);function ol(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let r=n(this);return Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0})}})}var rM=(e,t)=>{nx.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);if(Dk.has(n))return;Dk.add(n),ol(n,"format",(r)=>(o)=>sf(r,o)),ol(n,"flatten",(r)=>(o)=>of(r,o)),ol(n,"addIssue",(r)=>(o)=>{r.issues.push(o),r.message=JSON.stringify(r.issues,ms,2)}),ol(n,"addIssues",(r)=>(o)=>{r.issues.push(...o),r.message=JSON.stringify(r.issues,ms,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var Tt=I("ZodError",rM,void 0,{Parent:Error});var Mk=ws(Tt),qk=Ss(Tt),Uk=xs(Tt),Fk=Lc(Tt),Wk=ox(Tt),Vk=ix(Tt),Gk=sx(Tt),Zk=ax(Tt),Bk=cx(Tt),Hk=lx(Tt),Kk=ux(Tt),Jk=dx(Tt);function iM(){if(!dt.localeError)bt(Cf())}function As(){if(!dt.memoizer)bt({memoizer:$f()})}var pe=I("ZodType",(e,t)=>(iM(),ae.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Pt(t,{checks:[...t.checks??[],...e.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return tn(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(rq(e,t))},superRefine(e,t){return this.check(oq(e,t))},overwrite(e){return this.check(pr(e))},optional(){return Ee(this)},exactOptional(){return qM(this)},nullable(){return Xk(this)},nullish(){return Ee(Xk(this))},nonoptional(e){return ZM(this,e)},array(){return S(this)},or(e){return Z([this,e])},and(e){return al(this,e)},transform(e){return Qk(this,u0(e))},default(e){return WM(this,e)},prefault(e){return GM(this,e)},catch(e){return HM(this,e)},pipe(e){return Qk(this,e)},readonly(){return XM(this)},describe(e){let t=this.clone();return dr.add(t,{description:e}),t},meta(...e){if(e.length===0)return dr.get(this);let t=this.clone();return dr.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 ys(this,"~standard",{...gf(this),jsonSchema:{input:Rs(this,"input"),output:Rs(this,"output")}})},set "~standard"(e){Wn(this,"~standard",e)},parse:function e(t,n){return Mk(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await qk(this,t,n,{callee:e})},safeParse(e,t){return Uk(this,e,t)},async safeParseAsync(e,t){return Fk(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Wn(this,"spa",e)},validate(e,t){return Dc(this,e,t)},validateAsync(e,t){return Mc(this,e,t)},encode:function e(t,n){return Wk(this,t,n,{callee:e})},decode:function e(t,n){return Vk(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Gk(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Zk(this,t,n,{callee:e})},safeEncode(e,t){return Bk(this,e,t)},safeDecode(e,t){return Hk(this,e,t)},async safeEncodeAsync(e,t){return Kk(this,e,t)},async safeDecodeAsync(e,t){return Jk(this,e,t)},toJSONSchema(e){return wk(this,{})(e)},get description(){return dr.get(this)?.description},get _def(){return this._zod.def}}),e0=I("_ZodString",(e,t)=>{Gc.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Bf(e,n,r,o)},Oc({format:(e)=>We(e).format??null,minLength:(e)=>We(e).minimum??null,maxLength:(e)=>We(e).maximum??null},{regex(...e){return this.check(Of(...e))},includes(...e){return this.check(Nf(...e))},startsWith(...e){return this.check(jf(...e))},endsWith(...e){return this.check(Lf(...e))},min(...e){return this.check(Wo(...e))},max(...e){return this.check(tl(...e))},length(...e){return this.check(nl(...e))},nonempty(...e){return this.check(Wo(1,...e))},lowercase(e){return this.check(Af(e))},uppercase(e){return this.check(zf(e))},trim(){return this.check(qf())},normalize(...e){return this.check(Mf(...e))},toLowerCase(){return this.check(Uf())},toUpperCase(){return this.check(Ff())},slugify(){return this.check(Wf())}})),t0=I("ZodString",(e,t)=>{Gc.init(e,t),e0.init(e,t)},{email(e){return this.check(Ef(n0,e))},url(e){return this.check(Pf(r0,e))},jwt(e){return this.check(J_(vM,e))},emoji(e){return this.check(L_(cM,e))},guid(e){return this.check(A_(aM,e))},uuid(e){return this.check(If(Os,e))},uuidv4(e){return this.check(z_(Os,e))},uuidv6(e){return this.check(N_(Os,e))},uuidv7(e){return this.check(j_(Os,e))},nanoid(e){return this.check(D_(lM,e))},cuid(e){return this.check(M_(uM,e))},cuid2(e){return this.check(q_(dM,e))},ulid(e){return this.check(U_(pM,e))},base64(e){return this.check(Tf(o0,e))},base64url(e){return this.check(H_(SM,e))},xid(e){return this.check(F_(fM,e))},ksuid(e){return this.check(W_(mM,e))},ipv4(e){return this.check(V_(hM,e))},ipv6(e){return this.check(G_(gM,e))},cidrv4(e){return this.check(Z_(yM,e))},cidrv6(e){return this.check(B_(bM,e))},e164(e){return this.check(K_(xM,e))},datetime(e){return this.check(Yc(zs,e))},date(e){return this.check(Xc(Ns,e))},time(e){return this.check(Qc(js,e))},duration(e){return this.check(el(Ls,e))}});function u(e){return O_(t0,e)}var Te=I("ZodStringFormat",(e,t)=>{Ce.init(e,t),e0.init(e,t)}),zs=I("ZodISODateTime",(e,t)=>{Ov.init(e,t),Te.init(e,t)}),Ns=I("ZodISODate",(e,t)=>{Av.init(e,t),Te.init(e,t)}),js=I("ZodISOTime",(e,t)=>{zv.init(e,t),Te.init(e,t)}),Ls=I("ZodISODuration",(e,t)=>{Nv.init(e,t),Te.init(e,t)}),n0=I("ZodEmail",(e,t)=>{xv.init(e,t),Te.init(e,t)});function sM(e){return Ef(n0,e)}var aM=I("ZodGUID",(e,t)=>{wv.init(e,t),Te.init(e,t)});var Os=I("ZodUUID",(e,t)=>{Sv.init(e,t),Te.init(e,t)});function tt(e){return If(Os,e)}var r0=I("ZodURL",(e,t)=>{kv.init(e,t),Te.init(e,t)});function fr(e){return Pf(r0,e)}var cM=I("ZodEmoji",(e,t)=>{$v.init(e,t),Te.init(e,t)});var lM=I("ZodNanoID",(e,t)=>{Cv.init(e,t),Te.init(e,t)});var uM=I("ZodCUID",(e,t)=>{Rv.init(e,t),Te.init(e,t)});var dM=I("ZodCUID2",(e,t)=>{Ev.init(e,t),Te.init(e,t)});var pM=I("ZodULID",(e,t)=>{Iv.init(e,t),Te.init(e,t)});var fM=I("ZodXID",(e,t)=>{Pv.init(e,t),Te.init(e,t)});var mM=I("ZodKSUID",(e,t)=>{Tv.init(e,t),Te.init(e,t)});var hM=I("ZodIPv4",(e,t)=>{jv.init(e,t),Te.init(e,t)});var gM=I("ZodIPv6",(e,t)=>{Dv.init(e,t),Te.init(e,t)});var yM=I("ZodCIDRv4",(e,t)=>{Mv.init(e,t),Te.init(e,t)});var bM=I("ZodCIDRv6",(e,t)=>{qv.init(e,t),Te.init(e,t)});var o0=I("ZodBase64",(e,t)=>{Fv.init(e,t),Te.init(e,t)});function wM(e){return Tf(o0,e)}var SM=I("ZodBase64URL",(e,t)=>{Wv.init(e,t),Te.init(e,t)});var xM=I("ZodE164",(e,t)=>{Vv.init(e,t),Te.init(e,t)});var vM=I("ZodJWT",(e,t)=>{Gv.init(e,t),Te.init(e,t)});var il=I("ZodNumber",(e,t)=>{bf.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Hf(e,n,r,o),e.isFinite=!0},Oc({minValue:(e)=>{let{minimum:t,exclusiveMinimum:n}=We(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:n}=We(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:n}=We(e);return!!t||!!n?.some(Number.isSafeInteger)},format:(e)=>We(e).format??null},{gt(e,t){return this.check(Fo(e,t))},gte(e,t){return this.check(Zn(e,t))},min(e,t){return this.check(Zn(e,t))},lt(e,t){return this.check(Uo(e,t))},lte(e,t){return this.check(Gn(e,t))},max(e,t){return this.check(Gn(e,t))},int(e){return this.check(Yk(e))},safe(e){return this.check(Yk(e))},positive(e){return this.check(Fo(0,e))},nonnegative(e){return this.check(Zn(0,e))},negative(e){return this.check(Uo(0,e))},nonpositive(e){return this.check(Gn(0,e))},multipleOf(e,t){return this.check($s(e,t))},step(e,t){return this.check($s(e,t))},finite(){return this}}));function _(e){return Y_(il,e)}var _M=I("ZodNumberFormat",(e,t)=>{Zv.init(e,t),il.init(e,t)});function Yk(e){return Q_(_M,e)}var i0=I("ZodBoolean",(e,t)=>{Bv.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Kf(e,n,r,o)});function z(e){return ek(i0,e)}var s0=I("ZodBigInt",(e,t)=>{Hv.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Jf(e,n,r,o)},Oc({minValue:(e)=>We(e).minimum??null,maxValue:(e)=>We(e).maximum??null,format:(e)=>We(e).format??null},{gte(e,t){return this.check(Zn(e,t))},min(e,t){return this.check(Zn(e,t))},gt(e,t){return this.check(Fo(e,t))},lt(e,t){return this.check(Uo(e,t))},lte(e,t){return this.check(Gn(e,t))},max(e,t){return this.check(Gn(e,t))},positive(e){return this.check(Fo(BigInt(0),e))},negative(e){return this.check(Uo(BigInt(0),e))},nonpositive(e){return this.check(Gn(BigInt(0),e))},nonnegative(e){return this.check(Zn(BigInt(0),e))},multipleOf(e,t){return this.check($s(e,t))}}));function kM(e){return tk(s0,e)}var $M=I("ZodSymbol",(e,t)=>{Kv.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Yf(e,n,r,o)});function CM(e){return nk($M,e)}var RM=I("ZodUndefined",(e,t)=>{Jv.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Qf(e,n,r,o)});function EM(e){return rk(RM,e)}var IM=I("ZodNull",(e,t)=>{Yv.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Xf(e,n,r,o)});function ao(e){return ok(IM,e)}var PM=I("ZodAny",(e,t)=>{Xv.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>tm(e,n,r,o)});function a0(){return ik(PM)}var TM=I("ZodUnknown",(e,t)=>{Qv.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>nm(e,n,r,o)});function K(){return sk(TM)}var OM=I("ZodNever",(e,t)=>{e_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>em(e,n,r,o)});function Ds(e){return ak(OM,e)}var c0=I("ZodDate",(e,t)=>{t_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>rm(e,n,r,o),e.min=(n,r)=>e.check(Zn(n,r)),e.max=(n,r)=>e.check(Gn(n,r))},Oc({minDate:(e)=>{let{minimum:t}=We(e);return t?new Date(t):null},maxDate:(e)=>{let{maximum:t}=We(e);return t?new Date(t):null}},{}));function AM(e){return ck(c0,e)}var zM=I("ZodArray",(e,t)=>{As(),n_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>dm(e,n,r,o),e.element=t.element},{min(e,t){return this.check(Wo(e,t))},nonempty(e){return this.check(Wo(1,e))},max(e,t){return this.check(tl(e,t))},length(e,t){return this.check(nl(e,t))},unwrap(){return this.element}});function S(e,t){return uk(zM,e,t)}var sl=I("ZodObject",(e,t)=>{As(),i_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>pm(e,n,r,o),uD(e,"shape",(n)=>n._zod.def.shape,!1)},{keyof(){return T(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Pt(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Pt(this._zod.def,{catchall:K()}))},loose(){return this.clone(Pt(this._zod.def,{catchall:K()}))},strict(){return this.clone(Pt(this._zod.def,{catchall:Ds()}))},strip(){return this.clone(Pt(this._zod.def,{catchall:void 0}))},extend(e){return nD(this,e)},safeExtend(e){return rD(this,e)},merge(e){return oD(this,e)},pick(e){return eD(this,e)},omit(e){return tD(this,e)},partial(...e){return BS(Im,this,e[0])},exactPartial(...e){return BS(d0,this,e[0],"exactPartial")},required(...e){return iD(p0,this,e[0])}});function m(e,t){let n={type:"object",shape:e??{},...q(t)};return new sl(n)}function J(e,t){return new sl({type:"object",shape:e,catchall:Ds(),...q(t)})}function ie(e,t){return new sl({type:"object",shape:e,catchall:K(),...q(t)})}var l0=I("ZodUnion",(e,t)=>{wf.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>fm(e,n,r,o),e.options=t.options});function Z(e,t){return new l0({type:"union",options:e,...q(t)})}var NM=I("ZodDiscriminatedUnion",(e,t)=>{l0.init(e,t),s_.init(e,t)});function ke(e,t,n){return new NM({type:"union",options:t,discriminator:e,...q(n)})}var jM=I("ZodIntersection",(e,t)=>{a_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>mm(e,n,r,o)});function al(e,t){return new jM({type:"intersection",left:e,right:t})}var LM=I("ZodTuple",(e,t)=>{As(),Sf.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>hm(e,n,r,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 Im({type:"optional",innerType:t}))})}});function cl(e,t,n){let r=t instanceof ae,o=r?n:t;return new LM({type:"tuple",items:e,rest:r?t:null,...q(o)})}var Cm=I("ZodRecord",(e,t)=>{As(),c_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>gm(e,n,r,o),e.keyType=t.keyType,e.valueType=t.valueType});function B(e,t,n){if(!t||!t._zod)return new Cm({type:"record",keyType:u(),valueType:e,...q(t)});return new Cm({type:"record",keyType:e,valueType:t,...q(n)})}function Em(e,t,n){return new Cm({type:"record",keyType:e,valueType:t,...q(n),partial:!0})}var Rm=I("ZodEnum",(e,t)=>{l_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(r,o,i)=>om(e,r,o,i),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{let i={};for(let s of r)if(n.has(s))i[s]=t.entries[s];else throw Error(`Key ${s} not found in enum`);return new Rm({...t,checks:[],...q(o),entries:i})},e.exclude=(r,o)=>{let i={...t.entries};for(let s of r)if(n.has(s))delete i[s];else throw Error(`Key ${s} not found in enum`);return new Rm({...t,checks:[],...q(o),entries:i})}});function T(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((r)=>[r,r])):e;return new Rm({type:"enum",entries:n,...q(t)})}var DM=I("ZodLiteral",(e,t)=>{u_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>im(e,n,r,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 DM({type:"literal",values:Array.isArray(e)?e:[e],...q(t)})}var MM=I("ZodTransform",(e,t)=>{As(),d_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>um(e,n,r,o),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new bs(e.constructor.name);n.addIssue=(i)=>{if(typeof i==="string")n.issues.push(so(i,n.value,t));else{let s=i;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=n.value;s.inst??(s.inst=e),n.issues.push(so(s))}};let o=t.transform(n.value,n);if(o instanceof Promise)return o.then((i)=>(n.value=i,n));return n.value=o,n}});function u0(e){return new MM({type:"transform",transform:e})}var Im=I("ZodOptional",(e,t)=>{xf.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>rl(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Ee(e){return new Im({type:"optional",innerType:e})}var d0=I("ZodExactOptional",(e,t)=>{p_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>rl(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function qM(e){return new d0({type:"optional",innerType:e})}var UM=I("ZodNullable",(e,t)=>{f_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ym(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Xk(e){return new UM({type:"nullable",innerType:e})}var FM=I("ZodDefault",(e,t)=>{m_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Sm(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function WM(e,t){return new FM({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():Jp(t)}})}var VM=I("ZodPrefault",(e,t)=>{h_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>xm(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function GM(e,t){return new VM({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():Jp(t)}})}var p0=I("ZodNonOptional",(e,t)=>{g_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>bm(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function ZM(e,t){return new p0({type:"nonoptional",innerType:e,...q(t)})}var BM=I("ZodCatch",(e,t)=>{y_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>vm(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function HM(e,t){return new BM({type:"catch",innerType:e,catchValue:typeof t==="function"?t:YS(t)})}var KM=I("ZodNaN",(e,t)=>{b_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>sm(e,n,r,o)});function Ms(e){return lk(KM,e)}var f0=I("ZodPipe",(e,t)=>{vf.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>_m(e,n,r,o),e.in=t.in,e.out=t.out});function Qk(e,t){return new f0({type:"pipe",in:e,out:t})}var JM=I("ZodPreprocess",(e,t)=>{f0.init(e,t),w_.init(e,t)}),YM=I("ZodReadonly",(e,t)=>{S_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>km(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function XM(e){return new YM({type:"readonly",innerType:e})}var QM=I("ZodTemplateLiteral",(e,t)=>{x_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>am(e,n,r,o)});function eq(e,t){return new QM({type:"template_literal",parts:e,...q(t)})}var tq=I("ZodLazy",(e,t)=>{__.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>$m(e,n,r,o),e.unwrap=()=>e._zod.def.getter()});function Pm(e){return new tq({type:"lazy",getter:e})}var nq=I("ZodFunction",(e,t)=>{v_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>lm(e,n,r,o)});function Tm(e){return new nq({type:"function",input:Array.isArray(e?.input)?cl(e?.input):e?.input??S(K()),output:e?.output??K()})}var Om=I("ZodCustom",(e,t)=>{k_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>cm(e,n,r,o)});function Le(e,t){return dk(Om,e??(()=>!0),t)}function rq(e,t={}){return pk(Om,e,t)}function oq(e,t){return fk(e,t)}var iq=I("ZodInstanceOf",(e,t)=>{Om.init(e,t)},{properties(e,t){return this.check(Df(e,t))}});function sq(e,t={}){let n=new iq({type:"custom",check:"custom",fn:(r)=>r instanceof e,abort:!0,...q(t)});return n._zod.bag.Class=e,n._zod.check=(r)=>{if(!(r.value instanceof e))r.issues.push({code:"invalid_type",expected:e.name,input:r.value,inst:n,path:[...n._zod.def.path??[]]})},n}function wt(e){let t=Pm(()=>Z([u(e),_(),z(),ao(),S(t),B(u(),t)]));return t}function ll(e,t){return new JM({type:"pipe",in:u0(e),out:t})}var h0={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 m0;(function(e){})(m0||(m0={}));function g0(e){return Yc(zs,e)}function cq(e){return Xc(Ns,e)}function lq(e){return Qc(js,e)}function uq(e){return el(Ls,e)}function dq(e){return X_(il,e)}var b0={name:"@tripwire-sh/cli",version:"0.1.16-staging.1",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:"tsrs --noEmit --checkers 4 --fast false","typecheck:ts5":"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 qs=b0.version,fq=qs.includes("-staging.")?"staging":"production";function mr(e){let t=e.TRIPWIRE_ENV||fq;if(t!=="production"&&t!=="staging")throw Error("TRIPWIRE_ENV must be production or staging");return t}var rn=mr(process.env)==="staging",Bn=rn?"npx @tripwire-sh/cli@staging":"tripwire",M=rn?"tripwire-staging":"tripwire",Bo=rn?"tripwire-staging-get-started":"tripwire-get-started",Am=rn?"tripwire-staging-workflows":"tripwire-workflows",Us="tripwire-cli",zm="https://mcp.tripwire.sh/mcp",Nm="https://app.tripwire.sh/api/auth",mq="https://tripwire-mcp-preview-tripwire.unkey.app/mcp",hq="https://staging.tripwire.sh/api/auth",w0="offline_access tripwire:read tripwire:configure tripwire:moderate tripwire:admin";function Hn(e){return(e.TRIPWIRE_MCP_URL||(mr(e)==="staging"?mq:zm)).replace(/\/+$/,"")}function Fs(e){return(e.TRIPWIRE_AUTH_URL||(mr(e)==="staging"?hq:Nm)).replace(/\/+$/,"")}var gq="urn:ietf:params:oauth:grant-type:device_code",yq=m({device_code:u(),user_code:u(),verification_uri:u(),verification_uri_complete:u().optional(),expires_in:_(),interval:_().optional()}),x0=m({access_token:u().min(1),refresh_token:u().min(1).optional(),expires_in:_().optional(),token_type:u().optional()}),Lm=m({error:u(),error_description:u().optional()});class jm extends Error{constructor(){super(`Session expired. Run ${Bn} login.`);this.name="SessionExpiredError"}}class Ws extends Error{constructor(){super("Tripwire is not reachable right now. Try again in a minute.");this.name="AuthUnreachableError"}}var v0={fetch:(e,t)=>fetch(e,t),sleep:(e)=>new Promise((t)=>setTimeout(t,e)),now:()=>Date.now()};async function ul(e,t,n){let r=await e.fetch(t,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded",accept:"application/json"},body:new URLSearchParams(n).toString()}),o=await r.text(),i={error:"invalid_response",error_description:o.slice(0,200)};try{let s=wt().safeParse(JSON.parse(o));return{status:r.status,body:s.success?s.data:i,headers:r.headers}}catch{return{status:r.status,body:i,headers:r.headers}}}function _0(e,t){let n=Lm.safeParse(e);if(!n.success)return Error(t);return Error(n.data.error_description?`${n.data.error}: ${n.data.error_description}`:n.data.error)}async function k0(e,t,n){let{status:r,body:o}=await ul(e,`${t}/device/code`,{client_id:Us,scope:w0,resource:n}),i=yq.safeParse(o);if(r>=400||!i.success)throw _0(o,`Device authorization failed (HTTP ${r})`);return i.data}function $0(e,t,n,r,o){let i=t.refresh_token??o;return{accessToken:t.access_token,refreshToken:i,expiresAt:t.expires_in?e.now()+t.expires_in*1000:void 0,mcpUrl:r,authUrl:n}}var S0=5000;function bq(e,t){let n=(e.get("retry-after")??e.get("x-retry-after"))?.trim();if(!n)return null;if(/^\d+$/.test(n))return Number(n)*1000;let r=Date.parse(n);return Number.isNaN(r)?null:Math.max(0,r-t)}async function C0(e,t,n,r){let o=(r.interval??5)*1000,i=null,s=e.now()+r.expires_in*1000;while(e.now()<s){await e.sleep(Math.min(Math.max(o,i??0),s-e.now())),i=null;let{status:a,body:c,headers:l}=await ul(e,`${t}/oauth2/token`,{grant_type:gq,device_code:r.device_code,client_id:Us,resource:n}),d=x0.safeParse(c);if(a<400&&d.success)return $0(e,d.data,t,n);if(a===429){if(i=bq(l,e.now()),i===null)o+=S0;continue}let p=Lm.safeParse(c),f=p.success?p.data.error:"";if(f==="authorization_pending")continue;if(f==="slow_down"){o+=S0;continue}if(f==="access_denied")throw Error("Sign-in was denied in the browser");if(f==="expired_token")throw Error(`The code expired. Run ${Bn} login again.`);throw _0(c,`Token request failed (HTTP ${a})`)}throw Error(`The code expired. Run ${Bn} login again.`)}async function R0(e,t){if(!t.refreshToken)throw new jm;let{status:n,body:r}=await ul(e,`${t.authUrl}/oauth2/token`,{grant_type:"refresh_token",refresh_token:t.refreshToken,client_id:Us,resource:t.mcpUrl}).catch(()=>{throw new Ws}),o=x0.safeParse(r);if(n>=400||!o.success){let i=Lm.safeParse(r);throw(n===400||n===401)&&i.success&&i.data.error!=="invalid_response"?new jm:new Ws}return $0(e,o.data,t.authUrl,t.mcpUrl,t.refreshToken)}async function E0(e,t){let n=t.refreshToken??t.accessToken;await ul(e,`${t.authUrl}/oauth2/revoke`,{token:n,client_id:Us}).catch(()=>{return})}import{stdout as Vm,stdin as G0}from"node:process";import*as gr from"node:readline";import zq from"node:readline";var I0=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return(t)=>{let n=0;e.lastIndex=0;while(e.test(t))n+=1;return t.length-n}})(),P0=(e)=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,T0=(e)=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141;var wq=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Sq=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,O0=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,xq=/\t{1,1000}/y,A0=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,vq=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,_q=/\p{M}+/gu,kq={limit:1/0,ellipsis:""},z0=(e,t={},n={})=>{let r=t.limit??1/0,o=t.ellipsis??"",i=t?.ellipsisWidth??(o?z0(o,kq,n).width:0),s=0,a=n.controlWidth??0,c=n.tabWidth??8,l=n.emojiWidth??2,d=2,p=n.regularWidth??1,f=n.wideWidth??2,h=[[vq,p],[wq,0],[Sq,a],[xq,c],[A0,l],[O0,f]],g=0,y=0,b=e.length,w=0,R=!1,k=b,O=Math.max(0,r-i),x=0,v=0,E=0,A=0;e:while(!0){if(v>x||y>=b&&y>g){let D=e.slice(x,v)||e.slice(g,y);w=0;for(let te of D.replaceAll(_q,"")){let ue=te.codePointAt(0)||0;if(P0(ue))A=2;else if(T0(ue))A=f;else A=p;if(E+A>O)k=Math.min(k,Math.max(x,g)+w);if(E+A>r){R=!0;break e}w+=te.length,E+=A}x=v=0}if(y>=b)break e;for(let D=0,te=h.length;D<te;D++){let[ue,de]=h[D];if(ue.lastIndex=y,ue.test(e)){if(w=ue===O0?I0(e.slice(y,ue.lastIndex)):ue===A0?1:ue.lastIndex-y,A=w*de,E+A>O)k=Math.min(k,y+Math.floor((O-E)/de));if(E+A>r){R=!0;break e}E+=A,x=g,v=y,y=g=ue.lastIndex;continue e}}y+=1}return{width:R?O:E,index:R?k:b,truncated:R,ellipsed:R&&r>=i}},N0=z0;var $q={limit:1/0,ellipsis:"",ellipsisWidth:0},Cq=(e,t={})=>N0(e,$q,t).width,gn=Cq;var dl="\x1B",q0="›",Rq=39,Mm="\x07",U0="[",Eq="]",F0="m",qm=`${Eq}8;;`,j0=new RegExp(`(?:\\${U0}(?<code>\\d+)m|\\${qm}(?<uri>.*)${Mm})`,"y"),L0=(e)=>{if(e>=30&&e<=37)return 39;if(e>=90&&e<=97)return 39;if(e>=40&&e<=47)return 49;if(e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0;return},D0=(e)=>`${dl}${U0}${e}${F0}`,M0=(e)=>`${dl}${qm}${e}${Mm}`,Dm=(e,t,n)=>{let r=t[Symbol.iterator](),o=!1,i=!1,s=e.at(-1),a=s===void 0?0:gn(s),c=r.next(),l=r.next(),d=0;while(!c.done){let p=c.value,f=gn(p);if(a+f<=n)e[e.length-1]+=p;else e.push(p),a=0;if(p===dl||p===q0)o=!0,i=t.startsWith(qm,d+1);if(o){if(i){if(p===Mm)o=!1,i=!1}else if(p===F0)o=!1}else if(a+=f,a===n&&!l.done)e.push(""),a=0;c=l,l=r.next(),d+=p.length}if(s=e.at(-1),!a&&s!==void 0&&s.length&&e.length>1)e[e.length-2]+=e.pop()},Iq=(e)=>{let t=e.split(" "),n=t.length;while(n){if(gn(t[n-1]))break;n--}if(n===t.length)return e;return t.slice(0,n).join(" ")+t.slice(n).join("")},Pq=(e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let r="",o,i,s=e.split(" "),a=[""],c=0;for(let p=0;p<s.length;p++){let f=s[p];if(n.trim!==!1){let g=a.at(-1)??"",y=g.trimStart();if(g.length!==y.length)a[a.length-1]=y,c=gn(y)}if(p!==0){if(c>=t&&(n.wordWrap===!1||n.trim===!1))a.push(""),c=0;if(c||n.trim===!1)a[a.length-1]+=" ",c++}let h=gn(f);if(n.hard&&h>t){let g=t-c,y=1+Math.floor((h-g-1)/t);if(Math.floor((h-1)/t)<y)a.push("");Dm(a,f,t),c=gn(a.at(-1)??"");continue}if(c+h>t&&c&&h){if(n.wordWrap===!1&&c<t){Dm(a,f,t),c=gn(a.at(-1)??"");continue}a.push(""),c=0}if(c+h>t&&n.wordWrap===!1){Dm(a,f,t),c=gn(a.at(-1)??"");continue}a[a.length-1]+=f,c+=h}if(n.trim!==!1)a=a.map((p)=>Iq(p));let l=a.join(`
228
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let s of e.seen.entries()){let a=s[1];if(t===s[0]){i(s);continue}if(e.external){let l=e.external.registry.get(s[0])?.id;if(t!==s[0]&&l){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(a.cycle){i(s);continue}if(a.count>1){if(e.reused==="ref")i(s)}}if(e.external)e.sharedDefsExtractedFor=e.external}function yk(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let r of t){if(!r||typeof r!=="object")return;yk(r);let o=Object.keys(r);if(o.length!==1||o[0]!=="type")return;let i=r.type;for(let s of Array.isArray(i)?i:[i]){if(typeof s!=="string")return;if(!n.includes(s))n.push(s)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var bk=new Set(["type","properties","required","additionalProperties"]),hk=["oneOf","anyOf"];function gk(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 Vf(e){let t=[];for(let i of e){if(typeof i!=="object"||i.type!=="object")return null;for(let s in i)if(!bk.has(s))return null;t.push(i)}let n={},r=new Set;for(let i of t){for(let s in i.properties){if(Object.prototype.hasOwnProperty.call(n,s))continue;let a=[];for(let l of t){let d=l.properties?.[s]??gk(l);if(d===null||d===void 0)continue;if(!a.some((p)=>JSON.stringify(p)===JSON.stringify(d)))a.push(d)}let c=a.length===1?a[0]:Vf(a)??{allOf:a};It(n,s,c)}for(let s of i.required??[])r.add(s)}let o={type:"object",properties:n};if(r.size)o.required=[...r];if(t.every((i)=>i.additionalProperties===!1))o.additionalProperties=!1;else{let i=[];for(let s of t){let a=gk(s);if(a&&!i.some((c)=>JSON.stringify(c)===JSON.stringify(a)))i.push(a)}if(i.length===1)o.additionalProperties=i[0];else if(i.length>1)o.additionalProperties={allOf:i}}return o}function GD(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of bk)if(o in e)return;let n=t.filter((o)=>hk.some((i)=>Array.isArray(o[i]))),r=null;if(!n.length)r=Vf(t);else{let o=n[0],i=hk.find((c)=>Array.isArray(o[c]));if(Object.keys(o).length!==1)return;let s=t.filter((c)=>c!==o),a=o[i].map((c)=>Vf([...s,c]));if(a.some((c)=>!c))return;r={[i]:a}}if(!r)return;delete e.allOf,Cs(e,r)}function Ps(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");let r=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let l=c.def??c.schema,d={...l},p=c.ref;if(c.ref=null,p){r(p);let h=e.seen.get(p),g=h.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))l.allOf=l.allOf??[],l.allOf.push(g);else Cs(l,g);if(Cs(l,d),a._zod.parent===p)for(let b in l){if(b==="$ref"||b==="allOf")continue;if(!(b in d))delete l[b]}if(g.$ref&&h.def)for(let b in l){if(b==="$ref"||b==="allOf")continue;if(b in h.def&&JSON.stringify(l[b])===JSON.stringify(h.def[b]))delete l[b]}}let f=a._zod.parent;if(f&&f!==p){r(f);let h=e.seen.get(f);if(h?.schema.$ref){if(l.$ref=h.schema.$ref,h.def)for(let g in l){if(g==="$ref"||g==="allOf")continue;if(g in h.def&&JSON.stringify(l[g])===JSON.stringify(h.def[g]))delete l[g]}}}e.override({zodSchema:a,jsonSchema:l,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())r(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())yk(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 l of[c.schema,c.def]){let d=l?.allOf;if(!Array.isArray(d))continue;let p=a.get(d);if(p)p.push(l);else a.set(d,[l])}for(let c of e.intersections)for(let l of a.get(c)??[])GD(l)}}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)}Cs(o,n.defId?n.schema:n.def??n.schema);let i=e.metadataRegistry.get(t)?.id;if(i!==void 0&&o.id===i)delete o.id;let s=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;It(s,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(s).length>0)if(e.target==="draft-2020-12")o.$defs=s;else o.definitions=s;try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Rs(t,"input",e.processors),output:Rs(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function pt(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return pt(r.element,n);if(r.type==="set")return pt(r.valueType,n);if(r.type==="lazy")return pt(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault"||r.type==="catch")return pt(r.innerType,n);if(r.type==="intersection")return pt(r.left,n)||pt(r.right,n);if(r.type==="record"||r.type==="map")return pt(r.keyType,n)||pt(r.valueType,n);if(r.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return pt(r.in,n)||pt(r.out,n)}if(r.type==="object"){for(let o in r.shape)if(pt(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(let o of r.options)if(pt(o,n))return!0;return!1}if(r.type==="tuple"){for(let o of r.items)if(pt(o,n))return!0;if(r.rest&&pt(r.rest,n))return!0;return!1}return!1}var wk=(e,t={})=>(n)=>{let r=Es({...n,processors:t});return _e(e,r),Is(r,e),Ps(r,e)},Rs=(e,t,n={})=>(r)=>{let{libraryOptions:o,target:i}=r??{},s=Es({...o??{},target:i,io:t,processors:n});return _e(e,s),Is(s,e),Ps(s,e)};var Vo=(e,t,n)=>{if(e[t]===void 0||n>e[t])e[t]=n},Go=(e,t,n)=>{if(e[t]===void 0||n<e[t])e[t]=n},Sk=(e,t)=>{Vo(e,"minimum",t),Go(e,"maximum",t)},$k=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},Ck=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Rk=(e,t)=>{e.mime=e.mime?e.mime.filter((n)=>t.includes(n)):[...t]},Ek=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},xk=(e,t)=>Vo(e,"minimum",t.minimum),vk=(e,t)=>Go(e,"maximum",t.maximum),_k=(e)=>(t,n)=>{Ek(t,n.format);let[r,o]=e[n.format];Vo(t,"minimum",r),Go(t,"maximum",o)},ZD={greater_than:(e,t)=>Vo(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Go(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>$k(e,t.value),number_format:_k(Rc),bigint_format:_k(Xp),min_length:xk,max_length:vk,length_equals:(e,t)=>Sk(e,t.length),min_size:xk,max_size:vk,size_equals:(e,t)=>Sk(e,t.size),string_format:(e,t)=>{if(Ek(e,t.format),t.pattern)Ck(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)=>Rk(e,t.mime)};function We(e){let t={},n=e._zod.def,r=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let i of r)ZD[i._zod.def.check]?.(t,i._zod.def);let o=e._zod.bag;if(o.minimum!==void 0)Vo(t,"minimum",o.minimum);if(o.exclusiveMinimum!==void 0)Vo(t,"exclusiveMinimum",o.exclusiveMinimum);if(o.maximum!==void 0)Go(t,"maximum",o.maximum);if(o.exclusiveMaximum!==void 0)Go(t,"exclusiveMaximum",o.exclusiveMaximum);if(o.multipleOf!==void 0)$k(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)Rk(t,o.mime);for(let i of o.patterns??[])Ck(t,i);return t}var BD={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},HD=new Map([[yf,Rx],[Zc,Ex]]),Ik=(e)=>HD.get(e)??e,Bf=(e,t,n,r)=>{let o=n;o.type="string";let{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:l,laxFormat:d}=We(e);if(typeof i==="number")o.minLength=i;if(typeof s==="number")o.maxLength=s;if(a){if(o.format=BD[a]??a,o.format==="")delete o.format;if(a==="time"||d)delete o.format}if(l)o.contentEncoding=l;if(c&&c.size>0){let p=[...c].map(Ik);if(p.length===1)o.pattern=p[0].source;else if(p.length>1)o.allOf=[...p.map((f)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))]}},Hf=(e,t,n,r)=>{let o=n,{minimum:i,maximum:s,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:l,isInt:d}=We(e);o.type=d?"integer":"number";let p=typeof l==="number"&&l>=(i??Number.NEGATIVE_INFINITY),f=typeof c==="number"&&c<=(s??Number.POSITIVE_INFINITY),h=t.target==="draft-04"||t.target==="openapi-3.0";if(p)if(h)o.minimum=l,o.exclusiveMinimum=!0;else o.exclusiveMinimum=l;else if(typeof i==="number")o.minimum=i;if(f)if(h)o.maximum=c,o.exclusiveMaximum=!0;else o.exclusiveMaximum=c;else if(typeof s==="number")o.maximum=s;if(a){let g=new Set;for(let w of a)if(Number.isFinite(w)&&w!==0)g.add(Math.abs(w));else Ke(e,t,o,r,`A multipleOf divisor of ${w} cannot be represented in JSON Schema`);let[y,...b]=g;if(y!==void 0)o.multipleOf=y;if(b.length)o.allOf=[...o.allOf??[],...b.map((w)=>({multipleOf:w}))]}},Kf=(e,t,n,r)=>{n.type="boolean"},Jf=(e,t,n,r)=>{Ke(e,t,n,r,"BigInt cannot be represented in JSON Schema")},Yf=(e,t,n,r)=>{Ke(e,t,n,r,"Symbols cannot be represented in JSON Schema")},Xf=(e,t,n,r)=>{if(t.target==="openapi-3.0")n.type="string",n.nullable=!0,n.enum=[null];else n.type="null"},Qf=(e,t,n,r)=>{Ke(e,t,n,r,"Undefined cannot be represented in JSON Schema")},Pk=(e,t,n,r)=>{Ke(e,t,n,r,"Void cannot be represented in JSON Schema")},em=(e,t,n,r)=>{n.not={}},tm=(e,t,n,r)=>{},nm=(e,t,n,r)=>{},rm=(e,t,n,r)=>{Ke(e,t,n,r,"Date cannot be represented in JSON Schema")},om=(e,t,n,r)=>{let o=e._zod.def,i=fs(o.entries);if(i.length===0){n.not={};return}if(i.every((s)=>typeof s==="number"))n.type="number";if(i.every((s)=>typeof s==="string"))n.type="string";n.enum=i},im=(e,t,n,r)=>{let o=e._zod.def;if(o.values.length===0){n.not={};return}let i=[];for(let s of o.values)if(s===void 0){if(Ke(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof s==="bigint"){if(Ke(e,t,n,r,"BigInt literals cannot be represented in JSON Schema"))return;i.push(Number(s))}else i.push(s);if(i.length===0);else if(i.length===1){let s=i[0];if(n.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0")n.enum=[s];else n.const=s}else{if(i.every((s)=>typeof s==="number"))n.type="number";if(i.every((s)=>typeof s==="string"))n.type="string";if(i.every((s)=>typeof s==="boolean"))n.type="boolean";if(i.every((s)=>s===null))n.type="null";n.enum=i}},sm=(e,t,n,r)=>{Ke(e,t,n,r,"NaN cannot be represented in JSON Schema")},am=(e,t,n,r)=>{let o=n,i=e._zod.pattern;if(!i)throw Error("Pattern not found in template literal");o.type="string",o.pattern=i.source},Tk=(e,t,n,r)=>{let o=n;o.type="string",o.format="binary",o.contentEncoding="binary";let{minimum:i,maximum:s,mime:a}=We(e);if(i!==void 0)o.minLength=i;if(s!==void 0)o.maxLength=s;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}))},Ok=(e,t,n,r)=>{n.type="boolean"},cm=(e,t,n,r)=>{Ke(e,t,n,r,"Custom types cannot be represented in JSON Schema")},lm=(e,t,n,r)=>{Ke(e,t,n,r,"Function types cannot be represented in JSON Schema")},um=(e,t,n,r)=>{Ke(e,t,n,r,"Transforms cannot be represented in JSON Schema")},Ak=(e,t,n,r)=>{Ke(e,t,n,r,"Map cannot be represented in JSON Schema")},zk=(e,t,n,r)=>{Ke(e,t,n,r,"Set cannot be represented in JSON Schema")},dm=(e,t,n,r)=>{let o=n,i=e._zod.def,{minimum:s,maximum:a}=We(e);if(typeof s==="number")o.minItems=s;if(typeof a==="number")o.maxItems=a;o.type="array",o.items=_e(i.element,t,{...r,path:[...r.path,"items"]})};function Ts(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return Ts(t.out);if(t.type==="catch")return Ts(t.innerType);return e._zod.optin}var pm=(e,t,n,r)=>{let o=n,i=e._zod.def,s=i.shape;if(Object.getOwnPropertySymbols(s).length&&Ke(e,t,o,r,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let l in s)It(o.properties,l,_e(s[l],t,{...r,path:[...r.path,"properties",l]}));let c=[];for(let l of Object.keys(s)){let d=i.shape[l];if(t.io==="input"?Ts(d)===void 0:d._zod.optout===void 0)c.push(l)}if(c.length>0)o.required=c;if(i.catchall?._zod.def.type==="never")o.additionalProperties=!1;else if(!i.catchall){if(t.io==="output")o.additionalProperties=!1}else if(i.catchall)o.additionalProperties=_e(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})},fm=(e,t,n,r)=>{let o=e._zod.def,i=o.inclusive===!1,s=o.options.map((a,c)=>_e(a,t,{...r,path:[...r.path,i?"oneOf":"anyOf",c]}));if(i)n.oneOf=s;else n.anyOf=s},mm=(e,t,n,r)=>{let o=e._zod.def,i=_e(o.left,t,{...r,path:[...r.path,"allOf",0]}),s=_e(o.right,t,{...r,path:[...r.path,"allOf",1]}),a=(l)=>("allOf"in l)&&Object.keys(l).length===1,c=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];n.allOf=c,t.intersections.push(c)},hm=(e,t,n,r)=>{let o=n,i=e._zod.def;o.type="array";let s=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",c=i.items.map((y,b)=>_e(y,t,{...r,path:[...r.path,s,b]})),l=i.rest?_e(i.rest,t,{...r,path:[...r.path,a,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null,d=i.items.length;while(d>0){let y=i.items[d-1];if(!(t.io==="input"?Ts(y)!==void 0:y._zod.optout==="optional"))break;d--}let p=i.items.length,f=!i.rest;if(t.target==="draft-2020-12"){if(o.prefixItems=c,f)o.items=!1;else if(l)o.items=l;if(d>0)o.minItems=d;if(f)o.maxItems=p}else if(t.target==="openapi-3.0"){if(o.items={anyOf:c},l)o.items.anyOf.push(l);if(d>0)o.minItems=d;if(f)o.maxItems=p}else{if(o.items=c,f)o.additionalItems=!1;else if(l)o.additionalItems=l;if(d>0)o.minItems=d;if(f)o.maxItems=p}let{minimum:h,maximum:g}=We(e);if(typeof h==="number")o.minItems=h;if(typeof g==="number")o.maxItems=g};function Gf(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let g=e.get(t)?.def;if(!g)return t;let y=Gf(e,g,n);return y===g?t:y}for(let g of["anyOf","oneOf"]){let y=t[g];if(!Array.isArray(y))continue;let b=y.map((w)=>Gf(e,w,n));if(b.some((w,R)=>w!==y[R]))t={...t,[g]:b}}let r=Array.isArray(t.type)?t.type:[t.type],o=!r.includes("string")&&r.some((g)=>g==="number"||g==="integer"),i=t.enum??(t.const!==void 0?[t.const]:void 0);if(!o&&!i?.some((g)=>typeof g==="number"))return t;let{minimum:s,maximum:a,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:d,format:p,id:f,...h}=t;if(h.enum)h.enum=h.enum.map((g)=>typeof g==="number"?String(g):g);else if(typeof h.const==="number")h.const=String(h.const);if(!o)return h;if(h.type="string",!i)h.pattern=(r.includes("number")?Mo:qc).source;return h}var Zf=new WeakMap;function KD(e){let t=new Map;for(let r of e.seen.values())if(r.def&&!t.has(r.schema))t.set(r.schema,r);let n=new Map;for(let r of Zf.get(e)??[]){let o=e.seen.get(r),i=(o?.def??o?.schema)?.propertyNames;if(!i||i===!0||n.has(i))continue;let s=Gf(t,i,new Set);if(s!==i)n.set(i,s)}if(!n.size)return;for(let r of e.seen.values())for(let o of[r.schema,r.def]){let i=o&&n.get(o.propertyNames);if(i)o.propertyNames=i}}var gm=(e,t,n,r)=>{let o=n,i=e._zod.def;o.type="object";let s=i.keyType,a=We(s).patterns;if(i.mode==="loose"&&a&&a.size>0){let d=_e(i.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(let p of a)It(o.patternProperties,Ik(p).source,d)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=_e(i.keyType,t,{...r,path:[...r.path,"propertyNames"]});let d=Zf.get(t);if(!d)d=[],Zf.set(t,d),t.deferred.push(()=>KD(t));d.push(e)}o.additionalProperties=_e(i.valueType,t,{...r,path:[...r.path,"additionalProperties"]})}let c=s._zod.values,l=t.io==="input"&&Ts(i.valueType)!==void 0;if(c&&!i.partial&&!l){let d=[...c].filter((p)=>typeof p==="string"||typeof p==="number");if(d.length>0)o.required=d.map(String)}},ym=(e,t,n,r)=>{let o=e._zod.def,i=_e(o.innerType,t,r),s=t.seen.get(e);if(t.target==="openapi-3.0")s.ref=o.innerType,n.nullable=!0;else n.anyOf=[i,{type:"null"}]},bm=(e,t,n,r)=>{let o=e._zod.def;_e(o.innerType,t,r);let i=t.seen.get(e);i.ref=o.innerType},wm=Symbol();function Nk(e,t,n,r,o){let i=!1,s=JSON.stringify(e,(a,c)=>{if(typeof c!=="bigint")return c;return i=!0,null});if(!i)return JSON.parse(s);return Ke(t,n,r,o,"BigInt defaults cannot be represented in JSON Schema"),wm}var Sm=(e,t,n,r)=>{let o=e._zod.def;_e(o.innerType,t,r);let i=t.seen.get(e);i.ref=o.innerType;let s=Nk(o.defaultValue,e,t,n,r);if(s!==wm)n.default=s},xm=(e,t,n,r)=>{let o=e._zod.def;_e(o.innerType,t,r);let i=t.seen.get(e);if(i.ref=o.innerType,t.io!=="input")return;let s=Nk(o.defaultValue,e,t,n,r);if(s!==wm)n._prefault=s},vm=(e,t,n,r)=>{let o=e._zod.def;_e(o.innerType,t,r);let i=t.seen.get(e);i.ref=o.innerType;let s;try{s=o.catchValue(void 0)}catch{Ke(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=s},_m=(e,t,n,r)=>{let o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?i?o.out:o.in:o.out;_e(s,t,r);let a=t.seen.get(e);a.ref=s},km=(e,t,n,r)=>{let o=e._zod.def;_e(o.innerType,t,r);let i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},jk=(e,t,n,r)=>{let o=e._zod.def;_e(o.innerType,t,r);let i=t.seen.get(e);i.ref=o.innerType},rl=(e,t,n,r)=>{let o=e._zod.def;_e(o.innerType,t,r);let i=t.seen.get(e);i.ref=o.innerType},$m=(e,t,n,r)=>{let o=e._zod.innerType;_e(o,t,r);let i=t.seen.get(e);i.ref=o},kk={string:Bf,number:Hf,boolean:Kf,bigint:Jf,symbol:Yf,null:Xf,undefined:Qf,void:Pk,never:em,any:tm,unknown:nm,date:rm,enum:om,literal:im,nan:sm,template_literal:am,file:Tk,success:Ok,custom:cm,function:lm,transform:um,map:Ak,set:zk,array:dm,object:pm,union:fm,intersection:mm,tuple:hm,record:gm,nullable:ym,nonoptional:bm,default:Sm,prefault:xm,catch:vm,pipe:_m,readonly:km,promise:jk,optional:rl,lazy:$m};function Lk(e,t){if("_idmap"in e){let r=e,o=Es({...t,processors:kk}),i={};for(let c of r._idmap.entries()){let[l,d]=c;_e(d,o)}let s={},a={registry:r,uri:t?.uri,defs:i};o.external=a;for(let c of r._idmap.entries()){let[l,d]=c;Is(o,d),It(s,l,Ps(o,d))}if(Object.keys(i).length>0){let c=o.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[c]:i}}return{schemas:s}}let n=Es({...t,processors:kk});return _e(e,n),Is(n,e),Ps(n,e)}var Dk=new WeakSet([Object.prototype,Error.prototype]);function ol(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let r=n(this);return Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0})}})}var rM=(e,t)=>{nx.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);if(Dk.has(n))return;Dk.add(n),ol(n,"format",(r)=>(o)=>sf(r,o)),ol(n,"flatten",(r)=>(o)=>of(r,o)),ol(n,"addIssue",(r)=>(o)=>{r.issues.push(o),r.message=JSON.stringify(r.issues,ms,2)}),ol(n,"addIssues",(r)=>(o)=>{r.issues.push(...o),r.message=JSON.stringify(r.issues,ms,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var Tt=I("ZodError",rM,void 0,{Parent:Error});var Mk=ws(Tt),qk=Ss(Tt),Uk=xs(Tt),Fk=Lc(Tt),Wk=ox(Tt),Vk=ix(Tt),Gk=sx(Tt),Zk=ax(Tt),Bk=cx(Tt),Hk=lx(Tt),Kk=ux(Tt),Jk=dx(Tt);function iM(){if(!dt.localeError)bt(Cf())}function As(){if(!dt.memoizer)bt({memoizer:$f()})}var pe=I("ZodType",(e,t)=>(iM(),ae.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Pt(t,{checks:[...t.checks??[],...e.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return tn(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(rq(e,t))},superRefine(e,t){return this.check(oq(e,t))},overwrite(e){return this.check(pr(e))},optional(){return Ee(this)},exactOptional(){return qM(this)},nullable(){return Xk(this)},nullish(){return Ee(Xk(this))},nonoptional(e){return ZM(this,e)},array(){return S(this)},or(e){return Z([this,e])},and(e){return al(this,e)},transform(e){return Qk(this,u0(e))},default(e){return WM(this,e)},prefault(e){return GM(this,e)},catch(e){return HM(this,e)},pipe(e){return Qk(this,e)},readonly(){return XM(this)},describe(e){let t=this.clone();return dr.add(t,{description:e}),t},meta(...e){if(e.length===0)return dr.get(this);let t=this.clone();return dr.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 ys(this,"~standard",{...gf(this),jsonSchema:{input:Rs(this,"input"),output:Rs(this,"output")}})},set "~standard"(e){Wn(this,"~standard",e)},parse:function e(t,n){return Mk(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await qk(this,t,n,{callee:e})},safeParse(e,t){return Uk(this,e,t)},async safeParseAsync(e,t){return Fk(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Wn(this,"spa",e)},validate(e,t){return Dc(this,e,t)},validateAsync(e,t){return Mc(this,e,t)},encode:function e(t,n){return Wk(this,t,n,{callee:e})},decode:function e(t,n){return Vk(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Gk(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Zk(this,t,n,{callee:e})},safeEncode(e,t){return Bk(this,e,t)},safeDecode(e,t){return Hk(this,e,t)},async safeEncodeAsync(e,t){return Kk(this,e,t)},async safeDecodeAsync(e,t){return Jk(this,e,t)},toJSONSchema(e){return wk(this,{})(e)},get description(){return dr.get(this)?.description},get _def(){return this._zod.def}}),e0=I("_ZodString",(e,t)=>{Gc.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Bf(e,n,r,o)},Oc({format:(e)=>We(e).format??null,minLength:(e)=>We(e).minimum??null,maxLength:(e)=>We(e).maximum??null},{regex(...e){return this.check(Of(...e))},includes(...e){return this.check(Nf(...e))},startsWith(...e){return this.check(jf(...e))},endsWith(...e){return this.check(Lf(...e))},min(...e){return this.check(Wo(...e))},max(...e){return this.check(tl(...e))},length(...e){return this.check(nl(...e))},nonempty(...e){return this.check(Wo(1,...e))},lowercase(e){return this.check(Af(e))},uppercase(e){return this.check(zf(e))},trim(){return this.check(qf())},normalize(...e){return this.check(Mf(...e))},toLowerCase(){return this.check(Uf())},toUpperCase(){return this.check(Ff())},slugify(){return this.check(Wf())}})),t0=I("ZodString",(e,t)=>{Gc.init(e,t),e0.init(e,t)},{email(e){return this.check(Ef(n0,e))},url(e){return this.check(Pf(r0,e))},jwt(e){return this.check(J_(vM,e))},emoji(e){return this.check(L_(cM,e))},guid(e){return this.check(A_(aM,e))},uuid(e){return this.check(If(Os,e))},uuidv4(e){return this.check(z_(Os,e))},uuidv6(e){return this.check(N_(Os,e))},uuidv7(e){return this.check(j_(Os,e))},nanoid(e){return this.check(D_(lM,e))},cuid(e){return this.check(M_(uM,e))},cuid2(e){return this.check(q_(dM,e))},ulid(e){return this.check(U_(pM,e))},base64(e){return this.check(Tf(o0,e))},base64url(e){return this.check(H_(SM,e))},xid(e){return this.check(F_(fM,e))},ksuid(e){return this.check(W_(mM,e))},ipv4(e){return this.check(V_(hM,e))},ipv6(e){return this.check(G_(gM,e))},cidrv4(e){return this.check(Z_(yM,e))},cidrv6(e){return this.check(B_(bM,e))},e164(e){return this.check(K_(xM,e))},datetime(e){return this.check(Yc(zs,e))},date(e){return this.check(Xc(Ns,e))},time(e){return this.check(Qc(js,e))},duration(e){return this.check(el(Ls,e))}});function u(e){return O_(t0,e)}var Te=I("ZodStringFormat",(e,t)=>{Ce.init(e,t),e0.init(e,t)}),zs=I("ZodISODateTime",(e,t)=>{Ov.init(e,t),Te.init(e,t)}),Ns=I("ZodISODate",(e,t)=>{Av.init(e,t),Te.init(e,t)}),js=I("ZodISOTime",(e,t)=>{zv.init(e,t),Te.init(e,t)}),Ls=I("ZodISODuration",(e,t)=>{Nv.init(e,t),Te.init(e,t)}),n0=I("ZodEmail",(e,t)=>{xv.init(e,t),Te.init(e,t)});function sM(e){return Ef(n0,e)}var aM=I("ZodGUID",(e,t)=>{wv.init(e,t),Te.init(e,t)});var Os=I("ZodUUID",(e,t)=>{Sv.init(e,t),Te.init(e,t)});function tt(e){return If(Os,e)}var r0=I("ZodURL",(e,t)=>{kv.init(e,t),Te.init(e,t)});function fr(e){return Pf(r0,e)}var cM=I("ZodEmoji",(e,t)=>{$v.init(e,t),Te.init(e,t)});var lM=I("ZodNanoID",(e,t)=>{Cv.init(e,t),Te.init(e,t)});var uM=I("ZodCUID",(e,t)=>{Rv.init(e,t),Te.init(e,t)});var dM=I("ZodCUID2",(e,t)=>{Ev.init(e,t),Te.init(e,t)});var pM=I("ZodULID",(e,t)=>{Iv.init(e,t),Te.init(e,t)});var fM=I("ZodXID",(e,t)=>{Pv.init(e,t),Te.init(e,t)});var mM=I("ZodKSUID",(e,t)=>{Tv.init(e,t),Te.init(e,t)});var hM=I("ZodIPv4",(e,t)=>{jv.init(e,t),Te.init(e,t)});var gM=I("ZodIPv6",(e,t)=>{Dv.init(e,t),Te.init(e,t)});var yM=I("ZodCIDRv4",(e,t)=>{Mv.init(e,t),Te.init(e,t)});var bM=I("ZodCIDRv6",(e,t)=>{qv.init(e,t),Te.init(e,t)});var o0=I("ZodBase64",(e,t)=>{Fv.init(e,t),Te.init(e,t)});function wM(e){return Tf(o0,e)}var SM=I("ZodBase64URL",(e,t)=>{Wv.init(e,t),Te.init(e,t)});var xM=I("ZodE164",(e,t)=>{Vv.init(e,t),Te.init(e,t)});var vM=I("ZodJWT",(e,t)=>{Gv.init(e,t),Te.init(e,t)});var il=I("ZodNumber",(e,t)=>{bf.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Hf(e,n,r,o),e.isFinite=!0},Oc({minValue:(e)=>{let{minimum:t,exclusiveMinimum:n}=We(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:n}=We(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:n}=We(e);return!!t||!!n?.some(Number.isSafeInteger)},format:(e)=>We(e).format??null},{gt(e,t){return this.check(Fo(e,t))},gte(e,t){return this.check(Zn(e,t))},min(e,t){return this.check(Zn(e,t))},lt(e,t){return this.check(Uo(e,t))},lte(e,t){return this.check(Gn(e,t))},max(e,t){return this.check(Gn(e,t))},int(e){return this.check(Yk(e))},safe(e){return this.check(Yk(e))},positive(e){return this.check(Fo(0,e))},nonnegative(e){return this.check(Zn(0,e))},negative(e){return this.check(Uo(0,e))},nonpositive(e){return this.check(Gn(0,e))},multipleOf(e,t){return this.check($s(e,t))},step(e,t){return this.check($s(e,t))},finite(){return this}}));function _(e){return Y_(il,e)}var _M=I("ZodNumberFormat",(e,t)=>{Zv.init(e,t),il.init(e,t)});function Yk(e){return Q_(_M,e)}var i0=I("ZodBoolean",(e,t)=>{Bv.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Kf(e,n,r,o)});function z(e){return ek(i0,e)}var s0=I("ZodBigInt",(e,t)=>{Hv.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Jf(e,n,r,o)},Oc({minValue:(e)=>We(e).minimum??null,maxValue:(e)=>We(e).maximum??null,format:(e)=>We(e).format??null},{gte(e,t){return this.check(Zn(e,t))},min(e,t){return this.check(Zn(e,t))},gt(e,t){return this.check(Fo(e,t))},lt(e,t){return this.check(Uo(e,t))},lte(e,t){return this.check(Gn(e,t))},max(e,t){return this.check(Gn(e,t))},positive(e){return this.check(Fo(BigInt(0),e))},negative(e){return this.check(Uo(BigInt(0),e))},nonpositive(e){return this.check(Gn(BigInt(0),e))},nonnegative(e){return this.check(Zn(BigInt(0),e))},multipleOf(e,t){return this.check($s(e,t))}}));function kM(e){return tk(s0,e)}var $M=I("ZodSymbol",(e,t)=>{Kv.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Yf(e,n,r,o)});function CM(e){return nk($M,e)}var RM=I("ZodUndefined",(e,t)=>{Jv.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Qf(e,n,r,o)});function EM(e){return rk(RM,e)}var IM=I("ZodNull",(e,t)=>{Yv.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Xf(e,n,r,o)});function ao(e){return ok(IM,e)}var PM=I("ZodAny",(e,t)=>{Xv.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>tm(e,n,r,o)});function a0(){return ik(PM)}var TM=I("ZodUnknown",(e,t)=>{Qv.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>nm(e,n,r,o)});function K(){return sk(TM)}var OM=I("ZodNever",(e,t)=>{e_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>em(e,n,r,o)});function Ds(e){return ak(OM,e)}var c0=I("ZodDate",(e,t)=>{t_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>rm(e,n,r,o),e.min=(n,r)=>e.check(Zn(n,r)),e.max=(n,r)=>e.check(Gn(n,r))},Oc({minDate:(e)=>{let{minimum:t}=We(e);return t?new Date(t):null},maxDate:(e)=>{let{maximum:t}=We(e);return t?new Date(t):null}},{}));function AM(e){return ck(c0,e)}var zM=I("ZodArray",(e,t)=>{As(),n_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>dm(e,n,r,o),e.element=t.element},{min(e,t){return this.check(Wo(e,t))},nonempty(e){return this.check(Wo(1,e))},max(e,t){return this.check(tl(e,t))},length(e,t){return this.check(nl(e,t))},unwrap(){return this.element}});function S(e,t){return uk(zM,e,t)}var sl=I("ZodObject",(e,t)=>{As(),i_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>pm(e,n,r,o),uD(e,"shape",(n)=>n._zod.def.shape,!1)},{keyof(){return T(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Pt(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Pt(this._zod.def,{catchall:K()}))},loose(){return this.clone(Pt(this._zod.def,{catchall:K()}))},strict(){return this.clone(Pt(this._zod.def,{catchall:Ds()}))},strip(){return this.clone(Pt(this._zod.def,{catchall:void 0}))},extend(e){return nD(this,e)},safeExtend(e){return rD(this,e)},merge(e){return oD(this,e)},pick(e){return eD(this,e)},omit(e){return tD(this,e)},partial(...e){return BS(Im,this,e[0])},exactPartial(...e){return BS(d0,this,e[0],"exactPartial")},required(...e){return iD(p0,this,e[0])}});function m(e,t){let n={type:"object",shape:e??{},...q(t)};return new sl(n)}function J(e,t){return new sl({type:"object",shape:e,catchall:Ds(),...q(t)})}function ie(e,t){return new sl({type:"object",shape:e,catchall:K(),...q(t)})}var l0=I("ZodUnion",(e,t)=>{wf.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>fm(e,n,r,o),e.options=t.options});function Z(e,t){return new l0({type:"union",options:e,...q(t)})}var NM=I("ZodDiscriminatedUnion",(e,t)=>{l0.init(e,t),s_.init(e,t)});function ke(e,t,n){return new NM({type:"union",options:t,discriminator:e,...q(n)})}var jM=I("ZodIntersection",(e,t)=>{a_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>mm(e,n,r,o)});function al(e,t){return new jM({type:"intersection",left:e,right:t})}var LM=I("ZodTuple",(e,t)=>{As(),Sf.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>hm(e,n,r,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 Im({type:"optional",innerType:t}))})}});function cl(e,t,n){let r=t instanceof ae,o=r?n:t;return new LM({type:"tuple",items:e,rest:r?t:null,...q(o)})}var Cm=I("ZodRecord",(e,t)=>{As(),c_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>gm(e,n,r,o),e.keyType=t.keyType,e.valueType=t.valueType});function B(e,t,n){if(!t||!t._zod)return new Cm({type:"record",keyType:u(),valueType:e,...q(t)});return new Cm({type:"record",keyType:e,valueType:t,...q(n)})}function Em(e,t,n){return new Cm({type:"record",keyType:e,valueType:t,...q(n),partial:!0})}var Rm=I("ZodEnum",(e,t)=>{l_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(r,o,i)=>om(e,r,o,i),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{let i={};for(let s of r)if(n.has(s))i[s]=t.entries[s];else throw Error(`Key ${s} not found in enum`);return new Rm({...t,checks:[],...q(o),entries:i})},e.exclude=(r,o)=>{let i={...t.entries};for(let s of r)if(n.has(s))delete i[s];else throw Error(`Key ${s} not found in enum`);return new Rm({...t,checks:[],...q(o),entries:i})}});function T(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((r)=>[r,r])):e;return new Rm({type:"enum",entries:n,...q(t)})}var DM=I("ZodLiteral",(e,t)=>{u_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>im(e,n,r,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 DM({type:"literal",values:Array.isArray(e)?e:[e],...q(t)})}var MM=I("ZodTransform",(e,t)=>{As(),d_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>um(e,n,r,o),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new bs(e.constructor.name);n.addIssue=(i)=>{if(typeof i==="string")n.issues.push(so(i,n.value,t));else{let s=i;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=n.value;s.inst??(s.inst=e),n.issues.push(so(s))}};let o=t.transform(n.value,n);if(o instanceof Promise)return o.then((i)=>(n.value=i,n));return n.value=o,n}});function u0(e){return new MM({type:"transform",transform:e})}var Im=I("ZodOptional",(e,t)=>{xf.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>rl(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Ee(e){return new Im({type:"optional",innerType:e})}var d0=I("ZodExactOptional",(e,t)=>{p_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>rl(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function qM(e){return new d0({type:"optional",innerType:e})}var UM=I("ZodNullable",(e,t)=>{f_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ym(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Xk(e){return new UM({type:"nullable",innerType:e})}var FM=I("ZodDefault",(e,t)=>{m_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Sm(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function WM(e,t){return new FM({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():Jp(t)}})}var VM=I("ZodPrefault",(e,t)=>{h_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>xm(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function GM(e,t){return new VM({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():Jp(t)}})}var p0=I("ZodNonOptional",(e,t)=>{g_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>bm(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function ZM(e,t){return new p0({type:"nonoptional",innerType:e,...q(t)})}var BM=I("ZodCatch",(e,t)=>{y_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>vm(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function HM(e,t){return new BM({type:"catch",innerType:e,catchValue:typeof t==="function"?t:YS(t)})}var KM=I("ZodNaN",(e,t)=>{b_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>sm(e,n,r,o)});function Ms(e){return lk(KM,e)}var f0=I("ZodPipe",(e,t)=>{vf.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>_m(e,n,r,o),e.in=t.in,e.out=t.out});function Qk(e,t){return new f0({type:"pipe",in:e,out:t})}var JM=I("ZodPreprocess",(e,t)=>{f0.init(e,t),w_.init(e,t)}),YM=I("ZodReadonly",(e,t)=>{S_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>km(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function XM(e){return new YM({type:"readonly",innerType:e})}var QM=I("ZodTemplateLiteral",(e,t)=>{x_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>am(e,n,r,o)});function eq(e,t){return new QM({type:"template_literal",parts:e,...q(t)})}var tq=I("ZodLazy",(e,t)=>{__.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>$m(e,n,r,o),e.unwrap=()=>e._zod.def.getter()});function Pm(e){return new tq({type:"lazy",getter:e})}var nq=I("ZodFunction",(e,t)=>{v_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>lm(e,n,r,o)});function Tm(e){return new nq({type:"function",input:Array.isArray(e?.input)?cl(e?.input):e?.input??S(K()),output:e?.output??K()})}var Om=I("ZodCustom",(e,t)=>{k_.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,o)=>cm(e,n,r,o)});function Le(e,t){return dk(Om,e??(()=>!0),t)}function rq(e,t={}){return pk(Om,e,t)}function oq(e,t){return fk(e,t)}var iq=I("ZodInstanceOf",(e,t)=>{Om.init(e,t)},{properties(e,t){return this.check(Df(e,t))}});function sq(e,t={}){let n=new iq({type:"custom",check:"custom",fn:(r)=>r instanceof e,abort:!0,...q(t)});return n._zod.bag.Class=e,n._zod.check=(r)=>{if(!(r.value instanceof e))r.issues.push({code:"invalid_type",expected:e.name,input:r.value,inst:n,path:[...n._zod.def.path??[]]})},n}function wt(e){let t=Pm(()=>Z([u(e),_(),z(),ao(),S(t),B(u(),t)]));return t}function ll(e,t){return new JM({type:"pipe",in:u0(e),out:t})}var h0={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 m0;(function(e){})(m0||(m0={}));function g0(e){return Yc(zs,e)}function cq(e){return Xc(Ns,e)}function lq(e){return Qc(js,e)}function uq(e){return el(Ls,e)}function dq(e){return X_(il,e)}var b0={name:"@tripwire-sh/cli",version:"0.1.16",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:"tsrs --noEmit --checkers 4 --fast false","typecheck:ts5":"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 qs=b0.version,fq=qs.includes("-staging.")?"staging":"production";function mr(e){let t=e.TRIPWIRE_ENV||fq;if(t!=="production"&&t!=="staging")throw Error("TRIPWIRE_ENV must be production or staging");return t}var rn=mr(process.env)==="staging",Bn=rn?"npx @tripwire-sh/cli@staging":"tripwire",M=rn?"tripwire-staging":"tripwire",Bo=rn?"tripwire-staging-get-started":"tripwire-get-started",Am=rn?"tripwire-staging-workflows":"tripwire-workflows",Us="tripwire-cli",zm="https://mcp.tripwire.sh/mcp",Nm="https://app.tripwire.sh/api/auth",mq="https://tripwire-mcp-preview-tripwire.unkey.app/mcp",hq="https://staging.tripwire.sh/api/auth",w0="offline_access tripwire:read tripwire:configure tripwire:moderate tripwire:admin";function Hn(e){return(e.TRIPWIRE_MCP_URL||(mr(e)==="staging"?mq:zm)).replace(/\/+$/,"")}function Fs(e){return(e.TRIPWIRE_AUTH_URL||(mr(e)==="staging"?hq:Nm)).replace(/\/+$/,"")}var gq="urn:ietf:params:oauth:grant-type:device_code",yq=m({device_code:u(),user_code:u(),verification_uri:u(),verification_uri_complete:u().optional(),expires_in:_(),interval:_().optional()}),x0=m({access_token:u().min(1),refresh_token:u().min(1).optional(),expires_in:_().optional(),token_type:u().optional()}),Lm=m({error:u(),error_description:u().optional()});class jm extends Error{constructor(){super(`Session expired. Run ${Bn} login.`);this.name="SessionExpiredError"}}class Ws extends Error{constructor(){super("Tripwire is not reachable right now. Try again in a minute.");this.name="AuthUnreachableError"}}var v0={fetch:(e,t)=>fetch(e,t),sleep:(e)=>new Promise((t)=>setTimeout(t,e)),now:()=>Date.now()};async function ul(e,t,n){let r=await e.fetch(t,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded",accept:"application/json"},body:new URLSearchParams(n).toString()}),o=await r.text(),i={error:"invalid_response",error_description:o.slice(0,200)};try{let s=wt().safeParse(JSON.parse(o));return{status:r.status,body:s.success?s.data:i,headers:r.headers}}catch{return{status:r.status,body:i,headers:r.headers}}}function _0(e,t){let n=Lm.safeParse(e);if(!n.success)return Error(t);return Error(n.data.error_description?`${n.data.error}: ${n.data.error_description}`:n.data.error)}async function k0(e,t,n){let{status:r,body:o}=await ul(e,`${t}/device/code`,{client_id:Us,scope:w0,resource:n}),i=yq.safeParse(o);if(r>=400||!i.success)throw _0(o,`Device authorization failed (HTTP ${r})`);return i.data}function $0(e,t,n,r,o){let i=t.refresh_token??o;return{accessToken:t.access_token,refreshToken:i,expiresAt:t.expires_in?e.now()+t.expires_in*1000:void 0,mcpUrl:r,authUrl:n}}var S0=5000;function bq(e,t){let n=(e.get("retry-after")??e.get("x-retry-after"))?.trim();if(!n)return null;if(/^\d+$/.test(n))return Number(n)*1000;let r=Date.parse(n);return Number.isNaN(r)?null:Math.max(0,r-t)}async function C0(e,t,n,r){let o=(r.interval??5)*1000,i=null,s=e.now()+r.expires_in*1000;while(e.now()<s){await e.sleep(Math.min(Math.max(o,i??0),s-e.now())),i=null;let{status:a,body:c,headers:l}=await ul(e,`${t}/oauth2/token`,{grant_type:gq,device_code:r.device_code,client_id:Us,resource:n}),d=x0.safeParse(c);if(a<400&&d.success)return $0(e,d.data,t,n);if(a===429){if(i=bq(l,e.now()),i===null)o+=S0;continue}let p=Lm.safeParse(c),f=p.success?p.data.error:"";if(f==="authorization_pending")continue;if(f==="slow_down"){o+=S0;continue}if(f==="access_denied")throw Error("Sign-in was denied in the browser");if(f==="expired_token")throw Error(`The code expired. Run ${Bn} login again.`);throw _0(c,`Token request failed (HTTP ${a})`)}throw Error(`The code expired. Run ${Bn} login again.`)}async function R0(e,t){if(!t.refreshToken)throw new jm;let{status:n,body:r}=await ul(e,`${t.authUrl}/oauth2/token`,{grant_type:"refresh_token",refresh_token:t.refreshToken,client_id:Us,resource:t.mcpUrl}).catch(()=>{throw new Ws}),o=x0.safeParse(r);if(n>=400||!o.success){let i=Lm.safeParse(r);throw(n===400||n===401)&&i.success&&i.data.error!=="invalid_response"?new jm:new Ws}return $0(e,o.data,t.authUrl,t.mcpUrl,t.refreshToken)}async function E0(e,t){let n=t.refreshToken??t.accessToken;await ul(e,`${t.authUrl}/oauth2/revoke`,{token:n,client_id:Us}).catch(()=>{return})}import{stdout as Vm,stdin as G0}from"node:process";import*as gr from"node:readline";import zq from"node:readline";var I0=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return(t)=>{let n=0;e.lastIndex=0;while(e.test(t))n+=1;return t.length-n}})(),P0=(e)=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,T0=(e)=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141;var wq=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Sq=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,O0=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,xq=/\t{1,1000}/y,A0=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu,vq=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,_q=/\p{M}+/gu,kq={limit:1/0,ellipsis:""},z0=(e,t={},n={})=>{let r=t.limit??1/0,o=t.ellipsis??"",i=t?.ellipsisWidth??(o?z0(o,kq,n).width:0),s=0,a=n.controlWidth??0,c=n.tabWidth??8,l=n.emojiWidth??2,d=2,p=n.regularWidth??1,f=n.wideWidth??2,h=[[vq,p],[wq,0],[Sq,a],[xq,c],[A0,l],[O0,f]],g=0,y=0,b=e.length,w=0,R=!1,k=b,O=Math.max(0,r-i),x=0,v=0,E=0,A=0;e:while(!0){if(v>x||y>=b&&y>g){let D=e.slice(x,v)||e.slice(g,y);w=0;for(let te of D.replaceAll(_q,"")){let ue=te.codePointAt(0)||0;if(P0(ue))A=2;else if(T0(ue))A=f;else A=p;if(E+A>O)k=Math.min(k,Math.max(x,g)+w);if(E+A>r){R=!0;break e}w+=te.length,E+=A}x=v=0}if(y>=b)break e;for(let D=0,te=h.length;D<te;D++){let[ue,de]=h[D];if(ue.lastIndex=y,ue.test(e)){if(w=ue===O0?I0(e.slice(y,ue.lastIndex)):ue===A0?1:ue.lastIndex-y,A=w*de,E+A>O)k=Math.min(k,y+Math.floor((O-E)/de));if(E+A>r){R=!0;break e}E+=A,x=g,v=y,y=g=ue.lastIndex;continue e}}y+=1}return{width:R?O:E,index:R?k:b,truncated:R,ellipsed:R&&r>=i}},N0=z0;var $q={limit:1/0,ellipsis:"",ellipsisWidth:0},Cq=(e,t={})=>N0(e,$q,t).width,gn=Cq;var dl="\x1B",q0="›",Rq=39,Mm="\x07",U0="[",Eq="]",F0="m",qm=`${Eq}8;;`,j0=new RegExp(`(?:\\${U0}(?<code>\\d+)m|\\${qm}(?<uri>.*)${Mm})`,"y"),L0=(e)=>{if(e>=30&&e<=37)return 39;if(e>=90&&e<=97)return 39;if(e>=40&&e<=47)return 49;if(e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0;return},D0=(e)=>`${dl}${U0}${e}${F0}`,M0=(e)=>`${dl}${qm}${e}${Mm}`,Dm=(e,t,n)=>{let r=t[Symbol.iterator](),o=!1,i=!1,s=e.at(-1),a=s===void 0?0:gn(s),c=r.next(),l=r.next(),d=0;while(!c.done){let p=c.value,f=gn(p);if(a+f<=n)e[e.length-1]+=p;else e.push(p),a=0;if(p===dl||p===q0)o=!0,i=t.startsWith(qm,d+1);if(o){if(i){if(p===Mm)o=!1,i=!1}else if(p===F0)o=!1}else if(a+=f,a===n&&!l.done)e.push(""),a=0;c=l,l=r.next(),d+=p.length}if(s=e.at(-1),!a&&s!==void 0&&s.length&&e.length>1)e[e.length-2]+=e.pop()},Iq=(e)=>{let t=e.split(" "),n=t.length;while(n){if(gn(t[n-1]))break;n--}if(n===t.length)return e;return t.slice(0,n).join(" ")+t.slice(n).join("")},Pq=(e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let r="",o,i,s=e.split(" "),a=[""],c=0;for(let p=0;p<s.length;p++){let f=s[p];if(n.trim!==!1){let g=a.at(-1)??"",y=g.trimStart();if(g.length!==y.length)a[a.length-1]=y,c=gn(y)}if(p!==0){if(c>=t&&(n.wordWrap===!1||n.trim===!1))a.push(""),c=0;if(c||n.trim===!1)a[a.length-1]+=" ",c++}let h=gn(f);if(n.hard&&h>t){let g=t-c,y=1+Math.floor((h-g-1)/t);if(Math.floor((h-1)/t)<y)a.push("");Dm(a,f,t),c=gn(a.at(-1)??"");continue}if(c+h>t&&c&&h){if(n.wordWrap===!1&&c<t){Dm(a,f,t),c=gn(a.at(-1)??"");continue}a.push(""),c=0}if(c+h>t&&n.wordWrap===!1){Dm(a,f,t),c=gn(a.at(-1)??"");continue}a[a.length-1]+=f,c+=h}if(n.trim!==!1)a=a.map((p)=>Iq(p));let l=a.join(`
229
229
  `),d=!1;for(let p=0;p<l.length;p++){let f=l[p];if(r+=f,!d){if(d=f>="\uD800"&&f<="\uDBFF",d)continue}else d=!1;if(f===dl||f===q0){j0.lastIndex=p+1;let g=j0.exec(l)?.groups;if(g?.code!==void 0){let y=Number.parseFloat(g.code);o=y===Rq?void 0:y}else if(g?.uri!==void 0)i=g.uri.length===0?void 0:g.uri}if(l[p+1]===`
230
230
  `){if(i)r+=M0("");let h=o?L0(o):void 0;if(o&&h)r+=D0(h)}else if(f===`
231
231
  `){if(o&&L0(o))r+=D0(o);if(i)r+=M0(i)}}return r},Tq=/\r?\n/;function hr(e,t,n){return String(e).normalize().split(Tq).map((r)=>Pq(r,t,n)).join(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tripwire-sh/cli",
3
- "version": "0.1.16-staging.1",
3
+ "version": "0.1.16",
4
4
  "description": "Set up Tripwire in your coding agents and manage it from the terminal",
5
5
  "type": "module",
6
6
  "imports": {