"use client";
import { jsx, jsxs } from "react/jsx-runtime";
import { useT } from "@open-mercato/shared/lib/i18n/context";
function ChannelPayloadRendererWidget({
  data
}) {
  const t = useT();
  const payload = data?._channelPayload ?? null;
  if (!payload || !payload.channelContentType) return null;
  const { channelContentType, channelPayload, sanitizedHtml } = payload;
  if (channelContentType.startsWith("email/") && typeof sanitizedHtml === "string") {
    return /* @__PURE__ */ jsx(
      "section",
      {
        className: "rounded-md border bg-card p-4 text-sm",
        "aria-label": t(
          "communication_channels.channelPayload.email.aria",
          "Channel payload \u2014 email"
        ),
        children: /* @__PURE__ */ jsx("div", { dangerouslySetInnerHTML: { __html: sanitizedHtml } })
      }
    );
  }
  return /* @__PURE__ */ jsxs(
    "section",
    {
      className: "rounded-md border bg-muted p-4 text-xs",
      "aria-label": t("communication_channels.channelPayload.aria", "Channel payload"),
      children: [
        /* @__PURE__ */ jsx("header", { className: "mb-2 text-overline text-muted-foreground", children: t(
          `communication_channels.channelPayload.types.${channelContentType}`,
          channelContentType
        ) }),
        /* @__PURE__ */ jsx("pre", { className: "overflow-auto whitespace-pre-wrap break-words", children: JSON.stringify(channelPayload, null, 2) })
      ]
    }
  );
}
export {
  ChannelPayloadRendererWidget as default
};
//# sourceMappingURL=widget.client.js.map
