import { jsx as _jsx } from "@emotion/react/jsx-runtime";
import { FileOutlined } from '@ant-design/icons';
import { getIdByPath } from '../../../../../utils/get-id-by-path';
const parseActor = (actor, path, parent) => {
    var _a, _b;
    const isLeaf = !((_a = actor === null || actor === void 0 ? void 0 : actor.children) === null || _a === void 0 ? void 0 : _a.length);
    const actorPath = path.concat(`id:${actor.id}`);
    const node = {
        key: actor.id,
        title: actor.name,
        path: actorPath,
        parent,
        icon: _jsx(FileOutlined, {}),
        isLeaf,
    };
    if (!isLeaf) {
        const childPath = actorPath.concat('children');
        node.children = (_b = actor.children) === null || _b === void 0 ? void 0 : _b.map((child) => parseActor(child, childPath, node));
    }
    return node;
};
export const parseScenes = (scenes, inactiveSelectedSceneId) => scenes.map((scene) => {
    const node = {
        key: scene.id,
        title: scene.name,
        path: ['scenes', `id:${scene.id}`],
        className: inactiveSelectedSceneId === scene.id ? 'scenes-tree__scene_inactive' : undefined,
    };
    node.children = scene.actors.map((actor) => parseActor(actor, ['scenes', `id:${scene.id}`, 'actors'], node));
    return node;
});
export const getInspectedKey = (path) => {
    if (!path || path[0] !== 'scenes') {
        return void '';
    }
    return getIdByPath(path);
};
export const getSelectedPaths = (paths) => paths
    .filter((path) => path[0] === 'scenes');
