{"version":3,"sources":["../../../../src/components/atoms/Typography/Typography.tsx"],"names":["cva","jsx","twMerge","forwardRef"],"mappings":";;;;;;;AAWA,MAAM,kBAAA,GAAqBA,2BAAI,WAAA,EAAa;AAAA,EAC1C,QAAA,EAAU;AAAA,IACR,OAAA,EAAS;AAAA,MACP,EAAA,EAAI,mCAAA;AAAA,MACJ,EAAA,EAAI,wBAAA;AAAA,MACJ,EAAA,EAAI,wBAAA;AAAA,MACJ,IAAA,EAAM,uBAAA;AAAA,MACN,OAAA,EAAS;AAAA,KACX;AAAA,IACA,KAAA,EAAO;AAAA,MACL,OAAA,EAAS,mBAAA;AAAA,MACT,SAAA,EAAW,qBAAA;AAAA,MACX,MAAA,EAAQ,aAAA;AAAA,MACR,OAAA,EAAS;AAAA,KACX;AAAA,IACA,KAAA,EAAO;AAAA,MACL,IAAA,EAAM,WAAA;AAAA,MACN,MAAA,EAAQ,aAAA;AAAA,MACR,KAAA,EAAO,YAAA;AAAA,MACP,OAAA,EAAS;AAAA;AACX,GACF;AAAA,EACA,iBAAiB,EAAE,OAAA,EAAS,QAAQ,KAAA,EAAO,SAAA,EAAW,OAAO,MAAA;AAC/D,CAAC,CAAA;AAMD,MAAM,cAAA,GAAmE;AAAA,EACvE,EAAA,EAAI,IAAA;AAAA,EACJ,EAAA,EAAI,IAAA;AAAA,EACJ,EAAA,EAAI,IAAA;AAAA,EACJ,IAAA,EAAM,GAAA;AAAA,EACN,OAAA,EAAS;AACX,CAAA;AAmBA,SAAS,cAAA,CACP;AAAA,EACE,EAAA;AAAA,EACA,OAAA,GAAU,MAAA;AAAA,EACV,KAAA;AAAA,EACA,KAAA;AAAA,EACA,SAAA;AAAA,EACA,IAAA;AAAA,EACA,QAAA;AAAA,EACA,GAAG;AACL,CAAA,EACA,GAAA,EACA;AACA,EAAA,MAAM,SAAA,GAAa,EAAA,IAAM,cAAA,CAAe,OAAQ,CAAA;AAChD,EAAA,uBACEC,cAAA;AAAA,IAAC,SAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,SAAA,EAAWC,qBAAA;AAAA,QACT,kBAAA,CAAmB,EAAE,OAAA,EAAS,KAAA,EAAO,OAAO,CAAA;AAAA,QAC5C;AAAA,OACF;AAAA,MACC,GAAG,IAAA;AAAA,MAEH,QAAA,EAAA,IAAA,IAAQ;AAAA;AAAA,GACX;AAEJ;AAKO,MAAM,UAAA,GAAaC,gBAAA;AAAA,EACxB;AAGF","file":"Typography.cjs","sourcesContent":["import React, {\n  forwardRef,\n  type ElementType,\n  type ComponentPropsWithoutRef,\n  type ComponentPropsWithRef,\n  type JSX,\n  type ReactElement,\n} from \"react\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport { twMerge } from \"tailwind-merge\";\n\nconst typographyVariants = cva(\"font-sans\", {\n  variants: {\n    variant: {\n      h1: \"text-4xl font-bold tracking-tight\",\n      h2: \"text-3xl font-semibold\",\n      h3: \"text-2xl font-semibold\",\n      body: \"text-base font-normal\",\n      caption: \"text-xs font-medium uppercase tracking-wide\",\n    },\n    color: {\n      primary: \"text-font-primary\",\n      secondary: \"text-font-secondary\",\n      danger: \"text-danger\",\n      success: \"text-success\",\n    },\n    align: {\n      left: \"text-left\",\n      center: \"text-center\",\n      right: \"text-right\",\n      justify: \"text-justify\",\n    },\n  },\n  defaultVariants: { variant: \"body\", color: \"primary\", align: \"left\" },\n});\n\ntype VariantType = NonNullable<\n  VariantProps<typeof typographyVariants>[\"variant\"]\n>;\n\nconst defaultElement: Record<VariantType, keyof JSX.IntrinsicElements> = {\n  h1: \"h1\",\n  h2: \"h2\",\n  h3: \"h3\",\n  body: \"p\",\n  caption: \"span\",\n};\n\ntype TypographyProps = VariantProps<typeof typographyVariants> & {\n  text?: string;\n  className?: string;\n  children?: React.ReactNode;\n};\n\ntype PolymorphicProps<C extends ElementType> = {\n  as?: C;\n} & TypographyProps &\n  Omit<ComponentPropsWithoutRef<C>, keyof TypographyProps>;\n\ntype PolymorphicRef<C extends ElementType> = ComponentPropsWithRef<C>[\"ref\"];\n\nexport type TypographyComponent = <C extends ElementType = \"span\">(\n  props: PolymorphicProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null;\n\nfunction BaseTypography<C extends ElementType = \"span\">(\n  {\n    as,\n    variant = \"body\",\n    color,\n    align,\n    className,\n    text,\n    children,\n    ...rest\n  }: PolymorphicProps<C>,\n  ref: PolymorphicRef<C>\n) {\n  const Component = (as ?? defaultElement[variant!]) as ElementType;\n  return (\n    <Component\n      ref={ref}\n      className={twMerge(\n        typographyVariants({ variant, color, align }),\n        className\n      )}\n      {...rest}\n    >\n      {text ?? children}\n    </Component>\n  );\n}\n\n/**\n * Needed to allow typings to be autocompleted when using `as=\"...\"`\n * */\nexport const Typography = forwardRef(\n  BaseTypography as unknown as (\n    props: PolymorphicProps<ElementType> & { ref?: PolymorphicRef<ElementType> }\n  ) => ReactElement | null\n) as TypographyComponent;\n"]}