// API 요청 파라미터 타입
export interface PageDataRequest {
  game_alias: string;
  lang_code: string;
  page_url: string;
  q?: string;
  qc?: string;
}

// API 요청 헤더 타입
export interface PageDataRequestHeaders {
  "caller-Detail"?: string;
  "caller-ID"?: string;
  Authorization?: string;
}

// API 응답 데이터 타입
export interface PageDataResponse {
  code: number;
  message: string;
  value: PageDataValue;
}

// API 응답의 value 객체 타입
export interface PageDataValue {
  page_seq: number;
  page_type: number;
  page_name: string;
  page_name_en: string;
  page_ver: number;
  display_start_dt: string;
  lang_codes: string; // JSON string
  is_login_required: boolean;
  meta_tag_type: number;
  fit_page_height: boolean;
  use_top_btn: boolean;
  use_sns_btn: boolean;
  use_lnb: boolean;
  lnb_menus: PageDataLnbMenu[];
  templates: PageDataTemplate[];
  meta_tag: PageDataMetaTag;
}

// 메타 태그 타입
export interface PageDataMetaTag {
  x_desc: string;
  og_desc: string;
  x_image: string;
  x_title: string;
  og_image: string;
  og_title: string;
  page_desc: string;
  page_title: string;
}

// LNB 메뉴 타입
export interface PageDataLnbMenu {
  text_color_code_active: string;
  text_color_code_deactive: string;
  path_code: string;
  depth: number;
  sort_order: number;
  menu_name: string;
  target_type: number;
  page_ver_tmpl_name_en: string;
  tracking: string; // JSON string
}

// 템플릿 타입
export interface PageDataTemplate {
  tmpl_sort_order: number;
  page_ver_tmpl_name: string;
  page_ver_tmpl_name_en: string;
  template_code: string;
  template_type_code: string;
  template_category: string;
  template_name: string;
  template_sample_img_path: string;
  template_sample_zip_path: string;
  template_type_name: string;
  is_selectable_on_create: boolean;
  components: Record<string, PageDataComponent>;
}

// 컴포넌트 타입
export interface PageDataComponent {
  component_sort_order: number;
  component_type: string;
  set_count: number;
  component_name: string;
  is_required: boolean;
  has_operational_resource: boolean;
  min_count: number;
  max_count: number;
  component_id: string;
  operate_resources: PageDataOperateResource[];
  [key: string]: any; // Additional Properties
}

// 운영 리소스 타입
export interface PageDataOperateResource {
  seq: number;
  col: string;
  col2: string;
  col3: string;
  col4: string;
  col5: string;
  col6: string;
  col7: string;
  resource_control_type: number;
  resource_type: string;
  [key: string]: any; // Additional Properties
}

// API 에러 응답 타입
export interface PageDataErrorResponse {
  code: number;
  message: string;
  error?: string;
}

// API 응답 래퍼 타입 (성공/실패 통합)
export type PageDataApiResponse = PageDataResponse | PageDataErrorResponse;

// API 호출 옵션 타입
export interface PageDataApiOptions {
  gameAlias: string;
  langCode: string;
  pageUrl: string;
  q?: string;
  qc?: string;
  headers?: PageDataRequestHeaders;
  baseUrl?: string;
}

// API 상태 타입
export type PageDataApiStatus = "idle" | "loading" | "success" | "error";

// API 결과 타입 (상태와 데이터를 함께 관리)
export interface PageDataApiResult {
  status: PageDataApiStatus;
  data: PageDataResponse | null;
  error: string | null;
}

// 페이지 데이터 별칭 (기존 호환성)
export type pageData = PageDataValue;
