export function getDataType(data) {
    if (Array.isArray(data)) {
        if (data.length) {
            const item = data[0];
            if (Array.isArray(item)) {
                return 'array-matrix';
            }
            return 'array-obj';
        }
        return 'array-empty';
    }
    if (typeof data === 'object') {
        return 'object';
    }
    return 'unknown';
}
export function parseJsonStr(str) {
    let jsonObj = null;
    try {
        jsonObj = JSON.parse(str);
    }
    catch (e) {
        jsonObj = null;
    }
    return jsonObj;
}
export function isPath(str) {
    return str.startsWith('.');
}
export function getResByPath(data, path) {
    const pathArr = path.split('.');
    pathArr.shift();
    let lastPath = '';
    const getCurPathRes = (target, deep) => {
        const curPath = pathArr[deep];
        if (curPath === '*') {
            if (!Array.isArray(target)) {
                console.error(`wecharts: The data path is not compatible with the graph data, ${lastPath}.* is not a Array.`);
                return null;
            }
            lastPath = curPath;
            return target.map((item) => getCurPathRes(item, deep + 1));
        }
        if (deep < pathArr.length - 1) {
            if (!target[curPath]) {
                console.error(`wecharts: The data path is not compatible with the graph data, ${lastPath}.${curPath} is undefined.`);
                return null;
            }
            lastPath = curPath;
            return getCurPathRes(target[curPath], deep + 1);
        }
        return target[curPath];
    };
    return getCurPathRes(data, 0);
}
//# sourceMappingURL=utils.js.map