import * as Types from "../../../../../types/world/worldTypes";

export default function arrayLineToObject(array: Types.Line) {
    if (!Array.isArray(array)) {
        return {};
    }

    // Extract common properties from the first point
    const commonLayer = array[0][2];
    const commonType = array[0][3];

    // Map points into a structured format
    const line = array.map(([position, uuid]) => ({
        position,
        uuid,
    }));

    // Create the final structured object
    return {
        layer: commonLayer,
        type: commonType,
        line,
    };
}