"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.normalizeViewsResponse = normalizeViewsResponse;
/** 将业务接口或 `tableView` 原始数据的多层包结构规整为 `ViewsData`（直连读路径复用） */
function normalizeViewsResponse(raw) {
    const empty = { views: {}, viewOrder: [] };
    if (raw == null || typeof raw !== 'object') {
        return empty;
    }
    let obj = raw;
    if ('data' in obj && obj.data && typeof obj.data === 'object') {
        const inner = obj.data;
        if ('views' in inner) {
            obj = inner;
        }
    }
    if (!('views' in obj) || typeof obj.views !== 'object' || obj.views === null) {
        return empty;
    }
    /** 与魔方 / `getTableView` 对齐：除 `views` / `viewOrder` 外原样透传（如 customFields 及后续扩展字段），避免源码路径丢配置 */
    const normalized = {
        ...obj,
        views: obj.views,
        viewOrder: Array.isArray(obj.viewOrder) ? obj.viewOrder : [],
    };
    return normalized;
}
