export interface ComponentMeta {
  readonly name: string;
  readonly description: string;
  readonly parts: readonly string[];
  readonly requiredParts: readonly string[];
}

export interface ComponentEntry {
  exportPath: string;
  meta: ComponentMeta;
  schemas: Record<string, unknown>;
}

/** Converts a PascalCase component name to its pettyui/ kebab-case export path. */
export function toExportPath(name: string): string {
  return "pettyui/" + name.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
}

/** Looks up a single entry by component name (case-insensitive). Returns undefined if not found. */
export function findEntry(name: string, entries: ComponentEntry[]): ComponentEntry | undefined {
  const lower = name.toLowerCase();
  return entries.find((e) => e.meta.name.toLowerCase() === lower);
}

/** Returns all registered pettyui/ export paths from a given entry list. */
export function allExportPaths(entries: ComponentEntry[]): string[] {
  return entries.map((e) => e.exportPath);
}

export { COMPONENT_ENTRIES } from "./registry.js";
