/**
 * DrawerKey — the canonical string-literal union of every detail-drawer the
 * cockpit can open. Kept in its own (pure, no-React) module so both the trigger
 * components (ScanCard / hero cards) and the registry import the same union
 * without pulling in React content.
 *
 * Keys mirror the prototype `#drawer-templates` (`<template data-key="...">`) so
 * deep-links (`?drawer=market`) line up 1:1 with the redesign reference.
 */

export const DRAWER_KEYS = [
  "passport",
  "buildability",
  "urban",
  "restrictions",
  "engineering",
  "market",
  "economy",
  "risks",
  "georisks",
  "oks",
  "potential",
  "product",
  "finance",
  "legal",
  "environment",
  "insolation",
  "future3d",
] as const;

export type DrawerKey = (typeof DRAWER_KEYS)[number];

/** Narrow an arbitrary string (e.g. a `?drawer=` query value) to a DrawerKey. */
export function asDrawerKey(
  value: string | null | undefined,
): DrawerKey | null {
  if (!value) return null;
  return (DRAWER_KEYS as readonly string[]).includes(value)
    ? (value as DrawerKey)
    : null;
}
