@shadowclone/cli 0.0.14 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,134 @@
1
+ function Ot(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)=>Ln(r)).join(t)}function At(e,t){if(typeof t==="bigint")return t.toString();return t}class Ps{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 yr(e){return new Ps(e)}function Zs(e){return e===null||e===void 0}function br(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Es(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 he(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function vr(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function Te(e){return vr(e._zod.def)??e._zod.def.shape}function Os(e,t,r){Object.defineProperty(e,t,{get(){let n=r();return he(this,t,n),n},enumerable:!0,configurable:!0})}function As(e,t,r){if(t in e)he(e,t,r);else e[t]=r}function et(e,t,r,n){let o=Te(t);for(let i of r){let s=Object.getOwnPropertyDescriptor(o,i);if(!s.enumerable)continue;if(s.get)Os(e,i,()=>{let a=t._zod.def.shape[i];return n?n(a,i):a});else As(e,i,n?n(s.value,i):s.value)}}function vf(e,t){for(let r of Reflect.ownKeys(t)){let n=Object.getOwnPropertyDescriptor(t,r);if(!n.enumerable)continue;if(n.get)Os(e,r,()=>t[r]);else As(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 Cs(e){return JSON.stringify(e)}function Ts(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Rn="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Et(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Ns=yr(()=>{if(ne.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function tt(e){if(Et(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(Et(r)===!1)return!1;if(Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)return!1;return!0}function Mn(e){if(tt(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 Rs=new Set(["string","number","symbol"]);function ft(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ve(e,t,r){let n=new e._zod.constr(t??e._zod.def);if(!t||r?.parent)n._zod.parent=e;return n}function z(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 Ln(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Ms(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var _r=(()=>({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]}))(),Dn={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function _f(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 et(i,e,wr(e,t)),ve(e,ae(r,{shape:i,checks:[]}))}function wr(e,t){let r=Te(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 wf(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(wr(e,t)),s={};return et(s,e,Reflect.ownKeys(Te(e)).filter((a)=>!i.has(a))),ve(e,ae(r,{shape:s,checks:[]}))}function kf(e,t){if(!tt(t))throw Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let o=Te(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 ve(e,ae(e._zod.def,{shape:Ls(e,t)}))}function Ls(e,t){let r={};return et(r,e,Reflect.ownKeys(Te(e))),vf(r,t),r}function zf(e,t){if(!tt(t))throw Error("Invalid input to safeExtend: expected a plain object");return ve(e,ae(e._zod.def,{shape:Ls(e,t)}))}function $f(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={};et(r,e,Reflect.ownKeys(Te(e))),et(r,t,Reflect.ownKeys(Te(t)));let n=ae(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ve(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(wr(t,r)):void 0,u={};return et(u,t,Reflect.ownKeys(Te(t)),e&&((c,l)=>a&&!a.has(l)?c:new e({type:"optional",innerType:c}))),ve(t,ae(t._zod.def,{shape:u,checks:[]}))}function Sf(e,t,r){let n=r?new Set(wr(t,r)):void 0,o={};return et(o,t,Reflect.ownKeys(Te(t)),(i,s)=>n&&!n.has(s)?i:new e({type:"nonoptional",innerType:i})),ve(t,ae(t._zod.def,{shape:o}))}function _e(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 Bs(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 Ve(e,t){return t.map((r)=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Zt(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 we(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:Zt(e.inst?._zod.def?.error?.(e))??Zt(i?.(e))??Zt(t?.error?.(e))??Zt(r.customError?.(e))??Zt(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 If=/[\uD800-\uDBFF]/;function kr(e){let t=e.length;if(!If.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 zr(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function js(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 rt(...e){let[t,r,n]=e;if(typeof t==="string")return{message:t,code:"custom",input:r,inst:n};return{...t}}function Fs(e,t){for(let r in t){let n=Object.getOwnPropertyDescriptor(t,r);if(n.get)Object.defineProperty(e,r,{...n,enumerable:!1});else Pf(e,r,n.value)}}function Ne(e,t,r,n=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:n,value:r}),r}function $r(e,t,r){return Ne(e,t,r,!1)}function Us(e,t){for(let r in e){let n=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return Ne(this,r,n(this))},set(o){Ne(this,r,o)}})}return t}function Pf(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:Ne(this,t,r.bind(this))},set(n){Ne(this,t,n)}})}function Zf(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var Tn,qe=!1,Ef={configurable:!0,get(){qe=!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,Ef);let o=qe;qe=!1;try{let i=r(this);if(qe)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i});return qe=qe||o,i}catch(i){throw delete this[t],qe=qe||o,i}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function Of(e,t,r,n){let o=Zf(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 Af="~constantCatch";function qs(e){let t=()=>e;return t[Af]=!0,t}var Vs;var jn={value:void 0,enumerable:!1},Js="captureStackTrace"in Error?Error:null;function Cf(e){let t=Js;if(t){let r=t.stackTraceLimit;if(typeof r==="number"){try{t.stackTraceLimit=0}catch{return Js=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),Fs(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?Cf(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 ke extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Ct extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(Vs=globalThis).__zod_globalConfig??(Vs.__zod_globalConfig={});var ne=globalThis.__zod_globalConfig;function ce(e){if(e)Object.assign(ne,e);return ne}function Tf(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,At,2)),e.message}function Nf(e){this._zod.message=e}var Rf={get:Tf,set:Nf,enumerable:!0,configurable:!0},Un={value:void 0,enumerable:!1},Hs=new WeakSet([Object.prototype,Error.prototype]),Ks=(e,t)=>{e.name="$ZodError",Un.value=t,Object.defineProperty(e,"issues",Un),Un.value=void 0,Object.defineProperty(e,"message",Rf);let r=Object.getPrototypeOf(e);if(!Hs.has(r))Hs.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})}})},Gs=g("$ZodError",Ks),Dx=g("$ZodError",Ks,void 0,{Parent:Error});function Mf(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 Xs(e,t=(r)=>r.message){let r={},n=[];for(let o of e.issues)if(o.path.length>0)Mf(r,o.path[0],()=>[]).push(t(o));else n.push(t(o));return{formErrors:n,fieldErrors:r}}function Ys(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 Sr(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Ir=(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 ke;if(a.issues.length){let u=new(i?.Err??e)(a.issues.map((c)=>we(c,s,ce())));throw Rn(u,i?.callee??t),u}return a.value};return t};var Pr=(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)=>we(c,s,ce())));throw Rn(u,i?.callee??t),u}return a.value};return t};var Zr=(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 ke;return i.issues.length?Ws(e,i.issues,o):{success:!0,data:i.value}};function Ws(e,t,r){let n;return{success:!1,get error(){if(!n)n=new e(t.map((o)=>we(o,r,ce()))),t=void 0,r=void 0;return n},set error(o){n=o,t=void 0,r=void 0}}}var Er=(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?Ws(e,i.issues,o):{success:!0,data:i.value}};var Lf=Symbol.for("zod.compile.invalid"),Df=Symbol.for("zod.compile.fallback"),qn=(e,t,r)=>{let n=e._zod.bag.validator;if(n!==void 0){if(n(t)!==Lf)return!0;if(n.definite===!0&&r===void 0)return!1}return Bf(e,t,r)};function Bf(e,t,r){let n=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun,i;if(o)n[Df]=!0,i=o({value:t,issues:[]},n);else i=e._zod.run({value:t,issues:[]},n);if(i instanceof Promise)throw new ke;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},Qs=(e)=>{let t=Ir(e),r=(n,o,i,s)=>{let a=i?{...i,direction:"backward"}:{direction:"backward"};return t(n,o,a,Sr(r,s))};return r};var ea=(e)=>{let t=Ir(e),r=(n,o,i,s)=>t(n,o,i,Sr(r,s));return r};var ta=(e)=>{let t=Pr(e),r=async(n,o,i,s)=>{let a=i?{...i,direction:"backward"}:{direction:"backward"};return await t(n,o,a,Sr(r,s))};return r};var ra=(e)=>{let t=Pr(e),r=async(n,o,i,s)=>await t(n,o,i,Sr(r,s));return r};var na=(e)=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Zr(e)(t,r,o)};var oa=(e)=>(t,r,n)=>Zr(e)(t,r,n);var ia=(e)=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Er(e)(t,r,o)};var sa=(e)=>async(t,r,n)=>Er(e)(t,r,n);var aa=/^[cC][0-9a-z]{6,}$/,ca=/^[0-9a-z]+$/,ua=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,la=/^[0-9a-vA-V]{20}$/,pa=/^[A-Za-z0-9]{27}$/,fa=/^[a-zA-Z0-9_-]{21}$/;function da(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var ma=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var ha=/^([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 ga=/^(?:[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 jf="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function xa(){return new RegExp(jf,"u")}var ya=/^(?:(?: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])$/,ba=/^(([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 va=/^((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])$/,_a=/^(([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])$/,wa=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ka=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var za=/^https?$/,$a=/^\+[1-9]\d{6,14}$/;var Sa="(?:(?:\\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 Ff(e){return new RegExp(`^${e}$`)}var Ia=Ff(Sa);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 Pa(e){return new RegExp(`^${Jn(e)}$`)}function Za(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(`^${Sa}T(?:${n})$`)}var Ea=/^[\s\S]{0,}$/;var Kn=/^-?\d+$/,Tt=/^-?\d+(?:\.\d+)?$/,Oa=/^(?:true|false)$/i;var Aa=/^[^A-Z]*$/,Ca=/^[^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!Zs(t)&&t.length!==void 0},Or={number:"number",bigint:"bigint",object:"date"},Xn=g("$ZodCheckLessThan",(e,t)=>{X.init(e,t);let r=Or[typeof t.value];e._zod.check=(n)=>{if(t.inclusive?n.value<=t.value:n.value<t.value)return;n.issues.push({origin:Or[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=Or[typeof t.value];e._zod.check=(n)=>{if(t.inclusive?n.value>=t.value:n.value>t.value)return;n.issues.push({origin:Or[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})}}),Ta=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):Es(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})}}),Na=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]=_r[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 Ra=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?kr(o):i)<=t.maximum)return;let a=zr(o);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Ma=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?kr(o):i)>=t.minimum)return;let a=zr(o);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),La=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?kr(o):i;if(s===t.length)return;let a=zr(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})}}),Rt=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)=>{Rt.init(e,t),e._zod.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Ba=g("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Aa),Rt.init(e,t)}),ja=g("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Ca),Rt.init(e,t)}),Fa=g("$ZodCheckIncludes",(e,t)=>{X.init(e,t);let r=ft(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})}}),Ua=g("$ZodCheckStartsWith",(e,t)=>{X.init(e,t);let r=new RegExp(`^${ft(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})}}),qa=g("$ZodCheckEndsWith",(e,t)=>{X.init(e,t);let r=new RegExp(`.*${ft(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 Va=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 Ha={major:4,minor:6,patch:5};var D=g("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ha;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=_e(a),p;for(let f of u){if(f._zod.def.when){if(Bs(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 ke;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=_e(a,d)});else{if(a.issues.length===d)continue;if(Bn(a.issues,d,e),!l)l=_e(a,d)}}if(p)return p.then(()=>a);return a},s=(a,u,c)=>{if(_e(a))return a.aborted=!0,a;let l=i(u,o,c);if(l instanceof Promise){if(c.async===!1)throw new ke;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 ke;return c.then((l)=>i(l,o,u))}return i(c,o,u)}}},{get "~standard"(){return $r(this,"~standard",eo(this))},set "~standard"(e){Ne(this,"~standard",e)}}),oc=(e,t)=>e.issues.length?{issues:e.issues.map((r)=>we(r,t,ce()))}:{value:e.value};async function Uf(e,t){let r={async:!0};return oc(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 oc(n,r)}catch(n){}return Uf(e,t)},vendor:"zod",version:1}}var Nr=g("$ZodString",(e,t)=>{D.init(e,t),e._zod.pattern=t.pattern??Ea,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)=>{Rt.init(e,t),Nr.init(e,t)}),ic=g("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=ha),M.init(e,t)}),sc=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)}),ac=g("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=ga),M.init(e,t)}),cc=1,Cr=2;function uc(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function qf(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return uc(e)||Cr;return Vf(e,t)}function Vf(e,t){if(!t.normalize&&t.protocol?.source===za.source&&!/^https?:\/\//i.test(e))return cc;try{if(typeof URL<"u"){let r=URL;if(typeof r.parse==="function")return r.parse(e)??Cr}return new URL(e)}catch{return Cr}}var Jf=/[\t\n\r]/g;function Ka(e){return e.replace(Jf,"")}function Hf(e,t){return t.lastIndex=0,t.test(e.hostname)}function Kf(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var lc=g("$ZodURL",(e,t)=>{M.init(e,t),e._zod.check=(r)=>{try{let n=r.value.trim(),o=qf(n,t);if(o===cc){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(o===Cr){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}if(o===!0){r.value=Ka(n);return}if(t.hostname&&!Hf(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&&!Kf(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:Ka(n);return}catch(n){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),pc=g("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=xa()),M.init(e,t)}),fc=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?fa:da(t.length)),M.init(e,t)}),dc=g("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=aa),M.init(e,t)}),mc=g("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=ca),M.init(e,t)}),hc=g("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ua),M.init(e,t)}),gc=g("$ZodXID",(e,t)=>{t.pattern??(t.pattern=la),M.init(e,t)}),xc=g("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=pa),M.init(e,t)}),yc=g("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Za(t)),M.init(e,t)}),bc=g("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Ia),M.init(e,t)}),vc=g("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Pa(t)),M.init(e,t)}),_c=g("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ma),M.init(e,t)}),wc=g("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ya),M.init(e,t)}),Gf=/^[0-9a-fA-F:.]+$/;function kc(e){if(!Gf.test(e))return!1;return uc(`http://[${e}]`)}var zc=g("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ba),M.init(e,t),e._zod.check=(r)=>{if(!kc(r.value))r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}});var $c=g("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=va),M.init(e,t)});function Xf(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 kc(r)}var Sc=g("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=_a),M.init(e,t),e._zod.check=(r)=>{if(!Xf(r.value))r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function Ic(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}$/,Pc=g("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=to),M.init(e,t),e._zod.check=(r)=>{if(Ic(r.value))return;r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),Rr=/^[A-Za-z0-9_-]*$/;function Yf(e){if(!Rr.test(e))return!1;let t=e.replace(/[-_]/g,(n)=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return Ic(r)}var Zc=g("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Rr),M.init(e,t),e._zod.check=(r)=>{if(Yf(r.value))return;r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Ec=g("$ZodE164",(e,t)=>{t.pattern??(t.pattern=$a),M.init(e,t)});function Wf(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 Oc=g("$ZodJWT",(e,t)=>{M.init(e,t),e._zod.check=(r)=>{if(Wf(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)=>{D.init(e,t),e._zod.pattern=Tt,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}}),Ac=g("$ZodNumberFormat",(e,t)=>{Na.init(e,t),ro.init(e,t)}),Cc=g("$ZodBoolean",(e,t)=>{D.init(e,t),e._zod.pattern=Oa,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 Tc=g("$ZodUnknown",(e,t)=>{D.init(e,t),e._zod.parse=(r)=>r}),Nc=g("$ZodNever",(e,t)=>{D.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function Ga(e,t,r){if(e.issues.length)t.issues.push(...Ve(r,e.issues));t.value[r]=e.value}var Rc=g("$ZodArray",(e,t)=>{D.init(e,t);let r=ne.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)=>Ga(p,n,u)));else if(Ga(l,n,u),a&&l.issues.length!==0&&_e(l))break}if(s.length)return Promise.all(s).then(()=>n);return n}});function Tr(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(...Ve(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 Qf=[];function Mc(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),n=r.length?r:Qf,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=Ms(e.shape);return{...e,allKeys:o,symbolKeys:n,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}function Lc(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(_e(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)=>Tr(v,r,m,t,p,f)));else Tr(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 ed=g("$ZodObject",(e,t)=>{D.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=yr(()=>Mc(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))he(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=Et,s=t.catchall,a,u=ne.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(_e(c,x))break;x=c.issues.length}if(v==="__proto__")continue;let b=d[v],Z=b._zod.optin,L=b._zod.optout,j=b._zod.run({value:p[v],issues:[]},l);if(j instanceof Promise)f.push(j.then((T)=>Tr(T,c,v,p,Z,L)));else Tr(j,c,v,p,Z,L)}if(!s)return f.length?Promise.all(f).then(()=>c):c;return Lc(f,p,c,l,o.value,e,m===!0)}}),Dc=g("$ZodObjectJIT",(e,t)=>{ed.init(e,t);let r=e._zod.parse,n=yr(()=>Mc(t)),o=ne.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 L=Object.create(null),j=0;for(let T of m.allKeys)L[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=L[T],H=typeof T==="symbol"?`syms[${x.indexOf(T)}]`:Cs(T),Fe=`${H} in input`,Qe=d[T],Ue=Qe?._zod?.optin,xr=Ue!==void 0,On=Qe?._zod?.optout==="optional";if(v.write(`const ${O} = ${b(H)};`),xr&&On){let An=Ue==="optional"?`${O}_present`:`${O}.value !== undefined || ${O}_present`;v.write(`
17
+ const ${O}_present = ${Fe};
18
+ if (!${O}.issues.length || ${O}_present) {
19
+ if (${O}.issues.length) {${Z(O,H)}
20
+ }
21
+
22
+ if (${An}) {
23
+ newResult[${H}] = ${O}.value;
24
+ }
25
+ }
26
+
27
+ `)}else if(!xr)v.write(`
28
+ const ${O}_present = ${Fe};
29
+ if (${O}.issues.length) {${Z(O,H)}
30
+ }
31
+ if (!${O}_present && !${O}.issues.length) {
32
+ payload.issues.push({
33
+ code: "invalid_type",
34
+ expected: "nonoptional",
35
+ input: undefined,
36
+ path: [${H}]
37
+ });
38
+ if (ctx && ctx.abortEarly) {
39
+ payload.value = newResult;
40
+ return payload;
41
+ }
42
+ }
43
+
44
+ if (${O}_present) {
45
+ newResult[${H}] = ${O}.value;
46
+ }
47
+
48
+ `);else if(v.write(`
49
+ if (${O}.issues.length) {${Z(O,H)}
50
+ }
51
+ `),Ue==="defaulted")v.write(`newResult[${H}] = ${O}.value;`);else v.write(`
52
+ if (${O}.value !== undefined || ${Fe}) {
53
+ newResult[${H}] = ${O}.value;
54
+ }
55
+ `)}return v.write("payload.value = newResult;"),v.write("return payload;"),v.compile()},s,a=Et,u=!ne.jitless,l=u&&Ns.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 Lc([],x,d,m,f,e,m?.abortEarly===!0)}return r(d,m)}});function Xa(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)=>!_e(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)=>we(s,n,ce())))}),t}var Bc=g("$ZodUnion",(e,t)=>{D.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)=>br(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 Xa(s,n,e,o);return Promise.all(s).then((a)=>Xa(a,n,e,o))}});var jc=g("$ZodIntersection",(e,t)=>{D.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])=>Ya(r,u,c));return Ya(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(tt(e)&&tt(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 Ya(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(_e(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(u.mergeErrorPath)}`)}return e.value=u.data,e}var Fc=g("$ZodRecord",(e,t)=>{D.init(e,t);let r=ne.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let i=n.value;if(!tt(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)=>we(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(...Ve(l,m.issues));n.value[f]=m.value}));else{if(d.issues.length)n.issues.push(...Ve(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"&&Tt.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)=>we(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(...Ve(c,m.issues));n.value[f]=m.value}));else{if(d.issues.length)n.issues.push(...Ve(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 Uc=g("$ZodEnum",(e,t)=>{D.init(e,t);let r=Ot(t.entries),n=new Set(r);e._zod.values=n,N(e,"pattern",(o)=>{let i=Ot(o.def.entries).filter((s)=>Rs.has(typeof s));return new RegExp(i.length?`^(${i.map((s)=>ft(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 qc=g("$ZodTransform",(e,t)=>{D.init(e,t),e._zod.optin="optional",ne.memoizer?.guard(e),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Ct(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 ke;return r.value=o,r}});function Wa(e,t){return e.value=t.issues.length?void 0:t.value,e}var no=g("$ZodOptional",(e,t)=>{D.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(`^(${br(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)=>Wa(r,i));return Wa(r,o)}return t.innerType._zod.run(r,n)}}),Vc=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)}),Jc=g("$ZodNullable",(e,t)=>{D.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(`^(${br(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)}}),Hc=g("$ZodDefault",(e,t)=>{D.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)=>Qa(i,t));return Qa(o,t)}});function Qa(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var Kc=g("$ZodPrefault",(e,t)=>{D.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)}}),Gc=g("$ZodNonOptional",(e,t)=>{D.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)=>ec(i,e));return ec(o,e)}});function ec(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 tc(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)=>we(o,n,ce()))},input:e.value}),e}var Xc=g("$ZodCatch",(e,t)=>{D.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)=>tc(r,i,t,n));return tc(r,o,t,n)}});var Yc=g("$ZodPipe",(e,t)=>{D.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)=>Ar(s,t.in,n));return Ar(i,t.in,n)}let o=t.in._zod.run(r,n);if(o instanceof Promise)return o.then((i)=>Ar(i,t.out,n));return Ar(o,t.out,n)}});function Ar(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 Wc=g("$ZodReadonly",(e,t)=>{D.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(rc);return rc(o)}});function rc(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var Qc=g("$ZodCustom",(e,t)=>{X.init(e,t),D.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)=>nc(i,r,n,e));nc(o,r,n,e);return}});function nc(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(rt(o))}}class tu extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var io="~memo",eu=[];function ru(e){return e!==null&&typeof e==="object"}function oo(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var nu=new WeakMap,Mt=0,Dr=1,Lt=2;function Br(e,t,r){let n=nu.get(e);if(n!==void 0)return n?Lt:Mt;if(t.has(e))return Lt;t.add(e);let o=Mt,i=(l)=>{if(o!==Lt&&l?._zod){let p=Br(l,t,r);if(p>o)o=p}},s=(l,p)=>{let f=Mt;for(let d of Reflect.ownKeys(l)){let m=Object.getOwnPropertyDescriptor(l,d);if(p&&!m.enumerable)continue;let x=m.get?Dr:m.value?._zod?Br(m.value,t,r):Mt;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=vr(u);a(l?s(l,!0):Dr),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?Br(l,t,!1):Dr);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),td(e,o)}function td(e,t){if(t!==Dr)nu.set(e,t===Lt);return t}function rd(e,t){let r=e.buckets.get(t);if(!r)r=new WeakMap,e.buckets.set(t,r);return r}var Mr,Lr=[],nd={alloc(e,t,r){let n=Mr;if(!n)return r;Mr=void 0;let o={value:r,issues:null};return n.set(t.value,o),Lr.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"&&od(i,o.value))throw new tu;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=Br(e,new Set,!1);if(b===Mt){if(e._zod.parse=s,e._zod.run===a)e._zod.run=s;return s(u,c)}if(b===Lt||n)r=!0;else n=!0}let l=u.value;if(!ru(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=rd(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}Mr=f;let m=Lr.length,x=s(u,c);Mr=void 0;let v=Lr.length>m?Lr.pop():void 0;if(x instanceof Promise)return x.then((b)=>{if(v)v.issues=b.issues.length?oo(b.issues):eu;return b});if(v)v.issues=x.issues.length?oo(x.issues):eu;return x};if(e._zod.parse=a,e._zod.run===s)e._zod.run=a})}};function ou(){return nd}function od(e,t){let r=e[io]?.backEdges;return r!==void 0&&ru(t)&&r.has(t)}var id=()=>{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=js(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 ${Ln(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:id()}}var iu;class su{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 sd(){return new su}(iu=globalThis).__zod_globalRegistry??(iu.__zod_globalRegistry=sd());var nt=globalThis.__zod_globalRegistry;function au(e){if(e.checks)e.checks=[...e.checks];return e}function cu(e,t){return new e(au({type:"string",...z(t)}))}function uu(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...z(t)})}function lu(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...z(t)})}function ao(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...z(t)})}function pu(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...z(t)})}function fu(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...z(t)})}function du(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...z(t)})}function mu(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...z(t)})}function hu(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...z(t)})}function gu(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...z(t)})}function xu(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...z(t)})}function yu(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...z(t)})}function bu(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...z(t)})}function vu(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...z(t)})}function _u(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...z(t)})}function wu(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...z(t)})}function ku(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...z(t)})}function zu(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...z(t)})}function $u(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...z(t)})}function Su(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...z(t)})}function Iu(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...z(t)})}function Pu(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...z(t)})}function Zu(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...z(t)})}function Eu(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...z(t)})}function Ou(e,t){return new e({type:"string",format:"date",check:"string_format",...z(t)})}function Au(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...z(t)})}function Cu(e,t){return new e({type:"string",format:"duration",check:"string_format",...z(t)})}function Tu(e,t){return new e(au({type:"number",checks:[],...z(t)}))}function Nu(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...z(t)})}function Ru(e,t){return new e({type:"boolean",...z(t)})}function Mu(e){return new e({type:"unknown"})}function Lu(e,t){return new e({type:"never",...z(t)})}function jr(e,t){return new Xn({check:"less_than",...z(t),value:e,inclusive:!1})}function Dt(e,t){return new Xn({check:"less_than",...z(t),value:e,inclusive:!0})}function Fr(e,t){return new Yn({check:"greater_than",...z(t),value:e,inclusive:!1})}function Bt(e,t){return new Yn({check:"greater_than",...z(t),value:e,inclusive:!0})}function Ur(e,t){return new Ta({check:"multiple_of",...z(t),value:e})}function qr(e,t){return new Ra({check:"max_length",...z(t),maximum:e})}function dt(e,t){return new Ma({check:"min_length",...z(t),minimum:e})}function Vr(e,t){return new La({check:"length_equals",...z(t),length:e})}function co(e,t){return new Da({check:"string_format",format:"regex",...z(t),pattern:e})}function uo(e){return new Ba({check:"string_format",format:"lowercase",...z(e)})}function lo(e){return new ja({check:"string_format",format:"uppercase",...z(e)})}function po(e,t){return new Fa({check:"string_format",format:"includes",...z(t),includes:e})}function fo(e,t){return new Ua({check:"string_format",format:"starts_with",...z(t),prefix:e})}function mo(e,t){return new qa({check:"string_format",format:"ends_with",...z(t),suffix:e})}function Je(e){return new Va({check:"overwrite",tx:e})}function ho(e){return Je((t)=>t.normalize(e))}function go(){return Je((e)=>e.trim())}function xo(){return Je((e)=>e.toLowerCase())}function yo(){return Je((e)=>e.toUpperCase())}function bo(){return Je((e)=>Ts(e))}function Du(e,t,r){return new e({type:"array",element:t,...z(r)})}function Bu(e,t,r){return new e({type:"custom",check:"custom",fn:t,...z(r)})}function ju(e,t){let r=ad((n)=>(n.addIssue=(o)=>{if(typeof o==="string")n.issues.push(rt(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(rt(i))}},e(n.value,n)),t);return r}function ad(e,t){let r=new X({check:"custom",...z(t)});return r._zod.check=e,r}function jt(e,...t){for(let r of t)for(let n of Reflect.ownKeys(r))if(Object.prototype.propertyIsEnumerable.call(r,n))he(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??nt,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 ot(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)jt(s.schema,u);if(t.io==="input"&&ee(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 Fu(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}/${Fu(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+Fu(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 Vu(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;Vu(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 Ju=new Set(["type","properties","required","additionalProperties"]),Uu=["oneOf","anyOf"];function qu(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(!Ju.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]??qu(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};he(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=qu(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 cd(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of Ju)if(o in e)return;let r=t.filter((o)=>Uu.some((i)=>Array.isArray(o[i]))),n=null;if(!r.length)n=vo(t);else{let o=r[0],i=Uu.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,jt(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 jt(c,m);if(jt(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())Vu(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)??[])cd(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)}jt(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;he(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:Ft(t,"input",e.processors),output:Ft(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function ee(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 ee(n.element,r);if(n.type==="set")return ee(n.valueType,r);if(n.type==="lazy")return ee(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 ee(n.innerType,r);if(n.type==="intersection")return ee(n.left,r)||ee(n.right,r);if(n.type==="record"||n.type==="map")return ee(n.keyType,r)||ee(n.valueType,r);if(n.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return ee(n.in,r)||ee(n.out,r)}if(n.type==="object"){for(let o in n.shape)if(ee(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(ee(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(ee(o,r))return!0;if(n.rest&&ee(n.rest,r))return!0;return!1}return!1}var Hu=(e,t={})=>(r)=>{let n=_o({...r,processors:t});return V(e,n),wo(n,e),ko(n,e)},Ft=(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 mt=(e,t,r)=>{if(e[t]===void 0||r>e[t])e[t]=r},ht=(e,t,r)=>{if(e[t]===void 0||r<e[t])e[t]=r},Ku=(e,t)=>{mt(e,"minimum",t),ht(e,"maximum",t)},Wu=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},Qu=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},el=(e,t)=>{e.mime=e.mime?e.mime.filter((r)=>t.includes(r)):[...t]},tl=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},Gu=(e,t)=>mt(e,"minimum",t.minimum),Xu=(e,t)=>ht(e,"maximum",t.maximum),Yu=(e)=>(t,r)=>{tl(t,r.format);let[n,o]=e[r.format];mt(t,"minimum",n),ht(t,"maximum",o)},ud={greater_than:(e,t)=>mt(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>ht(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Wu(e,t.value),number_format:Yu(_r),bigint_format:Yu(Dn),min_length:Gu,max_length:Xu,length_equals:(e,t)=>Ku(e,t.length),min_size:Gu,max_size:Xu,size_equals:(e,t)=>Ku(e,t.size),string_format:(e,t)=>{if(tl(e,t.format),t.pattern)Qu(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)=>el(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)ud[i._zod.def.check]?.(t,i._zod.def);let o=e._zod.bag;if(o.minimum!==void 0)mt(t,"minimum",o.minimum);if(o.exclusiveMinimum!==void 0)mt(t,"exclusiveMinimum",o.exclusiveMinimum);if(o.maximum!==void 0)ht(t,"maximum",o.maximum);if(o.exclusiveMaximum!==void 0)ht(t,"exclusiveMaximum",o.exclusiveMaximum);if(o.multipleOf!==void 0)Wu(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)el(t,o.mime);for(let i of o.patterns??[])Qu(t,i);return t}var ld={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},pd=new Map([[to,wa],[Rr,ka]]),rl=(e)=>pd.get(e)??e,nl=(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=ld[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(rl);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}))]}},ol=(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 ot(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}))]}},il=(e,t,r,n)=>{r.type="boolean"};var sl=(e,t,r,n)=>{r.not={}};var al=(e,t,r,n)=>{};var cl=(e,t,r,n)=>{let o=e._zod.def,i=Ot(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 ul=(e,t,r,n)=>{ot(e,t,r,n,"Custom types cannot be represented in JSON Schema")};var ll=(e,t,r,n)=>{ot(e,t,r,n,"Transforms cannot be represented in JSON Schema")};var pl=(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 Jr(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return Jr(t.out);if(t.type==="catch")return Jr(t.innerType);return e._zod.optin}var fl=(e,t,r,n)=>{let o=r,i=e._zod.def,s=i.shape;if(Object.getOwnPropertySymbols(s).length&&ot(e,t,o,n,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let c in s)he(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"?Jr(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"]})},dl=(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},ml=(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")?Tt:Kn).source;return d}var $o=new WeakMap;function fd(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 hl=(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)he(o.patternProperties,rl(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(()=>fd(t));l.push(e)}o.additionalProperties=V(i.valueType,t,{...n,path:[...n.path,"additionalProperties"]})}let u=s._zod.values,c=t.io==="input"&&Jr(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)}},gl=(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"}]},xl=(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 yl(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 ot(t,r,n,o,"BigInt defaults cannot be represented in JSON Schema"),So}var bl=(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=yl(o.defaultValue,e,t,r,n);if(s!==So)r.default=s},vl=(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=yl(o.defaultValue,e,t,r,n);if(s!==So)r._prefault=s},_l=(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{ot(e,t,r,n,"Dynamic catch values are not supported in JSON Schema");return}r.default=s},wl=(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},kl=(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 zl=new WeakSet([Object.prototype,Error.prototype]);function Hr(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 vd=(e,t)=>{Gs.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);if(zl.has(r))return;zl.add(r),Hr(r,"format",(n)=>(o)=>Ys(n,o)),Hr(r,"flatten",(n)=>(o)=>Xs(n,o)),Hr(r,"addIssue",(n)=>(o)=>{n.issues.push(o),n.message=JSON.stringify(n.issues,At,2)}),Hr(r,"addIssues",(n)=>(o)=>{n.issues.push(...o),n.message=JSON.stringify(n.issues,At,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var ue=g("ZodError",vd,void 0,{Parent:Error});var $l=Ir(ue),Sl=Pr(ue),Il=Zr(ue),Pl=Er(ue),Zl=Qs(ue),El=ea(ue),Ol=ta(ue),Al=ra(ue),Cl=na(ue),Tl=oa(ue),Nl=ia(ue),Rl=sa(ue);function wd(){if(!ne.localeError)ce(so())}function Kr(){if(!ne.memoizer)ce({memoizer:ou()})}var F=g("ZodType",(e,t)=>(wd(),D.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 ve(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(xm(e,t))},superRefine(e,t){return this.check(ym(e,t))},overwrite(e){return this.check(Je(e))},optional(){return Bl(this)},exactOptional(){return om(this)},nullable(){return jl(this)},nullish(){return Bl(jl(this))},nonoptional(e){return lm(this,e)},array(){return te(this)},or(e){return Qd([this,e])},and(e){return tm(this,e)},transform(e){return Fl(this,nm(e))},default(e){return am(this,e)},prefault(e){return um(this,e)},catch(e){return fm(this,e)},pipe(e){return Fl(this,e)},readonly(){return hm(this)},describe(e){let t=this.clone();return nt.add(t,{description:e}),t},meta(...e){if(e.length===0)return nt.get(this);let t=this.clone();return nt.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 $r(this,"~standard",{...eo(this),jsonSchema:{input:Ft(this,"input"),output:Ft(this,"output")}})},set "~standard"(e){Ne(this,"~standard",e)},parse:function e(t,r){return $l(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await Sl(this,t,r,{callee:e})},safeParse(e,t){return Il(this,e,t)},async safeParseAsync(e,t){return Pl(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Ne(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 Zl(this,t,r,{callee:e})},decode:function e(t,r){return El(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await Ol(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await Al(this,t,r,{callee:e})},safeEncode(e,t){return Cl(this,e,t)},safeDecode(e,t){return Tl(this,e,t)},async safeEncodeAsync(e,t){return Nl(this,e,t)},async safeDecodeAsync(e,t){return Rl(this,e,t)},toJSONSchema(e){return Hu(this,{})(e)},get description(){return nt.get(this)?.description},get _def(){return this._zod.def}}),Ul=g("_ZodString",(e,t)=>{Nr.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>nl(e,r,n,o)},Us({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(dt(...e))},max(...e){return this.check(qr(...e))},length(...e){return this.check(Vr(...e))},nonempty(...e){return this.check(dt(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())}})),kd=g("ZodString",(e,t)=>{Nr.init(e,t),Ul.init(e,t)},{email(e){return this.check(uu(Pd,e))},url(e){return this.check(mu(Ed,e))},jwt(e){return this.check(Zu(Vd,e))},emoji(e){return this.check(hu(Od,e))},guid(e){return this.check(lu(Zd,e))},uuid(e){return this.check(ao(Ut,e))},uuidv4(e){return this.check(pu(Ut,e))},uuidv6(e){return this.check(fu(Ut,e))},uuidv7(e){return this.check(du(Ut,e))},nanoid(e){return this.check(gu(Ad,e))},cuid(e){return this.check(xu(Cd,e))},cuid2(e){return this.check(yu(Td,e))},ulid(e){return this.check(bu(Nd,e))},base64(e){return this.check(Su(Fd,e))},base64url(e){return this.check(Iu(Ud,e))},xid(e){return this.check(vu(Rd,e))},ksuid(e){return this.check(_u(Md,e))},ipv4(e){return this.check(wu(Ld,e))},ipv6(e){return this.check(ku(Dd,e))},cidrv4(e){return this.check(zu(Bd,e))},cidrv6(e){return this.check($u(jd,e))},e164(e){return this.check(Pu(qd,e))},datetime(e){return this.check(Eu(zd,e))},date(e){return this.check(Ou($d,e))},time(e){return this.check(Au(Sd,e))},duration(e){return this.check(Cu(Id,e))}});function k(e){return cu(kd,e)}var B=g("ZodStringFormat",(e,t)=>{M.init(e,t),Ul.init(e,t)}),zd=g("ZodISODateTime",(e,t)=>{yc.init(e,t),B.init(e,t)}),$d=g("ZodISODate",(e,t)=>{bc.init(e,t),B.init(e,t)}),Sd=g("ZodISOTime",(e,t)=>{vc.init(e,t),B.init(e,t)}),Id=g("ZodISODuration",(e,t)=>{_c.init(e,t),B.init(e,t)}),Pd=g("ZodEmail",(e,t)=>{ac.init(e,t),B.init(e,t)});var Zd=g("ZodGUID",(e,t)=>{ic.init(e,t),B.init(e,t)});var Ut=g("ZodUUID",(e,t)=>{sc.init(e,t),B.init(e,t)});function Gr(e){return ao(Ut,e)}var Ed=g("ZodURL",(e,t)=>{lc.init(e,t),B.init(e,t)});var Od=g("ZodEmoji",(e,t)=>{pc.init(e,t),B.init(e,t)});var Ad=g("ZodNanoID",(e,t)=>{fc.init(e,t),B.init(e,t)});var Cd=g("ZodCUID",(e,t)=>{dc.init(e,t),B.init(e,t)});var Td=g("ZodCUID2",(e,t)=>{mc.init(e,t),B.init(e,t)});var Nd=g("ZodULID",(e,t)=>{hc.init(e,t),B.init(e,t)});var Rd=g("ZodXID",(e,t)=>{gc.init(e,t),B.init(e,t)});var Md=g("ZodKSUID",(e,t)=>{xc.init(e,t),B.init(e,t)});var Ld=g("ZodIPv4",(e,t)=>{wc.init(e,t),B.init(e,t)});var Dd=g("ZodIPv6",(e,t)=>{zc.init(e,t),B.init(e,t)});var Bd=g("ZodCIDRv4",(e,t)=>{$c.init(e,t),B.init(e,t)});var jd=g("ZodCIDRv6",(e,t)=>{Sc.init(e,t),B.init(e,t)});var Fd=g("ZodBase64",(e,t)=>{Pc.init(e,t),B.init(e,t)});var Ud=g("ZodBase64URL",(e,t)=>{Zc.init(e,t),B.init(e,t)});var qd=g("ZodE164",(e,t)=>{Ec.init(e,t),B.init(e,t)});var Vd=g("ZodJWT",(e,t)=>{Oc.init(e,t),B.init(e,t)});var ql=g("ZodNumber",(e,t)=>{ro.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ol(e,r,n,o),e.isFinite=!0},Us({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(Fr(e,t))},gte(e,t){return this.check(Bt(e,t))},min(e,t){return this.check(Bt(e,t))},lt(e,t){return this.check(jr(e,t))},lte(e,t){return this.check(Dt(e,t))},max(e,t){return this.check(Dt(e,t))},int(e){return this.check(Ml(e))},safe(e){return this.check(Ml(e))},positive(e){return this.check(Fr(0,e))},nonnegative(e){return this.check(Bt(0,e))},negative(e){return this.check(jr(0,e))},nonpositive(e){return this.check(Dt(0,e))},multipleOf(e,t){return this.check(Ur(e,t))},step(e,t){return this.check(Ur(e,t))},finite(){return this}}));function Jd(e){return Tu(ql,e)}var Hd=g("ZodNumberFormat",(e,t)=>{Ac.init(e,t),ql.init(e,t)});function Ml(e){return Nu(Hd,e)}var Kd=g("ZodBoolean",(e,t)=>{Cc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>il(e,r,n,o)});function He(e){return Ru(Kd,e)}var Gd=g("ZodUnknown",(e,t)=>{Tc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>al(e,r,n,o)});function Ll(){return Mu(Gd)}var Xd=g("ZodNever",(e,t)=>{Nc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>sl(e,r,n,o)});function Vl(e){return Lu(Xd,e)}var Yd=g("ZodArray",(e,t)=>{Kr(),Rc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>pl(e,r,n,o),e.element=t.element},{min(e,t){return this.check(dt(e,t))},nonempty(e){return this.check(dt(1,e))},max(e,t){return this.check(qr(e,t))},length(e,t){return this.check(Vr(e,t))},unwrap(){return this.element}});function te(e,t){return Du(Yd,e,t)}var Jl=g("ZodObject",(e,t)=>{Kr(),Dc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>fl(e,r,n,o),Of(e,"shape",(r)=>r._zod.def.shape,!1)},{keyof(){return qt(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:Ll()}))},loose(){return this.clone(ae(this._zod.def,{catchall:Ll()}))},strict(){return this.clone(ae(this._zod.def,{catchall:Vl()}))},strip(){return this.clone(ae(this._zod.def,{catchall:void 0}))},extend(e){return kf(this,e)},safeExtend(e){return zf(this,e)},merge(e){return $f(this,e)},pick(e){return _f(this,e)},omit(e){return wf(this,e)},partial(...e){return Ds(Hl,this,e[0])},exactPartial(...e){return Ds(Kl,this,e[0],"exactPartial")},required(...e){return Sf(Gl,this,e[0])}});function Eo(e,t){let r={type:"object",shape:e??{},...z(t)};return new Jl(r)}function J(e,t){return new Jl({type:"object",shape:e,catchall:Vl(),...z(t)})}var Wd=g("ZodUnion",(e,t)=>{Bc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>dl(e,r,n,o),e.options=t.options});function Qd(e,t){return new Wd({type:"union",options:e,...z(t)})}var em=g("ZodIntersection",(e,t)=>{jc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ml(e,r,n,o)});function tm(e,t){return new em({type:"intersection",left:e,right:t})}var Dl=g("ZodRecord",(e,t)=>{Kr(),Fc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>hl(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function Xr(e,t,r){if(!t||!t._zod)return new Dl({type:"record",keyType:k(),valueType:e,...z(t)});return new Dl({type:"record",keyType:e,valueType:t,...z(r)})}var Zo=g("ZodEnum",(e,t)=>{Uc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(n,o,i)=>cl(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:[],...z(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:[],...z(o),entries:i})}});function qt(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map((n)=>[n,n])):e;return new Zo({type:"enum",entries:r,...z(t)})}var rm=g("ZodTransform",(e,t)=>{Kr(),qc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ll(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Ct(e.constructor.name);r.addIssue=(i)=>{if(typeof i==="string")r.issues.push(rt(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(rt(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 nm(e){return new rm({type:"transform",transform:e})}var Hl=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 Bl(e){return new Hl({type:"optional",innerType:e})}var Kl=g("ZodExactOptional",(e,t)=>{Vc.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 om(e){return new Kl({type:"optional",innerType:e})}var im=g("ZodNullable",(e,t)=>{Jc.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 jl(e){return new im({type:"nullable",innerType:e})}var sm=g("ZodDefault",(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,e.removeDefault=e.unwrap});function am(e,t){return new sm({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():Mn(t)}})}var cm=g("ZodPrefault",(e,t)=>{Kc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>vl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function um(e,t){return new cm({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():Mn(t)}})}var Gl=g("ZodNonOptional",(e,t)=>{Gc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>xl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function lm(e,t){return new Gl({type:"nonoptional",innerType:e,...z(t)})}var pm=g("ZodCatch",(e,t)=>{Xc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>_l(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function fm(e,t){return new pm({type:"catch",innerType:e,catchValue:typeof t==="function"?t:qs(t)})}var dm=g("ZodPipe",(e,t)=>{Yc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>wl(e,r,n,o),e.in=t.in,e.out=t.out});function Fl(e,t){return new dm({type:"pipe",in:e,out:t})}var mm=g("ZodReadonly",(e,t)=>{Wc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>kl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function hm(e){return new mm({type:"readonly",innerType:e})}var gm=g("ZodCustom",(e,t)=>{Qc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ul(e,r,n,o)});function xm(e,t={}){return Bu(gm,e,t)}function ym(e,t){return ju(e,t)}var gt=qt(["global","private","shared"]),bm=k().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/).max(48),xt=J({name:bm,description:k().trim().min(1).max(300),body:k().trim().min(1).max(24000)}),Oo=J({scope:gt,choices:Xr(k().max(128),He()),edits:Xr(k().max(128),k().min(1).max(48000)).default({}),custom:te(xt).max(40).default([])}),f0=Oo.extend({directory:k(),id:k()});var vm=J({id:k(),title:k(),parentId:k().nullable()}),_m=J({id:k(),itemIds:te(k()).min(1),parentId:k(),relatedHubIds:te(k()).max(2)}),Yr=J({hubs:te(vm),leaves:te(_m)});var wm=J({id:k(),name:k(),title:k(),description:k(),text:k(),kind:qt(["preference","skill"]),category:k().nullable(),section:k().nullable(),axis:k().nullable(),owner:qt(["packaged","managed","user","provider"])}),Xl=J({scope:gt,input:Oo,inherited:Xr(k(),He()),locked:Xr(k(),He()),items:te(wm),constellation:Yr,requirements:te(k()),libraryEnabled:He(),migrationRequired:He(),revisionId:k().nullable()}),Yl=J({id:Gr(),changes:te(J({path:k(),before:k().nullable(),after:k().nullable(),internal:He()})),warnings:te(k())}),Ao=J({revisionId:k().nullable()});var Co=window.location.hash.slice(1),km=Co||sessionStorage.getItem("shadowclone-session")||"";if(Co)sessionStorage.setItem("shadowclone-session",Co),history.replaceState(null,"",`${location.pathname}${location.search}`);async function Y(e){let t=await fetch(e.path,{method:e.body===void 0?"GET":"POST",headers:{Authorization:`Bearer ${km}`,"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=Eo({error:k()}).safeParse(r);throw Error(n.success?n.data.error:"The local editor could not complete this action.")}return e.schema.parse(r)}function To(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=To({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 zm=new Set(["agent","before","change","changing","code","existing","from","into","skill","that","the","this","when","with","work"]);function No(e){return e.toLowerCase().replaceAll(/[^a-z0-9-]+/g," ").split(/[\s-]+/).filter((t)=>t.length>2&&!zm.has(t))}function $m(e){return[e.category,e.section,e.axis,...No(e.name),...No(e.title),...No(e.description)].filter((t,r,n)=>Boolean(t&&n.indexOf(t)===r))}function Wl(e){return e.split("-").map((t)=>`${t[0]?.toUpperCase()??""}${t.slice(1)}`).join(" ")}function Sm(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:$m(r)}))}function Im(e){if(e<4)return Math.max(1,e);return Math.min(12,Math.max(4,Math.round(Math.sqrt(e))))}function Pm(e){let r=[...Map.groupBy(e,(i)=>i.topics[0]??"guidance")].map(([i,s])=>({key:i,entries:s})),n=Im(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 Zm(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 Em(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 Ql(e){let t=Sm(e),r=Pm(t),n=r.map(Zm),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:`${Wl(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=To({parentId:u,title:Wl(Em(f,a.key)),leaves:d});o.push(...m.hubs),i.push(...m.leaves)}return Yr.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 Ro(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 ze(e){let t=P(e);if(!(t instanceof HTMLSelectElement))throw Error("Expected a selection control");return t}function Me(e){let t=P(e);if(!(t instanceof HTMLTextAreaElement))throw Error("Expected a text editor");return t}function yt(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 fe(e){let t=P("notice");t.textContent=e.message,t.classList.toggle("success",e.success===!0),t.hidden=e.message.length===0}function it(e){fe({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 Mo(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 Lo(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.`:"",Me("custom-body").value=e?`# Personal guidance for ${e.title}
58
+
59
+ `:"",yt("custom-dialog").showModal()}function ep(){let e=xt.parse({name:oe("custom-name").value,description:oe("custom-description").value,body:Me("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=Ql(_.view.items);yt("custom-dialog").close(),oe("custom-name").value="",Me("custom-body").value=""}var tp={"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 $e(e){return tp[e.id]?.title??e.title}function rp(e){let t=tp[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 Om(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))Mo(e.item);_.input.edits[e.item.id]=r.value,_.input.choices[e.item.id]=!0,_.dirty=!0,fe({message:"Instructions added to your draft. Review the changes before applying.",success:!0}),e.rerender()}),t.append(r,n),t}function np(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:$e(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:rp({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}Mo(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(Om({item:r,rerender:e.rerender}))}var op=J({title:k().min(1).max(80),summary:k().min(1).max(600),strengths:te(k().min(1).max(180)).max(3),tradeoffs:te(k().min(1).max(180)).max(3),hubLabels:te(J({id:k().min(1).max(120),title:k().min(1).max(40)})).max(12).default([])}),ip=J({id:Gr(),destination:k(),payload:k(),limits:k(),cached:op.nullable()}),sp=J({description:op});function Wr(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 Qr(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()),Wr(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 Y({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 bt(e){return function(){return this.matches(e)}}function en(e){return function(t){return t.matches(e)}}var tn="http://www.w3.org/1999/xhtml",Do={svg:"http://www.w3.org/2000/svg",xhtml:tn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Se(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 Bo(e){let t;while(t=e.sourceEvent)e=t;return e}function Ie(e,t){if(e=Bo(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 Am(){}function Ke(e){return e==null?Am:function(){return this.querySelector(e)}}function jo(e){if(typeof e!=="function")e=Ke(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 Fo(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Cm(){return[]}function vt(e){return e==null?Cm:function(){return this.querySelectorAll(e)}}function Tm(e){return function(){return Fo(e.apply(this,arguments))}}function Uo(e){if(typeof e==="function")e=Tm(e);else e=vt(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 Nm=Array.prototype.find;function Rm(e){return function(){return Nm.call(this.children,e)}}function Mm(){return this.firstElementChild}function qo(e){return this.select(e==null?Mm:Rm(typeof e==="function"?e:en(e)))}var Lm=Array.prototype.filter;function Dm(){return Array.from(this.children)}function Bm(e){return function(){return Lm.call(this.children,e)}}function Vo(e){return this.selectAll(e==null?Dm:Bm(typeof e==="function"?e:en(e)))}function Jo(e){if(typeof e!=="function")e=bt(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 Vt(e){return Array(e.length)}function Ho(){return new U(this._enter||this._groups.map(Vt),this._parents)}function Jt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Jt.prototype={constructor:Jt,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 Ko(e){return function(){return e}}function jm(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 Jt(e,i[s]);for(;s<u;++s)if(a=t[s])o[s]=a}function Fm(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 Jt(e,i[a]);for(a=0;a<l;++a)if((u=t[a])&&c.get(f[a])===u)o[a]=u}function Um(e){return e.__data__}function Go(e,t){if(!arguments.length)return Array.from(this,Um);var r=t?Fm:jm,n=this._parents,o=this._groups;if(typeof e!=="function")e=Ko(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=qm(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,L=0,j,T;Z<m;++Z)if(j=x[Z]){if(Z>=L)L=Z+1;while(!(T=v[L])&&++L<m);j._next=T||null}}return s=new U(s,n),s._enter=a,s._exit=u,s}function qm(e){return typeof e==="object"&&"length"in e?e:Array.from(e)}function Xo(){return new U(this._exit||this._groups.map(Vt),this._parents)}function Yo(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 Wo(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 Qo(){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 ei(e){if(!e)e=Vm;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 Vm(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function ti(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function ri(){return Array.from(this)}function ni(){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 oi(){let e=0;for(let t of this)++e;return e}function ii(){return!this.node()}function si(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 Jm(e){return function(){this.removeAttribute(e)}}function Hm(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Km(e,t){return function(){this.setAttribute(e,t)}}function Gm(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Xm(e,t){return function(){var r=t.apply(this,arguments);if(r==null)this.removeAttribute(e);else this.setAttribute(e,r)}}function Ym(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 ai(e,t){var r=Se(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?Hm:Jm:typeof t==="function"?r.local?Ym:Xm:r.local?Gm:Km)(r,t))}function Ht(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Wm(e){return function(){this.style.removeProperty(e)}}function Qm(e,t,r){return function(){this.style.setProperty(e,t,r)}}function eh(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 ci(e,t,r){return arguments.length>1?this.each((t==null?Wm:typeof t==="function"?eh:Qm)(e,t,r==null?"":r)):Ge(this.node(),e)}function Ge(e,t){return e.style.getPropertyValue(t)||Ht(e).getComputedStyle(e,null).getPropertyValue(t)}function th(e){return function(){delete this[e]}}function rh(e,t){return function(){this[e]=t}}function nh(e,t){return function(){var r=t.apply(this,arguments);if(r==null)delete this[e];else this[e]=r}}function ui(e,t){return arguments.length>1?this.each((t==null?th:typeof t==="function"?nh:rh)(e,t)):this.node()[e]}function ap(e){return e.trim().split(/^|\s+/)}function li(e){return e.classList||new cp(e)}function cp(e){this._node=e,this._names=ap(e.getAttribute("class")||"")}cp.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 up(e,t){var r=li(e),n=-1,o=t.length;while(++n<o)r.add(t[n])}function lp(e,t){var r=li(e),n=-1,o=t.length;while(++n<o)r.remove(t[n])}function oh(e){return function(){up(this,e)}}function ih(e){return function(){lp(this,e)}}function sh(e,t){return function(){(t.apply(this,arguments)?up:lp)(this,e)}}function pi(e,t){var r=ap(e+"");if(arguments.length<2){var n=li(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"?sh:t?oh:ih)(r,t))}function ah(){this.textContent=""}function ch(e){return function(){this.textContent=e}}function uh(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function fi(e){return arguments.length?this.each(e==null?ah:(typeof e==="function"?uh:ch)(e)):this.node().textContent}function lh(){this.innerHTML=""}function ph(e){return function(){this.innerHTML=e}}function fh(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function di(e){return arguments.length?this.each(e==null?lh:(typeof e==="function"?fh:ph)(e)):this.node().innerHTML}function dh(){if(this.nextSibling)this.parentNode.appendChild(this)}function mi(){return this.each(dh)}function mh(){if(this.previousSibling)this.parentNode.insertBefore(this,this.parentNode.firstChild)}function hi(){return this.each(mh)}function hh(e){return function(){var t=this.ownerDocument,r=this.namespaceURI;return r===tn&&t.documentElement.namespaceURI===tn?t.createElement(e):t.createElementNS(r,e)}}function gh(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Kt(e){var t=Se(e);return(t.local?gh:hh)(t)}function gi(e){var t=typeof e==="function"?e:Kt(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function xh(){return null}function xi(e,t){var r=typeof e==="function"?e:Kt(e),n=t==null?xh:typeof t==="function"?t:Ke(t);return this.select(function(){return this.insertBefore(r.apply(this,arguments),n.apply(this,arguments)||null)})}function yh(){var e=this.parentNode;if(e)e.removeChild(this)}function yi(){return this.each(yh)}function bh(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function vh(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function bi(e){return this.select(e?vh:bh)}function vi(e){return arguments.length?this.property("__data__",e):this.node().__data__}function _h(e){return function(t){e.call(this,t,this.__data__)}}function wh(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 kh(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 zh(e,t,r){return function(){var n=this.__on,o,i=_h(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 _i(e,t,r){var n=wh(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?zh:kh;for(o=0;o<i;++o)this.each(a(n[o],t,r));return this}function pp(e,t,r){var n=Ht(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 $h(e,t){return function(){return pp(this,e,t)}}function Sh(e,t){return function(){return pp(this,e,t.apply(this,arguments))}}function wi(e,t){return this.each((typeof t==="function"?Sh:$h)(e,t))}function*ki(){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 zi=[null];function U(e,t){this._groups=e,this._parents=t}function fp(){return new U([[document.documentElement]],zi)}function Ih(){return this}U.prototype=fp.prototype={constructor:U,select:jo,selectAll:Uo,selectChild:qo,selectChildren:Vo,filter:Jo,data:Go,enter:Ho,exit:Xo,join:Yo,merge:Wo,selection:Ih,order:Qo,sort:ei,call:ti,nodes:ri,node:ni,size:oi,empty:ii,each:si,attr:ai,style:ci,property:ui,classed:pi,text:fi,html:di,raise:mi,lower:hi,append:gi,insert:xi,remove:yi,clone:bi,datum:vi,on:_i,dispatch:wi,[Symbol.iterator]:ki};var Le=fp;function W(e){return typeof e==="string"?new U([[document.querySelector(e)]],[document.documentElement]):new U([[e]],zi)}var Ph={value:()=>{}};function mp(){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 rn(r)}function rn(e){this._=e}function Zh(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}})}rn.prototype=mp.prototype={constructor:rn,on:function(e,t){var r=this._,n=Zh(e+"",r),o,i=-1,s=n.length;if(arguments.length<2){while(++i<s)if((o=(e=n[i]).type)&&(o=Eh(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]=dp(r[o],e.name,t);else if(t==null)for(o in r)r[o]=dp(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 rn(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 Eh(e,t){for(var r=0,n=e.length,o;r<n;++r)if((o=e[r]).name===t)return o.value}function dp(e,t,r){for(var n=0,o=e.length;n<o;++n)if(e[n].name===t){e[n]=Ph,e=e.slice(0,n).concat(e.slice(n+1));break}if(r!=null)e.push({name:t,value:r});return e}var Gt=mp;var nn={capture:!0,passive:!1};function Xt(e){e.preventDefault(),e.stopImmediatePropagation()}function on(e){var t=e.document.documentElement,r=W(e).on("dragstart.drag",Xt,nn);if("onselectstart"in t)r.on("selectstart.drag",Xt,nn);else t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none"}function $i(e,t){var r=e.document.documentElement,n=W(e).on("dragstart.drag",null);if(t)n.on("click.drag",Xt,nn),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 Ii=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Si=new RegExp(Ii.source,"g");function Oh(e){return function(){return e}}function Ah(e){return function(t){return e(t)+""}}function sn(e,t){var r=Ii.lastIndex=Si.lastIndex=0,n,o,i,s=-1,a=[],u=[];e=e+"",t=t+"";while((n=Ii.exec(e))&&(o=Si.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=Si.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]?Ah(u[0].x):Oh(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 hp=180/Math.PI,an={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function cn(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)*hp,skewX:Math.atan(u)*hp,scaleX:s,scaleY:a}}var un;function gp(e){let t=new(typeof DOMMatrix==="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?an:cn(t.a,t.b,t.c,t.d,t.e,t.f)}function xp(e){if(e==null)return an;if(!un)un=document.createElementNS("http://www.w3.org/2000/svg","g");if(un.setAttribute("transform",e),!(e=un.transform.baseVal.consolidate()))return an;return e=e.matrix,cn(e.a,e.b,e.c,e.d,e.e,e.f)}function yp(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 Pi=yp(gp,"px, ","px)","deg)"),Zi=yp(xp,", ",")",")");var Ch=0.000000000001;function bp(e){return((e=Math.exp(e))+1/e)/2}function Th(e){return((e=Math.exp(e))-1/e)/2}function Nh(e){return((e=Math.exp(2*e))-1)/(e+1)}var Ei=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<Ch)b=Math.log(f/c)/t,v=function(H){return[a+H*d,u+H*m,c*Math.exp(t*H*b)]};else{var Z=Math.sqrt(x),L=(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(L*L+1)-L),O=Math.log(Math.sqrt(j*j+1)-j);b=(O-T)/t,v=function(H){var Fe=H*b,Qe=bp(T),Ue=c/(r*Z)*(Qe*Nh(t*Fe+T)-Th(T));return[a+Ue*d,u+Ue*m,c*Qe/bp(t*Fe+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 Yt(e,t,r){e.prototype=t.prototype=r,r.constructor=e}function Oi(e,t){var r=Object.create(e.prototype);for(var n in t)r[n]=t[n];return r}function er(){}var Wt=0.7,fn=1/Wt,_t="\\s*([+-]?\\d+)\\s*",Qt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Pe="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Rh=/^#([0-9a-f]{3,8})$/,Mh=new RegExp(`^rgb\\(${_t},${_t},${_t}\\)$`),Lh=new RegExp(`^rgb\\(${Pe},${Pe},${Pe}\\)$`),Dh=new RegExp(`^rgba\\(${_t},${_t},${_t},${Qt}\\)$`),Bh=new RegExp(`^rgba\\(${Pe},${Pe},${Pe},${Qt}\\)$`),jh=new RegExp(`^hsl\\(${Qt},${Pe},${Pe}\\)$`),Fh=new RegExp(`^hsla\\(${Qt},${Pe},${Pe},${Qt}\\)$`),vp={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};Yt(er,Xe,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:_p,formatHex:_p,formatHex8:Uh,formatHsl:qh,formatRgb:wp,toString:wp});function _p(){return this.rgb().formatHex()}function Uh(){return this.rgb().formatHex8()}function qh(){return Pp(this).formatHsl()}function wp(){return this.rgb().formatRgb()}function Xe(e){var t,r;return e=(e+"").trim().toLowerCase(),(t=Rh.exec(e))?(r=t[1].length,t=parseInt(t[1],16),r===6?kp(t):r===3?new se(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):r===8?ln(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):r===4?ln(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=Mh.exec(e))?new se(t[1],t[2],t[3],1):(t=Lh.exec(e))?new se(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Dh.exec(e))?ln(t[1],t[2],t[3],t[4]):(t=Bh.exec(e))?ln(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=jh.exec(e))?Sp(t[1],t[2]/100,t[3]/100,1):(t=Fh.exec(e))?Sp(t[1],t[2]/100,t[3]/100,t[4]):vp.hasOwnProperty(e)?kp(vp[e]):e==="transparent"?new se(NaN,NaN,NaN,0):null}function kp(e){return new se(e>>16&255,e>>8&255,e&255,1)}function ln(e,t,r,n){if(n<=0)e=t=r=NaN;return new se(e,t,r,n)}function Vh(e){if(!(e instanceof er))e=Xe(e);if(!e)return new se;return e=e.rgb(),new se(e.r,e.g,e.b,e.opacity)}function wt(e,t,r,n){return arguments.length===1?Vh(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}Yt(se,wt,Oi(er,{brighter(e){return e=e==null?fn:Math.pow(fn,e),new se(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Wt:Math.pow(Wt,e),new se(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new se(at(this.r),at(this.g),at(this.b),dn(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:zp,formatHex:zp,formatHex8:Jh,formatRgb:$p,toString:$p}));function zp(){return`#${st(this.r)}${st(this.g)}${st(this.b)}`}function Jh(){return`#${st(this.r)}${st(this.g)}${st(this.b)}${st((isNaN(this.opacity)?1:this.opacity)*255)}`}function $p(){let e=dn(this.opacity);return`${e===1?"rgb(":"rgba("}${at(this.r)}, ${at(this.g)}, ${at(this.b)}${e===1?")":`, ${e})`}`}function dn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function at(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function st(e){return e=at(e),(e<16?"0":"")+e.toString(16)}function Sp(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 xe(e,t,r,n)}function Pp(e){if(e instanceof xe)return new xe(e.h,e.s,e.l,e.opacity);if(!(e instanceof er))e=Xe(e);if(!e)return new xe;if(e instanceof xe)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 xe(s,a,u,e.opacity)}function Zp(e,t,r,n){return arguments.length===1?Pp(e):new xe(e,t,r,n==null?1:n)}function xe(e,t,r,n){this.h=+e,this.s=+t,this.l=+r,this.opacity=+n}Yt(xe,Zp,Oi(er,{brighter(e){return e=e==null?fn:Math.pow(fn,e),new xe(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Wt:Math.pow(Wt,e),new xe(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(Ai(e>=240?e-240:e+120,o,n),Ai(e,o,n),Ai(e<120?e+240:e-120,o,n),this.opacity)},clamp(){return new xe(Ip(this.h),pn(this.s),pn(this.l),dn(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=dn(this.opacity);return`${e===1?"hsl(":"hsla("}${Ip(this.h)}, ${pn(this.s)*100}%, ${pn(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Ip(e){return e=(e||0)%360,e<0?e+360:e}function pn(e){return Math.max(0,Math.min(1,e||0))}function Ai(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 Ci(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 Ti(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 Ci((r-n/t)*t,s,o,i,a)}}function Ni(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 Ci((r-n/t)*t,o,i,s,a)}}var Ri=(e)=>()=>e;function Hh(e,t){return function(r){return e+r*t}}function Kh(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 Ep(e){return(e=+e)===1?mn:function(t,r){return r-t?Kh(t,r,e):Ri(isNaN(t)?r:t)}}function mn(e,t){var r=t-e;return r?Hh(e,r):Ri(isNaN(e)?t:e)}var hn=function e(t){var r=Ep(t);function n(o,i){var s=r((o=wt(o)).r,(i=wt(i)).r),a=r(o.g,i.g),u=r(o.b,i.b),c=mn(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 Op(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=wt(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 Gh=Op(Ti),Xh=Op(Ni);var kt=0,rr=0,tr=0,Cp=1000,gn,nr,xn=0,ct=0,yn=0,or=typeof performance==="object"&&performance.now?performance:Date,Tp=typeof window==="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function sr(){return ct||(Tp(Yh),ct=or.now()+yn)}function Yh(){ct=0}function ir(){this._call=this._time=this._next=null}ir.prototype=bn.prototype={constructor:ir,restart:function(e,t,r){if(typeof e!=="function")throw TypeError("callback is not a function");if(r=(r==null?sr():+r)+(t==null?0:+t),!this._next&&nr!==this){if(nr)nr._next=this;else gn=this;nr=this}this._call=e,this._time=r,Mi()},stop:function(){if(this._call)this._call=null,this._time=1/0,Mi()}};function bn(e,t,r){var n=new ir;return n.restart(e,t,r),n}function Np(){sr(),++kt;var e=gn,t;while(e){if((t=ct-e._time)>=0)e._call.call(void 0,t);e=e._next}--kt}function Ap(){ct=(xn=or.now())+yn,kt=rr=0;try{Np()}finally{kt=0,Qh(),ct=0}}function Wh(){var e=or.now(),t=e-xn;if(t>Cp)yn-=t,xn=e}function Qh(){var e,t=gn,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:gn=r;nr=e,Mi(n)}function Mi(e){if(kt)return;if(rr)rr=clearTimeout(rr);var t=e-ct;if(t>24){if(e<1/0)rr=setTimeout(Ap,e-or.now()-yn);if(tr)tr=clearInterval(tr)}else{if(!tr)xn=or.now(),tr=setInterval(Wh,Cp);kt=1,Tp(Ap)}}function ar(e,t,r){var n=new ir;return t=t==null?0:+t,n.restart((o)=>{n.stop(),e(o+t)},t,r),n}var eg=Gt("start","end","cancel","interrupt"),tg=[],Lp=0,Rp=1,_n=2,vn=3,Mp=4,wn=5,cr=6;function De(e,t,r,n,o,i){var s=e.__transition;if(!s)e.__transition={};else if(r in s)return;rg(e,r,{name:t,index:n,group:o,on:eg,tween:tg,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Lp})}function ur(e,t){var r=K(e,t);if(r.state>Lp)throw Error("too late; already scheduled");return r}function Q(e,t){var r=K(e,t);if(r.state>vn)throw Error("too late; already running");return r}function K(e,t){var r=e.__transition;if(!r||!(r=r[t]))throw Error("transition not found");return r}function rg(e,t,r){var n=e.__transition,o;n[t]=r,r.timer=bn(i,0,r.time);function i(c){if(r.state=Rp,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!==Rp)return u();for(l in n){if(d=n[l],d.name!==r.name)continue;if(d.state===vn)return ar(s);if(d.state===Mp)d.state=cr,d.timer.stop(),d.on.call("interrupt",e,e.__data__,d.index,d.group),delete n[l];else if(+l<t)d.state=cr,d.timer.stop(),d.on.call("cancel",e,e.__data__,d.index,d.group),delete n[l]}if(ar(function(){if(r.state===vn)r.state=Mp,r.timer.restart(a,r.delay,r.time),a(c)}),r.state=_n,r.on.call("start",e,e.__data__,r.index,r.group),r.state!==_n)return;r.state=vn,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=wn,1),p=-1,f=o.length;while(++p<f)o[p].call(e,l);if(r.state===wn)r.on.call("end",e,e.__data__,r.index,r.group),u()}function u(){r.state=cr,r.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function Ye(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>_n&&n.state<wn,n.state=cr,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 Li(e){return this.each(function(){Ye(this,e)})}function ng(e,t){var r,n;return function(){var o=Q(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 og(e,t,r){var n,o;if(typeof r!=="function")throw Error();return function(){var i=Q(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=K(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?ng:og)(r,e,t))}function zt(e,t,r){var n=e._id;return e.each(function(){var o=Q(this,n);(o.value||(o.value={}))[t]=r.apply(this,arguments)}),function(o){return K(o,n).value[t]}}function lr(e,t){var r;return(typeof t==="number"?le:t instanceof Xe?hn:(r=Xe(t))?(t=r,hn):sn)(e,t)}function ig(e){return function(){this.removeAttribute(e)}}function sg(e){return function(){this.removeAttributeNS(e.space,e.local)}}function ag(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 cg(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 ug(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 lg(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 Bi(e,t){var r=Se(e),n=r==="transform"?Zi:lr;return this.attrTween(e,typeof t==="function"?(r.local?lg:ug)(r,n,zt(this,"attr."+e,t)):t==null?(r.local?sg:ig)(r):(r.local?cg:ag)(r,n,t))}function pg(e,t){return function(r){this.setAttribute(e,t.call(this,r))}}function fg(e,t){return function(r){this.setAttributeNS(e.space,e.local,t.call(this,r))}}function dg(e,t){var r,n;function o(){var i=t.apply(this,arguments);if(i!==n)r=(n=i)&&fg(e,i);return r}return o._value=t,o}function mg(e,t){var r,n;function o(){var i=t.apply(this,arguments);if(i!==n)r=(n=i)&&pg(e,i);return r}return o._value=t,o}function ji(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=Se(e);return this.tween(r,(n.local?dg:mg)(n,t))}function hg(e,t){return function(){ur(this,e).delay=+t.apply(this,arguments)}}function gg(e,t){return t=+t,function(){ur(this,e).delay=t}}function Fi(e){var t=this._id;return arguments.length?this.each((typeof e==="function"?hg:gg)(t,e)):K(this.node(),t).delay}function xg(e,t){return function(){Q(this,e).duration=+t.apply(this,arguments)}}function yg(e,t){return t=+t,function(){Q(this,e).duration=t}}function Ui(e){var t=this._id;return arguments.length?this.each((typeof e==="function"?xg:yg)(t,e)):K(this.node(),t).duration}function bg(e,t){if(typeof t!=="function")throw Error();return function(){Q(this,e).ease=t}}function qi(e){var t=this._id;return arguments.length?this.each(bg(t,e)):K(this.node(),t).ease}function vg(e,t){return function(){var r=t.apply(this,arguments);if(typeof r!=="function")throw Error();Q(this,e).ease=r}}function Vi(e){if(typeof e!=="function")throw Error();return this.each(vg(this._id,e))}function Ji(e){if(typeof e!=="function")e=bt(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 re(n,this._parents,this._name,this._id)}function Hi(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 re(s,this._parents,this._name,this._id)}function _g(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 wg(e,t,r){var n,o,i=_g(t)?ur:Q;return function(){var s=i(this,e),a=s.on;if(a!==n)(o=(n=a).copy()).on(t,r);s.on=o}}function Ki(e,t){var r=this._id;return arguments.length<2?K(this.node(),r).on.on(e):this.each(wg(r,e,t))}function kg(e){return function(){var t=this.parentNode;for(var r in this.__transition)if(+r!==e)return;if(t)t.removeChild(this)}}function Gi(){return this.on("end.remove",kg(this._id))}function Xi(e){var t=this._name,r=this._id;if(typeof e!=="function")e=Ke(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,De(c[f],t,r,f,c,K(l,r))}return new re(i,this._parents,t,r)}function Yi(e){var t=this._name,r=this._id;if(typeof e!=="function")e=vt(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=K(l,r),x=0,v=f.length;x<v;++x)if(d=f[x])De(d,t,r,x,f,m);i.push(f),s.push(l)}return new re(i,s,t,r)}var zg=Le.prototype.constructor;function Wi(){return new zg(this._groups,this._parents)}function $g(e,t){var r,n,o;return function(){var i=Ge(this,e),s=(this.style.removeProperty(e),Ge(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 Sg(e,t,r){var n,o=r+"",i;return function(){var s=Ge(this,e);return s===o?null:s===n?i:i=t(n=s,r)}}function Ig(e,t,r){var n,o,i;return function(){var s=Ge(this,e),a=r(this),u=a+"";if(a==null)u=a=(this.style.removeProperty(e),Ge(this,e));return s===u?null:s===n&&u===o?i:(o=u,i=t(n=s,a))}}function Pg(e,t){var r,n,o,i="style."+t,s="end."+i,a;return function(){var u=Q(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 Qi(e,t,r){var n=(e+="")==="transform"?Pi:lr;return t==null?this.styleTween(e,$g(e,n)).on("end.style."+e,Dp(e)):typeof t==="function"?this.styleTween(e,Ig(e,n,zt(this,"style."+e,t))).each(Pg(this._id,e)):this.styleTween(e,Sg(e,n,t),r).on("end.style."+e,null)}function Zg(e,t,r){return function(n){this.style.setProperty(e,t.call(this,n),r)}}function Eg(e,t,r){var n,o;function i(){var s=t.apply(this,arguments);if(s!==o)n=(o=s)&&Zg(e,s,r);return n}return i._value=t,i}function es(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,Eg(e,t,r==null?"":r))}function Og(e){return function(){this.textContent=e}}function Ag(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function ts(e){return this.tween("text",typeof e==="function"?Ag(zt(this,"text",e)):Og(e==null?"":e+""))}function Cg(e){return function(t){this.textContent=e.call(this,t)}}function Tg(e){var t,r;function n(){var o=e.apply(this,arguments);if(o!==r)t=(r=o)&&Cg(o);return t}return n._value=e,n}function rs(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,Tg(e))}function ns(){var e=this._name,t=this._id,r=kn();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=K(u,t);De(u,e,r,c,s,{time:l.time+l.delay+l.duration,delay:0,duration:l.duration,ease:l.ease})}return new re(n,this._parents,e,r)}function os(){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=Q(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 Ng=0;function re(e,t,r,n){this._groups=e,this._parents=t,this._name=r,this._id=n}function Bp(e){return Le().transition(e)}function kn(){return++Ng}var Be=Le.prototype;re.prototype=Bp.prototype={constructor:re,select:Xi,selectAll:Yi,selectChild:Be.selectChild,selectChildren:Be.selectChildren,filter:Ji,merge:Hi,selection:Wi,transition:ns,call:Be.call,nodes:Be.nodes,node:Be.node,size:Be.size,empty:Be.empty,each:Be.each,on:Ki,attr:Bi,attrTween:ji,style:Qi,styleTween:es,text:ts,textTween:rs,remove:Gi,tween:Di,delay:Fi,duration:Ui,ease:qi,easeVarying:Vi,end:os,[Symbol.iterator]:Be[Symbol.iterator]};function zn(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Rg={time:null,delay:0,duration:250,ease:zn};function Mg(e,t){var r;while(!(r=e.__transition)||!(r=r[t]))if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return r}function is(e){var t,r;if(e instanceof re)t=e._id,e=e._name;else t=kn(),(r=Rg).time=sr(),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])De(u,e,t,c,s,r||Mg(u,t));return new re(n,this._parents,e,t)}Le.prototype.interrupt=Li;Le.prototype.transition=is;var pr=(e)=>()=>e;function ss(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 ye(e,t,r){this.k=e,this.x=t,this.y=r}ye.prototype={constructor:ye,scale:function(e){return e===1?this:new ye(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new ye(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 Ze=new ye(1,0,0);fr.prototype=ye.prototype;function fr(e){while(!e.__zoom)if(!(e=e.parentNode))return Ze;return e.__zoom}function $n(e){e.stopImmediatePropagation()}function ut(e){e.preventDefault(),e.stopImmediatePropagation()}function Lg(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Dg(){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 jp(){return this.__zoom||Ze}function Bg(e){return-e.deltaY*(e.deltaMode===1?0.05:e.deltaMode?1:0.002)*(e.ctrlKey?10:1)}function jg(){return navigator.maxTouchPoints||"ontouchstart"in this}function Fg(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 Sn(){var e=Lg,t=Dg,r=Fg,n=Bg,o=jg,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,u=Ei,c=Gt("start","zoom","end"),l,p,f,d=500,m=150,x=0,v=10;function b(h){h.property("__zoom",jp).on("wheel.zoom",Fe,{passive:!1}).on("mousedown.zoom",Qe).on("dblclick.zoom",Ue).filter(o).on("touchstart.zoom",xr).on("touchmove.zoom",On).on("touchend.zoom touchcancel.zoom",An).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}b.transform=function(h,S,y,I){var E=h.selection?h.selection():h;if(E.property("__zoom",jp),h!==E)T(h,S,y,I);else E.interrupt().each(function(){O(this,arguments).event(I).start().zoom(null,typeof S==="function"?S.apply(this,arguments):S).end()})},b.scaleBy=function(h,S,y,I){b.scaleTo(h,function(){var E=this.__zoom.k,A=typeof S==="function"?S.apply(this,arguments):S;return E*A},y,I)},b.scaleTo=function(h,S,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 S==="function"?S.apply(this,arguments):S;return r(L(Z(A,q),C,R),E,s)},y,I)},b.translateBy=function(h,S,y,I){b.transform(h,function(){return r(this.__zoom.translate(typeof S==="function"?S.apply(this,arguments):S,typeof y==="function"?y.apply(this,arguments):y),t.apply(this,arguments),s)},null,I)},b.translateTo=function(h,S,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(Ze.translate(R[0],R[1]).scale(C.k).translate(typeof S==="function"?-S.apply(this,arguments):-S,typeof y==="function"?-y.apply(this,arguments):-y),A,s)},I,E)};function Z(h,S){return S=Math.max(i[0],Math.min(i[1],S)),S===h.k?h:new ye(S,h.x,h.y)}function L(h,S,y){var I=S[0]-y[0]*h.k,E=S[1]-y[1]*h.k;return I===h.x&&E===h.y?h:new ye(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,S,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,be=Math.max(R[1][0]-R[0][0],R[1][1]-R[0][1]),G=E.__zoom,de=typeof S==="function"?S.apply(E,A):S,Ae=u(G.invert(q).concat(be/G.k),de.invert(q).concat(be/de.k));return function(me){if(me===1)me=de;else{var Ce=Ae(me),Cn=be/Ce[2];me=new ye(Cn,q[0]-Ce[0]*Cn,q[1]-Ce[1]*Cn)}C.zoom(null,me)}})}function O(h,S,y){return!y&&h.__zooming||new H(h,S)}function H(h,S){this.that=h,this.args=S,this.active=0,this.sourceEvent=null,this.extent=t.apply(h,S),this.taps=0}H.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,S){if(this.mouse&&h!=="mouse")this.mouse[1]=S.invert(this.mouse[0]);if(this.touch0&&h!=="touch")this.touch0[1]=S.invert(this.touch0[0]);if(this.touch1&&h!=="touch")this.touch1[1]=S.invert(this.touch1[0]);return this.that.__zoom=S,this.emit("zoom"),this},end:function(){if(--this.active===0)delete this.that.__zooming,this.emit("end");return this},emit:function(h){var S=W(this.that).datum();c.call(h,this.that,new ss(h,{sourceEvent:this.sourceEvent,target:b,type:h,transform:this.that.__zoom,dispatch:c}),S)}};function Fe(h,...S){if(!e.apply(this,arguments))return;var y=O(this,S).event(h),I=this.__zoom,E=Math.max(i[0],Math.min(i[1],I.k*Math.pow(2,n.apply(this,arguments)))),A=Ie(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)],Ye(this),y.start();ut(h),y.wheel=setTimeout(C,m),y.zoom("mouse",r(L(Z(I,E),y.mouse[0],y.mouse[1]),y.extent,s));function C(){y.wheel=null,y.end()}}function Qe(h,...S){if(f||!e.apply(this,arguments))return;var y=h.currentTarget,I=O(this,S,!0).event(h),E=W(h.view).on("mousemove.zoom",q,!0).on("mouseup.zoom",be,!0),A=Ie(h,y),{clientX:C,clientY:R}=h;on(h.view),$n(h),I.mouse=[A,this.__zoom.invert(A)],Ye(this),I.start();function q(G){if(ut(G),!I.moved){var de=G.clientX-C,Ae=G.clientY-R;I.moved=de*de+Ae*Ae>x}I.event(G).zoom("mouse",r(L(I.that.__zoom,I.mouse[0]=Ie(G,y),I.mouse[1]),I.extent,s))}function be(G){E.on("mousemove.zoom mouseup.zoom",null),$i(G.view,I.moved),ut(G),I.event(G).end()}}function Ue(h,...S){if(!e.apply(this,arguments))return;var y=this.__zoom,I=Ie(h.changedTouches?h.changedTouches[0]:h,this),E=y.invert(I),A=y.k*(h.shiftKey?0.5:2),C=r(L(Z(y,A),I,E),t.apply(this,S),s);if(ut(h),a>0)W(this).transition().duration(a).call(T,C,I,h);else W(this).call(b.transform,C,I,h)}function xr(h,...S){if(!e.apply(this,arguments))return;var y=h.touches,I=y.length,E=O(this,S,h.changedTouches.length===I).event(h),A,C,R,q;$n(h);for(C=0;C<I;++C)if(R=y[C],q=Ie(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);Ye(this),E.start()}}function On(h,...S){if(!this.__zooming)return;var y=O(this,S).event(h),I=h.changedTouches,E=I.length,A,C,R,q;ut(h);for(A=0;A<E;++A)if(C=I[A],R=Ie(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 be=y.touch0[0],G=y.touch0[1],de=y.touch1[0],Ae=y.touch1[1],me=(me=de[0]-be[0])*me+(me=de[1]-be[1])*me,Ce=(Ce=Ae[0]-G[0])*Ce+(Ce=Ae[1]-G[1])*Ce;C=Z(C,Math.sqrt(me/Ce)),R=[(be[0]+de[0])/2,(be[1]+de[1])/2],q=[(G[0]+Ae[0])/2,(G[1]+Ae[1])/2]}else if(y.touch0)R=y.touch0[0],q=y.touch0[1];else return;y.zoom("touch",r(L(C,R,q),y.extent,s))}function An(h,...S){if(!this.__zooming)return;var y=O(this,S).event(h),I=h.changedTouches,E=I.length,A,C;if($n(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=Ie(C,this),Math.hypot(p[0]-C[0],p[1]-C[1])<v){var R=W(this).on("dblclick.zoom");if(R)R.apply(this,arguments)}}}return b.wheelDelta=function(h){return arguments.length?(n=typeof h==="function"?h:pr(+h),b):n},b.filter=function(h){return arguments.length?(e=typeof h==="function"?h:pr(!!h),b):e},b.touchable=function(h){return arguments.length?(o=typeof h==="function"?h:pr(!!h),b):o},b.extent=function(h){return arguments.length?(t=typeof h==="function"?h:pr([[+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 Ug(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 qg(e){return`${$e(e)} ${e.description}`.toLowerCase().includes(_.search.toLowerCase())}function Fp(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=Ug(i.itemIds);if(!s||!qg(s))continue;let a=w({tag:"button",className:"skill-list-item",text:$e(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 Vg(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 as(){return this.eachAfter(Vg)}function cs(e,t){let r=-1;for(let n of this)e.call(t,n,++r,this);return this}function us(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 ls(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 ps(e,t){let r=-1;for(let n of this)if(e.call(t,n,++r,this))return n}function fs(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 ds(e){return this.eachBefore(function(t){if(t.children)t.children.sort(e)})}function ms(e){var t=this,r=Jg(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 Jg(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 hs(){var e=this,t=[e];while(e=e.parent)t.push(e);return t}function gs(){return Array.from(this)}function xs(){var e=[];return this.eachBefore(function(t){if(!t.children)e.push(t)}),e}function ys(){var e=this,t=[];return e.each(function(r){if(r!==e)t.push({source:r.parent,target:r})}),t}function*bs(){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 $t(e,t){if(e instanceof Map){if(e=[void 0,e],t===void 0)t=Gg}else if(t===void 0)t=Kg;var r=new lt(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 lt(s[a])),i.parent=n,i.depth=n.depth+1}return r.eachBefore(Yg)}function Hg(){return $t(this).eachBefore(Xg)}function Kg(e){return e.children}function Gg(e){return Array.isArray(e)?e[1]:null}function Xg(e){if(e.data.value!==void 0)e.value=e.data.value;e.data=e.data.data}function Yg(e){var t=0;do e.height=t;while((e=e.parent)&&e.height<++t)}function lt(e){this.data=e,this.depth=this.height=0,this.parent=null}lt.prototype=$t.prototype={constructor:lt,count:as,each:cs,eachAfter:ls,eachBefore:us,find:ps,sum:fs,sort:ds,path:ms,ancestors:hs,descendants:gs,leaves:xs,links:ys,copy:Hg,[Symbol.iterator]:bs};function Wg(e,t){return e.parent===t.parent?1:2}function vs(e){var t=e.children;return t?t[0]:e.t}function _s(e){var t=e.children;return t?t[t.length-1]:e.t}function Qg(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 ex(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 tx(e,t,r){return e.a.parent===t.parent?e.a:r}function In(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}In.prototype=Object.create(lt.prototype);function rx(e){var t=new In(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 In(i[s],s)),o.parent=r}return(t.parent=new In(null,0)).children=[t],t}function Pn(){var e=Wg,t=1,r=1,n=null;function o(c){var l=rx(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){ex(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,L=x.m,j;while(m=_s(m),f=vs(f),m&&f){if(x=vs(x),d=_s(d),d.a=c,j=m.z+Z-f.z-v+e(m._,f._),j>0)Qg(tx(m,c,p),c,j),v+=j,b+=j;Z+=m.m,v+=f.m,L+=x.m,b+=d.m}if(m&&!_s(d))d.t=m,d.m+=Z-b;if(f&&!vs(x))x.t=f,x.m+=v-L,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 ws(e){if(e===void 0)throw Error("Constellation layout is incomplete");return e}function nx(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 Up(e){let t=nx(e.constellation),r=$t(t,(a)=>a.children.filter((u)=>u.kind!=="skill"));Pn().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:ws(a.x)+e.width/2,y:e.height-92-ws(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:ws(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 ox={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"},ix={"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 qp(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",ox[e]),t.append(r),t}function Vp(e){return qp(ix[e.id]??"spark")}function Jp(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 qp(n)}function Hp(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 Kp(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 Gp(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 ks(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 sx="http://www.w3.org/2000/svg",St=()=>{return},We="",dr=null,je=new Set,Xp="",Yp=new Map,zs=null,Wp=new Map;function Ee(e){return document.createElementNS(sx,e)}function $s(e){let t=e.itemIds.map((r)=>Wp.get(r)).filter((r)=>r!==void 0);return t.find(ie)??t[0]}function Zn(e){let t=$s(e);return t?$e(t):e.title}function Qp(e){if(!_.search)return!0;let t=$s(e);return`${Zn(e)} ${t?.description??""}`.toLowerCase().includes(_.search.toLowerCase())}function ax(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 cx(e){let{group:t,node:r}=e,n=$s(r),o=Ee("g"),i=Ee(r.kind==="root"?"circle":"rect"),s=Ee("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",!Qp(r)),o.classList.toggle("focused",r.id===We),o.setAttribute("role","button"),o.setAttribute("tabindex","0"),o.setAttribute("aria-label",`${Zn(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 ax(Zn(r)).entries()){let f=Ee("tspan");f.setAttribute("x","0"),f.setAttribute("y",String((r.kind==="root"?44:38)+l*14)),f.textContent=p,s.append(f)}let u=Ee("title");if(u.textContent=Zn(r),o.append(u),o.append(i,s),r.kind==="root"){let l=document.querySelector(".brand-mark");if(l instanceof HTMLImageElement){let p=Ee("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=Ee("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?Vp(n):Jp(r.title)),l.append(p),o.append(l)}if(r.kind==="hub"){o.setAttribute("aria-expanded",String(je.has(r.id)));let l=Ee("text");l.setAttribute("class","map-node-count"),l.setAttribute("text-anchor","middle"),l.setAttribute("y","70");let p=Yp.get(r.id)??0;l.textContent=`${je.has(r.id)?"−":"+"} ${p} ${p===1?"skill":"skills"}`,o.append(l)}let c=()=>{if(n)St(n.id);else if(r.kind==="hub"){if(je.has(r.id))je.delete(r.id);else je.add(r.id);We=r.id}mr({inspect:St})};o.addEventListener("click",c),o.addEventListener("keydown",(l)=>{if(l.key==="Enter"||l.key===" ")l.preventDefault(),c()}),t.append(o)}function mr(e){St=e.inspect;let t=Ro("constellation-map"),r=_.view;if(!r)return;Fp({constellation:r.constellation,inspect:St});let n=t.getBoundingClientRect();if(n.width<=0||n.height<=0)return;Wp=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!==Xp;if(i){if(je.clear(),r.constellation.leaves.length<=40)for(let l of r.constellation.hubs)je.add(l.id);Xp=o,We=""}if(_.search)Hp({constellation:r.constellation,expandedHubIds:je,matchingItemIds:new Set(r.items.filter((l)=>`${$e(l)} ${l.description}`.toLowerCase().includes(_.search.toLowerCase())).map((l)=>l.id))});Yp=Gp(r.constellation);let s=Up({constellation:Kp({constellation:r.constellation,expandedHubIds:je}),width:n.width,height:n.height});zs=s,t.setAttribute("viewBox",`0 0 ${n.width} ${n.height}`),t.replaceChildren();let a=Ee("g");a.setAttribute("class","constellation-viewport"),t.append(a);for(let l of s.links){let p=Ee("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)cx({group:a,node:l});let u=Sn().scaleExtent([0.1,2.5]).on("zoom",(l)=>{a.setAttribute("transform",l.transform.toString())});if(W(t).call(u),a.setAttribute("transform",fr(t).toString()),dr=u,i){let l=ks({nodes:s.nodes,width:n.width,height:n.height});W(t).call(u.transform,Ze.translate(l.x,l.y).scale(Math.max(0.65,l.scale)))}let c=_.search?s.nodes.find((l)=>l.kind==="skill"&&Qp(l)):We?s.nodes.find((l)=>l.id===We):void 0;if(c&&(We||_.search)){let l=Ze.translate(n.width/2,n.height/2).scale(1.25).translate(-c.x,-c.y);W(t).call(u.transform,l)}}function ef(){let e=Ro("constellation-map");new ResizeObserver(()=>mr({inspect:St})).observe(e);let r=()=>{if(We="",dr)W(e).call(dr.transform,Ze)};P("fit-constellation").addEventListener("click",()=>{if(!dr||!zs)return;We="";let o=e.getBoundingClientRect(),i=ks({nodes:zs.nodes,width:o.width,height:o.height});W(e).call(dr.transform,Ze.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 tf(){mr({inspect:St})}var rf=null,It=null;function Ss(){let e=P("model-description");if(e.replaceChildren(),!It||rf!==JSON.stringify(_.input))return;e.append(w({tag:"h3",text:It.title}),w({tag:"p",text:It.summary}));for(let t of It.strengths)e.append(w({tag:"p",text:`Strength: ${t}`}));for(let t of It.tradeoffs)e.append(w({tag:"p",text:`Tradeoff: ${t}`}))}async function nf(){let e=JSON.stringify(_.input),t=await Y({path:"/api/description/preview",schema:ip,body:_.input});Qr({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:sp,accept:(r)=>{It=r.description,rf=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}tf(),Ss()}})}function of(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 sf(){let e=_.view?.items.filter((o)=>o.owner!=="provider"&&ie(o))??[],t=_.view?of({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)=>$e(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 En=null;async function af(){if(_.view===null)throw Error("Wait for your skills to load before reviewing the build.");let e=await Y({path:"/api/preview",schema:Yl,body:_.input});En=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)}yt("review-dialog").showModal()}async function cf(){if(En===null)throw Error("Review your build before applying it.");await Y({path:"/api/apply",schema:Ao,body:{previewId:En.id}}),En=null,yt("review-dialog").close(),fe({message:"Build equipped. Start a fresh agent session to use your updated skills.",success:!0})}async function uf(){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 Y({path:"/api/undo",schema:Ao,body:{revisionId:e}}),fe({message:"Restored the previous build.",success:!0})}function lf(){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 jI=J({name:k().trim().max(48),description:k().trim().max(300),body:k().trim().min(1).max(24000)}),pf=J({id:Gr(),destination:k(),payload:k(),limits:k(),cached:xt.nullable()}),ff=J({skill:xt});function pt(e){P("custom-status").textContent=e}async function ux(){let e=Me("custom-body").value;if(!e.trim()){pt("Describe what your agent should do, then use AI to shape it into a skill."),Me("custom-body").focus();return}let t=await Y({path:"/api/skill/preview",schema:pf,body:{name:oe("custom-name").value,description:oe("custom-description").value,body:e}});Qr({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:ff,accept:({skill:r})=>{oe("custom-name").value=r.name,oe("custom-description").value=r.description,Me("custom-body").value=r.body,pt("AI draft ready. Edit the instructions before adding the skill to your build."),Me("custom-body").focus()}})}function df(){let e=P("custom-ai");if(!(e instanceof HTMLButtonElement))return;e.addEventListener("click",()=>{if(e.disabled)return;e.disabled=!0,pt("Preparing your model request…"),ux().catch((t)=>{pt(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…")pt("")})})}var Is=!1;async function Pt(e){if(Is)return;Is=!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;Is=!1}}function Oe(e){P(e.id).addEventListener("click",()=>Pt(e.action).catch(it))}function mf(){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"))Wr(t)}var hf=te(J({id:Gr(),title:k(),state:k(),host:k(),parentId:k().nullable(),updatedAt:k(),verification:k(),review:He().nullable(),finish:k(),interruptedActions:Jd()}));function gf(){Oe({id:"refresh-tasks",action:async()=>{let e=await Y({path:"/api/tasks",schema:hf}),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)}}})}var lx=J({engine:qt(["claude-code","codex","cursor-agent","pi"]),model:k().min(1).optional(),name:k()}),xf=J({choices:te(lx),selected:Eo({engine:k().optional(),model:k().optional()})});function yf(){let e=null;Oe({id:"load-models",action:async()=>{e=await Y({path:"/api/learning-models",schema:xf});let t=ze("learning-model"),r=w({tag:"option",text:"Choose a configured model"});if(r.value="",r.disabled=!0,r.selected=!e.choices.some((n)=>n.engine===e?.selected.engine&&n.model===e?.selected.model),t.replaceChildren(r,...e.choices.map((n,o)=>{let i=w({tag:"option",text:n.name});return i.value=String(o),i.selected=n.engine===e?.selected.engine&&n.model===e?.selected.model,i})),e.choices.length===0)fe({message:"Configure a model in your coding harness, then refresh models."})}}),ze("learning-model").addEventListener("change",()=>{let t=ze("learning-model").value;if(t==="")return;let r=e?.choices[Number(t)];if(!r)return;Pt(async()=>{await Y({path:"/api/learning-model",schema:Eo({saved:He()}),body:{engine:r.engine,model:r.model}}),fe({message:"Saved your learning model. Session learning follows the session model unless overridden.",success:!0})}).catch(it)})}mf();gf();yf();function hr(){mr({inspect:(e)=>{_.activeId=e,hr()}}),np({rerender:hr,companion:Lo}),sf(),Ss(),P("undo").hidden=_.view?.revisionId===null}async function px(e){let t=await Y({path:`/api/build?scope=${e}`,schema:Xl});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??"";ze("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)fe({message:"Your existing profile needs its reviewed skills migration before this build can be applied. You can explore the editor now."});hr()}async function gr(e){let t=P("constellation-status"),r=P("retry-build");if(!r.hidden)fe({message:""});t.hidden=!1,r.hidden=!0,P("constellation-status-text").textContent="Loading your skills…",P("constellation").setAttribute("aria-busy","true");try{await px(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,ze("scope").value=_.input.scope,n}finally{P("constellation").setAttribute("aria-busy","false")}}Oe({id:"retry-build",action:()=>gr(_.input.scope)});Oe({id:"review",action:af});Oe({id:"describe",action:nf});Oe({id:"apply",action:async()=>{await cf(),await gr(_.input.scope)}});Oe({id:"undo",action:async()=>{await uf(),await gr(_.input.scope)}});P("new-skill").addEventListener("click",()=>Lo());P("custom-form").addEventListener("submit",(e)=>{e.preventDefault();try{ep(),hr()}catch(t){pt(t instanceof Error?t.message:"The skill could not be added.")}});oe("search").addEventListener("input",()=>{_.search=oe("search").value,hr()});ze("scope").addEventListener("change",()=>{if(_.dirty&&!window.confirm("Discard the draft and switch build scope?")){ze("scope").value=_.input.scope;return}let e=gt.parse(ze("scope").value);Pt(()=>gr(e)).catch(it)});for(let e of document.querySelectorAll(".close-dialog"))e.addEventListener("click",()=>e.closest("dialog")?.close());window.addEventListener("beforeunload",(e)=>{if(_.dirty)e.preventDefault()});var bf=gt.safeParse(new URLSearchParams(location.search).get("scope")??"global");lf();ef();df();Pt(()=>gr(bf.success?bf.data:"global")).catch(it);