import type { TailwindModifierKind } from "@fragments-sdk/core";

const MEDIA_MODIFIERS = new Set([
  "sm",
  "md",
  "lg",
  "xl",
  "2xl",
  "print",
  "portrait",
  "landscape",
  "motion-safe",
  "motion-reduce",
  "contrast-more",
  "contrast-less",
  "forced-colors",
]);

const STATE_MODIFIERS = new Set([
  "active",
  "autofill",
  "checked",
  "default",
  "disabled",
  "empty",
  "enabled",
  "even",
  "first",
  "first-letter",
  "first-line",
  "first-of-type",
  "focus",
  "focus-visible",
  "focus-within",
  "fullscreen",
  "hover",
  "in-range",
  "indeterminate",
  "invalid",
  "last",
  "last-of-type",
  "link",
  "not-first",
  "not-last",
  "odd",
  "only",
  "only-of-type",
  "open",
  "optional",
  "out-of-range",
  "placeholder-shown",
  "read-only",
  "read-write",
  "required",
  "target",
  "valid",
  "visited",
]);

export function classifyModifier(raw: string): TailwindModifierKind {
  if (raw === "dark") return "dark";
  if (MEDIA_MODIFIERS.has(raw)) return "media";
  if (STATE_MODIFIERS.has(raw)) return "state";
  if (raw.startsWith("group") || raw.startsWith("peer") || raw.startsWith("not-")) {
    return "state";
  }
  if (raw.startsWith("aria-")) return "aria";
  if (raw.startsWith("data-")) return "data";
  if (raw.startsWith("[") && raw.endsWith("]")) return "selector";
  if (raw.startsWith("@")) return "container";
  return "unknown";
}
