"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DataSetModule = void 0;
const tslib_1 = require("tslib");
const AdaptableModuleBase_1 = require("./AdaptableModuleBase");
const ModuleConstants = tslib_1.__importStar(require("../Utilities/Constants/ModuleConstants"));
const DataSetStatusPanelPopover_1 = require("../View/DataSet/DataSetStatusPanelPopover");
const Uuid_1 = require("../AdaptableState/Uuid");
const DataSetSelector_1 = require("../View/DataSet/DataSetSelector");
const getObjectTagsViewItems_1 = require("../Utilities/getObjectTagsViewItems");
class DataSetModule extends AdaptableModuleBase_1.AdaptableModuleBase {
    constructor(api) {
        super(ModuleConstants.DataSetModuleId, ModuleConstants.DataSetFriendlyName, 'data-set', 'DataSetPopup', 'Update the entire data source in AdapTable using pre-populated data sets', api);
    }
    onAdaptableReady() {
        this.api.dataSetApi.getDataSets().forEach((ds) => {
            if (!ds.Uuid) {
                ds.Uuid = (0, Uuid_1.createUuid)();
            }
        });
    }
    getModuleAdaptableObjects() {
        return this.api.optionsApi.getDataSetOptions()?.dataSets ?? [];
    }
    hasNamedQueryReferences() {
        return false;
    }
    toView(dataSet) {
        return {
            items: [
                {
                    name: 'Settings',
                    label: 'Name',
                    values: [dataSet.name],
                },
                {
                    name: 'Settings',
                    label: 'Description',
                    values: [dataSet.description ?? 'Not Specified'],
                },
                (0, getObjectTagsViewItems_1.getObjectTagsViewItems)(dataSet, this.api),
            ],
            abObject: dataSet,
        };
    }
    toViewAll() {
        return this.getModuleAdaptableObjects().map((dataSet) => this.toView(dataSet));
    }
    getViewProperties() {
        return {
            actions: [DataSetSelector_1.DataSetSelector],
            emptyView: 'No DataSets are provided',
            getStatusBarPanelProps: () => {
                const content = this.api.dataSetApi.getCurrentDataSet()?.name ?? this.moduleInfo.FriendlyName;
                return {
                    content: content,
                    popover: DataSetStatusPanelPopover_1.DataSetStatusPanelPopover,
                };
            },
        };
    }
}
exports.DataSetModule = DataSetModule;
