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


export default function SlidingBlocks2({
	width,
	height,
	className,
	animationDuration = 0.2,
	stroke,
	fill
}: LoadingBlocksProps){
	//https://github.com/n3r4zzurr0/svg-spinners/blob/main/svg-smil/blocks-shuffle-2.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"
				rx="1"
				width="10"
				height="10"
				className={className}
				stroke={stroke}
				fill={fill}
			>
				<animate
					id={`rectangle1_1_${id}`}
					begin={`0;rectangle2_4_${id}.end`}
					attributeName="x"
					dur={animationDuration}
					values="1;13"
					fill="freeze"
				/>
				<animate
					id={`rectangle1_2_${id}`}
					begin={`rectangle2_1_${id}.end`}
					attributeName="y"
					dur={animationDuration}
					values="1;13"
					fill="freeze"
				/>
				<animate
					id={`rectangle1_3_${id}`}
					begin={`rectangle2_2_${id}.end`}
					attributeName="x"
					dur={animationDuration}
					values="13;1"
					fill="freeze"
				/>
				<animate
					id={`rectangle1_4_${id}`}
					begin={`rectangle2_3_${id}.end`}
					attributeName="y"
					dur={animationDuration}
					values="13;1"
					fill="freeze"
				/>
			</rect>
			<rect
				x="1"
				y="13"
				rx="1"
				width="10"
				height="10"
				className={className}
				stroke={stroke}
				fill={fill}
			>
				<animate
					id={`rectangle2_1_${id}`}
					begin={`rectangle1_1_${id}.end`}
					attributeName="y"
					dur={animationDuration}
					values="13;1"
					fill="freeze"
				/>
				<animate
					id={`rectangle2_2_${id}`}
					begin={`rectangle1_2_${id}.end`}
					attributeName="x"
					dur={animationDuration}
					values="1;13"
					fill="freeze"
				/>
				<animate
					id={`rectangle2_3_${id}`}
					begin={`rectangle1_3_${id}.end`}
					attributeName="y"
					dur={animationDuration}
					values="1;13"
					fill="freeze"
				/>
				<animate
					id={`rectangle2_4_${id}`}
					begin={`rectangle1_4_${id}.end`}
					attributeName="x"
					dur={animationDuration}
					values="13;1"
					fill="freeze"
				/>
			</rect>
		</svg>
	);
}
