/**
 * @description
 * 보고서 탭의 도메인 인터페이스 모음. 유류 확산 보고서 전체 데이터 모델
 * (OilSpillReportData)과 템플릿·카테고리 정의(TemplateType/ReportSection/
 * CategoryDef), 그리고 백엔드 템플릿·카테고리·보고서 API 응답(ApiTemplate/
 * ApiCategory/ApiReport*)을 정의한다.
 *
 * @author dnlee (dnlee@gcsc.co.kr)
 */
import type {
  ReportType,
  ReportStatus,
  Jurisdiction,
  AnalysisCategory,
} from '@/types/reports/ReportsType';

/** 유출유 보고서 — 보고서 전체 데이터 모델 (사고·조석·기상·확산·민감자원·방제 포함) */
export interface OilSpillReportData {
  id: string;
  title: string;
  createdAt: string;
  updatedAt: string;
  author: string;
  reportType: ReportType;
  analysisCategory: AnalysisCategory;
  jurisdiction: Jurisdiction;
  status: ReportStatus;
  incident: {
    name: string;
    writeTime: string;
    shipName: string;
    agent: string;
    location: string;
    lat: string;
    lon: string;
    occurTime: string;
    accidentType: string;
    pollutant: string;
    spillAmount: string;
    depth: string;
    seabed: string;
  };
  tide: {
    date: string;
    tideType: string;
    lowTide1: string;
    highTide1: string;
    lowTide2: string;
    highTide2: string;
  }[];
  weather: {
    time: string;
    sunrise: string;
    sunset: string;
    windDir: string;
    windSpeed: string;
    currentDir: string;
    currentSpeed: string;
    waveHeight: string;
  }[];
  spread: {
    elapsed: string;
    weathered: string;
    seaRemain: string;
    coastAttach: string;
    area: string;
  }[];
  analysis: string;
  aquaculture: { type: string; area: string; distance: string }[];
  beaches: { name: string; distance: string }[];
  markets: { name: string; distance: string }[];
  esi: { code: string; type: string; length: string }[];
  species: { category: string; species: string }[];
  habitat: { type: string; area: string }[];
  sensitivity: { level: string; area: string; color: string }[];
  vessels: {
    name: string;
    org: string;
    dist: string;
    speed: string;
    ton: string;
    collectorType: string;
    collectorCap: string;
    boomType: string;
    boomLength: string;
  }[];
  etcEquipment: string;
  recovery: { shipName: string; period: string }[];
  result: {
    spillTotal: string;
    weatheredTotal: string;
    recoveredTotal: string;
    seaRemainTotal: string;
    coastAttachTotal: string;
  };
  capturedMapImage?: string;
  step3MapImage?: string;
  step6MapImage?: string;
  hasMapCapture?: boolean;
  acdntSn?: number;
  sensitiveMapImage?: string;
  sensitivityMapImage?: string;
}

/** 보고서 템플릿 — 템플릿 정의 (id·아이콘·라벨·섹션·필드 스키마) */
export interface TemplateType {
  id: ReportType;
  icon: string;
  label: string;
  desc: string;
  sections: {
    title: string;
    fields: {
      key: string;
      label: string;
      type: 'text' | 'textarea' | 'date' | 'checkbox-group';
      options?: string[];
    }[];
  }[];
}

/** 보고서 생성기 — 카테고리 내 섹션 정의 (체크박스 UI) */
export interface ReportSection {
  id: string;
  icon: string;
  title: string;
  desc: string;
  checked: boolean;
}

/** 보고서 생성기 — 카테고리 정의 (유출유/HNS/구난 3종) */
export interface CategoryDef {
  icon: string;
  label: string;
  desc: string;
  color: string;
  borderColor: string;
  bgActive: string;
  reportName: string;
  templates: { icon: string; label: string }[];
  sections: ReportSection[];
}

/** 보고서 템플릿 API — 템플릿 섹션 응답 */
export interface ApiTemplateSection {
  sectCd: string;
  sectNm: string;
  fieldDef: { key: string; label: string; type: string; options?: string[] }[];
  sortOrd: number;
}

/** 보고서 템플릿 API — 템플릿 응답 (섹션 배열 포함) */
export interface ApiTemplate {
  tmplSn: number;
  tmplCd: string;
  tmplNm: string;
  icon: string;
  tmplDc: string;
  sections: ApiTemplateSection[];
}

/** 보고서 카테고리 API — 카테고리 내 템플릿 요약 */
export interface ApiCategoryTemplate {
  icon: string;
  label: string;
}

/** 보고서 카테고리 API — 카테고리 내 섹션 정의 */
export interface ApiCategorySection {
  sectCd: string;
  sectNm: string;
  icon: string;
  sectDc: string;
  dfltYn: string;
  sortOrd: number;
}

/** 보고서 카테고리 API — 카테고리 상세 응답 (템플릿·섹션 배열 포함) */
export interface ApiCategory {
  ctgrSn: number;
  ctgrCd: string;
  ctgrNm: string;
  icon: string;
  ctgrDc: string;
  colorCd: string;
  borderColor: string;
  bgActive: string;
  reportNm: string;
  templates: ApiCategoryTemplate[];
  sections: ApiCategorySection[];
}

/** 보고서 API — 보고서 목록 아이템 응답 */
export interface ApiReportListItem {
  reportSn: number;
  tmplCd: string | null;
  tmplNm: string | null;
  ctgrCd: string | null;
  ctgrNm: string | null;
  title: string;
  jrsdCd: string | null;
  sttsCd: string;
  authorId: string;
  authorName: string;
  acdntSn?: number | null;
  regDtm: string;
  mdfcnDtm: string | null;
  hasMapCapture?: boolean;
}

/** 보고서 API — 보고서 섹션 데이터 응답 (데이터 페이로드 unknown) */
export interface ApiReportSectionData {
  sectCd: string;
  includeYn: string;
  sectData: unknown;
  sortOrd: number;
}

/** 보고서 API — 보고서 상세 응답 (목록 + 섹션 + 지도 캡처 이미지) */
export interface ApiReportDetail extends ApiReportListItem {
  acdntSn: number | null;
  sections: ApiReportSectionData[];
  step3MapImg?: string | null;
  step6MapImg?: string | null;
}

/** 보고서 API — 보고서 목록 응답 래퍼 */
export interface ApiReportListResponse {
  items: ApiReportListItem[];
  totalCount: number;
  page: number;
  size: number;
}
