"use client";

import { CropEditSession } from "./CropEditSession";
import { InpaintingEditSession } from "./InpaintingEditSession";
import { OutpaintingEditSession } from "./OutpaintingEditSession";
import { SplitGridEditSession } from "./SplitGridEditSession";
import { AnnotationEditSession } from "./AnnotationEditSession";
import type { ImageEditSessionProps } from "./types";

export function ImageEditSession({
  tool,
  nodeId,
  imageRef,
  imageSource,
  dimensions,
  models,
  splitGridSelection,
  onClose,
}: ImageEditSessionProps) {
  if (!tool) return null;

  const commonProps = {
    nodeId,
    imageRef,
    imageSource,
    dimensions,
    onClose,
  };

  switch (tool) {
    case "crop":
      return <CropEditSession {...commonProps} title="裁剪" />;
    case "outpainting":
      return <OutpaintingEditSession {...commonProps} model={models.outpainting} />;
    case "inpainting":
      return <InpaintingEditSession {...commonProps} model={models.inpainting} />;
    case "splitGrid":
      return splitGridSelection ? <SplitGridEditSession {...commonProps} selection={splitGridSelection} /> : null;
    case "annotate":
      return <AnnotationEditSession {...commonProps} />;
    default:
      return null;
  }
}
