import { TRANSITION_STYLE } from "../constants";
import type { OrganSvgProps } from "../types";

export function ThoracicCavity({ style, colorScale, isActive = false, className }: OrganSvgProps) {
  const defaultColor = colorScale.alpha[100];
  const activeColor = colorScale.alpha[200];
  const fill = style?.fill ?? (isActive ? activeColor : defaultColor);

  return (
    <g className={className} data-organ="thoracic-cavity">
      {/* Invisible outline for interaction */}
      <path d={OUTLINE_PATH} fill="transparent" />
      {/* Thoracic cavity main shape */}
      <path
        d={THORACIC_CAVITY_PATH}
        fill={fill}
        stroke={style?.stroke}
        strokeWidth={style?.strokeWidth}
        style={{ transition: TRANSITION_STYLE }}
      />
    </g>
  );
}

const OUTLINE_PATH =
  "M16.979 1.09281C18.2305 0.144621 22.3782 -0.556411 23.5717 0.609407C23.8146 1.99688 20.0653 1.01198 18.9624 1.91605C18.0816 2.31458 16.1224 3.5767 17.6987 4.25198C20.0899 5.23722 23.9339 6.53575 26.8354 6.32913C26.8354 6.32913 27.5467 5.65118 30.0004 5.65042V37.9278C29.9386 38.1891 29.761 37.9969 29.2797 36.9864C28.469 35.09 27.4485 38.1233 26.8764 38.7764C24.2547 43.0087 19.3369 45.7767 16.5424 49.7803C13.2032 54.4573 9.3354 55.5 7.3354 55.5C5.3354 55.5 1.48921 55.7735 0.952589 46.8946C0.187085 42.6326 -0.447585 42.8572 0.41255 38.2373C-0.476355 35.5105 1.01368 32.7392 0.655714 29.9717C0.688639 28.7097 1.39692 27.5582 1.51216 26.4512C1.60269 25.2484 1.02206 24.0897 1.38814 22.8721C3.40892 18.5695 3.23654 20.709 3.70161 15.6241C4.22857 14.1114 5.7966 13.1517 6.54146 11.7422C7.78017 9.72014 8.72286 7.48057 10.6489 5.84964C11.6654 4.93822 13.1427 4.37334 14.2622 3.66116C15.0935 2.83459 15.7649 1.84188 16.979 1.09281Z";
const THORACIC_CAVITY_PATH =
  "M16.979 1.09281C18.2305 0.144621 22.3782 -0.556411 23.5717 0.609407C23.8146 1.99688 20.0653 1.01198 18.9624 1.91605C18.0816 2.31458 16.1224 3.5767 17.6987 4.25198C20.0899 5.23722 23.9339 6.53575 26.8354 6.32913C26.8354 6.32913 27.5467 5.65118 30.0004 5.65042V37.9278C29.9386 38.1891 29.761 37.9969 29.2797 36.9864C28.469 35.09 27.4485 38.1233 26.8764 38.7764C24.2547 43.0087 19.3369 45.7767 16.5424 49.7803C13.2032 54.4573 9.3354 55.5 7.3354 55.5C5.3354 55.5 1.48921 55.7735 0.952589 46.8946C0.187085 42.6326 -0.447585 42.8572 0.41255 38.2373C-0.476355 35.5105 1.01368 32.7392 0.655714 29.9717C0.688639 28.7097 1.39692 27.5582 1.51216 26.4512C1.60269 25.2484 1.02206 24.0897 1.38814 22.8721C3.40892 18.5695 3.23654 20.709 3.70161 15.6241C4.22857 14.1114 5.7966 13.1517 6.54146 11.7422C7.78017 9.72014 8.72286 7.48057 10.6489 5.84964C11.6654 4.93822 13.1427 4.37334 14.2622 3.66116C15.0935 2.83459 15.7649 1.84188 16.979 1.09281ZM4.31489 48.2295C1.788 46.4585 3.4792 53.4479 7.3354 52.7471C9.1751 52.6917 11.4307 51.8977 12.5708 50.6836H12.5747C14.2206 48.9421 8.13414 51.4251 4.31489 48.2295ZM3.08833 41.0899C1.3186 39.7319 1.82862 42.3447 2.32661 43.2598C3.68892 45.2782 6.42188 46.3887 8.6772 47.7207C10.4017 48.5215 14.3241 47.4916 15.5258 46.0635L15.5297 46.0674C16.5913 44.7688 14.4232 44.8095 13.4106 44.8575C9.53373 45.3408 6.05979 43.1673 3.08833 41.0899ZM3.43403 34.9424C3.13774 34.6841 2.58586 34.1891 2.2895 34.5616C1.17828 40.4657 15.1676 45.8126 19.3286 40.6133C21.122 38.0271 10.3563 41.9751 3.43403 34.9424ZM3.38814 28.5762C1.9271 31.5467 3.94836 34.4952 11.8667 36.5469V36.5508C21.9333 40.3257 29.6175 28.5922 25.4819 31.4366C20.7448 34.9163 14.5869 34.7871 9.52876 31.6358C7.67675 30.8607 5.1413 28.6389 3.38814 28.5762ZM28.0004 33.1153C26.988 33.1226 23.6336 36.6762 24.3168 37.2002C24.8148 37.3035 25.4816 36.7798 25.7944 36.4219C26.3788 35.6617 28.1074 33.8164 28.0004 33.1153ZM26.0366 25.2998C11.3851 31.484 5.38922 18.7505 3.87056 22.2744C2.80909 25.0308 7.4018 27.2885 9.36079 28.4951C11.3198 29.7018 14.3736 31.8538 18.769 31.4922C22.3043 31.1564 26.5634 29.3699 27.1108 26.001C27.3742 25.1043 26.9544 24.9788 26.0366 25.2998ZM10.184 16.8643C9.28682 16.4436 6.99836 14.9569 6.57857 15.4551C3.71419 18.85 10.4843 21.2154 12.645 22.2744C17.353 24.5769 21.1146 24.8492 25.7651 23.0264C27.1562 22.65 28.65 20.4328 26.3823 20.2188C20.1104 20.5324 16.6123 20.0338 10.184 16.8643ZM10.6567 10.5176C8.87062 9.46604 8.44673 11.7313 9.23677 12.7129C11.0394 16.2111 28.8563 22.1372 27.6586 15.377C25.9794 14.3697 22.5715 14.6684 20.4643 14.1924C16.9373 13.6942 13.5748 12.2371 10.6528 10.5176H10.6567ZM17.02 6.3887C15.6701 5.51422 13.5875 5.19637 12.7807 6.72366V6.72073C11.1066 10.3108 26.2407 13.5057 27.8022 12.4141C27.3618 7.90139 20.5925 8.20396 17.02 6.3887Z";
