import { useState as f, useRef as s } from "react";
import { jsx as c } from "react/jsx-runtime";
function d({ onFileSelect: a }) {
  const [l, n] = f(!1);
  return { dragging: l, onDragEnter: (e) => {
    e.preventDefault(), n(!0);
  }, onDragLeave: (e) => {
    e.preventDefault(), (!e.relatedTarget || !e.currentTarget.contains(e.relatedTarget)) && n(!1);
  }, handleDrop: (e) => {
    e.preventDefault(), n(!1);
    const r = e.dataTransfer?.files;
    !r || r.length === 0 || a(r);
  } };
}
function D({
  onFilesSelected: a,
  allowedTypes: l,
  allowMultipleFiles: n = !1
}) {
  const t = s(null);
  function i() {
    t.current?.click();
  }
  function u() {
    t.current && (t.current.value = "");
  }
  function e(r) {
    const o = r.target.files;
    o && a(o);
  }
  return {
    openFileInput: i,
    clearFileInput: u,
    component: /* @__PURE__ */ c(
      "input",
      {
        "data-testid": "file-input",
        type: "file",
        ref: t,
        onChange: e,
        hidden: !0,
        accept: l?.join(","),
        multiple: n
      }
    )
  };
}
export {
  D as a,
  d as u
};
