import { jsxs as b, Fragment as x, jsx as e } from "react/jsx-runtime";
import { Suspense as A, lazy as I } from "react";
import { isActionAvailable as P } from "@edifice.io/client";
import { useToggle as R, useEdificeClient as y, Button as O, BlogPublic as k, LoadingScreen as v } from "@edifice.io/react";
import { x as F, w as T, u as j, h as w, f as B, r as z, S as E, a as L } from "./index2.js";
import { useTranslation as M } from "react-i18next";
const N = /* @__PURE__ */ I(async () => await import("./ResourceModal.js"));
function U({
  onResourceCreated: l
}) {
  const [n, s] = R(), a = F((o) => o.config), {
    appCode: t
  } = y(), {
    t: i
  } = M(t), {
    clearSelectedItems: u,
    clearSelectedIds: d
  } = T(), {
    data: r
  } = j(a == null ? void 0 : a.actions), m = r == null ? void 0 : r.find((o) => o.id === "create"), c = w(), p = B({
    onResourceCreated: l
  }), f = z();
  return m ? /* @__PURE__ */ b(x, { children: [
    /* @__PURE__ */ e(O, { type: "button", color: "primary", variant: "filled", leftIcon: /* @__PURE__ */ e(E, {}), className: "ms-auto", onClick: () => {
      if (t == "scrapbook") {
        L({
          searchParams: f,
          folderId: c.id
        });
        return;
      }
      u(), d(), s();
    }, children: i("explorer.create.title") }),
    /* @__PURE__ */ e(A, { fallback: /* @__PURE__ */ e(v, {}), children: n && /* @__PURE__ */ e(N, { mode: "create", currentFolder: c, createResource: p, isOpen: n, onSuccess: s, onCancel: s, children: (o, C, g, S, h) => t === "blog" && P("createPublic", r) && /* @__PURE__ */ e(k, { appCode: t, isUpdating: C, resource: o, watch: g, setValue: S, register: h }) }) })
  ] }) : null;
}
export {
  U as default
};
