{"version":3,"file":"createIcon.mjs","names":[],"sources":["../../src/utils/createIcon.tsx"],"sourcesContent":["import { forwardRef, type ReactNode } from 'react';\nimport type { IconProps } from './index';\n\n/**\n * Factory that creates a typed, accessible SVG icon component.\n *\n * The returned component is a pure function component with no hooks, so it\n * renders in React Server Components without a `'use client'` boundary.\n *\n * @param displayName - Component display name shown in React DevTools.\n * @param viewBox - SVG `viewBox` attribute value (e.g. `\"0 0 24 24\"`).\n * @param render - Function that returns the SVG content. Receives a stable, deterministic ID prefix for internal `id` attributes (e.g. gradient/mask definitions).\n * @param defaultFill - Default `fill` value applied to the `<svg>` element (e.g. `\"none\"` for stroke-based icons).\n */\nexport function createIcon(\n  displayName: string,\n  viewBox: string,\n  render: (id: string) => ReactNode,\n  defaultFill?: string,\n) {\n  // Deterministic per-component prefix instead of useId: rendering the same\n  // icon twice yields duplicate ids, but the duplicated defs are identical,\n  // so references still resolve to the correct shapes. In exchange, icons\n  // render server-side (RSC) and markup is stable across renders.\n  const iconId = `w3i-${displayName.toLowerCase()}`;\n  const Icon = forwardRef<SVGSVGElement, IconProps>((rawProps, ref) => {\n    const { title, titleId, size = '1em', width, height, ...props } = rawProps;\n    const isDecorative = !(\n      title ||\n      props['aria-label'] ||\n      props['aria-labelledby']\n    );\n    return (\n      <svg\n        xmlns=\"http://www.w3.org/2000/svg\"\n        viewBox={viewBox}\n        width={width ?? size}\n        height={height ?? size}\n        fill={defaultFill}\n        aria-hidden={isDecorative || undefined}\n        role={isDecorative ? undefined : 'img'}\n        aria-labelledby={title && titleId ? titleId : undefined}\n        ref={ref}\n        {...props}\n      >\n        {title && <title id={titleId}>{title}</title>}\n        {render(iconId)}\n      </svg>\n    );\n  });\n  Icon.displayName = displayName;\n  return Icon;\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA,SAAgB,WACd,aACA,SACA,QACA,aACA;CAKA,MAAM,SAAS,OAAO,YAAY,YAAY;CAC9C,MAAM,OAAO,YAAsC,UAAU,QAAQ;EACnE,MAAM,EAAE,OAAO,SAAS,OAAO,OAAO,OAAO,QAAQ,GAAG,UAAU;EAClE,MAAM,eAAe,EACnB,SACA,MAAM,iBACN,MAAM;EAER,OACE,qBAAC,OAAD;GACE,OAAM;GACG;GACT,OAAO,SAAS;GAChB,QAAQ,UAAU;GAClB,MAAM;GACN,eAAa,gBAAgB,KAAA;GAC7B,MAAM,eAAe,KAAA,IAAY;GACjC,mBAAiB,SAAS,UAAU,UAAU,KAAA;GACzC;GACL,GAAI;GAVN,UAAA,CAYG,SAAS,oBAAC,SAAD;IAAO,IAAI;IAAU,UAAA;GAAa,CAAA,GAC3C,OAAO,MAAM,CACX;;CAET,CAAC;CACD,KAAK,cAAc;CACnB,OAAO;AACT"}