import { ImageGallery as d } from "../ImageGallery/ImageGallery.es.js";
import e, { useReducer as f, useEffect as h } from "react";
import { Authentication as y } from "../Authentication/Authentication.es.js";
import { DestinationDashboard as E } from "../DestinationDashboard/DestinationDashboard.es.js";
import { useAssetUploadStore as A } from "../../state/assetUploadStore.es.js";
const D = ({ imageAssets: a, onCancel: c, onSuccess: u, showImageGallery: l }) => {
  const { setAssets: m } = A((n) => ({ setAssets: n.setAssets })), i = (n, s) => {
    var o;
    switch (s.type) {
      case "init":
        return /* @__PURE__ */ e.createElement(d, {
          asset: a,
          onAssetsChosen: (r) => t({ type: "auth", items: r })
        });
      case "auth":
        return /* @__PURE__ */ e.createElement(y, {
          onSuccess: () => {
            t({ type: "upload", items: s.items });
          }
        });
      case "upload":
        return m((o = s.items) != null ? o : []), /* @__PURE__ */ e.createElement(E, {
          onCancel: c,
          onUpload: (r) => {
            u(r), t({ type: "success" });
          }
        });
      case "success":
        return /* @__PURE__ */ e.createElement("div", null, "Upload Successful");
    }
  }, [p, t] = f(i, /* @__PURE__ */ e.createElement(e.Fragment, null));
  return h(() => {
    t(l ? { type: "init" } : { type: "auth", items: a });
  }, []), /* @__PURE__ */ e.createElement(e.Fragment, null, p);
};
export {
  D as Uploader
};
//# sourceMappingURL=Uploader.es.js.map
