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

export type EditorBlockDefaultsMessages = {
  text: {
    defaultText: string;
  };
  list: {
    firstItemText: string;
  };
  button: {
    label: string;
  };
  form: {
    nameLabel: string;
    emailLabel: string;
    messageLabel: string;
    successMessage: string;
    errorMessage: string;
  };
  formInput: {
    label: string;
  };
  formSelect: {
    label: string;
    option1Label: string;
    option2Label: string;
  };
  formCheckbox: {
    groupLabel: string;
    option1Label: string;
    option2Label: string;
  };
  formRadio: {
    groupLabel: string;
    optionALabel: string;
    optionBLabel: string;
  };
};

const EDITOR_BLOCK_DEFAULTS_MESSAGES: Record<AppLocale, EditorBlockDefaultsMessages> = {
  en: {
    text: {
      defaultText: "New text",
    },
    list: {
      firstItemText: "List item 1",
    },
    button: {
      label: "Button",
    },
    form: {
      nameLabel: "Name",
      emailLabel: "Email",
      messageLabel: "Message",
      successMessage: "Your message has been sent successfully.",
      errorMessage: "An error occurred while submitting.",
    },
    formInput: {
      label: "Input field",
    },
    formSelect: {
      label: "Select field",
      option1Label: "Option 1",
      option2Label: "Option 2",
    },
    formCheckbox: {
      groupLabel: "Checkbox group",
      option1Label: "Check 1",
      option2Label: "Check 2",
    },
    formRadio: {
      groupLabel: "Radio group",
      optionALabel: "Option A",
      optionBLabel: "Option B",
    },
  },
  ko: {
    text: {
      defaultText: "새 텍스트",
    },
    list: {
      firstItemText: "리스트 아이템 1",
    },
    button: {
      label: "버튼",
    },
    form: {
      nameLabel: "이름",
      emailLabel: "이메일",
      messageLabel: "메시지",
      successMessage: "성공적으로 전송되었습니다.",
      errorMessage: "전송 중 오류가 발생했습니다.",
    },
    formInput: {
      label: "입력 필드",
    },
    formSelect: {
      label: "셀렉트 필드",
      option1Label: "옵션 1",
      option2Label: "옵션 2",
    },
    formCheckbox: {
      groupLabel: "체크박스 그룹",
      option1Label: "옵션 1",
      option2Label: "옵션 2",
    },
    formRadio: {
      groupLabel: "라디오 그룹",
      optionALabel: "옵션 A",
      optionBLabel: "옵션 B",
    },
  },
};

export function getEditorBlockDefaultsMessages(
  locale: AppLocale | null | undefined,
): EditorBlockDefaultsMessages {
  const key = (locale ?? DEFAULT_LOCALE) as AppLocale;
  return EDITOR_BLOCK_DEFAULTS_MESSAGES[key] ?? EDITOR_BLOCK_DEFAULTS_MESSAGES[DEFAULT_LOCALE];
}
