import { getGranularityReferenceValue } from '../types/timeFrames';
/** Registry of reserved parameters. Add an entry here to expose a new system value. */
export const RESERVED_PARAMETERS = {
    date_zoom: {
        label: 'Date zoom',
        description: 'The selected date zoom granularity in lowercase (e.g. "week"). Empty when no date zoom is selected.',
        type: 'string',
        resolve: ({ dateZoom }) => dateZoom?.granularity
            ? getGranularityReferenceValue(dateZoom.granularity)
            : '',
    },
};
export const getReservedParameterNames = () => Object.keys(RESERVED_PARAMETERS);
export const isReservedParameterName = (name) => name in RESERVED_PARAMETERS;
/**
 * Reserved parameter definitions in the shared definition shape (without resolvers), for
 * merging into the available-parameter map and rendering in the parameters UI.
 */
export const getReservedParameterDefinitions = () => Object.entries(RESERVED_PARAMETERS).reduce((acc, [name, { resolve, ...definition }]) => ({
    ...acc,
    [name]: definition,
}), {});
/**
 * Resolve every reserved parameter to its value for the given query context.
 */
export const resolveReservedParameterValues = (context) => Object.entries(RESERVED_PARAMETERS).reduce((acc, [name, { resolve }]) => ({
    ...acc,
    [name]: resolve(context),
}), {});
/** Reserved names shadowed by a same-named user parameter (used to surface the override). */
export const getShadowedReservedNames = (userParameterNames) => {
    const userNames = new Set(userParameterNames);
    return getReservedParameterNames().filter((name) => userNames.has(name));
};
/** Append reserved names not already taken by a user parameter (deduped, user wins). */
export const mergeReservedNames = (userParameterNames) => {
    const userNames = new Set(userParameterNames);
    return [
        ...userParameterNames,
        ...getReservedParameterNames().filter((name) => !userNames.has(name)),
    ];
};
/**
 * Merge reserved definitions under user definitions; a user definition of the same name
 * wins (shadows the reserved entry).
 */
export const mergeReservedDefinitions = (userDefinitions) => ({
    ...getReservedParameterDefinitions(),
    ...(userDefinitions ?? {}),
});
/**
 * Merge resolved reserved values under user values; a user value of the same name wins
 * (shadows the reserved value).
 */
export const mergeReservedValues = (userValues, reservedValues) => ({
    ...reservedValues,
    ...(userValues ?? {}),
});
//# sourceMappingURL=reservedParameters.js.map