"use client";

import { createComponentDefinition } from "../../utils/createComponentDefinition";
import { ComponentCategory } from "@/types/component";
import { TitleWrapper } from "./TitleComponent";
import { InvTitleConfigPanel } from "./InvTitleConfigPanel";
import type { TitleConfig } from "./types";

/**
 * Title — 통합 제목/텍스트 컴포넌트 정의 (2026-04-11, Phase A-2)
 *
 * 흡수 대상:
 *   - v2-text-display (DISPLAY, withContainerQuery 적용)
 *   - text-display    (legacy, 완전 중복)
 *
 * 변형:
 *   - variant: h1~h6 | body | caption (시맨틱 프리셋)
 *   - fontSize / fontWeight / color / textAlign 개별 override
 *   - truncate (말줄임)
 *
 * 관련 문서:
 *   notes/gbpark/2026-04-11-component-unification-plan.md §3.7
 */

const DEFAULT_CONFIG: Partial<TitleConfig> = {
  text: "텍스트를 입력하세요",
  fontSize: "14px",
  fontWeight: "normal",
  color: "#212121",
  textAlign: "left",
};

export const TitleDefinition = createComponentDefinition({
  id: "title",
  name: "제목/텍스트",
  name_eng: "Title",
  description:
    "제목/본문/캡션 통합 텍스트 컴포넌트. variant 프리셋 + 개별 스타일",
  category: ComponentCategory.DISPLAY,
  web_type: "text",
  component: TitleWrapper,
  default_config: DEFAULT_CONFIG as Record<string, any>,
  default_size: { width: 200, height: 28 },
  config_panel: InvTitleConfigPanel,
  icon: "Type",
  tags: ["제목", "텍스트", "title", "text", "label", "heading"],
  version: "2.0.0",
  author: "INVYONE",
  documentation:
    "notes/gbpark/2026-04-11-component-unification-plan.md#37-title",
});

export type { TitleConfig } from "./types";
export { TitleComponent, TitleWrapper } from "./TitleComponent";
export { InvTitleConfigPanel } from "./InvTitleConfigPanel";
