export function cleanCategoryDisplayName(name: string): string {
  return name
    .replace(/\s*[（(][^（）()]*[）)]\s*/g, " ")
    .replace(/\s+/g, " ")
    .trim();
}

/** Split display name into title + parenthetical subtitle (matches design cards). */
export function categoryCardLines(
  name: string,
  description?: string,
): { line1: string; line2?: string } {
  const i = name.indexOf("（");
  if (i > 0 && name.includes("）")) {
    return { line1: name.slice(0, i).trim(), line2: name.slice(i).trim() };
  }
  const j = name.indexOf("(");
  if (j > 0 && name.includes(")")) {
    return { line1: name.slice(0, j).trim(), line2: name.slice(j).trim() };
  }
  if (description?.trim()) {
    return { line1: name, line2: description.trim() };
  }
  return { line1: name };
}
