import { jsx as _jsx } from "react/jsx-runtime";
import { translate } from '@stack-spot/portal-translate';
import { useConnectionInterfaceConfig } from '../ConnectionInterface.js';
import { RawSelectField } from './RawSelectField.js';
import { useRequiredConnectionOptions } from './use-required-connection-options.js';
export const RequiredConnectionField = (props) => {
    const { remote, local, isLoading } = useRequiredConnectionOptions(props.variable.config.metadata?.connectionInterfaceType);
    const { onImportPlugin } = useConnectionInterfaceConfig();
    const t = translate(dictionary);
    const renderLabel = (option) => remote.includes(option) ? option : `${option} (${t.new})`;
    return _jsx(RawSelectField, { ...props, options: [...local, ...remote], isLoading: isLoading, renderLabel: renderLabel, actions: onImportPlugin ? [{
                label: t.import,
                onSelect: onImportPlugin,
            }] : undefined });
};
const dictionary = {
    en: {
        new: 'New',
        import: 'Add connection from a plugin',
    },
    pt: {
        new: 'Novo',
        import: 'Adicionar connection de um plugin',
    },
};
//# sourceMappingURL=RequiredConnectionField.js.map