{"version":3,"file":"validate-icon-name.cjs","names":[],"sources":["../../src/icons/validate-icon-name.ts"],"sourcesContent":["import { isIconName } from \"./is-icon-name\";\nimport { normalizeIconName } from \"./normalize-icon-name\";\n\n/** The default message for a slug lucide does not ship. */\nexport const DEFAULT_ICON_PICKER_MESSAGE =\n    \"Ícone inexistente. Use um slug do lucide, em kebab-case.\";\n\n/**\n * Validate an icon slug the way `IconPicker` does.\n *\n * Its own module rather than living next to the component: a file that exports\n * both a component and other values breaks Fast Refresh in a consuming dev\n * server, which is what `react-refresh/only-export-components` guards and why\n * `icon-context.ts` is split off from `IconProvider` too.\n *\n * Exported because the picker is not the only place a slug is checked: a form\n * built on react-hook-form or zod validates before submitting, and duplicating\n * the rule there is how the two drift apart.\n *\n * Empty passes — \"no icon chosen\" is a `required` question, not a spelling one,\n * and conflating them would make the field impossible to clear.\n *\n * @example\n * // react-hook-form\n * register(\"icon\", { validate: (value) => validateIconName(value) ?? true });\n *\n * @example\n * // zod\n * z.string().refine((value) => !validateIconName(value), { message: \"Ícone inexistente\" });\n *\n * @param value - The slug to check, in any spelling the picker accepts.\n * @param message - Overrides the default message.\n * @returns The message when the slug does not exist, `undefined` when it is fine.\n */\nexport function validateIconName(value: string, message?: string): string | undefined {\n    if (value.trim() === \"\") return undefined;\n    return isIconName(normalizeIconName(value))\n        ? undefined\n        : (message ?? DEFAULT_ICON_PICKER_MESSAGE);\n}\n"],"mappings":"6EAIA,IAAa,EACT,2DA6BJ,SAAgB,EAAiB,EAAe,EAAsC,CAC9E,KAAM,KAAK,IAAM,GACrB,OAAO,EAAA,WAAW,EAAA,kBAAkB,CAAK,CAAC,EACpC,IAAA,GACC,GAAA,0DACX"}