import React, { useEffect, useRef, useState } from 'react' import Image from 'next/image' import { cn } from 'ui' import useConfData from '../hooks/use-conf-data' import { useBreakpoint } from 'common' interface Props { className?: string isGameMode?: boolean } const LWXBackground = ({ className, isGameMode = false }: Props) => { const { ticketState } = useConfData() const containerRef = useRef(null) const isMobile = useBreakpoint() const ref = useRef(null) const [isActive, setIsActive] = useState(false) const [gradientPos, setGradientPos] = useState({ x: 0, y: 0 }) const hasTicket = ticketState === 'ticket' const handleGlow = (event: any) => { if (isMobile) return setGradientPos({ x: 70, y: 40 }) if (!ref.current || !containerRef.current || hasTicket || isGameMode) return null const containerRefElement = containerRef.current as HTMLDivElement const { x: contX, y: contY, width: containerWidth, height: containerHeight, } = containerRefElement.getBoundingClientRect() const xCont = event.clientX - contX const yCont = event.clientY - contY const isContainerHovered = xCont > -3 && xCont < containerWidth + 3 && yCont > -3 && yCont < containerHeight + 3 setIsActive(isContainerHovered) if (!isContainerHovered) return const svgElement = ref.current as SVGElement const { x: svgX, y: svgY } = svgElement.getBoundingClientRect() const x = event.clientX - svgX - 50 const y = event.clientY - svgY - 50 setGradientPos({ x, y }) } useEffect(() => { if (typeof window === 'undefined') return window.addEventListener('mousemove', handleGlow) return () => { window.removeEventListener('mousemove', handleGlow) } }, [ticketState, isMobile]) const gradientTransformBg = `translate(${gradientPos?.x} ${gradientPos?.y}) rotate(67.9381) scale(182.424)` const gradientTransformStroke = `translate(${gradientPos?.x} ${gradientPos?.y}) rotate(71.6455) scale(105.635)` return (