/**
 * Icon resolution for Base components. Use semantic names (e.g. "plus", "trash") in views;
 * they are resolved to PrimeIcons classes here. Avoid raw "pi pi-*" in views.
 *
 * Aliases map common verbs to PrimeIcons glyph names (e.g. `edit` → `pi-pencil`, not `pi-edit`).
 *
 * @param {string} name - Icon name (e.g. "plus", "trash") or full class string (e.g. "pi pi-plus")
 * @returns {string} PrimeIcons class string, or empty string if no name
 */
const ALIASES = {
  edit: "pencil",
  pencil: "pencil",
  remove: "trash",
  delete: "trash",
  cancel: "times",
  close: "times",
  check: "check",
  save: "save",
};

export function resolveIcon(name) {
  if (!name || typeof name !== "string") return "";
  if (name.includes(" ")) return name; // already full class string (backward compat)
  const slug = ALIASES[name] ?? name;

  return "pi pi-" + slug;
}
