/**
 * mystateCONnews logo: a court-style legal-notice mark (the scales of
 * justice) and the wordmark with "CON" picked out in red. Drawn inline so it
 * takes any colour. If the CMS theme sets `logoUrl`, that uploaded image
 * replaces the mark.
 */

/** The scales-of-justice mark. `color` is the ink. */
export function LegalMark({
  size,
  color = "currentColor",
  strokeWidth = 1.6,
  className,
  style
}: {
  size?: number;
  color?: string;
  strokeWidth?: number;
  className?: string;
  style?: React.CSSProperties;
}) {
  return (
    <svg
      className={className}
      width={size}
      height={size}
      viewBox="0 0 24 24"
      fill="none"
      stroke={color}
      strokeWidth={strokeWidth}
      strokeLinecap="round"
      strokeLinejoin="round"
      aria-hidden="true"
      style={style}
    >
      <path d="M12 3v17" />
      <path d="M8 20.5h8" />
      <path d="M3.5 7.5h2c2 0 4.5-.8 6.5-2 2 1.2 4.5 2 6.5 2h2" />
      <circle cx="12" cy="4" r="1" />
      <path d="M5.5 7.5 2.5 14c.8.7 1.9 1 3 1s2.2-.3 3-1Z" />
      <path d="M18.5 7.5 15.5 14c.8.7 1.9 1 3 1s2.2-.3 3-1Z" />
    </svg>
  );
}

export function LogoMark({ size = 32, logoUrl, color }: { size?: number; logoUrl?: string; color?: string }) {
  if (logoUrl) {
    // eslint-disable-next-line @next/next/no-img-element
    return <img src={logoUrl} alt="" width={size} height={size} style={{ display: "block", objectFit: "contain" }} />;
  }
  return <LegalMark size={size} color={color} style={{ display: "block", flexShrink: 0 }} />;
}

/** "mystateCONnews" with CON in red; falls back to the plain name if the
 *  company name has no "CON" in it. */
export function Wordmark({ name, className = "logo-con" }: { name: string; className?: string }) {
  const i = name.indexOf("CON");
  if (i < 0) return <>{name}</>;
  return (
    <>
      {name.slice(0, i)}
      <span className={className}>CON</span>
      {name.slice(i + 3)}
    </>
  );
}
