import { jsx as e, jsxs as c } from "react/jsx-runtime";
import { IconArrowCircleUp as F, IconImageStack as b } from "@frontify/fondue-icons";
import { useRef as y } from "react";
import { Button as p } from "../Button/Button.es.js";
import { ButtonEmphasis as f, ButtonStyle as u } from "../Button/ButtonTypes.es.js";
import { useMemoizedId as j } from "../../hooks/useMemoizedId.es.js";
import { merge as a } from "../../utilities/merge.es.js";
import { SelectedAsset as A } from "./SingleAsset/SelectedAsset.es.js";
import { MultiAssetPreview as D } from "./MultiAssetPreview/MultiAssetPreview.es.js";
var W = /* @__PURE__ */ ((t) => (t.Small = "Small", t.Large = "Large", t))(W || {});
const E = ({
  assets: t = [],
  numberOfLocations: w = 1,
  actions: o = [],
  size: h = "Small",
  isLoading: d = !1,
  hideSize: g = !1,
  hideExtension: x = !1,
  onLibraryClick: s,
  onUploadClick: r,
  onMultiAssetClick: l,
  acceptFileType: v
}) => {
  const n = t.length, i = y(null), I = j(), N = (B) => {
    const m = B.target.files;
    m && r && r(m);
  }, S = () => {
    i.current && i.current.click();
  };
  return (d || n === 1) && o ? /* @__PURE__ */ e(
    A,
    {
      asset: t[0],
      size: h,
      actions: o,
      isLoading: d,
      hideExtension: x,
      hideSize: g
    }
  ) : n > 1 && l ? /* @__PURE__ */ e(D, { assets: t, onClick: l, numberOfLocations: w }) : /* @__PURE__ */ c(
    "div",
    {
      "data-test-id": "asset-input-placeholder",
      className: a([
        "tw-grid tw-p-3 tw-border tw-border-dashed tw-border-black-10 tw-rounded",
        r && s ? "tw-grid-cols-2 tw-divide-x tw-divide-black-10" : "tw-grid-cols-1"
      ]),
      children: [
        r && /* @__PURE__ */ c(
          "div",
          {
            className: a(["tw-flex tw-flex-col tw-h-8", s && "tw-pr-3"]),
            "data-test-id": "asset-input-upload",
            children: [
              /* @__PURE__ */ e(
                p,
                {
                  style: u.Default,
                  onClick: S,
                  emphasis: f.Weak,
                  icon: /* @__PURE__ */ e(F, {}),
                  children: "Upload"
                }
              ),
              /* @__PURE__ */ e(
                "input",
                {
                  id: I,
                  ref: i,
                  className: "tw-hidden",
                  type: "file",
                  accept: v,
                  multiple: !!l,
                  onChange: N
                }
              )
            ]
          }
        ),
        s && /* @__PURE__ */ e(
          "div",
          {
            className: a(["tw-flex tw-flex-col tw-h-8", r && "tw-pl-3"]),
            "data-test-id": "asset-input-library",
            children: /* @__PURE__ */ e(
              p,
              {
                style: u.Default,
                onClick: s,
                emphasis: f.Weak,
                icon: /* @__PURE__ */ e(b, {}),
                children: "Browse"
              }
            )
          }
        )
      ]
    }
  );
};
E.displayName = "FondueAssetInput";
export {
  E as AssetInput,
  W as AssetInputSize
};
//# sourceMappingURL=AssetInput.es.js.map
