import type { LoadingVariousProps } from "$/types/LoadingTypes";
import { usePrefersReducedMotion } from "$/util/AccessibilityUtil";


export default function SpinningTadpole({
	size,
	width,
	height,
	className,
	animationDuration = 750,
	color,
	stroke,
	fill,
	ariaLabel = "Loading"
}: Readonly<LoadingVariousProps>){
	//https://github.com/n3r4zzurr0/svg-spinners/blob/main/svg-smil/tadpole.svg
	const reducedMotion = usePrefersReducedMotion();
	const dur = reducedMotion ? animationDuration / 100 : animationDuration / 1000;


	return (
		<svg
			width={size ?? width}
			height={size ?? height}
			role="status"
			aria-live="polite"
			aria-label={ariaLabel}
			viewBox="0 0 24 24"
			xmlns="http://www.w3.org/2000/svg"
		>
			<path
				d="M12,23a9.63,9.63,0,0,1-8-9.5,9.51,9.51,0,0,1,6.79-9.1A1.66,1.66,0,0,0,12,2.81h0a1.67,1.67,0,0,0-1.94-1.64A11,11,0,0,0,12,23Z"
				className={className}
				stroke={color ?? stroke}
				fill={color ?? fill}
			>
				<animateTransform
					attributeName="transform"
					type="rotate"
					dur={dur}
					values="0 12 12;360 12 12"
					repeatCount="indefinite"
				/>
			</path>
		</svg>
	);
}
