/**
 * Copyright (c) 2020-present, Goldman Sachs
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import { ValueSpecification, observe_ValueSpecification, observe_GenericTypeReference, observe_PackageableElementReference, observe_VariableExpression, observe_GraphFetchTree, } from '@finos/legend-graph';
import { addUniqueEntry, deleteEntry } from '@finos/legend-shared';
import { action } from 'mobx';
export const valueSpecification_setGenericType = action((target, val) => {
    target.genericType = val ? observe_GenericTypeReference(val) : undefined;
});
export const valueSpecification_setMultiplicity = action((target, val) => {
    target.multiplicity = val;
});
export const simpleFunctionExpression_setFunc = action((target, val) => {
    target.func = val ? observe_PackageableElementReference(val) : undefined;
});
export const functionExpression_setParametersValues = action((target, values, context) => {
    target.parametersValues = values.map((val) => observe_ValueSpecification(val, context));
});
export const functionExpression_setParameterValue = action((target, val, idx, context) => {
    target.parametersValues[idx] = observe_ValueSpecification(val, context);
});
export const functionExpression_addParameterValue = action((target, val, context) => {
    target.parametersValues.push(observe_ValueSpecification(val, context));
});
export const propertyExpression_setFunc = action((target, val) => {
    target.func = val;
});
export const variableExpression_setName = action((target, val) => {
    target.name = val;
});
export const collectionInstanceValue_setValues = action((target, values, observerContext) => {
    target.values = values.map((val) => observe_ValueSpecification(val, observerContext));
});
export const instanceValue_setValue = action((target, val, idx, observerContext) => {
    target.values[idx] =
        val instanceof ValueSpecification
            ? observe_ValueSpecification(val, observerContext)
            : val;
});
export const instanceValue_setValues = action((target, values, observerContext) => {
    target.values = values.map((val) => val instanceof ValueSpecification
        ? observe_ValueSpecification(val, observerContext)
        : val);
});
export const graphFetchTree_addSubTree = action((target, val, observerContext) => {
    addUniqueEntry(target.subTrees, observe_GraphFetchTree(val, observerContext));
});
export const graphFetchTree_removeSubTree = action((target, val) => {
    deleteEntry(target.subTrees, val);
});
export const lambdaFunction_setExpressionSequence = action((target, val, observerContext) => {
    target.expressionSequence = val.map((v) => observe_ValueSpecification(v, observerContext));
});
export const lambdaFunction_setExpression = action((target, val, idx, observerContext) => {
    target.expressionSequence[idx] = observe_ValueSpecification(val, observerContext);
});
export const functionType_setParameters = action((target, val) => {
    target.parameters = val.map((v) => observe_VariableExpression(v));
});
//# sourceMappingURL=ValueSpecificationModifierHelper.js.map