import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import style from "./style.module.css";
import Carousel from "./carousel";
import WheelFrame from "./wheel-frame";
import { useEffect, useState } from "react";
export default function BlockSelector({ gameRef, staticBlock, staticBlockItems, posterItems }) {
    const [hasBeenInteracted, setHasBeenInteracted] = useState(false);
    useEffect(() => {
        if (!gameRef.current || !gameRef.current.scene)
            return;
        if (gameRef.current.scene.selectedCogTiltLeftBlock)
            return;
        if (gameRef.current.scene.selectedCogTiltRightBlock)
            return;
        const item = posterItems[0];
        switch (staticBlock) {
            case "left":
                gameRef.current.scene.selectedCogTiltLeftBlock = item;
                break;
            case "right":
                gameRef.current.scene.selectedCogTiltRightBlock = item;
                break;
        }
        // gameRef.current.scene.registerCogEvents();
    }, [gameRef.current]);
    const onBlockChange = (item) => {
        if (!gameRef.current || !gameRef.current.scene)
            return;
        switch (staticBlock) {
            case "left":
                gameRef.current.scene.selectedCogTiltLeftBlock = item;
                break;
            case "right":
                gameRef.current.scene.selectedCogTiltRightBlock = item;
                break;
        }
        // gameRef.current.scene.registerCogEvents();
    };
    const clickHandler = () => {
        setHasBeenInteracted(true);
    };
    return (_jsxs("div", { className: [style.blockSelector, hasBeenInteracted ? "" : style.uninteracted].join(" "), onClick: clickHandler, children: [_jsx("div", { className: style.carouselContainer, children: _jsx(WheelFrame, { Carusel: Carousel, onFrontPosterChange: (item) => { }, posterItems: staticBlockItems, isStatic: true }) }), _jsx("div", { className: style.carouselContainer, children: _jsx(WheelFrame, { Carusel: Carousel, onFrontPosterChange: onBlockChange, posterItems: posterItems }) })] }));
}
