import { jsx as e } from "../../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
import l from "classnames";
import i from "../../../../../internal/Typography/Typography.js";
import { TypographyVariant as a } from "../../../../../internal/Typography/types.js";
import { Icon as y } from "../../../../../internal/Icon/Icon.js";
import { SuccessIcon as f } from "../../../../../internal/SuccessIcon/SuccessIcon.js";
import s from "../../../../../internal/Button/Button.js";
import { ButtonVariant as m } from "../../../../../internal/Button/types.js";
/* empty css                 */
import { useState as d, useRef as k, useEffect as h, useCallback as T } from "../../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
import _ from "../../../../../../core/Context/preact/useCoreContext.js";
const w = ({ onGoToDetails: p, paymentLinkUrl: r }) => {
  const { i18n: t } = _(), [n, o] = d(!1), c = k(null);
  h(() => () => {
    c.current && clearTimeout(c.current);
  }, []);
  const u = T(async () => {
    if (r)
      try {
        await navigator.clipboard.writeText(r), o(!0), c.current && clearTimeout(c.current), c.current = setTimeout(() => {
          o(!1), c.current = null;
        }, 3e3);
      } catch {
      }
  }, [r]);
  return /* @__PURE__ */ e("section", { className: l("adyen-pe-payment-link-creation-form-success"), children: [
    /* @__PURE__ */ e("div", { className: "adyen-pe-payment-link-creation-form-success__content", children: [
      /* @__PURE__ */ e(f, { className: "adyen-pe-payment-link-creation-form-success__icon" }),
      /* @__PURE__ */ e(i, { variant: a.TITLE, className: "adyen-pe-payment-link-creation-form-success__title", children: t.get("payByLink.creation.success.title") }),
      /* @__PURE__ */ e(i, { variant: a.BODY, className: "adyen-pe-payment-link-creation-form-success__description", children: t.get("payByLink.creation.success.description") })
    ] }),
    /* @__PURE__ */ e("div", { className: "adyen-pe-payment-link-creation-form-success__actions", children: [
      /* @__PURE__ */ e(s, { variant: m.SECONDARY, onClick: p, children: t.get("payByLink.creation.success.showDetails") }),
      /* @__PURE__ */ e(s, { variant: m.PRIMARY, onClick: u, iconLeft: /* @__PURE__ */ e(y, { name: n ? "checkmark" : "copy" }), children: n ? t.get("payByLink.creation.success.copiedToClipboard") : t.get("payByLink.creation.success.copyLink") })
    ] })
  ] });
};
export {
  w as FormSuccess
};
