import * as THREE from "three";

export interface Trigger {
  uuid: string;
  name: string;
  type: string;
  bufferTime: number;
  isUsed: boolean;
}

export interface PointAction {
  uuid: string;
  name: string;
  type: "Inherit" | "Spawn" | "Despawn" | "Delay" | "Swap";
  objectType: string;
  material: string;
  delay: string | number;
  spawnInterval: string | number;
  isUsed: boolean;
  hitCount?: number;
}

export interface ProcessPoint {
  uuid: string; 
  position: number[];
  rotation: number[]; 
  actions: PointAction[]; 
  connections: {
    source: { modelUUID: string; pointUUID: string }; 
    targets: { modelUUID: string; pointUUID: string }[]; 
  };
  triggers?: Trigger[]; 
}
export interface ProcessPath {
  modeluuid: string;
  modelName: string;
  points: ProcessPoint[];
  pathPosition: number[];
  pathRotation: number[];
  speed: number;
  type: "Conveyor" | "Vehicle";
  isplaying: boolean
}

export interface ProcessData {
  id: string;
  paths: ProcessPath[];
  animationPath: { x: number; y: number; z: number }[];
  pointActions: PointAction[][];
  speed: number;
  customMaterials?: Record<string, THREE.Material>;
  renderAs?: "box" | "custom";
  pointTriggers: [];
}

export interface AnimationState {
  currentIndex: number;
  progress: number;
  isAnimating: boolean;
  speed: number;
  isDelaying: boolean;
  delayStartTime: number;
  currentDelayDuration: number;
  delayComplete: boolean;
  currentPathIndex: number;
}

export interface SpawnedObject {
  ref: React.RefObject<THREE.Group | THREE.Mesh>;
  state: AnimationState;
  visible: boolean;
  material: THREE.Material;
  spawnTime: number;
  currentMaterialType: string;
  position: THREE.Vector3;
}

export interface ProcessAnimationState {
  spawnedObjects: { [objectId: string]: SpawnedObject };
  nextSpawnTime: number;
  objectIdCounter: number;
  isProcessDelaying: boolean;
  processDelayStartTime: number;
  processDelayDuration: number;
  hasSpawnedZeroIntervalObject?: boolean;
}
