import type { LoadingBlocksProps } from "$/types/Loading";


export default function WaveBlocks({
	width,
	height,
	className,
	animationDuration = 0.6,
	stroke,
	fill
}: LoadingBlocksProps){
	//https://github.com/n3r4zzurr0/svg-spinners/blob/main/svg-smil/blocks-wave.svg
	const id = crypto.randomUUID().replaceAll("-", "");


	return (
		<svg
			width={width}
			height={height}
			viewBox="0 0 24 24"
			xmlns="http://www.w3.org/2000/svg"
		>
			<rect
				x="1"
				y="1"
				width="7.33"
				height="7.33"
				className={className}
				stroke={stroke}
				fill={fill}
			>
				<animate
					id={`rectangle1_1_${id}`}
					begin={`0;rectangle9_1_${id}.end+${animationDuration / 3}s`}
					attributeName="x"
					dur={animationDuration}
					values="1;4;1"
				/>
				<animate
					begin={`0;rectangle9_1_${id}.end+${animationDuration / 3}s`}
					attributeName="y"
					dur={animationDuration}
					values="1;4;1"
				/>
				<animate
					begin={`0;rectangle9_1_${id}.end+${animationDuration / 3}s`}
					attributeName="width"
					dur={animationDuration}
					values="7.33;1.33;7.33"
				/>
				<animate
					begin={`0;rectangle9_1_${id}.end+${animationDuration / 3}s`}
					attributeName="height"
					dur={animationDuration}
					values="7.33;1.33;7.33"
				/>
			</rect>
			<rect
				x="8.33"
				y="1"
				width="7.33"
				height="7.33"
				className={className}
				stroke={stroke}
				fill={fill}
			>
				<animate
					begin={`rectangle1_1_${id}.begin+${animationDuration / 6}s`}
					attributeName="x"
					dur={animationDuration}
					values="8.33;11.33;8.33"
				/>
				<animate
					begin={`rectangle1_1_${id}.begin+${animationDuration / 6}s`}
					attributeName="y"
					dur={animationDuration}
					values="1;4;1"
				/>
				<animate
					begin={`rectangle1_1_${id}.begin+${animationDuration / 6}s`}
					attributeName="width"
					dur={animationDuration}
					values="7.33;1.33;7.33"
				/>
				<animate
					begin={`rectangle1_1_${id}.begin+${animationDuration / 6}s`}
					attributeName="height"
					dur={animationDuration}
					values="7.33;1.33;7.33"
				/>
			</rect>
			<rect
				x="1"
				y="8.33"
				width="7.33"
				height="7.33"
				className={className}
				stroke={stroke}
				fill={fill}
			>
				<animate
					begin={`rectangle1_1_${id}.begin+${animationDuration / 6}s`}
					attributeName="x"
					dur={animationDuration}
					values="1;4;1"
				/>
				<animate
					begin={`rectangle1_1_${id}.begin+${animationDuration / 6}s`}
					attributeName="y"
					dur={animationDuration}
					values="8.33;11.33;8.33"
				/>
				<animate
					begin={`rectangle1_1_${id}.begin+${animationDuration / 6}s`}
					attributeName="width"
					dur={animationDuration}
					values="7.33;1.33;7.33"
				/>
				<animate
					begin={`rectangle1_1_${id}.begin+${animationDuration / 6}s`}
					attributeName="height"
					dur={animationDuration}
					values="7.33;1.33;7.33"
				/>
			</rect>
			<rect
				x="15.66"
				y="1"
				width="7.33"
				height="7.33"
				className={className}
				stroke={stroke}
				fill={fill}
			>
				<animate
					begin={`rectangle1_1_${id}.begin+${animationDuration / 3}s`}
					attributeName="x"
					dur={animationDuration}
					values="15.66;18.66;15.66"
				/>
				<animate
					begin={`rectangle1_1_${id}.begin+${animationDuration / 3}s`}
					attributeName="y"
					dur={animationDuration}
					values="1;4;1"
				/>
				<animate
					begin={`rectangle1_1_${id}.begin+${animationDuration / 3}s`}
					attributeName="width"
					dur={animationDuration}
					values="7.33;1.33;7.33"
				/>
				<animate
					begin={`rectangle1_1_${id}.begin+${animationDuration / 3}s`}
					attributeName="height"
					dur={animationDuration}
					values="7.33;1.33;7.33"
				/>
			</rect>
			<rect
				x="8.33"
				y="8.33"
				width="7.33"
				height="7.33"
				className={className}
				stroke={stroke}
				fill={fill}
			>
				<animate
					begin={`rectangle1_1_${id}.begin+${animationDuration / 3}s`}
					attributeName="x"
					dur={animationDuration}
					values="8.33;11.33;8.33"
				/>
				<animate
					begin={`rectangle1_1_${id}.begin+${animationDuration / 3}s`}
					attributeName="y"
					dur={animationDuration}
					values="8.33;11.33;8.33"
				/>
				<animate
					begin={`rectangle1_1_${id}.begin+${animationDuration / 3}s`}
					attributeName="width"
					dur={animationDuration}
					values="7.33;1.33;7.33"
				/>
				<animate
					begin={`rectangle1_1_${id}.begin+${animationDuration / 3}s`}
					attributeName="height"
					dur={animationDuration}
					values="7.33;1.33;7.33"
				/>
			</rect>
			<rect
				x="1"
				y="15.66"
				width="7.33"
				height="7.33"
				className={className}
				stroke={stroke}
				fill={fill}
			>
				<animate
					begin={`rectangle1_1_${id}.begin+${animationDuration / 3}s`}
					attributeName="x"
					dur={animationDuration}
					values="1;4;1"
				/>
				<animate
					begin={`rectangle1_1_${id}.begin+${animationDuration / 3}s`}
					attributeName="y"
					dur={animationDuration}
					values="15.66;18.66;15.66"
				/>
				<animate
					begin={`rectangle1_1_${id}.begin+${animationDuration / 3}s`}
					attributeName="width"
					dur={animationDuration}
					values="7.33;1.33;7.33"
				/>
				<animate
					begin={`rectangle1_1_${id}.begin+${animationDuration / 3}s`}
					attributeName="height"
					dur={animationDuration}
					values="7.33;1.33;7.33"
				/>
			</rect>
			<rect
				x="15.66"
				y="8.33"
				width="7.33"
				height="7.33"
				className={className}
				stroke={stroke}
				fill={fill}
			>
				<animate
					begin={`rectangle1_1_${id}.begin+${animationDuration / 2}s`}
					attributeName="x"
					dur={animationDuration}
					values="15.66;18.66;15.66"
				/>
				<animate
					begin={`rectangle1_1_${id}.begin+${animationDuration / 2}s`}
					attributeName="y"
					dur={animationDuration}
					values="8.33;11.33;8.33"
				/>
				<animate
					begin={`rectangle1_1_${id}.begin+${animationDuration / 2}s`}
					attributeName="width"
					dur={animationDuration}
					values="7.33;1.33;7.33"
				/>
				<animate
					begin={`rectangle1_1_${id}.begin+${animationDuration / 2}s`}
					attributeName="height"
					dur={animationDuration}
					values="7.33;1.33;7.33"
				/>
			</rect>
			<rect
				x="8.33"
				y="15.66"
				width="7.33"
				height="7.33"
				className={className}
				stroke={stroke}
				fill={fill}
			>
				<animate
					begin={`rectangle1_1_${id}.begin+${animationDuration / 2}s`}
					attributeName="x"
					dur={animationDuration}
					values="8.33;11.33;8.33"
				/>
				<animate
					begin={`rectangle1_1_${id}.begin+${animationDuration / 2}s`}
					attributeName="y"
					dur={animationDuration}
					values="15.66;18.66;15.66"
				/>
				<animate
					begin={`rectangle1_1_${id}.begin+${animationDuration / 2}s`}
					attributeName="width"
					dur={animationDuration}
					values="7.33;1.33;7.33"
				/>
				<animate
					begin={`rectangle1_1_${id}.begin+${animationDuration / 2}s`}
					attributeName="height"
					dur={animationDuration}
					values="7.33;1.33;7.33"
				/>
			</rect>
			<rect
				x="15.66"
				y="15.66"
				width="7.33"
				height="7.33"
				className={className}
				stroke={stroke}
				fill={fill}
			>
				<animate
					id={`rectangle9_1_${id}`}
					begin={`rectangle1_1_${id}.begin+${animationDuration * 2 / 3}s`}
					attributeName="x"
					dur={animationDuration}
					values="15.66;18.66;15.66"
				/>
				<animate
					begin={`rectangle1_1_${id}.begin+${animationDuration * 2 / 3}s`}
					attributeName="y"
					dur={animationDuration}
					values="15.66;18.66;15.66"
				/>
				<animate
					begin={`rectangle1_1_${id}.begin+${animationDuration * 2 / 3}s`}
					attributeName="width"
					dur={animationDuration}
					values="7.33;1.33;7.33"
				/>
				<animate
					begin={`rectangle1_1_${id}.begin+${animationDuration * 2 / 3}s`}
					attributeName="height"
					dur={animationDuration}
					values="7.33;1.33;7.33"
				/>
			</rect>
		</svg>
	);
}
