/** گزینه‌های رنگ چشم — همان فایل‌های مشخصات ظاهری */
export const EYE_COLOR_OPTIONS = Array.from({ length: 26 }, (_, i) => {
  const file = `${String(i + 1).padStart(2, "0")}.png`;
  return { value: file, label: `چشم ${i + 1}`, src: `/images/eyes/${file}` };
});

/** گزینه‌های رنگ مو — همان فایل‌های مشخصات ظاهری */
export const HAIR_COLOR_OPTIONS = Array.from({ length: 85 }, (_, i) => {
  const file = `${String(i + 1).padStart(2, "0")}.png`;
  return { value: file, label: `مو ${i + 1}`, src: `/images/hairs/${file}` };
});

export type AppearanceFilters = {
  heightMin?: string;
  heightMax?: string;
  weightMin?: string;
  weightMax?: string;
  sizeMin?: string;
  sizeMax?: string;
  hair_color?: string;
  eye_color?: string;
};

export function readAppearanceFiltersFromSearch(
  params: URLSearchParams
): AppearanceFilters {
  return {
    heightMin: params.get("heightMin") || "",
    heightMax: params.get("heightMax") || "",
    weightMin: params.get("weightMin") || "",
    weightMax: params.get("weightMax") || "",
    sizeMin: params.get("sizeMin") || "",
    sizeMax: params.get("sizeMax") || "",
    hair_color: params.get("hair_color") || "",
    eye_color: params.get("eye_color") || "",
  };
}

export function appendAppearanceFiltersToSearch(
  params: URLSearchParams,
  filters: AppearanceFilters
) {
  const entries: (keyof AppearanceFilters)[] = [
    "heightMin",
    "heightMax",
    "weightMin",
    "weightMax",
    "sizeMin",
    "sizeMax",
    "hair_color",
    "eye_color",
  ];
  entries.forEach((key) => {
    const val = filters[key];
    if (val) params.set(key, val);
    else params.delete(key);
  });
}
