import { jsx as s, jsxs as S } from "react/jsx-runtime";
import { a as h } from "./index.CfQlFjZU.js";
import { useEffect as x } from "react";
import { S as y } from "./shared.EdGf6tcG.js";
import { a as A } from "./Button.CpTwUWVr.js";
import { a as D } from "./TextInput.63vMRxAK.js";
import { U as E } from "./Upload.X0oU32lw.js";
import { u as R } from "./useId.7P31viIO.js";
import { u as I, M as N } from "./modal.BZAvb1Nx.js";
const U = "creator_tipsModuleModalContainer_GxU1p", j = { tipsModuleModalContainer: U }, w = ({
  onSubmit: m,
  onCancel: t,
  onMediaChange: a,
  onTitleChange: r,
  onLinkChange: d,
  suggestedAllowedMediaTypes: p,
  mediaUploading: u,
  media: M,
  heading: c,
  title: f,
  link: T,
  linkLabel: b,
  helpers: C,
  errors: k,
  disabled: l,
  visible: e = !0
}) => {
  const i = R(), { Modal: g, openModal: n, closeModal: o } = I();
  return x(() => {
    e ? n() : o();
  }, [e, n, o]), {
    onSubmit: (v) => {
      v.preventDefault(), m(v);
    },
    onCancel: t,
    onMediaChange: a,
    onMediaRemove: () => {
      a(null);
    },
    onTitleChange: r,
    onLinkChange: d,
    media: M,
    heading: c,
    title: f || "",
    linkLabel: b || "Link",
    link: T || "",
    suggestedAllowedMediaTypes: p,
    mediaUploading: u,
    disabled: l,
    helpers: C,
    errors: k,
    formId: i,
    containerClassName: j.tipsModuleModalContainer,
    Modal: g
  };
}, B = ({
  onSubmit: m,
  onCancel: t,
  onMediaChange: a,
  onMediaRemove: r,
  onTitleChange: d,
  onLinkChange: p,
  heading: u,
  media: M,
  title: c,
  link: f,
  linkLabel: T,
  suggestedAllowedMediaTypes: b,
  mediaUploading: C,
  disabled: k,
  helpers: l,
  errors: e,
  formId: i,
  containerClassName: g,
  Modal: n
}) => /* @__PURE__ */ s(
  n,
  {
    type: N.ADVANCED,
    heading: u,
    buttons: [
      {
        label: "Done",
        semantic: y.PRIMARY,
        type: A.SUBMIT,
        form: i,
        disabled: k
      },
      {
        label: "Cancel",
        semantic: y.SECONDARY,
        onClick: () => t()
      }
    ],
    onDismiss: () => t(),
    children: /* @__PURE__ */ S("form", { id: i, className: g, onSubmit: m, children: [
      /* @__PURE__ */ s(
        E,
        {
          label: "Thumbnail",
          helper: e?.media || l?.media,
          error: !!e?.media,
          suggestedAllowedTypes: b,
          onFileSelect: (o) => a(o),
          onFileRemove: () => r(),
          file: M,
          uploading: C
        }
      ),
      /* @__PURE__ */ s(
        D,
        {
          label: "Title",
          helper: e?.title || l?.title,
          isError: !!e?.title,
          value: c,
          onChange: (o) => d(o.target.value)
        }
      ),
      /* @__PURE__ */ s(
        D,
        {
          label: T,
          helper: e?.link || l?.link,
          isError: !!e?.link,
          value: f,
          onChange: (o) => p(o.target.value)
        }
      )
    ] })
  }
), z = h(B, w);
export {
  z as T
};
