@shadowclone/cli 0.0.12 → 0.0.14

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.
@@ -0,0 +1,134 @@
1
+ function Zt(e){let t=Object.values(e).filter((n)=>typeof n==="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function Nn(e,t="|"){return e.map((r)=>Dn(r)).join(t)}function Et(e,t){if(typeof t==="bigint")return t.toString();return t}class Is{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;if(e!==void 0)this._value=e(),this._getter=void 0;return this._value}}function gr(e){return new Is(e)}function Ps(e){return e===null||e===void 0}function xr(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Zs(e,t){let r=e/t,n=Math.round(r),o=4*Number.EPSILON*Math.max(Math.abs(r),1);if(Math.abs(r-n)<o)return 0;return r-n}function me(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function yr(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function Oe(e){return yr(e._zod.def)??e._zod.def.shape}function Es(e,t,r){Object.defineProperty(e,t,{get(){let n=r();return me(this,t,n),n},enumerable:!0,configurable:!0})}function Os(e,t,r){if(t in e)me(e,t,r);else e[t]=r}function Ye(e,t,r,n){let o=Oe(t);for(let i of r){let s=Object.getOwnPropertyDescriptor(o,i);if(!s.enumerable)continue;if(s.get)Es(e,i,()=>{let a=t._zod.def.shape[i];return n?n(a,i):a});else Os(e,i,n?n(s.value,i):s.value)}}function xf(e,t){for(let r of Reflect.ownKeys(t)){let n=Object.getOwnPropertyDescriptor(t,r);if(!n.enumerable)continue;if(n.get)Es(e,r,()=>t[r]);else Os(e,r,n.value)}}function ae(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function As(e){return JSON.stringify(e)}function Cs(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Rn="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Pt(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Ts=gr(()=>{if(te.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function We(e){if(Pt(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let r=t.prototype;if(Pt(r)===!1)return!1;if(Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)return!1;return!0}function Mn(e){if(We(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var Ns=new Set(["string","number","symbol"]);function lt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function be(e,t,r){let n=new e._zod.constr(t??e._zod.def);if(!t||r?.parent)n._zod.parent=e;return n}function k(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function Dn(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Rs(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var br=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),Ln={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function yf(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let i={};return Ye(i,e,vr(e,t)),be(e,ae(r,{shape:i,checks:[]}))}function vr(e,t){let r=Oe(e),n=[];for(let o of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,o)?.enumerable)throw Error(`Unrecognized key: "${String(o)}"`);if(t[o])n.push(o)}return n}function bf(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let i=new Set(vr(e,t)),s={};return Ye(s,e,Reflect.ownKeys(Oe(e)).filter((a)=>!i.has(a))),be(e,ae(r,{shape:s,checks:[]}))}function vf(e,t){if(!We(t))throw Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let o=Oe(e);for(let i of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(o,i)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return be(e,ae(e._zod.def,{shape:Ms(e,t)}))}function Ms(e,t){let r={};return Ye(r,e,Reflect.ownKeys(Oe(e))),xf(r,t),r}function _f(e,t){if(!We(t))throw Error("Invalid input to safeExtend: expected a plain object");return be(e,ae(e._zod.def,{shape:Ms(e,t)}))}function wf(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r={};Ye(r,e,Reflect.ownKeys(Oe(e))),Ye(r,t,Reflect.ownKeys(Oe(t)));let n=ae(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return be(e,n)}function Ds(e,t,r,n="partial"){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${n}() cannot be used on object schemas containing refinements`);let a=r?new Set(vr(t,r)):void 0,u={};return Ye(u,t,Reflect.ownKeys(Oe(t)),e&&((c,l)=>a&&!a.has(l)?c:new e({type:"optional",innerType:c}))),be(t,ae(t._zod.def,{shape:u,checks:[]}))}function kf(e,t,r){let n=r?new Set(vr(t,r)):void 0,o={};return Ye(o,t,Reflect.ownKeys(Oe(t)),(i,s)=>n&&!n.has(s)?i:new e({type:"nonoptional",innerType:i})),be(t,ae(t._zod.def,{shape:o}))}function ve(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function Ls(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function Fe(e,t){return t.map((r)=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function It(e){return typeof e==="string"?e:e?.message}function Bn(e,t,r){var n;for(let o=t;o<e.length;o++)(n=e[o]).schema??(n.schema=r)}function _e(e,t,r){var n;let o=e.inst?._zod?.traits;if(o?.has("$ZodType"))if(o.has("$ZodCheck"))(n=e).schema??(n.schema=e.inst);else e.schema=e.inst;let i=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,s=e.message?e.message:It(e.inst?._zod.def?.error?.(e))??It(i?.(e))??It(t?.error?.(e))??It(r.customError?.(e))??It(r.localeError?.(e))??"Invalid input",a={};for(let u of Object.keys(e)){if(u==="inst"||u==="schema"||u==="continue"||u==="input"||u==="__proto__")continue;a[u]=e[u]}if(a.path??(a.path=[]),a.message=s,t?.reportInput)a.input=e.input;return a}var zf=/[\uD800-\uDBFF]/;function _r(e){let t=e.length;if(!zf.test(e))return t;let r=t;for(let n=0;n<t-1;n++)if((e.charCodeAt(n)&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320)r--,n++;return r}function wr(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function Bs(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function Qe(...e){let[t,r,n]=e;if(typeof t==="string")return{message:t,code:"custom",input:r,inst:n};return{...t}}function js(e,t){for(let r in t){let n=Object.getOwnPropertyDescriptor(t,r);if(n.get)Object.defineProperty(e,r,{...n,enumerable:!1});else $f(e,r,n.value)}}function Ae(e,t,r,n=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:n,value:r}),r}function kr(e,t,r){return Ae(e,t,r,!1)}function Fs(e,t){for(let r in e){let n=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return Ae(this,r,n(this))},set(o){Ae(this,r,o)}})}return t}function $f(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:Ae(this,t,r.bind(this))},set(n){Ae(this,t,n)}})}function Sf(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var Tn,je=!1,If={configurable:!0,get(){je=!0;return}};function N(e,t,r){let n=Object.getPrototypeOf(e._zod);if(t in n&&Tn!==e._zod){Tn=void 0;return}Tn=e._zod,Object.defineProperty(n,t,{configurable:!0,get(){Object.defineProperty(this,t,If);let o=je;je=!1;try{let i=r(this);if(je)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i});return je=je||o,i}catch(i){throw delete this[t],je=je||o,i}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function Pf(e,t,r,n){let o=Sf(e,t);if(!o)return;Object.defineProperty(o,t,{configurable:!0,get(){let i={configurable:!0,writable:!0,enumerable:n,value:void 0};return Object.defineProperty(this,t,i),i.value=r(this),Object.defineProperty(this,t,i),i.value},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:n,value:i})}})}var Zf="~constantCatch";function Us(e){let t=()=>e;return t[Zf]=!0,t}var qs;var jn={value:void 0,enumerable:!1},Vs="captureStackTrace"in Error?Error:null;function Ef(e){let t=Vs;if(t){let r=t.stackTraceLimit;if(typeof r==="number"){try{t.stackTraceLimit=0}catch{return Vs=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function g(e,t,r,n){let o={};function i(f){this.def=f,this.constr=p,this.traits=new Set}i.prototype=o;let s=r,a=s&&new WeakSet;function u(f,d){if(!f._zod){jn.value=new i(d);try{Object.defineProperty(f,"_zod",jn)}finally{jn.value=void 0}}else if(f._zod.traits.has(e))return;if(f._zod.traits.add(e),t(f,d),a){let x=Object.getPrototypeOf(f),v=f._zod.constr.prototype,b=x;while(b&&b!==v)b=Object.getPrototypeOf(b);let Z=b??x;if(!a.has(Z))a.add(Z),js(Z,s)}let m=p.prototype;for(let x in m){if(!Object.prototype.hasOwnProperty.call(m,x))continue;if(!(x in f))f[x]=m[x].bind(f)}}let c=n?.Parent??Object;class l extends c{}Object.defineProperty(l,"name",{value:e});function p(f){let d=n?.Parent?Ef(l):this;u(d,f);let m=d._zod.deferred;if(m){for(let v of m)v();d._zod.deferred=void 0}let x=globalThis.__zod_globalConfig?.postProcessor;if(x)x(d);return d}return Object.defineProperty(p,"init",{value:u}),Object.defineProperty(p,Symbol.hasInstance,{value:(f)=>{if(n?.Parent&&f instanceof n.Parent)return!0;return f?._zod?.traits?.has(e)}}),Object.defineProperty(p,"name",{value:e}),p}class we extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Ot extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(qs=globalThis).__zod_globalConfig??(qs.__zod_globalConfig={});var te=globalThis.__zod_globalConfig;function ce(e){if(e)Object.assign(te,e);return te}function Of(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Et,2)),e.message}function Af(e){this._zod.message=e}var Cf={get:Of,set:Af,enumerable:!0,configurable:!0},Un={value:void 0,enumerable:!1},Js=new WeakSet([Object.prototype,Error.prototype]),Hs=(e,t)=>{e.name="$ZodError",Un.value=t,Object.defineProperty(e,"issues",Un),Un.value=void 0,Object.defineProperty(e,"message",Cf);let r=Object.getPrototypeOf(e);if(!Js.has(r))Js.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let n=()=>this.message;return Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0})}})},Ks=g("$ZodError",Hs),Rx=g("$ZodError",Hs,void 0,{Parent:Error});function Tf(e,t,r){if(!Object.prototype.hasOwnProperty.call(e,t))if(t==="__proto__")Object.defineProperty(e,t,{value:r(),writable:!0,enumerable:!0,configurable:!0});else e[t]=r();return e[t]}function Gs(e,t=(r)=>r.message){let r={},n=[];for(let o of e.issues)if(o.path.length>0)Tf(r,o.path[0],()=>[]).push(t(o));else n.push(t(o));return{formErrors:n,fieldErrors:r}}function Xs(e,t=(r)=>r.message){let r={_errors:[]},n=(o,i=[])=>{for(let s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map((a)=>n({issues:a},[...i,...s.path]));else if(s.code==="invalid_key")n({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")n({issues:s.issues},[...i,...s.path]);else{let a=[...i,...s.path];if(a.length===0)r._errors.push(t(s));else{let u=r,c=0;while(c<a.length){let l=a[c],p=c===a.length-1;if(l==="_errors"){if(p)u._errors.push(t(s));c++;continue}if(!Object.prototype.hasOwnProperty.call(u,l))Object.defineProperty(u,l,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let f=u[l];if(p)f._errors.push(t(s));u=f,c++}}}};return n(e),r}function zr(e,t){return{callee:t?.callee??e,Err:t?.Err}}var $r=(e)=>{let t=(r,n,o,i)=>{let s=o?{...o,async:!1}:{async:!1},a=r._zod.run({value:n,issues:[]},s);if(a instanceof Promise)throw new we;if(a.issues.length){let u=new(i?.Err??e)(a.issues.map((c)=>_e(c,s,ce())));throw Rn(u,i?.callee??t),u}return a.value};return t};var Sr=(e)=>{let t=async(r,n,o,i)=>{let s=o?{...o,async:!0}:{async:!0},a=r._zod.run({value:n,issues:[]},s);if(a instanceof Promise)a=await a;if(a.issues.length){let u=new(i?.Err??e)(a.issues.map((c)=>_e(c,s,ce())));throw Rn(u,i?.callee??t),u}return a.value};return t};var Ir=(e)=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},o);if(i instanceof Promise)throw new we;return i.issues.length?Ys(e,i.issues,o):{success:!0,data:i.value}};function Ys(e,t,r){let n;return{success:!1,get error(){if(!n)n=new e(t.map((o)=>_e(o,r,ce()))),t=void 0,r=void 0;return n},set error(o){n=o,t=void 0,r=void 0}}}var Pr=(e)=>async(t,r,n)=>{let o=n?{...n,async:!0}:{async:!0},i=t._zod.run({value:r,issues:[]},o);if(i instanceof Promise)i=await i;return i.issues.length?Ys(e,i.issues,o):{success:!0,data:i.value}};var Nf=Symbol.for("zod.compile.invalid"),Rf=Symbol.for("zod.compile.fallback"),qn=(e,t,r)=>{let n=e._zod.bag.validator;if(n!==void 0){if(n(t)!==Nf)return!0;if(n.definite===!0&&r===void 0)return!1}return Mf(e,t,r)};function Mf(e,t,r){let n=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun,i;if(o)n[Rf]=!0,i=o({value:t,issues:[]},n);else i=e._zod.run({value:t,issues:[]},n);if(i instanceof Promise)throw new we;return i.issues.length===0}var Vn=async(e,t,r)=>{let n=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},o=e._zod.run({value:t,issues:[]},n);if(o instanceof Promise)o=await o;return o.issues.length===0},Ws=(e)=>{let t=$r(e),r=(n,o,i,s)=>{let a=i?{...i,direction:"backward"}:{direction:"backward"};return t(n,o,a,zr(r,s))};return r};var Qs=(e)=>{let t=$r(e),r=(n,o,i,s)=>t(n,o,i,zr(r,s));return r};var ea=(e)=>{let t=Sr(e),r=async(n,o,i,s)=>{let a=i?{...i,direction:"backward"}:{direction:"backward"};return await t(n,o,a,zr(r,s))};return r};var ta=(e)=>{let t=Sr(e),r=async(n,o,i,s)=>await t(n,o,i,zr(r,s));return r};var ra=(e)=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Ir(e)(t,r,o)};var na=(e)=>(t,r,n)=>Ir(e)(t,r,n);var oa=(e)=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Pr(e)(t,r,o)};var ia=(e)=>async(t,r,n)=>Pr(e)(t,r,n);var sa=/^[cC][0-9a-z]{6,}$/,aa=/^[0-9a-z]+$/,ca=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,ua=/^[0-9a-vA-V]{20}$/,la=/^[A-Za-z0-9]{27}$/,pa=/^[a-zA-Z0-9_-]{21}$/;function fa(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var da=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var ma=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Hn=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var ha=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Df="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function ga(){return new RegExp(Df,"u")}var xa=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ya=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var ba=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,va=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,_a=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,wa=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var ka=/^https?$/,za=/^\+[1-9]\d{6,14}$/;var $a="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function Lf(e){return new RegExp(`^${e}$`)}var Sa=Lf($a);function Jn(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function Ia(e){return new RegExp(`^${Jn(e)}$`)}function Pa(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${Jn({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,n=e.local?`${r}|${Jn({precision:e.precision})}`:r;return new RegExp(`^${$a}T(?:${n})$`)}var Za=/^[\s\S]{0,}$/;var Kn=/^-?\d+$/,At=/^-?\d+(?:\.\d+)?$/,Ea=/^(?:true|false)$/i;var Oa=/^[^A-Z]*$/,Aa=/^[^a-z]*$/;var X=g("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var Gn=(e)=>{let t=e.value;return!Ps(t)&&t.length!==void 0},Zr={number:"number",bigint:"bigint",object:"date"},Xn=g("$ZodCheckLessThan",(e,t)=>{X.init(e,t);let r=Zr[typeof t.value];e._zod.check=(n)=>{if(t.inclusive?n.value<=t.value:n.value<t.value)return;n.issues.push({origin:Zr[typeof n.value]??r,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Yn=g("$ZodCheckGreaterThan",(e,t)=>{X.init(e,t);let r=Zr[typeof t.value];e._zod.check=(n)=>{if(t.inclusive?n.value>=t.value:n.value>t.value)return;n.issues.push({origin:Zr[typeof n.value]??r,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ca=g("$ZodCheckMultipleOf",(e,t)=>{X.init(e,t),e._zod.check=(r)=>{if(typeof r.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof r.value==="bigint"?t.value!==BigInt(0)&&r.value%t.value===BigInt(0):Zs(r.value,t.value)===0)return;r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Ta=g("$ZodCheckNumberFormat",(e,t)=>{X.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,i]=br[t.format];e._zod.check=(s)=>{let a=s.value;if(r){if(!Number.isInteger(a)){s.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});else s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}if(a<o)s.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort});if(a>i)s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}});var Na=g("$ZodCheckMaxLength",(e,t)=>{var r;X.init(e,t),(r=e._zod.def).when??(r.when=Gn),e._zod.check=(n)=>{let o=n.value,i=o.length;if((typeof o==="string"&&i>t.maximum?_r(o):i)<=t.maximum)return;let a=wr(o);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Ra=g("$ZodCheckMinLength",(e,t)=>{var r;X.init(e,t),(r=e._zod.def).when??(r.when=Gn),e._zod.check=(n)=>{let o=n.value,i=o.length;if((typeof o==="string"&&i>=t.minimum&&i<t.minimum*2?_r(o):i)>=t.minimum)return;let a=wr(o);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Ma=g("$ZodCheckLengthEquals",(e,t)=>{var r;X.init(e,t),(r=e._zod.def).when??(r.when=Gn),e._zod.check=(n)=>{let o=n.value,i=o.length,s=typeof o==="string"&&i>=t.length&&i<=t.length*2?_r(o):i;if(s===t.length)return;let a=wr(o),u=s>t.length;n.issues.push({origin:a,...u?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Tt=g("$ZodCheckStringFormat",(e,t)=>{var r,n;if(X.init(e,t),t.pattern)(r=e._zod).check??(r.check=(o)=>{if(t.pattern.lastIndex=0,t.pattern.test(o.value))return;o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(n=e._zod).check??(n.check=()=>{})}),Da=g("$ZodCheckRegex",(e,t)=>{Tt.init(e,t),e._zod.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),La=g("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Oa),Tt.init(e,t)}),Ba=g("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Aa),Tt.init(e,t)}),ja=g("$ZodCheckIncludes",(e,t)=>{X.init(e,t);let r=lt(t.includes),n=new RegExp(typeof t.position==="number"?`^.{${t.position},}${r}`:r);t.pattern=n,e._zod.check=(o)=>{if(o.value.includes(t.includes,t.position))return;o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Fa=g("$ZodCheckStartsWith",(e,t)=>{X.init(e,t);let r=new RegExp(`^${lt(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.check=(n)=>{if(n.value.startsWith(t.prefix))return;n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Ua=g("$ZodCheckEndsWith",(e,t)=>{X.init(e,t);let r=new RegExp(`.*${lt(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.check=(n)=>{if(n.value.endsWith(t.suffix))return;n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});var qa=g("$ZodCheckOverwrite",(e,t)=>{X.init(e,t),e._zod.check=(r)=>{r.value=t.tx(r.value)}});class Wn{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let r=e.split(`
2
+ `).filter((i)=>i),n=Math.min(...r.map((i)=>i.length-i.trimStart().length)),o=r.map((i)=>i.slice(n)).map((i)=>" ".repeat(this.indent*2)+i);for(let i of o)this.content.push(i)}compile(){let e=Function,t=this?.content??[""];return new e(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
3
+ ${t.join(`
4
+ `)}
5
+ };`)(...Object.values(this.closed))}}var Ja={major:4,minor:6,patch:5};var L=g("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ja;let n=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...n??[]]:n?.length?[...n]:[];for(let i of o)for(let s of i._zod.onattach)s(e);if(o.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=(a,u,c)=>{if(a.memo)return a;let l=ve(a),p;for(let f of u){if(f._zod.def.when){if(Ls(a))continue;if(!f._zod.def.when(a))continue}else if(l)continue;let d=a.issues.length,m=f._zod.check(a);if(m instanceof Promise&&c?.async===!1)throw new we;if(p||m instanceof Promise)p=(p??Promise.resolve()).then(async()=>{if(await m,a.issues.length===d)return;if(Bn(a.issues,d,e),!l)l=ve(a,d)});else{if(a.issues.length===d)continue;if(Bn(a.issues,d,e),!l)l=ve(a,d)}}if(p)return p.then(()=>a);return a},s=(a,u,c)=>{if(ve(a))return a.aborted=!0,a;let l=i(u,o,c);if(l instanceof Promise){if(c.async===!1)throw new we;return l.then((p)=>e._zod.parse(p,c))}return e._zod.parse(l,c)};e._zod.run=(a,u)=>{if(u.skipChecks)return e._zod.parse(a,u);if(u.direction==="backward"){let l=e._zod.parse({value:a.value,issues:[]},{...u,skipChecks:!0});if(l instanceof Promise)return l.then((p)=>s(p,a,u));return s(l,a,u)}let c=e._zod.parse(a,u);if(c instanceof Promise){if(u.async===!1)throw new we;return c.then((l)=>i(l,o,u))}return i(c,o,u)}}},{get "~standard"(){return kr(this,"~standard",eo(this))},set "~standard"(e){Ae(this,"~standard",e)}}),nc=(e,t)=>e.issues.length?{issues:e.issues.map((r)=>_e(r,t,ce()))}:{value:e.value};async function Bf(e,t){let r={async:!0};return nc(await e._zod.run({value:t,issues:[]},r),r)}function eo(e){return{validate:(t)=>{let r={async:!1};try{let n=e._zod.run({value:t,issues:[]},r);if(!(n instanceof Promise))return nc(n,r)}catch(n){}return Bf(e,t)},vendor:"zod",version:1}}var Cr=g("$ZodString",(e,t)=>{L.init(e,t),e._zod.pattern=t.pattern??Za,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch(o){}if(typeof r.value==="string")return r;return r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),M=g("$ZodStringFormat",(e,t)=>{Tt.init(e,t),Cr.init(e,t)}),oc=g("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=ma),M.init(e,t)}),ic=g("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Hn(n))}else t.pattern??(t.pattern=Hn());M.init(e,t)}),sc=g("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=ha),M.init(e,t)}),ac=1,Or=2;function cc(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function jf(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return cc(e)||Or;return Ff(e,t)}function Ff(e,t){if(!t.normalize&&t.protocol?.source===ka.source&&!/^https?:\/\//i.test(e))return ac;try{if(typeof URL<"u"){let r=URL;if(typeof r.parse==="function")return r.parse(e)??Or}return new URL(e)}catch{return Or}}var Uf=/[\t\n\r]/g;function Ha(e){return e.replace(Uf,"")}function qf(e,t){return t.lastIndex=0,t.test(e.hostname)}function Vf(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var uc=g("$ZodURL",(e,t)=>{M.init(e,t),e._zod.check=(r)=>{try{let n=r.value.trim(),o=jf(n,t);if(o===ac){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(o===Or){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}if(o===!0){r.value=Ha(n);return}if(t.hostname&&!qf(o,t.hostname))r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort});if(t.protocol&&!Vf(o,t.protocol))r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort});r.value=t.normalize?o.href:Ha(n);return}catch(n){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),lc=g("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=ga()),M.init(e,t)}),pc=g("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?pa:fa(t.length)),M.init(e,t)}),fc=g("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=sa),M.init(e,t)}),dc=g("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=aa),M.init(e,t)}),mc=g("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ca),M.init(e,t)}),hc=g("$ZodXID",(e,t)=>{t.pattern??(t.pattern=ua),M.init(e,t)}),gc=g("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=la),M.init(e,t)}),xc=g("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Pa(t)),M.init(e,t)}),yc=g("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Sa),M.init(e,t)}),bc=g("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Ia(t)),M.init(e,t)}),vc=g("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=da),M.init(e,t)}),_c=g("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=xa),M.init(e,t)}),Jf=/^[0-9a-fA-F:.]+$/;function wc(e){if(!Jf.test(e))return!1;return cc(`http://[${e}]`)}var kc=g("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ya),M.init(e,t),e._zod.check=(r)=>{if(!wc(r.value))r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}});var zc=g("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ba),M.init(e,t)});function Hf(e){let t=e.split("/");if(t.length!==2)return!1;let[r,n]=t;if(!n)return!1;let o=Number(n);if(`${o}`!==n)return!1;if(o<0||o>128)return!1;return wc(r)}var $c=g("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=va),M.init(e,t),e._zod.check=(r)=>{if(!Hf(r.value))r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function Sc(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var to=/^[0-9a-zA-Z+/]*={0,2}$/,Ic=g("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=to),M.init(e,t),e._zod.check=(r)=>{if(Sc(r.value))return;r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),Tr=/^[A-Za-z0-9_-]*$/;function Kf(e){if(!Tr.test(e))return!1;let t=e.replace(/[-_]/g,(n)=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return Sc(r)}var Pc=g("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Tr),M.init(e,t),e._zod.check=(r)=>{if(Kf(r.value))return;r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Zc=g("$ZodE164",(e,t)=>{t.pattern??(t.pattern=za),M.init(e,t)});function Gf(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let o=JSON.parse(atob(n));if("typ"in o&&o?.typ!=="JWT")return!1;if(!o.alg)return!1;if(t&&(!("alg"in o)||o.alg!==t))return!1;return!0}catch{return!1}}var Ec=g("$ZodJWT",(e,t)=>{M.init(e,t),e._zod.check=(r)=>{if(Gf(r.value,t.alg))return;r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var ro=g("$ZodNumber",(e,t)=>{L.init(e,t),e._zod.pattern=At,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch(s){}let o=r.value;if(typeof o==="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let i=typeof o==="number"?Number.isNaN(o)?"NaN":!Number.isFinite(o)?String(o):void 0:void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),r}}),Oc=g("$ZodNumberFormat",(e,t)=>{Ta.init(e,t),ro.init(e,t)}),Ac=g("$ZodBoolean",(e,t)=>{L.init(e,t),e._zod.pattern=Ea,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Boolean(r.value)}catch(i){}let o=r.value;if(typeof o==="boolean")return r;return r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}});var Cc=g("$ZodUnknown",(e,t)=>{L.init(e,t),e._zod.parse=(r)=>r}),Tc=g("$ZodNever",(e,t)=>{L.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function Ka(e,t,r){if(e.issues.length)t.issues.push(...Fe(r,e.issues));t.value[r]=e.value}var Nc=g("$ZodArray",(e,t)=>{L.init(e,t);let r=te.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=r?r.alloc(e,n,Array(i.length),o):Array(i.length);let s=[],a=o?.abortEarly;for(let u=0;u<i.length;u++){let c=i[u],l=t.element._zod.run({value:c,issues:[]},o);if(l instanceof Promise)s.push(l.then((p)=>Ka(p,n,u)));else if(Ka(l,n,u),a&&l.issues.length!==0&&ve(l))break}if(s.length)return Promise.all(s).then(()=>n);return n}});function Ar(e,t,r,n,o,i){let s=r in n,a=i==="optional";if(!s&&a&&o==="optional")return;if(e.issues.length){if(o!==void 0&&a&&!s)return;t.issues.push(...Fe(r,e.issues))}if(!s&&o===void 0){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}if(e.value===void 0){if(s||o==="defaulted"&&!a)t.value[r]=void 0}else t.value[r]=e.value}var Xf=[];function Rc(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),n=r.length?r:Xf,o=n.length?[...t,...n]:t;for(let s of o)if(!e.shape?.[s]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(s)}": expected a Zod schema`);let i=Rs(e.shape);return{...e,allKeys:o,symbolKeys:n,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}function Mc(e,t,r,n,o,i,s){let a=[],u=o.keySet,c=o.catchall._zod,l=c.def.type,{optin:p,optout:f}=c,d=0;for(let m in t){if(s&&r.issues.length!==d){if(ve(r,d))break;d=r.issues.length}if(u.has(m))continue;if(m==="__proto__"){if(l==="never")a.push(m);continue}if(l==="never"){a.push(m);continue}let x=c.run({value:t[m],issues:[]},n);if(x instanceof Promise)e.push(x.then((v)=>Ar(v,r,m,t,p,f)));else Ar(x,r,m,t,p,f)}if(a.length)r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i,continue:!0});if(!e.length)return r;return Promise.all(e).then(()=>r)}var Yf=g("$ZodObject",(e,t)=>{L.init(e,t);let r=Object.getOwnPropertyDescriptor(t,"shape"),n=r?.get?r.get.raw:t.shape??{};if(n){let c=()=>{let l={...n};return Object.defineProperty(t,"shape",{value:l}),c.raw=l,l};c.raw=n,Object.defineProperty(t,"shape",{get:c})}let o=gr(()=>Rc(t));N(e,"propValues",(c)=>{let l=c.def.shape,p={};for(let f in l){let d=l[f]._zod;if(d.values){if(!Object.prototype.hasOwnProperty.call(p,f))me(p,f,new Set);for(let m of d.values)p[f].add(m);if(d.optin!==void 0)p[f].add(void 0)}}return p});let i=Pt,s=t.catchall,a,u=te.memoizer;u?.attach(e),e._zod.parse=(c,l)=>{a??(a=o.value);let p=c.value;if(!i(p))return c.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),c;c.value=u?u.alloc(e,c,{},l):{};let f=[],d=a.shape,m=l?.abortEarly,x=c.issues.length;for(let v of a.allKeys){if(m&&c.issues.length!==x){if(ve(c,x))break;x=c.issues.length}if(v==="__proto__")continue;let b=d[v],Z=b._zod.optin,D=b._zod.optout,j=b._zod.run({value:p[v],issues:[]},l);if(j instanceof Promise)f.push(j.then((T)=>Ar(T,c,v,p,Z,D)));else Ar(j,c,v,p,Z,D)}if(!s)return f.length?Promise.all(f).then(()=>c):c;return Mc(f,p,c,l,o.value,e,m===!0)}}),Dc=g("$ZodObjectJIT",(e,t)=>{Yf.init(e,t);let r=e._zod.parse,n=gr(()=>Rc(t)),o=te.memoizer,i=(d)=>{let m=n.value,x=m.symbolKeys,v=new Wn(["payload","ctx"],{shape:d,inst:e,memo:o,syms:x}),b=(T)=>`shape[${T}]._zod.run({ value: input[${T}], issues: [] }, ctx)`,Z=(T,O)=>`
6
+ let ${T}_ab = false;
7
+ for (let i = 0; i < ${T}.issues.length; i++) {
8
+ const iss = ${T}.issues[i];
9
+ iss.path = iss.path ? [${O}, ...iss.path] : [${O}];
10
+ payload.issues.push(iss);
11
+ if (iss.continue !== true) ${T}_ab = true;
12
+ }
13
+ if (${T}_ab && ctx && ctx.abortEarly) {
14
+ payload.value = newResult;
15
+ return payload;
16
+ }`;v.write("const input = payload.value;");let D=Object.create(null),j=0;for(let T of m.allKeys)D[T]=`key_${j++}`;v.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let T of m.allKeys){if(T==="__proto__")continue;let O=D[T],J=typeof T==="symbol"?`syms[${x.indexOf(T)}]`:As(T),Le=`${J} in input`,Xe=d[T],Be=Xe?._zod?.optin,hr=Be!==void 0,On=Xe?._zod?.optout==="optional";if(v.write(`const ${O} = ${b(J)};`),hr&&On){let An=Be==="optional"?`${O}_present`:`${O}.value !== undefined || ${O}_present`;v.write(`
17
+ const ${O}_present = ${Le};
18
+ if (!${O}.issues.length || ${O}_present) {
19
+ if (${O}.issues.length) {${Z(O,J)}
20
+ }
21
+
22
+ if (${An}) {
23
+ newResult[${J}] = ${O}.value;
24
+ }
25
+ }
26
+
27
+ `)}else if(!hr)v.write(`
28
+ const ${O}_present = ${Le};
29
+ if (${O}.issues.length) {${Z(O,J)}
30
+ }
31
+ if (!${O}_present && !${O}.issues.length) {
32
+ payload.issues.push({
33
+ code: "invalid_type",
34
+ expected: "nonoptional",
35
+ input: undefined,
36
+ path: [${J}]
37
+ });
38
+ if (ctx && ctx.abortEarly) {
39
+ payload.value = newResult;
40
+ return payload;
41
+ }
42
+ }
43
+
44
+ if (${O}_present) {
45
+ newResult[${J}] = ${O}.value;
46
+ }
47
+
48
+ `);else if(v.write(`
49
+ if (${O}.issues.length) {${Z(O,J)}
50
+ }
51
+ `),Be==="defaulted")v.write(`newResult[${J}] = ${O}.value;`);else v.write(`
52
+ if (${O}.value !== undefined || ${Le}) {
53
+ newResult[${J}] = ${O}.value;
54
+ }
55
+ `)}return v.write("payload.value = newResult;"),v.write("return payload;"),v.compile()},s,a=Pt,u=!te.jitless,l=u&&Ts.value,p=t.catchall,f;e._zod.parse=(d,m)=>{f??(f=n.value);let x=d.value;if(!a(x))return d.issues.push({expected:"object",code:"invalid_type",input:x,inst:e}),d;if(u&&l&&m?.async===!1&&m.jitless!==!0){if(!s)s=i(t.shape);if(d=s(d,m),!p)return d;return Mc([],x,d,m,f,e,m?.abortEarly===!0)}return r(d,m)}});function Ga(e,t,r,n){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let o=e.filter((i)=>!ve(i));if(o.length===1)return t.value=o[0].value,o[0];return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map((i)=>i.issues.map((s)=>_e(s,n,ce())))}),t}var Lc=g("$ZodUnion",(e,t)=>{L.init(e,t),N(e,"optin",(n)=>n.def.options.some((o)=>o._zod.optin==="defaulted")?"defaulted":n.def.options.some((o)=>o._zod.optin!==void 0)?"optional":void 0),N(e,"optout",(n)=>n.def.options.some((o)=>o._zod.optout==="optional")?"optional":void 0),N(e,"values",(n)=>{if(n.def.options.every((o)=>o._zod.values))return new Set(n.def.options.flatMap((o)=>Array.from(o._zod.values)));return}),N(e,"pattern",(n)=>{if(n.def.options.every((o)=>o._zod.pattern)){let o=n.def.options.map((i)=>i._zod.pattern);return new RegExp(`^(${o.map((i)=>xr(i.source)).join("|")})$`)}return});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,o)=>{if(r)return r(n,o);let i=!1,s=[];for(let a of t.options){let u=a._zod.run({value:n.value,issues:[]},o);if(u instanceof Promise)s.push(u),i=!0;else{if(u.issues.length===0)return u;s.push(u)}}if(!i)return Ga(s,n,e,o);return Promise.all(s).then((a)=>Ga(a,n,e,o))}});var Bc=g("$ZodIntersection",(e,t)=>{L.init(e,t),e._zod.parse=(r,n)=>{let o=r.value,i=t.left._zod.run({value:o,issues:[]},n),s=t.right._zod.run({value:o,issues:[]},n);if(i instanceof Promise||s instanceof Promise)return Promise.all([i,s]).then(([u,c])=>Xa(r,u,c));return Xa(r,i,s)}});function Qn(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(We(e)&&We(t)){let r=Object.keys(t),n=Object.keys(e).filter((i)=>r.indexOf(i)!==-1),o={...e,...t};if(Object.prototype.hasOwnProperty.call(o,"__proto__"))delete o.__proto__;for(let i of n){if(i==="__proto__")continue;let s=Qn(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 r=[];for(let n=0;n<e.length;n++){let o=e[n],i=t[n],s=Qn(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[n,...s.mergeErrorPath]};r.push(s.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Xa(e,t,r){let n=new Map,o,i=new Map,s=(c,l)=>{let p;if(c.code==="unrecognized_keys"&&!c.path?.length)o??(o=c),p=c.keys;else if(c.code==="invalid_key"&&c.origin==="record"&&c.path?.length===1){let f=String(c.path[0]);if(!i.has(f))i.set(f,c);p=[f]}else return!1;for(let f of p){if(!n.has(f))n.set(f,{});n.get(f)[l]=!0}return!0};for(let c of t.issues)if(!s(c,"l"))e.issues.push(c);for(let c of r.issues)if(!s(c,"r"))e.issues.push(c);let a=[...n].filter(([,c])=>c.l&&c.r).map(([c])=>c);if(a.length){let c=o?a.filter((l)=>o.keys.includes(l)):[];if(c.length)e.issues.push({...o,keys:c});for(let l of a)if(!c.includes(l)&&i.has(l))e.issues.push(i.get(l))}let u=Qn(t.value,r.value);if(!u.valid){if(ve(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(u.mergeErrorPath)}`)}return e.value=u.data,e}var jc=g("$ZodRecord",(e,t)=>{L.init(e,t);let r=te.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let i=n.value;if(!We(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),n;let s=[],a=t.keyType._zod.values;if(a&&!t.partial){n.value=r?r.alloc(e,n,{},o):{};let u=new Set;for(let l of a)if(typeof l==="string"||typeof l==="number"||typeof l==="symbol"){if(u.add(typeof l==="number"?l.toString():l),l==="__proto__")continue;let p=t.keyType._zod.run({value:l,issues:[]},o);if(p instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(p.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:p.issues.map((m)=>_e(m,o,ce())),input:l,path:[l],inst:e});continue}let f=p.value;if(f==="__proto__")continue;let d=t.valueType._zod.run({value:i[l],issues:[]},o);if(d instanceof Promise)s.push(d.then((m)=>{if(m.issues.length)n.issues.push(...Fe(l,m.issues));n.value[f]=m.value}));else{if(d.issues.length)n.issues.push(...Fe(l,d.issues));n.value[f]=d.value}}let c;for(let l in i)if(!u.has(l))if(t.mode==="loose"){if(l==="__proto__")continue;n.value[l]=i[l]}else c=c??[],c.push(l);if(c&&c.length>0)n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c,continue:!0})}else{n.value=r?r.alloc(e,n,{},o):{};let u;for(let c of Reflect.ownKeys(i)){if(c==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(i,c))continue;let l=t.keyType._zod.run({value:c,issues:[]},o);if(l instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof c==="string"&&At.test(c)&&l.issues.length){let m=t.keyType._zod.run({value:Number(c),issues:[]},o);if(m instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(m.issues.length===0)l=m}if(l.issues.length){if(t.mode==="loose")n.value[c]=i[c];else if(a)u=u??[],u.push(c);else n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map((m)=>_e(m,o,ce())),input:c,path:[c],inst:e});continue}let f=l.value;if(f==="__proto__")continue;let d=t.valueType._zod.run({value:i[c],issues:[]},o);if(d instanceof Promise)s.push(d.then((m)=>{if(m.issues.length)n.issues.push(...Fe(c,m.issues));n.value[f]=m.value}));else{if(d.issues.length)n.issues.push(...Fe(c,d.issues));n.value[f]=d.value}}if(u&&u.length>0)n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:u,continue:!0})}if(s.length)return Promise.all(s).then(()=>n);return n}});var Fc=g("$ZodEnum",(e,t)=>{L.init(e,t);let r=Zt(t.entries),n=new Set(r);e._zod.values=n,N(e,"pattern",(o)=>{let i=Zt(o.def.entries).filter((s)=>Ns.has(typeof s));return new RegExp(i.length?`^(${i.map((s)=>lt(s.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,i)=>{let s=o.value;if(n.has(s))return o;return o.issues.push({code:"invalid_value",values:r,input:s,inst:e}),o}});var Uc=g("$ZodTransform",(e,t)=>{L.init(e,t),e._zod.optin="optional",te.memoizer?.guard(e),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Ot(e.constructor.name);let o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then((s)=>(r.value=s,r));if(o instanceof Promise)throw new we;return r.value=o,r}});function Ya(e,t){return e.value=t.issues.length?void 0:t.value,e}var no=g("$ZodOptional",(e,t)=>{L.init(e,t),N(e,"optin",(r)=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",N(e,"values",(r)=>{let n=r.def.innerType._zod.values;return n?new Set([...n,void 0]):void 0}),N(e,"pattern",(r)=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${xr(n.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(r.value===void 0){if(t.innerType._zod.optin!=="defaulted")return r;let o=t.innerType._zod.run({value:r.value,issues:[]},n);if(o instanceof Promise)return o.then((i)=>Ya(r,i));return Ya(r,o)}return t.innerType._zod.run(r,n)}}),qc=g("$ZodExactOptional",(e,t)=>{no.init(e,t),N(e,"values",(r)=>r.def.innerType._zod.values),N(e,"pattern",(r)=>r.def.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Vc=g("$ZodNullable",(e,t)=>{L.init(e,t),N(e,"optin",(r)=>r.def.innerType._zod.optin),N(e,"optout",(r)=>r.def.innerType._zod.optout),N(e,"pattern",(r)=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${xr(n.source)}|null)$`):void 0}),N(e,"values",(r)=>r.def.innerType._zod.values?new Set([...r.def.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>{if(r.value===null)return r;return t.innerType._zod.run(r,n)}}),Jc=g("$ZodDefault",(e,t)=>{L.init(e,t),e._zod.optin="defaulted",N(e,"values",(r)=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then((i)=>Wa(i,t));return Wa(o,t)}});function Wa(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var Hc=g("$ZodPrefault",(e,t)=>{L.init(e,t),e._zod.optin="defaulted",N(e,"values",(r)=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)r.value=t.defaultValue;return t.innerType._zod.run(r,n)}}),Kc=g("$ZodNonOptional",(e,t)=>{L.init(e,t),N(e,"values",(r)=>{let n=r.def.innerType._zod.values;return n?new Set([...n].filter((o)=>o!==void 0)):void 0}),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then((i)=>Qa(i,e));return Qa(o,e)}});function Qa(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 ec(e,t,r,n){if(!t.issues.length){if(e.value=t.value,t.memo)e.memo=!0;return e}return e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map((o)=>_e(o,n,ce()))},input:e.value}),e}var Gc=g("$ZodCatch",(e,t)=>{L.init(e,t),N(e,"optin",(r)=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),N(e,"optout",(r)=>r.def.innerType._zod.optout),N(e,"values",(r)=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run({value:r.value,issues:[]},n);if(o instanceof Promise)return o.then((i)=>ec(r,i,t,n));return ec(r,o,t,n)}});var Xc=g("$ZodPipe",(e,t)=>{L.init(e,t),N(e,"values",(r)=>r.def.in._zod.values),N(e,"optin",(r)=>r.def.in._zod.optin),N(e,"optout",(r)=>r.def.out._zod.optout),N(e,"propValues",(r)=>r.def.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){let i=t.out._zod.run(r,n);if(i instanceof Promise)return i.then((s)=>Er(s,t.in,n));return Er(i,t.in,n)}let o=t.in._zod.run(r,n);if(o instanceof Promise)return o.then((i)=>Er(i,t.out,n));return Er(o,t.out,n)}});function Er(e,t,r){if(e.issues.some((n)=>n.code!=="unrecognized_keys"))return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},r)}var Yc=g("$ZodReadonly",(e,t)=>{L.init(e,t),N(e,"propValues",(r)=>r.def.innerType._zod.propValues),N(e,"values",(r)=>r.def.innerType._zod.values),N(e,"optin",(r)=>r.def.innerType?._zod?.optin),N(e,"optout",(r)=>r.def.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then(tc);return tc(o)}});function tc(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var Wc=g("$ZodCustom",(e,t)=>{X.init(e,t),L.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=(r)=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then((i)=>rc(i,r,n,e));rc(o,r,n,e);return}});function rc(e,t,r,n){if(!e){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};if(n._zod.def.params)o.params=n._zod.def.params;t.issues.push(Qe(o))}}class eu extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var io="~memo",Qc=[];function tu(e){return e!==null&&typeof e==="object"}function oo(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var ru=new WeakMap,Nt=0,Mr=1,Rt=2;function Dr(e,t,r){let n=ru.get(e);if(n!==void 0)return n?Rt:Nt;if(t.has(e))return Rt;t.add(e);let o=Nt,i=(l)=>{if(o!==Rt&&l?._zod){let p=Dr(l,t,r);if(p>o)o=p}},s=(l,p)=>{let f=Nt;for(let d of Reflect.ownKeys(l)){let m=Object.getOwnPropertyDescriptor(l,d);if(p&&!m.enumerable)continue;let x=m.get?Mr:m.value?._zod?Dr(m.value,t,r):Nt;if(x>f)f=x}return f},a=(l)=>{if(l>o)o=l},u=e._zod.def,c=u.type;switch(c){case"object":{let l=yr(u);a(l?s(l,!0):Mr),i(u.catchall);break}case"array":i(u.element);break;case"tuple":for(let l of u.items)i(l);i(u.rest);break;case"record":case"map":i(u.keyType),i(u.valueType);break;case"set":i(u.valueType);break;case"union":for(let l of u.options)i(l);break;case"intersection":i(u.left),i(u.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":i(u.innerType);break;case"pipe":i(u.in),i(u.out);break;case"function":i(u.input),i(u.output);break;case"lazy":{let l=u._cachedInner??(r?e._zod.innerType:void 0);a(l?Dr(l,t,!1):Mr);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let l in u){let p=Object.getOwnPropertyDescriptor(u,l);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 d of f)i(d)}}return t.delete(e),Wf(e,o)}function Wf(e,t){if(t!==Mr)ru.set(e,t===Rt);return t}function Qf(e,t){let r=e.buckets.get(t);if(!r)r=new WeakMap,e.buckets.set(t,r);return r}var Nr,Rr=[],ed={alloc(e,t,r){let n=Nr;if(!n)return r;Nr=void 0;let o={value:r,issues:null};return n.set(t.value,o),Rr.push(o),r},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let r=e._zod.parse,n=(o,i)=>{if(i.direction!=="backward"&&td(i,o.value))throw new eu;return r(o,i)};if(e._zod.parse=n,e._zod.run===r)e._zod.run=n})},attach(e){var t;let r,n=!1,o,i;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let s=e._zod.parse,a=(u,c)=>{if(r===void 0){let b=Dr(e,new Set,!1);if(b===Nt){if(e._zod.parse=s,e._zod.run===a)e._zod.run=s;return s(u,c)}if(b===Rt||n)r=!0;else n=!0}let l=u.value;if(!tu(l))return s(u,c);let p=c[io];if(!p)p={buckets:new WeakMap,backEdges:void 0},c[io]=p;let f;if(o===c)f=i;else f=Qf(p,e),o=c,i=f;let d=f.get(l);if(d){if(u.value=d.value,d.issues){if(d.issues.length)u.issues.push(...oo(d.issues))}else u.memo=!0,p.backEdges??(p.backEdges=new WeakSet),p.backEdges.add(d.value);return u}Nr=f;let m=Rr.length,x=s(u,c);Nr=void 0;let v=Rr.length>m?Rr.pop():void 0;if(x instanceof Promise)return x.then((b)=>{if(v)v.issues=b.issues.length?oo(b.issues):Qc;return b});if(v)v.issues=x.issues.length?oo(x.issues):Qc;return x};if(e._zod.parse=a,e._zod.run===s)e._zod.run=a})}};function nu(){return ed}function td(e,t){let r=e[io]?.backEdges;return r!==void 0&&tu(t)&&r.has(t)}var rd=()=>{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 r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};function o(i,s){if(i==="number"&&typeof s==="number"&&!Number.isFinite(s))return String(s);return n[i]??i}return(i)=>{switch(i.code){case"invalid_type":{let s=o(i.expected),a=Bs(i.input),u=o(a,i.input);return`Invalid input: expected ${s}, received ${u}`}case"invalid_value":if(i.values.length===1)return`Invalid input: expected ${Dn(i.values[0])}`;return`Invalid option: expected one of ${Nn(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 ${r[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":""}: ${Nn(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 so(){return{localeError:rd()}}var ou;class iu{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let r=t[0];if(this._map.set(e,r),r&&typeof r==="object"&&"id"in r)this._idmap.set(r.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let r={...this.get(t)??{}};delete r.id;let n={...r,...this._map.get(e)};return Object.keys(n).length?n:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function nd(){return new iu}(ou=globalThis).__zod_globalRegistry??(ou.__zod_globalRegistry=nd());var et=globalThis.__zod_globalRegistry;function su(e){if(e.checks)e.checks=[...e.checks];return e}function au(e,t){return new e(su({type:"string",...k(t)}))}function cu(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...k(t)})}function uu(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...k(t)})}function ao(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...k(t)})}function lu(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...k(t)})}function pu(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...k(t)})}function fu(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...k(t)})}function du(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...k(t)})}function mu(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...k(t)})}function hu(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...k(t)})}function gu(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...k(t)})}function xu(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...k(t)})}function yu(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...k(t)})}function bu(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...k(t)})}function vu(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...k(t)})}function _u(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...k(t)})}function wu(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...k(t)})}function ku(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...k(t)})}function zu(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...k(t)})}function $u(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...k(t)})}function Su(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...k(t)})}function Iu(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...k(t)})}function Pu(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...k(t)})}function Zu(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...k(t)})}function Eu(e,t){return new e({type:"string",format:"date",check:"string_format",...k(t)})}function Ou(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...k(t)})}function Au(e,t){return new e({type:"string",format:"duration",check:"string_format",...k(t)})}function Cu(e,t){return new e(su({type:"number",checks:[],...k(t)}))}function Tu(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...k(t)})}function Nu(e,t){return new e({type:"boolean",...k(t)})}function Ru(e){return new e({type:"unknown"})}function Mu(e,t){return new e({type:"never",...k(t)})}function Lr(e,t){return new Xn({check:"less_than",...k(t),value:e,inclusive:!1})}function Mt(e,t){return new Xn({check:"less_than",...k(t),value:e,inclusive:!0})}function Br(e,t){return new Yn({check:"greater_than",...k(t),value:e,inclusive:!1})}function Dt(e,t){return new Yn({check:"greater_than",...k(t),value:e,inclusive:!0})}function jr(e,t){return new Ca({check:"multiple_of",...k(t),value:e})}function Fr(e,t){return new Na({check:"max_length",...k(t),maximum:e})}function pt(e,t){return new Ra({check:"min_length",...k(t),minimum:e})}function Ur(e,t){return new Ma({check:"length_equals",...k(t),length:e})}function co(e,t){return new Da({check:"string_format",format:"regex",...k(t),pattern:e})}function uo(e){return new La({check:"string_format",format:"lowercase",...k(e)})}function lo(e){return new Ba({check:"string_format",format:"uppercase",...k(e)})}function po(e,t){return new ja({check:"string_format",format:"includes",...k(t),includes:e})}function fo(e,t){return new Fa({check:"string_format",format:"starts_with",...k(t),prefix:e})}function mo(e,t){return new Ua({check:"string_format",format:"ends_with",...k(t),suffix:e})}function Ue(e){return new qa({check:"overwrite",tx:e})}function ho(e){return Ue((t)=>t.normalize(e))}function go(){return Ue((e)=>e.trim())}function xo(){return Ue((e)=>e.toLowerCase())}function yo(){return Ue((e)=>e.toUpperCase())}function bo(){return Ue((e)=>Cs(e))}function Du(e,t,r){return new e({type:"array",element:t,...k(r)})}function Lu(e,t,r){return new e({type:"custom",check:"custom",fn:t,...k(r)})}function Bu(e,t){let r=od((n)=>(n.addIssue=(o)=>{if(typeof o==="string")n.issues.push(Qe(o,n.value,r._zod.def));else{let i=o;if(i.fatal)i.continue=!1;if(i.code??(i.code="custom"),!("input"in i))i.input=n.value;i.inst??(i.inst=r),i.continue??(i.continue=!r._zod.def.abort),n.issues.push(Qe(i))}},e(n.value,n)),t);return r}function od(e,t){let r=new X({check:"custom",...k(t)});return r._zod.check=e,r}function Lt(e,...t){for(let r of t)for(let n of Reflect.ownKeys(r))if(Object.prototype.propertyIsEnumerable.call(r,n))me(e,n,r[n]);return e}function _o(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??et,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 tt(e,t,r,n,o){let i=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:n.path,message:o}):t.unrepresentable;if(i==="any")return!1;if(i===void 0||i==="throw")throw Error(o);return Object.assign(r,i),!0}function V(e,t,r={path:[],schemaPath:[]}){var n;let o=e._zod.def,i=t.seen.get(e);if(i){if(i.count++,r.schemaPath.includes(e))i.cycle=r.path;return i.schema}let s={schema:{},count:1,cycle:void 0,path:r.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 l={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,l);else{let f=s.schema,d=t.processors[o.type];if(!d)throw Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);d(e,t,f,l)}let p=e._zod.parent;if(p){if(!s.ref)s.ref=p;V(p,t,l),t.seen.get(p).isParent=!0}}let u=t.metadataRegistry.get(e);if(u)Lt(s.schema,u);if(t.io==="input"&&Q(e))delete s.schema.examples,delete s.schema.default;if(t.io==="input"&&"_prefault"in s.schema)(n=s.schema).default??(n.default=s.schema._prefault);return delete s.schema._prefault,t.seen.get(e).schema}function ju(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function wo(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let n=new Map;for(let s of e.seen.entries()){let a=e.metadataRegistry.get(s[0])?.id;if(a){let u=n.get(a);if(u&&u!==s[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(a,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??((m)=>m);if(p)return{ref:f(p)};let d=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=d,{defId:d,ref:`${f("__shared")}#/${a}/${ju(d)}`}}let u="#",c=`${u}/${a}/`;if(s[1]===r&&!s[1].schema.id)return{ref:u};let l=s[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:c+ju(l)}},i=(s)=>{if(s[1].schema.$ref)return;let a=s[1],{ref:u,defId:c}=o(s);if(a.def={...a.schema},c)a.defId=c;let l=a.schema;for(let p in l)delete l[p];l.$ref=u};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>
56
+
57
+ 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 c=e.external.registry.get(s[0])?.id;if(t!==s[0]&&c){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 qu(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let n of t){if(!n||typeof n!=="object")return;qu(n);let o=Object.keys(n);if(o.length!==1||o[0]!=="type")return;let i=n.type;for(let s of Array.isArray(i)?i:[i]){if(typeof s!=="string")return;if(!r.includes(s))r.push(s)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var Vu=new Set(["type","properties","required","additionalProperties"]),Fu=["oneOf","anyOf"];function Uu(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 vo(e){let t=[];for(let i of e){if(typeof i!=="object"||i.type!=="object")return null;for(let s in i)if(!Vu.has(s))return null;t.push(i)}let r={},n=new Set;for(let i of t){for(let s in i.properties){if(Object.prototype.hasOwnProperty.call(r,s))continue;let a=[];for(let c of t){let l=c.properties?.[s]??Uu(c);if(l===null||l===void 0)continue;if(!a.some((p)=>JSON.stringify(p)===JSON.stringify(l)))a.push(l)}let u=a.length===1?a[0]:vo(a)??{allOf:a};me(r,s,u)}for(let s of i.required??[])n.add(s)}let o={type:"object",properties:r};if(n.size)o.required=[...n];if(t.every((i)=>i.additionalProperties===!1))o.additionalProperties=!1;else{let i=[];for(let s of t){let a=Uu(s);if(a&&!i.some((u)=>JSON.stringify(u)===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 id(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of Vu)if(o in e)return;let r=t.filter((o)=>Fu.some((i)=>Array.isArray(o[i]))),n=null;if(!r.length)n=vo(t);else{let o=r[0],i=Fu.find((u)=>Array.isArray(o[u]));if(Object.keys(o).length!==1)return;let s=t.filter((u)=>u!==o),a=o[i].map((u)=>vo([...s,u]));if(a.some((u)=>!u))return;n={[i]:a}}if(!n)return;delete e.allOf,Lt(e,n)}function ko(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let n=(a)=>{let u=e.seen.get(a);if(u.ref===null)return;let c=u.def??u.schema,l={...c},p=u.ref;if(u.ref=null,p){n(p);let d=e.seen.get(p),m=d.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))c.allOf=c.allOf??[],c.allOf.push(m);else Lt(c,m);if(Lt(c,l),a._zod.parent===p)for(let v in c){if(v==="$ref"||v==="allOf")continue;if(!(v in l))delete c[v]}if(m.$ref&&d.def)for(let v in c){if(v==="$ref"||v==="allOf")continue;if(v in d.def&&JSON.stringify(c[v])===JSON.stringify(d.def[v]))delete c[v]}}let f=a._zod.parent;if(f&&f!==p){n(f);let d=e.seen.get(f);if(d?.schema.$ref){if(c.$ref=d.schema.$ref,d.def)for(let m in c){if(m==="$ref"||m==="allOf")continue;if(m in d.def&&JSON.stringify(c[m])===JSON.stringify(d.def[m]))delete c[m]}}}e.override({zodSchema:a,jsonSchema:c,path:u.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())n(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())qu(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let u of e.seen.values())for(let c of[u.schema,u.def]){let l=c?.allOf;if(!Array.isArray(l))continue;let p=a.get(l);if(p)p.push(c);else a.set(l,[c])}for(let u of e.intersections)for(let c of a.get(u)??[])id(c)}}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)}Lt(o,r.defId?r.schema:r.def??r.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 u=a[1];if(u.def&&u.defId){if(u.def.id===u.defId)delete u.def.id;me(s,u.defId,u.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:Bt(t,"input",e.processors),output:Bt(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function Q(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return Q(n.element,r);if(n.type==="set")return Q(n.valueType,r);if(n.type==="lazy")return Q(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault"||n.type==="catch")return Q(n.innerType,r);if(n.type==="intersection")return Q(n.left,r)||Q(n.right,r);if(n.type==="record"||n.type==="map")return Q(n.keyType,r)||Q(n.valueType,r);if(n.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return Q(n.in,r)||Q(n.out,r)}if(n.type==="object"){for(let o in n.shape)if(Q(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(Q(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(Q(o,r))return!0;if(n.rest&&Q(n.rest,r))return!0;return!1}return!1}var Ju=(e,t={})=>(r)=>{let n=_o({...r,processors:t});return V(e,n),wo(n,e),ko(n,e)},Bt=(e,t,r={})=>(n)=>{let{libraryOptions:o,target:i}=n??{},s=_o({...o??{},target:i,io:t,processors:r});return V(e,s),wo(s,e),ko(s,e)};var ft=(e,t,r)=>{if(e[t]===void 0||r>e[t])e[t]=r},dt=(e,t,r)=>{if(e[t]===void 0||r<e[t])e[t]=r},Hu=(e,t)=>{ft(e,"minimum",t),dt(e,"maximum",t)},Yu=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},Wu=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Qu=(e,t)=>{e.mime=e.mime?e.mime.filter((r)=>t.includes(r)):[...t]},el=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},Ku=(e,t)=>ft(e,"minimum",t.minimum),Gu=(e,t)=>dt(e,"maximum",t.maximum),Xu=(e)=>(t,r)=>{el(t,r.format);let[n,o]=e[r.format];ft(t,"minimum",n),dt(t,"maximum",o)},sd={greater_than:(e,t)=>ft(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>dt(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Yu(e,t.value),number_format:Xu(br),bigint_format:Xu(Ln),min_length:Ku,max_length:Gu,length_equals:(e,t)=>Hu(e,t.length),min_size:Ku,max_size:Gu,size_equals:(e,t)=>Hu(e,t.size),string_format:(e,t)=>{if(el(e,t.format),t.pattern)Wu(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)=>Qu(e,t.mime)};function pe(e){let t={},r=e._zod.def,n=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let i of n)sd[i._zod.def.check]?.(t,i._zod.def);let o=e._zod.bag;if(o.minimum!==void 0)ft(t,"minimum",o.minimum);if(o.exclusiveMinimum!==void 0)ft(t,"exclusiveMinimum",o.exclusiveMinimum);if(o.maximum!==void 0)dt(t,"maximum",o.maximum);if(o.exclusiveMaximum!==void 0)dt(t,"exclusiveMaximum",o.exclusiveMaximum);if(o.multipleOf!==void 0)Yu(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)Qu(t,o.mime);for(let i of o.patterns??[])Wu(t,i);return t}var ad={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},cd=new Map([[to,_a],[Tr,wa]]),tl=(e)=>cd.get(e)??e,rl=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:i,maximum:s,format:a,patterns:u,contentEncoding:c,laxFormat:l}=pe(e);if(typeof i==="number")o.minLength=i;if(typeof s==="number")o.maxLength=s;if(a){if(o.format=ad[a]??a,o.format==="")delete o.format;if(a==="time"||l)delete o.format}if(c)o.contentEncoding=c;if(u&&u.size>0){let p=[...u].map(tl);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}))]}},nl=(e,t,r,n)=>{let o=r,{minimum:i,maximum:s,multipleOf:a,exclusiveMaximum:u,exclusiveMinimum:c,isInt:l}=pe(e);o.type=l?"integer":"number";let p=typeof c==="number"&&c>=(i??Number.NEGATIVE_INFINITY),f=typeof u==="number"&&u<=(s??Number.POSITIVE_INFINITY),d=t.target==="draft-04"||t.target==="openapi-3.0";if(p)if(d)o.minimum=c,o.exclusiveMinimum=!0;else o.exclusiveMinimum=c;else if(typeof i==="number")o.minimum=i;if(f)if(d)o.maximum=u,o.exclusiveMaximum=!0;else o.exclusiveMaximum=u;else if(typeof s==="number")o.maximum=s;if(a){let m=new Set;for(let b of a)if(Number.isFinite(b)&&b!==0)m.add(Math.abs(b));else tt(e,t,o,n,`A multipleOf divisor of ${b} cannot be represented in JSON Schema`);let[x,...v]=m;if(x!==void 0)o.multipleOf=x;if(v.length)o.allOf=[...o.allOf??[],...v.map((b)=>({multipleOf:b}))]}},ol=(e,t,r,n)=>{r.type="boolean"};var il=(e,t,r,n)=>{r.not={}};var sl=(e,t,r,n)=>{};var al=(e,t,r,n)=>{let o=e._zod.def,i=Zt(o.entries);if(i.length===0){r.not={};return}if(i.every((s)=>typeof s==="number"))r.type="number";if(i.every((s)=>typeof s==="string"))r.type="string";r.enum=i};var cl=(e,t,r,n)=>{tt(e,t,r,n,"Custom types cannot be represented in JSON Schema")};var ul=(e,t,r,n)=>{tt(e,t,r,n,"Transforms cannot be represented in JSON Schema")};var ll=(e,t,r,n)=>{let o=r,i=e._zod.def,{minimum:s,maximum:a}=pe(e);if(typeof s==="number")o.minItems=s;if(typeof a==="number")o.maxItems=a;o.type="array",o.items=V(i.element,t,{...n,path:[...n.path,"items"]})};function qr(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return qr(t.out);if(t.type==="catch")return qr(t.innerType);return e._zod.optin}var pl=(e,t,r,n)=>{let o=r,i=e._zod.def,s=i.shape;if(Object.getOwnPropertySymbols(s).length&&tt(e,t,o,n,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let c in s)me(o.properties,c,V(s[c],t,{...n,path:[...n.path,"properties",c]}));let u=[];for(let c of Object.keys(s)){let l=i.shape[c];if(t.io==="input"?qr(l)===void 0:l._zod.optout===void 0)u.push(c)}if(u.length>0)o.required=u;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=V(i.catchall,t,{...n,path:[...n.path,"additionalProperties"]})},fl=(e,t,r,n)=>{let o=e._zod.def,i=o.inclusive===!1,s=o.options.map((a,u)=>V(a,t,{...n,path:[...n.path,i?"oneOf":"anyOf",u]}));if(i)r.oneOf=s;else r.anyOf=s},dl=(e,t,r,n)=>{let o=e._zod.def,i=V(o.left,t,{...n,path:[...n.path,"allOf",0]}),s=V(o.right,t,{...n,path:[...n.path,"allOf",1]}),a=(c)=>("allOf"in c)&&Object.keys(c).length===1,u=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];r.allOf=u,t.intersections.push(u)};function zo(e,t,r){if(t.$ref){if(r.has(t))return t;r.add(t);let m=e.get(t)?.def;if(!m)return t;let x=zo(e,m,r);return x===m?t:x}for(let m of["anyOf","oneOf"]){let x=t[m];if(!Array.isArray(x))continue;let v=x.map((b)=>zo(e,b,r));if(v.some((b,Z)=>b!==x[Z]))t={...t,[m]:v}}let n=Array.isArray(t.type)?t.type:[t.type],o=!n.includes("string")&&n.some((m)=>m==="number"||m==="integer"),i=t.enum??(t.const!==void 0?[t.const]:void 0);if(!o&&!i?.some((m)=>typeof m==="number"))return t;let{minimum:s,maximum:a,exclusiveMinimum:u,exclusiveMaximum:c,multipleOf:l,format:p,id:f,...d}=t;if(d.enum)d.enum=d.enum.map((m)=>typeof m==="number"?String(m):m);else if(typeof d.const==="number")d.const=String(d.const);if(!o)return d;if(d.type="string",!i)d.pattern=(n.includes("number")?At:Kn).source;return d}var $o=new WeakMap;function ud(e){let t=new Map;for(let n of e.seen.values())if(n.def&&!t.has(n.schema))t.set(n.schema,n);let r=new Map;for(let n of $o.get(e)??[]){let o=e.seen.get(n),i=(o?.def??o?.schema)?.propertyNames;if(!i||i===!0||r.has(i))continue;let s=zo(t,i,new Set);if(s!==i)r.set(i,s)}if(!r.size)return;for(let n of e.seen.values())for(let o of[n.schema,n.def]){let i=o&&r.get(o.propertyNames);if(i)o.propertyNames=i}}var ml=(e,t,r,n)=>{let o=r,i=e._zod.def;o.type="object";let s=i.keyType,a=pe(s).patterns;if(i.mode==="loose"&&a&&a.size>0){let l=V(i.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let p of a)me(o.patternProperties,tl(p).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=V(i.keyType,t,{...n,path:[...n.path,"propertyNames"]});let l=$o.get(t);if(!l)l=[],$o.set(t,l),t.deferred.push(()=>ud(t));l.push(e)}o.additionalProperties=V(i.valueType,t,{...n,path:[...n.path,"additionalProperties"]})}let u=s._zod.values,c=t.io==="input"&&qr(i.valueType)!==void 0;if(u&&!i.partial&&!c){let l=[...u].filter((p)=>typeof p==="string"||typeof p==="number");if(l.length>0)o.required=l.map(String)}},hl=(e,t,r,n)=>{let o=e._zod.def,i=V(o.innerType,t,n),s=t.seen.get(e);if(t.target==="openapi-3.0")s.ref=o.innerType,r.nullable=!0;else r.anyOf=[i,{type:"null"}]},gl=(e,t,r,n)=>{let o=e._zod.def;V(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType},So=Symbol();function xl(e,t,r,n,o){let i=!1,s=JSON.stringify(e,(a,u)=>{if(typeof u!=="bigint")return u;return i=!0,null});if(!i)return JSON.parse(s);return tt(t,r,n,o,"BigInt defaults cannot be represented in JSON Schema"),So}var yl=(e,t,r,n)=>{let o=e._zod.def;V(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType;let s=xl(o.defaultValue,e,t,r,n);if(s!==So)r.default=s},bl=(e,t,r,n)=>{let o=e._zod.def;V(o.innerType,t,n);let i=t.seen.get(e);if(i.ref=o.innerType,t.io!=="input")return;let s=xl(o.defaultValue,e,t,r,n);if(s!==So)r._prefault=s},vl=(e,t,r,n)=>{let o=e._zod.def;V(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType;let s;try{s=o.catchValue(void 0)}catch{tt(e,t,r,n,"Dynamic catch values are not supported in JSON Schema");return}r.default=s},_l=(e,t,r,n)=>{let o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?i?o.out:o.in:o.out;V(s,t,n);let a=t.seen.get(e);a.ref=s},wl=(e,t,r,n)=>{let o=e._zod.def;V(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType,r.readOnly=!0};var Io=(e,t,r,n)=>{let o=e._zod.def;V(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType};var kl=new WeakSet([Object.prototype,Error.prototype]);function Vr(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let n=r(this);return Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0})}})}var xd=(e,t)=>{Ks.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);if(kl.has(r))return;kl.add(r),Vr(r,"format",(n)=>(o)=>Xs(n,o)),Vr(r,"flatten",(n)=>(o)=>Gs(n,o)),Vr(r,"addIssue",(n)=>(o)=>{n.issues.push(o),n.message=JSON.stringify(n.issues,Et,2)}),Vr(r,"addIssues",(n)=>(o)=>{n.issues.push(...o),n.message=JSON.stringify(n.issues,Et,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var ue=g("ZodError",xd,void 0,{Parent:Error});var zl=$r(ue),$l=Sr(ue),Sl=Ir(ue),Il=Pr(ue),Pl=Ws(ue),Zl=Qs(ue),El=ea(ue),Ol=ta(ue),Al=ra(ue),Cl=na(ue),Tl=oa(ue),Nl=ia(ue);function bd(){if(!te.localeError)ce(so())}function Jr(){if(!te.memoizer)ce({memoizer:nu()})}var F=g("ZodType",(e,t)=>(bd(),L.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(ae(t,{checks:[...t.checks??[],...e.map((r)=>typeof r==="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return be(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(hm(e,t))},superRefine(e,t){return this.check(gm(e,t))},overwrite(e){return this.check(Ue(e))},optional(){return Ll(this)},exactOptional(){return rm(this)},nullable(){return Bl(this)},nullish(){return Ll(Bl(this))},nonoptional(e){return cm(this,e)},array(){return re(this)},or(e){return Yd([this,e])},and(e){return Qd(this,e)},transform(e){return jl(this,tm(e))},default(e){return im(this,e)},prefault(e){return am(this,e)},catch(e){return lm(this,e)},pipe(e){return jl(this,e)},readonly(){return dm(this)},describe(e){let t=this.clone();return et.add(t,{description:e}),t},meta(...e){if(e.length===0)return et.get(this);let t=this.clone();return et.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 kr(this,"~standard",{...eo(this),jsonSchema:{input:Bt(this,"input"),output:Bt(this,"output")}})},set "~standard"(e){Ae(this,"~standard",e)},parse:function e(t,r){return zl(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await $l(this,t,r,{callee:e})},safeParse(e,t){return Sl(this,e,t)},async safeParseAsync(e,t){return Il(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Ae(this,"spa",e)},validate(e,t){return qn(this,e,t)},validateAsync(e,t){return Vn(this,e,t)},encode:function e(t,r){return Pl(this,t,r,{callee:e})},decode:function e(t,r){return Zl(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await El(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await Ol(this,t,r,{callee:e})},safeEncode(e,t){return Al(this,e,t)},safeDecode(e,t){return Cl(this,e,t)},async safeEncodeAsync(e,t){return Tl(this,e,t)},async safeDecodeAsync(e,t){return Nl(this,e,t)},toJSONSchema(e){return Ju(this,{})(e)},get description(){return et.get(this)?.description},get _def(){return this._zod.def}}),Fl=g("_ZodString",(e,t)=>{Cr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>rl(e,r,n,o)},Fs({format:(e)=>pe(e).format??null,minLength:(e)=>pe(e).minimum??null,maxLength:(e)=>pe(e).maximum??null},{regex(...e){return this.check(co(...e))},includes(...e){return this.check(po(...e))},startsWith(...e){return this.check(fo(...e))},endsWith(...e){return this.check(mo(...e))},min(...e){return this.check(pt(...e))},max(...e){return this.check(Fr(...e))},length(...e){return this.check(Ur(...e))},nonempty(...e){return this.check(pt(1,...e))},lowercase(e){return this.check(uo(e))},uppercase(e){return this.check(lo(e))},trim(){return this.check(go())},normalize(...e){return this.check(ho(...e))},toLowerCase(){return this.check(xo())},toUpperCase(){return this.check(yo())},slugify(){return this.check(bo())}})),vd=g("ZodString",(e,t)=>{Cr.init(e,t),Fl.init(e,t)},{email(e){return this.check(cu($d,e))},url(e){return this.check(du(Id,e))},jwt(e){return this.check(Pu(Fd,e))},emoji(e){return this.check(mu(Pd,e))},guid(e){return this.check(uu(Sd,e))},uuid(e){return this.check(ao(jt,e))},uuidv4(e){return this.check(lu(jt,e))},uuidv6(e){return this.check(pu(jt,e))},uuidv7(e){return this.check(fu(jt,e))},nanoid(e){return this.check(hu(Zd,e))},cuid(e){return this.check(gu(Ed,e))},cuid2(e){return this.check(xu(Od,e))},ulid(e){return this.check(yu(Ad,e))},base64(e){return this.check($u(Ld,e))},base64url(e){return this.check(Su(Bd,e))},xid(e){return this.check(bu(Cd,e))},ksuid(e){return this.check(vu(Td,e))},ipv4(e){return this.check(_u(Nd,e))},ipv6(e){return this.check(wu(Rd,e))},cidrv4(e){return this.check(ku(Md,e))},cidrv6(e){return this.check(zu(Dd,e))},e164(e){return this.check(Iu(jd,e))},datetime(e){return this.check(Zu(_d,e))},date(e){return this.check(Eu(wd,e))},time(e){return this.check(Ou(kd,e))},duration(e){return this.check(Au(zd,e))}});function S(e){return au(vd,e)}var B=g("ZodStringFormat",(e,t)=>{M.init(e,t),Fl.init(e,t)}),_d=g("ZodISODateTime",(e,t)=>{xc.init(e,t),B.init(e,t)}),wd=g("ZodISODate",(e,t)=>{yc.init(e,t),B.init(e,t)}),kd=g("ZodISOTime",(e,t)=>{bc.init(e,t),B.init(e,t)}),zd=g("ZodISODuration",(e,t)=>{vc.init(e,t),B.init(e,t)}),$d=g("ZodEmail",(e,t)=>{sc.init(e,t),B.init(e,t)});var Sd=g("ZodGUID",(e,t)=>{oc.init(e,t),B.init(e,t)});var jt=g("ZodUUID",(e,t)=>{ic.init(e,t),B.init(e,t)});function Hr(e){return ao(jt,e)}var Id=g("ZodURL",(e,t)=>{uc.init(e,t),B.init(e,t)});var Pd=g("ZodEmoji",(e,t)=>{lc.init(e,t),B.init(e,t)});var Zd=g("ZodNanoID",(e,t)=>{pc.init(e,t),B.init(e,t)});var Ed=g("ZodCUID",(e,t)=>{fc.init(e,t),B.init(e,t)});var Od=g("ZodCUID2",(e,t)=>{dc.init(e,t),B.init(e,t)});var Ad=g("ZodULID",(e,t)=>{mc.init(e,t),B.init(e,t)});var Cd=g("ZodXID",(e,t)=>{hc.init(e,t),B.init(e,t)});var Td=g("ZodKSUID",(e,t)=>{gc.init(e,t),B.init(e,t)});var Nd=g("ZodIPv4",(e,t)=>{_c.init(e,t),B.init(e,t)});var Rd=g("ZodIPv6",(e,t)=>{kc.init(e,t),B.init(e,t)});var Md=g("ZodCIDRv4",(e,t)=>{zc.init(e,t),B.init(e,t)});var Dd=g("ZodCIDRv6",(e,t)=>{$c.init(e,t),B.init(e,t)});var Ld=g("ZodBase64",(e,t)=>{Ic.init(e,t),B.init(e,t)});var Bd=g("ZodBase64URL",(e,t)=>{Pc.init(e,t),B.init(e,t)});var jd=g("ZodE164",(e,t)=>{Zc.init(e,t),B.init(e,t)});var Fd=g("ZodJWT",(e,t)=>{Ec.init(e,t),B.init(e,t)});var Ul=g("ZodNumber",(e,t)=>{ro.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>nl(e,r,n,o),e.isFinite=!0},Fs({minValue:(e)=>{let{minimum:t,exclusiveMinimum:r}=pe(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:r}=pe(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:r}=pe(e);return!!t||!!r?.some(Number.isSafeInteger)},format:(e)=>pe(e).format??null},{gt(e,t){return this.check(Br(e,t))},gte(e,t){return this.check(Dt(e,t))},min(e,t){return this.check(Dt(e,t))},lt(e,t){return this.check(Lr(e,t))},lte(e,t){return this.check(Mt(e,t))},max(e,t){return this.check(Mt(e,t))},int(e){return this.check(Rl(e))},safe(e){return this.check(Rl(e))},positive(e){return this.check(Br(0,e))},nonnegative(e){return this.check(Dt(0,e))},negative(e){return this.check(Lr(0,e))},nonpositive(e){return this.check(Mt(0,e))},multipleOf(e,t){return this.check(jr(e,t))},step(e,t){return this.check(jr(e,t))},finite(){return this}}));function Ud(e){return Cu(Ul,e)}var qd=g("ZodNumberFormat",(e,t)=>{Oc.init(e,t),Ul.init(e,t)});function Rl(e){return Tu(qd,e)}var Vd=g("ZodBoolean",(e,t)=>{Ac.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ol(e,r,n,o)});function rt(e){return Nu(Vd,e)}var Jd=g("ZodUnknown",(e,t)=>{Cc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>sl(e,r,n,o)});function Ml(){return Ru(Jd)}var Hd=g("ZodNever",(e,t)=>{Tc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>il(e,r,n,o)});function ql(e){return Mu(Hd,e)}var Kd=g("ZodArray",(e,t)=>{Jr(),Nc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ll(e,r,n,o),e.element=t.element},{min(e,t){return this.check(pt(e,t))},nonempty(e){return this.check(pt(1,e))},max(e,t){return this.check(Fr(e,t))},length(e,t){return this.check(Ur(e,t))},unwrap(){return this.element}});function re(e,t){return Du(Kd,e,t)}var Vl=g("ZodObject",(e,t)=>{Jr(),Dc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>pl(e,r,n,o),Pf(e,"shape",(r)=>r._zod.def.shape,!1)},{keyof(){return Gr(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(ae(this._zod.def,{catchall:e}))},passthrough(){return this.clone(ae(this._zod.def,{catchall:Ml()}))},loose(){return this.clone(ae(this._zod.def,{catchall:Ml()}))},strict(){return this.clone(ae(this._zod.def,{catchall:ql()}))},strip(){return this.clone(ae(this._zod.def,{catchall:void 0}))},extend(e){return vf(this,e)},safeExtend(e){return _f(this,e)},merge(e){return wf(this,e)},pick(e){return yf(this,e)},omit(e){return bf(this,e)},partial(...e){return Ds(Jl,this,e[0])},exactPartial(...e){return Ds(Hl,this,e[0],"exactPartial")},required(...e){return kf(Kl,this,e[0])}});function Gd(e,t){let r={type:"object",shape:e??{},...k(t)};return new Vl(r)}function K(e,t){return new Vl({type:"object",shape:e,catchall:ql(),...k(t)})}var Xd=g("ZodUnion",(e,t)=>{Lc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>fl(e,r,n,o),e.options=t.options});function Yd(e,t){return new Xd({type:"union",options:e,...k(t)})}var Wd=g("ZodIntersection",(e,t)=>{Bc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>dl(e,r,n,o)});function Qd(e,t){return new Wd({type:"intersection",left:e,right:t})}var Dl=g("ZodRecord",(e,t)=>{Jr(),jc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ml(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function Kr(e,t,r){if(!t||!t._zod)return new Dl({type:"record",keyType:S(),valueType:e,...k(t)});return new Dl({type:"record",keyType:e,valueType:t,...k(r)})}var Zo=g("ZodEnum",(e,t)=>{Fc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(n,o,i)=>al(e,n,o,i),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{let i={};for(let s of n)if(r.has(s))i[s]=t.entries[s];else throw Error(`Key ${s} not found in enum`);return new Zo({...t,checks:[],...k(o),entries:i})},e.exclude=(n,o)=>{let i={...t.entries};for(let s of n)if(r.has(s))delete i[s];else throw Error(`Key ${s} not found in enum`);return new Zo({...t,checks:[],...k(o),entries:i})}});function Gr(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map((n)=>[n,n])):e;return new Zo({type:"enum",entries:r,...k(t)})}var em=g("ZodTransform",(e,t)=>{Jr(),Uc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ul(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Ot(e.constructor.name);r.addIssue=(i)=>{if(typeof i==="string")r.issues.push(Qe(i,r.value,t));else{let s=i;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=r.value;s.inst??(s.inst=e),r.issues.push(Qe(s))}};let o=t.transform(r.value,r);if(o instanceof Promise)return o.then((i)=>(r.value=i,r));return r.value=o,r}});function tm(e){return new em({type:"transform",transform:e})}var Jl=g("ZodOptional",(e,t)=>{no.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Io(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Ll(e){return new Jl({type:"optional",innerType:e})}var Hl=g("ZodExactOptional",(e,t)=>{qc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Io(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function rm(e){return new Hl({type:"optional",innerType:e})}var nm=g("ZodNullable",(e,t)=>{Vc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>hl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Bl(e){return new nm({type:"nullable",innerType:e})}var om=g("ZodDefault",(e,t)=>{Jc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>yl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function im(e,t){return new om({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():Mn(t)}})}var sm=g("ZodPrefault",(e,t)=>{Hc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>bl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function am(e,t){return new sm({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():Mn(t)}})}var Kl=g("ZodNonOptional",(e,t)=>{Kc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>gl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function cm(e,t){return new Kl({type:"nonoptional",innerType:e,...k(t)})}var um=g("ZodCatch",(e,t)=>{Gc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>vl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function lm(e,t){return new um({type:"catch",innerType:e,catchValue:typeof t==="function"?t:Us(t)})}var pm=g("ZodPipe",(e,t)=>{Xc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>_l(e,r,n,o),e.in=t.in,e.out=t.out});function jl(e,t){return new pm({type:"pipe",in:e,out:t})}var fm=g("ZodReadonly",(e,t)=>{Yc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>wl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function dm(e){return new fm({type:"readonly",innerType:e})}var mm=g("ZodCustom",(e,t)=>{Wc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>cl(e,r,n,o)});function hm(e,t={}){return Lu(mm,e,t)}function gm(e,t){return Bu(e,t)}var mt=Gr(["global","private","shared"]),xm=S().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/).max(48),ht=K({name:xm,description:S().trim().min(1).max(300),body:S().trim().min(1).max(24000)}),Eo=K({scope:mt,choices:Kr(S().max(128),rt()),edits:Kr(S().max(128),S().min(1).max(48000)).default({}),custom:re(ht).max(40).default([])}),u0=Eo.extend({directory:S(),id:S()});var ym=K({id:S(),title:S(),parentId:S().nullable()}),bm=K({id:S(),itemIds:re(S()).min(1),parentId:S(),relatedHubIds:re(S()).max(2)}),Xr=K({hubs:re(ym),leaves:re(bm)});var vm=K({id:S(),name:S(),title:S(),description:S(),text:S(),kind:Gr(["preference","skill"]),category:S().nullable(),section:S().nullable(),axis:S().nullable(),owner:Gr(["packaged","managed","user","provider"])}),Gl=K({scope:mt,input:Eo,inherited:Kr(S(),rt()),locked:Kr(S(),rt()),items:re(vm),constellation:Xr,requirements:re(S()),libraryEnabled:rt(),migrationRequired:rt(),revisionId:S().nullable()}),Xl=K({id:Hr(),changes:re(K({path:S(),before:S().nullable(),after:S().nullable(),internal:rt()})),warnings:re(S())}),Oo=K({revisionId:S().nullable()});var Ao=window.location.hash.slice(1),_m=Ao||sessionStorage.getItem("shadowclone-session")||"";if(Ao)sessionStorage.setItem("shadowclone-session",Ao),history.replaceState(null,"",`${location.pathname}${location.search}`);async function ne(e){let t=await fetch(e.path,{method:e.body===void 0?"GET":"POST",headers:{Authorization:`Bearer ${_m}`,"Content-Type":"application/json"},body:e.body===void 0?void 0:JSON.stringify(e.body),signal:e.signal}),r=await t.json();if(!t.ok){let n=Gd({error:S()}).safeParse(r);throw Error(n.success?n.data.error:"The local editor could not complete this action.")}return e.schema.parse(r)}function Co(e){if(e.leaves.length<=10)return{hubs:[],leaves:e.leaves.map((o)=>({...o,parentId:e.parentId}))};let t=10;while(e.leaves.length/t>10)t*=10;let r=[],n=[];for(let o=0;o<e.leaves.length;o+=t){let i=o/t,s=`${e.parentId}:${i}`,a=`${e.title} ${i+1}`;r.push({id:s,title:a,parentId:e.parentId});let u=Co({parentId:s,title:a,leaves:e.leaves.slice(o,o+t)});r.push(...u.hubs),n.push(...u.leaves)}return{hubs:r,leaves:n}}var wm=new Set(["agent","before","change","changing","code","existing","from","into","skill","that","the","this","when","with","work"]);function To(e){return e.toLowerCase().replaceAll(/[^a-z0-9-]+/g," ").split(/[\s-]+/).filter((t)=>t.length>2&&!wm.has(t))}function km(e){return[e.category,e.section,e.axis,...To(e.name),...To(e.title),...To(e.description)].filter((t,r,n)=>Boolean(t&&n.indexOf(t)===r))}function Yl(e){return e.split("-").map((t)=>`${t[0]?.toUpperCase()??""}${t.slice(1)}`).join(" ")}function zm(e){let t=new Map;for(let r of[...e].sort((n,o)=>n.id.localeCompare(o.id))){let n=`${r.kind}\x00${r.text.trim()}`,o=t.get(n);if(o)o.ids.push(r.id);else t.set(n,{item:r,ids:[r.id]})}return[...t.values()].map(({item:r,ids:n})=>({item:r,itemIds:n,topics:km(r)}))}function $m(e){if(e<4)return Math.max(1,e);return Math.min(12,Math.max(4,Math.round(Math.sqrt(e))))}function Sm(e){let r=[...Map.groupBy(e,(i)=>i.topics[0]??"guidance")].map(([i,s])=>({key:i,entries:s})),n=$m(e.length);r.sort((i,s)=>s.entries.length-i.entries.length||i.key.localeCompare(s.key));let o=r.slice(0,n);for(let i of r.slice(n))for(let s of i.entries)o.map((u)=>({candidate:u,score:(s.item.section===u.entries[0]?.item.section?4:0)+(s.topics.includes(u.key)?1:0)})).sort((u,c)=>c.score-u.score||u.candidate.entries.length-c.candidate.entries.length||u.candidate.key.localeCompare(c.candidate.key))[0]?.candidate.entries.push(s);return o.sort((i,s)=>i.key.localeCompare(s.key))}function Im(e){let t=new Set(e.entries.flatMap((n)=>n.item.category?[n.item.category]:[]));if(t.size===1)return[...t][0]??e.key;let r=new Set(e.entries.flatMap((n)=>n.item.section?[n.item.section]:[]));return r.size===1?[...r][0]??e.key:e.key}function Pm(e,t){let r=new Map;for(let n of e)for(let o of n.topics.filter((i)=>i!==t))r.set(o,(r.get(o)??0)+1);return[...r].sort(([n,o],[i,s])=>s-o||n.localeCompare(i))[0]?.[0]??t}function Wl(e){let t=zm(e),r=Sm(t),n=r.map(Im),o=[],i=[];for(let[s,a]of r.entries()){let u=`hub:${s}:${a.key}`,c=n[s]??a.key,l=n.slice(0,s).filter((x)=>x===c).length,p=n.filter((x)=>x===c).length;o.push({id:u,title:`${Yl(c)}${p>1?` ${l+1}`:""}`,parentId:null});let f=[...a.entries].sort((x,v)=>x.item.id.localeCompare(v.item.id)),d=f.map((x)=>{let v=r.map((b,Z)=>({candidate:b,index:Z})).filter(({candidate:b})=>b.key!==a.key&&x.topics.includes(b.key)).slice(0,2).map(({candidate:b,index:Z})=>`hub:${Z}:${b.key}`);return{id:`skill:${x.item.id}`,itemIds:[...x.itemIds],relatedHubIds:v}}),m=Co({parentId:u,title:Yl(Pm(f,a.key)),leaves:d});o.push(...m.hubs),i.push(...m.leaves)}return Xr.parse({hubs:o,leaves:i})}function P(e){let t=document.getElementById(e);if(t===null)throw Error("The editor is missing a required control");return t}function No(e){let t=document.querySelector(`#${e}`);if(!(t instanceof SVGSVGElement))throw Error("Expected an SVG canvas");return t}function oe(e){let t=P(e);if(!(t instanceof HTMLInputElement))throw Error("Expected an input control");return t}function gt(e){let t=P(e);if(!(t instanceof HTMLSelectElement))throw Error("Expected a selection control");return t}function Ce(e){let t=P(e);if(!(t instanceof HTMLTextAreaElement))throw Error("Expected a text editor");return t}function xt(e){let t=P(e);if(!(t instanceof HTMLDialogElement))throw Error("Expected an editor dialog");return t}function w(e){let t=document.createElement(e.tag);if(e.className)t.className=e.className;if(e.text!==void 0)t.textContent=e.text;return t}function Te(e){let t=P("notice");t.textContent=e.message,t.classList.toggle("success",e.success===!0),t.hidden=e.message.length===0}function Ft(e){Te({message:e instanceof Error?e.message:"The action failed."})}var _={view:null,input:{scope:"global",choices:{},edits:{},custom:[]},activeId:"",search:"",dirty:!1};function ie(e){let t=_.view?.locked[e.id];if(t!==void 0)return t;let r=_.input.choices[e.id];if(r!==void 0)return r;if(e.id.startsWith("custom:")&&_.input.custom.some((n)=>e.id===`custom:${n.name}`))return!0;return _.view?.inherited[e.id]===!0}function Ro(e){if(_.view?.locked[e.id]!==void 0)return;let t=!ie(e);if(_.input.choices[e.id]=t,t&&e.axis){for(let r of _.view?.items??[])if(r.axis===e.axis&&r.id!==e.id)_.input.choices[r.id]=!1,delete _.input.edits[r.id]}if(!t)delete _.input.edits[e.id];_.dirty=!0}function Mo(e){P("custom-status").textContent="",oe("custom-name").value=e?`my-${e.name}`.slice(0,48):"",oe("custom-description").value=e?`Use alongside ${e.name} for my working preferences.`:"",Ce("custom-body").value=e?`# Personal guidance for ${e.title}
58
+
59
+ `:"",xt("custom-dialog").showModal()}function Ql(){let e=ht.parse({name:oe("custom-name").value,description:oe("custom-description").value,body:Ce("custom-body").value}),t=`custom:${e.name}`;if(_.view?.items.some((r)=>r.name===e.name))throw Error("Choose a name that does not replace an existing skill.");if(_.input.custom.push(e),_.input.choices[t]=!0,_.dirty=!0,_.activeId=t,_.view?.items.push({id:t,name:e.name,title:e.name.replaceAll("-"," "),description:e.description,text:`---
60
+ name: ${e.name}
61
+ description: ${JSON.stringify(e.description)}
62
+ ---
63
+
64
+ ${e.body}
65
+ `,kind:"skill",category:null,section:null,axis:null,owner:"managed"}),_.view)_.view.constellation=Wl(_.view.items);xt("custom-dialog").close(),oe("custom-name").value="",Ce("custom-body").value=""}var ep={"design-deep-modules":{title:"Deep modules",summary:"Keep interfaces small and useful. Put complexity behind a clear boundary so callers have less to understand."},"typescript-type-safety":{title:"Explicit types",summary:"Represent valid states in the type system. Narrow uncertain values and keep unsafe assertions out of the implementation."},"scope-confirmed-changes":{title:"Scoped changes",summary:"Confirm the problem before editing. Keep the change focused, preserve surrounding behavior, and verify the result."},"diagnose-before-editing":{title:"Prove the bug",summary:"Trace the failure and establish its cause before changing code. Use evidence to choose the smallest useful fix."},"prove-regression-tests":{title:"Test the failure",summary:"Prove a regression test detects the original bug. Restore the fix and check that the same test passes."},"verify-and-review":{title:"Verify the finish",summary:"Run the relevant checks, inspect the complete diff, and report what was verified before calling the task done."},"testing-first":{title:"Test first",summary:"Capture the expected behavior at a public boundary before implementing the change. Let the failing test guide the work."},"testing-risk-based":{title:"Test the risk",summary:"Spend testing effort where behavior can break. Choose checks that catch meaningful failures without mirroring the implementation."},"research-primary-sources":{title:"Go to the source",summary:"Check authoritative documentation and original evidence when a technical decision depends on facts that need verification."},"planning-first":{title:"Plan the change",summary:"Establish the approach before implementation so the scope, decisions, and intended outcome are clear."},"planning-when-costly":{title:"Plan when it matters",summary:"Move directly on straightforward tasks. Pause for a plan when the cost, uncertainty, or consequences call for one."},"questions-autonomous":{title:"Keep moving",summary:"Use judgment to resolve routine choices. Ask when missing information changes the outcome or an action needs authorization."},"questions-early":{title:"Ask early",summary:"Resolve meaningful uncertainty with the user before investing in an implementation built on the wrong assumption."},"resolve-conflicts-by-intent":{title:"Preserve intent",summary:"Understand what both sides of a merge are trying to achieve. Resolve the conflict and verify the combined behavior."},"dependencies-existing":{title:"Know your tools",summary:"Look for a solution in the existing stack before adding another dependency."},"dependencies-mature":{title:"Choose proven tools",summary:"Use established, focused packages when they provide substantial reusable logic and justify the dependency."},"refactor-boundaries":{title:"Improve boundaries",summary:"Make a refactor when it improves responsibilities and simplifies the change. Keep its purpose connected to the task."},"refactor-preserve":{title:"Respect the structure",summary:"Work within the current structure and preserve unrelated code while making the requested change."}};function ke(e){return ep[e.id]?.title??e.title}function tp(e){let t=ep[e.item.id];if(t&&e.editedText===void 0&&e.item.owner==="packaged")return t.summary;let r=(e.editedText??e.item.text).replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n/,"").split(`
66
+ `).filter((n)=>n.trim()&&!n.startsWith("#")&&!n.startsWith("```")).slice(0,2).join(" ").replace(/\*\*/g,"");return r.length>320?`${r.slice(0,317).trimEnd()}…`:r}function Zm(e){let t=w({tag:"details",className:"editor"});t.append(w({tag:"summary",text:"Edit instructions"}));let r=w({tag:"textarea"});r.value=_.input.edits[e.item.id]??e.item.text,r.maxLength=48000,r.setAttribute("aria-label",`Instructions for ${e.item.title}`);let n=w({tag:"button",className:"quiet-button",text:"Save to draft"});return n.addEventListener("click",()=>{if(!ie(e.item))Ro(e.item);_.input.edits[e.item.id]=r.value,_.input.choices[e.item.id]=!0,_.dirty=!0,Te({message:"Instructions added to your draft. Review the changes before applying.",success:!0}),e.rerender()}),t.append(r,n),t}function rp(e){let t=P("detail"),r=_.view?.items.find((a)=>a.id===_.activeId);if(t.replaceChildren(),!r){t.append(w({tag:"h2",text:"Choose a skill."})),t.append(w({tag:"p",className:"detail-description",text:"Inspect a star to see what it teaches your agent."}));return}t.append(w({tag:"p",className:"eyebrow",text:`${(r.category??"CUSTOM").replaceAll("-"," ").toUpperCase()} / ${r.kind.toUpperCase()}`}),w({tag:"h2",text:ke(r)}),w({tag:"p",className:"detail-description",text:r.description}));let n=w({tag:"div",className:"behavior"});n.append(w({tag:"p",className:"eyebrow",text:"YOUR AGENT WILL"}),w({tag:"p",text:tp({item:r,editedText:_.input.edits[r.id]})})),t.append(n);let o=r.owner==="provider",i=_.view?.locked[r.id]!==void 0;if(t.append(w({tag:"p",className:"skill-status",text:i?"◇ Shared requirement":o?"◇ Managed by its provider":"◇ Workflow guidance"})),i){t.append(w({tag:"p",className:"owner-note",text:"This choice belongs to the shared repository build. Switch to shared scope to propose a reviewed change."}));return}let s=w({tag:"button",className:"primary-button",text:o?"Create a local companion":ie(r)?"Unequip skill":"Equip skill"});if(s.addEventListener("click",()=>{if(o){e.companion(r);return}Ro(r),e.rerender()}),t.append(s),o)t.append(w({tag:"p",className:"owner-note",text:"Enable or disable this package in its harness. A companion adds your own instructions without changing the package."}));else t.append(Zm({item:r,rerender:e.rerender}))}var np=K({title:S().min(1).max(80),summary:S().min(1).max(600),strengths:re(S().min(1).max(180)).max(3),tradeoffs:re(S().min(1).max(180)).max(3),hubLabels:re(K({id:S().min(1).max(120),title:S().min(1).max(40)})).max(12).default([])}),op=K({id:Hr(),destination:S(),payload:S(),limits:S(),cached:np.nullable()}),ip=K({description:np});function Yr(e){let t=!1,r=(n)=>{let o=e.getBoundingClientRect();return n.target===e&&(n.clientX<o.left||n.clientX>o.right||n.clientY<o.top||n.clientY>o.bottom)};e.addEventListener("pointerdown",(n)=>{t=r(n)}),e.addEventListener("click",(n)=>{if(t&&r(n))e.close();t=!1})}function Wr(e){let t=w({tag:"dialog"}),r=w({tag:"div",className:"dialog-heading"}),n=w({tag:"button",className:"quiet-button",text:"✕"}),o=w({tag:"details",className:"file-change"}),i=w({tag:"div",className:"dialog-actions"}),s=w({tag:"p",className:"review-message"}),a=w({tag:"button",className:"quiet-button",text:"Keep editing"}),u=w({tag:"button",className:"primary-button",text:e.confirm}),c=new AbortController;t.setAttribute("aria-label",e.title),n.setAttribute("aria-label","Close model request"),s.setAttribute("role","status"),n.addEventListener("click",()=>t.close()),Yr(t),r.append(w({tag:"h2",text:e.title}),n),o.append(w({tag:"summary",text:"Exact payload sent to the model"}),w({tag:"pre",text:e.review.payload})),a.addEventListener("click",()=>t.close()),t.addEventListener("close",()=>{c.abort(),t.remove()});async function l(){if(u.disabled)return;u.disabled=!0,u.textContent="Generating…",a.textContent="Cancel generation",s.textContent="Your model is working. You can cancel and keep your original draft.";try{let p=await ne({path:e.path,schema:e.schema,body:{previewId:e.review.id},signal:c.signal});if(!c.signal.aborted)e.accept(p),t.close()}catch(p){if(c.signal.aborted)return;s.className="review-warning",s.textContent=p instanceof Error?p.message:"Generation failed. Your draft is unchanged.",u.textContent="Request ended",a.textContent="Back to editing"}}u.addEventListener("click",()=>{l().catch(()=>{s.textContent="Generation failed. Return to editing to try again."})}),i.append(a,u),t.append(r,w({tag:"p",className:"review-message",text:`Destination: ${e.review.destination}`}),w({tag:"p",className:"review-message",text:e.review.limits}),w({tag:"p",className:"review-message",text:e.explanation}),o,s,i),document.body.append(t),t.showModal()}function yt(e){return function(){return this.matches(e)}}function Qr(e){return function(t){return t.matches(e)}}var en="http://www.w3.org/1999/xhtml",Do={svg:"http://www.w3.org/2000/svg",xhtml:en,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function ze(e){var t=e+="",r=t.indexOf(":");if(r>=0&&(t=e.slice(0,r))!=="xmlns")e=e.slice(r+1);return Do.hasOwnProperty(t)?{space:Do[t],local:e}:e}function Lo(e){let t;while(t=e.sourceEvent)e=t;return e}function $e(e,t){if(e=Lo(e),t===void 0)t=e.currentTarget;if(t){var r=t.ownerSVGElement||t;if(r.createSVGPoint){var n=r.createSVGPoint();return n.x=e.clientX,n.y=e.clientY,n=n.matrixTransform(t.getScreenCTM().inverse()),[n.x,n.y]}if(t.getBoundingClientRect){var o=t.getBoundingClientRect();return[e.clientX-o.left-t.clientLeft,e.clientY-o.top-t.clientTop]}}return[e.pageX,e.pageY]}function Em(){}function qe(e){return e==null?Em:function(){return this.querySelector(e)}}function Bo(e){if(typeof e!=="function")e=qe(e);for(var t=this._groups,r=t.length,n=Array(r),o=0;o<r;++o)for(var i=t[o],s=i.length,a=n[o]=Array(s),u,c,l=0;l<s;++l)if((u=i[l])&&(c=e.call(u,u.__data__,l,i))){if("__data__"in u)c.__data__=u.__data__;a[l]=c}return new U(n,this._parents)}function jo(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Om(){return[]}function bt(e){return e==null?Om:function(){return this.querySelectorAll(e)}}function Am(e){return function(){return jo(e.apply(this,arguments))}}function Fo(e){if(typeof e==="function")e=Am(e);else e=bt(e);for(var t=this._groups,r=t.length,n=[],o=[],i=0;i<r;++i)for(var s=t[i],a=s.length,u,c=0;c<a;++c)if(u=s[c])n.push(e.call(u,u.__data__,c,s)),o.push(u);return new U(n,o)}var Cm=Array.prototype.find;function Tm(e){return function(){return Cm.call(this.children,e)}}function Nm(){return this.firstElementChild}function Uo(e){return this.select(e==null?Nm:Tm(typeof e==="function"?e:Qr(e)))}var Rm=Array.prototype.filter;function Mm(){return Array.from(this.children)}function Dm(e){return function(){return Rm.call(this.children,e)}}function qo(e){return this.selectAll(e==null?Mm:Dm(typeof e==="function"?e:Qr(e)))}function Vo(e){if(typeof e!=="function")e=yt(e);for(var t=this._groups,r=t.length,n=Array(r),o=0;o<r;++o)for(var i=t[o],s=i.length,a=n[o]=[],u,c=0;c<s;++c)if((u=i[c])&&e.call(u,u.__data__,c,i))a.push(u);return new U(n,this._parents)}function Ut(e){return Array(e.length)}function Jo(){return new U(this._enter||this._groups.map(Ut),this._parents)}function qt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}qt.prototype={constructor:qt,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Ho(e){return function(){return e}}function Lm(e,t,r,n,o,i){var s=0,a,u=t.length,c=i.length;for(;s<c;++s)if(a=t[s])a.__data__=i[s],n[s]=a;else r[s]=new qt(e,i[s]);for(;s<u;++s)if(a=t[s])o[s]=a}function Bm(e,t,r,n,o,i,s){var a,u,c=new Map,l=t.length,p=i.length,f=Array(l),d;for(a=0;a<l;++a)if(u=t[a])if(f[a]=d=s.call(u,u.__data__,a,t)+"",c.has(d))o[a]=u;else c.set(d,u);for(a=0;a<p;++a)if(d=s.call(e,i[a],a,i)+"",u=c.get(d))n[a]=u,u.__data__=i[a],c.delete(d);else r[a]=new qt(e,i[a]);for(a=0;a<l;++a)if((u=t[a])&&c.get(f[a])===u)o[a]=u}function jm(e){return e.__data__}function Ko(e,t){if(!arguments.length)return Array.from(this,jm);var r=t?Bm:Lm,n=this._parents,o=this._groups;if(typeof e!=="function")e=Ho(e);for(var i=o.length,s=Array(i),a=Array(i),u=Array(i),c=0;c<i;++c){var l=n[c],p=o[c],f=p.length,d=Fm(e.call(l,l&&l.__data__,c,n)),m=d.length,x=a[c]=Array(m),v=s[c]=Array(m),b=u[c]=Array(f);r(l,p,x,v,b,d,t);for(var Z=0,D=0,j,T;Z<m;++Z)if(j=x[Z]){if(Z>=D)D=Z+1;while(!(T=v[D])&&++D<m);j._next=T||null}}return s=new U(s,n),s._enter=a,s._exit=u,s}function Fm(e){return typeof e==="object"&&"length"in e?e:Array.from(e)}function Go(){return new U(this._exit||this._groups.map(Ut),this._parents)}function Xo(e,t,r){var n=this.enter(),o=this,i=this.exit();if(typeof e==="function"){if(n=e(n),n)n=n.selection()}else n=n.append(e+"");if(t!=null){if(o=t(o),o)o=o.selection()}if(r==null)i.remove();else r(i);return n&&o?n.merge(o).order():o}function Yo(e){var t=e.selection?e.selection():e;for(var r=this._groups,n=t._groups,o=r.length,i=n.length,s=Math.min(o,i),a=Array(o),u=0;u<s;++u)for(var c=r[u],l=n[u],p=c.length,f=a[u]=Array(p),d,m=0;m<p;++m)if(d=c[m]||l[m])f[m]=d;for(;u<o;++u)a[u]=r[u];return new U(a,this._parents)}function Wo(){for(var e=this._groups,t=-1,r=e.length;++t<r;)for(var n=e[t],o=n.length-1,i=n[o],s;--o>=0;)if(s=n[o]){if(i&&s.compareDocumentPosition(i)^4)i.parentNode.insertBefore(s,i);i=s}return this}function Qo(e){if(!e)e=Um;function t(p,f){return p&&f?e(p.__data__,f.__data__):!p-!f}for(var r=this._groups,n=r.length,o=Array(n),i=0;i<n;++i){for(var s=r[i],a=s.length,u=o[i]=Array(a),c,l=0;l<a;++l)if(c=s[l])u[l]=c;u.sort(t)}return new U(o,this._parents).order()}function Um(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function ei(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function ti(){return Array.from(this)}function ri(){for(var e=this._groups,t=0,r=e.length;t<r;++t)for(var n=e[t],o=0,i=n.length;o<i;++o){var s=n[o];if(s)return s}return null}function ni(){let e=0;for(let t of this)++e;return e}function oi(){return!this.node()}function ii(e){for(var t=this._groups,r=0,n=t.length;r<n;++r)for(var o=t[r],i=0,s=o.length,a;i<s;++i)if(a=o[i])e.call(a,a.__data__,i,o);return this}function qm(e){return function(){this.removeAttribute(e)}}function Vm(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Jm(e,t){return function(){this.setAttribute(e,t)}}function Hm(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Km(e,t){return function(){var r=t.apply(this,arguments);if(r==null)this.removeAttribute(e);else this.setAttribute(e,r)}}function Gm(e,t){return function(){var r=t.apply(this,arguments);if(r==null)this.removeAttributeNS(e.space,e.local);else this.setAttributeNS(e.space,e.local,r)}}function si(e,t){var r=ze(e);if(arguments.length<2){var n=this.node();return r.local?n.getAttributeNS(r.space,r.local):n.getAttribute(r)}return this.each((t==null?r.local?Vm:qm:typeof t==="function"?r.local?Gm:Km:r.local?Hm:Jm)(r,t))}function Vt(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Xm(e){return function(){this.style.removeProperty(e)}}function Ym(e,t,r){return function(){this.style.setProperty(e,t,r)}}function Wm(e,t,r){return function(){var n=t.apply(this,arguments);if(n==null)this.style.removeProperty(e);else this.style.setProperty(e,n,r)}}function ai(e,t,r){return arguments.length>1?this.each((t==null?Xm:typeof t==="function"?Wm:Ym)(e,t,r==null?"":r)):Ve(this.node(),e)}function Ve(e,t){return e.style.getPropertyValue(t)||Vt(e).getComputedStyle(e,null).getPropertyValue(t)}function Qm(e){return function(){delete this[e]}}function eh(e,t){return function(){this[e]=t}}function th(e,t){return function(){var r=t.apply(this,arguments);if(r==null)delete this[e];else this[e]=r}}function ci(e,t){return arguments.length>1?this.each((t==null?Qm:typeof t==="function"?th:eh)(e,t)):this.node()[e]}function sp(e){return e.trim().split(/^|\s+/)}function ui(e){return e.classList||new ap(e)}function ap(e){this._node=e,this._names=sp(e.getAttribute("class")||"")}ap.prototype={add:function(e){var t=this._names.indexOf(e);if(t<0)this._names.push(e),this._node.setAttribute("class",this._names.join(" "))},remove:function(e){var t=this._names.indexOf(e);if(t>=0)this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" "))},contains:function(e){return this._names.indexOf(e)>=0}};function cp(e,t){var r=ui(e),n=-1,o=t.length;while(++n<o)r.add(t[n])}function up(e,t){var r=ui(e),n=-1,o=t.length;while(++n<o)r.remove(t[n])}function rh(e){return function(){cp(this,e)}}function nh(e){return function(){up(this,e)}}function oh(e,t){return function(){(t.apply(this,arguments)?cp:up)(this,e)}}function li(e,t){var r=sp(e+"");if(arguments.length<2){var n=ui(this.node()),o=-1,i=r.length;while(++o<i)if(!n.contains(r[o]))return!1;return!0}return this.each((typeof t==="function"?oh:t?rh:nh)(r,t))}function ih(){this.textContent=""}function sh(e){return function(){this.textContent=e}}function ah(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function pi(e){return arguments.length?this.each(e==null?ih:(typeof e==="function"?ah:sh)(e)):this.node().textContent}function ch(){this.innerHTML=""}function uh(e){return function(){this.innerHTML=e}}function lh(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function fi(e){return arguments.length?this.each(e==null?ch:(typeof e==="function"?lh:uh)(e)):this.node().innerHTML}function ph(){if(this.nextSibling)this.parentNode.appendChild(this)}function di(){return this.each(ph)}function fh(){if(this.previousSibling)this.parentNode.insertBefore(this,this.parentNode.firstChild)}function mi(){return this.each(fh)}function dh(e){return function(){var t=this.ownerDocument,r=this.namespaceURI;return r===en&&t.documentElement.namespaceURI===en?t.createElement(e):t.createElementNS(r,e)}}function mh(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Jt(e){var t=ze(e);return(t.local?mh:dh)(t)}function hi(e){var t=typeof e==="function"?e:Jt(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function hh(){return null}function gi(e,t){var r=typeof e==="function"?e:Jt(e),n=t==null?hh:typeof t==="function"?t:qe(t);return this.select(function(){return this.insertBefore(r.apply(this,arguments),n.apply(this,arguments)||null)})}function gh(){var e=this.parentNode;if(e)e.removeChild(this)}function xi(){return this.each(gh)}function xh(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function yh(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function yi(e){return this.select(e?yh:xh)}function bi(e){return arguments.length?this.property("__data__",e):this.node().__data__}function bh(e){return function(t){e.call(this,t,this.__data__)}}function vh(e){return e.trim().split(/^|\s+/).map(function(t){var r="",n=t.indexOf(".");if(n>=0)r=t.slice(n+1),t=t.slice(0,n);return{type:t,name:r}})}function _h(e){return function(){var t=this.__on;if(!t)return;for(var r=0,n=-1,o=t.length,i;r<o;++r)if(i=t[r],(!e.type||i.type===e.type)&&i.name===e.name)this.removeEventListener(i.type,i.listener,i.options);else t[++n]=i;if(++n)t.length=n;else delete this.__on}}function wh(e,t,r){return function(){var n=this.__on,o,i=bh(t);if(n){for(var s=0,a=n.length;s<a;++s)if((o=n[s]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=i,o.options=r),o.value=t;return}}if(this.addEventListener(e.type,i,r),o={type:e.type,name:e.name,value:t,listener:i,options:r},!n)this.__on=[o];else n.push(o)}}function vi(e,t,r){var n=vh(e+""),o,i=n.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var u=0,c=a.length,l;u<c;++u)for(o=0,l=a[u];o<i;++o)if((s=n[o]).type===l.type&&s.name===l.name)return l.value}return}a=t?wh:_h;for(o=0;o<i;++o)this.each(a(n[o],t,r));return this}function lp(e,t,r){var n=Vt(e),o=n.CustomEvent;if(typeof o==="function")o=new o(t,r);else if(o=n.document.createEvent("Event"),r)o.initEvent(t,r.bubbles,r.cancelable),o.detail=r.detail;else o.initEvent(t,!1,!1);e.dispatchEvent(o)}function kh(e,t){return function(){return lp(this,e,t)}}function zh(e,t){return function(){return lp(this,e,t.apply(this,arguments))}}function _i(e,t){return this.each((typeof t==="function"?zh:kh)(e,t))}function*wi(){for(var e=this._groups,t=0,r=e.length;t<r;++t)for(var n=e[t],o=0,i=n.length,s;o<i;++o)if(s=n[o])yield s}var ki=[null];function U(e,t){this._groups=e,this._parents=t}function pp(){return new U([[document.documentElement]],ki)}function $h(){return this}U.prototype=pp.prototype={constructor:U,select:Bo,selectAll:Fo,selectChild:Uo,selectChildren:qo,filter:Vo,data:Ko,enter:Jo,exit:Go,join:Xo,merge:Yo,selection:$h,order:Wo,sort:Qo,call:ei,nodes:ti,node:ri,size:ni,empty:oi,each:ii,attr:si,style:ai,property:ci,classed:li,text:pi,html:fi,raise:di,lower:mi,append:hi,insert:gi,remove:xi,clone:yi,datum:bi,on:vi,dispatch:_i,[Symbol.iterator]:wi};var Ne=pp;function Y(e){return typeof e==="string"?new U([[document.querySelector(e)]],[document.documentElement]):new U([[e]],ki)}var Sh={value:()=>{}};function dp(){for(var e=0,t=arguments.length,r={},n;e<t;++e){if(!(n=arguments[e]+"")||n in r||/[\s.]/.test(n))throw Error("illegal type: "+n);r[n]=[]}return new tn(r)}function tn(e){this._=e}function Ih(e,t){return e.trim().split(/^|\s+/).map(function(r){var n="",o=r.indexOf(".");if(o>=0)n=r.slice(o+1),r=r.slice(0,o);if(r&&!t.hasOwnProperty(r))throw Error("unknown type: "+r);return{type:r,name:n}})}tn.prototype=dp.prototype={constructor:tn,on:function(e,t){var r=this._,n=Ih(e+"",r),o,i=-1,s=n.length;if(arguments.length<2){while(++i<s)if((o=(e=n[i]).type)&&(o=Ph(r[o],e.name)))return o;return}if(t!=null&&typeof t!=="function")throw Error("invalid callback: "+t);while(++i<s)if(o=(e=n[i]).type)r[o]=fp(r[o],e.name,t);else if(t==null)for(o in r)r[o]=fp(r[o],e.name,null);return this},copy:function(){var e={},t=this._;for(var r in t)e[r]=t[r].slice();return new tn(e)},call:function(e,t){if((o=arguments.length-2)>0)for(var r=Array(o),n=0,o,i;n<o;++n)r[n]=arguments[n+2];if(!this._.hasOwnProperty(e))throw Error("unknown type: "+e);for(i=this._[e],n=0,o=i.length;n<o;++n)i[n].value.apply(t,r)},apply:function(e,t,r){if(!this._.hasOwnProperty(e))throw Error("unknown type: "+e);for(var n=this._[e],o=0,i=n.length;o<i;++o)n[o].value.apply(t,r)}};function Ph(e,t){for(var r=0,n=e.length,o;r<n;++r)if((o=e[r]).name===t)return o.value}function fp(e,t,r){for(var n=0,o=e.length;n<o;++n)if(e[n].name===t){e[n]=Sh,e=e.slice(0,n).concat(e.slice(n+1));break}if(r!=null)e.push({name:t,value:r});return e}var Ht=dp;var rn={capture:!0,passive:!1};function Kt(e){e.preventDefault(),e.stopImmediatePropagation()}function nn(e){var t=e.document.documentElement,r=Y(e).on("dragstart.drag",Kt,rn);if("onselectstart"in t)r.on("selectstart.drag",Kt,rn);else t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none"}function zi(e,t){var r=e.document.documentElement,n=Y(e).on("dragstart.drag",null);if(t)n.on("click.drag",Kt,rn),setTimeout(function(){n.on("click.drag",null)},0);if("onselectstart"in r)n.on("selectstart.drag",null);else r.style.MozUserSelect=r.__noselect,delete r.__noselect}function le(e,t){return e=+e,t=+t,function(r){return e*(1-r)+t*r}}var Si=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,$i=new RegExp(Si.source,"g");function Zh(e){return function(){return e}}function Eh(e){return function(t){return e(t)+""}}function on(e,t){var r=Si.lastIndex=$i.lastIndex=0,n,o,i,s=-1,a=[],u=[];e=e+"",t=t+"";while((n=Si.exec(e))&&(o=$i.exec(t))){if((i=o.index)>r)if(i=t.slice(r,i),a[s])a[s]+=i;else a[++s]=i;if((n=n[0])===(o=o[0]))if(a[s])a[s]+=o;else a[++s]=o;else a[++s]=null,u.push({i:s,x:le(n,o)});r=$i.lastIndex}if(r<t.length)if(i=t.slice(r),a[s])a[s]+=i;else a[++s]=i;return a.length<2?u[0]?Eh(u[0].x):Zh(t):(t=u.length,function(c){for(var l=0,p;l<t;++l)a[(p=u[l]).i]=p.x(c);return a.join("")})}var mp=180/Math.PI,sn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function an(e,t,r,n,o,i){var s,a,u;if(s=Math.sqrt(e*e+t*t))e/=s,t/=s;if(u=e*r+t*n)r-=e*u,n-=t*u;if(a=Math.sqrt(r*r+n*n))r/=a,n/=a,u/=a;if(e*n<t*r)e=-e,t=-t,u=-u,s=-s;return{translateX:o,translateY:i,rotate:Math.atan2(t,e)*mp,skewX:Math.atan(u)*mp,scaleX:s,scaleY:a}}var cn;function hp(e){let t=new(typeof DOMMatrix==="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?sn:an(t.a,t.b,t.c,t.d,t.e,t.f)}function gp(e){if(e==null)return sn;if(!cn)cn=document.createElementNS("http://www.w3.org/2000/svg","g");if(cn.setAttribute("transform",e),!(e=cn.transform.baseVal.consolidate()))return sn;return e=e.matrix,an(e.a,e.b,e.c,e.d,e.e,e.f)}function xp(e,t,r,n){function o(c){return c.length?c.pop()+" ":""}function i(c,l,p,f,d,m){if(c!==p||l!==f){var x=d.push("translate(",null,t,null,r);m.push({i:x-4,x:le(c,p)},{i:x-2,x:le(l,f)})}else if(p||f)d.push("translate("+p+t+f+r)}function s(c,l,p,f){if(c!==l){if(c-l>180)l+=360;else if(l-c>180)c+=360;f.push({i:p.push(o(p)+"rotate(",null,n)-2,x:le(c,l)})}else if(l)p.push(o(p)+"rotate("+l+n)}function a(c,l,p,f){if(c!==l)f.push({i:p.push(o(p)+"skewX(",null,n)-2,x:le(c,l)});else if(l)p.push(o(p)+"skewX("+l+n)}function u(c,l,p,f,d,m){if(c!==p||l!==f){var x=d.push(o(d)+"scale(",null,",",null,")");m.push({i:x-4,x:le(c,p)},{i:x-2,x:le(l,f)})}else if(p!==1||f!==1)d.push(o(d)+"scale("+p+","+f+")")}return function(c,l){var p=[],f=[];return c=e(c),l=e(l),i(c.translateX,c.translateY,l.translateX,l.translateY,p,f),s(c.rotate,l.rotate,p,f),a(c.skewX,l.skewX,p,f),u(c.scaleX,c.scaleY,l.scaleX,l.scaleY,p,f),c=l=null,function(d){var m=-1,x=f.length,v;while(++m<x)p[(v=f[m]).i]=v.x(d);return p.join("")}}}var Ii=xp(hp,"px, ","px)","deg)"),Pi=xp(gp,", ",")",")");var Oh=0.000000000001;function yp(e){return((e=Math.exp(e))+1/e)/2}function Ah(e){return((e=Math.exp(e))-1/e)/2}function Ch(e){return((e=Math.exp(2*e))-1)/(e+1)}var Zi=function e(t,r,n){function o(i,s){var a=i[0],u=i[1],c=i[2],l=s[0],p=s[1],f=s[2],d=l-a,m=p-u,x=d*d+m*m,v,b;if(x<Oh)b=Math.log(f/c)/t,v=function(J){return[a+J*d,u+J*m,c*Math.exp(t*J*b)]};else{var Z=Math.sqrt(x),D=(f*f-c*c+n*x)/(2*c*r*Z),j=(f*f-c*c-n*x)/(2*f*r*Z),T=Math.log(Math.sqrt(D*D+1)-D),O=Math.log(Math.sqrt(j*j+1)-j);b=(O-T)/t,v=function(J){var Le=J*b,Xe=yp(T),Be=c/(r*Z)*(Xe*Ch(t*Le+T)-Ah(T));return[a+Be*d,u+Be*m,c*Xe/yp(t*Le+T)]}}return v.duration=b*1000*t/Math.SQRT2,v}return o.rho=function(i){var s=Math.max(0.001,+i),a=s*s,u=a*a;return e(s,a,u)},o}(Math.SQRT2,2,4);function Gt(e,t,r){e.prototype=t.prototype=r,r.constructor=e}function Ei(e,t){var r=Object.create(e.prototype);for(var n in t)r[n]=t[n];return r}function Wt(){}var Xt=0.7,pn=1/Xt,vt="\\s*([+-]?\\d+)\\s*",Yt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Se="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Th=/^#([0-9a-f]{3,8})$/,Nh=new RegExp(`^rgb\\(${vt},${vt},${vt}\\)$`),Rh=new RegExp(`^rgb\\(${Se},${Se},${Se}\\)$`),Mh=new RegExp(`^rgba\\(${vt},${vt},${vt},${Yt}\\)$`),Dh=new RegExp(`^rgba\\(${Se},${Se},${Se},${Yt}\\)$`),Lh=new RegExp(`^hsl\\(${Yt},${Se},${Se}\\)$`),Bh=new RegExp(`^hsla\\(${Yt},${Se},${Se},${Yt}\\)$`),bp={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Gt(Wt,Je,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:vp,formatHex:vp,formatHex8:jh,formatHsl:Fh,formatRgb:_p,toString:_p});function vp(){return this.rgb().formatHex()}function jh(){return this.rgb().formatHex8()}function Fh(){return Ip(this).formatHsl()}function _p(){return this.rgb().formatRgb()}function Je(e){var t,r;return e=(e+"").trim().toLowerCase(),(t=Th.exec(e))?(r=t[1].length,t=parseInt(t[1],16),r===6?wp(t):r===3?new se(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):r===8?un(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):r===4?un(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Nh.exec(e))?new se(t[1],t[2],t[3],1):(t=Rh.exec(e))?new se(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Mh.exec(e))?un(t[1],t[2],t[3],t[4]):(t=Dh.exec(e))?un(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Lh.exec(e))?$p(t[1],t[2]/100,t[3]/100,1):(t=Bh.exec(e))?$p(t[1],t[2]/100,t[3]/100,t[4]):bp.hasOwnProperty(e)?wp(bp[e]):e==="transparent"?new se(NaN,NaN,NaN,0):null}function wp(e){return new se(e>>16&255,e>>8&255,e&255,1)}function un(e,t,r,n){if(n<=0)e=t=r=NaN;return new se(e,t,r,n)}function Uh(e){if(!(e instanceof Wt))e=Je(e);if(!e)return new se;return e=e.rgb(),new se(e.r,e.g,e.b,e.opacity)}function _t(e,t,r,n){return arguments.length===1?Uh(e):new se(e,t,r,n==null?1:n)}function se(e,t,r,n){this.r=+e,this.g=+t,this.b=+r,this.opacity=+n}Gt(se,_t,Ei(Wt,{brighter(e){return e=e==null?pn:Math.pow(pn,e),new se(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Xt:Math.pow(Xt,e),new se(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new se(it(this.r),it(this.g),it(this.b),fn(this.opacity))},displayable(){return-0.5<=this.r&&this.r<255.5&&(-0.5<=this.g&&this.g<255.5)&&(-0.5<=this.b&&this.b<255.5)&&(0<=this.opacity&&this.opacity<=1)},hex:kp,formatHex:kp,formatHex8:qh,formatRgb:zp,toString:zp}));function kp(){return`#${ot(this.r)}${ot(this.g)}${ot(this.b)}`}function qh(){return`#${ot(this.r)}${ot(this.g)}${ot(this.b)}${ot((isNaN(this.opacity)?1:this.opacity)*255)}`}function zp(){let e=fn(this.opacity);return`${e===1?"rgb(":"rgba("}${it(this.r)}, ${it(this.g)}, ${it(this.b)}${e===1?")":`, ${e})`}`}function fn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function it(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function ot(e){return e=it(e),(e<16?"0":"")+e.toString(16)}function $p(e,t,r,n){if(n<=0)e=t=r=NaN;else if(r<=0||r>=1)e=t=NaN;else if(t<=0)e=NaN;return new ge(e,t,r,n)}function Ip(e){if(e instanceof ge)return new ge(e.h,e.s,e.l,e.opacity);if(!(e instanceof Wt))e=Je(e);if(!e)return new ge;if(e instanceof ge)return e;e=e.rgb();var t=e.r/255,r=e.g/255,n=e.b/255,o=Math.min(t,r,n),i=Math.max(t,r,n),s=NaN,a=i-o,u=(i+o)/2;if(a){if(t===i)s=(r-n)/a+(r<n)*6;else if(r===i)s=(n-t)/a+2;else s=(t-r)/a+4;a/=u<0.5?i+o:2-i-o,s*=60}else a=u>0&&u<1?0:s;return new ge(s,a,u,e.opacity)}function Pp(e,t,r,n){return arguments.length===1?Ip(e):new ge(e,t,r,n==null?1:n)}function ge(e,t,r,n){this.h=+e,this.s=+t,this.l=+r,this.opacity=+n}Gt(ge,Pp,Ei(Wt,{brighter(e){return e=e==null?pn:Math.pow(pn,e),new ge(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Xt:Math.pow(Xt,e),new ge(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,r=this.l,n=r+(r<0.5?r:1-r)*t,o=2*r-n;return new se(Oi(e>=240?e-240:e+120,o,n),Oi(e,o,n),Oi(e<120?e+240:e-120,o,n),this.opacity)},clamp(){return new ge(Sp(this.h),ln(this.s),ln(this.l),fn(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&(0<=this.l&&this.l<=1)&&(0<=this.opacity&&this.opacity<=1)},formatHsl(){let e=fn(this.opacity);return`${e===1?"hsl(":"hsla("}${Sp(this.h)}, ${ln(this.s)*100}%, ${ln(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Sp(e){return e=(e||0)%360,e<0?e+360:e}function ln(e){return Math.max(0,Math.min(1,e||0))}function Oi(e,t,r){return(e<60?t+(r-t)*e/60:e<180?r:e<240?t+(r-t)*(240-e)/60:t)*255}function Ai(e,t,r,n,o){var i=e*e,s=i*e;return((1-3*e+3*i-s)*t+(4-6*i+3*s)*r+(1+3*e+3*i-3*s)*n+s*o)/6}function Ci(e){var t=e.length-1;return function(r){var n=r<=0?r=0:r>=1?(r=1,t-1):Math.floor(r*t),o=e[n],i=e[n+1],s=n>0?e[n-1]:2*o-i,a=n<t-1?e[n+2]:2*i-o;return Ai((r-n/t)*t,s,o,i,a)}}function Ti(e){var t=e.length;return function(r){var n=Math.floor(((r%=1)<0?++r:r)*t),o=e[(n+t-1)%t],i=e[n%t],s=e[(n+1)%t],a=e[(n+2)%t];return Ai((r-n/t)*t,o,i,s,a)}}var Ni=(e)=>()=>e;function Vh(e,t){return function(r){return e+r*t}}function Jh(e,t,r){return e=Math.pow(e,r),t=Math.pow(t,r)-e,r=1/r,function(n){return Math.pow(e+n*t,r)}}function Zp(e){return(e=+e)===1?dn:function(t,r){return r-t?Jh(t,r,e):Ni(isNaN(t)?r:t)}}function dn(e,t){var r=t-e;return r?Vh(e,r):Ni(isNaN(e)?t:e)}var mn=function e(t){var r=Zp(t);function n(o,i){var s=r((o=_t(o)).r,(i=_t(i)).r),a=r(o.g,i.g),u=r(o.b,i.b),c=dn(o.opacity,i.opacity);return function(l){return o.r=s(l),o.g=a(l),o.b=u(l),o.opacity=c(l),o+""}}return n.gamma=e,n}(1);function Ep(e){return function(t){var r=t.length,n=Array(r),o=Array(r),i=Array(r),s,a;for(s=0;s<r;++s)a=_t(t[s]),n[s]=a.r||0,o[s]=a.g||0,i[s]=a.b||0;return n=e(n),o=e(o),i=e(i),a.opacity=1,function(u){return a.r=n(u),a.g=o(u),a.b=i(u),a+""}}}var Hh=Ep(Ci),Kh=Ep(Ti);var wt=0,er=0,Qt=0,Ap=1000,hn,tr,gn=0,st=0,xn=0,rr=typeof performance==="object"&&performance.now?performance:Date,Cp=typeof window==="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function or(){return st||(Cp(Gh),st=rr.now()+xn)}function Gh(){st=0}function nr(){this._call=this._time=this._next=null}nr.prototype=yn.prototype={constructor:nr,restart:function(e,t,r){if(typeof e!=="function")throw TypeError("callback is not a function");if(r=(r==null?or():+r)+(t==null?0:+t),!this._next&&tr!==this){if(tr)tr._next=this;else hn=this;tr=this}this._call=e,this._time=r,Ri()},stop:function(){if(this._call)this._call=null,this._time=1/0,Ri()}};function yn(e,t,r){var n=new nr;return n.restart(e,t,r),n}function Tp(){or(),++wt;var e=hn,t;while(e){if((t=st-e._time)>=0)e._call.call(void 0,t);e=e._next}--wt}function Op(){st=(gn=rr.now())+xn,wt=er=0;try{Tp()}finally{wt=0,Yh(),st=0}}function Xh(){var e=rr.now(),t=e-gn;if(t>Ap)xn-=t,gn=e}function Yh(){var e,t=hn,r,n=1/0;while(t)if(t._call){if(n>t._time)n=t._time;e=t,t=t._next}else r=t._next,t._next=null,t=e?e._next=r:hn=r;tr=e,Ri(n)}function Ri(e){if(wt)return;if(er)er=clearTimeout(er);var t=e-st;if(t>24){if(e<1/0)er=setTimeout(Op,e-rr.now()-xn);if(Qt)Qt=clearInterval(Qt)}else{if(!Qt)gn=rr.now(),Qt=setInterval(Xh,Ap);wt=1,Cp(Op)}}function ir(e,t,r){var n=new nr;return t=t==null?0:+t,n.restart((o)=>{n.stop(),e(o+t)},t,r),n}var Wh=Ht("start","end","cancel","interrupt"),Qh=[],Mp=0,Np=1,vn=2,bn=3,Rp=4,_n=5,sr=6;function Re(e,t,r,n,o,i){var s=e.__transition;if(!s)e.__transition={};else if(r in s)return;eg(e,r,{name:t,index:n,group:o,on:Wh,tween:Qh,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Mp})}function ar(e,t){var r=H(e,t);if(r.state>Mp)throw Error("too late; already scheduled");return r}function W(e,t){var r=H(e,t);if(r.state>bn)throw Error("too late; already running");return r}function H(e,t){var r=e.__transition;if(!r||!(r=r[t]))throw Error("transition not found");return r}function eg(e,t,r){var n=e.__transition,o;n[t]=r,r.timer=yn(i,0,r.time);function i(c){if(r.state=Np,r.timer.restart(s,r.delay,r.time),r.delay<=c)s(c-r.delay)}function s(c){var l,p,f,d;if(r.state!==Np)return u();for(l in n){if(d=n[l],d.name!==r.name)continue;if(d.state===bn)return ir(s);if(d.state===Rp)d.state=sr,d.timer.stop(),d.on.call("interrupt",e,e.__data__,d.index,d.group),delete n[l];else if(+l<t)d.state=sr,d.timer.stop(),d.on.call("cancel",e,e.__data__,d.index,d.group),delete n[l]}if(ir(function(){if(r.state===bn)r.state=Rp,r.timer.restart(a,r.delay,r.time),a(c)}),r.state=vn,r.on.call("start",e,e.__data__,r.index,r.group),r.state!==vn)return;r.state=bn,o=Array(f=r.tween.length);for(l=0,p=-1;l<f;++l)if(d=r.tween[l].value.call(e,e.__data__,r.index,r.group))o[++p]=d;o.length=p+1}function a(c){var l=c<r.duration?r.ease.call(null,c/r.duration):(r.timer.restart(u),r.state=_n,1),p=-1,f=o.length;while(++p<f)o[p].call(e,l);if(r.state===_n)r.on.call("end",e,e.__data__,r.index,r.group),u()}function u(){r.state=sr,r.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function He(e,t){var r=e.__transition,n,o,i=!0,s;if(!r)return;t=t==null?null:t+"";for(s in r){if((n=r[s]).name!==t){i=!1;continue}o=n.state>vn&&n.state<_n,n.state=sr,n.timer.stop(),n.on.call(o?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete r[s]}if(i)delete e.__transition}function Mi(e){return this.each(function(){He(this,e)})}function tg(e,t){var r,n;return function(){var o=W(this,e),i=o.tween;if(i!==r){n=r=i;for(var s=0,a=n.length;s<a;++s)if(n[s].name===t){n=n.slice(),n.splice(s,1);break}}o.tween=n}}function rg(e,t,r){var n,o;if(typeof r!=="function")throw Error();return function(){var i=W(this,e),s=i.tween;if(s!==n){o=(n=s).slice();for(var a={name:t,value:r},u=0,c=o.length;u<c;++u)if(o[u].name===t){o[u]=a;break}if(u===c)o.push(a)}i.tween=o}}function Di(e,t){var r=this._id;if(e+="",arguments.length<2){var n=H(this.node(),r).tween;for(var o=0,i=n.length,s;o<i;++o)if((s=n[o]).name===e)return s.value;return null}return this.each((t==null?tg:rg)(r,e,t))}function kt(e,t,r){var n=e._id;return e.each(function(){var o=W(this,n);(o.value||(o.value={}))[t]=r.apply(this,arguments)}),function(o){return H(o,n).value[t]}}function cr(e,t){var r;return(typeof t==="number"?le:t instanceof Je?mn:(r=Je(t))?(t=r,mn):on)(e,t)}function ng(e){return function(){this.removeAttribute(e)}}function og(e){return function(){this.removeAttributeNS(e.space,e.local)}}function ig(e,t,r){var n,o=r+"",i;return function(){var s=this.getAttribute(e);return s===o?null:s===n?i:i=t(n=s,r)}}function sg(e,t,r){var n,o=r+"",i;return function(){var s=this.getAttributeNS(e.space,e.local);return s===o?null:s===n?i:i=t(n=s,r)}}function ag(e,t,r){var n,o,i;return function(){var s,a=r(this),u;if(a==null)return void this.removeAttribute(e);return s=this.getAttribute(e),u=a+"",s===u?null:s===n&&u===o?i:(o=u,i=t(n=s,a))}}function cg(e,t,r){var n,o,i;return function(){var s,a=r(this),u;if(a==null)return void this.removeAttributeNS(e.space,e.local);return s=this.getAttributeNS(e.space,e.local),u=a+"",s===u?null:s===n&&u===o?i:(o=u,i=t(n=s,a))}}function Li(e,t){var r=ze(e),n=r==="transform"?Pi:cr;return this.attrTween(e,typeof t==="function"?(r.local?cg:ag)(r,n,kt(this,"attr."+e,t)):t==null?(r.local?og:ng)(r):(r.local?sg:ig)(r,n,t))}function ug(e,t){return function(r){this.setAttribute(e,t.call(this,r))}}function lg(e,t){return function(r){this.setAttributeNS(e.space,e.local,t.call(this,r))}}function pg(e,t){var r,n;function o(){var i=t.apply(this,arguments);if(i!==n)r=(n=i)&&lg(e,i);return r}return o._value=t,o}function fg(e,t){var r,n;function o(){var i=t.apply(this,arguments);if(i!==n)r=(n=i)&&ug(e,i);return r}return o._value=t,o}function Bi(e,t){var r="attr."+e;if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!=="function")throw Error();var n=ze(e);return this.tween(r,(n.local?pg:fg)(n,t))}function dg(e,t){return function(){ar(this,e).delay=+t.apply(this,arguments)}}function mg(e,t){return t=+t,function(){ar(this,e).delay=t}}function ji(e){var t=this._id;return arguments.length?this.each((typeof e==="function"?dg:mg)(t,e)):H(this.node(),t).delay}function hg(e,t){return function(){W(this,e).duration=+t.apply(this,arguments)}}function gg(e,t){return t=+t,function(){W(this,e).duration=t}}function Fi(e){var t=this._id;return arguments.length?this.each((typeof e==="function"?hg:gg)(t,e)):H(this.node(),t).duration}function xg(e,t){if(typeof t!=="function")throw Error();return function(){W(this,e).ease=t}}function Ui(e){var t=this._id;return arguments.length?this.each(xg(t,e)):H(this.node(),t).ease}function yg(e,t){return function(){var r=t.apply(this,arguments);if(typeof r!=="function")throw Error();W(this,e).ease=r}}function qi(e){if(typeof e!=="function")throw Error();return this.each(yg(this._id,e))}function Vi(e){if(typeof e!=="function")e=yt(e);for(var t=this._groups,r=t.length,n=Array(r),o=0;o<r;++o)for(var i=t[o],s=i.length,a=n[o]=[],u,c=0;c<s;++c)if((u=i[c])&&e.call(u,u.__data__,c,i))a.push(u);return new ee(n,this._parents,this._name,this._id)}function Ji(e){if(e._id!==this._id)throw Error();for(var t=this._groups,r=e._groups,n=t.length,o=r.length,i=Math.min(n,o),s=Array(n),a=0;a<i;++a)for(var u=t[a],c=r[a],l=u.length,p=s[a]=Array(l),f,d=0;d<l;++d)if(f=u[d]||c[d])p[d]=f;for(;a<n;++a)s[a]=t[a];return new ee(s,this._parents,this._name,this._id)}function bg(e){return(e+"").trim().split(/^|\s+/).every(function(t){var r=t.indexOf(".");if(r>=0)t=t.slice(0,r);return!t||t==="start"})}function vg(e,t,r){var n,o,i=bg(t)?ar:W;return function(){var s=i(this,e),a=s.on;if(a!==n)(o=(n=a).copy()).on(t,r);s.on=o}}function Hi(e,t){var r=this._id;return arguments.length<2?H(this.node(),r).on.on(e):this.each(vg(r,e,t))}function _g(e){return function(){var t=this.parentNode;for(var r in this.__transition)if(+r!==e)return;if(t)t.removeChild(this)}}function Ki(){return this.on("end.remove",_g(this._id))}function Gi(e){var t=this._name,r=this._id;if(typeof e!=="function")e=qe(e);for(var n=this._groups,o=n.length,i=Array(o),s=0;s<o;++s)for(var a=n[s],u=a.length,c=i[s]=Array(u),l,p,f=0;f<u;++f)if((l=a[f])&&(p=e.call(l,l.__data__,f,a))){if("__data__"in l)p.__data__=l.__data__;c[f]=p,Re(c[f],t,r,f,c,H(l,r))}return new ee(i,this._parents,t,r)}function Xi(e){var t=this._name,r=this._id;if(typeof e!=="function")e=bt(e);for(var n=this._groups,o=n.length,i=[],s=[],a=0;a<o;++a)for(var u=n[a],c=u.length,l,p=0;p<c;++p)if(l=u[p]){for(var f=e.call(l,l.__data__,p,u),d,m=H(l,r),x=0,v=f.length;x<v;++x)if(d=f[x])Re(d,t,r,x,f,m);i.push(f),s.push(l)}return new ee(i,s,t,r)}var wg=Ne.prototype.constructor;function Yi(){return new wg(this._groups,this._parents)}function kg(e,t){var r,n,o;return function(){var i=Ve(this,e),s=(this.style.removeProperty(e),Ve(this,e));return i===s?null:i===r&&s===n?o:o=t(r=i,n=s)}}function Dp(e){return function(){this.style.removeProperty(e)}}function zg(e,t,r){var n,o=r+"",i;return function(){var s=Ve(this,e);return s===o?null:s===n?i:i=t(n=s,r)}}function $g(e,t,r){var n,o,i;return function(){var s=Ve(this,e),a=r(this),u=a+"";if(a==null)u=a=(this.style.removeProperty(e),Ve(this,e));return s===u?null:s===n&&u===o?i:(o=u,i=t(n=s,a))}}function Sg(e,t){var r,n,o,i="style."+t,s="end."+i,a;return function(){var u=W(this,e),c=u.on,l=u.value[i]==null?a||(a=Dp(t)):void 0;if(c!==r||o!==l)(n=(r=c).copy()).on(s,o=l);u.on=n}}function Wi(e,t,r){var n=(e+="")==="transform"?Ii:cr;return t==null?this.styleTween(e,kg(e,n)).on("end.style."+e,Dp(e)):typeof t==="function"?this.styleTween(e,$g(e,n,kt(this,"style."+e,t))).each(Sg(this._id,e)):this.styleTween(e,zg(e,n,t),r).on("end.style."+e,null)}function Ig(e,t,r){return function(n){this.style.setProperty(e,t.call(this,n),r)}}function Pg(e,t,r){var n,o;function i(){var s=t.apply(this,arguments);if(s!==o)n=(o=s)&&Ig(e,s,r);return n}return i._value=t,i}function Qi(e,t,r){var n="style."+(e+="");if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!=="function")throw Error();return this.tween(n,Pg(e,t,r==null?"":r))}function Zg(e){return function(){this.textContent=e}}function Eg(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function es(e){return this.tween("text",typeof e==="function"?Eg(kt(this,"text",e)):Zg(e==null?"":e+""))}function Og(e){return function(t){this.textContent=e.call(this,t)}}function Ag(e){var t,r;function n(){var o=e.apply(this,arguments);if(o!==r)t=(r=o)&&Og(o);return t}return n._value=e,n}function ts(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!=="function")throw Error();return this.tween(t,Ag(e))}function rs(){var e=this._name,t=this._id,r=wn();for(var n=this._groups,o=n.length,i=0;i<o;++i)for(var s=n[i],a=s.length,u,c=0;c<a;++c)if(u=s[c]){var l=H(u,t);Re(u,e,r,c,s,{time:l.time+l.delay+l.duration,delay:0,duration:l.duration,ease:l.ease})}return new ee(n,this._parents,e,r)}function ns(){var e,t,r=this,n=r._id,o=r.size();return new Promise(function(i,s){var a={value:s},u={value:function(){if(--o===0)i()}};if(r.each(function(){var c=W(this,n),l=c.on;if(l!==e)t=(e=l).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(u);c.on=t}),o===0)i()})}var Cg=0;function ee(e,t,r,n){this._groups=e,this._parents=t,this._name=r,this._id=n}function Lp(e){return Ne().transition(e)}function wn(){return++Cg}var Me=Ne.prototype;ee.prototype=Lp.prototype={constructor:ee,select:Gi,selectAll:Xi,selectChild:Me.selectChild,selectChildren:Me.selectChildren,filter:Vi,merge:Ji,selection:Yi,transition:rs,call:Me.call,nodes:Me.nodes,node:Me.node,size:Me.size,empty:Me.empty,each:Me.each,on:Hi,attr:Li,attrTween:Bi,style:Wi,styleTween:Qi,text:es,textTween:ts,remove:Ki,tween:Di,delay:ji,duration:Fi,ease:Ui,easeVarying:qi,end:ns,[Symbol.iterator]:Me[Symbol.iterator]};function kn(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Tg={time:null,delay:0,duration:250,ease:kn};function Ng(e,t){var r;while(!(r=e.__transition)||!(r=r[t]))if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return r}function os(e){var t,r;if(e instanceof ee)t=e._id,e=e._name;else t=wn(),(r=Tg).time=or(),e=e==null?null:e+"";for(var n=this._groups,o=n.length,i=0;i<o;++i)for(var s=n[i],a=s.length,u,c=0;c<a;++c)if(u=s[c])Re(u,e,t,c,s,r||Ng(u,t));return new ee(n,this._parents,e,t)}Ne.prototype.interrupt=Mi;Ne.prototype.transition=os;var ur=(e)=>()=>e;function is(e,{sourceEvent:t,target:r,transform:n,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},transform:{value:n,enumerable:!0,configurable:!0},_:{value:o}})}function xe(e,t,r){this.k=e,this.x=t,this.y=r}xe.prototype={constructor:xe,scale:function(e){return e===1?this:new xe(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new xe(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Ie=new xe(1,0,0);lr.prototype=xe.prototype;function lr(e){while(!e.__zoom)if(!(e=e.parentNode))return Ie;return e.__zoom}function zn(e){e.stopImmediatePropagation()}function at(e){e.preventDefault(),e.stopImmediatePropagation()}function Rg(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Mg(){var e=this;if(e instanceof SVGElement){if(e=e.ownerSVGElement||e,e.hasAttribute("viewBox"))return e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]];return[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]}return[[0,0],[e.clientWidth,e.clientHeight]]}function Bp(){return this.__zoom||Ie}function Dg(e){return-e.deltaY*(e.deltaMode===1?0.05:e.deltaMode?1:0.002)*(e.ctrlKey?10:1)}function Lg(){return navigator.maxTouchPoints||"ontouchstart"in this}function Bg(e,t,r){var n=e.invertX(t[0][0])-r[0][0],o=e.invertX(t[1][0])-r[1][0],i=e.invertY(t[0][1])-r[0][1],s=e.invertY(t[1][1])-r[1][1];return e.translate(o>n?(n+o)/2:Math.min(0,n)||Math.max(0,o),s>i?(i+s)/2:Math.min(0,i)||Math.max(0,s))}function $n(){var e=Rg,t=Mg,r=Bg,n=Dg,o=Lg,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,u=Zi,c=Ht("start","zoom","end"),l,p,f,d=500,m=150,x=0,v=10;function b(h){h.property("__zoom",Bp).on("wheel.zoom",Le,{passive:!1}).on("mousedown.zoom",Xe).on("dblclick.zoom",Be).filter(o).on("touchstart.zoom",hr).on("touchmove.zoom",On).on("touchend.zoom touchcancel.zoom",An).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}b.transform=function(h,z,y,I){var E=h.selection?h.selection():h;if(E.property("__zoom",Bp),h!==E)T(h,z,y,I);else E.interrupt().each(function(){O(this,arguments).event(I).start().zoom(null,typeof z==="function"?z.apply(this,arguments):z).end()})},b.scaleBy=function(h,z,y,I){b.scaleTo(h,function(){var E=this.__zoom.k,A=typeof z==="function"?z.apply(this,arguments):z;return E*A},y,I)},b.scaleTo=function(h,z,y,I){b.transform(h,function(){var E=t.apply(this,arguments),A=this.__zoom,C=y==null?j(E):typeof y==="function"?y.apply(this,arguments):y,R=A.invert(C),q=typeof z==="function"?z.apply(this,arguments):z;return r(D(Z(A,q),C,R),E,s)},y,I)},b.translateBy=function(h,z,y,I){b.transform(h,function(){return r(this.__zoom.translate(typeof z==="function"?z.apply(this,arguments):z,typeof y==="function"?y.apply(this,arguments):y),t.apply(this,arguments),s)},null,I)},b.translateTo=function(h,z,y,I,E){b.transform(h,function(){var A=t.apply(this,arguments),C=this.__zoom,R=I==null?j(A):typeof I==="function"?I.apply(this,arguments):I;return r(Ie.translate(R[0],R[1]).scale(C.k).translate(typeof z==="function"?-z.apply(this,arguments):-z,typeof y==="function"?-y.apply(this,arguments):-y),A,s)},I,E)};function Z(h,z){return z=Math.max(i[0],Math.min(i[1],z)),z===h.k?h:new xe(z,h.x,h.y)}function D(h,z,y){var I=z[0]-y[0]*h.k,E=z[1]-y[1]*h.k;return I===h.x&&E===h.y?h:new xe(h.k,I,E)}function j(h){return[(+h[0][0]+ +h[1][0])/2,(+h[0][1]+ +h[1][1])/2]}function T(h,z,y,I){h.on("start.zoom",function(){O(this,arguments).event(I).start()}).on("interrupt.zoom end.zoom",function(){O(this,arguments).event(I).end()}).tween("zoom",function(){var E=this,A=arguments,C=O(E,A).event(I),R=t.apply(E,A),q=y==null?j(R):typeof y==="function"?y.apply(E,A):y,ye=Math.max(R[1][0]-R[0][0],R[1][1]-R[0][1]),G=E.__zoom,fe=typeof z==="function"?z.apply(E,A):z,Ze=u(G.invert(q).concat(ye/G.k),fe.invert(q).concat(ye/fe.k));return function(de){if(de===1)de=fe;else{var Ee=Ze(de),Cn=ye/Ee[2];de=new xe(Cn,q[0]-Ee[0]*Cn,q[1]-Ee[1]*Cn)}C.zoom(null,de)}})}function O(h,z,y){return!y&&h.__zooming||new J(h,z)}function J(h,z){this.that=h,this.args=z,this.active=0,this.sourceEvent=null,this.extent=t.apply(h,z),this.taps=0}J.prototype={event:function(h){if(h)this.sourceEvent=h;return this},start:function(){if(++this.active===1)this.that.__zooming=this,this.emit("start");return this},zoom:function(h,z){if(this.mouse&&h!=="mouse")this.mouse[1]=z.invert(this.mouse[0]);if(this.touch0&&h!=="touch")this.touch0[1]=z.invert(this.touch0[0]);if(this.touch1&&h!=="touch")this.touch1[1]=z.invert(this.touch1[0]);return this.that.__zoom=z,this.emit("zoom"),this},end:function(){if(--this.active===0)delete this.that.__zooming,this.emit("end");return this},emit:function(h){var z=Y(this.that).datum();c.call(h,this.that,new is(h,{sourceEvent:this.sourceEvent,target:b,type:h,transform:this.that.__zoom,dispatch:c}),z)}};function Le(h,...z){if(!e.apply(this,arguments))return;var y=O(this,z).event(h),I=this.__zoom,E=Math.max(i[0],Math.min(i[1],I.k*Math.pow(2,n.apply(this,arguments)))),A=$e(h);if(y.wheel){if(y.mouse[0][0]!==A[0]||y.mouse[0][1]!==A[1])y.mouse[1]=I.invert(y.mouse[0]=A);clearTimeout(y.wheel)}else if(I.k===E)return;else y.mouse=[A,I.invert(A)],He(this),y.start();at(h),y.wheel=setTimeout(C,m),y.zoom("mouse",r(D(Z(I,E),y.mouse[0],y.mouse[1]),y.extent,s));function C(){y.wheel=null,y.end()}}function Xe(h,...z){if(f||!e.apply(this,arguments))return;var y=h.currentTarget,I=O(this,z,!0).event(h),E=Y(h.view).on("mousemove.zoom",q,!0).on("mouseup.zoom",ye,!0),A=$e(h,y),{clientX:C,clientY:R}=h;nn(h.view),zn(h),I.mouse=[A,this.__zoom.invert(A)],He(this),I.start();function q(G){if(at(G),!I.moved){var fe=G.clientX-C,Ze=G.clientY-R;I.moved=fe*fe+Ze*Ze>x}I.event(G).zoom("mouse",r(D(I.that.__zoom,I.mouse[0]=$e(G,y),I.mouse[1]),I.extent,s))}function ye(G){E.on("mousemove.zoom mouseup.zoom",null),zi(G.view,I.moved),at(G),I.event(G).end()}}function Be(h,...z){if(!e.apply(this,arguments))return;var y=this.__zoom,I=$e(h.changedTouches?h.changedTouches[0]:h,this),E=y.invert(I),A=y.k*(h.shiftKey?0.5:2),C=r(D(Z(y,A),I,E),t.apply(this,z),s);if(at(h),a>0)Y(this).transition().duration(a).call(T,C,I,h);else Y(this).call(b.transform,C,I,h)}function hr(h,...z){if(!e.apply(this,arguments))return;var y=h.touches,I=y.length,E=O(this,z,h.changedTouches.length===I).event(h),A,C,R,q;zn(h);for(C=0;C<I;++C)if(R=y[C],q=$e(R,this),q=[q,this.__zoom.invert(q),R.identifier],!E.touch0)E.touch0=q,A=!0,E.taps=1+!!l;else if(!E.touch1&&E.touch0[2]!==q[2])E.touch1=q,E.taps=0;if(l)l=clearTimeout(l);if(A){if(E.taps<2)p=q[0],l=setTimeout(function(){l=null},d);He(this),E.start()}}function On(h,...z){if(!this.__zooming)return;var y=O(this,z).event(h),I=h.changedTouches,E=I.length,A,C,R,q;at(h);for(A=0;A<E;++A)if(C=I[A],R=$e(C,this),y.touch0&&y.touch0[2]===C.identifier)y.touch0[0]=R;else if(y.touch1&&y.touch1[2]===C.identifier)y.touch1[0]=R;if(C=y.that.__zoom,y.touch1){var ye=y.touch0[0],G=y.touch0[1],fe=y.touch1[0],Ze=y.touch1[1],de=(de=fe[0]-ye[0])*de+(de=fe[1]-ye[1])*de,Ee=(Ee=Ze[0]-G[0])*Ee+(Ee=Ze[1]-G[1])*Ee;C=Z(C,Math.sqrt(de/Ee)),R=[(ye[0]+fe[0])/2,(ye[1]+fe[1])/2],q=[(G[0]+Ze[0])/2,(G[1]+Ze[1])/2]}else if(y.touch0)R=y.touch0[0],q=y.touch0[1];else return;y.zoom("touch",r(D(C,R,q),y.extent,s))}function An(h,...z){if(!this.__zooming)return;var y=O(this,z).event(h),I=h.changedTouches,E=I.length,A,C;if(zn(h),f)clearTimeout(f);f=setTimeout(function(){f=null},d);for(A=0;A<E;++A)if(C=I[A],y.touch0&&y.touch0[2]===C.identifier)delete y.touch0;else if(y.touch1&&y.touch1[2]===C.identifier)delete y.touch1;if(y.touch1&&!y.touch0)y.touch0=y.touch1,delete y.touch1;if(y.touch0)y.touch0[1]=this.__zoom.invert(y.touch0[0]);else if(y.end(),y.taps===2){if(C=$e(C,this),Math.hypot(p[0]-C[0],p[1]-C[1])<v){var R=Y(this).on("dblclick.zoom");if(R)R.apply(this,arguments)}}}return b.wheelDelta=function(h){return arguments.length?(n=typeof h==="function"?h:ur(+h),b):n},b.filter=function(h){return arguments.length?(e=typeof h==="function"?h:ur(!!h),b):e},b.touchable=function(h){return arguments.length?(o=typeof h==="function"?h:ur(!!h),b):o},b.extent=function(h){return arguments.length?(t=typeof h==="function"?h:ur([[+h[0][0],+h[0][1]],[+h[1][0],+h[1][1]]]),b):t},b.scaleExtent=function(h){return arguments.length?(i[0]=+h[0],i[1]=+h[1],b):[i[0],i[1]]},b.translateExtent=function(h){return arguments.length?(s[0][0]=+h[0][0],s[1][0]=+h[1][0],s[0][1]=+h[0][1],s[1][1]=+h[1][1],b):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},b.constrain=function(h){return arguments.length?(r=h,b):r},b.duration=function(h){return arguments.length?(a=+h,b):a},b.interpolate=function(h){return arguments.length?(u=h,b):u},b.on=function(){var h=c.on.apply(c,arguments);return h===c?b:h},b.clickDistance=function(h){return arguments.length?(x=(h=+h)*h,b):Math.sqrt(x)},b.tapDistance=function(h){return arguments.length?(v=+h,b):v},b}function jg(e){let t=e.map((r)=>_.view?.items.find((n)=>n.id===r)).filter((r)=>r!==void 0);return t.find(ie)??t[0]}function Fg(e){return`${ke(e)} ${e.description}`.toLowerCase().includes(_.search.toLowerCase())}function jp(e){let t=P("constellation-list");t.replaceChildren();let r=new Map(e.constellation.hubs.map((n)=>[n.id,n.parentId]));for(let n of e.constellation.hubs.filter((o)=>o.parentId===null)){let o=w({tag:"section",className:"skill-list-group"});o.append(w({tag:"h3",text:n.title}));for(let i of e.constellation.leaves.filter((s)=>{let a=s.parentId;while(a){if(a===n.id)return!0;a=r.get(a)??null}return!1})){let s=jg(i.itemIds);if(!s||!Fg(s))continue;let a=w({tag:"button",className:"skill-list-item",text:ke(s)});a.classList.toggle("equipped",ie(s)),a.addEventListener("click",()=>e.inspect(s.id)),o.append(a)}if(o.childElementCount>1)t.append(o)}}function Ug(e){var t=0,r=e.children,n=r&&r.length;if(!n)t=1;else while(--n>=0)t+=r[n].value;e.value=t}function ss(){return this.eachAfter(Ug)}function as(e,t){let r=-1;for(let n of this)e.call(t,n,++r,this);return this}function cs(e,t){var r=this,n=[r],o,i,s=-1;while(r=n.pop())if(e.call(t,r,++s,this),o=r.children)for(i=o.length-1;i>=0;--i)n.push(o[i]);return this}function us(e,t){var r=this,n=[r],o=[],i,s,a,u=-1;while(r=n.pop())if(o.push(r),i=r.children)for(s=0,a=i.length;s<a;++s)n.push(i[s]);while(r=o.pop())e.call(t,r,++u,this);return this}function ls(e,t){let r=-1;for(let n of this)if(e.call(t,n,++r,this))return n}function ps(e){return this.eachAfter(function(t){var r=+e(t.data)||0,n=t.children,o=n&&n.length;while(--o>=0)r+=n[o].value;t.value=r})}function fs(e){return this.eachBefore(function(t){if(t.children)t.children.sort(e)})}function ds(e){var t=this,r=qg(t,e),n=[t];while(t!==r)t=t.parent,n.push(t);var o=n.length;while(e!==r)n.splice(o,0,e),e=e.parent;return n}function qg(e,t){if(e===t)return e;var r=e.ancestors(),n=t.ancestors(),o=null;e=r.pop(),t=n.pop();while(e===t)o=e,e=r.pop(),t=n.pop();return o}function ms(){var e=this,t=[e];while(e=e.parent)t.push(e);return t}function hs(){return Array.from(this)}function gs(){var e=[];return this.eachBefore(function(t){if(!t.children)e.push(t)}),e}function xs(){var e=this,t=[];return e.each(function(r){if(r!==e)t.push({source:r.parent,target:r})}),t}function*ys(){var e=this,t,r=[e],n,o,i;do{t=r.reverse(),r=[];while(e=t.pop())if(yield e,n=e.children)for(o=0,i=n.length;o<i;++o)r.push(n[o])}while(r.length)}function zt(e,t){if(e instanceof Map){if(e=[void 0,e],t===void 0)t=Hg}else if(t===void 0)t=Jg;var r=new ct(e),n,o=[r],i,s,a,u;while(n=o.pop())if((s=t(n.data))&&(u=(s=Array.from(s)).length)){n.children=s;for(a=u-1;a>=0;--a)o.push(i=s[a]=new ct(s[a])),i.parent=n,i.depth=n.depth+1}return r.eachBefore(Gg)}function Vg(){return zt(this).eachBefore(Kg)}function Jg(e){return e.children}function Hg(e){return Array.isArray(e)?e[1]:null}function Kg(e){if(e.data.value!==void 0)e.value=e.data.value;e.data=e.data.data}function Gg(e){var t=0;do e.height=t;while((e=e.parent)&&e.height<++t)}function ct(e){this.data=e,this.depth=this.height=0,this.parent=null}ct.prototype=zt.prototype={constructor:ct,count:ss,each:as,eachAfter:us,eachBefore:cs,find:ls,sum:ps,sort:fs,path:ds,ancestors:ms,descendants:hs,leaves:gs,links:xs,copy:Vg,[Symbol.iterator]:ys};function Xg(e,t){return e.parent===t.parent?1:2}function bs(e){var t=e.children;return t?t[0]:e.t}function vs(e){var t=e.children;return t?t[t.length-1]:e.t}function Yg(e,t,r){var n=r/(t.i-e.i);t.c-=n,t.s+=r,e.c+=n,t.z+=r,t.m+=r}function Wg(e){var t=0,r=0,n=e.children,o=n.length,i;while(--o>=0)i=n[o],i.z+=t,i.m+=t,t+=i.s+(r+=i.c)}function Qg(e,t,r){return e.a.parent===t.parent?e.a:r}function Sn(e,t){this._=e,this.parent=null,this.children=null,this.A=null,this.a=this,this.z=0,this.m=0,this.c=0,this.s=0,this.t=null,this.i=t}Sn.prototype=Object.create(ct.prototype);function ex(e){var t=new Sn(e,0),r,n=[t],o,i,s,a;while(r=n.pop())if(i=r._.children){r.children=Array(a=i.length);for(s=a-1;s>=0;--s)n.push(o=r.children[s]=new Sn(i[s],s)),o.parent=r}return(t.parent=new Sn(null,0)).children=[t],t}function In(){var e=Xg,t=1,r=1,n=null;function o(c){var l=ex(c);if(l.eachAfter(i),l.parent.m=-l.z,l.eachBefore(s),n)c.eachBefore(u);else{var p=c,f=c,d=c;c.eachBefore(function(Z){if(Z.x<p.x)p=Z;if(Z.x>f.x)f=Z;if(Z.depth>d.depth)d=Z});var m=p===f?1:e(p,f)/2,x=m-p.x,v=t/(f.x+m+x),b=r/(d.depth||1);c.eachBefore(function(Z){Z.x=(Z.x+x)*v,Z.y=Z.depth*b})}return c}function i(c){var l=c.children,p=c.parent.children,f=c.i?p[c.i-1]:null;if(l){Wg(c);var d=(l[0].z+l[l.length-1].z)/2;if(f)c.z=f.z+e(c._,f._),c.m=c.z-d;else c.z=d}else if(f)c.z=f.z+e(c._,f._);c.parent.A=a(c,f,c.parent.A||p[0])}function s(c){c._.x=c.z+c.parent.m,c.m+=c.parent.m}function a(c,l,p){if(l){var f=c,d=c,m=l,x=f.parent.children[0],v=f.m,b=d.m,Z=m.m,D=x.m,j;while(m=vs(m),f=bs(f),m&&f){if(x=bs(x),d=vs(d),d.a=c,j=m.z+Z-f.z-v+e(m._,f._),j>0)Yg(Qg(m,c,p),c,j),v+=j,b+=j;Z+=m.m,v+=f.m,D+=x.m,b+=d.m}if(m&&!vs(d))d.t=m,d.m+=Z-b;if(f&&!bs(x))x.t=f,x.m+=v-D,p=c}return p}function u(c){c.x*=t,c.y=c.depth*r}return o.separation=function(c){return arguments.length?(e=c,o):e},o.size=function(c){return arguments.length?(n=!1,t=+c[0],r=+c[1],o):n?null:[t,r]},o.nodeSize=function(c){return arguments.length?(n=!0,t=+c[0],r=+c[1],o):n?[t,r]:null},o}function _s(e){if(e===void 0)throw Error("Constellation layout is incomplete");return e}function tx(e){let t=new Map;for(let o of e.hubs)t.set(o.id,{id:o.id,title:o.title,itemIds:[],relatedHubIds:[],children:[],kind:"hub"});let r={id:"constellation-root",title:"Shadowclone",itemIds:[],relatedHubIds:[],children:[],kind:"root"};for(let o of e.hubs){let i=t.get(o.id),s=o.parentId?t.get(o.parentId):r;if(i&&s)s.children.push(i)}for(let o of e.leaves)t.get(o.parentId)?.children.push({id:o.id,title:"",itemIds:o.itemIds,relatedHubIds:o.relatedHubIds,children:[],kind:"skill"});let n=(o)=>{o.children.sort((i,s)=>i.id.localeCompare(s.id));for(let i of o.children)n(i)};return n(r),r}function Fp(e){let t=tx(e.constellation),r=zt(t,(a)=>a.children.filter((u)=>u.kind!=="skill"));In().nodeSize([210,160])(r);let n=r.descendants().map((a)=>({id:a.data.id,title:a.data.title,itemIds:a.data.itemIds,relatedHubIds:a.data.relatedHubIds,kind:a.data.kind,parentId:a.parent?.data.id??null,x:_s(a.x)+e.width/2,y:e.height-92-_s(a.y)}));if(e.constellation.leaves.length===0&&r.height===1){let a=n.filter((p)=>p.kind==="hub"),u=Math.min(4,a.length),c=Math.ceil(a.length/u),l=new Map(a.map((p,f)=>[p.id,f]));n=n.map((p)=>{let f=l.get(p.id);return f===void 0?p:{...p,x:e.width/2+(f%u-(u-1)/2)*210,y:e.height-92-(c-Math.floor(f/u))*160}})}let o=[...n];for(let a of r.descendants()){let u=a.data.children.filter((c)=>c.kind==="skill");for(let[c,l]of u.entries())o.push({...l,parentId:a.data.id,x:_s(a.x)+e.width/2,y:e.height-92-r.height*160-88*(c+1)})}let i=new Map(o.map((a)=>[a.id,a])),s=o.flatMap((a)=>{let u=a.parentId?i.get(a.parentId):void 0;return u?[{id:`${u.id}:${a.id}`,sourceX:u.x,sourceY:u.y,targetX:a.x,targetY:a.y,related:!1}]:[]});for(let a of o.filter((u)=>u.kind==="skill"))for(let u of a.relatedHubIds){let c=i.get(u);if(c)s.push({id:`${a.id}:${c.id}:related`,sourceX:a.x,sourceY:a.y,targetX:c.x,targetY:c.y,related:!0})}return{nodes:o,links:s}}var rx={modules:"M4 4h6v6H4ZM14 4h6v6h-6ZM4 14h6v6H4ZM14 14h6v6h-6Z",code:"m8 5-6 7 6 7m8-14 6 7-6 7m-3-16-2 18",focus:"M8 3H4v4m12-4h4v4M4 17v4h4m12-4v4h-4M8 9h8v6H8Z",bug:"M9 5 7 2m8 3 2-3M8 9V7a4 4 0 0 1 8 0v2M6 9h12v6a6 6 0 0 1-12 0Zm6 0v12M2 10h4m12 0h4M2 15h4m12 0h4M4 21l3-3m10 0 3 3",flask:"M9 3h6m-5 0v7l-6 9q-1 2 2 2h12q3 0 2-2l-6-9V3M7 15h10",check:"m2 12 5 5L19 5M12 17l10-10",route:"M7 5h10a3 3 0 0 1 0 6H7a3 3 0 0 0 0 6h10M7 2a3 3 0 1 0 0 6 3 3 0 0 0 0-6m10 12a3 3 0 1 0 0 6 3 3 0 0 0 0-6",compass:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20m-3 7 8-2-2 8-8 2Z",flag:"M5 22V3q4-3 8 0t7 0v10q-3 3-7 0t-8 0",merge:"M6 2v8q0 5 6 5h6m-4-4 4 4-4 4M6 18v4M18 2v5",layers:"m12 2 10 6-10 6L2 8Zm-9 11 9 5 9-5M3 17l9 5 9-5",link:"m9 15 6-6m-7 4-2 2a4 4 0 0 0 6 6l3-3m1-5 2-2a4 4 0 0 0-6-6L9 8",shield:"m12 2 8 3v7q0 6-8 10-8-4-8-10V5Zm-4 9 3 3 5-6",question:"M8 7a4 4 0 1 1 6 4q-2 1-2 4m0 4v1M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20",spark:"m12 2 3 7 7 3-7 3-3 7-3-7-7-3 7-3Z",search:"M10 3a7 7 0 1 0 0 14 7 7 0 0 0 0-14m5 12 6 6"},nx={"design-deep-modules":"modules","typescript-type-safety":"code","scope-confirmed-changes":"focus","refactor-boundaries":"layers","refactor-preserve":"shield","dependencies-existing":"link","dependencies-mature":"layers","diagnose-before-editing":"bug","prove-regression-tests":"flask","testing-first":"flask","testing-risk-based":"shield","research-primary-sources":"search","verify-and-review":"check","planning-first":"route","planning-when-costly":"compass","questions-autonomous":"flag","questions-early":"question","resolve-conflicts-by-intent":"merge"};function Up(e){let t=document.createElementNS("http://www.w3.org/2000/svg","svg"),r=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("fill","none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","1.25"),t.setAttribute("stroke-linecap","round"),t.setAttribute("stroke-linejoin","round"),t.setAttribute("aria-hidden","true"),r.setAttribute("d",rx[e]),t.append(r),t}function qp(e){return Up(nx[e.id]??"spark")}function Vp(e){let t=e.toLowerCase(),n=Object.entries({engineering:"code",architecture:"modules",typescript:"code",workflow:"route",dependenc:"layers",testing:"flask",communication:"question",debugging:"bug",planning:"compass",research:"search",review:"check",setup:"spark"}).find(([o])=>t.includes(o))?.[1]??"compass";return Up(n)}function Jp(e){let t=new Map(e.constellation.hubs.map((r)=>[r.id,r.parentId]));for(let r of e.constellation.leaves){if(!r.itemIds.some((o)=>e.matchingItemIds.has(o)))continue;let n=r.parentId;while(n)e.expandedHubIds.add(n),n=t.get(n)??null}}function Hp(e){let t=new Set,r=new Map(e.constellation.hubs.map((o)=>[o.id,o.parentId]));return{hubs:e.constellation.hubs.filter((o)=>{let i=o.parentId;while(i){if(!e.expandedHubIds.has(i))return!1;i=r.get(i)??null}return t.add(o.id),!0}),leaves:e.constellation.leaves.filter((o)=>t.has(o.parentId)&&e.expandedHubIds.has(o.parentId))}}function Kp(e){let t=new Map,r=new Map(e.hubs.map((n)=>[n.id,n.parentId]));for(let n of e.leaves){let o=n.parentId;while(o)t.set(o,(t.get(o)??0)+1),o=r.get(o)??null}return t}function ws(e){let t=Math.min(...e.nodes.map((s)=>s.x))-100,r=Math.max(...e.nodes.map((s)=>s.x))+100,n=Math.min(...e.nodes.map((s)=>s.y))-56,o=Math.max(...e.nodes.map((s)=>s.y))+76,i=Math.min(1,(e.width-40)/(r-t),(e.height-80)/(o-n));return{scale:i,x:e.width/2-i*(t+r)/2,y:e.height/2-i*(n+o)/2}}var ox="http://www.w3.org/2000/svg",$t=()=>{return},Ke="",pr=null,De=new Set,Gp="",Xp=new Map,ks=null,Yp=new Map;function Pe(e){return document.createElementNS(ox,e)}function zs(e){let t=e.itemIds.map((r)=>Yp.get(r)).filter((r)=>r!==void 0);return t.find(ie)??t[0]}function Pn(e){let t=zs(e);return t?ke(t):e.title}function Wp(e){if(!_.search)return!0;let t=zs(e);return`${Pn(e)} ${t?.description??""}`.toLowerCase().includes(_.search.toLowerCase())}function ix(e){let t=[""];for(let r of e.split(/\s+/)){let n=t.at(-1)??"";if(n&&n.length+r.length>22)t.push(r);else t[t.length-1]=`${n} ${r}`.trim()}return t.slice(0,2).map((r,n)=>`${r.slice(0,24)}${n===1&&t.length>2||r.length>24?"…":""}`)}function sx(e){let{group:t,node:r}=e,n=zs(r),o=Pe("g"),i=Pe(r.kind==="root"?"circle":"rect"),s=Pe("text"),a=n?ie(n):!1;if(o.setAttribute("class",`map-node map-node-${r.kind}`),o.setAttribute("transform",`translate(${r.x} ${r.y})`),o.classList.toggle("equipped",a),o.classList.toggle("search-miss",!Wp(r)),o.classList.toggle("focused",r.id===Ke),o.setAttribute("role","button"),o.setAttribute("tabindex","0"),o.setAttribute("aria-label",`${Pn(r)}${a?", equipped":""}`),r.kind==="root")i.setAttribute("r","26");else{let l=r.kind==="hub"?32:24;i.setAttribute("x",String(-l/2)),i.setAttribute("y",String(-l/2)),i.setAttribute("width",String(l)),i.setAttribute("height",String(l)),i.setAttribute("rx","6"),i.setAttribute("transform","rotate(45)")}s.setAttribute("text-anchor","middle");for(let[l,p]of ix(Pn(r)).entries()){let f=Pe("tspan");f.setAttribute("x","0"),f.setAttribute("y",String((r.kind==="root"?44:38)+l*14)),f.textContent=p,s.append(f)}let u=Pe("title");if(u.textContent=Pn(r),o.append(u),o.append(i,s),r.kind==="root"){let l=document.querySelector(".brand-mark");if(l instanceof HTMLImageElement){let p=Pe("image");p.setAttribute("href",l.src);for(let[f,d]of Object.entries({x:"-16",y:"-16",width:"32",height:"32"}))p.setAttribute(f,d);o.append(p)}}else{let l=Pe("foreignObject"),p=w({tag:"span",className:"map-node-icon"});l.setAttribute("x","-9"),l.setAttribute("y","-9"),l.setAttribute("width","18"),l.setAttribute("height","18"),p.append(n?qp(n):Vp(r.title)),l.append(p),o.append(l)}if(r.kind==="hub"){o.setAttribute("aria-expanded",String(De.has(r.id)));let l=Pe("text");l.setAttribute("class","map-node-count"),l.setAttribute("text-anchor","middle"),l.setAttribute("y","70");let p=Xp.get(r.id)??0;l.textContent=`${De.has(r.id)?"−":"+"} ${p} ${p===1?"skill":"skills"}`,o.append(l)}let c=()=>{if(n)$t(n.id);else if(r.kind==="hub"){if(De.has(r.id))De.delete(r.id);else De.add(r.id);Ke=r.id}fr({inspect:$t})};o.addEventListener("click",c),o.addEventListener("keydown",(l)=>{if(l.key==="Enter"||l.key===" ")l.preventDefault(),c()}),t.append(o)}function fr(e){$t=e.inspect;let t=No("constellation-map"),r=_.view;if(!r)return;jp({constellation:r.constellation,inspect:$t});let n=t.getBoundingClientRect();if(n.width<=0||n.height<=0)return;Yp=new Map(r.items.map((l)=>[l.id,l]));let o=[...r.constellation.hubs.map((l)=>`${l.id}:${l.parentId}`),...r.constellation.leaves.map((l)=>l.id)].join(`
67
+ `),i=o!==Gp;if(i){if(De.clear(),r.constellation.leaves.length<=40)for(let l of r.constellation.hubs)De.add(l.id);Gp=o,Ke=""}if(_.search)Jp({constellation:r.constellation,expandedHubIds:De,matchingItemIds:new Set(r.items.filter((l)=>`${ke(l)} ${l.description}`.toLowerCase().includes(_.search.toLowerCase())).map((l)=>l.id))});Xp=Kp(r.constellation);let s=Fp({constellation:Hp({constellation:r.constellation,expandedHubIds:De}),width:n.width,height:n.height});ks=s,t.setAttribute("viewBox",`0 0 ${n.width} ${n.height}`),t.replaceChildren();let a=Pe("g");a.setAttribute("class","constellation-viewport"),t.append(a);for(let l of s.links){let p=Pe("path");p.setAttribute("class",l.related?"map-link related":"map-link"),p.setAttribute("d",`M${l.sourceX} ${l.sourceY}L${l.targetX} ${l.targetY}`),a.append(p)}for(let l of s.nodes)sx({group:a,node:l});let u=$n().scaleExtent([0.1,2.5]).on("zoom",(l)=>{a.setAttribute("transform",l.transform.toString())});if(Y(t).call(u),a.setAttribute("transform",lr(t).toString()),pr=u,i){let l=ws({nodes:s.nodes,width:n.width,height:n.height});Y(t).call(u.transform,Ie.translate(l.x,l.y).scale(Math.max(0.65,l.scale)))}let c=_.search?s.nodes.find((l)=>l.kind==="skill"&&Wp(l)):Ke?s.nodes.find((l)=>l.id===Ke):void 0;if(c&&(Ke||_.search)){let l=Ie.translate(n.width/2,n.height/2).scale(1.25).translate(-c.x,-c.y);Y(t).call(u.transform,l)}}function Qp(){let e=No("constellation-map");new ResizeObserver(()=>fr({inspect:$t})).observe(e);let r=()=>{if(Ke="",pr)Y(e).call(pr.transform,Ie)};P("fit-constellation").addEventListener("click",()=>{if(!pr||!ks)return;Ke="";let o=e.getBoundingClientRect(),i=ws({nodes:ks.nodes,width:o.width,height:o.height});Y(e).call(pr.transform,Ie.translate(i.x,i.y).scale(i.scale))}),P("reset-constellation").addEventListener("click",r);let n=P("toggle-constellation-view");n.addEventListener("click",()=>{let o=P("constellation").classList.toggle("list-view");n.setAttribute("aria-pressed",String(o))})}function ef(){fr({inspect:$t})}var tf=null,St=null;function $s(){let e=P("model-description");if(e.replaceChildren(),!St||tf!==JSON.stringify(_.input))return;e.append(w({tag:"h3",text:St.title}),w({tag:"p",text:St.summary}));for(let t of St.strengths)e.append(w({tag:"p",text:`Strength: ${t}`}));for(let t of St.tradeoffs)e.append(w({tag:"p",text:`Tradeoff: ${t}`}))}async function rf(){let e=JSON.stringify(_.input),t=await ne({path:"/api/description/preview",schema:op,body:_.input});Wr({review:t,title:"Describe your agent.",explanation:"An interpretation of your selected guidance. It does not change your skills or add personality instructions.",confirm:"Send and describe",path:"/api/description/generate",schema:ip,accept:(r)=>{St=r.description,tf=e;for(let n of r.description.hubLabels){let o=_.view?.constellation.hubs.find((i)=>i.id===n.id);if(o)o.title=n.title}ef(),$s()}})}function nf(e){let t=new Map(e.constellation.hubs.map((i)=>[i.id,i])),r=new Map;for(let i of e.constellation.leaves){if(!i.itemIds.some((a)=>e.selectedItemIds.has(a)))continue;let s=t.get(i.parentId);while(s?.parentId)s=t.get(s.parentId);if(s)r.set(s.id,(r.get(s.id)??0)+1)}let n=[...r].map(([i,s])=>({title:t.get(i)?.title??"Guidance",count:s})).sort((i,s)=>s.count-i.count||i.title.localeCompare(s.title)),o=n[0];return o?{title:`The ${o.title} Pathfinder`,traits:n.slice(0,4)}:null}function of(){let e=_.view?.items.filter((o)=>o.owner!=="provider"&&ie(o))??[],t=_.view?nf({constellation:_.view.constellation,selectedItemIds:new Set(e.map((o)=>o.id))}):null;P("equipped-count").textContent=`${e.length} ${e.length===1?"skill":"skills"} equipped${_.dirty?" · unsaved changes":""}`,P("identity-title").textContent=t?.title??"An open canvas",P("identity-description").textContent=t?`Your working style is shaped by ${e.slice(0,3).map((o)=>ke(o).toLowerCase()).join(", ")}${e.length>3?`, and ${e.length-3} more equipped skills`:""}.`:"Choose the instincts you want your agent to bring to work.";let r=P("traits");r.replaceChildren();for(let o of t?.traits??[])r.append(w({tag:"span",className:"trait",text:`${o.title} · ${o.count}`}));let n=P("requirements");if(n.replaceChildren(),n.hidden=!_.view?.requirements.length,_.view?.requirements.length){n.append(w({tag:"h3",text:"◇ Repository requirements"}));for(let o of _.view.requirements)n.append(w({tag:"p",text:o}))}}var Zn=null;async function sf(){if(_.view===null)throw Error("Wait for your skills to load before reviewing the build.");let e=await ne({path:"/api/preview",schema:Xl,body:_.input});Zn=e;let t=P("review-content");t.replaceChildren(),t.append(w({tag:"p",className:"review-message",text:`${e.changes.length} local files will change. Review the instructions and destinations below.`}));for(let r of e.warnings)t.append(w({tag:"p",className:"review-warning",text:r}));for(let r of e.changes){let n=w({tag:"details",className:"file-change"});if(n.append(w({tag:"summary",text:r.path})),r.internal)n.append(w({tag:"p",text:"Local configuration or supporting resource. Its previous version is retained for undo."}));else n.append(w({tag:"h4",text:"Before"}),w({tag:"pre",text:r.before??"New file"}),w({tag:"h4",text:"After"}),w({tag:"pre",text:r.after??"Remove managed file"}));t.append(n)}xt("review-dialog").showModal()}async function af(){if(Zn===null)throw Error("Review your build before applying it.");await ne({path:"/api/apply",schema:Oo,body:{previewId:Zn.id}}),Zn=null,xt("review-dialog").close(),Te({message:"Build equipped. Start a fresh agent session to use your updated skills.",success:!0})}async function cf(){let e=_.view?.revisionId;if(!e||!window.confirm("Restore the files from before the last apply? Later edits will be preserved if they conflict."))return;await ne({path:"/api/undo",schema:Oo,body:{revisionId:e}}),Te({message:"Restored the previous build.",success:!0})}function uf(){let e=P("starfield"),t=()=>{let n=e.getBoundingClientRect(),o=Math.max(1,Math.round(n.width)),i=Math.max(1,Math.round(n.height));e.setAttribute("viewBox",`0 0 ${o} ${i}`),e.setAttribute("preserveAspectRatio","xMidYMid meet"),e.replaceChildren();for(let s=0;s<54;s+=1){let a=document.createElementNS("http://www.w3.org/2000/svg","g"),u=document.createElementNS("http://www.w3.org/2000/svg","circle"),c=12+(s*137+29)%Math.max(24,o-24),l=8+(s*173+61)%Math.max(16,i-16);if(a.setAttribute("class",`star star-phase-${s%7}`),u.setAttribute("cx",String(c)),u.setAttribute("cy",String(l)),u.setAttribute("r",s%9===0?"1.7":"1"),a.append(u),s%9===0){let p=document.createElementNS("http://www.w3.org/2000/svg","path");p.setAttribute("d",`M${c-4} ${l}h8M${c} ${l-4}v8`),p.setAttribute("class","star-rays"),a.append(p)}e.append(a)}},r=()=>{e.classList.toggle("paused",document.hidden)};document.addEventListener("visibilitychange",r),new ResizeObserver(t).observe(e),t(),r()}var DI=K({name:S().trim().max(48),description:S().trim().max(300),body:S().trim().min(1).max(24000)}),lf=K({id:Hr(),destination:S(),payload:S(),limits:S(),cached:ht.nullable()}),pf=K({skill:ht});function ut(e){P("custom-status").textContent=e}async function ax(){let e=Ce("custom-body").value;if(!e.trim()){ut("Describe what your agent should do, then use AI to shape it into a skill."),Ce("custom-body").focus();return}let t=await ne({path:"/api/skill/preview",schema:lf,body:{name:oe("custom-name").value,description:oe("custom-description").value,body:e}});Wr({review:t,title:"Draft your skill with AI.",explanation:"Only the form fields below are sent. The result fills this form for you to edit; adding and applying it remain your choice.",confirm:"Send and draft",path:"/api/skill/generate",schema:pf,accept:({skill:r})=>{oe("custom-name").value=r.name,oe("custom-description").value=r.description,Ce("custom-body").value=r.body,ut("AI draft ready. Edit the instructions before adding the skill to your build."),Ce("custom-body").focus()}})}function ff(){let e=P("custom-ai");if(!(e instanceof HTMLButtonElement))return;e.addEventListener("click",()=>{if(e.disabled)return;e.disabled=!0,ut("Preparing your model request…"),ax().catch((t)=>{ut(t instanceof Error?t.message:"Could not prepare an AI draft. Your text is unchanged.")}).finally(()=>{if(e.disabled=!1,P("custom-status").textContent==="Preparing your model request…")ut("")})})}var Ss=!1;async function En(e){if(Ss)return;Ss=!0;let t=document.querySelectorAll("button, input, select, textarea"),r=Array.from(t,(n)=>({control:n,disabled:n.disabled}));for(let{control:n}of r)n.disabled=!0;try{await e()}finally{for(let{control:n,disabled:o}of r)n.disabled=o;Ss=!1}}function Ge(e){P(e.id).addEventListener("click",()=>En(e.action).catch(Ft))}function df(){let e=document.createElement("template");e.innerHTML=`
68
+ <dialog id="review-dialog" aria-labelledby="review-title">
69
+ <div class="dialog-heading">
70
+ <div>
71
+ <p class="eyebrow">READY TO EQUIP</p>
72
+ <h2 id="review-title">Review your changes.</h2>
73
+ </div>
74
+ <button class="close-dialog quiet-button" aria-label="Close review">
75
+ ✕
76
+ </button>
77
+ </div>
78
+ <div id="review-content"></div>
79
+ <div class="dialog-actions">
80
+ <button class="close-dialog quiet-button">Keep editing</button>
81
+ <button id="apply" class="primary-button">Apply build</button>
82
+ </div>
83
+ </dialog>
84
+
85
+ <dialog id="custom-dialog" aria-labelledby="custom-title">
86
+ <div class="dialog-heading">
87
+ <h2 id="custom-title">Create a skill.</h2>
88
+ <button
89
+ class="close-dialog quiet-button"
90
+ aria-label="Close skill editor"
91
+ >
92
+ ✕
93
+ </button>
94
+ </div>
95
+ <form id="custom-form">
96
+ <label>
97
+ Skill name
98
+ <input
99
+ id="custom-name"
100
+ pattern="[a-z0-9]+(-[a-z0-9]+)*"
101
+ maxlength="48"
102
+ placeholder="review-with-evidence"
103
+ required
104
+ >
105
+ </label>
106
+ <label>
107
+ When should your agent use it?
108
+ <input
109
+ id="custom-description"
110
+ maxlength="300"
111
+ placeholder="Use when reviewing an implementation."
112
+ required
113
+ >
114
+ </label>
115
+ <label>
116
+ What should your agent do?
117
+ <textarea
118
+ id="custom-body"
119
+ rows="9"
120
+ maxlength="24000"
121
+ placeholder="Describe the decisions, steps, and evidence you expect."
122
+ required
123
+ ></textarea>
124
+ </label>
125
+ <p id="custom-status" class="review-message" role="status"></p>
126
+ <div class="dialog-actions">
127
+ <button id="custom-ai" type="button" class="quiet-button">✦ Use AI</button>
128
+ <button type="submit" class="primary-button">
129
+ Add to your build
130
+ </button>
131
+ </div>
132
+ </form>
133
+ </dialog>
134
+ `,document.body.append(e.content);for(let t of document.querySelectorAll("dialog"))Yr(t)}var mf=re(K({id:Hr(),title:S(),state:S(),host:S(),parentId:S().nullable(),updatedAt:S(),verification:S(),review:rt().nullable(),finish:S(),interruptedActions:Ud()}));function hf(){Ge({id:"refresh-tasks",action:async()=>{let e=await ne({path:"/api/tasks",schema:mf}),t=P("task-list");if(t.replaceChildren(),e.length===0)t.append(w({tag:"p",text:"No recorded work in this repository. Choose the shadowclone-work skill to begin in your coding agent."}));for(let r of e){let n=w({tag:"article"});if(n.append(w({tag:"strong",text:r.title})),n.append(w({tag:"p",text:`${r.host} · ${r.state} · verification ${r.verification} · ${r.finish} finish line`})),n.append(w({tag:"code",text:`shadowclone task status ${r.id}`})),r.interruptedActions>0)n.append(w({tag:"p",text:"An interrupted action needs reconciliation before work can continue."}));t.append(n)}}})}df();hf();function dr(){fr({inspect:(e)=>{_.activeId=e,dr()}}),rp({rerender:dr,companion:Mo}),of(),$s(),P("undo").hidden=_.view?.revisionId===null}async function cx(e){let t=await ne({path:`/api/build?scope=${e}`,schema:Gl});if(_.view=t,_.input=structuredClone(t.input),_.dirty=!1,!t.items.some((n)=>n.id===_.activeId))_.activeId=t.items.find(ie)?.id??t.items[0]?.id??"";gt("scope").value=e;let r={global:"Your personal build follows you across coding agents.",private:"Only this repository. Stored privately on your machine; shared requirements stay in force.",shared:"A portable build for this repository. Review every file before sharing it with your team."};if(P("scope-note").textContent=r[e],P("library-note").hidden=t.libraryEnabled,t.migrationRequired)Te({message:"Your existing profile needs its reviewed skills migration before this build can be applied. You can explore the editor now."});dr()}async function mr(e){let t=P("constellation-status"),r=P("retry-build");if(!r.hidden)Te({message:""});t.hidden=!1,r.hidden=!0,P("constellation-status-text").textContent="Loading your skills…",P("constellation").setAttribute("aria-busy","true");try{await cx(e),t.hidden=!0}catch(n){throw P("constellation-status-text").textContent="Your skills couldn't be loaded. Retry to reconnect to the local editor.",r.hidden=!1,gt("scope").value=_.input.scope,n}finally{P("constellation").setAttribute("aria-busy","false")}}Ge({id:"retry-build",action:()=>mr(_.input.scope)});Ge({id:"review",action:sf});Ge({id:"describe",action:rf});Ge({id:"apply",action:async()=>{await af(),await mr(_.input.scope)}});Ge({id:"undo",action:async()=>{await cf(),await mr(_.input.scope)}});P("new-skill").addEventListener("click",()=>Mo());P("custom-form").addEventListener("submit",(e)=>{e.preventDefault();try{Ql(),dr()}catch(t){ut(t instanceof Error?t.message:"The skill could not be added.")}});oe("search").addEventListener("input",()=>{_.search=oe("search").value,dr()});gt("scope").addEventListener("change",()=>{if(_.dirty&&!window.confirm("Discard the draft and switch build scope?")){gt("scope").value=_.input.scope;return}let e=mt.parse(gt("scope").value);En(()=>mr(e)).catch(Ft)});for(let e of document.querySelectorAll(".close-dialog"))e.addEventListener("click",()=>e.closest("dialog")?.close());window.addEventListener("beforeunload",(e)=>{if(_.dirty)e.preventDefault()});var gf=mt.safeParse(new URLSearchParams(location.search).get("scope")??"global");uf();Qp();ff();En(()=>mr(gf.success?gf.data:"global")).catch(Ft);