import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { memo, useMemo } from 'react';
import { strikethroughText } from '../../utils/index.js';
import { SchemaSelection } from '../common/SchemaSelection/SchemaSelection.js';
import { SelectionTitle } from '../common/index.js';
import { styled } from '../../styled-components.js';
function DiscriminatorDropdownComponent({ activeOneOfIdx, parent, onChange, translate, }) {
    const options = useMemo(() => {
        return (parent.oneOf || []).map((subSchema, idx) => {
            const label = subSchema.schema.deprecated
                ? `${strikethroughText(subSchema.title)} (${translate('openapi.badges.deprecated', 'deprecated').toLowerCase()}`
                : subSchema.title;
            return {
                label,
                value: idx,
            };
        });
    }, [parent.oneOf, translate]);
    if (parent.oneOf === undefined) {
        return null;
    }
    return (_jsxs(Wrapper, { children: [_jsx(SelectionTitle, { children: translate('openapi.discriminator', 'Discriminator') }), _jsx(SchemaSelection, { options: options, pointer: parent.operationPointer, onChange: onChange, schema: parent, defaultOneOfIdx: activeOneOfIdx })] }));
}
export const Discriminator = memo(DiscriminatorDropdownComponent);
const Wrapper = styled.div `
  display: flex;
  flex-direction: column;
  align-items: flex-start;
`;
//# sourceMappingURL=Discriminator.js.map