import { useBlockProps, InnerBlocks } from "@wordpress/block-editor";
import ShapeA from "./shapeA.jsx";
import ShapeB from "./shapeB.jsx";
import ShapeC from "./shapeC.jsx";
export default function save({ attributes }) {
	const {
		backgroundColor,
		textColor,
		hasLightBackground,
		hasBackgroundColor,
		blockVariant,
		align,
		shapeType,
		borderColor,
	} = attributes;

	const lightnessClass = hasLightBackground
		? "content-box--bg-light"
		: "content-box--bg-dark";

	const alignClass =
		align === "full"
			? "alignfull"
			: align === "wide"
				? "alignwide"
				: "aligncontained";

	return (
		<section
			{...useBlockProps.save({
				className: `content-box content-box--variant-${blockVariant} content-box--${shapeType} ${lightnessClass} ${alignClass}`,
				style: {
					"--content-box-text-color": textColor ?? "inherit",
					"--content-box-background-color":
						blockVariant === "backgrounded" ||
						blockVariant === "framed-backgrounded"
							? backgroundColor
							: "transparent",
				},
			})}
		>
			{blockVariant === "backgrounded" &&
				backgroundColor &&
				shapeType === "shapeA" && (
					<ShapeA backgroundColor={backgroundColor} borderColor={"none"} />
				)}
			{blockVariant === "backgrounded" &&
				backgroundColor &&
				shapeType === "shapeB" && (
					<ShapeB backgroundColor={backgroundColor} borderColor={"none"} />
				)}
			{blockVariant === "backgrounded" &&
				backgroundColor &&
				shapeType === "shapeC" && (
					<ShapeC backgroundColor={backgroundColor} borderColor={"none"} />
				)}
			{blockVariant === "framed" &&
				backgroundColor &&
				shapeType === "shapeA" && (
					<ShapeA backgroundColor={"none"} borderColor={borderColor} />
				)}
			{blockVariant === "framed" &&
				backgroundColor &&
				shapeType === "shapeB" && (
					<ShapeB backgroundColor={"none"} borderColor={borderColor} />
				)}
			{blockVariant === "framed" &&
				backgroundColor &&
				shapeType === "shapeC" && (
					<ShapeC backgroundColor={"none"} borderColor={borderColor} />
				)}
			{blockVariant === "framed-backgrounded" &&
				backgroundColor &&
				shapeType === "shapeA" && (
					<ShapeA backgroundColor={backgroundColor} borderColor={borderColor} />
				)}
			{blockVariant === "framed-backgrounded" &&
				backgroundColor &&
				shapeType === "shapeB" && (
					<ShapeB backgroundColor={backgroundColor} borderColor={borderColor} />
				)}
			{blockVariant === "framed-backgrounded" &&
				backgroundColor &&
				shapeType === "shapeC" && (
					<ShapeC backgroundColor={backgroundColor} borderColor={borderColor} />
				)}
			<div className="content-box__innerblocks">
				<InnerBlocks.Content />
			</div>
		</section>
	);
}
