"use client";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { forwardRef } from "react";
import { getIcon } from "../icon/config.js";
import { useElementInteraction } from "../interaction/useElementInteraction.js";
import { SrOnly } from "../typography/SrOnly.js";
import { useEnsuredId } from "../useEnsuredId.js";
import { fileInput } from "./styles.js";
/**
 * **Client Component**
 * This might be able to become a server component if I remove the getIcon hook
 *
 * @example Simple Example
 * ```tsx
 * import { FileInput } from "@react-md/core/files/FileInput";
 * import { Form } from "@react-md/core/form/Form";
 * import type { ReactElement } from "react";
 *
 * const extensions = [
 *   "svg",
 *   "jpeg",
 *   "jpg",
 *   "png",
 *   "apng",
 *   "mkv",
 *   "mp4",
 *   "mpeg",
 *   "mpg",
 *   "webm",
 *   "mov",
 * ] as const;
 *
 * const FOUR_HUNDRED_MB = 400 * 1024 * 1024;
 * const maxFiles = 10;
 *
 * function Example(): ReactElement {
 *   const { stats, errors, onChange, clearErrors, reset, remove, accept } =
 *     useFileUpload({
 *       maxFiles,
 *       maxFileSize: FOUR_HUNDRED_MB,
 *       extensions,
 *     });
 *
 *   return (
 *     <Form>
 *       <FileInput accept={accept} multiple={maxFiles > 1} onChange={onChange} />
 *       <Button onClick={reset} disabled={!stats.length}>
 *         Remove all files
 *       </Button>
 *     </Form>
 *   );
 * }
 * ```
 *
 * @see {@link https://react-md.dev/components/file-input | FileInput Demos}
 * @since 6.0.0 Added additional support for `iconSize` and
 * `responsive`. Also removed the `disableIconSpacing` prop since it is no
 * longer required.
 */ export const FileInput = /*#__PURE__*/ forwardRef(function FileInput(props, ref) {
    const { id: propId, className, children: propChildren, icon: propIcon, iconAfter = false, srOnlyLabel = "Upload", disableRepeatableFiles = false, labelProps, theme = "primary", themeType = "contained", buttonType = propChildren ? "text" : "icon", disabled = false, iconSize, responsive, multiple = false, disableRipple, ...remaining } = props;
    const id = useEnsuredId(propId, "file-input");
    const { pressed, pressedClassName, ripples, handlers } = useElementInteraction({
        ...labelProps,
        mode: disableRipple ? "none" : undefined,
        onClick (event) {
            labelProps?.onClick?.(event);
            // stop propagation so 2 ripples are not created
            event.stopPropagation();
        },
        disabled
    });
    const icon = getIcon("upload", propIcon);
    let children = propChildren;
    if (typeof propChildren === "undefined" && !props["aria-label"] && !props["aria-labelledby"]) {
        children = /*#__PURE__*/ _jsx(SrOnly, {
            phoneOnly: responsive,
            children: srOnlyLabel
        });
    }
    return /*#__PURE__*/ _jsxs("label", {
        ...labelProps,
        ...handlers,
        className: fileInput({
            theme,
            themeType,
            buttonType,
            disabled,
            iconSize,
            pressed,
            responsive,
            pressedClassName,
            className: className || labelProps?.className
        }),
        children: [
            !iconAfter && icon,
            children,
            iconAfter && icon,
            /*#__PURE__*/ _jsx("input", {
                ...remaining,
                id: id,
                ref: ref,
                value: disableRepeatableFiles || !props.onChange ? remaining.value : "",
                type: "file",
                className: "rmd-hidden-input",
                disabled: disabled,
                multiple: multiple
            }),
            ripples
        ]
    });
});

//# sourceMappingURL=FileInput.js.map