import { AdaptableModuleBase } from './AdaptableModuleBase';
import * as ModuleConstants from '../Utilities/Constants/ModuleConstants';
import { DataSetStatusPanelPopover } from '../View/DataSet/DataSetStatusPanelPopover';
import { createUuid } from '../AdaptableState/Uuid';
import { DataSetSelector } from '../View/DataSet/DataSetSelector';
import { getObjectTagsViewItems } from '../Utilities/getObjectTagsViewItems';
export class DataSetModule extends 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 = 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'],
                },
                getObjectTagsViewItems(dataSet, this.api),
            ],
            abObject: dataSet,
        };
    }
    toViewAll() {
        return this.getModuleAdaptableObjects().map((dataSet) => this.toView(dataSet));
    }
    getViewProperties() {
        return {
            actions: [DataSetSelector],
            emptyView: 'No DataSets are provided',
            getStatusBarPanelProps: () => {
                const content = this.api.dataSetApi.getCurrentDataSet()?.name ?? this.moduleInfo.FriendlyName;
                return {
                    content: content,
                    popover: DataSetStatusPanelPopover,
                };
            },
        };
    }
}
