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

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

  return (
    <g className={className} data-organ="limbs">
      {/* Invisible outline for interaction */}
      <path d={OUTLINE_ARM_PATH} fill="transparent" />
      {/* Limbs */}
      <path
        d={LEG_PATH}
        fill={fill}
        stroke={style?.stroke}
        strokeWidth={style?.strokeWidth}
        style={{ transition: TRANSITION_STYLE }}
      />
      <path
        d={ARM_A_PATH}
        fill={fill}
        stroke={style?.stroke}
        strokeWidth={style?.strokeWidth}
        style={{ transition: TRANSITION_STYLE }}
      />
      <path
        d={ARM_B_PATH}
        fill={fill}
        stroke={style?.stroke}
        strokeWidth={style?.strokeWidth}
        style={{ transition: TRANSITION_STYLE }}
      />
    </g>
  );
}

const OUTLINE_ARM_PATH =
  "M75.0376 0.000741462C75.1455 -0.00446766 75.2385 0.0185036 75.311 0.0466399L76.2339 0.35914C76.4201 0.41922 76.6133 0.479488 76.7993 0.534921L77.3227 0.681406L77.3872 0.697031L77.4448 0.728281C77.8255 0.929277 78.0916 1.29483 78.2827 1.66187C78.3276 1.7482 78.3691 1.83929 78.4097 1.93238C78.4253 1.85177 78.4468 1.77314 78.4761 1.69801C78.6321 1.29802 78.9488 1.09326 79.2905 0.971445C79.6035 0.859871 80.0215 0.789112 80.4995 0.707773C81.0606 0.612329 81.5979 0.658069 81.9761 1.02809C82.3318 1.37617 82.3978 1.87442 82.4028 2.27809C82.4081 2.69998 82.345 3.19609 82.2886 3.66969C82.2306 4.15632 82.1749 4.64776 82.1743 5.12965L82.1977 5.81129C82.3333 9.20228 82.7489 12.318 83.2104 15.2576C83.7009 18.3809 84.2496 21.3372 84.5552 24.1736C85.3084 31.1711 86.4232 35.1709 87.1606 37.1043C87.3191 37.4494 87.4312 37.747 87.4927 38.0017C87.5523 38.249 87.5816 38.5215 87.5005 38.7722C87.4036 39.0717 87.1762 39.2595 86.9097 39.3308C86.6849 39.3908 86.4546 39.3634 86.2768 39.3269C85.9161 39.2528 85.4883 39.0745 85.1304 38.9255C84.7378 38.7622 84.4139 38.6272 84.1723 38.572L84.1391 38.5652L84.1069 38.5535C83.8368 38.4551 83.6201 38.3823 83.4175 38.3113C83.2257 38.2441 83.0397 38.1759 82.8804 38.0955C82.7347 38.022 82.5881 37.9245 82.4624 37.7859C82.4688 37.8294 82.474 37.8719 82.4751 37.9128C82.4802 38.1005 82.4378 38.284 82.3823 38.4441C82.271 38.7651 82.0687 39.097 81.8393 39.3816C81.6095 39.6667 81.3233 39.9412 81.0181 40.1267C80.738 40.2969 80.3017 40.4742 79.8647 40.2908L79.6548 40.2029L79.5688 39.992C78.8096 38.1383 78.3304 35.5411 77.9975 32.6238C77.6635 29.6959 77.472 26.396 77.3071 23.115C77.1418 19.8269 77.003 16.5608 76.7759 13.6746C76.548 10.7798 76.234 8.3152 75.7309 6.62086C75.6478 6.35563 75.1874 4.8056 74.8325 3.35035C74.6535 2.61625 74.4956 1.88239 74.4302 1.34547C74.3992 1.09133 74.3798 0.819325 74.4175 0.605234C74.4335 0.514365 74.4795 0.306634 74.6567 0.153085C74.7603 0.0633896 74.8926 0.00774985 75.0376 0.000741462Z";
const ARM_A_PATH =
  "M76.2591 5.91508C76.1195 5.47456 74.3985 -0.330432 75.1257 0.0147994C75.5396 0.16328 76.5301 0.49839 77.1887 0.664855C78.13 1.16186 78.5153 3.65933 78.6639 5.20939C80.3199 14.5365 78.3002 30.2129 81.8368 37.1324C82.3033 37.629 80.823 39.5463 80.0784 39.2339C77.1628 32.1153 78.3433 12.9348 76.2591 5.91508Z";
const ARM_B_PATH =
  "M80.5927 0.699994C82.5801 0.361916 81.623 2.50052 81.6252 4.59545C81.8344 11.9773 83.4012 18.0455 84.0085 23.6833C84.767 30.7298 85.8942 34.7808 86.6533 36.7654C87.8978 39.4599 85.4873 37.7592 84.2955 37.4867C82.1073 36.6898 82.7145 37.3582 82.9172 32.5225C83.0972 28.1729 81.534 20.5908 81.3636 19.3164C81.1931 18.0409 79.6368 6.64123 79.2027 3.84486C78.7674 1.04302 78.6051 1.0382 80.5927 0.699994Z";
const LEG_PATH =
  "M2.9609 201.924L3.01106 201.874L2.9609 201.924ZM3.10133 201.764C3.05118 201.684 2.94084 201.724 2.93081 201.814C0.292715 202.883 1.61678 198.735 1.60675 197.276C1.70705 195.937 1.71709 191.989 1.66693 187.091C1.27573 175.817 1.82742 162.104 0.262623 151.6C-0.148639 150.23 -0.178731 148.921 0.924654 148.711C0.904592 148.171 0.734069 147.562 0.854439 147.292C1.29579 146.062 2.89069 146.652 3.91383 146.602C6.19081 146.732 9.24017 145.972 9.6414 148.401C4.58589 156.267 6.06041 162.514 5.77955 173.278C5.98017 183.523 6.06041 193.278 8.50792 201.194C9.14989 203.413 7.84589 203.363 6.42152 202.244C5.31813 201.834 4.04423 202.613 3.11136 201.764H3.10133ZM2.9609 201.924L2.98096 201.894L2.95087 201.924H2.9609ZM3.20164 162.454C3.41229 172.929 4.37524 183.633 3.65303 193.848C3.6129 194.468 2.86059 195.977 2.95087 193.738C3.29192 184.842 2.22865 171.679 2.22865 162.234C2.22865 159.356 3.17155 160.065 3.21167 162.454H3.20164Z";
