import { isValidElement } from 'react';
/**
 * Converts a `ReactNode` to a `string` representation. Extracts text content from React elements
 * recursively.
 *
 * Based on `https://github.com/sunknudsen/react-node-to-string`
 *
 * @param reactNode - The React node to convert to string.
 * @returns The string representation of the node, or empty string for null/undefined/boolean.
 */
export function reactNodeToString(reactNode) {
    if (typeof reactNode === 'string') {
        return reactNode;
    }
    if (typeof reactNode === 'number') {
        return String(reactNode);
    }
    if (Array.isArray(reactNode)) {
        return reactNode.map((child) => reactNodeToString(child)).join('');
    }
    if (isValidElement(reactNode)) {
        const element = reactNode;
        return reactNodeToString(element.props.children);
    }
    return '';
}
//# sourceMappingURL=reactNodeToString.js.map