"use client";
import { jsx, jsxs } from "react/jsx-runtime";
import * as React from "react";
import { Copy, Check } from "lucide-react";
import { Button } from "@open-mercato/ui/primitives/button";
import { useT } from "@open-mercato/shared/lib/i18n/context";
function CopyButton({ value, label }) {
  const t = useT();
  const [copied, setCopied] = React.useState(false);
  const handleCopy = React.useCallback(async () => {
    if (typeof navigator === "undefined" || !navigator.clipboard) return;
    await navigator.clipboard.writeText(value);
    setCopied(true);
    window.setTimeout(() => setCopied(false), 1500);
  }, [value]);
  return /* @__PURE__ */ jsxs(Button, { type: "button", variant: "ghost", size: "sm", onClick: handleCopy, "aria-label": label, children: [
    copied ? /* @__PURE__ */ jsx(Check, { className: "h-4 w-4", "aria-hidden": true }) : /* @__PURE__ */ jsx(Copy, { className: "h-4 w-4", "aria-hidden": true }),
    /* @__PURE__ */ jsx("span", { className: "ml-1.5 text-xs", children: copied ? t("customer_accounts.domainMapping.copyTarget.copied", "Copied") : t("customer_accounts.domainMapping.copyTarget", "Copy") })
  ] });
}
function DefaultDnsConfig({ hostname, cnameTarget, aRecordTarget }) {
  const t = useT();
  const exampleHost = hostname ?? t("customer_accounts.domainMapping.hostname.placeholder", "e.g., shop.yourdomain.com");
  return /* @__PURE__ */ jsxs("div", { className: "space-y-4 rounded-lg border bg-muted/20 p-4", children: [
    /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
      /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-foreground", children: t("customer_accounts.domainMapping.cnameInstruction", "Add a CNAME record for {hostname} pointing to {target} in your DNS provider", {
        hostname: exampleHost,
        target: cnameTarget ?? "\u2014"
      }) }),
      cnameTarget ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 rounded-md border bg-background px-3 py-2", children: [
        /* @__PURE__ */ jsx("code", { className: "flex-1 truncate font-mono text-sm", children: cnameTarget }),
        /* @__PURE__ */ jsx(CopyButton, { value: cnameTarget, label: t("customer_accounts.domainMapping.copyTarget", "Copy") })
      ] }) : null
    ] }),
    aRecordTarget ? /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
      /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: t("customer_accounts.domainMapping.aRecordInstruction", "For an apex domain, add an A record for {hostname} pointing to {target}", {
        hostname: exampleHost,
        target: aRecordTarget
      }) }),
      /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 rounded-md border bg-background px-3 py-2", children: [
        /* @__PURE__ */ jsx("code", { className: "flex-1 truncate font-mono text-sm", children: aRecordTarget }),
        /* @__PURE__ */ jsx(CopyButton, { value: aRecordTarget, label: t("customer_accounts.domainMapping.copyTarget", "Copy") })
      ] })
    ] }) : null,
    /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t("customer_accounts.domainMapping.propagationNote", "DNS changes can take up to 48 hours to propagate. The system checks automatically \u2014 you'll be notified when it's ready.") })
  ] });
}
var DnsConfig_default = DefaultDnsConfig;
export {
  DefaultDnsConfig,
  DnsConfig_default as default
};
//# sourceMappingURL=DnsConfig.js.map
