import type { AppLocale } from "../locale";
import { DEFAULT_LOCALE } from "../locale";

export type PublicPageRendererMessages = {
  requiredFieldsPrefix: string;
  submitSuccessDefault: string;
  submitErrorDefault: string;

  checkboxGroupLabelImageAltFallback: string;
  checkboxOptionImageAltFallback: string;
  radioOptionImageAltFallback: string;
};

const PUBLIC_PAGE_RENDERER_MESSAGES: Record<AppLocale, PublicPageRendererMessages> = {
  en: {
    requiredFieldsPrefix: "Please fill in the following required fields:",
    submitSuccessDefault: "Submitted successfully.",
    submitErrorDefault: "An error occurred while submitting.",

    checkboxGroupLabelImageAltFallback: "Form group title",
    checkboxOptionImageAltFallback: "Checkbox option",
    radioOptionImageAltFallback: "Radio option",
  },
  ko: {
    requiredFieldsPrefix: "다음 필수 항목을 입력해 주세요:",
    submitSuccessDefault: "성공적으로 전송되었습니다.",
    submitErrorDefault: "전송 중 오류가 발생했습니다.",

    checkboxGroupLabelImageAltFallback: "폼 그룹 타이틀",
    checkboxOptionImageAltFallback: "체크박스 옵션",
    radioOptionImageAltFallback: "라디오 옵션",
  },
};

export function getPublicPageRendererMessages(
  locale: AppLocale | null | undefined,
): PublicPageRendererMessages {
  const key = (locale ?? DEFAULT_LOCALE) as AppLocale;
  return PUBLIC_PAGE_RENDERER_MESSAGES[key] ?? PUBLIC_PAGE_RENDERER_MESSAGES[DEFAULT_LOCALE];
}
