// (C) 2026 GoodData Corporation
import { areObjRefsEqual } from "@gooddata/sdk-model";
const addParameter = (state, action) => {
    const { parameter, workspaceDefault } = action.payload;
    if (state.parameters.some((entry) => areObjRefsEqual(entry.parameter.ref, parameter.ref))) {
        return;
    }
    state.parameters.push({
        parameter,
        runtimeOverride: parameter.value ?? workspaceDefault,
    });
};
const setParameterRuntimeValue = (state, action) => {
    const { ref, value } = action.payload;
    const entry = state.parameters.find((item) => areObjRefsEqual(item.parameter.ref, ref));
    if (entry) {
        entry.runtimeOverride = value;
    }
};
const removeParameter = (state, action) => {
    state.parameters = state.parameters.filter((entry) => !areObjRefsEqual(entry.parameter.ref, action.payload.ref));
};
/**
 * Replace the entire entry list. Used when (re-)loading a persisted dashboard.
 *
 * @alpha
 */
const setParameterEntries = (state, action) => {
    state.parameters = action.payload;
};
export const parametersReducers = {
    addParameter,
    setParameterRuntimeValue,
    removeParameter,
    setParameterEntries,
};
//# sourceMappingURL=parametersReducers.js.map