import { gettext } from '@c8y/ngx-components/gettext';
import { DynamicComponentErrorStrategy, DynamicDatapointsResolver, hookWidget } from '@c8y/ngx-components';
import { defaultWidgetIds } from '@c8y/ngx-components/widgets/definitions';
import { importConfigWithTargets, exportConfigWithTargets } from '@c8y/ngx-components/widgets/import-export-config';
import { hookWidgetConfig } from '@c8y/ngx-components/context-dashboard';
import { PRESET_NAME } from '@c8y/ngx-components/global-context';

const KPI_FORM_OPTIONS = {
    showRedRange: true,
    showYellowRange: true
};

const kpiWidgetDefinition = {
    id: defaultWidgetIds.KPI,
    label: gettext('KPI'),
    description: gettext('Displays the last measurement value of a device.'),
    loadComponent: () => import('@c8y/ngx-components/widgets/implementations/kpi').then(m => m.KpiWidgetViewComponent),
    loadConfigComponent: () => import('@c8y/ngx-components/widgets/implementations/kpi').then(m => m.KpiWidgetConfigComponent),
    previewImage: 'c8y-style-assets/kpi-widget.png',
    resolve: {
        datapoints: DynamicDatapointsResolver
    },
    errorStrategy: DynamicComponentErrorStrategy.OVERLAY_ERROR,
    data: {
        schema: () => import('c8y-schema-loader?interfaceName=KpiWidgetConfig&type=widget-config!@c8y/ngx-components/widgets/implementations/kpi'),
        export: exportConfigWithTargets,
        import: importConfigWithTargets,
        controls: PRESET_NAME.KPI_CONFIG,
        settings: {
            noNewWidgets: false,
            widgetDefaults: {
                _width: 4,
                _height: 2
            },
            ng1: {
                options: {
                    noDeviceTarget: true,
                    groupsSelectable: false
                }
            }
        }
    }
};
const kpiWidgetProviders = [
    hookWidget(kpiWidgetDefinition),
    hookWidgetConfig({
        widgetId: defaultWidgetIds.KPI,
        priority: 10,
        label: gettext('Time context'),
        initialState: {
            controls: PRESET_NAME.KPI_CONFIG
        },
        loadComponent: () => import('@c8y/ngx-components/context-dashboard').then(m => m.GlobalContextSectionComponent)
    }),
    hookWidgetConfig({
        widgetId: defaultWidgetIds.KPI,
        label: gettext('Data point selection'),
        loadComponent: () => import('@c8y/ngx-components/datapoint-selector').then(m => m.WidgetDatapointsSelectorComponent),
        initialState: {
            minActiveCount: 1,
            maxActiveCount: 1,
            defaultFormOptions: KPI_FORM_OPTIONS
        },
        expanded: true,
        priority: 100
    })
];

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

export { kpiWidgetDefinition, kpiWidgetProviders };
//# sourceMappingURL=c8y-ngx-components-widgets-definitions-kpi.mjs.map
