"use client";
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
import { forwardRef, useCallback, useState } from "react";
import { useResizeObserver } from "../useResizeObserver.js";
import { toastContent } from "./toastContentStyles.js";
/**
 * **Client Component**
 *
 * @since 6.0.0
 */ export const ToastContent = /*#__PURE__*/ forwardRef(function ToastContent(props, ref) {
    const { className, children, action, stacked, multiline: propMultiline, closeButton, disableWrapper, ...remaining } = props;
    const [isMultiline, setMultiline] = useState(false);
    const nodeRef = useResizeObserver({
        ref,
        disabled: disableWrapper || typeof propMultiline === "boolean",
        disableWidth: true,
        onUpdate: useCallback((entry)=>{
            const element = entry.target;
            const style = window.getComputedStyle(element);
            const lineHeight = parseFloat(style.lineHeight);
            if (Number.isNaN(lineHeight)) {
                return;
            }
            setMultiline(element.scrollHeight > lineHeight);
        }, [])
    });
    const multiline = propMultiline ?? isMultiline;
    if (disableWrapper) {
        return /*#__PURE__*/ _jsx(_Fragment, {
            children: children
        });
    }
    return /*#__PURE__*/ _jsx("div", {
        ...remaining,
        ref: nodeRef,
        className: toastContent({
            action,
            stacked,
            multiline,
            closeButton,
            className
        }),
        children: children
    });
});

//# sourceMappingURL=ToastContent.js.map