import React, { useMemo } from 'react';
import { map, pipe, sortBy } from 'ramda';
import { getLastUriPart } from '@reltio/mdm-sdk';
import { MultiValueSelector } from '../MultiValueSelector';
import { useMdmMetadata } from '../contexts/MdmModuleContext';
export var SourceSystemsSelector = function (_a) {
    var values = _a.values, onChange = _a.onChange, TextFieldProps = _a.TextFieldProps, fullWidth = _a.fullWidth;
    var metadata = useMdmMetadata();
    var options = useMemo(function () {
        return pipe(sortBy(function (option) { return option.label; }), map(function (_a) {
            var label = _a.label, uri = _a.uri;
            return ({ label: label, value: getLastUriPart(uri) });
        }))(metadata.sources);
    }, [metadata.sources]);
    return (React.createElement(MultiValueSelector, { values: values, onChange: onChange, options: options, TextFieldProps: TextFieldProps, fullWidth: fullWidth }));
};
SourceSystemsSelector.displayName = 'SourceSystemsSelector';
