import React, { useMemo, } from 'react';
import classNames from 'classnames';
import { st, classes } from './MaxLines.st.css.js';
export function MaxLines(props) {
    const { children, maxLines = 1, lineHeight, webkitLineClamp, textOverflow, wordBreak, ...rest } = props;
    const style = useMemo(() => ({
        ...(webkitLineClamp && { WebkitLineClamp: maxLines }),
        ...(textOverflow && { textOverflow }),
        ...(lineHeight && {
            lineHeight: `${lineHeight}px`,
            maxHeight: `${lineHeight * maxLines}px`,
        }),
        wordBreak,
        ...rest.style,
    }), [rest.style, maxLines, webkitLineClamp, lineHeight]);
    const className = st(classes.root, {
        clamp: webkitLineClamp,
    }, rest.className);
    let child;
    if (typeof children === 'function') {
        child = children({ className, style });
    }
    else {
        const { type: WrappedComponent, props: wrappedProps } = children;
        child = (React.createElement(WrappedComponent, { ...rest, ...wrappedProps, className: classNames(className, wrappedProps.className), style: { ...style, ...wrappedProps.style } }));
    }
    return child;
}
//# sourceMappingURL=MaxLines.js.map