import { jsx as e } from "../../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
import C from "classnames";
import { Alert as x } from "../../../../../internal/Alert/Alert.js";
import d from "../../../../../internal/Typography/Typography.js";
import { AlertTypeOption as O, AlertVariantOption as P } from "../../../../../internal/Alert/types.js";
import { useResponsiveContainer as D, containerQueries as U } from "../../../../../../hooks/useResponsiveContainer.js";
import { Divider as W } from "../../../../../internal/Divider/Divider.js";
import { TypographyElement as T, TypographyVariant as c } from "../../../../../internal/Typography/types.js";
import { invisibleFields as _ } from "./constants.js";
import { useWizardFormContext as E } from "../../../../../../hooks/form/wizard/WizardFormContext.js";
import { useMemo as N } from "../../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
import { Tag as B } from "../../../../../internal/Tag/Tag.js";
/* empty css                 */
import j from "../../../../../../core/Context/preact/useCoreContext.js";
import v from "../../../../../internal/StructuredList/StructuredList.js";
import { Fragment as w } from "../../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/dist/preact.module.js";
const ne = ({ countryDatasetData: g }) => {
  const { getSummaryData: b, getValues: k, getDisplayValue: A } = E(), f = b(), { i18n: t } = j(), S = D(U.down.xs), F = N(() => {
    const { payment: r } = f, y = r?.fields.filter(({ id: o }) => !_.includes(o)), a = {
      id: "store",
      label: "payByLink.creation.summary.fields.store",
      value: k("store"),
      displayValue: A("store")
    };
    return [...a ? [a] : [], ...y || []]?.map(({ label: o, value: u, id: l, displayValue: i }) => ({
      key: o || l,
      value: i || u,
      id: l,
      render: (n) => {
        switch (n.id) {
          case "linkValidity.quantity": {
            const m = r?.fields?.find((p) => p.id === "linkValidity.durationUnit");
            return t.get(`payByLink.creation.fields.validity.linkValidityUnit.${m?.value}`, {
              values: { quantity: n.value },
              count: Number(n.value)
            });
          }
          case "amount.value": {
            const m = r?.fields?.find((p) => p.id === "amount.currency");
            return t.amount(n.value, m?.value);
          }
          case "linkType":
            return t.get(`payByLink.creation.form.linkTypes.${n.value}`);
          default:
            return n.value;
        }
      }
    })) || [];
  }, [f, A, k, t]), s = N(() => {
    const { customer: r } = f, y = r?.fields.filter(({ id: i }) => !_.includes(i)), a = ({
      label: i,
      value: n,
      id: m,
      displayValue: p
    }) => ({
      key: i || m,
      value: p || n,
      id: m,
      render: (h) => {
        switch (h.id) {
          case "countryCode":
          case "deliveryAddress.country":
          case "billingAddress.country":
            return g?.find((V) => V.id === h.value)?.name;
          default:
            return h.value;
        }
      }
    }), I = y?.filter((i) => i.id?.startsWith("deliveryAddress."))?.map(a), L = y?.filter((i) => i.id?.startsWith("billingAddress."))?.map(a), o = y?.filter((i) => !i?.id?.startsWith("deliveryAddress.") && !i?.id?.startsWith("billingAddress."))?.map(a), u = r?.fields.find((i) => i.id === "sendLinkToShopper" && i.value === !0), l = r?.fields.find((i) => i.id === "sendSuccessEmailToShopper" && i.value === !0);
    return (u || l) && o?.splice(3, 0, {
      key: "payByLink.creation.summary.fields.emailNotifications",
      value: [l, u].filter(Boolean),
      render: () => /* @__PURE__ */ e("div", { className: "adyen-pe-payment-link-creation-form-summary__tags-container", children: [
        u && /* @__PURE__ */ e(B, { children: /* @__PURE__ */ e(d, { variant: c.CAPTION, el: T.SPAN, stronger: !0, children: t.get("payByLink.creation.summary.fields.emailNotifications.emailCreation") }) }),
        l && /* @__PURE__ */ e(B, { children: /* @__PURE__ */ e(d, { variant: c.CAPTION, el: T.SPAN, stronger: !0, children: t.get("payByLink.creation.summary.fields.emailNotifications.paymentSuccess") }) })
      ] })
    }), { nonAddressItems: o, deliveryAddressItems: I, billingAddressItems: L };
  }, [g, f, t]);
  return /* @__PURE__ */ e("section", { className: C("adyen-pe-payment-link-creation-form-summary", { "adyen-pe-payment-link-creation-form-summary--mobile": S }), children: [
    /* @__PURE__ */ e("section", { className: "adyen-pe-payment-link-creation-form-summary__section", children: [
      /* @__PURE__ */ e(d, { variant: c.SUBTITLE, className: "adyen-pe-payment-link-creation-form-summary__section-title", children: t.get("payByLink.creation.summary.paymentDetails") }),
      /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(v, { layout: "5-7", align: "start", condensed: !1, items: F }) })
    ] }),
    s.nonAddressItems?.length && /* @__PURE__ */ e(w, { children: [
      /* @__PURE__ */ e(W, {}),
      /* @__PURE__ */ e("section", { className: "adyen-pe-payment-link-creation-form-summary__section", children: [
        /* @__PURE__ */ e(d, { variant: c.SUBTITLE, className: "adyen-pe-payment-link-creation-form-summary__section-title", children: t.get("payByLink.creation.summary.shopperInformation") }),
        /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(v, { layout: "5-7", align: "start", condensed: !1, items: s.nonAddressItems }) })
      ] })
    ] }),
    !!s.deliveryAddressItems?.length && /* @__PURE__ */ e("section", { className: "adyen-pe-payment-link-creation-form-summary__section", children: [
      /* @__PURE__ */ e(d, { variant: c.BODY, className: "adyen-pe-payment-link-creation-form-summary__section-title", children: t.get("payByLink.creation.summary.deliveryAddress") }),
      /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(v, { layout: "5-7", align: "start", condensed: !1, items: s.deliveryAddressItems || [] }) })
    ] }),
    !!s.billingAddressItems?.length && /* @__PURE__ */ e("section", { className: "adyen-pe-payment-link-creation-form-summary__section", children: [
      /* @__PURE__ */ e(d, { variant: c.BODY, className: "adyen-pe-payment-link-creation-form-summary__section-title", children: t.get("payByLink.creation.summary.billingAddress") }),
      /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(v, { layout: "5-7", align: "start", condensed: !1, items: s.billingAddressItems || [] }) })
    ] }),
    /* @__PURE__ */ e(
      x,
      {
        className: "adyen-pe-payment-link-creation-form-summary__alert",
        variant: P.TIP,
        type: O.HIGHLIGHT,
        description: t.get("payByLink.creation.summary.alertDescription")
      }
    )
  ] });
};
export {
  ne as FormSummary
};
