const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/CodeViewer-rSBW2agS.js","assets/react-vendor-BVoutfaX.js","assets/xyflow-CYMCcsWN.js","assets/xyflow-BZV40eAE.css","assets/graph-layout-7tFr_anw.js","assets/elk-CXeXGyKz.js","assets/graphology-BgTy_cc3.js","assets/LearnPanel-5c2YOSlA.js","assets/markdown-DpllbSd9.js","assets/PathFinderModal-iyLG943e.js","assets/KeyboardShortcutsHelp-C08UrzhP.js","assets/RagAssistant-B-bW6zDi.js","assets/OnboardingOverlay-HYdAkhjv.js"])))=>i.map(i=>d[i]); var br=Object.defineProperty;var yr=(e,t,n)=>t in e?br(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var St=(e,t,n)=>yr(e,typeof t!="symbol"?t+"":t,n);import{R as Xe,a as v,j as a,b as wr}from"./react-vendor-BVoutfaX.js";import{H as fe,P as pe,R as Ht,u as vr,a as kr,b as Ut,i as Wt,B as Kt,c as Jt,C as Yt,M as Xt,e as Nr}from"./xyflow-CYMCcsWN.js";import{f as jr,a as _r,b as Cr,c as Sr,d as Ir,e as Tr,g as Er}from"./graph-layout-7tFr_anw.js";import{E as $r}from"./elk-CXeXGyKz.js";import{G as Lr,l as zr}from"./graphology-BgTy_cc3.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))o(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const i of s.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&o(i)}).observe(document,{childList:!0,subtree:!0});function n(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function o(r){if(r.ep)return;r.ep=!0;const s=n(r);fetch(r.href,s)}})();const Ar="modulepreload",Or=function(e){return"/"+e},dn={},xe=function(t,n,o){let r=Promise.resolve();if(n&&n.length>0){let i=function(l){return Promise.all(l.map(u=>Promise.resolve(u).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),d=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));r=i(n.map(l=>{if(l=Or(l),l in dn)return;dn[l]=!0;const u=l.endsWith(".css"),f=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${f}`))return;const h=document.createElement("link");if(h.rel=u?"stylesheet":Ar,u||(h.as="script"),h.crossOrigin="",h.href=l,d&&h.setAttribute("nonce",d),document.head.appendChild(h),u)return new Promise((g,m)=>{h.addEventListener("load",g),h.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${l}`)))})}))}function s(i){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=i,window.dispatchEvent(c),!c.defaultPrevented)throw i}return r.then(i=>{for(const c of i||[])c.status==="rejected"&&s(c.reason);return t().catch(s)})};function _(e,t,n){function o(c,d){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:d,constr:i,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,d);const l=i.prototype,u=Object.keys(l);for(let f=0;f{var d,l;return n!=null&&n.Parent&&c instanceof n.Parent?!0:(l=(d=c==null?void 0:c._zod)==null?void 0:d.traits)==null?void 0:l.has(e)}}),Object.defineProperty(i,"name",{value:e}),i}class Fe extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class no extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const oo={};function Ie(e){return oo}function ro(e){const t=Object.values(e).filter(o=>typeof o=="number");return Object.entries(e).filter(([o,r])=>t.indexOf(+o)===-1).map(([o,r])=>r)}function Lt(e,t){return typeof t=="bigint"?t.toString():t}function qt(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Qt(e){return e==null}function en(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Mr(e,t){const n=(e.toString().split(".")[1]||"").length,o=t.toString();let r=(o.split(".")[1]||"").length;if(r===0&&/\d?e-\d?/.test(o)){const d=o.match(/\d?e-(\d?)/);d!=null&&d[1]&&(r=Number.parseInt(d[1]))}const s=n>r?n:r,i=Number.parseInt(e.toFixed(s).replace(".","")),c=Number.parseInt(t.toFixed(s).replace(".",""));return i%c/10**s}const ln=Symbol("evaluating");function W(e,t,n){let o;Object.defineProperty(e,t,{get(){if(o!==ln)return o===void 0&&(o=ln,o=n()),o},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function Le(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function ke(...e){const t={};for(const n of e){const o=Object.getOwnPropertyDescriptors(n);Object.assign(t,o)}return Object.defineProperties({},t)}function un(e){return JSON.stringify(e)}function Fr(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const so="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function dt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Dr=qt(()=>{var e;if(typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)!=null&&e.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function Ue(e){if(dt(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(dt(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function ao(e){return Ue(e)?{...e}:Array.isArray(e)?[...e]:e}const Pr=new Set(["string","number","symbol"]);function wt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ne(e,t,n){const o=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(o._zod.parent=e),o}function O(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Rr(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Zr={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Br(e,t){const n=e._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=ke(e._zod.def,{get shape(){const i={};for(const c in t){if(!(c in n.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&(i[c]=n.shape[c])}return Le(this,"shape",i),i},checks:[]});return Ne(e,s)}function Vr(e,t){const n=e._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=ke(e._zod.def,{get shape(){const i={...e._zod.def.shape};for(const c in t){if(!(c in n.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&delete i[c]}return Le(this,"shape",i),i},checks:[]});return Ne(e,s)}function Gr(e,t){if(!Ue(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const s=e._zod.def.shape;for(const i in t)if(Object.getOwnPropertyDescriptor(s,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const r=ke(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return Le(this,"shape",s),s}});return Ne(e,r)}function Hr(e,t){if(!Ue(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=ke(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t};return Le(this,"shape",o),o}});return Ne(e,n)}function Ur(e,t){const n=ke(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t._zod.def.shape};return Le(this,"shape",o),o},get catchall(){return t._zod.def.catchall},checks:[]});return Ne(e,n)}function Wr(e,t,n){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const i=ke(t._zod.def,{get shape(){const c=t._zod.def.shape,d={...c};if(n)for(const l in n){if(!(l in c))throw new Error(`Unrecognized key: "${l}"`);n[l]&&(d[l]=e?new e({type:"optional",innerType:c[l]}):c[l])}else for(const l in c)d[l]=e?new e({type:"optional",innerType:c[l]}):c[l];return Le(this,"shape",d),d},checks:[]});return Ne(t,i)}function Kr(e,t,n){const o=ke(t._zod.def,{get shape(){const r=t._zod.def.shape,s={...r};if(n)for(const i in n){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(s[i]=new e({type:"nonoptional",innerType:r[i]}))}else for(const i in r)s[i]=new e({type:"nonoptional",innerType:r[i]});return Le(this,"shape",s),s}});return Ne(t,o)}function Me(e,t=0){var n;if(e.aborted===!0)return!0;for(let o=t;o{var o;return(o=n).path??(o.path=[]),n.path.unshift(e),n})}function qe(e){return typeof e=="string"?e:e==null?void 0:e.message}function Te(e,t,n){var r,s,i,c,d,l;const o={...e,path:e.path??[]};if(!e.message){const u=qe((i=(s=(r=e.inst)==null?void 0:r._zod.def)==null?void 0:s.error)==null?void 0:i.call(s,e))??qe((c=t==null?void 0:t.error)==null?void 0:c.call(t,e))??qe((d=n.customError)==null?void 0:d.call(n,e))??qe((l=n.localeError)==null?void 0:l.call(n,e))??"Invalid input";o.message=u}return delete o.inst,delete o.continue,t!=null&&t.reportInput||delete o.input,o}function nn(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function We(...e){const[t,n,o]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:o}:{...t}}const io=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Lt,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},co=_("$ZodError",io),lo=_("$ZodError",io,{Parent:Error});function Jr(e,t=n=>n.message){const n={},o=[];for(const r of e.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(t(r))):o.push(t(r));return{formErrors:o,fieldErrors:n}}function Yr(e,t=n=>n.message){const n={_errors:[]},o=r=>{for(const s of r.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(i=>o({issues:i}));else if(s.code==="invalid_key")o({issues:s.issues});else if(s.code==="invalid_element")o({issues:s.issues});else if(s.path.length===0)n._errors.push(t(s));else{let i=n,c=0;for(;c(t,n,o,r)=>{const s=o?Object.assign(o,{async:!1}):{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new Fe;if(i.issues.length){const c=new((r==null?void 0:r.Err)??e)(i.issues.map(d=>Te(d,s,Ie())));throw so(c,r==null?void 0:r.callee),c}return i.value},rn=e=>async(t,n,o,r)=>{const s=o?Object.assign(o,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){const c=new((r==null?void 0:r.Err)??e)(i.issues.map(d=>Te(d,s,Ie())));throw so(c,r==null?void 0:r.callee),c}return i.value},vt=e=>(t,n,o)=>{const r=o?{...o,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)throw new Fe;return s.issues.length?{success:!1,error:new(e??co)(s.issues.map(i=>Te(i,r,Ie())))}:{success:!0,data:s.value}},Xr=vt(lo),kt=e=>async(t,n,o)=>{const r=o?Object.assign(o,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},r);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>Te(i,r,Ie())))}:{success:!0,data:s.value}},qr=kt(lo),Qr=e=>(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return on(e)(t,n,r)},es=e=>(t,n,o)=>on(e)(t,n,o),ts=e=>async(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return rn(e)(t,n,r)},ns=e=>async(t,n,o)=>rn(e)(t,n,o),os=e=>(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return vt(e)(t,n,r)},rs=e=>(t,n,o)=>vt(e)(t,n,o),ss=e=>async(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return kt(e)(t,n,r)},as=e=>async(t,n,o)=>kt(e)(t,n,o),is=/^[cC][^\s-]{8,}$/,cs=/^[0-9a-z]+$/,ds=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,ls=/^[0-9a-vA-V]{20}$/,us=/^[A-Za-z0-9]{27}$/,fs=/^[a-zA-Z0-9_-]{21}$/,ps=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,hs=/^([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})$/,fn=e=>e?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})$`):/^([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)$/,ms=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,gs="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function xs(){return new RegExp(gs,"u")}const bs=/^(?:(?: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])$/,ys=/^(([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}|:))$/,ws=/^((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])$/,vs=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ks=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,uo=/^[A-Za-z0-9_-]*$/,Ns=/^\+[1-9]\d{6,14}$/,fo="(?:(?:\\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])))",js=new RegExp(`^${fo}$`);function po(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function _s(e){return new RegExp(`^${po(e)}$`)}function Cs(e){const t=po({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const o=`${t}(?:${n.join("|")})`;return new RegExp(`^${fo}T(?:${o})$`)}const Ss=e=>{const t=e?`[\\s\\S]{${(e==null?void 0:e.minimum)??0},${(e==null?void 0:e.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Is=/^-?\d+$/,Ts=/^-?\d+(?:\.\d+)?$/,Es=/^[^A-Z]*$/,$s=/^[^a-z]*$/,ce=_("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ho={number:"number",bigint:"bigint",object:"date"},mo=_("$ZodCheckLessThan",(e,t)=>{ce.init(e,t);const n=ho[typeof t.value];e._zod.onattach.push(o=>{const r=o._zod.bag,s=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value{(t.inclusive?o.value<=t.value:o.value{ce.init(e,t);const n=ho[typeof t.value];e._zod.onattach.push(o=>{const r=o._zod.bag,s=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value>=t.value:o.value>t.value)||o.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ls=_("$ZodCheckMultipleOf",(e,t)=>{ce.init(e,t),e._zod.onattach.push(n=>{var o;(o=n._zod.bag).multipleOf??(o.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):Mr(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),zs=_("$ZodCheckNumberFormat",(e,t)=>{var i;ce.init(e,t),t.format=t.format||"float64";const n=(i=t.format)==null?void 0:i.includes("int"),o=n?"int":"number",[r,s]=Zr[t.format];e._zod.onattach.push(c=>{const d=c._zod.bag;d.format=t.format,d.minimum=r,d.maximum=s,n&&(d.pattern=Is)}),e._zod.check=c=>{const d=c.value;if(n){if(!Number.isInteger(d)){c.issues.push({expected:o,format:t.format,code:"invalid_type",continue:!1,input:d,inst:e});return}if(!Number.isSafeInteger(d)){d>0?c.issues.push({input:d,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort}):c.issues.push({input:d,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort});return}}ds&&c.issues.push({origin:"number",input:d,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),As=_("$ZodCheckMaxLength",(e,t)=>{var n;ce.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!Qt(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum{const r=o.value;if(r.length<=t.maximum)return;const i=nn(r);o.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Os=_("$ZodCheckMinLength",(e,t)=>{var n;ce.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!Qt(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(o._zod.bag.minimum=t.minimum)}),e._zod.check=o=>{const r=o.value;if(r.length>=t.minimum)return;const i=nn(r);o.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Ms=_("$ZodCheckLengthEquals",(e,t)=>{var n;ce.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!Qt(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=o=>{const r=o.value,s=r.length;if(s===t.length)return;const i=nn(r),c=s>t.length;o.issues.push({origin:i,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),Nt=_("$ZodCheckStringFormat",(e,t)=>{var n,o;ce.init(e,t),e._zod.onattach.push(r=>{const s=r._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(o=e._zod).check??(o.check=()=>{})}),Fs=_("$ZodCheckRegex",(e,t)=>{Nt.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Ds=_("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Es),Nt.init(e,t)}),Ps=_("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=$s),Nt.init(e,t)}),Rs=_("$ZodCheckIncludes",(e,t)=>{ce.init(e,t);const n=wt(t.includes),o=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=o,e._zod.onattach.push(r=>{const s=r._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(o)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),Zs=_("$ZodCheckStartsWith",(e,t)=>{ce.init(e,t);const n=new RegExp(`^${wt(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(o=>{const r=o._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=o=>{o.value.startsWith(t.prefix)||o.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:o.value,inst:e,continue:!t.abort})}}),Bs=_("$ZodCheckEndsWith",(e,t)=>{ce.init(e,t);const n=new RegExp(`.*${wt(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(o=>{const r=o._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=o=>{o.value.endsWith(t.suffix)||o.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:o.value,inst:e,continue:!t.abort})}}),Vs=_("$ZodCheckOverwrite",(e,t)=>{ce.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Gs{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const o=t.split(` `).filter(i=>i),r=Math.min(...o.map(i=>i.length-i.trimStart().length)),s=o.map(i=>i.slice(r)).map(i=>" ".repeat(this.indent*2)+i);for(const i of s)this.content.push(i)}compile(){const t=Function,n=this==null?void 0:this.args,r=[...((this==null?void 0:this.content)??[""]).map(s=>` ${s}`)];return new t(...n,r.join(` `))}}const Hs={major:4,minor:3,patch:6},ee=_("$ZodType",(e,t)=>{var r;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Hs;const o=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&o.unshift(e);for(const s of o)for(const i of s._zod.onattach)i(e);if(o.length===0)(n=e._zod).deferred??(n.deferred=[]),(r=e._zod.deferred)==null||r.push(()=>{e._zod.run=e._zod.parse});else{const s=(c,d,l)=>{let u=Me(c),f;for(const h of d){if(h._zod.def.when){if(!h._zod.def.when(c))continue}else if(u)continue;const g=c.issues.length,m=h._zod.check(c);if(m instanceof Promise&&(l==null?void 0:l.async)===!1)throw new Fe;if(f||m instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await m,c.issues.length!==g&&(u||(u=Me(c,g)))});else{if(c.issues.length===g)continue;u||(u=Me(c,g))}}return f?f.then(()=>c):c},i=(c,d,l)=>{if(Me(c))return c.aborted=!0,c;const u=s(d,o,l);if(u instanceof Promise){if(l.async===!1)throw new Fe;return u.then(f=>e._zod.parse(f,l))}return e._zod.parse(u,l)};e._zod.run=(c,d)=>{if(d.skipChecks)return e._zod.parse(c,d);if(d.direction==="backward"){const u=e._zod.parse({value:c.value,issues:[]},{...d,skipChecks:!0});return u instanceof Promise?u.then(f=>i(f,c,d)):i(u,c,d)}const l=e._zod.parse(c,d);if(l instanceof Promise){if(d.async===!1)throw new Fe;return l.then(u=>s(u,o,d))}return s(l,o,d)}}W(e,"~standard",()=>({validate:s=>{var i;try{const c=Xr(e,s);return c.success?{value:c.data}:{issues:(i=c.error)==null?void 0:i.issues}}catch{return qr(e,s).then(d=>{var l;return d.success?{value:d.data}:{issues:(l=d.error)==null?void 0:l.issues}})}},vendor:"zod",version:1}))}),sn=_("$ZodString",(e,t)=>{var n;ee.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??Ss(e._zod.bag),e._zod.parse=(o,r)=>{if(t.coerce)try{o.value=String(o.value)}catch{}return typeof o.value=="string"||o.issues.push({expected:"string",code:"invalid_type",input:o.value,inst:e}),o}}),X=_("$ZodStringFormat",(e,t)=>{Nt.init(e,t),sn.init(e,t)}),Us=_("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=hs),X.init(e,t)}),Ws=_("$ZodUUID",(e,t)=>{if(t.version){const o={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(o===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=fn(o))}else t.pattern??(t.pattern=fn());X.init(e,t)}),Ks=_("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=ms),X.init(e,t)}),Js=_("$ZodURL",(e,t)=>{X.init(e,t),e._zod.check=n=>{try{const o=n.value.trim(),r=new URL(o);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(r.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=r.href:n.value=o;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Ys=_("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=xs()),X.init(e,t)}),Xs=_("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=fs),X.init(e,t)}),qs=_("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=is),X.init(e,t)}),Qs=_("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=cs),X.init(e,t)}),ea=_("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ds),X.init(e,t)}),ta=_("$ZodXID",(e,t)=>{t.pattern??(t.pattern=ls),X.init(e,t)}),na=_("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=us),X.init(e,t)}),oa=_("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Cs(t)),X.init(e,t)}),ra=_("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=js),X.init(e,t)}),sa=_("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=_s(t)),X.init(e,t)}),aa=_("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ps),X.init(e,t)}),ia=_("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=bs),X.init(e,t),e._zod.bag.format="ipv4"}),ca=_("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ys),X.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),da=_("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ws),X.init(e,t)}),la=_("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=vs),X.init(e,t),e._zod.check=n=>{const o=n.value.split("/");try{if(o.length!==2)throw new Error;const[r,s]=o;if(!s)throw new Error;const i=Number(s);if(`${i}`!==s)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${r}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function xo(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const ua=_("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=ks),X.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{xo(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function fa(e){if(!uo.test(e))return!1;const t=e.replace(/[-_]/g,o=>o==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return xo(n)}const pa=_("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=uo),X.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{fa(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),ha=_("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Ns),X.init(e,t)});function ma(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[o]=n;if(!o)return!1;const r=JSON.parse(atob(o));return!("typ"in r&&(r==null?void 0:r.typ)!=="JWT"||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}}const ga=_("$ZodJWT",(e,t)=>{X.init(e,t),e._zod.check=n=>{ma(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),bo=_("$ZodNumber",(e,t)=>{ee.init(e,t),e._zod.pattern=e._zod.bag.pattern??Ts,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const r=n.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;const s=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...s?{received:s}:{}}),n}}),xa=_("$ZodNumberFormat",(e,t)=>{zs.init(e,t),bo.init(e,t)}),ba=_("$ZodUnknown",(e,t)=>{ee.init(e,t),e._zod.parse=n=>n}),ya=_("$ZodNever",(e,t)=>{ee.init(e,t),e._zod.parse=(n,o)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function pn(e,t,n){e.issues.length&&t.issues.push(...tn(n,e.issues)),t.value[n]=e.value}const wa=_("$ZodArray",(e,t)=>{ee.init(e,t),e._zod.parse=(n,o)=>{const r=n.value;if(!Array.isArray(r))return n.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),n;n.value=Array(r.length);const s=[];for(let i=0;ipn(l,n,i))):pn(d,n,i)}return s.length?Promise.all(s).then(()=>n):n}});function lt(e,t,n,o,r){if(e.issues.length){if(r&&!(n in o))return;t.issues.push(...tn(n,e.issues))}e.value===void 0?n in o&&(t.value[n]=void 0):t.value[n]=e.value}function yo(e){var o,r,s,i;const t=Object.keys(e.shape);for(const c of t)if(!((i=(s=(r=(o=e.shape)==null?void 0:o[c])==null?void 0:r._zod)==null?void 0:s.traits)!=null&&i.has("$ZodType")))throw new Error(`Invalid element at key "${c}": expected a Zod schema`);const n=Rr(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function wo(e,t,n,o,r,s){const i=[],c=r.keySet,d=r.catchall._zod,l=d.def.type,u=d.optout==="optional";for(const f in t){if(c.has(f))continue;if(l==="never"){i.push(f);continue}const h=d.run({value:t[f],issues:[]},o);h instanceof Promise?e.push(h.then(g=>lt(g,n,f,t,u))):lt(h,n,f,t,u)}return i.length&&n.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:s}),e.length?Promise.all(e).then(()=>n):n}const va=_("$ZodObject",(e,t)=>{ee.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const c=t.shape;Object.defineProperty(t,"shape",{get:()=>{const d={...c};return Object.defineProperty(t,"shape",{value:d}),d}})}const o=qt(()=>yo(t));W(e._zod,"propValues",()=>{const c=t.shape,d={};for(const l in c){const u=c[l]._zod;if(u.values){d[l]??(d[l]=new Set);for(const f of u.values)d[l].add(f)}}return d});const r=dt,s=t.catchall;let i;e._zod.parse=(c,d)=>{i??(i=o.value);const l=c.value;if(!r(l))return c.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),c;c.value={};const u=[],f=i.shape;for(const h of i.keys){const g=f[h],m=g._zod.optout==="optional",p=g._zod.run({value:l[h],issues:[]},d);p instanceof Promise?u.push(p.then(N=>lt(N,c,h,l,m))):lt(p,c,h,l,m)}return s?wo(u,l,c,d,o.value,e):u.length?Promise.all(u).then(()=>c):c}}),ka=_("$ZodObjectJIT",(e,t)=>{va.init(e,t);const n=e._zod.parse,o=qt(()=>yo(t)),r=h=>{var k;const g=new Gs(["shape","payload","ctx"]),m=o.value,p=T=>{const j=un(T);return`shape[${j}]._zod.run({ value: input[${j}], issues: [] }, ctx)`};g.write("const input = payload.value;");const N=Object.create(null);let y=0;for(const T of m.keys)N[T]=`key_${y++}`;g.write("const newResult = {};");for(const T of m.keys){const j=N[T],C=un(T),I=h[T],E=((k=I==null?void 0:I._zod)==null?void 0:k.optout)==="optional";g.write(`const ${j} = ${p(T)};`),E?g.write(` if (${j}.issues.length) { if (${C} in input) { payload.issues = payload.issues.concat(${j}.issues.map(iss => ({ ...iss, path: iss.path ? [${C}, ...iss.path] : [${C}] }))); } } if (${j}.value === undefined) { if (${C} in input) { newResult[${C}] = undefined; } } else { newResult[${C}] = ${j}.value; } `):g.write(` if (${j}.issues.length) { payload.issues = payload.issues.concat(${j}.issues.map(iss => ({ ...iss, path: iss.path ? [${C}, ...iss.path] : [${C}] }))); } if (${j}.value === undefined) { if (${C} in input) { newResult[${C}] = undefined; } } else { newResult[${C}] = ${j}.value; } `)}g.write("payload.value = newResult;"),g.write("return payload;");const x=g.compile();return(T,j)=>x(h,T,j)};let s;const i=dt,c=!oo.jitless,l=c&&Dr.value,u=t.catchall;let f;e._zod.parse=(h,g)=>{f??(f=o.value);const m=h.value;return i(m)?c&&l&&(g==null?void 0:g.async)===!1&&g.jitless!==!0?(s||(s=r(t.shape)),h=s(h,g),u?wo([],m,h,g,f,e):h):n(h,g):(h.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),h)}});function hn(e,t,n,o){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;const r=e.filter(s=>!Me(s));return r.length===1?(t.value=r[0].value,r[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(s=>s.issues.map(i=>Te(i,o,Ie())))}),t)}const Na=_("$ZodUnion",(e,t)=>{ee.init(e,t),W(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),W(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),W(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),W(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(s=>s._zod.pattern);return new RegExp(`^(${r.map(s=>en(s.source)).join("|")})$`)}});const n=t.options.length===1,o=t.options[0]._zod.run;e._zod.parse=(r,s)=>{if(n)return o(r,s);let i=!1;const c=[];for(const d of t.options){const l=d._zod.run({value:r.value,issues:[]},s);if(l instanceof Promise)c.push(l),i=!0;else{if(l.issues.length===0)return l;c.push(l)}}return i?Promise.all(c).then(d=>hn(d,r,e,s)):hn(c,r,e,s)}}),ja=_("$ZodIntersection",(e,t)=>{ee.init(e,t),e._zod.parse=(n,o)=>{const r=n.value,s=t.left._zod.run({value:r,issues:[]},o),i=t.right._zod.run({value:r,issues:[]},o);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([d,l])=>mn(n,d,l)):mn(n,s,i)}});function zt(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(Ue(e)&&Ue(t)){const n=Object.keys(t),o=Object.keys(e).filter(s=>n.indexOf(s)!==-1),r={...e,...t};for(const s of o){const i=zt(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};r[s]=i.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let o=0;oc.l&&c.r).map(([c])=>c);if(s.length&&r&&e.issues.push({...r,keys:s}),Me(e))return e;const i=zt(t.value,n.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}const _a=_("$ZodTuple",(e,t)=>{ee.init(e,t);const n=t.items;e._zod.parse=(o,r)=>{const s=o.value;if(!Array.isArray(s))return o.issues.push({input:s,inst:e,expected:"tuple",code:"invalid_type"}),o;o.value=[];const i=[],c=[...n].reverse().findIndex(u=>u._zod.optin!=="optional"),d=c===-1?0:n.length-c;if(!t.rest){const u=s.length>n.length,f=s.length=s.length&&l>=d)continue;const f=u._zod.run({value:s[l],issues:[]},r);f instanceof Promise?i.push(f.then(h=>Qe(h,o,l))):Qe(f,o,l)}if(t.rest){const u=s.slice(n.length);for(const f of u){l++;const h=t.rest._zod.run({value:f,issues:[]},r);h instanceof Promise?i.push(h.then(g=>Qe(g,o,l))):Qe(h,o,l)}}return i.length?Promise.all(i).then(()=>o):o}});function Qe(e,t,n){e.issues.length&&t.issues.push(...tn(n,e.issues)),t.value[n]=e.value}const Ca=_("$ZodEnum",(e,t)=>{ee.init(e,t);const n=ro(t.entries),o=new Set(n);e._zod.values=o,e._zod.pattern=new RegExp(`^(${n.filter(r=>Pr.has(typeof r)).map(r=>typeof r=="string"?wt(r):r.toString()).join("|")})$`),e._zod.parse=(r,s)=>{const i=r.value;return o.has(i)||r.issues.push({code:"invalid_value",values:n,input:i,inst:e}),r}}),Sa=_("$ZodTransform",(e,t)=>{ee.init(e,t),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new no(e.constructor.name);const r=t.transform(n.value,n);if(o.async)return(r instanceof Promise?r:Promise.resolve(r)).then(i=>(n.value=i,n));if(r instanceof Promise)throw new Fe;return n.value=r,n}});function gn(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const vo=_("$ZodOptional",(e,t)=>{ee.init(e,t),e._zod.optin="optional",e._zod.optout="optional",W(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),W(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${en(n.source)})?$`):void 0}),e._zod.parse=(n,o)=>{if(t.innerType._zod.optin==="optional"){const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(s=>gn(s,n.value)):gn(r,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,o)}}),Ia=_("$ZodExactOptional",(e,t)=>{vo.init(e,t),W(e._zod,"values",()=>t.innerType._zod.values),W(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,o)=>t.innerType._zod.run(n,o)}),Ta=_("$ZodNullable",(e,t)=>{ee.init(e,t),W(e._zod,"optin",()=>t.innerType._zod.optin),W(e._zod,"optout",()=>t.innerType._zod.optout),W(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${en(n.source)}|null)$`):void 0}),W(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,o)=>n.value===null?n:t.innerType._zod.run(n,o)}),Ea=_("$ZodDefault",(e,t)=>{ee.init(e,t),e._zod.optin="optional",W(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);if(n.value===void 0)return n.value=t.defaultValue,n;const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(s=>xn(s,t)):xn(r,t)}});function xn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const $a=_("$ZodPrefault",(e,t)=>{ee.init(e,t),e._zod.optin="optional",W(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>(o.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,o))}),La=_("$ZodNonOptional",(e,t)=>{ee.init(e,t),W(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(o=>o!==void 0)):void 0}),e._zod.parse=(n,o)=>{const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(s=>bn(s,e)):bn(r,e)}});function bn(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const za=_("$ZodCatch",(e,t)=>{ee.init(e,t),W(e._zod,"optin",()=>t.innerType._zod.optin),W(e._zod,"optout",()=>t.innerType._zod.optout),W(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(s=>(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(i=>Te(i,o,Ie()))},input:n.value}),n.issues=[]),n)):(n.value=r.value,r.issues.length&&(n.value=t.catchValue({...n,error:{issues:r.issues.map(s=>Te(s,o,Ie()))},input:n.value}),n.issues=[]),n)}}),Aa=_("$ZodPipe",(e,t)=>{ee.init(e,t),W(e._zod,"values",()=>t.in._zod.values),W(e._zod,"optin",()=>t.in._zod.optin),W(e._zod,"optout",()=>t.out._zod.optout),W(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,o)=>{if(o.direction==="backward"){const s=t.out._zod.run(n,o);return s instanceof Promise?s.then(i=>et(i,t.in,o)):et(s,t.in,o)}const r=t.in._zod.run(n,o);return r instanceof Promise?r.then(s=>et(s,t.out,o)):et(r,t.out,o)}});function et(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Oa=_("$ZodReadonly",(e,t)=>{ee.init(e,t),W(e._zod,"propValues",()=>t.innerType._zod.propValues),W(e._zod,"values",()=>t.innerType._zod.values),W(e._zod,"optin",()=>{var n,o;return(o=(n=t.innerType)==null?void 0:n._zod)==null?void 0:o.optin}),W(e._zod,"optout",()=>{var n,o;return(o=(n=t.innerType)==null?void 0:n._zod)==null?void 0:o.optout}),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(yn):yn(r)}});function yn(e){return e.value=Object.freeze(e.value),e}const Ma=_("$ZodCustom",(e,t)=>{ce.init(e,t),ee.init(e,t),e._zod.parse=(n,o)=>n,e._zod.check=n=>{const o=n.value,r=t.fn(o);if(r instanceof Promise)return r.then(s=>wn(s,n,o,e));wn(r,n,o,e)}});function wn(e,t,n,o){if(!e){const r={code:"custom",input:n,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};o._zod.def.params&&(r.params=o._zod.def.params),t.issues.push(We(r))}}var vn;class Fa{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const o=n[0];return this._map.set(t,o),o&&typeof o=="object"&&"id"in o&&this._idmap.set(o.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const o={...this.get(n)??{}};delete o.id;const r={...o,...this._map.get(t)};return Object.keys(r).length?r:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function Da(){return new Fa}(vn=globalThis).__zod_globalRegistry??(vn.__zod_globalRegistry=Da());const He=globalThis.__zod_globalRegistry;function Pa(e,t){return new e({type:"string",...O(t)})}function Ra(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...O(t)})}function kn(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...O(t)})}function Za(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...O(t)})}function Ba(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...O(t)})}function Va(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...O(t)})}function Ga(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...O(t)})}function Ha(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...O(t)})}function Ua(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...O(t)})}function Wa(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...O(t)})}function Ka(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...O(t)})}function Ja(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...O(t)})}function Ya(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...O(t)})}function Xa(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...O(t)})}function qa(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...O(t)})}function Qa(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...O(t)})}function ei(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...O(t)})}function ti(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...O(t)})}function ni(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...O(t)})}function oi(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...O(t)})}function ri(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...O(t)})}function si(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...O(t)})}function ai(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...O(t)})}function ii(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...O(t)})}function ci(e,t){return new e({type:"string",format:"date",check:"string_format",...O(t)})}function di(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...O(t)})}function li(e,t){return new e({type:"string",format:"duration",check:"string_format",...O(t)})}function ui(e,t){return new e({type:"number",checks:[],...O(t)})}function fi(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...O(t)})}function pi(e){return new e({type:"unknown"})}function hi(e,t){return new e({type:"never",...O(t)})}function Nn(e,t){return new mo({check:"less_than",...O(t),value:e,inclusive:!1})}function It(e,t){return new mo({check:"less_than",...O(t),value:e,inclusive:!0})}function jn(e,t){return new go({check:"greater_than",...O(t),value:e,inclusive:!1})}function Tt(e,t){return new go({check:"greater_than",...O(t),value:e,inclusive:!0})}function _n(e,t){return new Ls({check:"multiple_of",...O(t),value:e})}function ko(e,t){return new As({check:"max_length",...O(t),maximum:e})}function ut(e,t){return new Os({check:"min_length",...O(t),minimum:e})}function No(e,t){return new Ms({check:"length_equals",...O(t),length:e})}function mi(e,t){return new Fs({check:"string_format",format:"regex",...O(t),pattern:e})}function gi(e){return new Ds({check:"string_format",format:"lowercase",...O(e)})}function xi(e){return new Ps({check:"string_format",format:"uppercase",...O(e)})}function bi(e,t){return new Rs({check:"string_format",format:"includes",...O(t),includes:e})}function yi(e,t){return new Zs({check:"string_format",format:"starts_with",...O(t),prefix:e})}function wi(e,t){return new Bs({check:"string_format",format:"ends_with",...O(t),suffix:e})}function De(e){return new Vs({check:"overwrite",tx:e})}function vi(e){return De(t=>t.normalize(e))}function ki(){return De(e=>e.trim())}function Ni(){return De(e=>e.toLowerCase())}function ji(){return De(e=>e.toUpperCase())}function _i(){return De(e=>Fr(e))}function Ci(e,t,n){return new e({type:"array",element:t,...O(n)})}function Si(e,t,n){return new e({type:"custom",check:"custom",fn:t,...O(n)})}function Ii(e){const t=Ti(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(We(o,n.value,t._zod.def));else{const r=o;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=n.value),r.inst??(r.inst=t),r.continue??(r.continue=!t._zod.def.abort),n.issues.push(We(r))}},e(n.value,n)));return t}function Ti(e,t){const n=new ce({check:"custom",...O(t)});return n._zod.check=e,n}function jo(e){let t=(e==null?void 0:e.target)??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:(e==null?void 0:e.metadata)??He,target:t,unrepresentable:(e==null?void 0:e.unrepresentable)??"throw",override:(e==null?void 0:e.override)??(()=>{}),io:(e==null?void 0:e.io)??"output",counter:0,seen:new Map,cycles:(e==null?void 0:e.cycles)??"ref",reused:(e==null?void 0:e.reused)??"inline",external:(e==null?void 0:e.external)??void 0}}function oe(e,t,n={path:[],schemaPath:[]}){var u,f;var o;const r=e._zod.def,s=t.seen.get(e);if(s)return s.count++,n.schemaPath.includes(e)&&(s.cycle=n.path),s.schema;const i={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,i);const c=(f=(u=e._zod).toJSONSchema)==null?void 0:f.call(u);if(c)i.schema=c;else{const h={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,h);else{const m=i.schema,p=t.processors[r.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);p(e,t,m,h)}const g=e._zod.parent;g&&(i.ref||(i.ref=g),oe(g,t,h),t.seen.get(g).isParent=!0)}const d=t.metadataRegistry.get(e);return d&&Object.assign(i.schema,d),t.io==="input"&&ae(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&i.schema._prefault&&((o=i.schema).default??(o.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function _o(e,t){var i,c,d,l;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=new Map;for(const u of e.seen.entries()){const f=(i=e.metadataRegistry.get(u[0]))==null?void 0:i.id;if(f){const h=o.get(f);if(h&&h!==u[0])throw new Error(`Duplicate schema id "${f}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(f,u[0])}}const r=u=>{var p;const f=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const N=(p=e.external.registry.get(u[0]))==null?void 0:p.id,y=e.external.uri??(k=>k);if(N)return{ref:y(N)};const x=u[1].defId??u[1].schema.id??`schema${e.counter++}`;return u[1].defId=x,{defId:x,ref:`${y("__shared")}#/${f}/${x}`}}if(u[1]===n)return{ref:"#"};const g=`#/${f}/`,m=u[1].schema.id??`__schema${e.counter++}`;return{defId:m,ref:g+m}},s=u=>{if(u[1].schema.$ref)return;const f=u[1],{ref:h,defId:g}=r(u);f.def={...f.schema},g&&(f.defId=g);const m=f.schema;for(const p in m)delete m[p];m.$ref=h};if(e.cycles==="throw")for(const u of e.seen.entries()){const f=u[1];if(f.cycle)throw new Error(`Cycle detected: #/${(c=f.cycle)==null?void 0:c.join("/")}/ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const u of e.seen.entries()){const f=u[1];if(t===u[0]){s(u);continue}if(e.external){const g=(d=e.external.registry.get(u[0]))==null?void 0:d.id;if(t!==u[0]&&g){s(u);continue}}if((l=e.metadataRegistry.get(u[0]))==null?void 0:l.id){s(u);continue}if(f.cycle){s(u);continue}if(f.count>1&&e.reused==="ref"){s(u);continue}}}function Co(e,t){var i,c,d;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=l=>{const u=e.seen.get(l);if(u.ref===null)return;const f=u.def??u.schema,h={...f},g=u.ref;if(u.ref=null,g){o(g);const p=e.seen.get(g),N=p.schema;if(N.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(f.allOf=f.allOf??[],f.allOf.push(N)):Object.assign(f,N),Object.assign(f,h),l._zod.parent===g)for(const x in f)x==="$ref"||x==="allOf"||x in h||delete f[x];if(N.$ref&&p.def)for(const x in f)x==="$ref"||x==="allOf"||x in p.def&&JSON.stringify(f[x])===JSON.stringify(p.def[x])&&delete f[x]}const m=l._zod.parent;if(m&&m!==g){o(m);const p=e.seen.get(m);if(p!=null&&p.schema.$ref&&(f.$ref=p.schema.$ref,p.def))for(const N in f)N==="$ref"||N==="allOf"||N in p.def&&JSON.stringify(f[N])===JSON.stringify(p.def[N])&&delete f[N]}e.override({zodSchema:l,jsonSchema:f,path:u.path??[]})};for(const l of[...e.seen.entries()].reverse())o(l[0]);const r={};if(e.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":e.target,(i=e.external)!=null&&i.uri){const l=(c=e.external.registry.get(t))==null?void 0:c.id;if(!l)throw new Error("Schema is missing an `id` property");r.$id=e.external.uri(l)}Object.assign(r,n.def??n.schema);const s=((d=e.external)==null?void 0:d.defs)??{};for(const l of e.seen.entries()){const u=l[1];u.def&&u.defId&&(s[u.defId]=u.def)}e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?r.$defs=s:r.definitions=s);try{const l=JSON.parse(JSON.stringify(r));return Object.defineProperty(l,"~standard",{value:{...t["~standard"],jsonSchema:{input:ft(t,"input",e.processors),output:ft(t,"output",e.processors)}},enumerable:!1,writable:!1}),l}catch{throw new Error("Error converting schema to JSON.")}}function ae(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return ae(o.element,n);if(o.type==="set")return ae(o.valueType,n);if(o.type==="lazy")return ae(o.getter(),n);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault")return ae(o.innerType,n);if(o.type==="intersection")return ae(o.left,n)||ae(o.right,n);if(o.type==="record"||o.type==="map")return ae(o.keyType,n)||ae(o.valueType,n);if(o.type==="pipe")return ae(o.in,n)||ae(o.out,n);if(o.type==="object"){for(const r in o.shape)if(ae(o.shape[r],n))return!0;return!1}if(o.type==="union"){for(const r of o.options)if(ae(r,n))return!0;return!1}if(o.type==="tuple"){for(const r of o.items)if(ae(r,n))return!0;return!!(o.rest&&ae(o.rest,n))}return!1}const Ei=(e,t={})=>n=>{const o=jo({...n,processors:t});return oe(e,o),_o(o,e),Co(o,e)},ft=(e,t,n={})=>o=>{const{libraryOptions:r,target:s}=o??{},i=jo({...r??{},target:s,io:t,processors:n});return oe(e,i),_o(i,e),Co(i,e)},$i={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Li=(e,t,n,o)=>{const r=n;r.type="string";const{minimum:s,maximum:i,format:c,patterns:d,contentEncoding:l}=e._zod.bag;if(typeof s=="number"&&(r.minLength=s),typeof i=="number"&&(r.maxLength=i),c&&(r.format=$i[c]??c,r.format===""&&delete r.format,c==="time"&&delete r.format),l&&(r.contentEncoding=l),d&&d.size>0){const u=[...d];u.length===1?r.pattern=u[0].source:u.length>1&&(r.allOf=[...u.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},zi=(e,t,n,o)=>{const r=n,{minimum:s,maximum:i,format:c,multipleOf:d,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof c=="string"&&c.includes("int")?r.type="integer":r.type="number",typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(r.minimum=u,r.exclusiveMinimum=!0):r.exclusiveMinimum=u),typeof s=="number"&&(r.minimum=s,typeof u=="number"&&t.target!=="draft-04"&&(u>=s?delete r.minimum:delete r.exclusiveMinimum)),typeof l=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(r.maximum=l,r.exclusiveMaximum=!0):r.exclusiveMaximum=l),typeof i=="number"&&(r.maximum=i,typeof l=="number"&&t.target!=="draft-04"&&(l<=i?delete r.maximum:delete r.exclusiveMaximum)),typeof d=="number"&&(r.multipleOf=d)},Ai=(e,t,n,o)=>{n.not={}},Oi=(e,t,n,o)=>{},Mi=(e,t,n,o)=>{const r=e._zod.def,s=ro(r.entries);s.every(i=>typeof i=="number")&&(n.type="number"),s.every(i=>typeof i=="string")&&(n.type="string"),n.enum=s},Fi=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Di=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Pi=(e,t,n,o)=>{const r=n,s=e._zod.def,{minimum:i,maximum:c}=e._zod.bag;typeof i=="number"&&(r.minItems=i),typeof c=="number"&&(r.maxItems=c),r.type="array",r.items=oe(s.element,t,{...o,path:[...o.path,"items"]})},Ri=(e,t,n,o)=>{var l;const r=n,s=e._zod.def;r.type="object",r.properties={};const i=s.shape;for(const u in i)r.properties[u]=oe(i[u],t,{...o,path:[...o.path,"properties",u]});const c=new Set(Object.keys(i)),d=new Set([...c].filter(u=>{const f=s.shape[u]._zod;return t.io==="input"?f.optin===void 0:f.optout===void 0}));d.size>0&&(r.required=Array.from(d)),((l=s.catchall)==null?void 0:l._zod.def.type)==="never"?r.additionalProperties=!1:s.catchall?s.catchall&&(r.additionalProperties=oe(s.catchall,t,{...o,path:[...o.path,"additionalProperties"]})):t.io==="output"&&(r.additionalProperties=!1)},Zi=(e,t,n,o)=>{const r=e._zod.def,s=r.inclusive===!1,i=r.options.map((c,d)=>oe(c,t,{...o,path:[...o.path,s?"oneOf":"anyOf",d]}));s?n.oneOf=i:n.anyOf=i},Bi=(e,t,n,o)=>{const r=e._zod.def,s=oe(r.left,t,{...o,path:[...o.path,"allOf",0]}),i=oe(r.right,t,{...o,path:[...o.path,"allOf",1]}),c=l=>"allOf"in l&&Object.keys(l).length===1,d=[...c(s)?s.allOf:[s],...c(i)?i.allOf:[i]];n.allOf=d},Vi=(e,t,n,o)=>{const r=n,s=e._zod.def;r.type="array";const i=t.target==="draft-2020-12"?"prefixItems":"items",c=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",d=s.items.map((h,g)=>oe(h,t,{...o,path:[...o.path,i,g]})),l=s.rest?oe(s.rest,t,{...o,path:[...o.path,c,...t.target==="openapi-3.0"?[s.items.length]:[]]}):null;t.target==="draft-2020-12"?(r.prefixItems=d,l&&(r.items=l)):t.target==="openapi-3.0"?(r.items={anyOf:d},l&&r.items.anyOf.push(l),r.minItems=d.length,l||(r.maxItems=d.length)):(r.items=d,l&&(r.additionalItems=l));const{minimum:u,maximum:f}=e._zod.bag;typeof u=="number"&&(r.minItems=u),typeof f=="number"&&(r.maxItems=f)},Gi=(e,t,n,o)=>{const r=e._zod.def,s=oe(r.innerType,t,o),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=r.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},Hi=(e,t,n,o)=>{const r=e._zod.def;oe(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType},Ui=(e,t,n,o)=>{const r=e._zod.def;oe(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType,n.default=JSON.parse(JSON.stringify(r.defaultValue))},Wi=(e,t,n,o)=>{const r=e._zod.def;oe(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(r.defaultValue)))},Ki=(e,t,n,o)=>{const r=e._zod.def;oe(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType;let i;try{i=r.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=i},Ji=(e,t,n,o)=>{const r=e._zod.def,s=t.io==="input"?r.in._zod.def.type==="transform"?r.out:r.in:r.out;oe(s,t,o);const i=t.seen.get(e);i.ref=s},Yi=(e,t,n,o)=>{const r=e._zod.def;oe(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType,n.readOnly=!0},So=(e,t,n,o)=>{const r=e._zod.def;oe(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType},Xi=_("ZodISODateTime",(e,t)=>{oa.init(e,t),q.init(e,t)});function qi(e){return ii(Xi,e)}const Qi=_("ZodISODate",(e,t)=>{ra.init(e,t),q.init(e,t)});function ec(e){return ci(Qi,e)}const tc=_("ZodISOTime",(e,t)=>{sa.init(e,t),q.init(e,t)});function nc(e){return di(tc,e)}const oc=_("ZodISODuration",(e,t)=>{aa.init(e,t),q.init(e,t)});function rc(e){return li(oc,e)}const sc=(e,t)=>{co.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Yr(e,n)},flatten:{value:n=>Jr(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Lt,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Lt,2)}},isEmpty:{get(){return e.issues.length===0}}})},he=_("ZodError",sc,{Parent:Error}),ac=on(he),ic=rn(he),cc=vt(he),dc=kt(he),lc=Qr(he),uc=es(he),fc=ts(he),pc=ns(he),hc=os(he),mc=rs(he),gc=ss(he),xc=as(he),ne=_("ZodType",(e,t)=>(ee.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:ft(e,"input"),output:ft(e,"output")}}),e.toJSONSchema=Ei(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(ke(t,{checks:[...t.checks??[],...n.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0}),e.with=e.check,e.clone=(n,o)=>Ne(e,n,o),e.brand=()=>e,e.register=((n,o)=>(n.add(e,o),e)),e.parse=(n,o)=>ac(e,n,o,{callee:e.parse}),e.safeParse=(n,o)=>cc(e,n,o),e.parseAsync=async(n,o)=>ic(e,n,o,{callee:e.parseAsync}),e.safeParseAsync=async(n,o)=>dc(e,n,o),e.spa=e.safeParseAsync,e.encode=(n,o)=>lc(e,n,o),e.decode=(n,o)=>uc(e,n,o),e.encodeAsync=async(n,o)=>fc(e,n,o),e.decodeAsync=async(n,o)=>pc(e,n,o),e.safeEncode=(n,o)=>hc(e,n,o),e.safeDecode=(n,o)=>mc(e,n,o),e.safeEncodeAsync=async(n,o)=>gc(e,n,o),e.safeDecodeAsync=async(n,o)=>xc(e,n,o),e.refine=(n,o)=>e.check(ld(n,o)),e.superRefine=n=>e.check(ud(n)),e.overwrite=n=>e.check(De(n)),e.optional=()=>Tn(e),e.exactOptional=()=>Xc(e),e.nullable=()=>En(e),e.nullish=()=>Tn(En(e)),e.nonoptional=n=>od(e,n),e.array=()=>ie(e),e.or=n=>Vc([e,n]),e.and=n=>Hc(e,n),e.transform=n=>$n(e,Jc(n)),e.default=n=>ed(e,n),e.prefault=n=>nd(e,n),e.catch=n=>sd(e,n),e.pipe=n=>$n(e,n),e.readonly=()=>cd(e),e.describe=n=>{const o=e.clone();return He.add(o,{description:n}),o},Object.defineProperty(e,"description",{get(){var n;return(n=He.get(e))==null?void 0:n.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return He.get(e);const o=e.clone();return He.add(o,n[0]),o},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),Io=_("_ZodString",(e,t)=>{sn.init(e,t),ne.init(e,t),e._zod.processJSONSchema=(o,r,s)=>Li(e,o,r);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...o)=>e.check(mi(...o)),e.includes=(...o)=>e.check(bi(...o)),e.startsWith=(...o)=>e.check(yi(...o)),e.endsWith=(...o)=>e.check(wi(...o)),e.min=(...o)=>e.check(ut(...o)),e.max=(...o)=>e.check(ko(...o)),e.length=(...o)=>e.check(No(...o)),e.nonempty=(...o)=>e.check(ut(1,...o)),e.lowercase=o=>e.check(gi(o)),e.uppercase=o=>e.check(xi(o)),e.trim=()=>e.check(ki()),e.normalize=(...o)=>e.check(vi(...o)),e.toLowerCase=()=>e.check(Ni()),e.toUpperCase=()=>e.check(ji()),e.slugify=()=>e.check(_i())}),bc=_("ZodString",(e,t)=>{sn.init(e,t),Io.init(e,t),e.email=n=>e.check(Ra(yc,n)),e.url=n=>e.check(Ha(wc,n)),e.jwt=n=>e.check(ai(Oc,n)),e.emoji=n=>e.check(Ua(vc,n)),e.guid=n=>e.check(kn(Cn,n)),e.uuid=n=>e.check(Za(tt,n)),e.uuidv4=n=>e.check(Ba(tt,n)),e.uuidv6=n=>e.check(Va(tt,n)),e.uuidv7=n=>e.check(Ga(tt,n)),e.nanoid=n=>e.check(Wa(kc,n)),e.guid=n=>e.check(kn(Cn,n)),e.cuid=n=>e.check(Ka(Nc,n)),e.cuid2=n=>e.check(Ja(jc,n)),e.ulid=n=>e.check(Ya(_c,n)),e.base64=n=>e.check(oi(Lc,n)),e.base64url=n=>e.check(ri(zc,n)),e.xid=n=>e.check(Xa(Cc,n)),e.ksuid=n=>e.check(qa(Sc,n)),e.ipv4=n=>e.check(Qa(Ic,n)),e.ipv6=n=>e.check(ei(Tc,n)),e.cidrv4=n=>e.check(ti(Ec,n)),e.cidrv6=n=>e.check(ni($c,n)),e.e164=n=>e.check(si(Ac,n)),e.datetime=n=>e.check(qi(n)),e.date=n=>e.check(ec(n)),e.time=n=>e.check(nc(n)),e.duration=n=>e.check(rc(n))});function H(e){return Pa(bc,e)}const q=_("ZodStringFormat",(e,t)=>{X.init(e,t),Io.init(e,t)}),yc=_("ZodEmail",(e,t)=>{Ks.init(e,t),q.init(e,t)}),Cn=_("ZodGUID",(e,t)=>{Us.init(e,t),q.init(e,t)}),tt=_("ZodUUID",(e,t)=>{Ws.init(e,t),q.init(e,t)}),wc=_("ZodURL",(e,t)=>{Js.init(e,t),q.init(e,t)}),vc=_("ZodEmoji",(e,t)=>{Ys.init(e,t),q.init(e,t)}),kc=_("ZodNanoID",(e,t)=>{Xs.init(e,t),q.init(e,t)}),Nc=_("ZodCUID",(e,t)=>{qs.init(e,t),q.init(e,t)}),jc=_("ZodCUID2",(e,t)=>{Qs.init(e,t),q.init(e,t)}),_c=_("ZodULID",(e,t)=>{ea.init(e,t),q.init(e,t)}),Cc=_("ZodXID",(e,t)=>{ta.init(e,t),q.init(e,t)}),Sc=_("ZodKSUID",(e,t)=>{na.init(e,t),q.init(e,t)}),Ic=_("ZodIPv4",(e,t)=>{ia.init(e,t),q.init(e,t)}),Tc=_("ZodIPv6",(e,t)=>{ca.init(e,t),q.init(e,t)}),Ec=_("ZodCIDRv4",(e,t)=>{da.init(e,t),q.init(e,t)}),$c=_("ZodCIDRv6",(e,t)=>{la.init(e,t),q.init(e,t)}),Lc=_("ZodBase64",(e,t)=>{ua.init(e,t),q.init(e,t)}),zc=_("ZodBase64URL",(e,t)=>{pa.init(e,t),q.init(e,t)}),Ac=_("ZodE164",(e,t)=>{ha.init(e,t),q.init(e,t)}),Oc=_("ZodJWT",(e,t)=>{ga.init(e,t),q.init(e,t)}),To=_("ZodNumber",(e,t)=>{bo.init(e,t),ne.init(e,t),e._zod.processJSONSchema=(o,r,s)=>zi(e,o,r),e.gt=(o,r)=>e.check(jn(o,r)),e.gte=(o,r)=>e.check(Tt(o,r)),e.min=(o,r)=>e.check(Tt(o,r)),e.lt=(o,r)=>e.check(Nn(o,r)),e.lte=(o,r)=>e.check(It(o,r)),e.max=(o,r)=>e.check(It(o,r)),e.int=o=>e.check(Sn(o)),e.safe=o=>e.check(Sn(o)),e.positive=o=>e.check(jn(0,o)),e.nonnegative=o=>e.check(Tt(0,o)),e.negative=o=>e.check(Nn(0,o)),e.nonpositive=o=>e.check(It(0,o)),e.multipleOf=(o,r)=>e.check(_n(o,r)),e.step=(o,r)=>e.check(_n(o,r)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function pt(e){return ui(To,e)}const Mc=_("ZodNumberFormat",(e,t)=>{xa.init(e,t),To.init(e,t)});function Sn(e){return fi(Mc,e)}const Fc=_("ZodUnknown",(e,t)=>{ba.init(e,t),ne.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Oi()});function In(){return pi(Fc)}const Dc=_("ZodNever",(e,t)=>{ya.init(e,t),ne.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ai(e,n,o)});function Pc(e){return hi(Dc,e)}const Rc=_("ZodArray",(e,t)=>{wa.init(e,t),ne.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Pi(e,n,o,r),e.element=t.element,e.min=(n,o)=>e.check(ut(n,o)),e.nonempty=n=>e.check(ut(1,n)),e.max=(n,o)=>e.check(ko(n,o)),e.length=(n,o)=>e.check(No(n,o)),e.unwrap=()=>e.element});function ie(e,t){return Ci(Rc,e,t)}const Zc=_("ZodObject",(e,t)=>{ka.init(e,t),ne.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ri(e,n,o,r),W(e,"shape",()=>t.shape),e.keyof=()=>Ee(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:In()}),e.loose=()=>e.clone({...e._zod.def,catchall:In()}),e.strict=()=>e.clone({...e._zod.def,catchall:Pc()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>Gr(e,n),e.safeExtend=n=>Hr(e,n),e.merge=n=>Ur(e,n),e.pick=n=>Br(e,n),e.omit=n=>Vr(e,n),e.partial=(...n)=>Wr(Eo,e,n[0]),e.required=(...n)=>Kr($o,e,n[0])});function je(e,t){const n={type:"object",shape:e??{},...O(t)};return new Zc(n)}const Bc=_("ZodUnion",(e,t)=>{Na.init(e,t),ne.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Zi(e,n,o,r),e.options=t.options});function Vc(e,t){return new Bc({type:"union",options:e,...O(t)})}const Gc=_("ZodIntersection",(e,t)=>{ja.init(e,t),ne.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Bi(e,n,o,r)});function Hc(e,t){return new Gc({type:"intersection",left:e,right:t})}const Uc=_("ZodTuple",(e,t)=>{_a.init(e,t),ne.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Vi(e,n,o,r),e.rest=n=>e.clone({...e._zod.def,rest:n})});function Wc(e,t,n){const o=t instanceof ee,r=o?n:t,s=o?t:null;return new Uc({type:"tuple",items:e,rest:s,...O(r)})}const At=_("ZodEnum",(e,t)=>{Ca.init(e,t),ne.init(e,t),e._zod.processJSONSchema=(o,r,s)=>Mi(e,o,r),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(o,r)=>{const s={};for(const i of o)if(n.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new At({...t,checks:[],...O(r),entries:s})},e.exclude=(o,r)=>{const s={...t.entries};for(const i of o)if(n.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new At({...t,checks:[],...O(r),entries:s})}});function Ee(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(o=>[o,o])):e;return new At({type:"enum",entries:n,...O(t)})}const Kc=_("ZodTransform",(e,t)=>{Sa.init(e,t),ne.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Di(e,n),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new no(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(We(s,n.value,t));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=e),n.issues.push(We(i))}};const r=t.transform(n.value,n);return r instanceof Promise?r.then(s=>(n.value=s,n)):(n.value=r,n)}});function Jc(e){return new Kc({type:"transform",transform:e})}const Eo=_("ZodOptional",(e,t)=>{vo.init(e,t),ne.init(e,t),e._zod.processJSONSchema=(n,o,r)=>So(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function Tn(e){return new Eo({type:"optional",innerType:e})}const Yc=_("ZodExactOptional",(e,t)=>{Ia.init(e,t),ne.init(e,t),e._zod.processJSONSchema=(n,o,r)=>So(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function Xc(e){return new Yc({type:"optional",innerType:e})}const qc=_("ZodNullable",(e,t)=>{Ta.init(e,t),ne.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Gi(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function En(e){return new qc({type:"nullable",innerType:e})}const Qc=_("ZodDefault",(e,t)=>{Ea.init(e,t),ne.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ui(e,n,o,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ed(e,t){return new Qc({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():ao(t)}})}const td=_("ZodPrefault",(e,t)=>{$a.init(e,t),ne.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Wi(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function nd(e,t){return new td({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():ao(t)}})}const $o=_("ZodNonOptional",(e,t)=>{La.init(e,t),ne.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Hi(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function od(e,t){return new $o({type:"nonoptional",innerType:e,...O(t)})}const rd=_("ZodCatch",(e,t)=>{za.init(e,t),ne.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ki(e,n,o,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function sd(e,t){return new rd({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const ad=_("ZodPipe",(e,t)=>{Aa.init(e,t),ne.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ji(e,n,o,r),e.in=t.in,e.out=t.out});function $n(e,t){return new ad({type:"pipe",in:e,out:t})}const id=_("ZodReadonly",(e,t)=>{Oa.init(e,t),ne.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Yi(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function cd(e){return new id({type:"readonly",innerType:e})}const dd=_("ZodCustom",(e,t)=>{Ma.init(e,t),ne.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Fi(e,n)});function ld(e,t={}){return Si(dd,e,t)}function ud(e){return Ii(e)}const fd=Ee(["imports","exports","contains","inherits","implements","calls","subscribes","publishes","middleware","reads_from","writes_to","transforms","validates","depends_on","tested_by","configures","related","similar_to","deploys","serves","provisions","triggers","migrates","documents","routes","defines_schema","contains_flow","flow_step","cross_domain","cites","contradicts","builds_on","exemplifies","categorized_under","authored_by"]),Ln={func:"function",fn:"function",method:"function",interface:"class",struct:"class",mod:"module",pkg:"module",package:"module",container:"service",deployment:"service",pod:"service",doc:"document",readme:"document",docs:"document",job:"pipeline",ci:"pipeline",route:"endpoint",api:"endpoint",query:"endpoint",mutation:"endpoint",setting:"config",env:"config",configuration:"config",infra:"resource",infrastructure:"resource",terraform:"resource",migration:"table",database:"table",db:"table",view:"table",proto:"schema",protobuf:"schema",definition:"schema",typedef:"schema",business_domain:"domain",business_flow:"flow",business_process:"flow",task:"step",business_step:"step",note:"article",page:"article",wiki_page:"article",person:"entity",actor:"entity",organization:"entity",tag:"topic",category:"topic",theme:"topic",assertion:"claim",decision:"claim",thesis:"claim",reference:"source",raw:"source",paper:"source"},zn={extends:"inherits",invokes:"calls",invoke:"calls",uses:"depends_on",requires:"depends_on",relates_to:"related",related_to:"related",similar:"similar_to",import:"imports",export:"exports",contain:"contains",publish:"publishes",subscribe:"subscribes",describes:"documents",documented_by:"documents",creates:"provisions",exposes:"serves",listens:"serves",deploys_to:"deploys",migrates_to:"migrates",routes_to:"routes",triggers_on:"triggers",fires:"triggers",defines:"defines_schema",has_flow:"contains_flow",next_step:"flow_step",interacts_with:"cross_domain",references:"cites",cites_source:"cites",conflicts_with:"contradicts",disagrees_with:"contradicts",refines:"builds_on",elaborates:"builds_on",illustrates:"exemplifies",instance_of:"exemplifies",example_of:"exemplifies",belongs_to:"categorized_under",tagged_with:"categorized_under",written_by:"authored_by",created_by:"authored_by"},An={low:"simple",easy:"simple",medium:"moderate",intermediate:"moderate",high:"complex",hard:"complex",difficult:"complex"},On={to:"forward",outbound:"forward",from:"backward",inbound:"backward",both:"bidirectional",mutual:"bidirectional"};function pd(e){const t={...e};return(e.tour===null||e.tour===void 0)&&(t.tour=[]),(e.layers===null||e.layers===void 0)&&(t.layers=[]),Array.isArray(e.nodes)&&(t.nodes=e.nodes.map(n=>{if(typeof n!="object"||n===null)return n;const o={...n};return o.filePath===null&&delete o.filePath,o.lineRange===null&&delete o.lineRange,o.languageNotes===null&&delete o.languageNotes,typeof o.type=="string"&&(o.type=o.type.toLowerCase()),typeof o.complexity=="string"&&(o.complexity=o.complexity.toLowerCase()),o})),Array.isArray(e.edges)&&(t.edges=e.edges.map(n=>{if(typeof n!="object"||n===null)return n;const o={...n};return o.description===null&&delete o.description,typeof o.type=="string"&&(o.type=o.type.toLowerCase()),typeof o.direction=="string"&&(o.direction=o.direction.toLowerCase()),o})),Array.isArray(t.tour)&&(t.tour=t.tour.map(n=>{if(typeof n!="object"||n===null)return n;const o={...n};return o.languageLesson===null&&delete o.languageLesson,o})),t}function hd(e){const t=[],n={...e};return Array.isArray(e.nodes)&&(n.nodes=e.nodes.map((o,r)=>{if(typeof o!="object"||o===null)return o;const s={...o},i=s.name||s.id||`index ${r}`;if((!s.type||typeof s.type!="string")&&(s.type="file",t.push({level:"auto-corrected",category:"missing-field",message:`nodes[${r}] ("${i}"): missing "type" — defaulted to "file"`,path:`nodes[${r}].type`})),!s.complexity||s.complexity==="")s.complexity="moderate",t.push({level:"auto-corrected",category:"missing-field",message:`nodes[${r}] ("${i}"): missing "complexity" — defaulted to "moderate"`,path:`nodes[${r}].complexity`});else if(typeof s.complexity=="string"&&s.complexity in An){const c=s.complexity;s.complexity=An[s.complexity],t.push({level:"auto-corrected",category:"alias",message:`nodes[${r}] ("${i}"): complexity "${c}" — mapped to "${s.complexity}"`,path:`nodes[${r}].complexity`})}return Array.isArray(s.tags)||(s.tags=[],t.push({level:"auto-corrected",category:"missing-field",message:`nodes[${r}] ("${i}"): missing "tags" — defaulted to []`,path:`nodes[${r}].tags`})),(!s.summary||typeof s.summary!="string")&&(s.summary=s.name||"No summary",t.push({level:"auto-corrected",category:"missing-field",message:`nodes[${r}] ("${i}"): missing "summary" — defaulted to name`,path:`nodes[${r}].summary`})),s})),Array.isArray(e.edges)&&(n.edges=e.edges.map((o,r)=>{if(typeof o!="object"||o===null)return o;const s={...o};if((!s.type||typeof s.type!="string")&&(s.type="depends_on",t.push({level:"auto-corrected",category:"missing-field",message:`edges[${r}]: missing "type" — defaulted to "depends_on"`,path:`edges[${r}].type`})),!s.direction||typeof s.direction!="string")s.direction="forward",t.push({level:"auto-corrected",category:"missing-field",message:`edges[${r}]: missing "direction" — defaulted to "forward"`,path:`edges[${r}].direction`});else if(s.direction in On){const i=s.direction;s.direction=On[s.direction],t.push({level:"auto-corrected",category:"alias",message:`edges[${r}]: direction "${i}" — mapped to "${s.direction}"`,path:`edges[${r}].direction`})}if(s.weight===void 0||s.weight===null)s.weight=.5,t.push({level:"auto-corrected",category:"missing-field",message:`edges[${r}]: missing "weight" — defaulted to 0.5`,path:`edges[${r}].weight`});else if(typeof s.weight=="string"){const i=parseFloat(s.weight);if(isNaN(i)){const c=s.weight;s.weight=.5,t.push({level:"auto-corrected",category:"type-coercion",message:`edges[${r}]: weight "${c}" is not a valid number — defaulted to 0.5`,path:`edges[${r}].weight`})}else{const c=s.weight;s.weight=i,t.push({level:"auto-corrected",category:"type-coercion",message:`edges[${r}]: weight was string "${c}" — coerced to number`,path:`edges[${r}].weight`})}}if(typeof s.weight=="number"&&(s.weight<0||s.weight>1)){const i=s.weight;s.weight=Math.max(0,Math.min(1,s.weight)),t.push({level:"auto-corrected",category:"out-of-range",message:`edges[${r}]: weight ${i} clamped to ${s.weight}`,path:`edges[${r}].weight`})}return s})),{data:n,issues:t}}const md=je({entities:ie(H()).optional(),businessRules:ie(H()).optional(),crossDomainInteractions:ie(H()).optional(),entryPoint:H().optional(),entryType:Ee(["http","cli","event","cron","manual"]).optional()}).passthrough(),gd=je({wikilinks:ie(H()).optional(),backlinks:ie(H()).optional(),category:H().optional(),content:H().optional()}).passthrough(),Lo=je({id:H(),type:Ee(["file","function","class","module","concept","config","document","service","table","endpoint","pipeline","schema","resource","domain","flow","step","article","entity","topic","claim","source"]),name:H(),filePath:H().optional(),lineRange:Wc([pt(),pt()]).optional(),summary:H(),tags:ie(H()),complexity:Ee(["simple","moderate","complex"]),languageNotes:H().optional(),domainMeta:md.optional(),knowledgeMeta:gd.optional()}).passthrough(),zo=je({source:H(),target:H(),type:fd,direction:Ee(["forward","backward","bidirectional"]),description:H().optional(),weight:pt().min(0).max(1)}),Ao=je({id:H(),name:H(),description:H(),nodeIds:ie(H())}),Oo=je({order:pt(),title:H(),description:H(),nodeIds:ie(H()),languageLesson:H().optional()}),Mo=je({name:H(),languages:ie(H()),frameworks:ie(H()),description:H(),analyzedAt:H(),gitCommitHash:H()});je({version:H(),kind:Ee(["codebase","knowledge"]).optional(),project:Mo,nodes:ie(Lo),edges:ie(zo),layers:ie(Ao),tour:ie(Oo)});function xd(e){return{level:"fatal",category:"invalid-collection",message:`"${e}" must be an array when present`,path:e}}function Re(e,t){const n=e.map(o=>o.message);return t&&!n.includes(t)&&n.unshift(t),n.length>0?n:void 0}function bd(e){if(typeof e!="object"||e===null)return e;const t=e,n={...t};return Array.isArray(t.nodes)&&(n.nodes=t.nodes.map(o=>typeof o=="object"&&o!==null&&typeof o.type=="string"&&o.type in Ln?{...o,type:Ln[o.type]}:o)),Array.isArray(t.edges)&&(n.edges=t.edges.map(o=>typeof o=="object"&&o!==null&&typeof o.type=="string"&&o.type in zn?{...o,type:zn[o.type]}:o)),n}function Mn(e){var m,p,N,y;if(typeof e!="object"||e===null){const x="Invalid input: not an object";return{success:!1,issues:[],fatal:x,errors:Re([],x)}}const n=pd(e),o=bd(n),{data:r,issues:s}=hd(o),i=["nodes","edges","layers","tour"];for(const x of i)if(x in r&&r[x]!==void 0&&!Array.isArray(r[x])){const k=xd(x);return s.push(k),{success:!1,errors:Re(s,k.message),issues:s,fatal:k.message}}const c=Mo.safeParse(r.project);if(!c.success)return{success:!1,errors:Re(s,"Missing or invalid project metadata"),issues:s,fatal:"Missing or invalid project metadata"};const d=[];if(Array.isArray(r.nodes))for(let x=0;xx.id)),u=[];if(Array.isArray(r.edges))for(let x=0;xl.has(T))}):s.push({level:"dropped",category:"invalid-layer",message:`layers[${x}]: ${((N=k.error.issues[0])==null?void 0:N.message)??"validation failed"} — removed`,path:`layers[${x}]`})}const h=[];if(Array.isArray(r.tour))for(let x=0;xl.has(T))}):s.push({level:"dropped",category:"invalid-tour-step",message:`tour[${x}]: ${((y=k.error.issues[0])==null?void 0:y.message)??"validation failed"} — removed`,path:`tour[${x}]`})}return{success:!0,data:{version:typeof r.version=="string"?r.version:"1.0.0",project:c.data,nodes:d,edges:u,layers:f,tour:h},issues:s,errors:Re(s)}}const Fn=e=>{let t;const n=new Set,o=(l,u)=>{const f=typeof l=="function"?l(t):l;if(!Object.is(f,t)){const h=t;t=u??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(g=>g(t,h))}},r=()=>t,c={setState:o,getState:r,getInitialState:()=>d,subscribe:l=>(n.add(l),()=>n.delete(l))},d=t=e(o,r,c);return c},yd=(e=>e?Fn(e):Fn),wd=e=>e;function vd(e,t=wd){const n=Xe.useSyncExternalStore(e.subscribe,Xe.useCallback(()=>t(e.getState()),[e,t]),Xe.useCallback(()=>t(e.getInitialState()),[e,t]));return Xe.useDebugValue(n),n}const kd=e=>{const t=yd(e),n=o=>vd(t,o);return Object.assign(n,t),n},Nd=(e=>kd);function ye(e){return Array.isArray?Array.isArray(e):Po(e)==="[object Array]"}function jd(e){if(typeof e=="string")return e;let t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function _d(e){return e==null?"":jd(e)}function ge(e){return typeof e=="string"}function Fo(e){return typeof e=="number"}function Cd(e){return e===!0||e===!1||Sd(e)&&Po(e)=="[object Boolean]"}function Do(e){return typeof e=="object"}function Sd(e){return Do(e)&&e!==null}function le(e){return e!=null}function Et(e){return!e.trim().length}function Po(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const Id="Incorrect 'index' type",Td=e=>`Invalid value for key ${e}`,Ed=e=>`Pattern length exceeds max of ${e}.`,$d=e=>`Missing ${e} property in key`,Ld=e=>`Property 'weight' in key '${e}' must be a positive integer`,Dn=Object.prototype.hasOwnProperty;class zd{constructor(t){this._keys=[],this._keyMap={};let n=0;t.forEach(o=>{let r=Ro(o);this._keys.push(r),this._keyMap[r.id]=r,n+=r.weight}),this._keys.forEach(o=>{o.weight/=n})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Ro(e){let t=null,n=null,o=null,r=1,s=null;if(ge(e)||ye(e))o=e,t=Pn(e),n=Ot(e);else{if(!Dn.call(e,"name"))throw new Error($d("name"));const i=e.name;if(o=i,Dn.call(e,"weight")&&(r=e.weight,r<=0))throw new Error(Ld(i));t=Pn(i),n=Ot(i),s=e.getFn}return{path:t,id:n,weight:r,src:o,getFn:s}}function Pn(e){return ye(e)?e:e.split(".")}function Ot(e){return ye(e)?e.join("."):e}function Ad(e,t){let n=[],o=!1;const r=(s,i,c)=>{if(le(s))if(!i[c])n.push(s);else{let d=i[c];const l=s[d];if(!le(l))return;if(c===i.length-1&&(ge(l)||Fo(l)||Cd(l)))n.push(_d(l));else if(ye(l)){o=!0;for(let u=0,f=l.length;ue.score===t.score?e.idx{this._keysMap[n.id]=o})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,ge(this.docs[0])?this.docs.forEach((t,n)=>{this._addString(t,n)}):this.docs.forEach((t,n)=>{this._addObject(t,n)}),this.norm.clear())}add(t){const n=this.size();ge(t)?this._addString(t,n):this._addObject(t,n)}removeAt(t){this.records.splice(t,1);for(let n=t,o=this.size();n{let i=r.getFn?r.getFn(t):this.getFn(t,r.path);if(le(i)){if(ye(i)){let c=[];const d=[{nestedArrIndex:-1,value:i}];for(;d.length;){const{nestedArrIndex:l,value:u}=d.pop();if(le(u))if(ge(u)&&!Et(u)){let f={v:u,i:l,n:this.norm.get(u)};c.push(f)}else ye(u)&&u.forEach((f,h)=>{d.push({nestedArrIndex:h,value:f})})}o.$[s]=c}else if(ge(i)&&!Et(i)){let c={v:i,n:this.norm.get(i)};o.$[s]=c}}}),this.records.push(o)}toJSON(){return{keys:this.keys,records:this.records}}}function Zo(e,t,{getFn:n=F.getFn,fieldNormWeight:o=F.fieldNormWeight}={}){const r=new an({getFn:n,fieldNormWeight:o});return r.setKeys(e.map(Ro)),r.setSources(t),r.create(),r}function Zd(e,{getFn:t=F.getFn,fieldNormWeight:n=F.fieldNormWeight}={}){const{keys:o,records:r}=e,s=new an({getFn:t,fieldNormWeight:n});return s.setKeys(o),s.setIndexRecords(r),s}function nt(e,{errors:t=0,currentLocation:n=0,expectedLocation:o=0,distance:r=F.distance,ignoreLocation:s=F.ignoreLocation}={}){const i=t/e.length;if(s)return i;const c=Math.abs(o-n);return r?i+c/r:c?1:i}function Bd(e=[],t=F.minMatchCharLength){let n=[],o=-1,r=-1,s=0;for(let i=e.length;s=t&&n.push([o,r]),o=-1)}return e[s-1]&&s-o>=t&&n.push([o,s-1]),n}const Se=32;function Vd(e,t,n,{location:o=F.location,distance:r=F.distance,threshold:s=F.threshold,findAllMatches:i=F.findAllMatches,minMatchCharLength:c=F.minMatchCharLength,includeMatches:d=F.includeMatches,ignoreLocation:l=F.ignoreLocation}={}){if(t.length>Se)throw new Error(Ed(Se));const u=t.length,f=e.length,h=Math.max(0,Math.min(o,f));let g=s,m=h;const p=c>1||d,N=p?Array(f):[];let y;for(;(y=e.indexOf(t,m))>-1;){let I=nt(t,{currentLocation:y,expectedLocation:h,distance:r,ignoreLocation:l});if(g=Math.min(I,g),m=y+u,p){let E=0;for(;E=M;P-=1){let V=P-1,R=n[e.charAt(V)];if(p&&(N[V]=+!!R),D[P]=(D[P+1]<<1|1)&R,I&&(D[P]|=(x[P+1]|x[P])<<1|1|x[P+1]),D[P]&j&&(k=nt(t,{errors:I,currentLocation:V,expectedLocation:h,distance:r,ignoreLocation:l}),k<=g)){if(g=k,m=V,m<=h)break;M=Math.max(1,2*h-m)}}if(nt(t,{errors:I+1,currentLocation:h,expectedLocation:h,distance:r,ignoreLocation:l})>g)break;x=D}const C={isMatch:m>=0,score:Math.max(.001,k)};if(p){const I=Bd(N,c);I.length?d&&(C.indices=I):C.isMatch=!1}return C}function Gd(e){let t={};for(let n=0,o=e.length;ne.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"")):(e=>e);class Bo{constructor(t,{location:n=F.location,threshold:o=F.threshold,distance:r=F.distance,includeMatches:s=F.includeMatches,findAllMatches:i=F.findAllMatches,minMatchCharLength:c=F.minMatchCharLength,isCaseSensitive:d=F.isCaseSensitive,ignoreDiacritics:l=F.ignoreDiacritics,ignoreLocation:u=F.ignoreLocation}={}){if(this.options={location:n,threshold:o,distance:r,includeMatches:s,findAllMatches:i,minMatchCharLength:c,isCaseSensitive:d,ignoreDiacritics:l,ignoreLocation:u},t=d?t:t.toLowerCase(),t=l?ht(t):t,this.pattern=t,this.chunks=[],!this.pattern.length)return;const f=(g,m)=>{this.chunks.push({pattern:g,alphabet:Gd(g),startIndex:m})},h=this.pattern.length;if(h>Se){let g=0;const m=h%Se,p=h-m;for(;g{const{isMatch:x,score:k,indices:T}=Vd(t,p,N,{location:s+y,distance:i,threshold:c,findAllMatches:d,minMatchCharLength:l,includeMatches:r,ignoreLocation:u});x&&(g=!0),h+=k,x&&T&&(f=[...f,...T])});let m={isMatch:g,score:g?h/this.chunks.length:1};return g&&r&&(m.indices=f),m}}class _e{constructor(t){this.pattern=t}static isMultiMatch(t){return Rn(t,this.multiRegex)}static isSingleMatch(t){return Rn(t,this.singleRegex)}search(){}}function Rn(e,t){const n=e.match(t);return n?n[1]:null}class Hd extends _e{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const n=t===this.pattern;return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class Ud extends _e{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const o=t.indexOf(this.pattern)===-1;return{isMatch:o,score:o?0:1,indices:[0,t.length-1]}}}class Wd extends _e{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const n=t.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,this.pattern.length-1]}}}class Kd extends _e{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const n=!t.startsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}}class Jd extends _e{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const n=t.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[t.length-this.pattern.length,t.length-1]}}}class Yd extends _e{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const n=!t.endsWith(this.pattern);return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}}class Vo extends _e{constructor(t,{location:n=F.location,threshold:o=F.threshold,distance:r=F.distance,includeMatches:s=F.includeMatches,findAllMatches:i=F.findAllMatches,minMatchCharLength:c=F.minMatchCharLength,isCaseSensitive:d=F.isCaseSensitive,ignoreDiacritics:l=F.ignoreDiacritics,ignoreLocation:u=F.ignoreLocation}={}){super(t),this._bitapSearch=new Bo(t,{location:n,threshold:o,distance:r,includeMatches:s,findAllMatches:i,minMatchCharLength:c,isCaseSensitive:d,ignoreDiacritics:l,ignoreLocation:u})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class Go extends _e{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let n=0,o;const r=[],s=this.pattern.length;for(;(o=t.indexOf(this.pattern,n))>-1;)n=o+s,r.push([o,n-1]);const i=!!r.length;return{isMatch:i,score:i?0:1,indices:r}}}const Mt=[Hd,Go,Wd,Kd,Yd,Jd,Ud,Vo],Zn=Mt.length,Xd=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,qd="|";function Qd(e,t={}){return e.split(qd).map(n=>{let o=n.trim().split(Xd).filter(s=>s&&!!s.trim()),r=[];for(let s=0,i=o.length;s!!(e[mt.AND]||e[mt.OR]),ol=e=>!!e[Pt.PATH],rl=e=>!ye(e)&&Do(e)&&!Rt(e),Bn=e=>({[mt.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function Ho(e,t,{auto:n=!0}={}){const o=r=>{let s=Object.keys(r);const i=ol(r);if(!i&&s.length>1&&!Rt(r))return o(Bn(r));if(rl(r)){const d=i?r[Pt.PATH]:s[0],l=i?r[Pt.PATTERN]:r[d];if(!ge(l))throw new Error(Td(d));const u={keyId:Ot(d),pattern:l};return n&&(u.searcher=Dt(l,t)),u}let c={children:[],operator:s[0]};return s.forEach(d=>{const l=r[d];ye(l)&&l.forEach(u=>{c.children.push(o(u))})}),c};return Rt(e)||(e=Bn(e)),o(e)}function sl(e,{ignoreFieldNorm:t=F.ignoreFieldNorm}){e.forEach(n=>{let o=1;n.matches.forEach(({key:r,norm:s,score:i})=>{const c=r?r.weight:null;o*=Math.pow(i===0&&c?Number.EPSILON:i,(c||1)*(t?1:s))}),n.score=o})}function al(e,t){const n=e.matches;t.matches=[],le(n)&&n.forEach(o=>{if(!le(o.indices)||!o.indices.length)return;const{indices:r,value:s}=o;let i={indices:r,value:s};o.key&&(i.key=o.key.src),o.idx>-1&&(i.refIndex=o.idx),t.matches.push(i)})}function il(e,t){t.score=e.score}function cl(e,t,{includeMatches:n=F.includeMatches,includeScore:o=F.includeScore}={}){const r=[];return n&&r.push(al),o&&r.push(il),e.map(s=>{const{idx:i}=s,c={item:t[i],refIndex:i};return r.length&&r.forEach(d=>{d(s,c)}),c})}class $e{constructor(t,n={},o){this.options={...F,...n},this.options.useExtendedSearch,this._keyStore=new zd(this.options.keys),this.setCollection(t,o)}setCollection(t,n){if(this._docs=t,n&&!(n instanceof an))throw new Error(Id);this._myIndex=n||Zo(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){le(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const n=[];for(let o=0,r=this._docs.length;o-1&&(d=d.slice(0,n)),cl(d,this._docs,{includeMatches:o,includeScore:r})}_searchStringList(t){const n=Dt(t,this.options),{records:o}=this._myIndex,r=[];return o.forEach(({v:s,i,n:c})=>{if(!le(s))return;const{isMatch:d,score:l,indices:u}=n.searchIn(s);d&&r.push({item:s,idx:i,matches:[{score:l,value:s,norm:c,indices:u}]})}),r}_searchLogical(t){const n=Ho(t,this.options),o=(c,d,l)=>{if(!c.children){const{keyId:f,searcher:h}=c,g=this._findMatches({key:this._keyStore.get(f),value:this._myIndex.getValueForItemAtKeyId(d,f),searcher:h});return g&&g.length?[{idx:l,item:d,matches:g}]:[]}const u=[];for(let f=0,h=c.children.length;f{if(le(c)){let l=o(n,c,d);l.length&&(s[d]||(s[d]={idx:d,item:c,matches:[]},i.push(s[d])),l.forEach(({matches:u})=>{s[d].matches.push(...u)}))}}),i}_searchObjectList(t){const n=Dt(t,this.options),{keys:o,records:r}=this._myIndex,s=[];return r.forEach(({$:i,i:c})=>{if(!le(i))return;let d=[];o.forEach((l,u)=>{d.push(...this._findMatches({key:l,value:i[u],searcher:n}))}),d.length&&s.push({idx:c,item:i,matches:d})}),s}_findMatches({key:t,value:n,searcher:o}){if(!le(n))return[];let r=[];if(ye(n))n.forEach(({v:s,i,n:c})=>{if(!le(s))return;const{isMatch:d,score:l,indices:u}=o.searchIn(s);d&&r.push({score:l,key:t,value:s,idx:i,norm:c,indices:u})});else{const{v:s,n:i}=n,{isMatch:c,score:d,indices:l}=o.searchIn(s);c&&r.push({score:d,key:t,value:s,norm:i,indices:l})}return r}}$e.version="7.1.0";$e.createIndex=Zo;$e.parseIndex=Zd;$e.config=F;$e.parseQuery=Ho;nl(tl);const Vn={keys:[{name:"name",weight:.4},{name:"tags",weight:.3},{name:"summary",weight:.2},{name:"languageNotes",weight:.1}],threshold:.4,includeScore:!0,ignoreLocation:!0,useExtendedSearch:!0};class dl{constructor(t){St(this,"fuse");St(this,"nodes");this.nodes=t,this.fuse=new $e(t,Vn)}search(t,n){const o=t.trim();if(!o)return[];const r=(n==null?void 0:n.limit)??50,s=o.split(/\s+/).join(" | ");let c=this.fuse.search(s);if(n!=null&&n.types&&n.types.length>0){const d=new Set(n.types);c=c.filter(l=>d.has(l.item.type))}return c.slice(0,r).map(d=>({nodeId:d.item.id,score:d.score??0}))}updateNodes(t){this.nodes=t,this.fuse=new $e(t,Vn)}}const gt=["file","function","class","module","concept","config","document","service","table","endpoint","pipeline","schema","resource","domain","flow","step","article","entity","topic","claim","source"],xt=["simple","moderate","complex"],bt=["structural","behavioral","data-flow","dependencies","semantic","infrastructure","domain","knowledge"],ll={structural:["imports","exports","contains","inherits","implements"],behavioral:["calls","subscribes","publishes","middleware"],"data-flow":["reads_from","writes_to","transforms","validates"],dependencies:["depends_on","tested_by","configures"],semantic:["related","similar_to"],infrastructure:["deploys","serves","provisions","triggers","migrates","documents","routes","defines_schema"],domain:["contains_flow","flow_step","cross_domain"],knowledge:["cites","contradicts","builds_on","exemplifies","categorized_under","authored_by"]},Ze={nodeTypes:new Set(gt),complexities:new Set(xt),layerIds:new Set,edgeCategories:new Set(bt)};function ul(e){const t=new Map;for(const r of e.nodes)t.set(r.id,r);const n=new Map,o=new Map;for(const r of e.layers)for(const s of r.nodeIds){n.has(s)||n.set(s,r.id);let i=o.get(s);i||(i=new Set,o.set(s,i)),i.add(r.id)}return{nodesById:t,nodeIdToLayerId:n,nodeIdToLayerIds:o}}function ot(e){return[...e.tour??[]].sort((n,o)=>n.order-o.order)}function rt(e,t){if(t.length===0)return{};const n=e.get(t[0]);return n?{navigationLevel:"layer-detail",activeLayerId:n}:{}}function st(e,t){const n=e.activeLayerId;return!n||n===t?{}:{containerLayoutCache:new Map,containerSizeMemory:new Map,expandedContainers:new Set,pendingFocusContainer:null}}const b=Nd()((e,t)=>({graph:null,nodesById:new Map,nodeIdToLayerId:new Map,nodeIdToLayerIds:new Map,selectedNodeId:null,searchQuery:"",searchResults:[],searchEngine:null,searchMode:"fuzzy",navigationLevel:"overview",activeLayerId:null,codeViewerOpen:!1,codeViewerNodeId:null,codeViewerExpanded:!1,tourActive:!1,currentTourStep:0,tourHighlightedNodeIds:[],persona:"junior",diffMode:!1,changedNodeIds:new Set,affectedNodeIds:new Set,focusNodeId:null,nodeHistory:[],filters:{...Ze,nodeTypes:new Set(Ze.nodeTypes),complexities:new Set(Ze.complexities),layerIds:new Set(Ze.layerIds),edgeCategories:new Set(Ze.edgeCategories)},filterPanelOpen:!1,exportMenuOpen:!1,pathFinderOpen:!1,reactFlowInstance:null,nodeTypeFilters:{code:!0,config:!0,docs:!0,infra:!0,data:!0,domain:!0,knowledge:!0},toggleNodeTypeFilter:n=>e(o=>({nodeTypeFilters:{...o.nodeTypeFilters,[n]:!o.nodeTypeFilters[n]},containerLayoutCache:new Map,containerSizeMemory:new Map,expandedContainers:new Set,pendingFocusContainer:null})),detailLevel:"file",setDetailLevel:n=>e({detailLevel:n,showFunctionsInClassView:!1,containerLayoutCache:new Map,containerSizeMemory:new Map,expandedContainers:new Set,pendingFocusContainer:null}),showFunctionsInClassView:!1,toggleShowFunctionsInClassView:()=>e(n=>({showFunctionsInClassView:!n.showFunctionsInClassView,containerLayoutCache:new Map,containerSizeMemory:new Map,expandedContainers:new Set,pendingFocusContainer:null})),setGraph:n=>{const o=new dl(n.nodes),r=t().searchQuery,s=r.trim()?o.search(r):[],{viewMode:i,domainGraph:c,activeDomainId:d}=t(),l=i==="domain"&&c!==null,{nodesById:u,nodeIdToLayerId:f,nodeIdToLayerIds:h}=ul(n);e({graph:n,nodesById:u,nodeIdToLayerId:f,nodeIdToLayerIds:h,searchEngine:o,searchResults:s,navigationLevel:"overview",activeLayerId:null,selectedNodeId:null,focusNodeId:null,nodeHistory:[],viewMode:l?"domain":"structural",activeDomainId:l?d:null,containerLayoutCache:new Map,expandedContainers:new Set,pendingFocusContainer:null,containerSizeMemory:new Map,stage1Tick:0,layoutIssues:[]})},selectNode:n=>{const{selectedNodeId:o,nodeHistory:r}=t();e(n&&o&&n!==o?{selectedNodeId:n,nodeHistory:[...r,o].slice(-50)}:{selectedNodeId:n})},navigateToNode:n=>{t().navigateToNodeInLayer(n)},navigateToNodeInLayer:n=>{const{graph:o,selectedNodeId:r,nodeHistory:s,nodeIdToLayerId:i}=t();if(!o)return;const c=i.get(n)??null,d=r&&n!==r?[...s,r].slice(-50):s;e(c?{navigationLevel:"layer-detail",activeLayerId:c,selectedNodeId:n,focusNodeId:null,codeViewerOpen:!1,codeViewerNodeId:null,codeViewerExpanded:!1,nodeHistory:d}:{selectedNodeId:n,nodeHistory:d})},navigateToHistoryIndex:n=>{const{nodeHistory:o,graph:r,nodeIdToLayerId:s}=t();if(!r||n<0||n>=o.length)return;const i=o[n],c=o.slice(0,n),d=s.get(i)??null;e({selectedNodeId:i,nodeHistory:c,...d?{navigationLevel:"layer-detail",activeLayerId:d}:{}})},goBackNode:()=>{const{nodeHistory:n,graph:o,nodeIdToLayerId:r}=t();if(n.length===0||!o)return;const s=n[n.length-1],i=n.slice(0,-1),c=r.get(s)??null;e(c?{navigationLevel:"layer-detail",activeLayerId:c,selectedNodeId:s,nodeHistory:i}:{selectedNodeId:s,nodeHistory:i})},drillIntoLayer:n=>e({navigationLevel:"layer-detail",activeLayerId:n,selectedNodeId:null,focusNodeId:null,codeViewerOpen:!1,codeViewerNodeId:null,codeViewerExpanded:!1,containerLayoutCache:new Map,containerSizeMemory:new Map,expandedContainers:new Set,pendingFocusContainer:null}),navigateToOverview:()=>e({navigationLevel:"overview",activeLayerId:null,selectedNodeId:null,focusNodeId:null,codeViewerOpen:!1,codeViewerNodeId:null,codeViewerExpanded:!1,containerLayoutCache:new Map,containerSizeMemory:new Map,expandedContainers:new Set,pendingFocusContainer:null}),setFocusNode:n=>e({focusNodeId:n,selectedNodeId:n,containerLayoutCache:new Map,containerSizeMemory:new Map,expandedContainers:new Set,pendingFocusContainer:null}),setSearchMode:n=>e({searchMode:n}),setSearchQuery:n=>{const o=t().searchEngine;if(t().searchMode,!o||!n.trim()){e({searchQuery:n,searchResults:[]});return}const r=o.search(n);e({searchQuery:n,searchResults:r})},setPersona:n=>e({persona:n,containerLayoutCache:new Map,containerSizeMemory:new Map,expandedContainers:new Set,pendingFocusContainer:null}),openCodeViewer:n=>e({codeViewerOpen:!0,codeViewerNodeId:n,codeViewerExpanded:!1}),closeCodeViewer:()=>e({codeViewerOpen:!1,codeViewerNodeId:null,codeViewerExpanded:!1}),expandCodeViewer:()=>e({codeViewerExpanded:!0}),collapseCodeViewer:()=>e({codeViewerExpanded:!1}),setDiffOverlay:(n,o)=>e({diffMode:!0,changedNodeIds:new Set(n),affectedNodeIds:new Set(o)}),toggleDiffMode:()=>e(n=>({diffMode:!n.diffMode})),clearDiffOverlay:()=>e({diffMode:!1,changedNodeIds:new Set,affectedNodeIds:new Set}),toggleFilterPanel:()=>e(n=>({filterPanelOpen:!n.filterPanelOpen,exportMenuOpen:!1})),toggleExportMenu:()=>e(n=>({exportMenuOpen:!n.exportMenuOpen,filterPanelOpen:!1})),togglePathFinder:()=>e(n=>({pathFinderOpen:!n.pathFinderOpen})),setReactFlowInstance:n=>e({reactFlowInstance:n}),setFilters:n=>e(o=>({filters:{...o.filters,...n}})),resetFilters:()=>e({filters:{nodeTypes:new Set(gt),complexities:new Set(xt),layerIds:new Set,edgeCategories:new Set(bt)}}),hasActiveFilters:()=>{const{filters:n}=t();return n.nodeTypes.size!==gt.length||n.complexities.size!==xt.length||n.layerIds.size>0||n.edgeCategories.size!==bt.length},startTour:()=>{const{graph:n,nodeIdToLayerId:o,activeLayerId:r}=t();if(!n||!n.tour||n.tour.length===0)return;const s=ot(n),i=rt(o,s[0].nodeIds);e({tourActive:!0,currentTourStep:0,tourHighlightedNodeIds:s[0].nodeIds,selectedNodeId:null,...i,...st(i,r)})},stopTour:()=>e({tourActive:!1,currentTourStep:0,tourHighlightedNodeIds:[]}),setTourStep:n=>{const{graph:o,nodeIdToLayerId:r,activeLayerId:s}=t();if(!o||!o.tour||o.tour.length===0)return;const i=ot(o);if(n<0||n>=i.length)return;const c=rt(r,i[n].nodeIds);e({currentTourStep:n,tourHighlightedNodeIds:i[n].nodeIds,...c,...st(c,s)})},nextTourStep:()=>{const{graph:n,currentTourStep:o,nodeIdToLayerId:r,activeLayerId:s}=t();if(!n||!n.tour||n.tour.length===0)return;const i=ot(n);if(o{const{graph:n,currentTourStep:o,nodeIdToLayerId:r,activeLayerId:s}=t();if(!(!n||!n.tour||n.tour.length===0)&&o>0){const i=ot(n),c=o-1,d=rt(r,i[c].nodeIds);e({currentTourStep:c,tourHighlightedNodeIds:i[c].nodeIds,...d,...st(d,s)})}},viewMode:"structural",isKnowledgeGraph:!1,domainGraph:null,activeDomainId:null,setDomainGraph:n=>{e({domainGraph:n})},setIsKnowledgeGraph:n=>{e({isKnowledgeGraph:n})},setViewMode:n=>{e({viewMode:n,selectedNodeId:null,focusNodeId:null,codeViewerOpen:!1,codeViewerNodeId:null,codeViewerExpanded:!1})},navigateToDomain:n=>{const{selectedNodeId:o,nodeHistory:r}=t(),s=o?[...r,o].slice(-50):r;e({viewMode:"domain",activeDomainId:n,focusNodeId:null,nodeHistory:s})},clearActiveDomain:()=>{e({activeDomainId:null,selectedNodeId:null,focusNodeId:null})},expandedContainers:new Set,pendingFocusContainer:null,setPendingFocusContainer:n=>e({pendingFocusContainer:n}),tourFitPending:!1,setTourFitPending:n=>e({tourFitPending:n}),toggleContainer:n=>e(o=>{const r=new Set(o.expandedContainers),s=!r.has(n);return s?r.add(n):r.delete(n),{expandedContainers:r,pendingFocusContainer:s?n:o.pendingFocusContainer}}),expandContainer:n=>e(o=>{if(o.expandedContainers.has(n))return{};const r=new Set(o.expandedContainers);return r.add(n),{expandedContainers:r}}),collapseContainer:n=>e(o=>{if(!o.expandedContainers.has(n))return{};const r=new Set(o.expandedContainers);return r.delete(n),{expandedContainers:r}}),collapseAllContainers:()=>e({expandedContainers:new Set}),containerLayoutCache:new Map,setContainerLayout:(n,o,r)=>e(s=>{const i=new Map(s.containerLayoutCache);i.set(n,{childPositions:o,actualSize:r});const c=new Map(s.containerSizeMemory);return c.set(n,r),{containerLayoutCache:i,containerSizeMemory:c}}),clearContainerLayouts:()=>e({containerLayoutCache:new Map,expandedContainers:new Set,pendingFocusContainer:null}),containerSizeMemory:new Map,stage1Tick:0,bumpStage1Tick:()=>e(n=>({stage1Tick:n.stage1Tick+1})),layoutIssues:[],appendLayoutIssues:n=>e(o=>{if(n.length===0)return{};const r=new Set(o.layoutIssues.map(i=>`${i.level}|${i.message}`)),s=n.filter(i=>!r.has(`${i.level}|${i.message}`));return s.length===0?{}:{layoutIssues:[...o.layoutIssues,...s]}}),clearLayoutIssues:()=>e({layoutIssues:[]})})),fl={common:{loading:"Loading project...",noGraphLoaded:"No graph loaded",selectNode:"Select a node to see details",back:"Back",focus:"Focus",unfocus:"Unfocus",openCode:"Open code",file:"File",tags:"Tags",connections:"Connections",filter:"Filter",resetAll:"Reset All",analyzed:"Analyzed",startGuidedTour:"Start Guided Tour",truncated:"(truncated)",preview:"Preview",doubleClickToOpen:"double-click to open",appName:"Understand Anything",pressKeyboard:"Press ? for keyboard shortcuts",path:"Path",theme:"Theme"},projectOverview:{nodes:"Nodes",edges:"Edges",layers:"Layers",types:"Types",fileTypes:"File Types",code:"Code",config:"Config",docs:"Docs",infra:"Infra",data:"Data",domain:"Domain",knowledge:"Knowledge",languages:"Languages",frameworks:"Frameworks",nodeTypeDistribution:"Node Type Distribution",complexityDistribution:"Complexity Distribution",simple:"Simple",moderate:"Moderate",complex:"Complex",mostConnectedNodes:"Most Connected Nodes",avgConnectionsPerNode:"Avg Connections per Node"},nodeInfo:{definedInThisFile:"Defined in this file",languageConcepts:"Language Concepts",category:"Category",wikilinks:"Wikilinks",backlinks:"Backlinks",entities:"Entities",businessRules:"Business Rules",crossDomain:"Cross-Domain",flows:"Flows",entryPoint:"Entry Point",steps:"Steps",implementation:"Implementation"},fileExplorer:{analyzedFiles:"Analyzed Files",filesFromGraph:"files from the current knowledge graph",noFilePathsFound:"No file paths found."},filterPanel:{nodeTypes:"Node Types",complexity:"Complexity",layers:"Layers",edgeCategories:"Edge Categories"},personaSelector:{overview:"Overview",overviewDesc:"High-level architecture view",learn:"Learn",learnDesc:"Full dashboard with guided learning",deepDive:"Deep Dive",deepDiveDesc:"Code-focused with chat"},sidebar:{info:"Info",files:"Files"},mobile:{graph:"Graph",info:"Info",files:"Files"},drawer:{controls:"Controls",dashboard:"Dashboard",role:"Role",view:"View",diffOverlay:"Diff overlay",nodeTypes:"Node types",layers:"Layers",tools:"Tools",path:"Path",help:"Help",structural:"Structural",domain:"Domain"},domainView:{backToDomains:"Back to domains"},detailLevel:{filesTitle:"Files only — architecture-level dependencies (fast)",classesTitle:"Files + Classes — code structure with inheritance",files:"Files",classes:"+Classes",fnTitle:"Toggle function nodes (may slow down rendering)",fn:"fn"},nodeTypeLabels:{all:"All",code:"Code",config:"Config",docs:"Docs",infra:"Infra",data:"Data",domain:"Domain",knowledge:"Knowledge"},tokenGate:{validating:"Validating...",continue:"Continue"},diffToggle:{hideOverlay:"Hide diff overlay",showOverlay:"Show diff overlay",noData:"No diff data loaded",changed:"Changed",affected:"Affected"},learnPanel:{finish:"Finish",next:"Next",prev:"Prev",noTour:"No tour available",noTourHint:"Generate a tour from your knowledge graph to get a guided walkthrough",projectTour:"Project Tour",steps:"steps",stepsTitle:"Steps",guidedWalkthrough:"Guided walkthrough of the codebase",startTour:"Start Tour",tour:"Tour",exitTour:"Exit Tour"},layer:{defaultName:"Layer",label:"layers"},breadcrumb:{projectOverview:"Project Overview",project:"Project",escBack:"Esc to go back"},warningBanner:{dropped:"Dropped",fatal:"Fatal"},themePicker:{changeTheme:"Change theme",theme:"Theme",accentColor:"Accent Color",headingFont:"Heading Font",serif:"Serif",sans:"Sans",mono:"Mono"},codeViewer:{fullFile:"Full file",lines:"Lines",linesLabel:"lines",noFile:"No file selected",loading:"Loading source...",openLarger:"Open larger code viewer",closeExpanded:"Close expanded code viewer",closeViewer:"Close code viewer",sourceUnavailable:"Source unavailable"},customNode:{tested:"Tested",hasTests:"Has tests"},ariaLabels:{openMenu:"Open menu",closeMenu:"Close menu",settings:"Settings",hideSearch:"Hide search",showSearch:"Show search"},nodeTypeFilter:{hide:"Hide",show:"Show",nodesLabel:"nodes"},keyboardShortcuts:{showHelp:"Show keyboard shortcuts",general:"General",navigation:"Navigation",tour:"Tour",view:"View",focusSearch:"Focus search bar",nextStep:"Next tour step",prevStep:"Previous tour step",toggleDiff:"Toggle diff mode",toggleFilter:"Toggle filter panel",toggleExport:"Toggle export menu",openPathFinder:"Open path finder",title:"Keyboard Shortcuts",toggleHint:"Press ? anytime to toggle this help",closeHint:"Press ESC to close",escapeDesc:"Close panels and modals / go back to overview"},search:{placeholder:"Search nodes by name, summary, or tags...",fuzzy:"Fuzzy",semantic:"Semantic",result:"result"},export:{label:"Export",title:"Export graph (E)",asPNG:"Export as PNG",asSVG:"Export as SVG",asJSON:"Export as JSON"},edgeLabels:{imports:{forward:"imports",backward:"imported by"},exports:{forward:"exports to",backward:"exported by"},contains:{forward:"contains",backward:"contained in"},inherits:{forward:"inherits from",backward:"inherited by"},implements:{forward:"implements",backward:"implemented by"},calls:{forward:"calls",backward:"called by"},subscribes:{forward:"subscribes to",backward:"subscribed by"},publishes:{forward:"publishes to",backward:"consumed by"},middleware:{forward:"middleware for",backward:"uses middleware"},reads_from:{forward:"reads from",backward:"read by"},writes_to:{forward:"writes to",backward:"written by"},transforms:{forward:"transforms",backward:"transformed by"},validates:{forward:"validates",backward:"validated by"},depends_on:{forward:"depends on",backward:"depended on by"},tested_by:{forward:"tested by",backward:"tests"},configures:{forward:"configures",backward:"configured by"},related:{forward:"related to",backward:"related to"},similar_to:{forward:"similar to",backward:"similar to"},deploys:{forward:"deploys",backward:"deployed by"},serves:{forward:"serves",backward:"served by"},migrates:{forward:"migrates",backward:"migrated by"},documents:{forward:"documents",backward:"documented by"},provisions:{forward:"provisions",backward:"provisioned by"},routes:{forward:"routes to",backward:"routed from"},defines_schema:{forward:"defines schema for",backward:"schema defined by"},triggers:{forward:"triggers",backward:"triggered by"},contains_flow:{forward:"contains flow",backward:"flow in"},flow_step:{forward:"flow step",backward:"step of"},cross_domain:{forward:"cross-domain to",backward:"cross-domain from"},cites:{forward:"cites",backward:"cited by"},contradicts:{forward:"contradicts",backward:"contradicted by"},builds_on:{forward:"builds on",backward:"built upon by"},exemplifies:{forward:"exemplifies",backward:"exemplified by"},categorized_under:{forward:"categorized under",backward:"categorizes"},authored_by:{forward:"authored by",backward:"authored"}},pathFinder:{title:"Find path between nodes (P)"},onboarding:{header:"UNDERSTAND-ANYTHING · GET STARTED",skipForever:"Don't show again",prev:"Previous",next:"Next",finish:"Start exploring",steps:[{title:"Welcome to the knowledge graph",body:"The dots and lines you see are entities and relations Understand-Anything extracted from this project. A node can be a file, class, or function from the code — or a concept, entity, or claim from a knowledge wiki.",hint:"Five steps to cover the core operations"},{title:"Three views at the top",body:"Overview shows the big picture (force-directed). Learn follows a preset learning path. Deep Dive shows type and complexity stats. Each view answers a different question.",hint:"Decide what you're asking before you switch"},{title:"Search + click a node",body:"The top search box fuzzy-matches node name / summary / tags. Click any node and the right panel opens with summary, neighbors, and Open Article.",hint:"Search centers and highlights; clicking a node highlights its edges"},{title:"Layer switch + Project Tour",body:"The layer tabs next to All filter the graph to one category, sourced from index.md. Project Tour on the right walks you through the editor's preset sequence.",hint:"Use Layer when nodes are too dense; start Tour when you have no entry point"},{title:"More hidden features",body:"The top bar also has Filter (by type / complexity), Export (export the graph), Path (find a path between two nodes), and Theme. Press Shift + ? for the full keyboard shortcuts.",hint:"Expand them when you need them — no need to memorize all at once"}]}},pl={common:{loading:"加载项目...",noGraphLoaded:"未加载知识图谱",selectNode:"选择节点查看详情",back:"返回",focus:"聚焦",unfocus:"取消聚焦",openCode:"打开代码",file:"文件",tags:"标签",connections:"连接",filter:"筛选",resetAll:"重置全部",analyzed:"分析时间",startGuidedTour:"开始导览",truncated:"(已截断)",preview:"预览",doubleClickToOpen:"双击打开",appName:"Understand Anything",pressKeyboard:"按 ? 查看键盘快捷键",path:"路径",theme:"主题"},projectOverview:{nodes:"节点",edges:"边",layers:"层级",types:"类型",fileTypes:"文件类型",code:"代码",config:"配置",docs:"文档",infra:"基础设施",data:"数据",domain:"领域",knowledge:"知识",languages:"编程语言",frameworks:"框架",nodeTypeDistribution:"节点类型分布",complexityDistribution:"复杂度分布",simple:"简单",moderate:"中等",complex:"复杂",mostConnectedNodes:"连接最多的节点",avgConnectionsPerNode:"节点平均连接数"},nodeInfo:{definedInThisFile:"在此文件中定义",languageConcepts:"语言概念",category:"分类",wikilinks:"维基链接",backlinks:"反向链接",entities:"实体",businessRules:"业务规则",crossDomain:"跨领域",flows:"流程",entryPoint:"入口点",steps:"步骤",implementation:"实现"},fileExplorer:{analyzedFiles:"已分析文件",filesFromGraph:"来自当前知识图谱的文件",noFilePathsFound:"未找到文件路径。"},filterPanel:{nodeTypes:"节点类型",complexity:"复杂度",layers:"层级",edgeCategories:"边类别"},personaSelector:{overview:"概览",overviewDesc:"高层次架构视图",learn:"学习",learnDesc:"完整仪表盘与导览学习",deepDive:"深入",deepDiveDesc:"代码聚焦与对话"},sidebar:{info:"信息",files:"文件"},mobile:{graph:"图谱",info:"信息",files:"文件"},drawer:{controls:"控制",dashboard:"仪表盘",role:"角色",view:"视图",diffOverlay:"差异覆盖",nodeTypes:"节点类型",layers:"层级",tools:"工具",path:"路径",help:"帮助",structural:"结构",domain:"领域"},domainView:{backToDomains:"返回领域列表"},detailLevel:{filesTitle:"仅文件 — 架构级依赖(快速)",classesTitle:"文件 + 类 — 代码结构及继承关系",files:"文件",classes:"+类",fnTitle:"切换函数节点(可能降低渲染速度)",fn:"函数"},nodeTypeLabels:{all:"全部",code:"代码",config:"配置",docs:"文档",infra:"基础设施",data:"数据",domain:"领域",knowledge:"知识"},tokenGate:{validating:"验证中...",continue:"继续"},diffToggle:{hideOverlay:"隐藏差异覆盖",showOverlay:"显示差异覆盖",noData:"未加载差异数据",changed:"已修改",affected:"受影响"},learnPanel:{finish:"完成",next:"下一步",prev:"上一步",noTour:"无导览可用",noTourHint:"从知识图谱生成导览以获取代码库的引导式讲解",projectTour:"项目导览",steps:"步",stepsTitle:"步骤",guidedWalkthrough:"代码库引导式讲解",startTour:"开始导览",tour:"导览",exitTour:"退出导览"},layer:{defaultName:"层级",label:"层"},breadcrumb:{projectOverview:"项目概览",project:"项目",escBack:"按 Esc 返回"},warningBanner:{dropped:"已丢弃",fatal:"致命错误"},themePicker:{changeTheme:"更换主题",theme:"主题",accentColor:"强调色",headingFont:"标题字体",serif:"衬线",sans:"无衬线",mono:"等宽"},codeViewer:{fullFile:"完整文件",lines:"行",linesLabel:"行",noFile:"未选择文件",loading:"加载源码中...",openLarger:"打开更大的代码查看器",closeExpanded:"关闭展开的代码查看器",closeViewer:"关闭代码查看器",sourceUnavailable:"源码不可用"},customNode:{tested:"已测试",hasTests:"有测试"},ariaLabels:{openMenu:"打开菜单",closeMenu:"关闭菜单",settings:"设置",hideSearch:"隐藏搜索",showSearch:"显示搜索"},nodeTypeFilter:{hide:"隐藏",show:"显示",nodesLabel:"节点"},keyboardShortcuts:{showHelp:"显示键盘快捷键",general:"通用",navigation:"导航",tour:"导览",view:"视图",focusSearch:"聚焦搜索栏",nextStep:"下一步导览",prevStep:"上一步导览",toggleDiff:"切换差异模式",toggleFilter:"切换筛选面板",toggleExport:"切换导出菜单",openPathFinder:"打开路径查找器",title:"键盘快捷键",toggleHint:"按 ? 随时切换此帮助",closeHint:"按 ESC 关闭",escapeDesc:"关闭面板和弹窗 / 返回概览"},search:{placeholder:"搜索节点名称、摘要或标签...",fuzzy:"模糊",semantic:"语义",result:"结果"},export:{label:"导出",title:"导出图谱 (E)",asPNG:"导出为 PNG",asSVG:"导出为 SVG",asJSON:"导出为 JSON"},edgeLabels:{imports:{forward:"导入",backward:"被导入"},exports:{forward:"导出到",backward:"被导出"},contains:{forward:"包含",backward:"被包含"},inherits:{forward:"继承自",backward:"被继承"},implements:{forward:"实现",backward:"被实现"},calls:{forward:"调用",backward:"被调用"},subscribes:{forward:"订阅",backward:"被订阅"},publishes:{forward:"发布到",backward:"被消费"},middleware:{forward:"中间件",backward:"使用中间件"},reads_from:{forward:"读取",backward:"被读取"},writes_to:{forward:"写入",backward:"被写入"},transforms:{forward:"转换",backward:"被转换"},validates:{forward:"验证",backward:"被验证"},depends_on:{forward:"依赖",backward:"被依赖"},tested_by:{forward:"被测试",backward:"测试"},configures:{forward:"配置",backward:"被配置"},related:{forward:"相关",backward:"相关"},similar_to:{forward:"相似",backward:"相似"},deploys:{forward:"部署",backward:"被部署"},serves:{forward:"服务",backward:"被服务"},migrates:{forward:"迁移",backward:"被迁移"},documents:{forward:"文档化",backward:"被文档化"},provisions:{forward:"提供",backward:"被提供"},routes:{forward:"路由到",backward:"被路由"},defines_schema:{forward:"定义架构",backward:"架构被定义"},triggers:{forward:"触发",backward:"被触发"},contains_flow:{forward:"包含流程",backward:"流程所在"},flow_step:{forward:"流程步骤",backward:"步骤所属"},cross_domain:{forward:"跨领域到",backward:"跨领域来自"},cites:{forward:"引用",backward:"被引用"},contradicts:{forward:"反驳",backward:"被反驳"},builds_on:{forward:"基于",backward:"作为基础"},exemplifies:{forward:"例证",backward:"被例证"},categorized_under:{forward:"归类于",backward:"归类"},authored_by:{forward:"作者",backward:"著作"}},pathFinder:{title:"查找节点间路径 (P)"},onboarding:{header:"UNDERSTAND-ANYTHING · 入门",skipForever:"不再显示",prev:"上一步",next:"下一步",finish:"开始探索",steps:[{title:"欢迎进入知识图",body:"你看到的圆点和连线是 Understand-Anything 把这份项目抽出来的实体和关系。节点可以是代码里的文件、类、函数,也可以是知识 wiki 里的概念、实体或断言。",hint:"5 步以内带你过完核心操作"},{title:"顶部三个视图",body:"Overview 看全貌(力导向图)· Learn 跟随预设学习路径 · Deep Dive 看类型 / 复杂度统计。每个视图回答一种不同的问法。",hint:"切视图前先想清楚自己在问什么"},{title:"搜索 + 点节点",body:"顶部搜索框模糊匹配节点名 / summary / tags。点任意节点 → 右侧详情面板出现 summary + 邻居列表 + Open Article 按钮。",hint:"搜索高亮居中,点节点高亮邻居边"},{title:"Layer 切换 + Tour",body:"顶部 All 旁边的 layer 标签按 index.md 分类只显示部分节点。右侧 Project Tour 自动按编辑者预设顺序导览。",hint:"节点太密看不清就用 Layer,没头绪就启 Tour"},{title:"更多隐藏功能",body:"顶栏还有 Filter(按类型 / 复杂度过滤)、Export(导出图)、Path(找两个节点之间的路径)、Theme(切换主题)。Shift + ? 看完整快捷键。",hint:"需要时再展开,不要一次记完"}]}},hl={common:{loading:"載入專案...",noGraphLoaded:"未載入知識圖谱",selectNode:"選擇節點查看詳情",back:"返回",focus:"聚焦",unfocus:"取消聚焦",openCode:"開啟程式碼",file:"檔案",tags:"標籤",connections:"連結",filter:"篩選",resetAll:"重置全部",analyzed:"分析時間",startGuidedTour:"開始導覽",truncated:"(已截斷)",preview:"預覽",doubleClickToOpen:"雙擊開啟",appName:"Understand Anything",pressKeyboard:"按 ? 查看鍵盤快捷鍵",path:"路徑",theme:"主題"},projectOverview:{nodes:"節點",edges:"邊",layers:"層級",types:"類型",fileTypes:"檔案類型",code:"程式碼",config:"配置",docs:"文件",infra:"基礎設施",data:"資料",domain:"領域",knowledge:"知識",languages:"程式語言",frameworks:"框架",nodeTypeDistribution:"節點類型分布",complexityDistribution:"複雜度分布",simple:"簡單",moderate:"中等",complex:"複雜",mostConnectedNodes:"連結最多的節點",avgConnectionsPerNode:"節點平均連結數"},nodeInfo:{definedInThisFile:"在此檔案中定義",languageConcepts:"語言概念",category:"分類",wikilinks:"維基連結",backlinks:"反向連結",entities:"實體",businessRules:"業務規則",crossDomain:"跨領域",flows:"流程",entryPoint:"入口點",steps:"步驟",implementation:"實作"},fileExplorer:{analyzedFiles:"已分析檔案",filesFromGraph:"來自目前知識圖谱的檔案",noFilePathsFound:"未找到檔案路徑。"},filterPanel:{nodeTypes:"節點類型",complexity:"複雜度",layers:"層級",edgeCategories:"邊類別"},personaSelector:{overview:"概覽",overviewDesc:"高層次架構視圖",learn:"學習",learnDesc:"完整儀表板與導覽學習",deepDive:"深入",deepDiveDesc:"程式碼聚焦與對話"},sidebar:{info:"資訊",files:"檔案"},mobile:{graph:"圖谱",info:"資訊",files:"檔案"},drawer:{controls:"控制",dashboard:"儀表板",role:"角色",view:"視圖",diffOverlay:"差異覆蓋",nodeTypes:"節點類型",layers:"層級",tools:"工具",path:"路徑",help:"幫助",structural:"結構",domain:"領域"},domainView:{backToDomains:"返回領域列表"},detailLevel:{filesTitle:"僅檔案 — 架構級依賴(快速)",classesTitle:"檔案 + 類別 — 程式碼結構及繼承關係",files:"檔案",classes:"+類別",fnTitle:"切換函數節點(可能降低渲染速度)",fn:"函數"},nodeTypeLabels:{all:"全部",code:"程式碼",config:"配置",docs:"文件",infra:"基礎設施",data:"資料",domain:"領域",knowledge:"知識"},tokenGate:{validating:"驗證中...",continue:"繼續"},diffToggle:{hideOverlay:"隱藏差異覆蓋",showOverlay:"顯示差異覆蓋",noData:"未載入差異資料",changed:"已修改",affected:"受影響"},learnPanel:{finish:"完成",next:"下一步",prev:"上一步",noTour:"無導覽可用",noTourHint:"從知識圖谱生成導覽以獲取程式碼庫的引導式講解",projectTour:"專案導覽",steps:"步",stepsTitle:"步驟",guidedWalkthrough:"程式碼庫引導式講解",startTour:"開始導覽",tour:"導覽",exitTour:"退出導覽"},layer:{defaultName:"層級",label:"層"},breadcrumb:{projectOverview:"專案概覽",project:"專案",escBack:"按 Esc 返回"},warningBanner:{dropped:"已捨棄",fatal:"致命錯誤"},themePicker:{changeTheme:"變更主題",theme:"主題",accentColor:"強調色",headingFont:"標題字型",serif:"襯線",sans:"無襯線",mono:"等寬"},codeViewer:{fullFile:"完整檔案",lines:"行",linesLabel:"行",noFile:"未選擇檔案",loading:"載入原始碼中...",openLarger:"開啟更大的程式碼檢視器",closeExpanded:"關閉展開的程式碼檢視器",closeViewer:"關閉程式碼檢視器",sourceUnavailable:"原始碼不可用"},customNode:{tested:"已測試",hasTests:"有測試"},ariaLabels:{openMenu:"開啟選單",closeMenu:"關閉選單",settings:"設定",hideSearch:"隱藏搜尋",showSearch:"顯示搜尋"},nodeTypeFilter:{hide:"隱藏",show:"顯示",nodesLabel:"節點"},keyboardShortcuts:{showHelp:"顯示鍵盤快捷鍵",general:"一般",navigation:"導航",tour:"導覽",view:"檢視",focusSearch:"聚焦搜尋列",nextStep:"下一步導覽",prevStep:"上一步導覽",toggleDiff:"切換差異模式",toggleFilter:"切換篩選面板",toggleExport:"切換匯出選單",openPathFinder:"開啟路徑尋找器",title:"鍵盤快捷鍵",toggleHint:"按 ? 隨時切換此幫助",closeHint:"按 ESC 關閉",escapeDesc:"關閉面板和彈窗 / 返回概覽"},search:{placeholder:"搜尋節點名稱、摘要或標籤...",fuzzy:"模糊",semantic:"語意",result:"結果"},export:{label:"匯出",title:"匯出圖谱 (E)",asPNG:"匯出為 PNG",asSVG:"匯出為 SVG",asJSON:"匯出為 JSON"},edgeLabels:{imports:{forward:"導入",backward:"被導入"},exports:{forward:"導出到",backward:"被導出"},contains:{forward:"包含",backward:"被包含"},inherits:{forward:"繼承自",backward:"被繼承"},implements:{forward:"實作",backward:"被實作"},calls:{forward:"呼叫",backward:"被呼叫"},subscribes:{forward:"訂閱",backward:"被訂閱"},publishes:{forward:"發布到",backward:"被消費"},middleware:{forward:"中介軟體",backward:"使用中介軟體"},reads_from:{forward:"讀取",backward:"被讀取"},writes_to:{forward:"寫入",backward:"被寫入"},transforms:{forward:"轉換",backward:"被轉換"},validates:{forward:"驗證",backward:"被驗證"},depends_on:{forward:"依賴",backward:"被依賴"},tested_by:{forward:"被測試",backward:"測試"},configures:{forward:"配置",backward:"被配置"},related:{forward:"相關",backward:"相關"},similar_to:{forward:"相似",backward:"相似"},deploys:{forward:"部署",backward:"被部署"},serves:{forward:"服務",backward:"被服務"},migrates:{forward:"遷移",backward:"被遷移"},documents:{forward:"文件化",backward:"被文件化"},provisions:{forward:"提供",backward:"被提供"},routes:{forward:"路由到",backward:"被路由"},defines_schema:{forward:"定義架構",backward:"架構被定義"},triggers:{forward:"觸發",backward:"被觸發"},contains_flow:{forward:"包含流程",backward:"流程所在"},flow_step:{forward:"流程步驟",backward:"步驟所属"},cross_domain:{forward:"跨領域到",backward:"跨領域来自"},cites:{forward:"引用",backward:"被引用"},contradicts:{forward:"反駁",backward:"被反駁"},builds_on:{forward:"基於",backward:"作為基礎"},exemplifies:{forward:"例證",backward:"被例證"},categorized_under:{forward:"归类於",backward:"归类"},authored_by:{forward:"作者",backward:"著作"}},pathFinder:{title:"尋找節點間路徑 (P)"},onboarding:{header:"UNDERSTAND-ANYTHING · 入門",skipForever:"不再顯示",prev:"上一步",next:"下一步",finish:"開始探索",steps:[{title:"歡迎進入知識圖",body:"你看到的圓點和連線是 Understand-Anything 把這份專案抽出來的實體和關係。節點可以是程式碼裡的檔案、類別、函式,也可以是知識 wiki 裡的概念、實體或斷言。",hint:"5 步以內帶你過完核心操作"},{title:"頂部三個視圖",body:"Overview 看全貌(力導向圖)· Learn 跟隨預設學習路徑 · Deep Dive 看類型 / 複雜度統計。每個視圖回答一種不同的問法。",hint:"切視圖前先想清楚自己在問什麼"},{title:"搜尋 + 點節點",body:"頂部搜尋框模糊匹配節點名 / summary / tags。點任意節點 → 右側詳情面板出現 summary + 鄰居列表 + Open Article 按鈕。",hint:"搜尋高亮置中,點節點高亮鄰居邊"},{title:"Layer 切換 + Tour",body:"頂部 All 旁邊的 layer 標籤按 index.md 分類只顯示部分節點。右側 Project Tour 自動按編輯者預設順序導覽。",hint:"節點太密看不清就用 Layer,沒頭緒就啟 Tour"},{title:"更多隱藏功能",body:"頂欄還有 Filter(按類型 / 複雜度過濾)、Export(匯出圖)、Path(找兩個節點之間的路徑)、Theme(切換主題)。Shift + ? 看完整快捷鍵。",hint:"需要時再展開,不要一次記完"}]}},ml={common:{loading:"プロジェクトを読み込み中...",noGraphLoaded:"知識グラフが読み込まれていません",selectNode:"ノードを選択して詳細を表示",back:"戻る",focus:"フォーカス",unfocus:"フォーカス解除",openCode:"コードを開く",file:"ファイル",tags:"タグ",connections:"接続",filter:"フィルター",resetAll:"すべてリセット",analyzed:"分析日時",startGuidedTour:"ガイド付きツアーを開始",truncated:"(省略)",preview:"プレビュー",doubleClickToOpen:"ダブルクリックで開く",appName:"Understand Anything",pressKeyboard:"? を押してキーボードショートカットを表示",path:"パス",theme:"テーマ"},projectOverview:{nodes:"ノード",edges:"エッジ",layers:"レイヤー",types:"タイプ",fileTypes:"ファイルタイプ",code:"コード",config:"設定",docs:"ドキュメント",infra:"インフラ",data:"データ",domain:"ドメイン",knowledge:"ナレッジ",languages:"プログラミング言語",frameworks:"フレームワーク",nodeTypeDistribution:"ノードタイプ分布",complexityDistribution:"複雑度分布",simple:"単純",moderate:"中程度",complex:"複雑",mostConnectedNodes:"最も接続されているノード",avgConnectionsPerNode:"ノード平均接続数"},nodeInfo:{definedInThisFile:"このファイルで定義",languageConcepts:"言語概念",category:"カテゴリ",wikilinks:"Wikilinks",backlinks:"Backlinks",entities:"エンティティ",businessRules:"ビジネスルール",crossDomain:"クロスドメイン",flows:"フロー",entryPoint:"エントリポイント",steps:"ステップ",implementation:"実装"},fileExplorer:{analyzedFiles:"分析済みファイル",filesFromGraph:"現在の知識グラフからのファイル",noFilePathsFound:"ファイルパスが見つかりません。"},filterPanel:{nodeTypes:"ノードタイプ",complexity:"複雑度",layers:"レイヤー",edgeCategories:"エッジカテゴリ"},personaSelector:{overview:"概要",overviewDesc:"高レベルアーキテクチャビュー",learn:"学習",learnDesc:"ガイド付き学習付き完全ダッシュボード",deepDive:"詳細",deepDiveDesc:"コード中心のチャット"},sidebar:{info:"情報",files:"ファイル"},mobile:{graph:"グラフ",info:"情報",files:"ファイル"},drawer:{controls:"コントロール",dashboard:"ダッシュボード",role:"ロール",view:"ビュー",diffOverlay:"差分オーバーレイ",nodeTypes:"ノードタイプ",layers:"レイヤー",tools:"ツール",path:"パス",help:"ヘルプ",structural:"構造",domain:"ドメイン"},domainView:{backToDomains:"ドメインに戻る"},detailLevel:{filesTitle:"ファイルのみ — アーキテクチャレベルの依存関係(高速)",classesTitle:"ファイル + クラス — 継承を含むコード構造",files:"ファイル",classes:"+クラス",fnTitle:"関数ノードを切り替え(レンダリングが遅くなる可能性)",fn:"fn"},nodeTypeLabels:{all:"すべて",code:"コード",config:"設定",docs:"ドキュメント",infra:"インフラ",data:"データ",domain:"ドメイン",knowledge:"ナレッジ"},tokenGate:{validating:"検証中...",continue:"続行"},diffToggle:{hideOverlay:"差分オーバーレイを非表示",showOverlay:"差分オーバーレイを表示",noData:"差分データが読み込まれていません",changed:"変更済み",affected:"影響あり"},learnPanel:{finish:"完了",next:"次へ",prev:"前へ",noTour:"ツアーがありません",noTourHint:"知識グラフからツアーを生成してコードベースのガイド付きウォークスルーを取得",projectTour:"プロジェクトツアー",steps:"ステップ",stepsTitle:"ステップ",guidedWalkthrough:"コードベースのガイド付きウォークスルー",startTour:"ツアー開始",tour:"ツアー",exitTour:"ツアー終了"},layer:{defaultName:"レイヤー",label:"レイヤー"},breadcrumb:{projectOverview:"プロジェクト概要",project:"プロジェクト",escBack:"Escで戻る"},warningBanner:{dropped:"削除済み",fatal:"致命的"},themePicker:{changeTheme:"テーマ変更",theme:"テーマ",accentColor:"アクセント色",headingFont:"見出しフォント",serif:"セリフ",sans:"サン",mono:"モノ"},codeViewer:{fullFile:"ファイル全体",lines:"行",linesLabel:"行",noFile:"ファイル未選択",loading:"ソース読み込み中...",openLarger:"大きなコードビューアを開く",closeExpanded:"展開したコードビューアを閉じる",closeViewer:"コードビューアを閉じる",sourceUnavailable:"ソースが利用できません"},customNode:{tested:"テスト済み",hasTests:"テストあり"},ariaLabels:{openMenu:"メニューを開く",closeMenu:"メニューを閉じる",settings:"設定",hideSearch:"検索を非表示",showSearch:"検索を表示"},nodeTypeFilter:{hide:"非表示",show:"表示",nodesLabel:"ノード"},keyboardShortcuts:{showHelp:"キーボードショートカットを表示",general:"一般",navigation:"ナビゲーション",tour:"ツアー",view:"ビュー",focusSearch:"検索バーにフォーカス",nextStep:"次のツアーステップ",prevStep:"前のツアーステップ",toggleDiff:"差分モード切り替え",toggleFilter:"フィルターパネル切り替え",toggleExport:"エクスポートメニュー切り替え",openPathFinder:"パスファインダーを開く",title:"キーボードショートカット",toggleHint:"いつでも ? を押してこのヘルプを切り替え",closeHint:"ESC を押して閉じる",escapeDesc:"パネルとモーダルを閉じる / 概要に戻る"},search:{placeholder:"ノード名、概要、タグで検索...",fuzzy:"ファジー",semantic:"セマンティック",result:"結果"},export:{label:"エクスポート",title:"グラフをエクスポート (E)",asPNG:"PNGでエクスポート",asSVG:"SVGでエクスポート",asJSON:"JSONでエクスポート"},edgeLabels:{imports:{forward:"インポート",backward:"インポートされる"},exports:{forward:"エクスポート",backward:"エクスポートされる"},contains:{forward:"含む",backward:"含まれる"},inherits:{forward:"継承",backward:"継承される"},implements:{forward:"実装",backward:"実装される"},calls:{forward:"呼び出す",backward:"呼び出される"},subscribes:{forward:"購読",backward:"購読される"},publishes:{forward:"公開",backward:"消費される"},middleware:{forward:"ミドルウェア",backward:"ミドルウェアを使用"},reads_from:{forward:"読み取り",backward:"読み取られる"},writes_to:{forward:"書き込み",backward:"書き込まれる"},transforms:{forward:"変換",backward:"変換される"},validates:{forward:"検証",backward:"検証される"},depends_on:{forward:"依存",backward:"依存される"},tested_by:{forward:"テストされる",backward:"テスト"},configures:{forward:"設定",backward:"設定される"},related:{forward:"関連",backward:"関連"},similar_to:{forward:"類似",backward:"類似"},deploys:{forward:"デプロイ",backward:"デプロイされる"},serves:{forward:"提供",backward:"提供される"},migrates:{forward:"移行",backward:"移行される"},documents:{forward:"ドキュメント化",backward:"ドキュメント化される"},provisions:{forward:"提供",backward:"提供される"},routes:{forward:"ルーティング",backward:"ルーティングされる"},defines_schema:{forward:"スキーマ定義",backward:"スキーマ定義される"},triggers:{forward:"トリガー",backward:"トリガーされる"},contains_flow:{forward:"フローを含む",backward:"フロー内"},flow_step:{forward:"フローステップ",backward:"ステップの"},cross_domain:{forward:"クロスドメイン",backward:"クロスドメインから"},cites:{forward:"引用",backward:"引用される"},contradicts:{forward:"矛盾",backward:"矛盾される"},builds_on:{forward:"基礎",backward:"基礎となる"},exemplifies:{forward:"例示",backward:"例示される"},categorized_under:{forward:"カテゴリ化",backward:"カテゴリ化する"},authored_by:{forward:"作成者",backward:"作成"}},pathFinder:{title:"ノード間のパスを検索 (P)"},onboarding:{header:"UNDERSTAND-ANYTHING · はじめに",skipForever:"次回から表示しない",prev:"前へ",next:"次へ",finish:"探索を始める",steps:[{title:"知識グラフへようこそ",body:"表示されているノードとエッジは、Understand-Anything がこのプロジェクトから抽出したエンティティと関係です。ノードはコード側のファイル・クラス・関数のこともあれば、知識 wiki 側の概念・エンティティ・記述のこともあります。",hint:"5 ステップで主要な操作を確認します"},{title:"上部の 3 つのビュー",body:"Overview は全体像(力学的レイアウト)、Learn はあらかじめ用意された学習パス、Deep Dive はタイプ / 複雑度の統計を表示します。それぞれ異なる問いに答えるためのビューです。",hint:"切り替える前に、何を知りたいかを明確に"},{title:"検索 + ノードクリック",body:"上部の検索ボックスはノード名 / summary / タグをあいまい検索します。任意のノードをクリックすると、右側のパネルに summary、隣接ノード、Open Article ボタンが表示されます。",hint:"検索はノードを中央寄せ・ハイライト、クリックは隣接エッジをハイライトします"},{title:"Layer 切替 + Project Tour",body:"上部 All の隣にある layer タブは index.md に基づいて 1 つのカテゴリだけを表示します。右側の Project Tour は編集者が用意した順序でガイドします。",hint:"ノードが多すぎるときは Layer、入り口がわからないときは Tour"},{title:"その他の隠れた機能",body:"上部バーには Filter(タイプ / 複雑度で絞り込み)、Export(グラフを書き出す)、Path(2 つのノード間のパスを検索)、Theme(テーマ切替)もあります。Shift + ? で全キーボードショートカットを確認できます。",hint:"必要になったときに開けば十分。一度に覚える必要はありません"}]}},gl={common:{loading:"프로젝트 로딩 중...",noGraphLoaded:"지식 그래프가 로드되지 않음",selectNode:"노드를 선택하여 상세 정보 확인",back:"뒤로",focus:"포커스",unfocus:"포커스 해제",openCode:"코드 열기",file:"파일",tags:"태그",connections:"연결",filter:"필터",resetAll:"모두 재설정",analyzed:"분석 시간",startGuidedTour:"가이드 투어 시작",truncated:"(생략)",preview:"미리보기",doubleClickToOpen:"두 번 클릭하여 열기",appName:"Understand Anything",pressKeyboard:"? 키를 눌러 키보드 단축키 보기",path:"경로",theme:"테마"},projectOverview:{nodes:"노드",edges:"엣지",layers:"레이어",types:"타입",fileTypes:"파일 타입",code:"코드",config:"설정",docs:"문서",infra:"인프라",data:"데이터",domain:"도메인",knowledge:"지식",languages:"프로그래밍 언어",frameworks:"프레임워크",nodeTypeDistribution:"노드 타입 분포",complexityDistribution:"복잡도 분포",simple:"단순",moderate:"중간",complex:"복잡",mostConnectedNodes:"가장 많이 연결된 노드",avgConnectionsPerNode:"노드 평균 연결 수"},nodeInfo:{definedInThisFile:"이 파일에 정義",languageConcepts:"언어 개념",category:"카테고리",wikilinks:"Wikilinks",backlinks:"Backlinks",entities:"엔티티",businessRules:"비즈니스 규칙",crossDomain:"크로스 도메인",flows:"플로우",entryPoint:"진입점",steps:"단계",implementation:"구현"},fileExplorer:{analyzedFiles:"분석된 파일",filesFromGraph:"현재 지식 그래프의 파일",noFilePathsFound:"파일 경로를 찾을 수 없습니다."},filterPanel:{nodeTypes:"노드 타입",complexity:"복잡도",layers:"레이어",edgeCategories:"엣지 카테고리"},personaSelector:{overview:"개요",overviewDesc:"고수준 아키텍처 뷰",learn:"학습",learnDesc:"가이드 학습 포함 완전 대시보드",deepDive:"심층",deepDiveDesc:"코드 중심 채팅"},sidebar:{info:"정보",files:"파일"},mobile:{graph:"그래프",info:"정보",files:"파일"},drawer:{controls:"컨트롤",dashboard:"대시보드",role:"역할",view:"보기",diffOverlay:"차분 오버레이",nodeTypes:"노드 타입",layers:"레이어",tools:"도구",path:"경로",help:"도움말",structural:"구조",domain:"도메인"},domainView:{backToDomains:"도메인으로 돌아가기"},detailLevel:{filesTitle:"파일만 — 아키텍처 레벨 의존성 (빠름)",classesTitle:"파일 + 클래스 — 상속 포함 코드 구조",files:"파일",classes:"+클래스",fnTitle:"함수 노드 토글 (렌더링 속도 저하 가능)",fn:"fn"},nodeTypeLabels:{all:"모두",code:"코드",config:"설정",docs:"문서",infra:"인프라",data:"데이터",domain:"도메인",knowledge:"지식"},tokenGate:{validating:"검증 중...",continue:"계속"},diffToggle:{hideOverlay:"차분 오버레이 숨기기",showOverlay:"차분 오버레이 표시",noData:"차분 데이터가 로드되지 않음",changed:"변경됨",affected:"영향받음"},learnPanel:{finish:"완료",next:"다음",prev:"이전",noTour:"투어 없음",noTourHint:"지식 그래프에서 투어를 생성하여 코드베이스의 가이드 워크스루를 얻으세요",projectTour:"프로젝트 투어",steps:"단계",stepsTitle:"단계",guidedWalkthrough:"코드베이스 가이드 워크스루",startTour:"투어 시작",tour:"투어",exitTour:"투어 종료"},layer:{defaultName:"레이어",label:"레이어"},breadcrumb:{projectOverview:"프로젝트 개요",project:"프로젝트",escBack:"Esc로 돌아가기"},warningBanner:{dropped:"삭제됨",fatal:"치명적"},themePicker:{changeTheme:"테마 변경",theme:"테마",accentColor:"강조색",headingFont:"제목 폰트",serif:"세리프",sans:"산스",mono:"모노"},codeViewer:{fullFile:"전체 파일",lines:"행",linesLabel:"행",noFile:"파일 선택 안 됨",loading:"소스 로딩 중...",openLarger:"더 큰 코드 뷰어 열기",closeExpanded:"확장된 코드 뷰어 닫기",closeViewer:"코드 뷰어 닫기",sourceUnavailable:"소스 사용 불가"},customNode:{tested:"테스트됨",hasTests:"테스트 있음"},ariaLabels:{openMenu:"메뉴 열기",closeMenu:"메뉴 닫기",settings:"설정",hideSearch:"검색 숨기기",showSearch:"검색 표시"},nodeTypeFilter:{hide:"숨기기",show:"표시",nodesLabel:"노드"},keyboardShortcuts:{showHelp:"키보드 단축키 표시",general:"일반",navigation:"탐색",tour:"투어",view:"보기",focusSearch:"검색창 포커스",nextStep:"다음 투어 단계",prevStep:"이전 투어 단계",toggleDiff:"차분 모드 전환",toggleFilter:"필터 패널 전환",toggleExport:"내보내기 메뉴 전환",openPathFinder:"경로 찾기 열기",title:"키보드 단축키",toggleHint:"언제든 ?를 눌러 이 도움말을 토글",closeHint:"ESC를 눌러 닫기",escapeDesc:"패널 및 모달 닫기 / 개요로 돌아가기"},search:{placeholder:"노드 이름, 요약, 태그로 검색...",fuzzy:"퍼지",semantic:"시맨틱",result:"결과"},export:{label:"내보내기",title:"그래프 내보내기 (E)",asPNG:"PNG로 내보내기",asSVG:"SVG로 내보내기",asJSON:"JSON으로 내보내기"},edgeLabels:{imports:{forward:"임포트",backward:"임포트됨"},exports:{forward:"내보내기",backward:"내보내기됨"},contains:{forward:"포함",backward:"포함됨"},inherits:{forward:"상속",backward:"상속됨"},implements:{forward:"구현",backward:"구현됨"},calls:{forward:"호출",backward:"호출됨"},subscribes:{forward:"구독",backward:"구독됨"},publishes:{forward:"게시",backward:"소비됨"},middleware:{forward:"미들웨어",backward:"미들웨어 사용"},reads_from:{forward:"읽기",backward:"읽기됨"},writes_to:{forward:"쓰기",backward:"쓰기됨"},transforms:{forward:"변환",backward:"변환됨"},validates:{forward:"검증",backward:"검증됨"},depends_on:{forward:"종속",backward:"종속됨"},tested_by:{forward:"테스트됨",backward:"테스트"},configures:{forward:"설정",backward:"설정됨"},related:{forward:"관련",backward:"관련"},similar_to:{forward:"유사",backward:"유사"},deploys:{forward:"배포",backward:"배포됨"},serves:{forward:"서비스",backward:"서비스됨"},migrates:{forward:"마이그레이션",backward:"마이그레이션됨"},documents:{forward:"문서화",backward:"문서화됨"},provisions:{forward:"제공",backward:"제공됨"},routes:{forward:"라우팅",backward:"라우팅됨"},defines_schema:{forward:"스키마 정의",backward:"스키마 정의됨"},triggers:{forward:"트리거",backward:"트리거됨"},contains_flow:{forward:"플로우 포함",backward:"플로우 내"},flow_step:{forward:"플로우 단계",backward:"단계의"},cross_domain:{forward:"크로스 도메인",backward:"크로스 도메인에서"},cites:{forward:"인용",backward:"인용됨"},contradicts:{forward:"반박",backward:"반박됨"},builds_on:{forward:"기반",backward:"기반됨"},exemplifies:{forward:"예시",backward:"예시됨"},categorized_under:{forward:"카테고리화",backward:"카테고리화함"},authored_by:{forward:"작성자",backward:"작성"}},pathFinder:{title:"노드 간 경로 찾기 (P)"},onboarding:{header:"UNDERSTAND-ANYTHING · 시작하기",skipForever:"다시 보지 않기",prev:"이전",next:"다음",finish:"탐색 시작",steps:[{title:"지식 그래프에 오신 것을 환영합니다",body:"보이는 점과 선은 Understand-Anything이 이 프로젝트에서 추출한 엔티티와 관계입니다. 노드는 코드 쪽의 파일·클래스·함수일 수도 있고, 지식 위키 쪽의 개념·엔티티·진술일 수도 있습니다.",hint:"5단계로 핵심 조작을 살펴봅니다"},{title:"상단의 세 가지 뷰",body:"Overview는 전체 모습(포스 디렉티드), Learn은 미리 정의된 학습 경로, Deep Dive는 타입 / 복잡도 통계를 보여줍니다. 각 뷰는 서로 다른 질문에 답합니다.",hint:"전환하기 전에 무엇을 묻고 싶은지 정하세요"},{title:"검색 + 노드 클릭",body:"상단 검색창은 노드 이름 / summary / 태그를 퍼지 매칭합니다. 노드를 클릭하면 오른쪽 패널에 summary, 이웃 목록, Open Article 버튼이 나타납니다.",hint:"검색은 노드를 중앙 정렬·강조하고, 클릭은 인접 엣지를 강조합니다"},{title:"Layer 전환 + Project Tour",body:"상단 All 옆의 layer 탭은 index.md를 기반으로 한 카테고리만 표시합니다. 오른쪽의 Project Tour는 편집자가 설정한 순서대로 안내합니다.",hint:"노드가 너무 빽빽하면 Layer, 시작점이 없으면 Tour를 사용하세요"},{title:"숨겨진 추가 기능",body:"상단 바에는 Filter(타입 / 복잡도로 필터링), Export(그래프 내보내기), Path(두 노드 사이 경로 찾기), Theme(테마 전환)도 있습니다. Shift + ?를 누르면 전체 키보드 단축키를 볼 수 있습니다.",hint:"필요할 때 펼쳐 보면 됩니다. 한 번에 다 외울 필요는 없습니다"}]}},xl={common:{loading:"Загрузка проекта...",noGraphLoaded:"Граф знаний не загружен",selectNode:"Выберите узел, чтобы увидеть подробности",back:"Назад",focus:"Фокус",unfocus:"Снять фокус",openCode:"Открыть код",file:"Файл",tags:"Теги",connections:"Связи",filter:"Фильтр",resetAll:"Сбросить всё",analyzed:"Проанализировано",startGuidedTour:"Начать обзор",truncated:"(сокращено)",preview:"Предпросмотр",doubleClickToOpen:"двойной клик, чтобы открыть",appName:"Understand Anything",pressKeyboard:"Нажмите ? для горячих клавиш",path:"Путь",theme:"Тема"},projectOverview:{nodes:"Узлы",edges:"Рёбра",layers:"Слои",types:"Типы",fileTypes:"Типы файлов",code:"Код",config:"Конфиг",docs:"Документация",infra:"Инфраструктура",data:"Данные",domain:"Домен",knowledge:"Знания",languages:"Языки",frameworks:"Фреймворки",nodeTypeDistribution:"Распределение типов узлов",complexityDistribution:"Распределение сложности",simple:"Простой",moderate:"Средний",complex:"Сложный",mostConnectedNodes:"Самые связанные узлы",avgConnectionsPerNode:"Среднее число связей на узел"},nodeInfo:{definedInThisFile:"Определено в этом файле",languageConcepts:"Концепции языка",category:"Категория",wikilinks:"Wiki-ссылки",backlinks:"Обратные ссылки",entities:"Сущности",businessRules:"Бизнес-правила",crossDomain:"Междоменные связи",flows:"Потоки",entryPoint:"Точка входа",steps:"Шаги",implementation:"Реализация"},fileExplorer:{analyzedFiles:"Проанализированные файлы",filesFromGraph:"файлы из текущего графа знаний",noFilePathsFound:"Пути файлов не найдены."},filterPanel:{nodeTypes:"Типы узлов",complexity:"Сложность",layers:"Слои",edgeCategories:"Категории рёбер"},personaSelector:{overview:"Обзор",overviewDesc:"Высокоуровневый архитектурный вид",learn:"Обучение",learnDesc:"Полная панель с пошаговым обучением",deepDive:"Погружение",deepDiveDesc:"Фокус на коде с чатом"},sidebar:{info:"Информация",files:"Файлы"},mobile:{graph:"Граф",info:"Информация",files:"Файлы"},drawer:{controls:"Управление",dashboard:"Панель",role:"Роль",view:"Вид",diffOverlay:"Наложение изменений",nodeTypes:"Типы узлов",layers:"Слои",tools:"Инструменты",path:"Путь",help:"Помощь",structural:"Структура",domain:"Домен"},domainView:{backToDomains:"Назад к доменам"},detailLevel:{filesTitle:"Только файлы — зависимости архитектурного уровня (быстро)",classesTitle:"Файлы + классы — структура кода с наследованием",files:"Файлы",classes:"+Классы",fnTitle:"Переключить узлы функций (может замедлить отрисовку)",fn:"fn"},nodeTypeLabels:{all:"Все",code:"Код",config:"Конфиг",docs:"Документация",infra:"Инфраструктура",data:"Данные",domain:"Домен",knowledge:"Знания"},tokenGate:{validating:"Проверка...",continue:"Продолжить"},diffToggle:{hideOverlay:"Скрыть наложение изменений",showOverlay:"Показать наложение изменений",noData:"Данные об изменениях не загружены",changed:"Изменено",affected:"Затронуто"},learnPanel:{finish:"Завершить",next:"Далее",prev:"Назад",noTour:"Обзор недоступен",noTourHint:"Сгенерируйте обзор из графа знаний, чтобы получить пошаговое руководство по кодовой базе",projectTour:"Обзор проекта",steps:"шагов",stepsTitle:"Шаги",guidedWalkthrough:"Пошаговое знакомство с кодовой базой",startTour:"Начать обзор",tour:"Обзор",exitTour:"Завершить обзор"},layer:{defaultName:"Слой",label:"слои"},breadcrumb:{projectOverview:"Обзор проекта",project:"Проект",escBack:"Esc — назад"},warningBanner:{dropped:"Отброшено",fatal:"Критично"},themePicker:{changeTheme:"Сменить тему",theme:"Тема",accentColor:"Акцентный цвет",headingFont:"Шрифт заголовков",serif:"Серифный",sans:"Без засечек",mono:"Моноширинный"},codeViewer:{fullFile:"Весь файл",lines:"Строки",linesLabel:"строк",noFile:"Файл не выбран",loading:"Загрузка исходного кода...",openLarger:"Открыть увеличенный просмотрщик кода",closeExpanded:"Закрыть расширенный просмотрщик кода",closeViewer:"Закрыть просмотрщик кода",sourceUnavailable:"Исходный код недоступен"},customNode:{tested:"Покрыт тестами",hasTests:"Есть тесты"},ariaLabels:{openMenu:"Открыть меню",closeMenu:"Закрыть меню",settings:"Настройки",hideSearch:"Скрыть поиск",showSearch:"Показать поиск"},nodeTypeFilter:{hide:"Скрыть",show:"Показать",nodesLabel:"узлов"},keyboardShortcuts:{showHelp:"Показать горячие клавиши",general:"Общие",navigation:"Навигация",tour:"Обзор",view:"Вид",focusSearch:"Перейти к строке поиска",nextStep:"Следующий шаг обзора",prevStep:"Предыдущий шаг обзора",toggleDiff:"Переключить режим изменений",toggleFilter:"Переключить панель фильтров",toggleExport:"Переключить меню экспорта",openPathFinder:"Открыть поиск пути",title:"Горячие клавиши",toggleHint:"Нажмите ?, чтобы открыть или закрыть эту справку",closeHint:"Нажмите ESC, чтобы закрыть",escapeDesc:"Закрыть панели и модальные окна / вернуться к обзору"},search:{placeholder:"Поиск узлов по имени, описанию или тегам...",fuzzy:"Нечёткий",semantic:"Семантический",result:"результат"},export:{label:"Экспорт",title:"Экспортировать граф (E)",asPNG:"Экспортировать как PNG",asSVG:"Экспортировать как SVG",asJSON:"Экспортировать как JSON"},edgeLabels:{imports:{forward:"импортирует",backward:"импортируется"},exports:{forward:"экспортирует в",backward:"экспортируется"},contains:{forward:"содержит",backward:"содержится в"},inherits:{forward:"наследует от",backward:"наследуется"},implements:{forward:"реализует",backward:"реализуется"},calls:{forward:"вызывает",backward:"вызывается"},subscribes:{forward:"подписывается на",backward:"подписан"},publishes:{forward:"публикует в",backward:"получает события"},middleware:{forward:"middleware для",backward:"использует middleware"},reads_from:{forward:"читает из",backward:"читается"},writes_to:{forward:"пишет в",backward:"записывается"},transforms:{forward:"преобразует",backward:"преобразуется"},validates:{forward:"валидирует",backward:"валидируется"},depends_on:{forward:"зависит от",backward:"является зависимостью"},tested_by:{forward:"тестируется",backward:"тестирует"},configures:{forward:"конфигурирует",backward:"конфигурируется"},related:{forward:"связан с",backward:"связан с"},similar_to:{forward:"похож на",backward:"похож на"},deploys:{forward:"разворачивает",backward:"разворачивается"},serves:{forward:"обслуживает",backward:"обслуживается"},migrates:{forward:"мигрирует",backward:"мигрируется"},documents:{forward:"документирует",backward:"документируется"},provisions:{forward:"обеспечивает",backward:"обеспечивается"},routes:{forward:"маршрутизирует в",backward:"маршрутизируется из"},defines_schema:{forward:"определяет схему для",backward:"схема определена"},triggers:{forward:"запускает",backward:"запускается"},contains_flow:{forward:"содержит поток",backward:"поток в"},flow_step:{forward:"шаг потока",backward:"шаг"},cross_domain:{forward:"междоменно к",backward:"междоменно из"},cites:{forward:"цитирует",backward:"цитируется"},contradicts:{forward:"противоречит",backward:"опровергается"},builds_on:{forward:"основан на",backward:"основа для"},exemplifies:{forward:"иллюстрирует",backward:"иллюстрируется"},categorized_under:{forward:"относится к",backward:"категоризирует"},authored_by:{forward:"автор",backward:"автор"}},pathFinder:{title:"Найти путь между узлами (P)"},onboarding:{header:"UNDERSTAND-ANYTHING · НАЧАЛО РАБОТЫ",skipForever:"Больше не показывать",prev:"Назад",next:"Далее",finish:"Начать исследование",steps:[{title:"Добро пожаловать в граф знаний",body:"Точки и линии — это сущности и связи, извлечённые Understand-Anything из этого проекта. Узлом может быть файл, класс или функция из кода — либо концепция, сущность или утверждение из вики знаний.",hint:"Пять шагов охватят основные операции"},{title:"Три вида сверху",body:"Overview показывает общую картину (force-directed). Learn ведёт по заранее заданному учебному пути. Deep Dive показывает статистику по типам и сложности. Каждый вид отвечает на свой вопрос.",hint:"Перед переключением определитесь, о чём вы спрашиваете"},{title:"Поиск + клик по узлу",body:"Поисковая строка сверху делает нечёткое совпадение по имени узла, summary и тегам. Кликните по узлу — справа откроется панель с summary, соседями и кнопкой Open Article.",hint:"Поиск центрирует и подсвечивает; клик подсвечивает соседние рёбра"},{title:"Переключение Layer + Project Tour",body:"Вкладки layer рядом с All фильтруют граф по одной категории на основе index.md. Project Tour справа проводит вас по заранее заданной последовательности.",hint:"Используйте Layer, когда узлов слишком много; запустите Tour, если непонятно с чего начать"},{title:"Другие скрытые возможности",body:"В верхней панели также есть Filter (фильтр по типу / сложности), Export (экспорт графа), Path (поиск пути между двумя узлами) и Theme (смена темы). Нажмите Shift + ?, чтобы увидеть полный список горячих клавиш.",hint:"Открывайте их по мере необходимости — не нужно запоминать всё сразу"}]}},Gn={en:fl,zh:pl,"zh-TW":hl,ja:ml,ko:gl,ru:xl};function bl(e){return Gn[e]??Gn.en}function yl(e){if(!e)return"en";const t=e.toLowerCase().replace(/[_\s]/g,"-");return t==="zh"||t==="chinese"||t==="zh-cn"?"zh":t==="zh-tw"||t==="traditional-chinese"?"zh-TW":t==="ja"||t==="japanese"?"ja":t==="ko"||t==="korean"?"ko":t==="ru"||t==="russian"||t==="ru-ru"?"ru":"en"}const Uo=v.createContext(null);function re(){const e=v.useContext(Uo);if(!e)throw new Error("useI18n must be used within an I18nProvider");return e}function wl({language:e,children:t}){const n=v.useMemo(()=>yl(e),[e]),o=v.useMemo(()=>bl(n),[n]),r=v.useMemo(()=>({locale:o,localeKey:n,t:o}),[o,n]);return a.jsx(Uo.Provider,{value:r,children:t})}const Hn={file:"var(--color-node-file)",function:"var(--color-node-function)",class:"var(--color-node-class)",module:"var(--color-node-module)",concept:"var(--color-node-concept)",config:"var(--color-node-config)",document:"var(--color-node-document)",service:"var(--color-node-service)",table:"var(--color-node-table)",endpoint:"var(--color-node-endpoint)",pipeline:"var(--color-node-pipeline)",schema:"var(--color-node-schema)",resource:"var(--color-node-resource)",domain:"var(--color-node-concept)",flow:"var(--color-node-pipeline)",step:"var(--color-node-function)",article:"var(--color-node-article)",entity:"var(--color-node-entity)",topic:"var(--color-node-topic)",claim:"var(--color-node-claim)",source:"var(--color-node-source)"},Un={file:"text-node-file",function:"text-node-function",class:"text-node-class",module:"text-node-module",concept:"text-node-concept",config:"text-node-config",document:"text-node-document",service:"text-node-service",table:"text-node-table",endpoint:"text-node-endpoint",pipeline:"text-node-pipeline",schema:"text-node-schema",resource:"text-node-resource",domain:"text-node-concept",flow:"text-node-pipeline",step:"text-node-function",article:"text-node-article",entity:"text-node-entity",topic:"text-node-topic",claim:"text-node-claim",source:"text-node-source"},Wn={simple:"text-node-function",moderate:"text-accent-dim",complex:"text-[#c97070]"};function vl({id:e,data:t}){var u;const n=t.nodeType,o=Hn[n]??Hn.file,r=Un[n]??Un.file,s=Wn[t.complexity]??Wn.simple,{t:i}=re();let c="";if(t.isSelected)c="ring-2 ring-accent node-glow";else if(t.isTourHighlighted)c="ring-2 ring-accent-dim animate-accent-pulse";else if(t.isHighlighted){const f=t.searchScore??1;f<=.1?c="ring-2 ring-accent-bright":f<=.3?c="ring-2 ring-accent":c="ring-1 ring-accent-dim/60"}t.isDiffChanged?c+=" ring-2 ring-[var(--color-diff-changed)] diff-changed-glow":t.isDiffAffected?c+=" ring-1 ring-[var(--color-diff-affected)] diff-affected-glow":t.isDiffFaded&&(c+=" diff-faded"),t.isSelectionFaded?c+=" opacity-20 pointer-events-auto":t.isNeighbor&&(c+=" ring-1 ring-gold-dim/50");const d=t.label??"unnamed",l=d.length>24?d.slice(0,22)+"...":d;return a.jsxs("div",{className:`relative rounded-lg bg-elevated border border-border-subtle ${c} min-w-[180px] max-w-[220px] overflow-hidden transition-[box-shadow,outline,opacity,filter] duration-200 cursor-pointer shadow-[0_2px_8px_rgba(0,0,0,0.3)]`,onClick:()=>{var f;return(f=t.onNodeClick)==null?void 0:f.call(t,e)},children:[a.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 rounded-l-lg",style:{backgroundColor:o}}),a.jsx(fe,{type:"target",position:pe.Top,className:"!bg-text-muted !w-2 !h-2"}),a.jsxs("div",{className:"pl-4 pr-3 py-2",children:[a.jsxs("div",{className:"flex items-center justify-between mb-1",children:[a.jsx("span",{className:`text-[10px] font-semibold uppercase tracking-wider ${r}`,children:t.nodeType}),a.jsxs("div",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:`text-[9px] font-mono ${s}`,children:t.complexity}),((u=t.tags)==null?void 0:u.includes("tested"))&&a.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-node-function shadow-[0_0_4px_rgba(90,158,111,0.6)]",role:"img","aria-label":i.customNode.tested,title:i.customNode.hasTests})]})]}),a.jsx("div",{className:"text-sm font-heading text-text-primary truncate",title:t.label,children:l}),a.jsx("div",{className:"text-[11px] text-text-secondary mt-1 line-clamp-2 leading-tight",children:t.summary})]}),a.jsx(fe,{type:"source",position:pe.Bottom,className:"!bg-text-muted !w-2 !h-2"})]})}const Wo=v.memo(vl),Kn=[{bg:"rgba(74, 124, 155, 0.12)",border:"rgba(74, 124, 155, 0.4)",label:"#4a7c9b"},{bg:"rgba(90, 158, 111, 0.12)",border:"rgba(90, 158, 111, 0.4)",label:"#5a9e6f"},{bg:"rgba(139, 111, 176, 0.12)",border:"rgba(139, 111, 176, 0.4)",label:"#8b6fb0"},{bg:"rgba(201, 160, 108, 0.12)",border:"rgba(201, 160, 108, 0.4)",label:"#c9a06c"},{bg:"rgba(176, 122, 138, 0.12)",border:"rgba(176, 122, 138, 0.4)",label:"#b07a8a"},{bg:"rgba(74, 155, 140, 0.12)",border:"rgba(74, 155, 140, 0.4)",label:"#4a9b8c"},{bg:"rgba(120, 130, 145, 0.12)",border:"rgba(120, 130, 145, 0.4)",label:"#788291"}];function jt(e){return Kn[e%Kn.length]}function Ko(){const e=b(c=>c.graph),t=b(c=>c.navigationLevel),n=b(c=>c.activeLayerId),{t:o}=re(),r=(e==null?void 0:e.layers)??[];if(!(r.length>0))return null;const i=r.find(c=>c.id===n);return a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-[11px] font-medium text-text-secondary whitespace-nowrap",children:t==="overview"?`${r.length} ${o.layer.label}`:(i==null?void 0:i.name)??o.layer.defaultName}),a.jsx("div",{className:"flex items-center gap-3",children:r.map((c,d)=>{const l=jt(d),u=t==="layer-detail"&&c.id===n;return a.jsxs("div",{className:"flex items-center gap-1 whitespace-nowrap",children:[a.jsx("span",{className:"inline-block w-2 h-2 rounded-full",style:{backgroundColor:l.label,opacity:t==="layer-detail"&&!u?.3:1}}),a.jsxs("span",{className:`text-[11px] ${u?"text-text-primary font-medium":"text-text-secondary"}`,style:{opacity:t==="layer-detail"&&!u?.4:1},children:[c.name,a.jsxs("span",{className:"text-text-muted ml-0.5",children:["(",c.nodeIds.length,")"]})]})]},c.id)})})]})}const Jn={simple:"text-node-function",moderate:"text-gold-dim",complex:"text-[#c97070]"};function kl({data:e}){const t=jt(e.layerColorIndex),n=Jn[e.aggregateComplexity]??Jn.simple;return a.jsxs("div",{className:"relative rounded-xl bg-elevated border border-border-subtle overflow-hidden cursor-pointer transition-all duration-200 hover:border-gold/40 hover:shadow-lg group",style:{width:300,boxShadow:"0 4px 16px rgba(0,0,0,0.4)"},onClick:()=>e.onDrillIn(e.layerId),children:[a.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1.5 rounded-l-xl",style:{backgroundColor:t.label}}),a.jsx(fe,{type:"target",position:pe.Top,className:"!bg-text-muted !w-2 !h-2"}),a.jsxs("div",{className:"pl-5 pr-4 py-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:t.label},children:"流程"}),a.jsxs("div",{className:"flex items-center gap-2",children:[e.searchMatchCount!=null&&e.searchMatchCount>0&&a.jsxs("span",{className:"text-[10px] font-mono bg-gold/20 text-gold px-1.5 py-0.5 rounded",children:[e.searchMatchCount," match",e.searchMatchCount!==1?"es":""]}),a.jsx("span",{className:`text-[10px] font-mono ${n}`,children:e.aggregateComplexity})]})]}),a.jsx("div",{className:"text-lg font-heading text-text-primary mb-1",children:e.layerName}),a.jsx("div",{className:"text-[11px] text-text-secondary line-clamp-2 leading-tight mb-3",children:e.layerDescription}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("span",{className:"text-[11px] text-text-muted",children:[e.fileCount," 个文档"]}),a.jsx("span",{className:"text-[10px] text-text-muted opacity-0 group-hover:opacity-100 transition-opacity",children:"点击查看 →"})]})]}),a.jsx(fe,{type:"source",position:pe.Bottom,className:"!bg-text-muted !w-2 !h-2"})]})}const Nl=v.memo(kl);function jl({data:e}){const t=jt(e.layerColorIndex);return a.jsxs("div",{className:"relative rounded-lg bg-elevated/60 overflow-hidden cursor-pointer transition-all duration-200 hover:bg-elevated/80",style:{width:220,border:`2px dashed ${t.border}`,boxShadow:"0 2px 8px rgba(0,0,0,0.2)"},onClick:()=>e.onNavigate(e.targetLayerId),children:[a.jsx(fe,{type:"target",position:pe.Top,className:"!bg-text-muted !w-2 !h-2"}),a.jsxs("div",{className:"px-3 py-2.5",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx("span",{className:"inline-block w-2 h-2 rounded-full shrink-0",style:{backgroundColor:t.label}}),a.jsx("span",{className:"text-sm text-text-primary truncate",children:e.targetLayerName})]}),a.jsx("span",{className:"text-text-muted ml-2 shrink-0",children:"→"})]}),a.jsxs("div",{className:"text-[10px] text-text-muted mt-1 pl-4",children:[e.connectionCount," connection",e.connectionCount!==1?"s":""]})]}),a.jsx(fe,{type:"source",position:pe.Bottom,className:"!bg-text-muted !w-2 !h-2"})]})}const _l=v.memo(jl);function Cl({data:e,width:t,height:n}){const o=jt(e.colorIndex),r=e.isDiffAffected?"var(--color-diff-changed)":e.isExpanded||e.isFocusedViaChild?"rgba(212,165,116,0.6)":"rgba(212,165,116,0.25)",s=e.isExpanded||e.isFocusedViaChild?1.5:1,i=e.name==="~",c=i?"(root)":e.name,d=l=>{l.stopPropagation(),e.onToggle(e.containerId)};return a.jsx("div",{role:"button",tabIndex:0,"aria-expanded":e.isExpanded,"aria-label":`${c} container, ${e.childCount} item${e.childCount!==1?"s":""}, ${e.isExpanded?"expanded":"collapsed"}`,className:"rounded-xl cursor-pointer transition-all focus:outline-none focus:ring-2 focus:ring-[rgba(212,165,116,0.6)]",style:{width:t,height:n,background:"rgba(255,255,255,0.02)",border:`${s}px solid ${r}`,position:"relative"},onClick:d,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),d(l))},children:a.jsxs("div",{className:"flex items-center justify-between font-heading",style:{padding:"12px 16px",color:o.label,fontSize:14,fontWeight:400},children:[a.jsxs("span",{className:i?"opacity-50":"",style:{display:"flex",alignItems:"center",gap:6},children:[e.isExpanded&&a.jsx("span",{style:{fontSize:10},children:"▾"}),c,e.searchHitCount!=null&&e.searchHitCount>0&&a.jsxs("span",{className:"font-mono",style:{marginLeft:6,fontSize:10,background:"rgba(212,165,116,0.2)",color:"var(--color-gold, #d4a574)",padding:"1px 6px",borderRadius:8},children:[e.searchHitCount," hit",e.searchHitCount!==1?"s":""]})]}),a.jsx("span",{style:{color:"#a39787",fontSize:11},children:e.childCount})]})})}const Jo=v.memo(Cl);Jo.displayName="ContainerNode";function Sl(){const e=b(i=>i.navigationLevel),t=b(i=>i.activeLayerId),n=b(i=>i.graph),o=b(i=>i.navigateToOverview),{t:r}=re(),s=n==null?void 0:n.layers.find(i=>i.id===t);return a.jsxs("div",{className:"absolute top-4 left-4 z-10 flex items-center gap-2",children:[e==="overview"&&a.jsx("div",{className:"px-4 py-2 rounded-full bg-elevated border border-border-subtle text-xs font-semibold tracking-wider uppercase text-text-secondary shadow-lg",children:r.breadcrumb.projectOverview}),e==="layer-detail"&&a.jsxs("div",{className:"flex items-center gap-1.5 px-4 py-2 rounded-full bg-elevated border border-gold/30 text-xs font-semibold tracking-wider uppercase shadow-lg",children:[a.jsx("button",{onClick:o,className:"text-gold hover:text-gold-bright transition-colors",children:r.breadcrumb.project}),a.jsx("span",{className:"text-text-muted",children:"›"}),a.jsx("span",{className:"text-text-primary",children:(s==null?void 0:s.name)??r.layer.defaultName}),a.jsxs("span",{className:"text-text-muted ml-1 text-[10px] normal-case tracking-normal",children:["(",r.breadcrumb.escBack,")"]})]})]})}const Il={presetId:"dark-gold",accentId:"gold"},at=[{id:"gold",name:"Gold",accent:"#d4a574",accentDim:"#c9a96e",accentBright:"#e8c49a"},{id:"ocean",name:"Ocean",accent:"#5ba4cf",accentDim:"#4e93ba",accentBright:"#7abce0"},{id:"emerald",name:"Emerald",accent:"#5ea67a",accentDim:"#4e9468",accentBright:"#78c492"},{id:"rose",name:"Rose",accent:"#cf7a8a",accentDim:"#b96e7e",accentBright:"#e094a4"},{id:"purple",name:"Purple",accent:"#9b7abf",accentDim:"#876bb0",accentBright:"#b494d4"},{id:"amber",name:"Amber",accent:"#c9963a",accentDim:"#b5862e",accentBright:"#ddb05c"},{id:"teal",name:"Teal",accent:"#4aab9a",accentDim:"#3d9686",accentBright:"#68c4b4"},{id:"silver",name:"Silver",accent:"#a0a8b0",accentDim:"#8e959c",accentBright:"#b8bfc6"}],Tl=[{id:"indigo",name:"Indigo",accent:"#4a6fa5",accentDim:"#3d5f8f",accentBright:"#6088bf"},{id:"ocean",name:"Ocean",accent:"#3a8ab5",accentDim:"#2e7aa0",accentBright:"#55a0cc"},{id:"emerald",name:"Emerald",accent:"#3a8a5c",accentDim:"#2e7a4e",accentBright:"#55a878"},{id:"rose",name:"Rose",accent:"#a5566a",accentDim:"#8f4a5c",accentBright:"#bf6e82"},{id:"purple",name:"Purple",accent:"#6b5a9e",accentDim:"#5c4d8a",accentBright:"#8474b5"},{id:"amber",name:"Amber",accent:"#9e7a30",accentDim:"#8a6a28",accentBright:"#b5923e"},{id:"teal",name:"Teal",accent:"#2e8a7a",accentDim:"#267a6c",accentBright:"#45a595"},{id:"slate",name:"Slate",accent:"#5a6570",accentDim:"#4e5860",accentBright:"#6e7a85"}],Zt=[{id:"dark-gold",name:"Dark Gold",isDark:!0,defaultAccentId:"gold",accentSwatches:at,colors:{root:"#0a0a0a",surface:"#111111",elevated:"#1a1a1a",panel:"#141414","text-primary":"#f5f0eb","text-secondary":"#a39787","text-muted":"#6b5f53","node-file":"#4a7c9b","node-function":"#5a9e6f","node-class":"#8b6fb0","node-module":"#c9a06c","node-concept":"#b07a8a","node-config":"#5eead4","node-document":"#7dd3fc","node-service":"#a78bfa","node-table":"#6ee7b7","node-endpoint":"#fdba74","node-pipeline":"#fda4af","node-schema":"#fcd34d","node-resource":"#a5b4fc"}},{id:"dark-ocean",name:"Dark Ocean",isDark:!0,defaultAccentId:"ocean",accentSwatches:at,colors:{root:"#0a0e14",surface:"#111820",elevated:"#1a222c",panel:"#141c24","text-primary":"#e8edf2","text-secondary":"#87939f","text-muted":"#536b7a","node-file":"#4a7c9b","node-function":"#5a9e6f","node-class":"#8b6fb0","node-module":"#c9a06c","node-concept":"#b07a8a","node-config":"#5eead4","node-document":"#7dd3fc","node-service":"#a78bfa","node-table":"#6ee7b7","node-endpoint":"#fdba74","node-pipeline":"#fda4af","node-schema":"#fcd34d","node-resource":"#a5b4fc"}},{id:"dark-forest",name:"Dark Forest",isDark:!0,defaultAccentId:"emerald",accentSwatches:at,colors:{root:"#0a100a",surface:"#111811",elevated:"#1a241a",panel:"#141c14","text-primary":"#ebf0eb","text-secondary":"#87a38f","text-muted":"#536b5a","node-file":"#4a7c9b","node-function":"#5a9e6f","node-class":"#8b6fb0","node-module":"#c9a06c","node-concept":"#b07a8a","node-config":"#5eead4","node-document":"#7dd3fc","node-service":"#a78bfa","node-table":"#6ee7b7","node-endpoint":"#fdba74","node-pipeline":"#fda4af","node-schema":"#fcd34d","node-resource":"#a5b4fc"}},{id:"dark-rose",name:"Dark Rose",isDark:!0,defaultAccentId:"rose",accentSwatches:at,colors:{root:"#100a0a",surface:"#181111",elevated:"#221a1a",panel:"#1c1414","text-primary":"#f2e8ea","text-secondary":"#9f8790","text-muted":"#6b535a","node-file":"#4a7c9b","node-function":"#5a9e6f","node-class":"#8b6fb0","node-module":"#c9a06c","node-concept":"#b07a8a","node-config":"#5eead4","node-document":"#7dd3fc","node-service":"#a78bfa","node-table":"#6ee7b7","node-endpoint":"#fdba74","node-pipeline":"#fda4af","node-schema":"#fcd34d","node-resource":"#a5b4fc"}},{id:"light-minimal",name:"Light Minimal",isDark:!1,defaultAccentId:"indigo",accentSwatches:Tl,colors:{root:"#f5f3f0",surface:"#eae7e3",elevated:"#ffffff",panel:"#f0ede9","text-primary":"#1a1a1a","text-secondary":"#6b6b6b","text-muted":"#a0a0a0","node-file":"#3a6a87","node-function":"#488a5b","node-class":"#755d99","node-module":"#a88a56","node-concept":"#966674","node-config":"#14b8a6","node-document":"#38bdf8","node-service":"#8b5cf6","node-table":"#34d399","node-endpoint":"#fb923c","node-pipeline":"#fb7185","node-schema":"#facc15","node-resource":"#818cf8"}}];function Bt(e){return Zt.find(t=>t.id===e)??Zt[0]}function El(e,t){return e.accentSwatches.find(n=>n.id===t)??e.accentSwatches.find(n=>n.id===e.defaultAccentId)??e.accentSwatches[0]}function $l(e){const t=e.replace("#",""),n=parseInt(t,16);return`${n>>16&255}, ${n>>8&255}, ${n&255}`}function Ll(e,t){const n=$l(e);return{"color-border-subtle":`rgba(${n}, ${t?.12:.1})`,"color-border-medium":`rgba(${n}, ${t?.25:.18})`,"glass-bg":t?"rgba(20, 20, 20, 0.8)":"rgba(255, 255, 255, 0.8)","glass-bg-heavy":t?"rgba(20, 20, 20, 0.95)":"rgba(255, 255, 255, 0.95)","glass-border":`rgba(${n}, ${t?.1:.08})`,"glass-border-heavy":`rgba(${n}, ${t?.15:.12})`,"scrollbar-thumb":`rgba(${n}, 0.2)`,"scrollbar-thumb-hover":`rgba(${n}, 0.35)`,"glow-accent":`rgba(${n}, 0.15)`,"glow-accent-strong":`rgba(${n}, 0.4)`,"glow-accent-pulse":`rgba(${n}, 0.6)`,"color-edge":`rgba(${n}, 0.3)`,"color-edge-dim":`rgba(${n}, 0.08)`,"color-edge-dot":`rgba(${n}, 0.15)`,"color-accent-overlay-bg":`rgba(${n}, 0.05)`,"color-accent-overlay-border":`rgba(${n}, 0.25)`,"kbd-bg":`rgba(${n}, 0.1)`}}function zl(e){const t=Bt(e.presetId),n=El(t,e.accentId),o=document.documentElement.style;for(const[c,d]of Object.entries(t.colors))o.setProperty(`--color-${c}`,d);o.setProperty("--color-accent",n.accent),o.setProperty("--color-accent-dim",n.accentDim),o.setProperty("--color-accent-bright",n.accentBright);const r=Ll(n.accent,t.isDark);for(const[c,d]of Object.entries(r))o.setProperty(`--${c}`,d);document.documentElement.setAttribute("data-theme",t.isDark?"dark":"light");const s={serif:"var(--font-serif)",sans:"var(--font-sans)",mono:"var(--font-mono)"},i=e.headingFont??"serif";o.setProperty("--font-heading",s[i]??s.serif)}const Yo="ua-theme",Xo=v.createContext(null);function qo(){try{const e=localStorage.getItem(Yo);if(!e)return null;const t=JSON.parse(e);return t&&typeof t.presetId=="string"&&typeof t.accentId=="string"?t:null}catch{return null}}function Al(e){try{localStorage.setItem(Yo,JSON.stringify(e))}catch{}}function Ol(e){return qo()??e??Il}function Ml({metaTheme:e,children:t}){const[n,o]=v.useState(()=>Ol(e)),r=v.useRef(!1);v.useEffect(()=>{zl(n),r.current&&Al(n),r.current=!0},[n]),v.useEffect(()=>{e&&!qo()&&o(e)},[e]);const s=v.useCallback(l=>{o(u=>{const f=Bt(l);return{presetId:l,accentId:f.defaultAccentId}})},[]),i=v.useCallback(l=>{o(u=>({...u,accentId:l}))},[]),c=v.useCallback(l=>{o(u=>({...u,headingFont:l}))},[]),d=Bt(n.presetId);return a.jsx(Xo.Provider,{value:{config:n,preset:d,setPreset:s,setAccent:i,setHeadingFont:c},children:t})}function Qo(){const e=v.useContext(Xo);if(!e)throw new Error("useTheme must be used within ThemeProvider");return e}const de=280,ue=120,Fl=320,Dl=180,Pl=240,Rl=80;function Zl(e,t,n,o){if(e.length===0)return{nodes:e,edges:t};const r=e.map(y=>({id:y.id,x:Math.random()*800-400,y:Math.random()*800-400,community:o==null?void 0:o.get(y.id)})),s=new Set(r.map(y=>y.id)),i=t.filter(y=>s.has(y.source)&&s.has(y.target)).map(y=>({source:y.source,target:y.target})),c=o?Math.max(1,new Set(o.values()).size):1,d=y=>2*Math.PI*y/c,l=Math.max(600,e.length*5),u=e.length>100,f=u?-600:-350,h=u?250:150,g=jr(r).force("link",_r(i).id(y=>y.id).distance(h).strength(.2)).force("charge",Cr().strength(f).distanceMax(1500)).force("center",Sr(0,0).strength(.03)).force("collide",Ir().radius(y=>{const x=n==null?void 0:n.get(y.id);return Math.max(20,(((x==null?void 0:x.width)??de)+40)/2)}).strength(.8));o&&c>1&&(g.force("clusterX",Tr(y=>{const x=y.community??0;return Math.cos(d(x))*l}).strength(.3)),g.force("clusterY",Er(y=>{const x=y.community??0;return Math.sin(d(x))*l}).strength(.3)));const m=Math.min(300,Math.max(100,e.length));g.tick(m),g.stop();const p=new Map(r.map(y=>[y.id,{x:y.x??0,y:y.y??0}]));return{nodes:e.map(y=>{const x=p.get(y.id)??{x:0,y:0},k=n==null?void 0:n.get(y.id),T=(k==null?void 0:k.width)??de,j=(k==null?void 0:k.height)??ue;return{...y,position:{x:x.x-T/2,y:x.y-j/2}}}),edges:t}}const Vt={algorithm:"layered","elk.direction":"DOWN","elk.layered.spacing.nodeNodeBetweenLayers":"80","elk.spacing.nodeNode":"60","elk.layered.crossingMinimization.strategy":"LAYER_SWEEP","elk.edgeRouting":"ORTHOGONAL","elk.layered.compaction.postCompaction.strategy":"LEFT","elk.padding":"[top=40,left=20,right=20,bottom=20]"};function er(e,t,n,o){return{id:"root",layoutOptions:{...Vt,...o},children:e.map(r=>{const s=n.get(r.id);return{id:r.id,width:(s==null?void 0:s.width)??de,height:(s==null?void 0:s.height)??ue}}),edges:t.map((r,s)=>({id:r.id??`e${s}`,sources:[String(r.source)],targets:[String(r.target)]}))}}function cn(e,t){const n=new Map;for(const o of t.children??[])n.set(o.id,{x:o.x??0,y:o.y??0,width:o.width,height:o.height});return e.map(o=>{const r=n.get(o.id);return r?{...o,position:{x:r.x,y:r.y},...r.width!=null?{width:r.width}:{},...r.height!=null?{height:r.height}:{}}:{...o,position:o.position??{x:0,y:0}}})}const Bl=de,Vl=ue;function Be(e,t,n){return{level:e,category:t,message:n}}function Ve(e,t){if(e)throw new Error(`[ELK repair] ${t.level}: ${t.message}`)}function Gl(e,t={}){const n=[],o=t.strict;let r=0;const s=C=>C.map(I=>{const E={...I};return(E.width==null||E.height==null)&&(E.width=E.width??Bl,E.height=E.height??Vl,r++),E.children&&(E.children=s(E.children)),E}),i=s(e.children);if(r>0){const C=Be("auto-corrected","elk-missing-dimensions",`Set default dimensions on ${r} node(s) missing width/height.`);n.push(C),Ve(o,C)}let c=0;const d=C=>{const I=new Set,E=[];for(const w of C){if(I.has(w.id)){c++;continue}I.add(w.id),E.push({...w,children:w.children?d(w.children):void 0})}return E},l=d(i);if(c>0){const C=Be("auto-corrected","elk-duplicate-id",`Removed ${c} duplicate child id(s).`);n.push(C),Ve(o,C)}const u=new Set,f=C=>{for(const I of C)u.add(I.id),I.children&&f(I.children)};f(l);let h=0;const g=l.filter(C=>C.parentId&&!u.has(C.parentId)?(h++,!1):!0);if(h>0){const C=Be("dropped","elk-orphan-parent",`Dropped ${h} child(ren) with missing parent reference.`);n.push(C),Ve(o,C)}let m=0;const p=e.edges.filter(C=>C.sources.every(E=>u.has(E))&&C.targets.every(E=>u.has(E))?!0:(m++,!1));if(m>0){const C=Be("dropped","elk-orphan-edge",`Dropped ${m} edge(s) referencing nonexistent nodes.`);n.push(C),Ve(o,C)}const N=new Map,y=(C,I)=>{for(const E of C)I&&N.set(E.id,I),E.children&&y(E.children,E.id)};y(g);let x=0;const k=C=>{const I=new Set;let E=N.get(C);for(;E;){if(E===C||I.has(E))return!0;I.add(E),E=N.get(E)}return!1},T=C=>C.filter(I=>k(I.id)?(x++,!1):!0).map(I=>({...I,children:I.children?T(I.children):void 0})),j=T(g);if(x>0){const C=Be("dropped","elk-containment-cycle",`Dropped ${x} node(s) in containment cycles.`);n.push(C),Ve(o,C)}return{input:{...e,children:j,edges:p},issues:n}}const Hl=new $r;async function yt(e,t={}){const{input:n,issues:o}=Gl(e,t);try{return{positioned:await Hl.layout(n),issues:o}}catch(r){const s={level:"fatal",category:"elk-layout-failed",message:`ELK layout failed: ${r instanceof Error?r.message:String(r)}. This looks like a dashboard rendering bug — please file an issue with the copied error.`};if(t.strict)throw r;return{positioned:{...n,children:[],edges:[]},issues:[...o,s]}}}function tr(e){const t=new Map;for(const o of e.layers)for(const r of o.nodeIds)t.set(r,o.id);const n=new Map;for(const o of e.edges){const r=t.get(o.source),s=t.get(o.target);if(!r||!s||r===s)continue;const[i,c]=r({sourceLayerId:o.sourceLayerId,targetLayerId:o.targetLayerId,count:o.count,edgeTypes:Array.from(o.edgeTypes)}))}function Ul(e,t,n){const o=tr(e),r=new Map(e.layers.map(i=>[i.id,i.name])),s=new Map;for(const i of o)i.sourceLayerId===t?s.set(i.targetLayerId,(s.get(i.targetLayerId)??0)+i.count):i.targetLayerId===t&&s.set(i.sourceLayerId,(s.get(i.sourceLayerId)??0)+i.count);return Array.from(s.entries()).map(([i,c])=>({layerId:i,layerName:r.get(i)??i,connectionCount:c}))}function Wl(e,t,n){var i,c;const o=new Set(((i=e.layers.find(d=>d.id===t))==null?void 0:i.nodeIds)??[]),r=new Set(((c=e.layers.find(d=>d.id===n))==null?void 0:c.nodeIds)??[]),s=new Set;for(const d of e.edges)o.has(d.source)&&r.has(d.target)&&s.add(d.source),o.has(d.target)&&r.has(d.source)&&s.add(d.target);return s}function Kl(e,t){const n=[],o=new Map;for(const s of e){const i=t.get(s.source),c=t.get(s.target);if(!i||!c)continue;if(i===c){n.push(s);continue}const d=`${i.length}:${i}\0${c}`,l=o.get(d);l?(l.count++,l.edgeTypes.add(s.type)):o.set(d,{sourceContainerId:i,targetContainerId:c,count:1,edgeTypes:new Set([s.type])})}const r=[...o.values()].map(s=>({sourceContainerId:s.sourceContainerId,targetContainerId:s.targetContainerId,count:s.count,edgeTypes:[...s.edgeTypes]}));return{intraContainer:n,interContainerAggregated:r}}function Jl(e,t){const n=new Set(e),o=new Lr({type:"undirected",multi:!1});for(const c of e)o.addNode(c);for(const c of t)!n.has(c.source)||!n.has(c.target)||c.source!==c.target&&(o.hasEdge(c.source,c.target)||o.addEdge(c.source,c.target));const r=zr(o),s=new Map;for(const c of e)s.set(c,r[c]??-1);let i=Math.max(...Array.from(s.values()).filter(c=>c>=0),-1)+1;for(const[c,d]of s)d===-1&&s.set(c,i++);return s}const Yl=2,Yn=.7,Xl=3,Xn="~";function ql(e){if(e.length===0)return"";const t=e.map(r=>{const s=r.lastIndexOf("/");return s>=0?r.slice(0,s):""});let n=t[0];for(const r of t)for(;!r.startsWith(n);)if(n=n.slice(0,-1),!n)return"";const o=n.lastIndexOf("/");return o>=0?n.slice(0,o+1):""}function Ql(e){const t=e.indexOf("/");return t>=0?e.slice(0,t):e}function eu(e){const t=e.filter(s=>s.filePath),n=ql(t.map(s=>s.filePath)),o=new Map,r=[];for(const s of e){if(!s.filePath){r.push(s.id);continue}const i=s.filePath.slice(n.length);if(!i.includes("/")){r.push(s.id);continue}const c=Ql(i),d=o.get(c)??[];d.push(s.id),o.set(c,d)}return{groups:o,rooted:r}}function tu(e,t,n){if(e.size+(t.length>0?1:0)Yn)return!0;return t.length/n>Yn}function nu(e,t){if(e.length===0)return{containers:[],ungrouped:[]};const{groups:n,rooted:o}=eu(e),r=tu(n,o,e.length);let s;if(r){const c=Jl(e.map(u=>u.id),t),d=new Map;for(const[u,f]of c){const h=d.get(f)??[];h.push(u),d.set(f,h)}s=[...d.entries()].sort((u,f)=>u[0]-f[0]).map(([u,f],h)=>({id:`container:cluster-${u}`,name:h<26?`Cluster ${String.fromCharCode(65+h)}`:`Cluster ${h+1}`,nodeIds:f,strategy:"community"}))}else s=[...n.entries()].map(([c,d])=>({id:`container:${c}`,name:c,nodeIds:d,strategy:"folder"})),o.length>0&&s.push({id:`container:${Xn}`,name:Xn,nodeIds:o,strategy:"folder"});const i=[];return e.length>=Xl&&(s=s.filter(c=>c.nodeIds.length===1?(i.push(c.nodeIds[0]),!1):!0)),{containers:s,ungrouped:i}}function ou(e,t){const n={simple:0,moderate:0,complex:0};let o=0;for(const s of e.nodeIds){const i=t.get(s);i&&(o++,n[i.complexity]++)}const r=n.complex>o*.3?"complex":n.moderate>o*.3?"moderate":"simple";return{resolvedCount:o,aggregateComplexity:r}}const ru={custom:Wo,"layer-cluster":Nl,portal:_l,container:Jo},su={file:"code",function:"code",class:"code",module:"code",concept:"code",config:"config",document:"docs",service:"infra",resource:"infra",pipeline:"infra",table:"data",endpoint:"data",schema:"data",domain:"domain",flow:"domain",step:"domain",article:"knowledge",entity:"knowledge",topic:"knowledge",claim:"knowledge",source:"knowledge"};function au(){const e=b(c=>c.tourHighlightedNodeIds),t=b(c=>c.setTourFitPending),{fitView:n,getInternalNode:o}=Ut(),r=Nr(),s=v.useRef(""),i=v.useRef("");return v.useEffect(()=>{const c=e.join(` `);if(c===""){s.current="",i.current="",t(!1);return}if(c===s.current)return;const d=240;let l=0,u=!1,f=0;i.current!==c&&t(!0);const h=()=>{var m,p;if(u)return;let g=!0;for(const N of e){const y=o(N);if(!y||!((m=y.measured)!=null&&m.width)||!((p=y.measured)!=null&&p.height)){g=!1;break}}if(g){n({nodes:e.map(N=>({id:N})),duration:500,padding:.3,maxZoom:1.2,minZoom:.4}),s.current=c,i.current="",t(!1);return}if(++l{u=!0,cancelAnimationFrame(f)}},[e,r,n,o,t]),null}function iu(){const e=b(o=>o.selectedNodeId),{fitView:t}=Ut(),n=v.useRef(null);return v.useEffect(()=>{if(e&&e!==n.current){const o=setTimeout(()=>{t({nodes:[{id:e}],duration:500,padding:.3,maxZoom:1.2,minZoom:.01})},100);return n.current=e,()=>clearTimeout(o)}n.current=e},[e,t]),null}function cu(){const e=b(u=>u.graph),t=b(u=>u.nodesById),n=b(u=>u.nodeIdToLayerId),o=b(u=>u.searchResults),r=b(u=>u.drillIntoLayer),s=v.useMemo(()=>{if(!e)return null;const u=e.layers??[];if(u.length===0)return null;const f=new Map;if(o.length>0)for(const N of o){const y=n.get(N.nodeId);y&&f.set(y,(f.get(y)??0)+1)}const h=u.map((N,y)=>{const{aggregateComplexity:x}=ou(N,t);return{id:N.id,type:"layer-cluster",position:{x:0,y:0},data:{layerId:N.id,layerName:N.name,layerDescription:N.description,fileCount:N.nodeIds.length,aggregateComplexity:x,layerColorIndex:y,searchMatchCount:f.get(N.id),onDrillIn:r}}}),m=tr(e).map((N,y)=>({id:`le-${y}`,source:N.sourceLayerId,target:N.targetLayerId,label:`${N.count}`,style:{stroke:"rgba(212,165,116,0.4)",strokeWidth:Math.min(1+Math.log2(N.count+1),5)},labelStyle:{fill:"#a39787",fontSize:11,fontWeight:600}})),p=new Map;for(const N of h)p.set(N.id,{width:Fl,height:Dl});return{clusterNodes:h,flowEdges:m,dims:p}},[e,t,n,o,r]),[i,c]=v.useState({nodes:[],edges:[]}),[d,l]=v.useState("ready");return v.useEffect(()=>{if(!s){c({nodes:[],edges:[]}),l("ready");return}let u=!1;const{clusterNodes:f,flowEdges:h,dims:g}=s,m=f,p=er(m,h,g,{"elk.direction":"RIGHT","elk.layered.spacing.nodeNodeBetweenLayers":"150","elk.spacing.nodeNode":"80"});return l("computing"),yt(p,{strict:!1}).then(({positioned:N,issues:y})=>{if(u)return;y.length>0&&b.getState().appendLayoutIssues(y);const x=cn(m,N);c({nodes:x,edges:h}),l("ready")}).catch(N=>{u||(console.error("[overview ELK] layout failed:",N),l("ready"))}),()=>{u=!0}},[s]),{...i,layoutStatus:d}}const qn={nodes:[],edges:[],portalNodes:[],portalEdges:[],filteredEdges:[],filteredNodes:[],containers:[],nodeToContainer:new Map,intraContainer:[]};function du(){const e=b($=>$.graph),t=b($=>$.nodesById),n=b($=>$.activeLayerId),o=b($=>$.selectNode),r=b($=>$.persona),s=b($=>$.diffMode),i=b($=>$.changedNodeIds),c=b($=>$.affectedNodeIds),d=b($=>$.focusNodeId),l=b($=>$.nodeTypeFilters),u=b($=>$.drillIntoLayer),f=b($=>$.detailLevel),h=b($=>$.showFunctionsInClassView),g=v.useCallback($=>{o($)},[o]),m=v.useCallback($=>b.getState().toggleContainer($),[]),p=v.useMemo(()=>{if(!e||!n)return null;const $=e.layers.find(L=>L.id===n);if(!$)return null;const D=new Set($.nodeIds),Z=new Set(D);if(f!=="file"){for(const L of e.edges)if(L.type==="contains"&&D.has(L.source)){const B=t.get(L.target);if(!B)continue;(B.type==="class"||B.type==="function"&&h)&&Z.add(L.target)}}const P=new Set(["function","class"]),V=new Set(["file","module","concept","config","document","service","table","endpoint","pipeline","schema","resource","domain","flow","step","function","class"]);let R=e.nodes.filter(L=>!(!Z.has(L.id)||!V.has(L.type)||r==="non-technical"&&P.has(L.type)));R=R.filter(L=>{const me=su[L.type]??"code";return l[me]!==!1});let U=new Set(R.map(L=>L.id)),A=e.edges.filter(L=>U.has(L.source)&&U.has(L.target));if(d&&U.has(d)){const L=new Set([d]);for(const B of A)B.source===d&&L.add(B.target),B.target===d&&L.add(B.source);R=R.filter(B=>L.has(B.id)),U=new Set(R.map(B=>B.id)),A=A.filter(B=>U.has(B.source)&&U.has(B.target))}const{containers:Q,ungrouped:se}=nu(R,A),K=new Set(se),z=new Map;for(const L of Q)for(const B of L.nodeIds)z.set(B,L.id);for(const L of K)z.set(L,L);const{intraContainer:J,interContainerAggregated:S}=Kl(A,z),Y=800,G=600,te=b.getState().containerSizeMemory,we=L=>{var be;const B=(be=te.get(L.id))==null?void 0:be.width;if(B)return B;const me=Math.sqrt(L.nodeIds.length)*de*1.2;return Math.min(Y,Math.max(de,me))},ve=L=>{var be;const B=(be=te.get(L.id))==null?void 0:be.height;if(B)return B;const me=Math.sqrt(L.nodeIds.length)*ue*1.2;return Math.min(G,Math.max(ue,me))},ze=Q.map((L,B)=>({id:L.id,type:"container",position:{x:0,y:0},width:we(L),height:ve(L),data:{containerId:L.id,name:L.name,childCount:L.nodeIds.length,strategy:L.strategy,colorIndex:B%12,isExpanded:!1,hasSearchHits:!1,isDiffAffected:!1,isFocusedViaChild:!1,onToggle:m}})),Ke=R.filter(L=>K.has(L.id)).map(L=>{var B;return{id:L.id,type:"custom",position:{x:0,y:0},data:{label:L.name??((B=L.filePath)==null?void 0:B.split("/").pop())??L.id,nodeType:L.type,summary:L.summary,complexity:L.complexity,tags:L.tags,isHighlighted:!1,searchScore:void 0,isSelected:!1,isTourHighlighted:!1,isDiffChanged:s&&i.has(L.id),isDiffAffected:s&&c.has(L.id),isDiffFaded:s&&!i.has(L.id)&&!c.has(L.id),isNeighbor:!1,isSelectionFaded:!1,onNodeClick:g}}}),Je=S.map((L,B)=>{const me=s?{stroke:"rgba(212,165,116,0.08)",strokeWidth:1}:{stroke:"rgba(212,165,116,0.4)",strokeWidth:Math.min(1+Math.log2(L.count+1),5)};return{id:`agg-${B}`,source:L.sourceContainerId,target:L.targetContainerId,label:String(L.count),style:me,labelStyle:{fill:s?"rgba(163,151,135,0.3)":"#a39787",fontSize:11}}}),Ye=Ul(e,n),_t=new Map(e.layers.map((L,B)=>[L.id,B])),Ce=Ye.map(L=>({id:`portal:${L.layerId}`,type:"portal",position:{x:0,y:0},data:{targetLayerId:L.layerId,targetLayerName:L.layerName,connectionCount:L.connectionCount,layerColorIndex:_t.get(L.layerId)??0,onNavigate:u}})),Ae=[];let Pe=Je.length;for(const L of Ye){const B=Wl(e,n,L.layerId),me=new Set;for(const be of B){if(!U.has(be))continue;const Ct=z.get(be)??be;me.has(Ct)||(me.add(Ct),Ae.push({id:`e-${Pe++}`,source:Ct,target:`portal:${L.layerId}`,style:{stroke:"rgba(212,165,116,0.2)",strokeWidth:1,strokeDasharray:"4 4"},animated:!1}))}}return{containers:Q,ungrouped:se,nodeToContainer:z,intraContainer:J,filteredGraphNodes:R,filteredGraphEdges:A,containerFlowNodes:ze,ungroupedFlowNodes:Ke,aggEdges:Je,portalNodes:Ce,portalEdges:Ae}},[e,t,n,r,s,i,c,d,l,u,f,h,g,m]),N=b($=>$.stage1Tick),[y,x]=v.useState(qn),[k,T]=v.useState("ready");v.useEffect(()=>{if(!p){x(qn),T("ready");return}let $=!1;const{containers:D,nodeToContainer:Z,intraContainer:P,filteredGraphNodes:V,filteredGraphEdges:R,containerFlowNodes:U,ungroupedFlowNodes:A,aggEdges:Q,portalNodes:se,portalEdges:K}=p,z=b.getState().containerSizeMemory,J=[...U.map(G=>{const te=z.get(G.id);return{id:G.id,width:(te==null?void 0:te.width)??G.width??de,height:(te==null?void 0:te.height)??G.height??ue}}),...A.map(G=>({id:G.id,width:de,height:ue})),...se.map(G=>({id:G.id,width:Pl,height:Rl}))],S=[...Q.map(G=>({id:G.id,sources:[String(G.source)],targets:[String(G.target)]})),...K.map(G=>({id:G.id,sources:[String(G.source)],targets:[String(G.target)]}))],Y={id:"layer",layoutOptions:Vt,children:J,edges:S};return T("computing"),yt(Y,{strict:!1}).then(({positioned:G,issues:te})=>{if($)return;te.length>0&&b.getState().appendLayoutIssues(te);const we=[...U,...A,...se],ve=cn(we,G);x({nodes:ve,edges:Q,portalNodes:se,portalEdges:K,filteredEdges:R,filteredNodes:V,containers:D,nodeToContainer:Z,intraContainer:P}),T("ready")}).catch(G=>{$||(console.error("[layer-detail Stage 1 ELK] layout failed:",G),T("ready"))}),()=>{$=!0}},[p,N]);const j=b($=>$.expandedContainers),C=b($=>$.containerLayoutCache),I=b($=>$.setContainerLayout),E=b($=>$.bumpStage1Tick),w=y.containers,M=y.intraContainer;return v.useEffect(()=>{if(w.length===0)return;const $=[...j].filter(P=>!C.has(P));if($.length===0)return;let D=!1;const Z=b.getState().containerSizeMemory;return Promise.all($.map(async P=>{const V=w.find(K=>K.id===P);if(!V)return null;const R=new Set(V.nodeIds),U=M.filter(K=>R.has(K.source)&&R.has(K.target)),A=V.nodeIds.map(K=>({id:K,width:de,height:ue})),Q=U.map((K,z)=>({id:`${P}-e${z}`,sources:[K.source],targets:[K.target]})),se={id:P,layoutOptions:Vt,children:A,edges:Q};try{const{positioned:K,issues:z}=await yt(se,{strict:!1});z.length>0&&b.getState().appendLayoutIssues(z);const J=new Map;let S=0,Y=0;for(const Ce of K.children??[]){const Ae=Ce.x??0,Pe=Ce.y??0,L=Ce.width??de,B=Ce.height??ue;J.set(Ce.id,{x:Ae,y:Pe}),Ae+L>S&&(S=Ae+L),Pe+B>Y&&(Y=Pe+B)}const G={width:S+40,height:Y+60},te=Z.get(P),we=800,ve=600,ze=(te==null?void 0:te.width)??Math.min(we,Math.max(de,Math.sqrt(V.nodeIds.length)*de*1.2)),Ke=(te==null?void 0:te.height)??Math.min(ve,Math.max(ue,Math.sqrt(V.nodeIds.length)*ue*1.2)),Je=Math.abs(G.width-ze)/ze,Ye=Math.abs(G.height-Ke)/Ke,_t=Je>.2||Ye>.2;return{containerId:P,childPositions:J,actualSize:G,deviated:_t}}catch(K){return console.error(`[Stage 2 ${P}] layout failed:`,K),null}})).then(P=>{if(D)return;let V=!1;for(const R of P)R&&(I(R.containerId,R.childPositions,R.actualSize),R.deviated&&(V=!0));V&&E()}),()=>{D=!0}},[j,w,M,C,I,E]),{...y,layoutStatus:k}}function lu(e,t){var n;return{id:e.id,type:"custom",position:{x:0,y:0},data:{label:e.name??((n=e.filePath)==null?void 0:n.split("/").pop())??e.id,nodeType:e.type,summary:e.summary,complexity:e.complexity,tags:e.tags,isHighlighted:!1,searchScore:void 0,isSelected:!1,isTourHighlighted:!1,isDiffChanged:t.diffMode&&t.changedNodeIds.has(e.id),isDiffAffected:t.diffMode&&t.affectedNodeIds.has(e.id),isDiffFaded:t.diffMode&&!t.changedNodeIds.has(e.id)&&!t.affectedNodeIds.has(e.id),isNeighbor:!1,isSelectionFaded:!1,onNodeClick:t.onNodeClick}}}function uu(){const e=b(j=>j.selectedNodeId),t=b(j=>j.searchResults),n=b(j=>j.tourHighlightedNodeIds),o=b(j=>j.expandedContainers),r=b(j=>j.containerLayoutCache),s=b(j=>j.diffMode),i=b(j=>j.changedNodeIds),c=b(j=>j.affectedNodeIds),d=b(j=>j.focusNodeId),l=b(j=>j.selectNode),u=v.useCallback(j=>l(j),[l]),f=du(),h=v.useMemo(()=>{if(o.size===0)return[];const j=[],C=new Map(f.filteredNodes.map(I=>[I.id,I]));for(const I of o){const E=r.get(I),w=f.containers.find(M=>M.id===I);if(!(!E||!w))for(const M of w.nodeIds){const $=C.get(M),D=E.childPositions.get(M);if(!$||!D)continue;const Z=lu($,{diffMode:s,changedNodeIds:i,affectedNodeIds:c,onNodeClick:u});j.push({...Z,parentId:I,extent:"parent",position:D})}}return j},[o,r,f.containers,f.filteredNodes,s,i,c,u]),g=v.useMemo(()=>{const j=new Map;if(t.length===0)return j;for(const C of t){const I=f.nodeToContainer.get(C.nodeId);!I||I===C.nodeId||j.set(I,(j.get(I)??0)+1)}return j},[t,f.nodeToContainer]),m=v.useMemo(()=>{const j=new Set;if(!s)return j;for(const C of i){const I=f.nodeToContainer.get(C);I&&I!==C&&j.add(I)}for(const C of c){const I=f.nodeToContainer.get(C);I&&I!==C&&j.add(I)}return j},[s,i,c,f.nodeToContainer]),p=v.useMemo(()=>{const j=new Set;if(!d)return j;const C=f.nodeToContainer.get(d);C&&C!==d&&j.add(C);for(const I of f.filteredEdges)if(I.source===d){const E=f.nodeToContainer.get(I.target);E&&E!==I.target&&j.add(E)}else if(I.target===d){const E=f.nodeToContainer.get(I.source);E&&E!==I.source&&j.add(E)}return j},[d,f.filteredEdges,f.nodeToContainer]),N=v.useMemo(()=>{const j=new Set;if(!e)return j;const C=f.nodeToContainer.get(e);C&&C!==e&&j.add(C);for(const I of f.filteredEdges)if(I.source===e){const E=f.nodeToContainer.get(I.target);E&&E!==I.target&&j.add(E)}else if(I.target===e){const E=f.nodeToContainer.get(I.source);E&&E!==I.source&&j.add(E)}return j},[e,f.filteredEdges,f.nodeToContainer]),y=v.useMemo(()=>{const j=[...f.nodes,...h],C=new Map(t.map(w=>[w.nodeId,w.score])),I=new Set(n),E=new Set;if(e){for(const w of f.filteredEdges)w.source===e&&E.add(w.target),w.target===e&&E.add(w.source);E.add(e)}return j.map(w=>{if(w.type==="portal")return w;if(w.type==="container"){const A=String(w.id),Q=w.data,se=o.has(A),K=g.get(A)??0,z=K>0,J=z?K:void 0,S=m.has(A),Y=p.has(A)||N.has(A);return Q.isExpanded===se&&Q.hasSearchHits===z&&Q.searchHitCount===J&&Q.isDiffAffected===S&&Q.isFocusedViaChild===Y?w:{...w,data:{...Q,isExpanded:se,hasSearchHits:z,searchHitCount:J,isDiffAffected:S,isFocusedViaChild:Y}}}const M=C.get(w.id),$=M!==void 0,D=e===w.id,Z=I.has(w.id),P=!!e,V=P&&E.has(w.id)&&!D,R=P&&!E.has(w.id),U=w.data;return U.isHighlighted===$&&U.searchScore===M&&U.isSelected===D&&U.isTourHighlighted===Z&&U.isNeighbor===V&&U.isSelectionFaded===R?w:{...w,data:{...U,isHighlighted:$,searchScore:M,isSelected:D,isTourHighlighted:Z,isNeighbor:V,isSelectionFaded:R}}})},[f.nodes,h,f.filteredEdges,e,t,n,o,g,m,p,N]),x=v.useMemo(()=>{if(o.size===0)return f.edges;const j=[],C=new Set;for(const I of f.edges){const E=String(I.source),w=String(I.target),M=o.has(E),$=o.has(w);if(!M&&!$){j.push(I);continue}const D=f.filteredEdges.filter(Z=>{const P=f.nodeToContainer.get(Z.source),V=f.nodeToContainer.get(Z.target);return P===E&&V===w});for(const Z of D){const P=M?Z.source:E,V=$?Z.target:w,R=`${P}|${V}|${Z.type}`;C.has(R)||(C.add(R),j.push({id:`inflated-${R}`,source:P,target:V,label:Z.type,style:{stroke:"rgba(212,165,116,0.5)",strokeWidth:1.5},labelStyle:{fill:"#a39787",fontSize:10}}))}}for(const I of f.intraContainer){const E=f.nodeToContainer.get(I.source);if(!E||!o.has(E))continue;const w=`intra|${I.source}|${I.target}|${I.type}`;C.has(w)||(C.add(w),j.push({id:w,source:I.source,target:I.target,label:I.type,style:{stroke:"rgba(212,165,116,0.5)",strokeWidth:1.5},labelStyle:{fill:"#a39787",fontSize:10}}))}return j},[f.edges,f.filteredEdges,f.intraContainer,f.nodeToContainer,o]),k=v.useMemo(()=>{const j=[...x,...f.portalEdges];return e?j.map(C=>{var E;const I=C.source===e||C.target===e;return(E=C.style)!=null&&E.strokeDasharray?C:I?{...C,animated:!0,style:{stroke:"rgba(212,165,116,0.8)",strokeWidth:2.5},labelStyle:{fill:"#d4a574",fontSize:11,fontWeight:600}}:{...C,animated:!1,style:{stroke:"rgba(212,165,116,0.08)",strokeWidth:1},labelStyle:{fill:"rgba(163,151,135,0.2)",fontSize:10}}}):j},[x,f.portalEdges,e]),T=v.useMemo(()=>f.containers.map(j=>j.id),[f.containers]);return{nodes:y,edges:k,nodeToContainer:f.nodeToContainer,containerIds:T,layoutStatus:f.layoutStatus}}function fu(){const e=b(z=>z.graph),t=b(z=>z.navigationLevel),n=b(z=>z.activeLayerId),o=b(z=>z.selectNode),r=b(z=>z.drillIntoLayer),s=b(z=>z.focusNodeId),i=b(z=>z.setFocusNode),c=b(z=>z.setReactFlowInstance),d=b(z=>z.tourHighlightedNodeIds),l=b(z=>z.expandContainer),u=b(z=>z.collapseContainer),f=b(z=>z.pendingFocusContainer),h=b(z=>z.setPendingFocusContainer),g=b(z=>z.tourFitPending),{preset:m}=Qo(),p=cu(),N=uu(),{nodes:y,edges:x,nodeToContainer:k,containerIds:T,layoutStatus:j}=t==="overview"?{...p,nodeToContainer:void 0,containerIds:void 0}:N,[C,I,E]=vr(y),[w,M,$]=kr(x),{fitView:D,getViewport:Z,setCenter:P}=Ut();v.useEffect(()=>{I(y)},[y,I]),v.useEffect(()=>{M(x)},[x,M]);const V=v.useRef(!1);v.useEffect(()=>{V.current=!0},[t,n]),v.useEffect(()=>{if(!V.current||C.length===0)return;V.current=!1;const z=requestAnimationFrame(()=>{D({duration:400,padding:.2})});return()=>cancelAnimationFrame(z)},[C,D]),v.useEffect(()=>{var we,ve;if(!f)return;const z=C.find(ze=>ze.id===f);if(!z)return;const J=z.width??((we=z.style)==null?void 0:we.width)??0,S=z.height??((ve=z.style)==null?void 0:ve.height)??0,Y=z.position.x+J/2,G=z.position.y+S/2,{zoom:te}=Z();P(Y,G,{zoom:te,duration:0})},[f,C,Z,P]),v.useEffect(()=>{if(!f)return;const z=window.setTimeout(()=>h(null),1200);return()=>window.clearTimeout(z)},[f,h]),v.useEffect(()=>{if(!s||!k)return;const z=k.get(s);z&&z!==s&&l(z)},[s,k,l]);const R=v.useRef(new Set);v.useEffect(()=>{if(!k)return;const z=new Set;for(const Y of d){const G=k.get(Y);G&&G!==Y&&z.add(G)}const J=new Set;for(const Y of R.current)z.has(Y)?J.add(Y):u(Y);const S=b.getState().expandedContainers;for(const Y of z)S.has(Y)||(l(Y),J.add(Y));R.current=J},[d,k,l,u]);const U=v.useRef(null),A=v.useRef(null),Q=v.useCallback(z=>{z!==null&&(!T||T.length===0||(U.current!==null&&window.clearTimeout(U.current),U.current=window.setTimeout(()=>{const J=Z(),S=A.current;if(A.current=J.zoom,J.zoom<=1||S!==null&&J.zoom<=S)return;const Y=b.getState().expandedContainers;for(const G of T)Y.has(G)||l(G)},200)))},[T,Z,l]);v.useEffect(()=>()=>{U.current!==null&&(window.clearTimeout(U.current),U.current=null)},[Q]);const se=v.useCallback((z,J)=>{if(t==="overview")r(J.id);else if(J.id.startsWith("portal:")){const S=J.id.replace("portal:","");r(S)}else o(J.id)},[t,r,o]),K=v.useCallback(()=>{o(null)},[o]);return e?a.jsxs("div",{className:"h-full w-full relative",children:[a.jsx(Sl,{}),s&&t==="layer-detail"&&a.jsx("div",{className:"absolute top-14 left-1/2 -translate-x-1/2 z-10",children:a.jsxs("button",{onClick:()=>i(null),className:"px-4 py-2 rounded-full bg-elevated border border-gold/30 text-gold text-xs font-semibold tracking-wider uppercase hover:bg-gold/10 transition-colors flex items-center gap-2 shadow-lg",children:[a.jsx("span",{children:"Showing neighborhood"}),a.jsx("span",{className:"text-text-muted",children:"×"})]})}),a.jsxs(Wt,{nodes:C,edges:w,onNodesChange:E,onEdgesChange:$,onNodeClick:se,onPaneClick:K,onMove:t==="layer-detail"?Q:void 0,onInit:c,nodeTypes:ru,nodesDraggable:!1,nodesConnectable:!1,edgesFocusable:!1,edgesReconnectable:!1,elementsSelectable:!1,fitView:!0,fitViewOptions:{minZoom:.01,padding:.1},minZoom:.01,maxZoom:2,colorMode:m.isDark?"dark":"light",children:[a.jsx(Kt,{variant:Jt.Dots,color:"var(--color-edge-dot)",gap:20,size:1}),a.jsx(Yt,{}),a.jsx(Xt,{nodeColor:"var(--color-elevated)",maskColor:"var(--glass-bg)",className:"!bg-surface !border !border-border-subtle"}),a.jsx(au,{}),a.jsx(iu,{})]}),(j==="computing"||g)&&a.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(10,10,10,0.5)",pointerEvents:"none",zIndex:10},children:a.jsx("span",{style:{color:"#d4a574",fontSize:14},children:g?"Locating tour highlight…":"Computing layout…"})})]}):a.jsx("div",{className:"h-full w-full flex items-center justify-center bg-root rounded-lg",children:a.jsx("p",{className:"text-text-muted text-sm",children:"No knowledge graph loaded"})})}function nr(){return a.jsx(Ht,{children:a.jsx(fu,{})})}function pu({data:e}){const t=b(s=>s.navigateToDomain),n=b(s=>s.selectedNodeId),o=b(s=>s.selectNode),r=n===e.domainId;return a.jsxs("div",{className:`rounded-xl border-2 px-5 py-4 min-w-[280px] max-w-[360px] cursor-pointer transition-all ${r?"border-accent bg-accent/10 shadow-lg shadow-accent/10":"border-accent/40 bg-surface hover:border-accent/70"}`,onClick:()=>o(e.domainId),onDoubleClick:()=>t(e.domainId),children:[a.jsx(fe,{type:"target",position:pe.Left,className:"!bg-accent/60 !w-2 !h-2"}),a.jsx(fe,{type:"source",position:pe.Right,className:"!bg-accent/60 !w-2 !h-2"}),a.jsx("div",{className:"font-heading text-sm text-accent font-semibold mb-1 truncate",children:e.label}),a.jsx("div",{className:"text-[11px] text-text-secondary line-clamp-2 mb-2",children:e.summary}),e.entities&&e.entities.length>0&&a.jsxs("div",{className:"mb-2",children:[a.jsx("div",{className:"text-[9px] uppercase tracking-wider text-text-muted mb-1",children:"Entities"}),a.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.entities.slice(0,5).map(s=>a.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-elevated text-text-secondary",children:s},s)),e.entities.length>5&&a.jsxs("span",{className:"text-[10px] text-text-muted",children:["+",e.entities.length-5]})]})]}),a.jsxs("div",{className:"text-[10px] text-text-muted",children:[e.flowCount," flow",e.flowCount!==1?"s":""]})]})}const hu=v.memo(pu);function mu({data:e}){const t=b(r=>r.selectNode),o=b(r=>r.selectedNodeId)===e.flowId;return a.jsxs("div",{className:`rounded-lg border px-4 py-3 min-w-[240px] max-w-[320px] cursor-pointer transition-all ${o?"border-accent bg-accent/10":"border-border-medium bg-surface hover:border-accent/50"}`,onClick:()=>t(e.flowId),children:[a.jsx(fe,{type:"target",position:pe.Left,className:"!bg-accent/60 !w-2 !h-2"}),a.jsx(fe,{type:"source",position:pe.Right,className:"!bg-accent/60 !w-2 !h-2"}),e.entryPoint&&a.jsx("div",{className:"text-[9px] font-mono text-accent/70 mb-1 truncate",children:e.entryPoint}),a.jsx("div",{className:"text-xs font-semibold text-text-primary mb-1 truncate",children:e.label}),a.jsx("div",{className:"text-[10px] text-text-secondary line-clamp-2",children:e.summary}),a.jsxs("div",{className:"text-[9px] text-text-muted mt-1",children:[e.stepCount," step",e.stepCount!==1?"s":""]})]})}const gu=v.memo(mu);function xu({data:e}){const t=b(r=>r.selectNode),o=b(r=>r.selectedNodeId)===e.stepId;return a.jsxs("div",{className:`rounded-lg border px-3 py-2.5 min-w-[180px] max-w-[240px] cursor-pointer transition-all ${o?"border-accent bg-accent/10":"border-border-subtle bg-elevated hover:border-accent/40"}`,onClick:()=>t(e.stepId),children:[a.jsx(fe,{type:"target",position:pe.Left,className:"!bg-text-muted/40 !w-1.5 !h-1.5"}),a.jsx(fe,{type:"source",position:pe.Right,className:"!bg-text-muted/40 !w-1.5 !h-1.5"}),a.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[a.jsx("span",{className:"text-[9px] font-mono text-accent/60 shrink-0",children:e.order}),a.jsx("span",{className:"text-[11px] font-medium text-text-primary truncate",children:e.label})]}),a.jsx("div",{className:"text-[10px] text-text-secondary line-clamp-2",children:e.summary}),e.filePath&&a.jsx("div",{className:"text-[9px] font-mono text-text-muted mt-1 truncate",children:e.filePath})]})}const bu=v.memo(xu),yu={"domain-cluster":hu,"flow-node":gu,"step-node":bu};function or(e){return e.domainMeta}function wu(e){const t=new Map,n=e.nodes.filter(i=>i.type==="domain"),o=new Map;for(const i of e.edges)i.type==="contains_flow"&&o.set(i.source,(o.get(i.source)??0)+1);const r=n.map(i=>{const c=or(i),d={label:i.name,summary:i.summary,entities:c==null?void 0:c.entities,flowCount:o.get(i.id)??0,businessRules:c==null?void 0:c.businessRules,domainId:i.id};return t.set(i.id,{width:320,height:180}),{id:i.id,type:"domain-cluster",position:{x:0,y:0},data:d}}),s=e.edges.filter(i=>i.type==="cross_domain").map((i,c)=>({id:`cd-${c}-${i.source}-${i.target}`,source:i.source,target:i.target,label:i.description??"",style:{stroke:"var(--color-accent)",strokeDasharray:"6 3",strokeWidth:2},labelStyle:{fill:"var(--color-text-muted)",fontSize:10},labelBgStyle:{fill:"var(--color-surface)",fillOpacity:.9},labelBgPadding:[6,4],labelBgBorderRadius:4,animated:!0}));return{nodes:r,edges:s,dims:t}}function vu(e,t){const n=new Set(e.edges.filter(m=>m.type==="contains_flow"&&m.source===t).map(m=>m.target)),o=e.nodes.filter(m=>n.has(m.id)),r=e.edges.filter(m=>m.type==="flow_step"&&n.has(m.source)),s=new Set(r.map(m=>m.target)),i=e.nodes.filter(m=>s.has(m.id)),c=new Map;for(const m of r)c.set(m.target,m.weight);const d=new Map;for(const m of r)d.set(m.source,(d.get(m.source)??0)+1);const l=new Map,u=o.map(m=>{const p=or(m);return l.set(m.id,{width:260,height:120}),{id:m.id,type:"flow-node",position:{x:0,y:0},data:{label:m.name,summary:m.summary,entryPoint:p==null?void 0:p.entryPoint,entryType:p==null?void 0:p.entryType,stepCount:d.get(m.id)??0,flowId:m.id}}}),f=i.map(m=>(l.set(m.id,{width:200,height:90}),{id:m.id,type:"step-node",position:{x:0,y:0},data:{label:m.name,summary:m.summary,filePath:m.filePath,stepId:m.id,order:Math.round((c.get(m.id)??0)*10)}})),h=[...u,...f],g=r.map((m,p)=>({id:`fs-${p}-${m.source}-${m.target}`,source:m.source,target:m.target,style:{stroke:"var(--color-border-medium)",strokeWidth:1.5},animated:!1}));return{nodes:h,edges:g,dims:l}}function ku(){const e=b(l=>l.domainGraph),t=b(l=>l.activeDomainId),n=b(l=>l.clearActiveDomain),{t:o}=re(),r=v.useMemo(()=>e?t?vu(e,t):wu(e):null,[e,t]),[s,i]=v.useState({nodes:[],edges:[]});v.useEffect(()=>{if(!r){i({nodes:[],edges:[]});return}let l=!1;const{nodes:u,edges:f,dims:h}=r,g=er(u,f,h,{"elk.direction":"RIGHT"});return yt(g,{strict:!1}).then(({positioned:m,issues:p})=>{l||(p.length>0&&b.getState().appendLayoutIssues(p),i({nodes:cn(u,m),edges:f}))}).catch(m=>{l||console.error("[domain ELK] layout failed:",m)}),()=>{l=!0}},[r]);const{nodes:c,edges:d}=s;return e?a.jsxs("div",{className:"h-full w-full relative",children:[t&&a.jsx("div",{className:"absolute top-3 left-3 z-10",children:a.jsx("button",{type:"button",onClick:()=>n(),className:"px-3 py-1.5 text-xs rounded-lg bg-elevated border border-border-subtle text-text-secondary hover:text-text-primary transition-colors",children:o.domainView.backToDomains})}),a.jsxs(Wt,{nodes:c,edges:d,nodeTypes:yu,fitView:!0,fitViewOptions:{padding:.2},minZoom:.1,maxZoom:2,proOptions:{hideAttribution:!0},children:[a.jsx(Kt,{variant:Jt.Dots,gap:20,size:1,color:"var(--color-border-subtle)"}),a.jsx(Yt,{}),a.jsx(Xt,{nodeColor:"var(--color-accent)",maskColor:"var(--glass-bg)",className:"!bg-surface !border !border-border-subtle"})]})]}):a.jsx("div",{className:"h-full flex items-center justify-center text-text-muted text-sm",children:"No domain graph available. Run /understand-domain to generate one."})}function rr(){return a.jsx(Ht,{children:a.jsx(ku,{})})}const Nu={custom:Wo},Qn={related:{stroke:"var(--color-border-medium)",strokeWidth:.5,opacity:.12},cites:{stroke:"var(--color-node-source)",strokeWidth:1.5,strokeDasharray:"6 3"},contradicts:{stroke:"#c97070",strokeWidth:2},builds_on:{stroke:"var(--color-node-claim)",strokeWidth:1.5},exemplifies:{stroke:"var(--color-node-entity)",strokeWidth:1,strokeDasharray:"3 3"},categorized_under:{stroke:"var(--color-border-medium)",strokeWidth:.5,opacity:.08},authored_by:{stroke:"var(--color-node-entity)",strokeWidth:1,strokeDasharray:"4 4"},implements:{stroke:"var(--color-node-function)",strokeWidth:1,opacity:.4},depends_on:{stroke:"var(--color-node-module)",strokeWidth:1,opacity:.4}};function ju(e){const t=Math.min(1.5,Math.max(.85,.85+e*.03));return{width:Math.round(de*t),height:Math.round(ue*t)}}function _u(e){const t=new Map;for(const d of e.edges)t.set(d.source,(t.get(d.source)??0)+1),t.set(d.target,(t.get(d.target)??0)+1);const n=new Map;e.layers.forEach((d,l)=>{for(const u of d.nodeIds)n.set(u,l)});const o=new Map;for(const d of e.nodes)o.set(d.id,ju(t.get(d.id)??0));const r=e.nodes.map(d=>({id:d.id,type:"custom",position:{x:0,y:0},data:{}})),s=e.edges.map((d,l)=>({id:`ke-${l}`,source:d.source,target:d.target})),{nodes:i}=Zl(r,s,o,n),c=new Map;for(const d of i)c.set(d.id,d.position);return{positionMap:c,edgeCounts:t,communityMap:n}}function Cu(){const e=b(p=>p.graph),t=b(p=>p.selectedNodeId),n=b(p=>p.focusNodeId),o=b(p=>p.selectNode),r=b(p=>p.searchResults),s=b(p=>p.tourHighlightedNodeIds),i=b(p=>p.nodeTypeFilters),c=v.useCallback(p=>o(p),[o]),d=v.useMemo(()=>new Map(r.map(p=>[p.nodeId,p.score])),[r]),l=v.useMemo(()=>new Set(s),[s]),u=v.useMemo(()=>{if(!e)return null;const p=e.nodes.filter(x=>["article","entity","topic","claim","source"].includes(x.type)?i.knowledge!==!1:!0),N=new Set(p.map(x=>x.id)),y=e.edges.filter(x=>N.has(x.source)&&N.has(x.target));return{...e,nodes:p,edges:y}},[e,i]),{positionMap:f,edgeCounts:h}=v.useMemo(()=>u?_u(u):{positionMap:new Map,edgeCounts:new Map},[u]),{nodes:g,edges:m}=v.useMemo(()=>{if(!u)return{nodes:[],edges:[]};const p=new Set;if(n||t){const k=n??t;for(const T of u.edges)T.source===k&&p.add(T.target),T.target===k&&p.add(T.source)}const N=u.nodes.map(k=>{const T=k.id===t,j=k.id===n,C=p.has(k.id),I=(n||t)&&!T&&!j&&!C,E=d.get(k.id),w=E!==void 0,M=l.has(k.id),$={label:k.name,nodeType:k.type,summary:k.summary,complexity:k.complexity,isHighlighted:w,searchScore:E,isSelected:T,isTourHighlighted:M,isDiffChanged:!1,isDiffAffected:!1,isDiffFaded:!1,isNeighbor:C,isSelectionFaded:!!I,onNodeClick:c,incomingCount:h.get(k.id)??0,tags:k.tags};return{id:k.id,type:"custom",position:f.get(k.id)??{x:0,y:0},data:$}}),y=n??t,x=u.edges.map(k=>{const T=Qn[k.type]??Qn.related,j=y&&(k.source===y||k.target===y);let C;return y?j?C={...T,strokeWidth:Math.max(2,(T.strokeWidth??1)*1.5),opacity:1}:C={...T,opacity:.04}:C=T,{id:`ke-${k.source}-${k.target}-${k.type}`,source:k.source,target:k.target,style:C,animated:k.type==="contradicts"&&(!y||!!j),label:j&&k.type!=="related"&&k.type!=="categorized_under"?k.type.replace(/_/g," "):void 0,labelStyle:{fill:"var(--color-text-muted)",fontSize:9,opacity:.7},labelBgStyle:{fill:"var(--color-surface)",fillOpacity:.9},labelBgPadding:[4,2],labelBgBorderRadius:3}});return{nodes:N,edges:x}},[u,t,n,d,l,c,f,h]);return e?a.jsx("div",{className:"h-full w-full relative",children:a.jsxs(Wt,{nodes:g,edges:m,nodeTypes:Nu,fitView:!0,fitViewOptions:{padding:.15},minZoom:.05,maxZoom:2,proOptions:{hideAttribution:!0},children:[a.jsx(Kt,{variant:Jt.Dots,gap:20,size:1,color:"var(--color-border-subtle)"}),a.jsx(Yt,{}),a.jsx(Xt,{nodeColor:p=>{const N=p.data,y=(N==null?void 0:N.nodeType)??"article";return{article:"var(--color-node-article)",entity:"var(--color-node-entity)",topic:"var(--color-node-topic)",claim:"var(--color-node-claim)",source:"var(--color-node-source)"}[y]??"var(--color-accent)"},maskColor:"var(--glass-bg)",className:"!bg-surface !border !border-border-subtle"})]})}):a.jsx("div",{className:"h-full flex items-center justify-center text-text-muted text-sm",children:"No knowledge graph available. Run /understand-knowledge to generate one."})}function sr(){return a.jsx(Ht,{children:a.jsx(Cu,{})})}const eo={file:"text-node-file border border-node-file/30 bg-node-file/10",function:"text-node-function border border-node-function/30 bg-node-function/10",class:"text-node-class border border-node-class/30 bg-node-class/10",module:"text-node-module border border-node-module/30 bg-node-module/10",concept:"text-node-concept border border-node-concept/30 bg-node-concept/10",config:"text-node-config border border-node-config/30 bg-node-config/10",document:"text-node-document border border-node-document/30 bg-node-document/10",service:"text-node-service border border-node-service/30 bg-node-service/10",table:"text-node-table border border-node-table/30 bg-node-table/10",endpoint:"text-node-endpoint border border-node-endpoint/30 bg-node-endpoint/10",pipeline:"text-node-pipeline border border-node-pipeline/30 bg-node-pipeline/10",schema:"text-node-schema border border-node-schema/30 bg-node-schema/10",resource:"text-node-resource border border-node-resource/30 bg-node-resource/10",domain:"text-node-concept border border-node-concept/30 bg-node-concept/10",flow:"text-node-pipeline border border-node-pipeline/30 bg-node-pipeline/10",step:"text-node-function border border-node-function/30 bg-node-function/10",article:"text-node-article border border-node-article/30 bg-node-article/10",entity:"text-node-entity border border-node-entity/30 bg-node-entity/10",topic:"text-node-topic border border-node-topic/30 bg-node-topic/10",claim:"text-node-claim border border-node-claim/30 bg-node-claim/10",source:"text-node-source border border-node-source/30 bg-node-source/10"};function ar(){const e=b(y=>y.searchQuery),t=b(y=>y.searchResults),n=b(y=>y.graph),o=b(y=>y.setSearchQuery),r=b(y=>y.navigateToNodeInLayer),s=b(y=>y.searchMode),i=b(y=>y.setSearchMode),{t:c}=re(),[d,l]=v.useState(!1),u=v.useRef(null),f=v.useRef(null),h=v.useMemo(()=>new Map(((n==null?void 0:n.nodes)??[]).map(y=>[y.id,y])),[n]),g=t.slice(0,5),m=v.useCallback(y=>{o(y.target.value),l(!0)},[o]),p=v.useCallback(y=>{r(y),l(!1)},[r]);v.useEffect(()=>{const y=x=>{var k;x.key==="Escape"&&(l(!1),(k=f.current)==null||k.blur())};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[]),v.useEffect(()=>{const y=x=>{u.current&&!u.current.contains(x.target)&&l(!1)};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[]);const N=d&&e.trim()&&g.length>0;return a.jsxs("div",{ref:u,className:"relative z-30",children:[a.jsxs("div",{className:"flex items-center gap-2 px-3 sm:px-4 py-2 bg-surface border-b border-border-subtle",children:[a.jsx("svg",{className:"w-4 h-4 text-text-muted shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),a.jsx("input",{ref:f,type:"text",value:e,onChange:m,onFocus:()=>l(!0),placeholder:c.search.placeholder,"data-testid":"search-input",className:"flex-1 min-w-0 bg-elevated text-text-primary text-sm rounded-lg px-3 py-1.5 border border-border-subtle focus:outline-none focus:border-accent/50 placeholder-text-muted"}),a.jsxs("div",{className:"flex items-center gap-1 bg-elevated rounded-lg p-0.5 shrink-0",children:[a.jsx("button",{onClick:()=>i("fuzzy"),className:`text-[10px] px-1.5 py-0.5 rounded transition-colors ${s==="fuzzy"?"bg-accent/20 text-accent":"text-text-muted hover:text-text-secondary"}`,children:c.search.fuzzy}),a.jsx("button",{onClick:()=>i("semantic"),className:`text-[10px] px-1.5 py-0.5 rounded transition-colors ${s==="semantic"?"bg-accent/20 text-accent":"text-text-muted hover:text-text-secondary"}`,children:c.search.semantic})]}),e.trim()&&a.jsxs("span",{className:"hidden sm:inline text-xs text-text-muted shrink-0",children:[t.length," ",c.search.result,t.length!==1?"s":""," ",a.jsxs("span",{className:"text-text-muted",children:["(",s,")"]})]})]}),N&&a.jsx("div",{className:"absolute left-4 right-4 top-full mt-0.5 glass rounded-lg shadow-xl overflow-hidden",children:g.map(y=>{const x=h.get(y.nodeId);if(!x)return null;const k=Math.round((1-y.score)*100),T=eo[x.type]??eo.file;return a.jsxs("button",{type:"button",onClick:()=>p(y.nodeId),className:"w-full flex items-center gap-3 px-3 py-2 hover:bg-elevated transition-colors text-left",children:[a.jsx("span",{className:`text-[10px] font-semibold uppercase tracking-wider px-1.5 py-0.5 rounded ${T} shrink-0`,children:x.type}),a.jsx("span",{className:"text-sm text-text-primary truncate flex-1",children:x.name}),a.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[a.jsx("div",{className:"w-16 h-1.5 bg-elevated rounded-full overflow-hidden",children:a.jsx("div",{className:"h-full bg-accent rounded-full",style:{width:`${k}%`}})}),a.jsxs("span",{className:"text-[10px] text-text-muted w-7 text-right",children:[k,"%"]})]})]},y.nodeId)})})]})}const it={file:"text-node-file border border-node-file/30 bg-node-file/10",function:"text-node-function border border-node-function/30 bg-node-function/10",class:"text-node-class border border-node-class/30 bg-node-class/10",module:"text-node-module border border-node-module/30 bg-node-module/10",concept:"text-node-concept border border-node-concept/30 bg-node-concept/10",config:"text-node-config border border-node-config/30 bg-node-config/10",document:"text-node-document border border-node-document/30 bg-node-document/10",service:"text-node-service border border-node-service/30 bg-node-service/10",table:"text-node-table border border-node-table/30 bg-node-table/10",endpoint:"text-node-endpoint border border-node-endpoint/30 bg-node-endpoint/10",pipeline:"text-node-pipeline border border-node-pipeline/30 bg-node-pipeline/10",schema:"text-node-schema border border-node-schema/30 bg-node-schema/10",resource:"text-node-resource border border-node-resource/30 bg-node-resource/10",domain:"text-node-concept border border-node-concept/30 bg-node-concept/10",flow:"text-node-pipeline border border-node-pipeline/30 bg-node-pipeline/10",step:"text-node-function border border-node-function/30 bg-node-function/10",article:"text-node-article border border-node-article/30 bg-node-article/10",entity:"text-node-entity border border-node-entity/30 bg-node-entity/10",topic:"text-node-topic border border-node-topic/30 bg-node-topic/10",claim:"text-node-claim border border-node-claim/30 bg-node-claim/10",source:"text-node-source border border-node-source/30 bg-node-source/10"},ct={simple:"text-node-function border border-node-function/30 bg-node-function/10",moderate:"text-accent-dim border border-accent-dim/30 bg-accent-dim/10",complex:"text-[#c97070] border border-[#c97070]/30 bg-[#c97070]/10"};function Su(e,t,n){const o=n.edgeLabels[e];if(!o){const r=e.replace(/_/g," ").replace(/\b\w/g,s=>s.toUpperCase());return t?r:`${r} (reverse)`}return t?o.forward:o.backward}function Iu({node:e,graph:t}){const n=b(l=>l.navigateToNode),{t:o}=re(),r=e.knowledgeMeta,s=t.edges.filter(l=>l.type==="related"&&l.source===e.id).map(l=>t.nodes.find(u=>u.id===l.target)).filter(l=>l!==void 0),i=t.edges.filter(l=>l.type==="related"&&l.target===e.id).map(l=>t.nodes.find(u=>u.id===l.source)).filter(l=>l!==void 0),c=t.edges.find(l=>l.type==="categorized_under"&&l.source===e.id),d=c?t.nodes.find(l=>l.id===c.target):null;return a.jsxs("div",{className:"space-y-3",children:[d&&a.jsxs("div",{children:[a.jsx("h4",{className:"text-[10px] uppercase tracking-wider text-text-muted mb-1",children:o.nodeInfo.category}),a.jsx("button",{type:"button",onClick:()=>n(d.id),className:"text-[11px] px-2 py-0.5 rounded bg-elevated text-accent hover:text-accent-bright transition-colors",children:d.name})]}),(r==null?void 0:r.wikilinks)&&r.wikilinks.length>0&&a.jsxs("div",{children:[a.jsxs("h4",{className:"text-[10px] uppercase tracking-wider text-text-muted mb-1",children:[o.nodeInfo.wikilinks," (",s.length,")"]}),a.jsx("div",{className:"space-y-1 max-h-[200px] overflow-auto",children:s.map(l=>a.jsx("button",{type:"button",onClick:()=>n(l.id),className:"block w-full text-left px-2 py-1.5 rounded bg-elevated hover:bg-accent/10 text-[11px] text-text-secondary hover:text-accent transition-colors truncate",children:l.name},l.id))})]}),i.length>0&&a.jsxs("div",{children:[a.jsxs("h4",{className:"text-[10px] uppercase tracking-wider text-text-muted mb-1",children:[o.nodeInfo.backlinks," (",i.length,")"]}),a.jsx("div",{className:"space-y-1 max-h-[200px] overflow-auto",children:i.map(l=>a.jsx("button",{type:"button",onClick:()=>n(l.id),className:"block w-full text-left px-2 py-1.5 rounded bg-elevated hover:bg-accent/10 text-[11px] text-text-secondary hover:text-accent transition-colors truncate",children:l.name},l.id))})]}),(r==null?void 0:r.content)&&a.jsxs("div",{children:[a.jsx("h4",{className:"text-[10px] uppercase tracking-wider text-text-muted mb-1",children:o.common.preview}),a.jsx("div",{className:"text-[11px] text-text-secondary leading-relaxed bg-elevated rounded-lg p-3 max-h-[520px] overflow-auto whitespace-pre-wrap font-mono",children:r.content})]})]})}function Tu({node:e,graph:t}){const n=b(i=>i.navigateToDomain),o=b(i=>i.selectNode),{t:r}=re(),s=e.domainMeta;if(e.type==="domain"){const i=t.edges.filter(c=>c.type==="contains_flow"&&c.source===e.id).map(c=>t.nodes.find(d=>d.id===c.target)).filter(c=>c!==void 0);return a.jsxs("div",{className:"space-y-3",children:[Array.isArray(s==null?void 0:s.entities)&&s.entities.length>0?a.jsxs("div",{children:[a.jsx("h4",{className:"text-[10px] uppercase tracking-wider text-text-muted mb-1",children:r.nodeInfo.entities}),a.jsx("div",{className:"flex flex-wrap gap-1",children:s.entities.map(c=>a.jsx("span",{className:"text-[11px] px-2 py-0.5 rounded bg-elevated text-text-secondary",children:c},c))})]}):null,Array.isArray(s==null?void 0:s.businessRules)&&s.businessRules.length>0?a.jsxs("div",{children:[a.jsx("h4",{className:"text-[10px] uppercase tracking-wider text-text-muted mb-1",children:r.nodeInfo.businessRules}),a.jsx("ul",{className:"text-[11px] text-text-secondary space-y-1",children:s.businessRules.map((c,d)=>a.jsxs("li",{className:"flex gap-1.5",children:[a.jsx("span",{className:"text-accent shrink-0",children:"-"}),c]},d))})]}):null,Array.isArray(s==null?void 0:s.crossDomainInteractions)&&s.crossDomainInteractions.length>0?a.jsxs("div",{children:[a.jsx("h4",{className:"text-[10px] uppercase tracking-wider text-text-muted mb-1",children:r.nodeInfo.crossDomain}),a.jsx("ul",{className:"text-[11px] text-text-secondary space-y-1",children:s.crossDomainInteractions.map((c,d)=>a.jsx("li",{children:c},d))})]}):null,i.length>0&&a.jsxs("div",{children:[a.jsx("h4",{className:"text-[10px] uppercase tracking-wider text-text-muted mb-1",children:r.nodeInfo.flows}),a.jsx("div",{className:"space-y-1",children:i.map(c=>a.jsx("button",{type:"button",onClick:()=>{n(e.id),o(c.id)},className:"block w-full text-left px-2 py-1.5 rounded bg-elevated hover:bg-accent/10 text-[11px] text-text-secondary hover:text-accent transition-colors",children:c.name},c.id))})]})]})}if(e.type==="flow"){const i=t.edges.filter(c=>c.type==="flow_step"&&c.source===e.id).sort((c,d)=>c.weight-d.weight).map(c=>t.nodes.find(d=>d.id===c.target)).filter(c=>c!==void 0);return a.jsxs("div",{className:"space-y-3",children:[s!=null&&s.entryPoint?a.jsxs("div",{children:[a.jsx("h4",{className:"text-[10px] uppercase tracking-wider text-text-muted mb-1",children:r.nodeInfo.entryPoint}),a.jsx("div",{className:"text-[11px] font-mono text-accent",children:s.entryPoint})]}):null,i.length>0&&a.jsxs("div",{children:[a.jsx("h4",{className:"text-[10px] uppercase tracking-wider text-text-muted mb-1",children:r.nodeInfo.steps}),a.jsx("ol",{className:"space-y-1",children:i.map((c,d)=>a.jsx("li",{children:a.jsxs("button",{type:"button",onClick:()=>o(c.id),className:"block w-full text-left px-2 py-1.5 rounded bg-elevated hover:bg-accent/10 text-[11px] transition-colors",children:[a.jsxs("span",{className:"text-accent/60 mr-1.5",children:[d+1,"."]}),a.jsx("span",{className:"text-text-secondary hover:text-accent",children:c.name})]})},c.id))})]})]})}return e.type==="step"&&e.filePath?a.jsx("div",{className:"space-y-3",children:a.jsxs("div",{children:[a.jsx("h4",{className:"text-[10px] uppercase tracking-wider text-text-muted mb-1",children:r.nodeInfo.implementation}),a.jsxs("div",{className:"text-[11px] font-mono text-text-secondary",children:[e.filePath,e.lineRange&&a.jsxs("span",{className:"text-text-muted",children:[":",e.lineRange[0],"-",e.lineRange[1]]})]})]})}):null}function ir(){const e=b(w=>w.graph),t=b(w=>w.selectedNodeId),n=b(w=>w.nodeHistory),o=b(w=>w.goBackNode),[r,s]=v.useState(!0),{t:i}=re(),c=b(w=>w.navigateToNode),d=b(w=>w.navigateToHistoryIndex),l=b(w=>w.setFocusNode),u=b(w=>w.openCodeViewer),f=b(w=>w.focusNodeId),h=b(w=>w.viewMode),g=b(w=>w.domainGraph),m=h==="domain"&&g?g:e,p=(m==null?void 0:m.nodes.find(w=>w.id===t))??null,N=n.map(w=>{const M=m==null?void 0:m.nodes.find($=>$.id===w);return{id:w,name:(M==null?void 0:M.name)??w}});if(!p)return a.jsx("div",{className:"h-full w-full flex items-center justify-center bg-surface",children:a.jsx("p",{className:"text-text-muted text-sm",children:i.common.selectNode})});const x=((m==null?void 0:m.edges)??[]).filter(w=>w.source===p.id||w.target===p.id),k=x.filter(w=>w.type==="contains"&&w.source===p.id),T=x.filter(w=>!(w.type==="contains"&&w.source===p.id)),j=k.map(w=>m==null?void 0:m.nodes.find(M=>M.id===w.target)).filter(w=>w!==void 0),C=p.type,I=it[C]??it.file,E=ct[p.complexity]??ct.simple;return a.jsxs("div",{className:"h-full w-full overflow-auto p-5 animate-fade-slide-in",children:[N.length>0&&a.jsxs("div",{className:"mb-3 flex items-center gap-1 flex-wrap",children:[a.jsxs("button",{onClick:o,className:"text-[10px] font-semibold text-gold hover:text-gold-bright transition-colors flex items-center gap-1",children:[a.jsx("span",{children:"←"}),a.jsx("span",{children:i.common.back})]}),a.jsx("span",{className:"text-text-muted text-[10px]",children:"│"}),N.slice(-3).map((w,M,$)=>a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx("button",{onClick:()=>{const D=N.length-$.length+M;d(D)},className:"text-[10px] text-text-muted hover:text-gold transition-colors truncate max-w-[80px]",title:w.name,children:w.name}),M<$.length-1&&a.jsx("span",{className:"text-text-muted text-[10px]",children:"›"})]},`${w.id}-${M}`)),a.jsx("span",{className:"text-text-muted text-[10px]",children:"›"}),a.jsx("span",{className:"text-[10px] text-text-primary font-medium truncate max-w-[80px]",children:p.name})]}),a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsx("span",{className:`text-[10px] font-semibold uppercase tracking-wider px-2 py-0.5 rounded ${I}`,children:p.type}),a.jsx("span",{className:`text-[10px] font-semibold px-2 py-0.5 rounded ${E}`,children:p.complexity})]}),a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("h2",{className:"text-lg font-heading text-text-primary",children:p.name}),a.jsx("button",{onClick:()=>l(f===p.id?null:p.id),className:`text-[10px] font-semibold uppercase tracking-wider px-2.5 py-1 rounded transition-colors ${f===p.id?"bg-gold/20 text-gold border border-gold/40":"text-text-muted border border-border-subtle hover:text-gold hover:border-gold/30"}`,children:f===p.id?i.common.unfocus:i.common.focus})]}),a.jsx("p",{className:"text-sm text-text-secondary mb-4 leading-relaxed",children:p.summary}),p.filePath&&a.jsx("div",{className:"text-xs text-text-secondary mb-4 rounded-lg border border-border-subtle bg-elevated/60 p-3",children:a.jsxs("div",{className:"flex items-start justify-between gap-3",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"font-medium text-text-muted mb-1",children:i.common.file}),a.jsxs("div",{className:"font-mono truncate",title:p.filePath,children:[p.filePath,p.lineRange&&a.jsxs("span",{className:"ml-2 text-text-muted",children:["L",p.lineRange[0],"-",p.lineRange[1]]})]})]}),a.jsx("button",{type:"button",onClick:()=>u(p.id),className:"shrink-0 text-[10px] font-semibold uppercase tracking-wider px-2.5 py-1 rounded border border-accent/30 text-accent hover:text-accent-bright hover:border-accent/60 transition-colors",children:"查看文档"})]})}),p.languageNotes&&a.jsxs("div",{className:"mb-4",children:[a.jsxs("button",{onClick:()=>s(!r),className:"flex items-center gap-1.5 text-xs font-semibold text-accent uppercase tracking-wider mb-2 hover:text-accent-bright transition-colors",children:[a.jsx("svg",{className:`w-3 h-3 transition-transform ${r?"rotate-90":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),i.nodeInfo.languageConcepts]}),r&&a.jsx("div",{className:"bg-accent/5 border border-accent/20 rounded-lg p-3",children:a.jsx("p",{className:"text-sm text-text-secondary leading-relaxed",children:p.languageNotes})})]}),p.tags.length>0&&a.jsxs("div",{className:"mb-4",children:[a.jsx("h3",{className:"text-[11px] font-semibold text-accent uppercase tracking-wider mb-2",children:i.common.tags}),a.jsx("div",{className:"flex flex-wrap gap-1.5",children:p.tags.map(w=>a.jsx("span",{className:"text-[11px] glass text-text-secondary px-2.5 py-1 rounded-full",children:w},w))})]}),m&&p&&(p.type==="article"||p.type==="entity"||p.type==="topic"||p.type==="claim"||p.type==="source"||p.knowledgeMeta)&&a.jsx(Iu,{node:p,graph:m}),m&&p&&(p.type==="domain"||p.type==="flow"||p.type==="step")&&a.jsx(Tu,{node:p,graph:m}),j.length>0&&a.jsxs("div",{className:"mb-4",children:[a.jsxs("h3",{className:"text-[11px] font-semibold text-gold uppercase tracking-wider mb-2",children:[i.nodeInfo.definedInThisFile," (",j.length,")"]}),a.jsx("div",{className:"space-y-1",children:j.map(w=>{if(!w)return null;const M=it[w.type]??it.file,$=ct[w.complexity]??ct.simple;return a.jsxs("div",{className:"text-xs bg-elevated rounded-lg px-3 py-2 border border-border-subtle cursor-pointer hover:border-gold/40 hover:bg-gold/5 transition-colors",onClick:()=>c(w.id),children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`text-[9px] font-semibold uppercase tracking-wider px-1.5 py-0.5 rounded ${M}`,children:w.type}),a.jsx("span",{className:"text-text-primary truncate",children:w.name}),a.jsx("span",{className:`text-[9px] ml-auto ${$} px-1 py-0.5 rounded`,children:w.complexity})]}),w.summary&&a.jsx("p",{className:"text-[11px] text-text-muted mt-1 line-clamp-1 pl-1",children:w.summary})]},w.id)})})]}),T.length>0&&a.jsxs("div",{children:[a.jsxs("h3",{className:"text-[11px] font-semibold text-gold uppercase tracking-wider mb-2",children:[i.common.connections," (",T.length,")"]}),a.jsx("div",{className:"space-y-1.5",children:T.map((w,M)=>{const $=w.source===p.id,D=$?w.target:w.source,Z=m==null?void 0:m.nodes.find(R=>R.id===D),P=Su(w.type,$,i),V=$?"→":"←";return a.jsxs("div",{className:"text-xs bg-elevated rounded-lg px-3 py-2 border border-border-subtle flex items-center gap-2 cursor-pointer hover:border-gold/40 hover:bg-gold/5 transition-colors",onClick:()=>{c(D)},children:[a.jsx("span",{className:"text-gold font-mono",children:V}),a.jsx("span",{className:"text-text-muted",children:P}),a.jsx("span",{className:"text-text-primary truncate",children:(Z==null?void 0:Z.name)??D})]},M)})})]})]})}function cr(){const e=b(i=>i.diffMode),t=b(i=>i.toggleDiffMode),n=b(i=>i.changedNodeIds),o=b(i=>i.affectedNodeIds),{t:r}=re(),s=n.size>0;return a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("button",{onClick:t,disabled:!s,className:`px-2 py-0.5 rounded text-[11px] font-medium transition-colors ${e&&s?"bg-[var(--color-diff-changed-dim)] text-[var(--color-diff-changed)]":s?"bg-elevated text-text-secondary hover:bg-surface":"bg-elevated text-text-muted cursor-not-allowed"}`,title:s?e?r.diffToggle.hideOverlay:r.diffToggle.showOverlay:r.diffToggle.noData,children:["Diff ",e&&s?"ON":"OFF"]}),e&&s&&a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("span",{className:"inline-block w-2 h-2 rounded-full",style:{backgroundColor:"var(--color-diff-changed)"}}),a.jsxs("span",{className:"text-text-secondary text-[11px]",children:[r.diffToggle.changed,a.jsxs("span",{className:"text-text-muted ml-0.5",children:["(",n.size,")"]})]})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("span",{className:"inline-block w-2 h-2 rounded-full",style:{backgroundColor:"var(--color-diff-affected)"}}),a.jsxs("span",{className:"text-text-secondary text-[11px]",children:[r.diffToggle.affected,a.jsxs("span",{className:"text-text-muted ml-0.5",children:["(",o.size,")"]})]})]})]})]})}function dr(){const e=b(x=>x.graph),t=b(x=>x.filters),n=b(x=>x.setFilters),o=b(x=>x.resetFilters),r=b(x=>x.hasActiveFilters),s=b(x=>x.filterPanelOpen),i=b(x=>x.toggleFilterPanel),{t:c}=re(),d=v.useRef(null),l=gt,u=xt,f=bt,h=(e==null?void 0:e.layers)??[];v.useEffect(()=>{const x=k=>{d.current&&!d.current.contains(k.target)&&s&&i()};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[s,i]);const g=x=>{const k=new Set(t.nodeTypes);k.has(x)?k.delete(x):k.add(x),n({nodeTypes:k})},m=x=>{const k=new Set(t.complexities);k.has(x)?k.delete(x):k.add(x),n({complexities:k})},p=x=>{const k=new Set(t.layerIds);k.has(x)?k.delete(x):k.add(x),n({layerIds:k})},N=x=>{const k=new Set(t.edgeCategories);k.has(x)?k.delete(x):k.add(x),n({edgeCategories:k})},y=r();return a.jsxs("div",{ref:d,className:"relative",children:[a.jsxs("button",{onClick:i,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm transition-colors ${y?"bg-gold/20 text-gold hover:bg-gold/30":"bg-elevated text-text-secondary hover:text-text-primary"}`,title:"Filter graph (F)",children:[a.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 4a1 1 0 011-1h16a1 1 0 011 1v2.586a1 1 0 01-.293.707l-6.414 6.414a1 1 0 00-.293.707V17l-4 4v-6.586a1 1 0 00-.293-.707L3.293 7.293A1 1 0 013 6.586V4z"})}),c.common.filter]}),s&&a.jsx("div",{className:"absolute right-0 top-full mt-2 w-72 glass rounded-lg shadow-xl overflow-hidden animate-fade-slide-in z-50",children:a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-xs font-semibold text-text-secondary uppercase tracking-wider mb-2",children:c.filterPanel.nodeTypes}),a.jsx("div",{className:"space-y-1.5",children:l.map(x=>a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer hover:bg-elevated/50 rounded px-2 py-1 transition-colors",children:[a.jsx("input",{type:"checkbox",checked:t.nodeTypes.has(x),onChange:()=>g(x),className:"w-3.5 h-3.5 rounded border-border-subtle bg-elevated checked:bg-gold checked:border-gold focus:ring-0 focus:ring-offset-0 cursor-pointer"}),a.jsx("span",{className:"text-sm text-text-primary capitalize",children:x})]},x))})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-xs font-semibold text-text-secondary uppercase tracking-wider mb-2",children:c.filterPanel.complexity}),a.jsx("div",{className:"space-y-1.5",children:u.map(x=>a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer hover:bg-elevated/50 rounded px-2 py-1 transition-colors",children:[a.jsx("input",{type:"checkbox",checked:t.complexities.has(x),onChange:()=>m(x),className:"w-3.5 h-3.5 rounded border-border-subtle bg-elevated checked:bg-gold checked:border-gold focus:ring-0 focus:ring-offset-0 cursor-pointer"}),a.jsx("span",{className:"text-sm text-text-primary capitalize",children:x})]},x))})]}),h.length>0&&a.jsxs("div",{children:[a.jsx("h3",{className:"text-xs font-semibold text-text-secondary uppercase tracking-wider mb-2",children:c.filterPanel.layers}),a.jsx("div",{className:"space-y-1.5",children:h.map(x=>a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer hover:bg-elevated/50 rounded px-2 py-1 transition-colors",children:[a.jsx("input",{type:"checkbox",checked:t.layerIds.has(x.id),onChange:()=>p(x.id),className:"w-3.5 h-3.5 rounded border-border-subtle bg-elevated checked:bg-gold checked:border-gold focus:ring-0 focus:ring-offset-0 cursor-pointer"}),a.jsx("div",{className:"w-2 h-2 rounded-full bg-gold/50 shrink-0"}),a.jsx("span",{className:"text-sm text-text-primary",children:x.name})]},x.id))})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-xs font-semibold text-text-secondary uppercase tracking-wider mb-2",children:c.filterPanel.edgeCategories}),a.jsx("div",{className:"space-y-1.5",children:f.map(x=>a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer hover:bg-elevated/50 rounded px-2 py-1 transition-colors",children:[a.jsx("input",{type:"checkbox",checked:t.edgeCategories.has(x),onChange:()=>N(x),className:"w-3.5 h-3.5 rounded border-border-subtle bg-elevated checked:bg-gold checked:border-gold focus:ring-0 focus:ring-offset-0 cursor-pointer"}),a.jsx("span",{className:"text-sm text-text-primary capitalize",children:x.replace(/-/g," ")})]},x))})]}),y&&a.jsx("button",{onClick:o,className:"w-full px-3 py-1.5 text-sm bg-elevated hover:bg-gold/20 text-text-secondary hover:text-gold rounded-lg transition-colors",children:c.common.resetAll})]})})]})}function Eu(e,t,n){const o=n.layerIds.size>0;return e.filter(r=>{if(!n.nodeTypes.has(r.type)||r.complexity&&!n.complexities.has(r.complexity))return!1;if(o){const s=t.get(r.id);if(!s)return!1;let i=!1;for(const c of s)if(n.layerIds.has(c)){i=!0;break}if(!i)return!1}return!0})}function $u(e,t,n){return e.filter(o=>{if(!t.has(o.source)||!t.has(o.target))return!1;const r=Lu(o.type);return!(r&&!n.edgeCategories.has(r))})}function Lu(e){for(const[t,n]of Object.entries(ll))if(n.includes(e))return t;return null}function zu(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}function $t(e,t){const n=URL.createObjectURL(e),o=document.createElement("a");o.href=n,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(n)}function lr(){const e=b(g=>g.graph),t=b(g=>g.nodeIdToLayerIds),n=b(g=>g.filters),o=b(g=>g.exportMenuOpen),r=b(g=>g.toggleExportMenu),s=b(g=>g.reactFlowInstance),i=b(g=>g.persona),{t:c}=re(),d=v.useRef(null);v.useEffect(()=>{const g=m=>{d.current&&!d.current.contains(m.target)&&o&&r()};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[o,r]);const l=()=>{if(!s)return null;const g=s.getNodes(),m=s.getEdges();if(g.length===0)return null;let p=1/0,N=1/0,y=-1/0,x=-1/0;g.forEach(w=>{const M=w.position.x,$=w.position.y,D=w.width??200,Z=w.height??80;p=Math.min(p,M),N=Math.min(N,$),y=Math.max(y,M+D),x=Math.max(x,$+Z)});const k=40,T=y-p+k*2,j=x-N+k*2,C=-p+k,I=-N+k;let E=``;return E+='',m.forEach(w=>{const M=g.find(R=>R.id===w.source),$=g.find(R=>R.id===w.target);if(!M||!$)return;const D=M.position.x+(M.width??200)/2+C,Z=M.position.y+(M.height??80)/2+I,P=$.position.x+($.width??200)/2+C,V=$.position.y+($.height??80)/2+I;E+=``}),g.forEach(w=>{if(w.type==="group")return;const M=w.position.x+C,$=w.position.y+I,D=w.width??200,Z=w.height??80;E+=``,E+=`${zu(String(w.data.label??w.id))}`}),E+="",{svgContent:E,width:T,height:j}},u=async()=>{if(!s){alert("Graph not ready for export");return}try{const g=l();if(!g){alert("No nodes to export");return}const{svgContent:m,width:p,height:N}=g,y=new Blob([m],{type:"image/svg+xml;charset=utf-8"}),x=URL.createObjectURL(y),k=new Image;k.onerror=()=>{URL.revokeObjectURL(x),alert("Failed to export PNG: could not render graph as image.")},k.onload=()=>{const T=document.createElement("canvas");T.width=p*2,T.height=N*2;const j=T.getContext("2d");if(!j){URL.revokeObjectURL(x),alert("Failed to create canvas context");return}j.drawImage(k,0,0,p*2,N*2),URL.revokeObjectURL(x);const C=`${(e==null?void 0:e.project.name)??"knowledge-graph"}-export.png`;T.toBlob(I=>{I?($t(I,C),r()):alert("Failed to export PNG: image encoding failed.")},"image/png")},k.src=x}catch(g){console.error("PNG export failed:",g),alert(`Failed to export PNG: ${g instanceof Error?g.message:String(g)}`)}},f=()=>{if(!s){alert("Graph not ready for export");return}try{const g=l();if(!g){alert("No nodes to export");return}const m=new Blob([g.svgContent],{type:"image/svg+xml;charset=utf-8"}),p=`${(e==null?void 0:e.project.name)??"knowledge-graph"}-export.svg`;$t(m,p),r()}catch(g){console.error("SVG export failed:",g),alert(`Failed to export SVG: ${g instanceof Error?g.message:String(g)}`)}},h=()=>{if(!e){alert("No graph loaded");return}try{const g=new Set(["function","class"]);let m=i==="non-technical"?e.nodes.filter(j=>!g.has(j.type)):e.nodes;m=Eu(m,t,n);const p=new Set(m.map(j=>j.id));let N=e.edges.filter(j=>p.has(j.source)&&p.has(j.target));N=$u(N,p,n);const y={...e,nodes:m,edges:N},x=JSON.stringify(y,null,2),k=new Blob([x],{type:"application/json"}),T=`${e.project.name??"knowledge-graph"}-export.json`;$t(k,T),r()}catch(g){console.error("JSON export failed:",g),alert(`Failed to export JSON: ${g instanceof Error?g.message:String(g)}`)}};return a.jsxs("div",{ref:d,className:"relative",children:[a.jsxs("button",{onClick:r,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm bg-elevated text-text-secondary hover:text-text-primary transition-colors",title:c.export.title,children:[a.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})}),c.export.label]}),o&&a.jsx("div",{className:"absolute right-0 top-full mt-2 w-52 glass rounded-lg shadow-xl overflow-hidden animate-fade-slide-in z-50",children:a.jsxs("div",{className:"p-2",children:[a.jsxs("button",{onClick:u,disabled:!s,className:"w-full flex items-center gap-3 px-3 py-2 text-sm text-text-primary hover:bg-elevated transition-colors rounded-lg text-left disabled:opacity-50 disabled:cursor-not-allowed",children:[a.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),a.jsx("span",{children:c.export.asPNG})]}),a.jsxs("button",{onClick:f,disabled:!s,className:"w-full flex items-center gap-3 px-3 py-2 text-sm text-text-primary hover:bg-elevated transition-colors rounded-lg text-left disabled:opacity-50 disabled:cursor-not-allowed",children:[a.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 21a4 4 0 01-4-4V5a2 2 0 012-2h4a2 2 0 012 2v12a4 4 0 01-4 4zm0 0h12a2 2 0 002-2v-4a2 2 0 00-2-2h-2.343M11 7.343l1.657-1.657a2 2 0 012.828 0l2.829 2.829a2 2 0 010 2.828l-8.486 8.485M7 17h.01"})}),a.jsx("span",{children:c.export.asSVG})]}),a.jsxs("button",{onClick:h,disabled:!e,className:"w-full flex items-center gap-3 px-3 py-2 text-sm text-text-primary hover:bg-elevated transition-colors rounded-lg text-left disabled:opacity-50 disabled:cursor-not-allowed",children:[a.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})}),a.jsx("span",{children:c.export.asJSON})]})]})})]})}function ur(){const e=b(r=>r.persona),t=b(r=>r.setPersona),{t:n}=re(),o=[{id:"non-technical",label:n.personaSelector.overview,description:n.personaSelector.overviewDesc},{id:"junior",label:n.personaSelector.learn,description:n.personaSelector.learnDesc},{id:"experienced",label:n.personaSelector.deepDive,description:n.personaSelector.deepDiveDesc}];return a.jsx("div",{className:"flex items-center gap-1 bg-elevated rounded-lg p-0.5",children:o.map(r=>a.jsx("button",{onClick:()=>t(r.id),title:r.description,className:`px-2.5 py-1 rounded text-[11px] font-medium transition-colors ${e===r.id?"bg-accent/20 text-accent":"text-text-muted hover:text-text-secondary hover:bg-surface"}`,children:r.label},r.id))})}function fr(){const e=b(p=>p.graph),t=b(p=>p.startTour),{t:n}=re();if(!e)return a.jsx("div",{className:"h-full w-full flex items-center justify-center",children:a.jsx("p",{className:"text-text-muted text-sm",children:n.common.loading})});const{project:o,nodes:r,edges:s,layers:i}=e,c=e.tour.length>0,d={};for(const p of r)d[p.type]=(d[p.type]??0)+1;const l={simple:0,moderate:0,complex:0};for(const p of r)p.complexity&&(l[p.complexity]=(l[p.complexity]??0)+1);const u=new Map;for(const p of s)u.set(p.source,(u.get(p.source)??0)+1),u.set(p.target,(u.get(p.target)??0)+1);const f=Array.from(u.entries()).sort((p,N)=>N[1]-p[1]).slice(0,5).map(([p,N])=>{const y=r.find(x=>x.id===p);return{id:p,name:(y==null?void 0:y.name)??p,count:N}}),h=r.length>0?(s.length*2/r.length).toFixed(1):"0",g=[{label:n.projectOverview.code,color:"var(--color-node-file)",count:(d.file??0)+(d.function??0)+(d.class??0)+(d.module??0)+(d.concept??0)},{label:n.projectOverview.config,color:"var(--color-node-config)",count:d.config??0},{label:n.projectOverview.docs,color:"var(--color-node-document)",count:d.document??0},{label:n.projectOverview.infra,color:"var(--color-node-service)",count:(d.service??0)+(d.resource??0)+(d.pipeline??0)},{label:n.projectOverview.data,color:"var(--color-node-table)",count:(d.table??0)+(d.endpoint??0)+(d.schema??0)},{label:n.projectOverview.domain,color:"var(--color-node-concept)",count:(d.domain??0)+(d.flow??0)+(d.step??0)}],m=g.some(p=>p.label!==n.projectOverview.code&&p.count>0);return a.jsxs("div",{className:"h-full w-full overflow-auto p-5 animate-fade-slide-in",children:[a.jsx("h2",{className:"font-heading text-2xl text-text-primary mb-1",children:o.name}),a.jsx("p",{className:"text-sm text-text-secondary leading-relaxed mb-6",children:o.description}),a.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-6",children:[a.jsxs("div",{className:"bg-elevated rounded-lg p-3 border border-border-subtle",children:[a.jsx("div",{className:"text-2xl font-mono font-medium text-accent",children:r.length}),a.jsx("div",{className:"text-[11px] text-text-muted uppercase tracking-wider mt-1",children:n.projectOverview.nodes})]}),a.jsxs("div",{className:"bg-elevated rounded-lg p-3 border border-border-subtle",children:[a.jsx("div",{className:"text-2xl font-mono font-medium text-accent",children:s.length}),a.jsx("div",{className:"text-[11px] text-text-muted uppercase tracking-wider mt-1",children:n.projectOverview.edges})]}),a.jsxs("div",{className:"bg-elevated rounded-lg p-3 border border-border-subtle",children:[a.jsx("div",{className:"text-2xl font-mono font-medium text-accent",children:i.length}),a.jsx("div",{className:"text-[11px] text-text-muted uppercase tracking-wider mt-1",children:n.projectOverview.layers})]}),a.jsxs("div",{className:"bg-elevated rounded-lg p-3 border border-border-subtle",children:[a.jsx("div",{className:"text-2xl font-mono font-medium text-accent",children:Object.keys(d).length}),a.jsx("div",{className:"text-[11px] text-text-muted uppercase tracking-wider mt-1",children:n.projectOverview.types})]})]}),m&&a.jsxs("div",{className:"mb-5",children:[a.jsx("h3",{className:"text-[11px] font-semibold text-accent uppercase tracking-wider mb-2",children:n.projectOverview.fileTypes}),a.jsx("div",{className:"space-y-1.5",children:g.filter(p=>p.count>0).map(p=>a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"w-2.5 h-2.5 rounded-full shrink-0",style:{backgroundColor:p.color}}),a.jsx("span",{className:"text-xs text-text-secondary flex-1",children:p.label}),a.jsx("span",{className:"text-xs font-mono text-text-muted",children:p.count})]},p.label))})]}),o.languages.length>0&&a.jsxs("div",{className:"mb-5",children:[a.jsx("h3",{className:"text-[11px] font-semibold text-accent uppercase tracking-wider mb-2",children:n.projectOverview.languages}),a.jsx("div",{className:"flex flex-wrap gap-1.5",children:o.languages.map(p=>a.jsx("span",{className:"text-[11px] glass text-text-secondary px-2.5 py-1 rounded-full",children:p},p))})]}),o.frameworks.length>0&&a.jsxs("div",{className:"mb-5",children:[a.jsx("h3",{className:"text-[11px] font-semibold text-accent uppercase tracking-wider mb-2",children:n.projectOverview.frameworks}),a.jsx("div",{className:"flex flex-wrap gap-1.5",children:o.frameworks.map(p=>a.jsx("span",{className:"text-[11px] glass text-text-secondary px-2.5 py-1 rounded-full",children:p},p))})]}),a.jsxs("div",{className:"mb-5",children:[a.jsx("h3",{className:"text-[11px] font-semibold text-accent uppercase tracking-wider mb-3",children:n.projectOverview.nodeTypeDistribution}),a.jsx("div",{className:"space-y-2",children:Object.entries(d).sort((p,N)=>N[1]-p[1]).map(([p,N])=>{const y=(N/r.length*100).toFixed(0);return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[a.jsx("span",{className:"text-text-secondary capitalize",children:p}),a.jsxs("span",{className:"text-text-muted font-mono",children:[N," (",y,"%)"]})]}),a.jsx("div",{className:"w-full h-1.5 bg-elevated rounded-full overflow-hidden",children:a.jsx("div",{className:"h-full bg-accent/50 rounded-full transition-all duration-500",style:{width:`${y}%`}})})]},p)})})]}),Object.values(l).some(p=>p>0)&&a.jsxs("div",{className:"mb-5",children:[a.jsx("h3",{className:"text-[11px] font-semibold text-accent uppercase tracking-wider mb-3",children:n.projectOverview.complexityDistribution}),a.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[a.jsxs("div",{className:"bg-elevated rounded-lg p-2 border border-border-subtle text-center",children:[a.jsx("div",{className:"text-lg font-mono font-medium text-green-400",children:l.simple}),a.jsx("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mt-0.5",children:n.projectOverview.simple})]}),a.jsxs("div",{className:"bg-elevated rounded-lg p-2 border border-border-subtle text-center",children:[a.jsx("div",{className:"text-lg font-mono font-medium text-yellow-400",children:l.moderate}),a.jsx("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mt-0.5",children:n.projectOverview.moderate})]}),a.jsxs("div",{className:"bg-elevated rounded-lg p-2 border border-border-subtle text-center",children:[a.jsx("div",{className:"text-lg font-mono font-medium text-red-400",children:l.complex}),a.jsx("div",{className:"text-[10px] text-text-muted uppercase tracking-wider mt-0.5",children:n.projectOverview.complex})]})]})]}),f.length>0&&a.jsxs("div",{className:"mb-5",children:[a.jsx("h3",{className:"text-[11px] font-semibold text-accent uppercase tracking-wider mb-3",children:n.projectOverview.mostConnectedNodes}),a.jsx("div",{className:"space-y-2",children:f.map((p,N)=>a.jsxs("div",{className:"flex items-center gap-2 text-xs bg-elevated rounded-lg p-2 border border-border-subtle",children:[a.jsx("div",{className:"w-5 h-5 shrink-0 rounded-full bg-accent/20 flex items-center justify-center text-[10px] font-bold text-accent",children:N+1}),a.jsx("span",{className:"flex-1 text-text-primary truncate",children:p.name}),a.jsx("span",{className:"text-text-muted font-mono shrink-0",children:p.count})]},p.id))})]}),a.jsx("div",{className:"mb-5 bg-elevated rounded-lg p-3 border border-border-subtle",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-xs text-text-secondary",children:n.projectOverview.avgConnectionsPerNode}),a.jsx("span",{className:"text-lg font-mono font-medium text-accent",children:h})]})}),a.jsxs("div",{className:"text-[11px] text-text-muted mb-6",children:[n.common.analyzed,": ",new Date(o.analyzedAt).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})]}),c&&a.jsx("button",{onClick:t,className:"w-full bg-accent/10 border border-accent/30 text-accent text-sm font-medium py-2.5 px-4 rounded-lg hover:bg-accent/20 transition-all duration-200",children:n.common.startGuidedTour})]})}function Au(e){const t=e.replace(/\\/g,"/").replace(/^\/+/,"").replace(/^\.\//,"");return!t||t==="."||t.includes("\0")||t.split("/").some(n=>n==="..")?null:t}function Ou(e,t){return!e||e.type!=="file"&&t.type==="file"?t:e}function Mu(e,t){const n=new Map;for(const i of e){if(t&&!t.has(i.id)||!i.filePath)continue;const c=Au(i.filePath);c&&n.set(c,Ou(n.get(c),i))}const o={name:"",path:"",type:"folder",children:[]},r=new Map([["",o]]);for(const[i,c]of n){const d=i.split("/");let l=o,u="";for(let f=0;fi.sort((c,d)=>c.type!==d.type?c.type==="folder"?-1:1:c.name.localeCompare(d.name)).map(c=>({...c,children:s(c.children)}));return s(o.children)}function pr({entry:e,depth:t,expanded:n,toggleFolder:o,openFile:r}){const s=n.has(e.path),i=12+t*14;return e.type==="folder"?a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",onClick:()=>o(e.path),className:"w-full flex items-center gap-1.5 py-1.5 pr-3 text-left text-xs text-text-secondary hover:text-text-primary hover:bg-elevated transition-colors",style:{paddingLeft:i},title:e.path,children:[a.jsx("span",{className:"w-3 text-text-muted",children:s?"v":">"}),a.jsx("span",{className:"truncate font-medium",children:e.name})]}),s&&e.children.map(c=>a.jsx(pr,{entry:c,depth:t+1,expanded:n,toggleFolder:o,openFile:r},c.path))]}):a.jsxs("button",{type:"button",onClick:()=>e.nodeId&&r(e.nodeId),className:"w-full flex items-center gap-1.5 py-1.5 pr-3 text-left text-xs text-text-secondary hover:text-accent hover:bg-accent/5 transition-colors",style:{paddingLeft:i},title:e.path,children:[a.jsx("span",{className:"w-3 text-text-muted",children:"-"}),a.jsx("span",{className:"truncate font-mono",children:e.name})]})}function hr(){const e=b(m=>m.graph),t=b(m=>m.activeLayerId),n=b(m=>m.navigationLevel),o=b(m=>m.openCodeViewer),r=b(m=>m.navigateToNode),{t:s}=re(),i=e==null?void 0:e.layers.find(m=>m.id===t),c=v.useMemo(()=>n==="layer-detail"&&i?new Set(i.nodeIds):void 0,[n,i]),d=v.useMemo(()=>Mu((e==null?void 0:e.nodes)??[],c),[e,c]),[l,u]=v.useState(()=>new Set),f=m=>{r(m),o(m)},h=m=>{u(p=>{const N=new Set(p);return N.has(m)?N.delete(m):N.add(m),N})},g=v.useMemo(()=>{const m=p=>p.reduce((N,y)=>N+(y.type==="file"?1:m(y.children)),0);return m(d)},[d]);return e?a.jsxs("div",{className:"h-full flex flex-col min-h-0",children:[a.jsxs("div",{className:"px-4 py-3 border-b border-border-subtle shrink-0",children:[a.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-accent",children:i?i.name:s.fileExplorer.analyzedFiles}),a.jsxs("div",{className:"text-xs text-text-muted mt-1",children:[g," ",i?"个文档":s.fileExplorer.filesFromGraph]})]}),a.jsx("div",{className:"flex-1 overflow-auto py-2",children:d.length===0?a.jsx("div",{className:"px-4 py-6 text-sm text-text-muted",children:s.fileExplorer.noFilePathsFound}):d.map(m=>a.jsx(pr,{entry:m,depth:0,expanded:l,toggleFolder:h,openFile:f},m.path))})]}):a.jsx("div",{className:"h-full flex items-center justify-center p-5 text-sm text-text-muted",children:s.common.noGraphLoaded})}function Fu(e){const n=e.some(r=>r.level==="fatal")?["Some of these issues look like dashboard rendering bugs.","Please file an issue at github.com/Lum1104/Understand-Anything/issues with the text below.",""]:["The following issues were found in your knowledge-graph.json.","These are LLM generation errors — not a system bug.","You can ask your agent to fix these specific issues in the knowledge-graph.json file:",""],o=[...e].sort((r,s)=>{const i={fatal:0,dropped:1,"auto-corrected":2};return(i[r.level]??3)-(i[s.level]??3)});for(const r of o){const s=r.level==="auto-corrected"?"Auto-corrected":r.level==="dropped"?"Dropped":"Fatal";n.push(`[${s}] ${r.message}`)}return n.join(` `)}function mr({issues:e}){const[t,n]=v.useState(!1),[o,r]=v.useState(!1),s=e.filter(T=>T.level==="fatal"),i=e.filter(T=>T.level==="auto-corrected"),c=e.filter(T=>T.level==="dropped"),d=s.length>0,l=[];s.length>0&&l.push(`${s.length} fatal error${s.length!==1?"s":""}`),i.length>0&&l.push(`${i.length} auto-correction${i.length!==1?"s":""}`),c.length>0&&l.push(`${c.length} dropped item${c.length!==1?"s":""}`);const u=d?`Dashboard hit ${l.join(", ")}`:`Knowledge graph loaded with ${l.join(" and ")}`,f=v.useCallback(async()=>{const T=Fu(e);try{await navigator.clipboard.writeText(T),r(!0),setTimeout(()=>r(!1),2e3)}catch{console.warn("Clipboard write failed — copy text manually from the expanded issue list")}},[e]);if(e.length===0)return null;const h=d?"bg-red-900/25 border-b border-red-700 text-red-200 text-sm":"bg-amber-900/20 border-b border-amber-700 text-amber-200 text-sm",g=d?"hover:bg-red-900/15":"hover:bg-amber-900/10",m=d?"text-red-400":"text-amber-400",p=d?"text-red-400/60":"text-amber-400/60",N=d?"border-red-700/50":"border-amber-700/50",y=d?"text-red-200/70":"text-amber-200/60",x=d?"bg-red-800/40 text-red-200 hover:bg-red-800/60":"bg-amber-800/40 text-amber-200 hover:bg-amber-800/60",k=d?"Copy these issues and file a bug report on GitHub":"Copy these issues and ask your agent to fix them in knowledge-graph.json";return a.jsxs("div",{className:h,children:[a.jsxs("button",{type:"button","aria-expanded":t,onClick:()=>n(T=>!T),className:`w-full flex items-center gap-2 px-5 py-3 text-left transition-colors ${g}`,children:[a.jsx("svg",{className:`w-4 h-4 shrink-0 ${m} transition-transform duration-200 ${t?"rotate-90":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),a.jsx("svg",{className:`w-4 h-4 shrink-0 ${m}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4.5c-.77-.833-2.694-.833-3.464 0L3.34 16.5c-.77.833.192 2.5 1.732 2.5z"})}),a.jsx("span",{className:"flex-1",children:u}),a.jsx("span",{className:`text-xs shrink-0 ${p}`,children:t?"click to collapse":"click to expand"})]}),t&&a.jsxs("div",{className:"px-5 pb-4",children:[a.jsxs("div",{className:"space-y-1 mb-3",children:[s.length>0&&a.jsxs("div",{children:[a.jsxs("h4",{className:"text-xs font-semibold uppercase tracking-wider text-red-400 mb-1",children:["Fatal (",s.length,")"]}),s.map((T,j)=>a.jsxs("div",{className:"flex items-start gap-2 py-0.5 pl-2 text-red-200",children:[a.jsx("span",{className:"text-red-400 shrink-0 mt-0.5",children:a.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4.5c-.77-.833-2.694-.833-3.464 0L3.34 16.5c-.77.833.192 2.5 1.732 2.5z"})})}),a.jsx("span",{className:"text-xs",children:T.message})]},`ft-${j}`))]}),i.length>0&&a.jsxs("div",{className:s.length>0?"mt-2":"",children:[a.jsxs("h4",{className:"text-xs font-semibold uppercase tracking-wider text-amber-400 mb-1",children:["Auto-corrected (",i.length,")"]}),i.map((T,j)=>a.jsxs("div",{className:"flex items-start gap-2 py-0.5 pl-2 text-amber-200/80",children:[a.jsx("span",{className:"text-amber-400 shrink-0 mt-0.5",children:a.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),a.jsx("span",{className:"text-xs",children:T.message})]},`ac-${j}`))]}),c.length>0&&a.jsxs("div",{className:s.length>0||i.length>0?"mt-2":"",children:[a.jsxs("h4",{className:"text-xs font-semibold uppercase tracking-wider text-orange-400 mb-1",children:["Dropped (",c.length,")"]}),c.map((T,j)=>a.jsxs("div",{className:"flex items-start gap-2 py-0.5 pl-2 text-orange-300/80",children:[a.jsx("span",{className:"text-orange-400 shrink-0 mt-0.5",children:a.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),a.jsx("span",{className:"text-xs",children:T.message})]},`dr-${j}`))]})]}),a.jsxs("div",{className:`flex items-center justify-between pt-2 border-t ${N}`,children:[a.jsx("p",{className:`text-xs ${y}`,children:k}),a.jsx("button",{type:"button",onClick:f,className:`flex items-center gap-1.5 px-3 py-1 rounded text-xs font-medium transition-colors shrink-0 ml-4 ${x}`,children:o?a.jsxs(a.Fragment,{children:[a.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),"Copied!"]}):a.jsxs(a.Fragment,{children:[a.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})}),"Copy Issues"]})})]})]})]})}function Du({onTokenValid:e}){const[t,n]=v.useState(""),[o,r]=v.useState(null),[s,i]=v.useState(!1),c=async d=>{d.preventDefault();const l=t.trim();if(l){i(!0),r(null);try{const u=await fetch(`/knowledge-graph.json?token=${encodeURIComponent(l)}`);u.ok?e(l):u.status===403?r("Invalid token. Please check and try again."):r(`Unexpected response (${u.status}). Is the dashboard server running?`)}catch(u){r(`Could not reach the server: ${u instanceof Error?u.message:String(u)}`)}finally{i(!1)}}};return a.jsx("div",{className:"h-screen w-screen flex items-center justify-center bg-root noise-overlay",children:a.jsxs("div",{className:"w-full max-w-md px-8 py-10 bg-surface border border-border-subtle rounded-lg shadow-2xl",children:[a.jsx("h1",{className:"font-heading text-2xl text-text-primary tracking-wide text-center mb-2",children:"Access Token Required"}),a.jsxs("p",{className:"text-text-muted text-sm text-center mb-8",children:["Paste the access token from your terminal. Look for the"," ",a.jsx("span",{role:"img","aria-label":"key",children:"🔑"})," line."]}),a.jsxs("form",{onSubmit:c,className:"flex flex-col gap-4",children:[a.jsx("input",{type:"text",value:t,onChange:d=>{n(d.target.value),o&&r(null)},placeholder:"Paste token here...",autoFocus:!0,className:"w-full px-4 py-3 bg-elevated border border-border-subtle rounded text-text-primary placeholder:text-text-muted/50 font-mono text-sm focus:outline-none focus:border-accent transition-colors"}),o&&a.jsx("p",{className:"text-red-400 text-sm",children:o}),a.jsx("button",{type:"submit",disabled:s||!t.trim(),className:"w-full py-3 bg-accent text-root font-semibold rounded transition-all hover:brightness-110 disabled:opacity-40 disabled:cursor-not-allowed",children:s?"Validating...":"Continue"})]})]})})}const Pu={graph:a.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.6,children:[a.jsx("circle",{cx:"6",cy:"7",r:"2"}),a.jsx("circle",{cx:"18",cy:"7",r:"2"}),a.jsx("circle",{cx:"12",cy:"17",r:"2"}),a.jsx("path",{strokeLinecap:"round",d:"M7.6 8.5L11 15.5M16.4 8.5L13 15.5M8 7h8"})]}),info:a.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.6,children:[a.jsx("circle",{cx:"12",cy:"12",r:"9"}),a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 11v5M12 8h.01"})]}),files:a.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.6,children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6.5A1.5 1.5 0 0 1 5.5 5h3.382a1.5 1.5 0 0 1 1.342.83l.671 1.34A1.5 1.5 0 0 0 12.236 8H18.5A1.5 1.5 0 0 1 20 9.5v8a1.5 1.5 0 0 1-1.5 1.5h-13A1.5 1.5 0 0 1 4 17.5z"})})},Ru=["graph","info","files"];function Zu({activeTab:e,onTabChange:t}){const{t:n}=re(),o={graph:n.mobile.graph,info:n.mobile.info,files:n.mobile.files};return a.jsx("nav",{className:"flex shrink-0 bg-surface border-t border-border-subtle",children:Ru.map(r=>{const s=e===r;return a.jsxs("button",{type:"button",onClick:()=>t(r),className:`relative flex-1 flex flex-col items-center justify-center gap-1 py-2.5 text-[10px] font-semibold uppercase tracking-[0.14em] transition-colors ${s?"text-accent":"text-text-muted hover:text-text-secondary"}`,"aria-current":s?"page":void 0,children:[a.jsx("span",{className:"w-5 h-5",children:Pu[r]}),o[r],s&&a.jsx("span",{className:"absolute top-0 left-1/2 -translate-x-1/2 w-8 h-px bg-accent"})]},r)})})}function gr(){const{config:e,preset:t,setPreset:n,setAccent:o,setHeadingFont:r}=Qo(),[s,i]=v.useState(!1),c=v.useRef(null),{t:d}=re();v.useEffect(()=>{if(!s)return;function u(f){c.current&&!c.current.contains(f.target)&&i(!1)}return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[s]),v.useEffect(()=>{if(!s)return;function u(f){f.key==="Escape"&&i(!1)}return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[s]);const l=v.useCallback(u=>{n(u)},[n]);return a.jsxs("div",{ref:c,className:"relative",children:[a.jsxs("button",{onClick:()=>i(u=>!u),className:"flex items-center gap-1.5 px-2 py-1 rounded text-xs text-text-secondary hover:text-text-primary transition-colors",title:d.themePicker.changeTheme,children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"12",cy:"12",r:"10"}),a.jsx("path",{d:"M12 2a7 7 0 0 0 0 14 4 4 0 0 1 0 8 10 10 0 0 0 0-20z"}),a.jsx("circle",{cx:"8",cy:"10",r:"1.5",fill:"currentColor"}),a.jsx("circle",{cx:"12",cy:"7",r:"1.5",fill:"currentColor"}),a.jsx("circle",{cx:"16",cy:"10",r:"1.5",fill:"currentColor"})]}),a.jsx("span",{className:"hidden sm:inline",children:d.common.theme})]}),s&&a.jsxs("div",{className:"absolute right-0 top-full mt-2 w-64 rounded-lg glass-heavy shadow-xl z-50 p-3 space-y-3",children:[a.jsxs("div",{children:[a.jsx("div",{className:"text-[10px] font-semibold text-text-muted uppercase tracking-wider mb-2",children:d.themePicker.theme}),a.jsx("div",{className:"space-y-1",children:Zt.map(u=>{var f;return a.jsxs("button",{onClick:()=>l(u.id),className:`w-full flex items-center gap-2.5 px-2.5 py-1.5 rounded text-xs transition-colors ${u.id===e.presetId?"bg-accent/15 text-accent":"text-text-secondary hover:text-text-primary hover:bg-elevated"}`,children:[a.jsxs("div",{className:"flex gap-1",children:[a.jsx("span",{className:"w-3 h-3 rounded-full border border-border-subtle",style:{backgroundColor:u.colors.root}}),a.jsx("span",{className:"w-3 h-3 rounded-full border border-border-subtle",style:{backgroundColor:u.colors.surface}}),a.jsx("span",{className:"w-3 h-3 rounded-full border border-border-subtle",style:{backgroundColor:((f=u.accentSwatches.find(h=>h.id===u.defaultAccentId))==null?void 0:f.accent)??u.accentSwatches[0].accent}})]}),a.jsx("span",{children:u.name}),u.id===e.presetId&&a.jsx("svg",{className:"ml-auto w-3.5 h-3.5 text-accent",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:a.jsx("polyline",{points:"20 6 9 17 4 12"})})]},u.id)})})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-[10px] font-semibold text-text-muted uppercase tracking-wider mb-2",children:d.themePicker.accentColor}),a.jsx("div",{className:"flex gap-2 flex-wrap",children:t.accentSwatches.map(u=>a.jsx("button",{onClick:()=>o(u.id),className:`w-6 h-6 rounded-full transition-transform hover:scale-110 ${u.id===e.accentId?"ring-2 ring-text-primary ring-offset-1 ring-offset-root":""}`,style:{backgroundColor:u.accent},title:u.name},u.id))})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-[10px] font-semibold text-text-muted uppercase tracking-wider mb-2",children:d.themePicker.headingFont}),a.jsx("div",{className:"flex gap-1",children:[{id:"serif",label:d.themePicker.serif,sample:"Aa"},{id:"sans",label:d.themePicker.sans,sample:"Aa"},{id:"mono",label:d.themePicker.mono,sample:"Aa"}].map(u=>a.jsx("button",{onClick:()=>r(u.id),className:`flex-1 px-2 py-1.5 rounded text-xs transition-colors ${(e.headingFont??"serif")===u.id?"bg-accent/15 text-accent":"text-text-secondary hover:text-text-primary hover:bg-elevated"}`,style:{fontFamily:u.id==="serif"?"var(--font-serif)":u.id==="mono"?"var(--font-mono)":"var(--font-sans)"},children:u.label},u.id))})]})]})]})}function Oe({children:e}){return a.jsx("h3",{className:"text-[10px] font-semibold uppercase tracking-[0.18em] text-text-muted mb-3",children:e})}function Bu({open:e,onClose:t,onTogglePathFinder:n,onShowKeyboardHelp:o}){var N;const r=b(y=>y.graph),s=b(y=>y.isKnowledgeGraph),i=b(y=>y.domainGraph),c=b(y=>y.viewMode),d=b(y=>y.setViewMode),l=b(y=>y.nodeTypeFilters),u=b(y=>y.toggleNodeTypeFilter),{t:f}=re(),h=[{key:"code",label:f.nodeTypeLabels.code,color:"var(--color-node-file)"},{key:"config",label:f.nodeTypeLabels.config,color:"var(--color-node-config)"},{key:"docs",label:f.nodeTypeLabels.docs,color:"var(--color-node-document)"},{key:"infra",label:f.nodeTypeLabels.infra,color:"var(--color-node-service)"},{key:"data",label:f.nodeTypeLabels.data,color:"var(--color-node-table)"},{key:"domain",label:f.nodeTypeLabels.domain,color:"var(--color-node-concept)"},{key:"knowledge",label:f.nodeTypeLabels.knowledge,color:"var(--color-node-article)"}],g=[{key:"knowledge",label:f.nodeTypeLabels.all,color:"var(--color-node-article)"}];v.useEffect(()=>{if(!e)return;const y=x=>{x.key==="Escape"&&t()};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[e,t]),v.useEffect(()=>{if(!e)return;const y=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=y}},[e]);const m=s?g:h,p=!!(r&&!s&&i);return a.jsxs("div",{className:`fixed inset-0 z-40 ${e?"pointer-events-auto":"pointer-events-none"}`,"aria-hidden":!e,children:[a.jsx("button",{type:"button","aria-label":"Close menu",onClick:t,className:`absolute inset-0 bg-black/65 backdrop-blur-sm transition-opacity duration-300 ${e?"opacity-100":"opacity-0"}`}),a.jsxs("aside",{className:`absolute left-0 top-0 bottom-0 w-[86%] max-w-[360px] bg-surface border-r border-border-subtle flex flex-col transition-transform duration-300 ease-out ${e?"translate-x-0":"-translate-x-full"}`,role:"dialog","aria-label":"Settings",children:[a.jsxs("header",{className:"flex items-center justify-between px-5 py-4 border-b border-border-subtle shrink-0",children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.2em] text-accent",children:f.drawer.controls}),a.jsx("h2",{className:"font-heading text-lg text-text-primary mt-0.5 leading-none",children:(r==null?void 0:r.project.name)??f.drawer.dashboard})]}),a.jsx("button",{type:"button",onClick:t,"aria-label":"Close menu",className:"w-9 h-9 flex items-center justify-center rounded-lg text-text-muted hover:text-text-primary hover:bg-elevated transition-colors",children:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 6l12 12M6 18L18 6"})})})]}),a.jsxs("div",{className:"flex-1 overflow-auto px-5 py-5 space-y-7",children:[a.jsxs("section",{children:[a.jsx(Oe,{children:f.drawer.role}),a.jsx(ur,{})]}),p&&a.jsxs("section",{children:[a.jsx(Oe,{children:f.drawer.view}),a.jsxs("div",{className:"inline-flex items-center bg-elevated rounded-lg p-0.5",children:[a.jsx("button",{type:"button",onClick:()=>d("domain"),className:`px-3 py-1.5 text-xs font-medium rounded-md transition-colors ${c==="domain"?"bg-accent/20 text-accent":"text-text-muted hover:text-text-secondary"}`,children:f.drawer.domain}),a.jsx("button",{type:"button",onClick:()=>d("structural"),className:`px-3 py-1.5 text-xs font-medium rounded-md transition-colors ${c==="structural"?"bg-accent/20 text-accent":"text-text-muted hover:text-text-secondary"}`,children:f.drawer.structural})]})]}),a.jsxs("section",{children:[a.jsx(Oe,{children:f.drawer.diffOverlay}),a.jsx(cr,{})]}),a.jsxs("section",{children:[a.jsx(Oe,{children:f.drawer.nodeTypes}),a.jsx("div",{className:"flex flex-wrap gap-1.5",children:m.map(y=>{const x=l[y.key]!==!1;return a.jsxs("button",{type:"button",onClick:()=>u(y.key),className:`text-[10px] font-semibold uppercase tracking-wider px-2 py-1 rounded border transition-colors flex items-center gap-1.5 whitespace-nowrap ${x?"border-border-medium bg-elevated text-text-secondary":"border-transparent bg-transparent text-text-muted/40 line-through"}`,children:[a.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:y.color,opacity:x?1:.3}}),y.label]},y.key)})})]}),r&&(((N=r.layers)==null?void 0:N.length)??0)>0&&a.jsxs("section",{children:[a.jsx(Oe,{children:f.drawer.layers}),a.jsx("div",{className:"-mx-1",children:a.jsx(Ko,{})})]}),a.jsxs("section",{children:[a.jsx(Oe,{children:f.drawer.tools}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx(dr,{}),a.jsx(lr,{}),a.jsxs("button",{type:"button",onClick:()=>{n(),t()},className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm bg-elevated text-text-secondary hover:text-text-primary transition-colors",children:[a.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 7h8m0 0v8m0-8l-8 8-4-4-6 6"})}),f.drawer.path]}),a.jsx(gr,{}),a.jsxs("button",{type:"button",onClick:()=>{o(),t()},className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm bg-elevated text-text-secondary hover:text-text-primary transition-colors","aria-label":f.drawer.help,children:[a.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),f.drawer.help]})]})]})]})]})]})}const Vu=v.lazy(()=>xe(()=>import("./CodeViewer-rSBW2agS.js"),__vite__mapDeps([0,1,2,3,4,5,6]))),Gu=v.lazy(()=>xe(()=>import("./LearnPanel-5c2YOSlA.js"),__vite__mapDeps([7,1,8,2,3,4,5,6]))),Hu=v.lazy(()=>xe(()=>import("./PathFinderModal-iyLG943e.js"),__vite__mapDeps([9,1,2,3,4,5,6]))),Uu=v.lazy(()=>xe(()=>import("./KeyboardShortcutsHelp-C08UrzhP.js"),__vite__mapDeps([10,1,2,3,4,5,6])));function Wu({accessToken:e,showKeyboardHelp:t,setShowKeyboardHelp:n,loadError:o,allIssues:r,shortcuts:s}){const i=b(w=>w.graph),c=b(w=>w.selectedNodeId),d=b(w=>w.tourActive),l=b(w=>w.persona),u=b(w=>w.viewMode),f=b(w=>w.domainGraph),h=b(w=>w.codeViewerOpen),g=b(w=>w.closeCodeViewer),m=b(w=>w.pathFinderOpen),p=b(w=>w.togglePathFinder),{t:N}=re(),[y,x]=v.useState("graph"),[k,T]=v.useState(!1),[j,C]=v.useState(!1);v.useEffect(()=>{c&&x("info")},[c]),v.useEffect(()=>{h&&C(!1)},[h]);const I=d||l==="junior",E=a.jsxs(a.Fragment,{children:[c&&a.jsx(ir,{}),I&&a.jsx(v.Suspense,{fallback:null,children:a.jsx(Gu,{})}),!c&&!I&&a.jsx(fr,{})]});return a.jsxs("div",{className:"h-screen w-screen flex flex-col bg-root text-text-primary noise-overlay",children:[a.jsxs("header",{className:"flex items-center gap-2 px-3 h-12 shrink-0 bg-surface border-b border-border-subtle",children:[a.jsx("button",{type:"button",onClick:()=>T(!0),className:"w-9 h-9 flex items-center justify-center rounded-lg text-text-secondary hover:text-text-primary hover:bg-elevated transition-colors -ml-1","aria-label":"Open menu",children:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",strokeWidth:1.8,viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",d:"M4 7h16M4 12h16M4 17h16"})})}),a.jsx("h1",{className:"font-heading text-base flex-1 min-w-0 truncate text-center text-text-primary tracking-wide",children:(i==null?void 0:i.project.name)??N.common.appName}),a.jsx("button",{type:"button",onClick:()=>C(w=>!w),className:`w-9 h-9 flex items-center justify-center rounded-lg transition-colors -mr-1 ${j?"text-accent bg-accent/15":"text-text-secondary hover:text-text-primary hover:bg-elevated"}`,"aria-label":j?"Hide search":"Show search","aria-pressed":j,children:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",strokeWidth:1.8,viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})})]}),j&&a.jsx(ar,{}),r.length>0&&!o&&a.jsx(mr,{issues:r}),o&&a.jsx("div",{className:"px-4 py-3 bg-red-900/30 border-b border-red-700 text-red-200 text-sm",children:o}),a.jsxs("div",{className:"flex-1 min-h-0 relative",children:[a.jsx("div",{className:`absolute inset-0 ${y==="graph"?"":"invisible pointer-events-none"}`,"aria-hidden":y!=="graph",children:u==="knowledge"?a.jsx(sr,{}):u==="domain"&&f?a.jsx(rr,{}):a.jsx(nr,{})}),a.jsx("div",{className:`absolute inset-0 overflow-auto bg-surface ${y==="info"?"":"invisible pointer-events-none"}`,"aria-hidden":y!=="info",children:E}),a.jsx("div",{className:`absolute inset-0 overflow-auto bg-surface ${y==="files"?"":"invisible pointer-events-none"}`,"aria-hidden":y!=="files",children:a.jsx(hr,{})})]}),a.jsx(Zu,{activeTab:y,onTabChange:x}),a.jsx(Bu,{open:k,onClose:()=>T(!1),onTogglePathFinder:p,onShowKeyboardHelp:()=>n(!0)}),h&&a.jsx("div",{className:"fixed inset-0 z-50 flex bg-black/70 backdrop-blur-sm p-2 sm:p-4",onMouseDown:g,children:a.jsx("div",{className:"flex-1 rounded-lg border border-border-medium bg-surface shadow-2xl overflow-hidden",onMouseDown:w=>w.stopPropagation(),children:a.jsx(v.Suspense,{fallback:null,children:a.jsx(Vu,{accessToken:e,presentation:"modal",onClose:g})})})}),t&&a.jsx(v.Suspense,{fallback:null,children:a.jsx(Uu,{shortcuts:s,onClose:()=>n(!1)})}),m&&a.jsx(v.Suspense,{fallback:null,children:a.jsx(Hu,{isOpen:m,onClose:p})})]})}const Ku=768;function Ju(e=Ku){const t=`(max-width: ${e-1}px)`,[n,o]=v.useState(()=>typeof window>"u"?!1:window.matchMedia(t).matches);return v.useEffect(()=>{const r=window.matchMedia(t),s=i=>o(i.matches);return o(r.matches),r.addEventListener("change",s),()=>r.removeEventListener("change",s)},[t]),n}function Yu(e,t=!0){v.useEffect(()=>{if(!t)return;const n=o=>{const r=o.target,s=r.tagName.toLowerCase();if(!((s==="input"||s==="textarea"||r.isContentEditable)&&o.key!=="Escape"))for(const i of e){const c=o.key.toLowerCase()===i.key.toLowerCase(),d=i.ctrlKey?o.ctrlKey:!o.ctrlKey,l=i.shiftKey?o.shiftKey:!o.shiftKey,u=i.altKey?o.altKey:!o.altKey,f=i.metaKey?o.metaKey:!o.metaKey;if(c&&d&&l&&u&&f){(o.ctrlKey||o.metaKey||o.altKey)&&o.preventDefault(),i.action();break}}};return document.addEventListener("keydown",n),()=>document.removeEventListener("keydown",n)},[e,t])}function hf(e){var r;const t=[],n=(r=navigator.userAgentData)!=null&&r.platform?navigator.userAgentData.platform==="macOS":navigator.platform.includes("Mac");(e.ctrlKey||e.metaKey)&&t.push(n?"⌘":"Ctrl");const o=e.key.length===1&&/[^a-zA-Z0-9]/.test(e.key);return e.shiftKey&&!o&&t.push("⇧"),e.altKey&&t.push(n?"⌥":"Alt"),t.push(o?e.key:e.key.toUpperCase()),t.join(" + ")}const to=v.lazy(()=>xe(()=>import("./CodeViewer-rSBW2agS.js"),__vite__mapDeps([0,1,2,3,4,5,6]))),Xu=v.lazy(()=>xe(()=>import("./LearnPanel-5c2YOSlA.js"),__vite__mapDeps([7,1,8,2,3,4,5,6]))),qu=v.lazy(()=>xe(()=>import("./PathFinderModal-iyLG943e.js"),__vite__mapDeps([9,1,2,3,4,5,6]))),Qu=v.lazy(()=>xe(()=>import("./KeyboardShortcutsHelp-C08UrzhP.js"),__vite__mapDeps([10,1,2,3,4,5,6]))),ef=v.lazy(()=>xe(()=>import("./RagAssistant-B-bW6zDi.js"),__vite__mapDeps([11,1,2,3,4,5,6]))),tf=v.lazy(()=>xe(()=>import("./OnboardingOverlay-HYdAkhjv.js"),__vite__mapDeps([12,1,2,3,4,5,6]))),Gt="understand-anything-token",xr="ua-onboarding-dismissed-v1";function nf(){return typeof window>"u"?!1:new URLSearchParams(window.location.search).get("onboard")==="force"?!0:window.localStorage.getItem(xr)!=="1"}function Ge(e,t){const n=`/${e}`;return t?`${n}?token=${encodeURIComponent(t)}`:n}function of(){const e=new URLSearchParams(window.location.search),t=e.get("token");if(t){sessionStorage.setItem(Gt,t),e.delete("token");const n=e.toString(),o=window.location.pathname+(n?`?${n}`:"")+window.location.hash;return window.history.replaceState(null,"",o),t}return sessionStorage.getItem(Gt)}function rf(){const[e,t]=v.useState(of),n=v.useCallback(o=>{sessionStorage.setItem(Gt,o),t(o)},[]);return e===null?a.jsx(Du,{onTokenValid:n}):a.jsx(sf,{accessToken:e})}function sf({accessToken:e}){const t=b(h=>h.setGraph),n=b(h=>h.setDomainGraph),o=b(h=>h.setDiffOverlay),[r,s]=v.useState(null),[i,c]=v.useState([]),[d,l]=v.useState(null),[u,f]=v.useState();return v.useEffect(()=>{fetch(Ge("meta.json",e)).then(h=>h.ok?h.json():null).then(h=>{h!=null&&h.theme&&l(h.theme)}).catch(()=>{}),fetch(Ge("config.json",e)).then(h=>h.ok?h.json():null).then(h=>{h!=null&&h.outputLanguage&&f(h.outputLanguage)}).catch(()=>{})},[]),v.useEffect(()=>{fetch(Ge("knowledge-graph.json",e)).then(h=>h.json()).then(h=>{const g=Mn(h);if(g.success&&g.data){t(g.data),c(g.issues),h.kind==="knowledge"&&(b.getState().setViewMode("knowledge"),b.getState().setIsKnowledgeGraph(!0));for(const m of g.issues)m.level==="auto-corrected"?console.warn(`[graph] auto-corrected: ${m.message}`):m.level==="dropped"&&console.error(`[graph] dropped: ${m.message}`)}else g.fatal?(console.error("Knowledge graph validation failed:",g.fatal),s(`Invalid knowledge graph: ${g.fatal}`)):(console.error("Knowledge graph validation failed: unknown error"),s("Invalid knowledge graph: unknown validation error"))}).catch(h=>{console.error("Failed to load knowledge graph:",h),s(`Failed to load knowledge graph: ${h instanceof Error?h.message:String(h)}`)})},[t]),v.useEffect(()=>{fetch(Ge("diff-overlay.json",e)).then(h=>h.ok?h.json():null).then(h=>{if(h&&typeof h=="object"&&"changedNodeIds"in h&&"affectedNodeIds"in h&&Array.isArray(h.changedNodeIds)&&Array.isArray(h.affectedNodeIds)){const g=h;g.changedNodeIds.length>0&&o(g.changedNodeIds,g.affectedNodeIds)}}).catch(()=>{})},[o]),v.useEffect(()=>{fetch(Ge("domain-graph.json",e)).then(h=>h.ok?h.json():null).then(h=>{if(!h)return;const g=Mn(h);g.success&&g.data?n(g.data):g.fatal&&console.warn(`[domain-graph] validation failed: ${g.fatal}`)}).catch(()=>{})},[n]),a.jsx(wl,{language:u??"en",children:a.jsx(Ml,{metaTheme:d,children:a.jsx(af,{accessToken:e,loadError:r,graphIssues:i})})})}function af({accessToken:e,loadError:t,graphIssues:n}){const o=b(S=>S.graph),r=b(S=>S.selectedNodeId),s=b(S=>S.tourActive),i=b(S=>S.persona),c=b(S=>S.codeViewerOpen),d=b(S=>S.codeViewerExpanded),l=b(S=>S.expandCodeViewer),u=b(S=>S.collapseCodeViewer),f=b(S=>S.pathFinderOpen),h=b(S=>S.togglePathFinder),g=b(S=>S.nodeTypeFilters),m=b(S=>S.toggleNodeTypeFilter),p=b(S=>S.detailLevel),N=b(S=>S.setDetailLevel),y=b(S=>S.showFunctionsInClassView),x=b(S=>S.toggleShowFunctionsInClassView),[k,T]=v.useState(!1),[j,C]=v.useState(!1),[I,E]=v.useState("info"),[w,M]=v.useState(nf),$=v.useCallback(S=>{S&&typeof window<"u"&&window.localStorage.setItem(xr,"1"),M(!1)},[]),D=b(S=>S.viewMode),Z=b(S=>S.setViewMode),P=b(S=>S.isKnowledgeGraph),V=b(S=>S.domainGraph),R=b(S=>S.layoutIssues),U=Ju(),{t:A}=re(),Q=v.useMemo(()=>[...n,...R],[n,R]);v.useEffect(()=>{r&&E("info")},[r]);const se=v.useMemo(()=>[{key:"?",shiftKey:!0,description:A.keyboardShortcuts.showHelp,action:()=>T(S=>!S),category:"General"},{key:"Escape",description:A.keyboardShortcuts.escapeDesc,action:()=>{const S=b.getState();S.pathFinderOpen?S.togglePathFinder():S.filterPanelOpen?S.toggleFilterPanel():S.exportMenuOpen?S.toggleExportMenu():S.codeViewerExpanded?S.collapseCodeViewer():S.codeViewerOpen?S.closeCodeViewer():S.selectedNodeId?S.selectNode(null):S.navigationLevel==="layer-detail"?S.navigateToOverview():S.tourActive?S.stopTour():T(!1)},category:"Navigation"},{key:"/",description:A.keyboardShortcuts.focusSearch,action:()=>{const S=document.querySelector('[data-testid="search-input"]');S==null||S.focus()},category:"Navigation"},{key:"ArrowRight",description:A.keyboardShortcuts.nextStep,action:()=>{const S=b.getState();S.tourActive&&S.nextTourStep()},category:"Tour"},{key:"ArrowLeft",description:A.keyboardShortcuts.prevStep,action:()=>{const S=b.getState();S.tourActive&&S.prevTourStep()},category:"Tour"},{key:"d",description:A.keyboardShortcuts.toggleDiff,action:()=>{b.getState().toggleDiffMode()},category:"View"},{key:"f",description:A.keyboardShortcuts.toggleFilter,action:()=>{b.getState().toggleFilterPanel()},category:"View"},{key:"e",description:A.keyboardShortcuts.toggleExport,action:()=>{b.getState().toggleExportMenu()},category:"View"},{key:"p",description:A.keyboardShortcuts.openPathFinder,action:()=>{b.getState().togglePathFinder()},category:"View"},{key:"r",description:"打开知识库 RAG 问答",action:()=>C(S=>!S),category:"View"}],[A]);Yu(se);const K=s||i==="junior",z=a.jsxs(a.Fragment,{children:[r&&a.jsx(ir,{}),K&&a.jsx(v.Suspense,{fallback:null,children:a.jsx(Xu,{})}),!r&&!K&&a.jsx(fr,{})]}),J=a.jsxs("div",{className:"h-full flex flex-col min-h-0",children:[a.jsx("div",{className:"flex items-center gap-1 p-2 border-b border-border-subtle bg-surface shrink-0",children:["info","files"].map(S=>a.jsx("button",{type:"button",onClick:()=>E(S),className:`flex-1 px-3 py-1.5 rounded-md text-xs font-semibold uppercase tracking-wider transition-colors ${I===S?"bg-accent/15 text-accent":"text-text-muted hover:text-text-primary hover:bg-elevated"}`,children:S==="info"?A.sidebar.info:A.sidebar.files},S))}),a.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:I==="files"?a.jsx(hr,{}):z})]});return U?a.jsx(Wu,{accessToken:e,showKeyboardHelp:k,setShowKeyboardHelp:T,loadError:t,allIssues:Q,shortcuts:se}):a.jsxs("div",{className:"h-screen w-screen flex flex-col bg-root text-text-primary noise-overlay",children:[a.jsxs("header",{className:"flex items-center px-3 sm:px-5 py-3 bg-surface border-b border-border-subtle shrink-0 gap-2 sm:gap-4",children:[a.jsxs("div",{className:"flex items-center gap-3 sm:gap-5 shrink-0 min-w-0",children:[a.jsx("h1",{className:"font-heading text-base sm:text-lg text-text-primary tracking-wide truncate max-w-[160px] sm:max-w-[220px] lg:max-w-none",children:(o==null?void 0:o.project.name)??A.common.appName}),a.jsx("div",{className:"w-px h-5 bg-border-subtle hidden sm:block"}),a.jsx(ur,{}),o&&!P&&V&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"w-px h-5 bg-border-subtle"}),a.jsxs("div",{className:"flex items-center bg-elevated rounded-lg p-0.5",children:[a.jsx("button",{type:"button",onClick:()=>Z("domain"),title:A.drawer.domain,className:`px-3 py-1 text-xs font-medium rounded-md transition-colors ${D==="domain"?"bg-accent/20 text-accent":"text-text-muted hover:text-text-secondary"}`,children:A.drawer.domain}),a.jsx("button",{type:"button",onClick:()=>Z("structural"),title:A.drawer.structural,className:`px-3 py-1 text-xs font-medium rounded-md transition-colors ${D==="structural"?"bg-accent/20 text-accent":"text-text-muted hover:text-text-secondary"}`,children:A.drawer.structural})]})]})]}),a.jsx("div",{className:"flex-1 min-w-0 overflow-x-auto scrollbar-hide",children:a.jsxs("div",{className:"flex items-center gap-4 w-max",children:[a.jsx(cr,{}),!P&&D!=="domain"&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"w-px h-5 bg-border-subtle"}),a.jsxs("div",{className:"flex items-center bg-elevated rounded-lg p-0.5",children:[a.jsx("button",{type:"button",onClick:()=>N("file"),title:A.detailLevel.filesTitle,className:`px-3 py-1 text-xs font-medium rounded-md transition-colors ${p==="file"?"bg-accent/20 text-accent":"text-text-muted hover:text-text-secondary"}`,children:A.detailLevel.files}),a.jsx("button",{type:"button",onClick:()=>N("class"),title:A.detailLevel.classesTitle,className:`px-3 py-1 text-xs font-medium rounded-md transition-colors ${p==="class"?"bg-accent/20 text-accent":"text-text-muted hover:text-text-secondary"}`,children:A.detailLevel.classes})]}),p==="class"&&a.jsx("button",{type:"button",onClick:x,title:A.detailLevel.fnTitle,className:`text-[10px] font-semibold uppercase tracking-wider px-2 py-1 rounded border transition-colors ${y?"border-amber-500/50 bg-amber-500/10 text-amber-400":"border-border-medium bg-elevated text-text-muted hover:text-text-secondary"}`,children:A.detailLevel.fn})]}),a.jsx("div",{className:"flex items-center gap-1",children:(P?[{key:"knowledge",label:A.nodeTypeLabels.all,color:"var(--color-node-article)"}]:[{key:"code",label:A.nodeTypeLabels.code,color:"var(--color-node-file)"},{key:"config",label:A.nodeTypeLabels.config,color:"var(--color-node-config)"},{key:"docs",label:A.nodeTypeLabels.docs,color:"var(--color-node-document)"},{key:"infra",label:A.nodeTypeLabels.infra,color:"var(--color-node-service)"},{key:"data",label:A.nodeTypeLabels.data,color:"var(--color-node-table)"},{key:"domain",label:A.nodeTypeLabels.domain,color:"var(--color-node-concept)"},{key:"knowledge",label:A.nodeTypeLabels.knowledge,color:"var(--color-node-article)"}]).map(S=>a.jsxs("button",{onClick:()=>m(S.key),className:`text-[10px] font-semibold uppercase tracking-wider px-2 py-1 rounded border transition-colors flex items-center gap-1.5 whitespace-nowrap ${g[S.key]!==!1?"border-border-medium bg-elevated text-text-secondary hover:text-text-primary":"border-transparent bg-transparent text-text-muted/40 line-through hover:text-text-muted"}`,title:`${g[S.key]!==!1?"Hide":"Show"} ${S.label} nodes`,children:[a.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:S.color,opacity:g[S.key]!==!1?1:.3}}),S.label]},S.key))}),a.jsx(Ko,{})]})}),a.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 shrink-0",children:[a.jsx(dr,{}),a.jsx(lr,{}),a.jsxs("button",{type:"button",onClick:()=>C(!0),className:"flex items-center gap-1.5 px-2 sm:px-3 py-1.5 rounded-lg text-sm bg-elevated text-text-secondary hover:text-text-primary transition-colors",title:"知识库 RAG 问答",children:[a.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 10h8M8 14h5m8-2a9 9 0 11-3.219-6.89L21 5v7z"})}),a.jsx("span",{className:"hidden md:inline",children:"RAG"})]}),a.jsxs("button",{onClick:h,className:"flex items-center gap-1.5 px-2 sm:px-3 py-1.5 rounded-lg text-sm bg-elevated text-text-secondary hover:text-text-primary transition-colors",title:A.pathFinder.title,children:[a.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 7h8m0 0v8m0-8l-8 8-4-4-6 6"})}),a.jsx("span",{className:"hidden md:inline",children:A.common.path})]}),a.jsx(gr,{}),a.jsx("button",{onClick:()=>T(!0),className:"text-text-muted hover:text-accent transition-colors",title:A.keyboardShortcuts.showHelp,children:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})})]})]}),a.jsx(ar,{}),Q.length>0&&!t&&a.jsx(mr,{issues:Q}),t&&a.jsx("div",{className:"px-5 py-3 bg-red-900/30 border-b border-red-700 text-red-200 text-sm",children:t}),a.jsxs("div",{className:"flex-1 flex min-h-0 relative",children:[a.jsxs("div",{className:"flex-1 min-w-0 min-h-0 relative",children:[D==="knowledge"?a.jsx(sr,{}):D==="domain"&&V?a.jsx(rr,{}):a.jsx(nr,{}),a.jsx("div",{className:"absolute top-3 right-3 text-sm text-text-muted/60 pointer-events-none select-none",children:A.common.pressKeyboard})]}),a.jsx("aside",{className:"w-[260px] md:w-[300px] lg:w-[360px] shrink-0 bg-surface border-l border-border-subtle overflow-auto",children:J}),c&&!d&&a.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-[40vh] bg-surface border-t border-border-subtle animate-slide-up z-20 overflow-hidden",children:a.jsx(v.Suspense,{fallback:null,children:a.jsx(to,{accessToken:e,onExpand:l})})})]}),c&&d&&a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/65 backdrop-blur-sm p-4 sm:p-6",onMouseDown:u,children:a.jsx("div",{className:"w-[calc(100vw-32px)] max-w-[1120px] h-[calc(100vh-32px)] sm:h-[calc(100vh-48px)] max-h-[820px] rounded-lg border border-border-medium bg-surface shadow-2xl overflow-hidden",onMouseDown:S=>S.stopPropagation(),children:a.jsx(v.Suspense,{fallback:null,children:a.jsx(to,{accessToken:e,presentation:"modal",onClose:u})})})}),k&&a.jsx(v.Suspense,{fallback:null,children:a.jsx(Qu,{shortcuts:se,onClose:()=>T(!1)})}),j&&a.jsx(v.Suspense,{fallback:null,children:a.jsx(ef,{onClose:()=>C(!1)})}),f&&a.jsx(v.Suspense,{fallback:null,children:a.jsx(qu,{isOpen:f,onClose:h})}),w&&a.jsx(v.Suspense,{fallback:null,children:a.jsx(tf,{onDismiss:$})})]})}wr.createRoot(document.getElementById("root")).render(a.jsx(v.StrictMode,{children:a.jsx(rf,{})}));export{re as a,hf as f,b as u};