{"version":3,"sources":["../src/community-header/types.ts","../src/community-header/LegionCommunityHeader.tsx"],"names":["LegionCommunityHeader"],"mappings":";;;;;;AA+EO,IAAM,4BAAA,GAGT;AAAA,EACF,kBAAA,EAAoB,sBAAA;AAAA,EACpB,qBAAA,EAAuB,yBAAA;AAAA,EACvB,eAAA,EAAiB,mBAAA;AAAA,EACjB,wBAAA,EAA0B,6BAAA;AAAA,EAC1B,iBAAA,EAAmB,qBAAA;AAAA,EACnB,cAAA,EAAgB,kBAAA;AAAA,EAChB,kBAAA,EAAoB,sBAAA;AAAA,EACpB,kBAAA,EAAoB,sBAAA;AAAA,EACpB,YAAA,EAAc,gBAAA;AAAA,EACd,gBAAA,EAAkB,oBAAA;AAAA,EAClB,gBAAA,EAAkB,oBAAA;AAAA,EAClB,eAAA,EAAiB,mBAAA;AAAA,EACjB,iBAAA,EAAmB,qBAAA;AAAA,EACnB,cAAA,EAAgB,kBAAA;AAAA,EAChB,mBAAA,EAAqB,wBAAA;AAAA,EACrB,aAAA,EAAe,gBAAA;AAAA,EACf,SAAA,EAAW,YAAA;AAAA,EACX,wBAAA,EAA0B;AAC5B;AC7EO,SAAS,8BACd,KAAA,EACQ;AACR,EAAA,MAAM;AAAA,IACJ,OAAA;AAAA,IACA,KAAA,GAAQ,WAAA;AAAA,IACR,UAAA,GAAa,IAAA;AAAA,IACb,SAAA,GAAY,IAAA;AAAA,IACZ,UAAA,GAAa,IAAA;AAAA,IACb,YAAA;AAAA,IACA,KAAA,GAAQ;AAAA,GACV,GAAI,KAAA;AAEJ,EAAA,MAAM,GAAA,GAAM,IAAI,GAAA,CAAI,0BAAA,EAA4B,OAAO,CAAA;AACvD,EAAA,GAAA,CAAI,YAAA,CAAa,GAAA,CAAI,OAAA,EAAS,KAAK,CAAA;AACnC,EAAA,GAAA,CAAI,YAAA,CAAa,GAAA,CAAI,YAAA,EAAc,MAAA,CAAO,UAAU,CAAC,CAAA;AACrD,EAAA,GAAA,CAAI,YAAA,CAAa,GAAA,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AAA,EAAY,yBAAA;AAAA,MAEZ,QAAA,kBAAA,GAAA;AAAA,QAAC,QAAA;AAAA,QAAA;AAAA,UACC,GAAA,EAAK,SAAA;AAAA,UACL,GAAA;AAAA,UACA,KAAA,EAAM,yBAAA;AAAA,UACN,KAAA,EAAM,MAAA;AAAA,UACN,MAAA,EAAO,MAAA;AAAA,UACP,WAAA,EAAY,GAAA;AAAA,UACZ,SAAA,EAAU,IAAA;AAAA,UACV,OAAA,EAAQ,MAAA;AAAA,UACR,MAAA,EAAQ,UAAA;AAAA,UACR,OAAA,EAAS,WAAA;AAAA,UACT,KAAA,EAAO,EAAE,MAAA,EAAQ,MAAA;AAAO;AAAA;AAC1B;AAAA,GACF;AAEJ,CAAC","file":"community-header.mjs","sourcesContent":["/**\n * Theming props for the Community Header Widget.\n * These map to CSS custom properties used internally.\n */\nexport interface CommunityHeaderThemingProps {\n  /** Primary color */\n  headerPrimaryColor?: string;\n  /** Container background color */\n  headerBackgroundColor?: string;\n  /** Primary text color */\n  headerTextColor?: string;\n  /** Secondary text color */\n  headerSecondaryTextColor?: string;\n  /** Border color */\n  headerBorderColor?: string;\n  /** Search input background */\n  headerSearchBg?: string;\n  /** Search input border */\n  headerSearchBorder?: string;\n  /** Search input border radius */\n  headerSearchRadius?: string;\n  /** Stat card background */\n  headerStatBg?: string;\n  /** Stat card border radius */\n  headerStatRadius?: string;\n  /** Font family */\n  headerFontFamily?: string;\n  /** Title font size */\n  headerTitleSize?: string;\n  /** Title font weight */\n  headerTitleWeight?: string;\n  /** Stat value font size */\n  headerStatSize?: string;\n  /** Stat label font size */\n  headerStatLabelSize?: string;\n  /** Container padding */\n  headerPadding?: string;\n  /** Gap between elements */\n  headerGap?: string;\n  /** Transition duration */\n  headerTransitionDuration?: string;\n}\n\n/**\n * Core configuration props for the Community Header Widget.\n */\nexport interface CommunityHeaderWidgetProps\n  extends CommunityHeaderThemingProps {\n  /** Base URL of the Legion application (required) */\n  baseUrl: string;\n  /** Community title. Default: \"Community\" */\n  title?: string;\n  /** Show search bar. Default: true */\n  showSearch?: boolean;\n  /** Show stats section. Default: true */\n  showStats?: boolean;\n  /** Show online count. Default: true */\n  showOnline?: boolean;\n  /** Community URL prefix */\n  communityUrl?: string;\n  /** Theme preset. Default: \"light\" */\n  theme?: \"light\" | \"dark\";\n  /** Widget height CSS value. Default: \"auto\" */\n  height?: string;\n  /** Widget width CSS value. Default: \"100%\" */\n  width?: 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 kebab-case query params.\n */\nexport const HEADER_THEMING_PROP_TO_PARAM: Record<\n  keyof CommunityHeaderThemingProps,\n  string\n> = {\n  headerPrimaryColor: \"header-primary-color\",\n  headerBackgroundColor: \"header-background-color\",\n  headerTextColor: \"header-text-color\",\n  headerSecondaryTextColor: \"header-secondary-text-color\",\n  headerBorderColor: \"header-border-color\",\n  headerSearchBg: \"header-search-bg\",\n  headerSearchBorder: \"header-search-border\",\n  headerSearchRadius: \"header-search-radius\",\n  headerStatBg: \"header-stat-bg\",\n  headerStatRadius: \"header-stat-radius\",\n  headerFontFamily: \"header-font-family\",\n  headerTitleSize: \"header-title-size\",\n  headerTitleWeight: \"header-title-weight\",\n  headerStatSize: \"header-stat-size\",\n  headerStatLabelSize: \"header-stat-label-size\",\n  headerPadding: \"header-padding\",\n  headerGap: \"header-gap\",\n  headerTransitionDuration: \"header-transition-duration\",\n};\n\n","import {\n  useRef,\n  useCallback,\n  useMemo,\n  forwardRef,\n  useImperativeHandle,\n} from \"react\";\nimport {\n  type CommunityHeaderWidgetProps,\n  type CommunityHeaderThemingProps,\n  HEADER_THEMING_PROP_TO_PARAM,\n} from \"./types\";\n\n/**\n * Ref handle exposed by LegionCommunityHeader for imperative control.\n */\nexport interface LegionCommunityHeaderHandle {\n  /** Reload the widget iframe */\n  refresh: () => void;\n}\n\n/**\n * Build the iframe src URL from widget props.\n */\nexport function buildCommunityHeaderWidgetUrl(\n  props: CommunityHeaderWidgetProps\n): string {\n  const {\n    baseUrl,\n    title = \"Community\",\n    showSearch = true,\n    showStats = true,\n    showOnline = true,\n    communityUrl,\n    theme = \"light\",\n  } = props;\n\n  const url = new URL(\"/widget/community-header\", baseUrl);\n  url.searchParams.set(\"title\", title);\n  url.searchParams.set(\"showSearch\", String(showSearch));\n  url.searchParams.set(\"showStats\", String(showStats));\n  url.searchParams.set(\"showOnline\", String(showOnline));\n  url.searchParams.set(\"theme\", theme);\n\n  if (communityUrl) {\n    url.searchParams.set(\"communityUrl\", communityUrl);\n  }\n\n  // Append theming params\n  const themingKeys = Object.keys(HEADER_THEMING_PROP_TO_PARAM) as Array<\n    keyof CommunityHeaderThemingProps\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(HEADER_THEMING_PROP_TO_PARAM[key], String(value));\n    }\n  }\n\n  return url.toString();\n}\n\n/**\n * LegionCommunityHeader – a React component that embeds the Legion\n * Community Header widget via an iframe.\n */\nexport const LegionCommunityHeader = forwardRef<\n  LegionCommunityHeaderHandle,\n  CommunityHeaderWidgetProps\n>(function LegionCommunityHeader(props, ref) {\n  const {\n    title = \"Community\",\n    showSearch,\n    showStats,\n    showOnline,\n    communityUrl,\n    theme = \"light\",\n    height = \"auto\",\n    width = \"100%\",\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    () => buildCommunityHeaderWidgetUrl(props),\n    [\n      baseUrl, title, showSearch, showStats, showOnline, communityUrl, theme,\n      ...Object.keys(HEADER_THEMING_PROP_TO_PARAM).map(\n        (k) => rest[k as keyof typeof rest]\n      ),\n    ]\n  );\n\n  const handleLoad = useCallback(() => {\n    onLoad?.({ widget: \"community-header\", theme });\n  }, [theme, onLoad]);\n\n  const handleError = useCallback(() => {\n    onError?.(\"Failed to load community header widget\");\n  }, [onError]);\n\n  const resolvedHeight = height === \"auto\" ? \"120px\" : height;\n\n  return (\n    <div\n      className={className}\n      style={{ width, height: resolvedHeight, ...style }}\n      data-testid=\"legion-community-header\"\n    >\n      <iframe\n        ref={iframeRef}\n        src={src}\n        title=\"Community Header Widget\"\n        width=\"100%\"\n        height=\"100%\"\n        frameBorder=\"0\"\n        scrolling=\"no\"\n        loading=\"lazy\"\n        onLoad={handleLoad}\n        onError={handleError}\n        style={{ border: \"none\" }}\n      />\n    </div>\n  );\n});\n\n"]}