import { jsx as d } from "react/jsx-runtime";
import { useEffect as f } from "react";
import { a as x } from "./index.CfQlFjZU.js";
import { S as p } from "./shared.EdGf6tcG.js";
import { a as T } from "./TextArea.slboc5OS.js";
import { a as C } from "./Button.CpTwUWVr.js";
import { u as A, M as D } from "./modal.BZAvb1Nx.js";
import { u as h } from "./useId.7P31viIO.js";
const y = "creator_textModuleContainer_kEIAi", E = { textModuleContainer: y }, S = ({
  onSubmit: n,
  onCancel: t,
  onContentChange: r,
  content: s,
  helpers: l,
  errors: i,
  disabled: o,
  visible: e = !0
}) => {
  const m = h(), { Modal: c, openModal: a, closeModal: u } = A();
  return f(() => {
    e ? a() : u();
  }, [e, a, u]), {
    onSubmit: (M) => {
      M.preventDefault(), n(M);
    },
    onCancel: t,
    onContentChange: r,
    content: s || "",
    disabled: o,
    helpers: l,
    errors: i,
    formId: m,
    containerClassName: E.textModuleContainer,
    Modal: c
  };
}, b = ({
  onSubmit: n,
  onCancel: t,
  onContentChange: r,
  content: s,
  disabled: l,
  helpers: i,
  errors: o,
  formId: e,
  containerClassName: m,
  Modal: c
}) => /* @__PURE__ */ d(
  c,
  {
    type: D.ADVANCED,
    heading: "Add Text",
    buttons: [
      {
        label: "Done",
        semantic: p.PRIMARY,
        type: C.SUBMIT,
        form: e,
        disabled: l
      },
      {
        label: "Cancel",
        semantic: p.SECONDARY,
        onClick: () => t()
      }
    ],
    onDismiss: () => t(),
    children: /* @__PURE__ */ d("form", { id: e, className: m, onSubmit: n, children: /* @__PURE__ */ d(
      T,
      {
        label: "Text",
        helper: o?.content || i?.content,
        isError: !!o?.content,
        value: s,
        onChange: (a) => r(a.target.value)
      }
    ) })
  }
), Y = x(b, S);
export {
  Y as T
};
