import { __rest } from "tslib";
/**
 * Util to convert a metric into editor values consumable by the configuration editor
 * @param metric - IMetric metric
 * @param displayConfig - display configuration for the metric
 * @returns
 */
export function metricToEditor(metric, displayConfig) {
    const { allowExpressionSet, expressionSet, fieldType, itemId } = displayConfig, 
    // statistic,
    config = __rest(displayConfig, ["allowExpressionSet", "expressionSet", "fieldType", "itemId"]);
    let editor = Object.assign({}, config);
    if (metric && metric.source) {
        const metricType = metric.source.type || "";
        switch (metricType) {
            case "service-query":
                editor = Object.assign(Object.assign({ type: "dynamic", dynamicMetric: Object.assign(Object.assign({}, metric.source), { itemId,
                        expressionSet,
                        allowExpressionSet,
                        fieldType, sourceLink: displayConfig.sourceLink, sourceTitle: displayConfig.sourceTitle }) }, editor), { sourceLink: undefined, sourceTitle: undefined });
                break;
            case "static-value":
                editor = Object.assign({ type: "static", value: metric.source.value, valueType: metric.source.valueType }, editor);
                break;
        }
    }
    return editor;
}
//# sourceMappingURL=metricToEditor.js.map