import { d as attr_style, f as stringify, c as escape_html } from './dev-BNpEUZI3.js';

//#region src/lib/graph/edge-kinds.ts
/**
* The edge-style table. Every {@link EdgeKind} variant MUST be present
* — the edge-kinds.test.ts unit enforces that invariant at build time.
*/
var EDGE_STYLE = {
	parent: {
		color: "var(--edge-structural)",
		thickness: 1,
		arrow: true
	},
	contains: {
		color: "var(--edge-structural)",
		thickness: 1,
		arrow: true
	},
	has_method: {
		color: "var(--edge-structural-soft)",
		thickness: 1,
		arrow: true
	},
	has_property: {
		color: "var(--edge-structural-soft)",
		thickness: 1,
		arrow: true
	},
	member_of: {
		color: "var(--edge-structural)",
		thickness: 1,
		arrow: true
	},
	calls: {
		color: "var(--edge-call)",
		thickness: 1.5,
		arrow: true
	},
	extends: {
		color: "var(--edge-extends)",
		thickness: 1.5,
		arrow: true
	},
	implements: {
		color: "var(--edge-implements)",
		thickness: 1.5,
		arrow: true
	},
	imports: {
		color: "var(--edge-import)",
		thickness: 1,
		arrow: true
	},
	accesses: {
		color: "var(--edge-import-soft)",
		thickness: 1,
		arrow: true
	},
	defines: {
		color: "var(--edge-definition)",
		thickness: 1.2,
		arrow: true
	},
	blocks: {
		color: "var(--edge-workflow)",
		dash: "6 3",
		thickness: 1.5,
		arrow: true
	},
	depends: {
		color: "var(--edge-workflow-soft)",
		dash: "2 3",
		thickness: 1.5,
		arrow: true
	},
	supersedes: {
		color: "var(--edge-knowledge)",
		dash: "6 3",
		thickness: 1.8,
		arrow: true
	},
	contradicts: {
		color: "var(--edge-contradicts)",
		dash: "4 2",
		thickness: 1.8,
		arrow: true
	},
	derived_from: {
		color: "var(--edge-knowledge-soft)",
		thickness: 1.4,
		arrow: true
	},
	produced_by: {
		color: "var(--edge-knowledge-soft)",
		thickness: 1.2,
		arrow: true
	},
	informed_by: {
		color: "var(--edge-knowledge-soft)",
		thickness: 1.2,
		arrow: true
	},
	references: {
		color: "var(--edge-citation)",
		thickness: 1,
		arrow: false
	},
	cites: {
		color: "var(--edge-citation)",
		dash: "2 3",
		thickness: 1,
		arrow: false
	},
	documents: {
		color: "var(--edge-citation-soft)",
		thickness: 1.2,
		arrow: true
	},
	fires: {
		color: "var(--edge-fires)",
		thickness: 1.4,
		arrow: false,
		animated: true
	},
	co_fires: {
		color: "var(--edge-cofires)",
		thickness: 1.2,
		arrow: false,
		animated: true
	},
	messages: {
		color: "var(--edge-messages)",
		thickness: 1,
		arrow: true
	},
	relates_to: {
		color: "var(--edge-relates)",
		thickness: .8,
		arrow: false
	}
};
/**
* Short human-readable description for an edge kind. Consumed by the
* legend dock and keyboard-accessible side-panel.
*
* @param kind - Canonical edge kind.
*/
function describeEdgeKind(kind) {
	switch (kind) {
		case "parent": return "Parent of (hierarchy)";
		case "contains": return "Contains (hierarchy)";
		case "has_method": return "Has method";
		case "has_property": return "Has property";
		case "member_of": return "Member of";
		case "calls": return "Calls (function invocation)";
		case "extends": return "Extends (class hierarchy)";
		case "implements": return "Implements (interface)";
		case "imports": return "Imports module";
		case "accesses": return "Accesses property / field";
		case "defines": return "Defines symbol";
		case "blocks": return "Blocks (task cannot start)";
		case "depends": return "Depends on (task dependency)";
		case "supersedes": return "Supersedes (memory lineage)";
		case "contradicts": return "Contradicts (memory conflict)";
		case "derived_from": return "Derived from";
		case "produced_by": return "Produced by";
		case "informed_by": return "Informed by";
		case "references": return "References";
		case "cites": return "Cites";
		case "documents": return "Documents";
		case "fires": return "Synapse fires";
		case "co_fires": return "Co-fires (Hebbian)";
		case "messages": return "Conduit message";
		case "relates_to": return "Relates to (generic)";
	}
}
/**
* Resolver cache — populated lazily by {@link resolveEdgeStyleForWebGL}
* once per render loop. Key = edge kind, value = `[r,g,b]` linear-ish
* RGB tuple in the `[0,1]` range.
*/
var webglRgbCache = /* @__PURE__ */ new Map();
/**
* Parse a CSS `rgb()` / `rgba()` / `#rrggbb` string into `[r,g,b]` in
* the `[0,1]` range. Rejects anything else with a fallback to white.
*
* The browser always serialises computed `getComputedStyle` values
* into `rgb()` / `rgba()` form (per CSS Color 4), so a single parser
* covers both `var(--token)` references AND `color-mix()` composites.
*
* @param css - CSS colour string resolved by the browser.
*/
function parseCssColorToRgb01(css) {
	const trimmed = css.trim();
	const rgbMatch = /rgba?\(([^)]+)\)/i.exec(trimmed);
	if (rgbMatch) {
		const parts = rgbMatch[1].split(/[,\s/]+/).filter((p) => p.length > 0);
		if (parts.length >= 3) {
			const r = Number.parseFloat(parts[0]);
			const g = Number.parseFloat(parts[1]);
			const b = Number.parseFloat(parts[2]);
			if (Number.isFinite(r) && Number.isFinite(g) && Number.isFinite(b)) return [
				r / 255,
				g / 255,
				b / 255
			];
		}
	}
	const hexMatch = /^#([0-9a-f]{6})$/i.exec(trimmed);
	if (hexMatch) {
		const hex = hexMatch[1];
		return [
			Number.parseInt(hex.slice(0, 2), 16) / 255,
			Number.parseInt(hex.slice(2, 4), 16) / 255,
			Number.parseInt(hex.slice(4, 6), 16) / 255
		];
	}
	return [
		1,
		1,
		1
	];
}
/**
* Resolve an edge kind to an `[r,g,b]` tuple in the `[0,1]` range for
* use as THREE.js vertex colour / shader uniform.
*
* Reads from `getComputedStyle(:root)` so every token swap (theme
* change, prefers-contrast, etc.) flows through without a rebuild.
* The result is memoised — call {@link invalidateEdgeStyleCache} on
* theme change.
*
* Safe to call in SSR: returns a neutral grey when `document` is
* unavailable.
*
* @param kind - Canonical edge kind.
*/
function resolveEdgeStyleForWebGL(kind) {
	const cached = webglRgbCache.get(kind);
	if (cached !== void 0) return cached;
	if (typeof document === "undefined" || typeof window === "undefined") return [
		.5,
		.5,
		.5
	];
	const style = EDGE_STYLE[kind];
	const probe = document.createElement("span");
	probe.style.color = style.color;
	probe.style.position = "absolute";
	probe.style.visibility = "hidden";
	probe.style.pointerEvents = "none";
	document.body.appendChild(probe);
	const computed = window.getComputedStyle(probe).color;
	document.body.removeChild(probe);
	const rgb = parseCssColorToRgb01(computed);
	webglRgbCache.set(kind, rgb);
	return rgb;
}
/**
* Ordered list of every edge kind — consumers use this to iterate in a
* stable order (legend dock, tests, docs).
*/
var ALL_EDGE_KINDS = [
	"parent",
	"contains",
	"has_method",
	"has_property",
	"member_of",
	"calls",
	"extends",
	"implements",
	"imports",
	"accesses",
	"defines",
	"blocks",
	"depends",
	"supersedes",
	"contradicts",
	"derived_from",
	"produced_by",
	"informed_by",
	"references",
	"cites",
	"documents",
	"fires",
	"co_fires",
	"messages",
	"relates_to"
];
//#endregion
//#region src/lib/graph/hover-label.svelte
function Hover_label($$renderer, $$props) {
	$$renderer.component(($$renderer) => {
		/**
		* Props for {@link HoverLabel}.
		*/
		/** Node under the pointer, or null to hide. */
		/** Pointer x, relative to the canvas container (in pixels). */
		/** Pointer y, relative to the canvas container (in pixels). */
		/** Optional secondary line. */
		/** Optional accent colour (CSS variable reference). */
		let { node, x, y, secondary = null, accent = "var(--accent)" } = $$props;
		if (node) {
			$$renderer.push("<!--[0-->");
			$$renderer.push(`<div class="hover-label svelte-tncwnh" role="tooltip" aria-hidden="true"${attr_style(`left: ${stringify(x + 14)}px; top: ${stringify(y + 14)}px; --hover-accent: ${stringify(accent)};`)}><span class="dot svelte-tncwnh" aria-hidden="true"></span> <span class="content svelte-tncwnh"><span class="label svelte-tncwnh">${escape_html(node.label)}</span> <span class="meta svelte-tncwnh"><span class="kind svelte-tncwnh">${escape_html(node.kind)}</span> `);
			if (secondary) {
				$$renderer.push("<!--[0-->");
				$$renderer.push(`<span class="sep svelte-tncwnh" aria-hidden="true">·</span> <span class="secondary svelte-tncwnh">${escape_html(secondary)}</span>`);
			} else $$renderer.push("<!--[-1-->");
			$$renderer.push(`<!--]--></span></span></div>`);
		} else $$renderer.push("<!--[-1-->");
		$$renderer.push(`<!--]-->`);
	});
}

export { ALL_EDGE_KINDS as A, EDGE_STYLE as E, Hover_label as H, describeEdgeKind as d, resolveEdgeStyleForWebGL as r };
//# sourceMappingURL=no-face-up-DcejJLy-.js.map
