import { PreviewService, hookWidget, hookPreview } from '@c8y/ngx-components';
import { WidgetAssetSelectorComponent, hookWidgetConfig } from '@c8y/ngx-components/context-dashboard';
import * as i0 from '@angular/core';
import { inject, Injectable } from '@angular/core';
import { gettext } from '@c8y/ngx-components/gettext';
import { defaultWidgetIds } from '@c8y/ngx-components/widgets/definitions';
import { importConfigWithDevice, exportConfigWithDevice } from '@c8y/ngx-components/widgets/import-export-config';
import { map } from 'rxjs';

class AssetTableWidgetFactory {
    constructor() {
        this.previewService = inject(PreviewService);
        this.baseWidgetDefinition = {
            id: defaultWidgetIds.ASSET_TABLE,
            label: gettext('Asset table'),
            description: gettext('Displays a table of assets with configurable columns and filters.'),
            loadComponent: () => import('@c8y/ngx-components/widgets/implementations/asset-table').then(m => m.AssetTableWidgetViewComponent),
            previewImage: 'c8y-style-assets/asset-table-pr.png',
            data: {
                settings: {
                    schema: () => import('c8y-schema-loader?interfaceName=AssetTableWidgetConfig&type=widget-config!@c8y/ngx-components/widgets/implementations/asset-table'),
                    export: exportConfigWithDevice,
                    import: importConfigWithDevice,
                    noNewWidgets: false,
                    widgetDefaults: {
                        _width: 8,
                        _height: 6
                    },
                    ng1: {
                        options: {
                            noDeviceTarget: true,
                            groupsSelectable: true
                        }
                    }
                },
                displaySettings: {
                    globalTimeContext: true,
                    globalAutoRefreshContext: true
                }
            }
        };
    }
    get() {
        return this.previewService.getState$('ui.asset-table.v2').pipe(map(state => {
            if (state) {
                return [this.baseWidgetDefinition];
            }
            return [];
        }));
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AssetTableWidgetFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AssetTableWidgetFactory, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AssetTableWidgetFactory, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root'
                }]
        }] });

class AssetTableConfigFactory {
    constructor() {
        this.betaPreviewService = inject(PreviewService);
        this.baseWidgetConfigDefinition = [
            {
                widgetId: defaultWidgetIds.ASSET_TABLE,
                label: gettext('Asset selection'),
                loadComponent: () => Promise.resolve(WidgetAssetSelectorComponent),
                priority: 100,
                initialState: {
                    isRequired: false,
                    groupsSelectable: true
                }
            },
            {
                widgetId: defaultWidgetIds.ASSET_TABLE,
                label: gettext('Asset properties'),
                loadComponent: () => import('@c8y/ngx-components/widgets/implementations/asset-table').then(m => m.AssetTableGridSettingsComponent),
                priority: 50,
                expanded: true
            },
            {
                widgetId: defaultWidgetIds.ASSET_TABLE,
                label: gettext('Settings'),
                loadComponent: () => import('@c8y/ngx-components/widgets/implementations/asset-table').then(m => m.AssetTableWidgetConfigComponent),
                priority: 0,
                expanded: true
            }
        ];
    }
    get() {
        return this.betaPreviewService.getState$('ui.asset-table.v2').pipe(map(state => {
            if (state) {
                return this.baseWidgetConfigDefinition;
            }
            return [];
        }));
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AssetTableConfigFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AssetTableConfigFactory, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AssetTableConfigFactory, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root'
                }]
        }] });

const assetTableWidgetProviders = [
    hookWidget(AssetTableWidgetFactory),
    hookWidgetConfig(AssetTableConfigFactory),
    hookPreview({
        key: 'ui.asset-table.v2',
        label: gettext('Asset table v2'),
        description: () => import('@c8y/style/markdown-files/asset-table-widget-preview.md').then(m => m.default),
        settings: {
            reload: true
        }
    })
];

/**
 * Generated bundle index. Do not edit.
 */

export { assetTableWidgetProviders };
//# sourceMappingURL=c8y-ngx-components-widgets-definitions-asset-table.mjs.map
