import { jsx as e } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
/* empty css                               */
import d from "../../../../internal/Typography/Typography.js";
import { TypographyVariant as p } from "../../../../internal/Typography/types.js";
import l from "../PaymentLinkSettingsContainer/context/context.js";
import { useState as c, useEffect as h, useMemo as f } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
import { isThemePayload as u, isThemeData as g } from "./types.js";
import k from "../PaymentLinkSettingsContainer/components/LoadingSkeleton/LoadingSkeleton.js";
import L from "../PaymentLinkSettingsContainer/components/SettingsError/SettingsError.js";
import T from "../../../../../core/Context/preact/useCoreContext.js";
import { ThemeForm as E } from "./components/ThemeForm/ThemeForm.js";
const N = "payByLink.settings.theme.errors.couldNotLoad", O = () => {
  const { i18n: n } = T(), { payload: a, setSavedData: y, savedData: t, themeError: r, isLoadingContent: i } = l(), [o, s] = c();
  h(() => {
    u(a) && s(a);
  }, [a, y, s]);
  const m = f(() => !i && !r ? t && typeof t == "object" && Object.keys(t).length > 0 ? t : { brandName: "" } : { brandName: "" }, [t, i, r]);
  return r ? /* @__PURE__ */ e("section", { className: "adyen-pe-payment-link-theme", children: /* @__PURE__ */ e(L, { error: r, errorMessage: N }) }) : !t || !g(m) || !o ? /* @__PURE__ */ e(k, { rowNumber: 3 }) : /* @__PURE__ */ e("section", { className: "adyen-pe-payment-link-theme", children: [
    /* @__PURE__ */ e("div", { className: "adyen-pe-payment-link-settings__content-header", children: [
      /* @__PURE__ */ e(d, { variant: p.TITLE, medium: !0, children: n.get("payByLink.settings.theme.title") }),
      /* @__PURE__ */ e(d, { variant: p.BODY, wide: !0, className: "adyen-pe-payment-link-settings-terms-and-conditions-disclaimer", children: n.get("payByLink.settings.theme.subtitle") })
    ] }),
    /* @__PURE__ */ e(E, { theme: m, initialPayload: o })
  ] });
};
export {
  O as default
};
