import { jsxs, jsx } from "react/jsx-runtime";
import * as React from "react";
import { XCircle, TriangleAlert, CircleCheck, Info, X } from "lucide-react";
import { cn } from "../../lib/utils.js";
import { Button } from "../Button/button.js";
import { ItemPrefix, ItemContent } from "../../patterns/element-anatomy/item-anatomy.js";
const VARIANT_ICON = {
  neutral: null,
  info: Info,
  success: CircleCheck,
  warning: TriangleAlert,
  error: XCircle
};
const SUBTLE_ICON_COLOR = {
  neutral: "text-fg-muted",
  info: "text-info-text",
  success: "text-success-text",
  warning: "text-warning-text",
  error: "text-error-text"
};
const NOTICE_LAYOUT = [
  "flex items-start gap-2 w-full",
  "text-body leading-compact",
  "px-4 py-3"
].join(" ");
const Notice = React.forwardRef(
  ({
    variant = "neutral",
    title,
    description,
    endContent,
    dismissible = true,
    onDismiss,
    dismissAriaLabel = "關閉通知",
    // i18n-allow: DS default; consumer override via dismissAriaLabel prop
    iconClassName,
    className,
    ...props
  }, ref) => {
    const StatusIcon = VARIANT_ICON[variant];
    return /* @__PURE__ */ jsxs(
      "div",
      {
        ref,
        className: cn(NOTICE_LAYOUT, className),
        ...props,
        children: [
          StatusIcon && /* @__PURE__ */ jsx(ItemPrefix, { children: /* @__PURE__ */ jsx(StatusIcon, { size: 16, className: cn("shrink-0", iconClassName), "aria-hidden": true }) }),
          /* @__PURE__ */ jsx(
            ItemContent,
            {
              label: title,
              description,
              labelClassName: description ? "font-medium" : void 0
            }
          ),
          (endContent || dismissible) && // @row-slot-handcraft-allow: Notice 是非-row alert（非 item-anatomy row），此 end slot 是 Notice 自身 layout 的 dismiss/endContent 容器，不是 row prefix/suffix → 不消費 ItemPrefix/ItemSuffix
          /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 shrink-0 h-[1lh]", children: [
            endContent,
            dismissible && /* @__PURE__ */ jsx(
              Button,
              {
                "data-dismiss": true,
                iconOnly: true,
                dismiss: true,
                size: "xs",
                startIcon: X,
                "aria-label": dismissAriaLabel,
                onClick: onDismiss
              }
            )
          ] })
        ]
      }
    );
  }
);
Notice.displayName = "Notice";
let themeObserverStarted = false;
const themeSubscribers = /* @__PURE__ */ new Set();
function getInverseTheme() {
  if (typeof document === "undefined") return "dark";
  const current = document.documentElement.getAttribute("data-theme") ?? "light";
  return current === "dark" ? "light" : "dark";
}
function startThemeObserver() {
  if (themeObserverStarted || typeof document === "undefined") return;
  themeObserverStarted = true;
  const root = document.documentElement;
  const observer = new MutationObserver(() => {
    themeSubscribers.forEach((cb) => cb());
  });
  observer.observe(root, { attributes: true, attributeFilter: ["data-theme"] });
}
function subscribe(cb) {
  startThemeObserver();
  themeSubscribers.add(cb);
  return () => themeSubscribers.delete(cb);
}
function useInverseTheme() {
  return React.useSyncExternalStore(subscribe, getInverseTheme, getInverseTheme);
}
const noticeMeta = {
  component: "Notice",
  family: 2,
  // Family 2（List item layout）消費者 — 對齊 notice.spec.md frontmatter family: 2 + body「Layout Family」段
  variants: {},
  sizes: {},
  states: ["default"],
  // 無互動 layout primitive(spec「邊界案例」:不擁有 disabled;hover / focus 屬內嵌 dismiss Button)
  tokens: {
    bg: [],
    fg: ["text-error-text", "text-fg-muted", "text-fg-secondary", "text-info-text", "text-success-text", "text-warning-text"],
    ring: []
  }
};
export {
  Notice,
  SUBTLE_ICON_COLOR,
  noticeMeta,
  useInverseTheme
};
//# sourceMappingURL=notice.js.map
