import type { ReactNode, SVGProps } from "react";

export type SupplyFeatureIconProps = SVGProps<SVGSVGElement> & {
  size?: number;
};

type SupplyIconFrameProps = SupplyFeatureIconProps & {
  children: ReactNode;
};

function SupplyIconFrame({ children, size = 20, ...props }: SupplyIconFrameProps) {
  return (
    <svg
      width={size}
      height={size}
      viewBox="0 0 24 24"
      fill="none"
      stroke="currentColor"
      strokeWidth="1.8"
      strokeLinecap="round"
      strokeLinejoin="round"
      focusable="false"
      {...props}
    >
      {children}
    </svg>
  );
}

export function PipeFeatureIcon(props: SupplyFeatureIconProps) {
  return (
    <SupplyIconFrame {...props}>
      <circle cx="3.5" cy="12" r="1.75" />
      <circle cx="20.5" cy="12" r="1.75" />
      <path d="M5.25 9.5h13.5M5.25 14.5h13.5" />
    </SupplyIconFrame>
  );
}

export function JunctionFeatureIcon(props: SupplyFeatureIconProps) {
  return (
    <SupplyIconFrame {...props}>
      <circle cx="12" cy="12" r="5" />
      <circle cx="12" cy="12" r="1.75" />
      <path d="M12 2.5V7M2.5 12H7M17 12h4.5M12 17v4.5" />
    </SupplyIconFrame>
  );
}

export function ValveFeatureIcon(props: SupplyFeatureIconProps) {
  return (
    <SupplyIconFrame {...props}>
      <path d="M3.5 12h4.75M15.75 12h4.75" />
      <path d="m8.25 7 7.5 5-7.5 5V7Z" />
      <path d="m15.75 7-7.5 5 7.5 5V7Z" />
      <path d="M12 7V3.5M9.5 3.5h5" />
    </SupplyIconFrame>
  );
}

export function ReservoirFeatureIcon(props: SupplyFeatureIconProps) {
  return (
    <SupplyIconFrame {...props}>
      <path d="M5 8.5c0-2.2 14-2.2 14 0v7c0 2.2-14 2.2-14 0v-7Z" />
      <path d="M5 8.5c0 2.2 14 2.2 14 0" />
      <path d="M5 12c0 2.2 14 2.2 14 0" />
      <path d="M8 19.5h8" />
    </SupplyIconFrame>
  );
}

export function ScadaFeatureIcon(props: SupplyFeatureIconProps) {
  return (
    <SupplyIconFrame {...props}>
      <circle cx="12" cy="7.5" r="1.75" />
      <path d="M8.25 4.25a5.25 5.25 0 0 0 0 6.5M15.75 4.25a5.25 5.25 0 0 1 0 6.5" />
      <path d="M5.25 2.25a9 9 0 0 0 0 10.5M18.75 2.25a9 9 0 0 1 0 10.5" />
      <path d="M12 9.25v5.25M3.5 18h4l1.5-3 2.75 6 2.5-5 1.25 2h5" />
    </SupplyIconFrame>
  );
}

export function PumpFeatureIcon(props: SupplyFeatureIconProps) {
  return (
    <SupplyIconFrame {...props}>
      <circle cx="9.5" cy="13.5" r="6" />
      <circle cx="9.5" cy="13.5" r="1.25" />
      <path d="M9.5 12.25V8.5M10.75 13.5h3.75M8.65 14.4 6.2 16.85" />
      <path d="M9.5 7.5V3.5h10v5M3.5 13.5H1.75" />
      <path d="m17 6 2.5 2.5L22 6" />
    </SupplyIconFrame>
  );
}
