import { jsx as r } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
import { FileInput as c } from "../../../../internal/FormFields/FileInput/FileInput.js";
import { getDefenseDocumentContent as y } from "../../utils/index.js";
import { TypographyElement as h, TypographyVariant as p } from "../../../../internal/Typography/types.js";
import d from "../../../../internal/Typography/Typography.js";
import { useMemo as g } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
import { useDisputeFlow as F } from "../../context/dispute/context.js";
import { ALLOWED_FILE_TYPES as T, DOCUMENT_MAX_SIZE as _ } from "./constants.js";
import C from "../../../../../core/Context/preact/useCoreContext.js";
const S = ({
  document: e,
  disabled: l,
  required: s,
  mapError: m
}) => {
  const { i18n: i } = C(), { removeFieldFromDefendPayload: n, addFileToDefendPayload: f, defenseDocumentConfig: a } = F(), { title: u, primaryDescriptionItems: t } = g(() => y(a, i, e), [a, i, e]) || {};
  return /* @__PURE__ */ r("div", { className: "adyen-pe-defend-dispute-document-upload", children: [
    /* @__PURE__ */ r("div", { children: [
      /* @__PURE__ */ r(
        d,
        {
          strongest: !0,
          className: "adyen-pe-defend-dispute-document-upload__title",
          variant: p.BODY,
          el: h.DIV,
          children: u || e
        }
      ),
      t && t.length > 0 ? t.map((o, D) => /* @__PURE__ */ r(
        d,
        {
          className: "adyen-pe-defend-dispute-document-upload__description",
          variant: p.BODY,
          children: o
        },
        `${D}-description`
      )) : null
    ] }),
    /* @__PURE__ */ r(
      c,
      {
        allowedFileTypes: T,
        maxFileSize: (o) => _[o],
        mapError: m,
        onDelete: () => {
          e && n(e);
        },
        disabled: l,
        required: s,
        onChange: (o) => {
          o[0] ? f(e, o[0]) : n(e);
        }
      },
      e
    )
  ] });
};
export {
  S as DefendDocumentUpload
};
