---

import type { HTMLTag, Polymorphic } from 'astro/types';
import { clsx } from 'clsx';
import { twMerge } from '@/utils/twMerge';
import { shared } from './styles';

type Props<Tag extends HTMLTag = 'p'> = Polymorphic<{ as: Tag }> & {
  maxWidth?: boolean;
  class?: string;
};

const { as: Tag = 'p', maxWidth = true, class: className, ...props } = Astro.props;
---

<Tag
  class={twMerge(clsx(shared.p, maxWidth && shared.prose), className)}
  {...props}
>
  <slot />
</Tag>
