'use strict';

var localsHelper = require('./localsHelper.js');

const FEATURE_FLAG_NAMESPACE = 'hmpps-digital-prison-reporting';
const FEATURE_FLAG_KEYS = {
    SAVE_DEFAULTS: 'saveDefaultsEnabled',
    STREAMING_DOWNLOAD: 'streamingDownloadEnabled',
    BAR_CHARTS: 'barChartsEnabled',
    LINE_CHARTS: 'lineChartsEnabled',
    DONUT_CHARTS: 'donutChartsEnabled',
    SCORECARD_CHARTS: 'scorecardChartsEnabled',
    SCORECARD_GROUP_CHARTS: 'scorecardgroupChartsEnabled',
    MATRIX_TIMESERIES_CHARTS: 'matrixtimeseriesChartsEnabled',
    BAR_TIMESERIES_CHARTS: 'bartimeseriesChartsEnabled',
    LINE_TIMESERIES_CHARTS: 'linetimeseriesChartsEnabled',
};
const DASHBOARD_VISUALISATION_FEATURE_FLAGS = [
    FEATURE_FLAG_KEYS.BAR_CHARTS,
    FEATURE_FLAG_KEYS.LINE_CHARTS,
    FEATURE_FLAG_KEYS.DONUT_CHARTS,
    FEATURE_FLAG_KEYS.SCORECARD_CHARTS,
    FEATURE_FLAG_KEYS.SCORECARD_GROUP_CHARTS,
    FEATURE_FLAG_KEYS.MATRIX_TIMESERIES_CHARTS,
    FEATURE_FLAG_KEYS.BAR_TIMESERIES_CHARTS,
    FEATURE_FLAG_KEYS.LINE_TIMESERIES_CHARTS,
];
const FEATURE_FLAGS = [
    FEATURE_FLAG_KEYS.SAVE_DEFAULTS,
    FEATURE_FLAG_KEYS.STREAMING_DOWNLOAD,
    ...DASHBOARD_VISUALISATION_FEATURE_FLAGS,
];
const DEFAULT_FEATURE_FLAG_ENTITY_ID = 'anonymous';
const FEATURE_FLAG_FALLBACK_STATES = {
    [FEATURE_FLAG_KEYS.SAVE_DEFAULTS]: true,
    [FEATURE_FLAG_KEYS.STREAMING_DOWNLOAD]: false,
    [FEATURE_FLAG_KEYS.BAR_CHARTS]: false,
    [FEATURE_FLAG_KEYS.LINE_CHARTS]: false,
    [FEATURE_FLAG_KEYS.DONUT_CHARTS]: false,
    [FEATURE_FLAG_KEYS.SCORECARD_CHARTS]: false,
    [FEATURE_FLAG_KEYS.SCORECARD_GROUP_CHARTS]: false,
    [FEATURE_FLAG_KEYS.MATRIX_TIMESERIES_CHARTS]: false,
    [FEATURE_FLAG_KEYS.BAR_TIMESERIES_CHARTS]: false,
    [FEATURE_FLAG_KEYS.LINE_TIMESERIES_CHARTS]: false,
};
const toFeatureFlagEntityId = (entityId) => {
    if (!entityId || entityId.trim().length === 0) {
        return DEFAULT_FEATURE_FLAG_ENTITY_ID;
    }
    return entityId;
};
const createFeatureFlagEvaluationSubject = (entityId) => {
    return {
        entityId: toFeatureFlagEntityId(entityId),
        context: {},
    };
};
const getFeatureFlagEvaluationSubject = (res) => {
    const { dprUser } = localsHelper.default.getValues(res);
    return createFeatureFlagEvaluationSubject(dprUser.id);
};
const getFeatureFlagFallbackState = (flagKey) => {
    return FEATURE_FLAG_FALLBACK_STATES[flagKey];
};

exports.DASHBOARD_VISUALISATION_FEATURE_FLAGS = DASHBOARD_VISUALISATION_FEATURE_FLAGS;
exports.DEFAULT_FEATURE_FLAG_ENTITY_ID = DEFAULT_FEATURE_FLAG_ENTITY_ID;
exports.FEATURE_FLAGS = FEATURE_FLAGS;
exports.FEATURE_FLAG_KEYS = FEATURE_FLAG_KEYS;
exports.FEATURE_FLAG_NAMESPACE = FEATURE_FLAG_NAMESPACE;
exports.createFeatureFlagEvaluationSubject = createFeatureFlagEvaluationSubject;
exports.getFeatureFlagEvaluationSubject = getFeatureFlagEvaluationSubject;
exports.getFeatureFlagFallbackState = getFeatureFlagFallbackState;
//# sourceMappingURL=featureFlagsHelper.js.map
