interface AssetEventSchema {
    modelUuid: string;
    modelName: string;
    position: [number, number, number];
    rotation: [number, number, number];
    state: "idle" | "running" | "stopped" | "disabled" | "error";
}

interface TriggerSchema {
    triggerUuid: string;
    triggerName: string;
    triggerType: "onComplete" | "onStart" | "onStop" | "delay" | "onError";
    delay: number;
    triggeredAsset: {
        triggeredModel: { modelName: string, modelUuid: string };
        triggeredPoint: { pointName: string, pointUuid: string };
        triggeredAction: { actionName: string, actionUuid: string };
    } | null;
}

interface ConveyorPointSchema {
    uuid: string;
    position: [number, number, number];
    rotation: [number, number, number];
    action: {
        actionUuid: string;
        actionName: string;
        actionType: "default" | "spawn" | "swap" | "delay" | "despawn";
        material: string;
        delay: number | "inherit";
        spawnInterval: number | "inherit";
        spawnCount: number | "inherit";
        triggers: TriggerSchema[];
    };
}

interface VehiclePointSchema {
    uuid: string;
    position: [number, number, number];
    rotation: [number, number, number];
    action: {
        actionUuid: string;
        actionName: string;
        actionType: "travel";
        unLoadDuration: number;
        loadCapacity: number;
        pickUpPoint: { x: number; y: number, z: number } | null;
        unLoadPoint: { x: number; y: number, z: number } | null;
        triggers: TriggerSchema[];
    };
}

interface RoboticArmPointSchema {
    uuid: string;
    position: [number, number, number];
    rotation: [number, number, number];
    actions: {
        actionUuid: string;
        actionName: string;
        actionType: "pickAndPlace";
        process: { startPoint: [number, number, number] | null; endPoint: [number, number, number] | null; };
        triggers: TriggerSchema[];
    }[];
}

interface MachinePointSchema {
    uuid: string;
    position: [number, number, number];
    rotation: [number, number, number];
    action: {
        actionUuid: string;
        actionName: string;
        actionType: "process";
        processTime: number;
        swapMaterial: string;
        triggers: TriggerSchema[];
    };
}

interface StoragePointSchema {
    uuid: string;
    position: [number, number, number];
    rotation: [number, number, number];
    action: {
        actionUuid: string;
        actionName: string;
        actionType: "store";
        materials: { materialName: string; materialId: string; }[];
        storageCapacity: number;
    };
}

interface ConveyorEventSchema extends AssetEventSchema {
    type: "transfer";
    speed: number;
    points: ConveyorPointSchema[];
}

interface VehicleEventSchema extends AssetEventSchema {
    type: "vehicle";
    speed: number;
    point: VehiclePointSchema;
}

interface RoboticArmEventSchema extends AssetEventSchema {
    type: "roboticArm";
    speed: number;
    point: RoboticArmPointSchema;
}

interface MachineEventSchema extends AssetEventSchema {
    type: "machine";
    point: MachinePointSchema;
}

interface StorageEventSchema extends AssetEventSchema {
    type: "storageUnit";
    point: StoragePointSchema;
}

type PointsScheme = ConveyorPointSchema | VehiclePointSchema | RoboticArmPointSchema | MachinePointSchema | StoragePointSchema;

type EventsSchema = ConveyorEventSchema | VehicleEventSchema | RoboticArmEventSchema | MachineEventSchema | StorageEventSchema;

type productsSchema = {
    productName: string;
    productId: string;
    eventDatas: EventsSchema[];
}[]


interface ConveyorStatus extends ConveyorEventSchema {
    productId: string;
    isActive: boolean;
    idleTime: number;
    activeTime: number;
    
}

interface MachineStatus extends MachineEventSchema {
    productId: string;
    isActive: boolean;
    idleTime: number;
    activeTime: number;
}

interface ArmBotStatus extends RoboticArmEventSchema {
    productId: string;
    isActive: boolean;
    idleTime: number;
    activeTime: number;
    currentAction?: {
        actionUuid: string;
        actionName: string;
    };
}

interface VehicleStatus extends VehicleEventSchema {
    productId: string;
    isActive: boolean;
    idleTime: number;
    activeTime: number;
    currentLoad: number;
    distanceTraveled: number;
}

interface StorageUnitStatus extends StorageEventSchema {
    productId: string;
    isActive: boolean;
    idleTime: number;
    activeTime: number;
    currentLoad: number;
}

interface MaterialSchema {
    materialId: string;
    materialName: string;
    materialType: string;
    isActive: boolean;
    startTime?: string;
    endTime?: string;
    cost?: number;
    weight?: number;
}

type MaterialsSchema = MaterialSchema[];