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AA,QACN,KAAA,EAAM,MAAA;AAAA,QACN,OAAA,EAAQ,MAAA;AAAA,QACR,KAAA,EAAO,WAAA;AAAA,QACP,MAAA,EAAQ,UAAA;AAAA,QACR,OAAA,EAAS;AAAA;AAAA,KACX,EACF,CAAA;AAAA,EAEJ;AACF","file":"matrix.mjs","sourcesContent":["/**\n * Theming props for the Matrix Widget.\n * These map to CSS custom properties used internally.\n */\nexport interface MatrixThemingProps {\n  /** Container background color */\n  matrixBackgroundColor?: string;\n  /** Primary text color */\n  matrixTextColor?: string;\n  /** Secondary text color */\n  matrixSecondaryTextColor?: string;\n  /** Border color */\n  matrixBorderColor?: string;\n  /** Container border radius */\n  matrixBorderRadius?: string;\n  /** Container padding */\n  matrixPadding?: string;\n  /** Container box shadow */\n  matrixShadow?: string;\n  /** Primary color */\n  matrixPrimaryColor?: string;\n  /** Accent color */\n  matrixAccentColor?: string;\n  /** Card background */\n  matrixCardBg?: string;\n  /** Card hover background */\n  matrixCardHoverBg?: string;\n  /** Card border */\n  matrixCardBorder?: string;\n  /** Card border radius */\n  matrixCardRadius?: string;\n  /** Card box shadow */\n  matrixCardShadow?: string;\n  /** Card padding */\n  matrixCardPadding?: string;\n  /** Card gap */\n  matrixCardGap?: string;\n  /** Icon background */\n  matrixIconBg?: string;\n  /** Icon color */\n  matrixIconColor?: string;\n  /** Icon size */\n  matrixIconSize?: string;\n  /** Icon border radius */\n  matrixIconRadius?: string;\n  /** Indicator color */\n  matrixIndicatorColor?: string;\n  /** Indicator size */\n  matrixIndicatorSize?: string;\n  /** Badge background */\n  matrixBadgeBg?: string;\n  /** Badge text color */\n  matrixBadgeColor?: string;\n  /** Font family */\n  matrixFontFamily?: string;\n  /** Title font size */\n  matrixTitleSize?: string;\n  /** Title font weight */\n  matrixTitleWeight?: string;\n  /** Body text font size */\n  matrixBodySize?: string;\n  /** Body text font weight */\n  matrixBodyWeight?: string;\n  /** Timestamp font size */\n  matrixTimestampSize?: string;\n  /** Timestamp text color */\n  matrixTimestampColor?: string;\n  /** Empty state icon color */\n  matrixEmptyIconColor?: string;\n  /** Empty state icon size */\n  matrixEmptyIconSize?: string;\n  /** Empty state title font size */\n  matrixEmptyTitleSize?: string;\n  /** Empty state text color */\n  matrixEmptyTextColor?: string;\n  /** Button background */\n  matrixButtonBg?: string;\n  /** Button text color */\n  matrixButtonColor?: string;\n  /** Button border radius */\n  matrixButtonRadius?: string;\n  /** Button padding */\n  matrixButtonPadding?: string;\n  /** Transition duration */\n  matrixTransitionDuration?: string;\n  /** Hover scale factor */\n  matrixHoverScale?: string;\n  /** Animation timing function */\n  matrixAnimationTiming?: string;\n  /** Container minimum height */\n  matrixMinHeight?: string;\n  /** Container maximum width */\n  matrixMaxWidth?: string;\n  /** Layout gap */\n  matrixGap?: string;\n}\n\n/**\n * Core configuration props for the Matrix Widget.\n */\nexport interface MatrixWidgetProps extends MatrixThemingProps {\n  /** Base URL of the Legion application (required) */\n  baseUrl: string;\n  /** Theme preset. Default: \"light\" */\n  theme?: \"light\" | \"dark\";\n  /** Title shown in empty state. Default: \"You're all caught up\" */\n  emptyTitle?: string;\n  /** Subtitle shown in empty state. Default: \"No updates right now\" */\n  emptySubtitle?: string;\n  /** Accent color name. Default: \"blue\" (light) / \"gray\" (dark) */\n  accentColor?: string;\n  /** Icon for empty state. Default: \"bell\" */\n  emptyIcon?: \"bell\" | \"gift\" | \"activity\" | \"trophy\";\n  /** Widget width CSS value. Default: \"100%\" */\n  width?: string;\n  /** Widget height CSS value. Default: \"400px\" */\n  height?: string;\n  /** Additional CSS class name for the container */\n  className?: string;\n  /** Additional inline styles for the container */\n  style?: React.CSSProperties;\n  /** Callback when the widget iframe has loaded */\n  onLoad?: (detail: { widget: string; theme: string }) => void;\n  /** Callback when the widget iframe fails to load */\n  onError?: (message: string) => void;\n}\n\n/**\n * Mapping from camelCase theming prop names to the kebab-case query\n * parameter names used by the matrix widget iframe URL.\n */\nexport const MATRIX_THEMING_PROP_TO_PARAM: Record<\n  keyof MatrixThemingProps,\n  string\n> = {\n  matrixBackgroundColor: \"matrix-background-color\",\n  matrixTextColor: \"matrix-text-color\",\n  matrixSecondaryTextColor: \"matrix-secondary-text-color\",\n  matrixBorderColor: \"matrix-border-color\",\n  matrixBorderRadius: \"matrix-border-radius\",\n  matrixPadding: \"matrix-padding\",\n  matrixShadow: \"matrix-shadow\",\n  matrixPrimaryColor: \"matrix-primary-color\",\n  matrixAccentColor: \"matrix-accent-color\",\n  matrixCardBg: \"matrix-card-bg\",\n  matrixCardHoverBg: \"matrix-card-hover-bg\",\n  matrixCardBorder: \"matrix-card-border\",\n  matrixCardRadius: \"matrix-card-radius\",\n  matrixCardShadow: \"matrix-card-shadow\",\n  matrixCardPadding: \"matrix-card-padding\",\n  matrixCardGap: \"matrix-card-gap\",\n  matrixIconBg: \"matrix-icon-bg\",\n  matrixIconColor: \"matrix-icon-color\",\n  matrixIconSize: \"matrix-icon-size\",\n  matrixIconRadius: \"matrix-icon-radius\",\n  matrixIndicatorColor: \"matrix-indicator-color\",\n  matrixIndicatorSize: \"matrix-indicator-size\",\n  matrixBadgeBg: \"matrix-badge-bg\",\n  matrixBadgeColor: \"matrix-badge-color\",\n  matrixFontFamily: \"matrix-font-family\",\n  matrixTitleSize: \"matrix-title-size\",\n  matrixTitleWeight: \"matrix-title-weight\",\n  matrixBodySize: \"matrix-body-size\",\n  matrixBodyWeight: \"matrix-body-weight\",\n  matrixTimestampSize: \"matrix-timestamp-size\",\n  matrixTimestampColor: \"matrix-timestamp-color\",\n  matrixEmptyIconColor: \"matrix-empty-icon-color\",\n  matrixEmptyIconSize: \"matrix-empty-icon-size\",\n  matrixEmptyTitleSize: \"matrix-empty-title-size\",\n  matrixEmptyTextColor: \"matrix-empty-text-color\",\n  matrixButtonBg: \"matrix-button-bg\",\n  matrixButtonColor: \"matrix-button-color\",\n  matrixButtonRadius: \"matrix-button-radius\",\n  matrixButtonPadding: \"matrix-button-padding\",\n  matrixTransitionDuration: \"matrix-transition-duration\",\n  matrixHoverScale: \"matrix-hover-scale\",\n  matrixAnimationTiming: \"matrix-animation-timing\",\n  matrixMinHeight: \"matrix-min-height\",\n  matrixMaxWidth: \"matrix-max-width\",\n  matrixGap: \"matrix-gap\",\n};\n\n","import React, {\n  useRef,\n  useCallback,\n  useMemo,\n  forwardRef,\n  useImperativeHandle,\n} from \"react\";\nimport {\n  type MatrixWidgetProps,\n  type MatrixThemingProps,\n  MATRIX_THEMING_PROP_TO_PARAM,\n} from \"./types\";\n\n/**\n * Ref handle exposed by LegionMatrix for imperative control.\n */\nexport interface LegionMatrixHandle {\n  /** Reload the widget iframe */\n  refresh: () => void;\n}\n\n/**\n * Build the iframe src URL from widget props.\n */\nexport function buildMatrixWidgetUrl(props: MatrixWidgetProps): string {\n  const {\n    baseUrl,\n    theme = \"light\",\n    emptyTitle = \"You're all caught up\",\n    emptySubtitle = \"No updates right now\",\n    accentColor,\n    emptyIcon = \"bell\",\n  } = props;\n\n  const url = new URL(\"/widget/matrix\", baseUrl);\n  url.searchParams.set(\"theme\", theme);\n  url.searchParams.set(\"emptyTitle\", emptyTitle);\n  url.searchParams.set(\"emptySubtitle\", emptySubtitle);\n\n  // Default accent color depends on theme\n  const resolvedAccentColor =\n    accentColor ?? (theme === \"dark\" ? \"gray\" : \"blue\");\n  url.searchParams.set(\"accentColor\", resolvedAccentColor);\n\n  // Validate emptyIcon\n  const validIcons: Array<MatrixWidgetProps[\"emptyIcon\"]> = [\n    \"bell\",\n    \"gift\",\n    \"activity\",\n    \"trophy\",\n  ];\n  const resolvedIcon = validIcons.includes(emptyIcon) ? emptyIcon : \"bell\";\n  url.searchParams.set(\"emptyIcon\", resolvedIcon!);\n\n  // Append theming params\n  const themingKeys = Object.keys(MATRIX_THEMING_PROP_TO_PARAM) as Array<\n    keyof MatrixThemingProps\n  >;\n  for (const key of themingKeys) {\n    const value = props[key];\n    if (value !== undefined && value !== null && String(value).length > 0) {\n      url.searchParams.set(MATRIX_THEMING_PROP_TO_PARAM[key], String(value));\n    }\n  }\n\n  return url.toString();\n}\n\n/**\n * LegionMatrix – a React component that embeds the Legion\n * Matrix (site-wide notification feed) widget via an iframe.\n *\n * @example\n * ```tsx\n * import { LegionMatrix } from '@legionhandtech/lht-react-widgets';\n *\n * function App() {\n *   return (\n *     <LegionMatrix\n *       baseUrl=\"https://your-legion-domain.com\"\n *       theme=\"light\"\n *       emptyTitle=\"You're all caught up\"\n *       emptyIcon=\"bell\"\n *     />\n *   );\n * }\n * ```\n */\nexport const LegionMatrix = forwardRef<LegionMatrixHandle, MatrixWidgetProps>(\n  function LegionMatrix(props, ref) {\n    const {\n      theme = \"light\",\n      emptyTitle,\n      emptySubtitle,\n      accentColor,\n      emptyIcon,\n      width = \"100%\",\n      height = \"400px\",\n      className,\n      style,\n      onLoad,\n      onError,\n      baseUrl,\n      ...rest\n    } = props;\n\n    const iframeRef = useRef<HTMLIFrameElement>(null);\n\n    useImperativeHandle(\n      ref,\n      () => ({\n        refresh: () => {\n          const iframe = iframeRef.current;\n          if (iframe?.contentWindow) {\n            iframe.contentWindow.location.reload();\n          }\n        },\n      }),\n      []\n    );\n\n    const src = useMemo(\n      () => buildMatrixWidgetUrl(props),\n      [\n        baseUrl,\n        theme,\n        emptyTitle,\n        emptySubtitle,\n        accentColor,\n        emptyIcon,\n        ...Object.keys(MATRIX_THEMING_PROP_TO_PARAM).map(\n          (k) => rest[k as keyof typeof rest]\n        ),\n      ]\n    );\n\n    const handleLoad = useCallback(() => {\n      onLoad?.({ widget: \"matrix\", theme });\n    }, [theme, onLoad]);\n\n    const handleError = useCallback(() => {\n      onError?.(\"Failed to load matrix widget\");\n    }, [onError]);\n\n    const containerStyle: React.CSSProperties = {\n      display: \"block\",\n      width,\n      backgroundColor: \"transparent\",\n      ...style,\n    };\n\n    const iframeStyle: React.CSSProperties = {\n      border: \"none\",\n      borderRadius: \"8px\",\n      overflow: \"hidden\",\n      width: \"100%\",\n      height,\n    };\n\n    return (\n      <div className={className} style={containerStyle}>\n        <iframe\n          ref={iframeRef}\n          src={src}\n          title=\"Matrix Widget\"\n          width=\"100%\"\n          loading=\"lazy\"\n          style={iframeStyle}\n          onLoad={handleLoad}\n          onError={handleError}\n        />\n      </div>\n    );\n  }\n);\n\n"]}