"use client";
'use strict';

var jsxRuntime = require('react/jsx-runtime');
var React = require('react');
var server = require('@windrun-huaiin/base-ui/components/server');
var lib = require('@windrun-huaiin/base-ui/lib');

function GoToTop() {
    const [isVisible, setIsVisible] = React.useState(false);
    // listen to scroll event
    React.useEffect(() => {
        const toggleVisibility = () => {
            if (window.scrollY > 300) {
                setIsVisible(true);
            }
            else {
                setIsVisible(false);
            }
        };
        window.addEventListener('scroll', toggleVisibility);
        return () => window.removeEventListener('scroll', toggleVisibility);
    }, []);
    // scroll to top
    const scrollToTop = () => {
        window.scrollTo({
            top: 0,
            behavior: 'smooth'
        });
    };
    return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: isVisible && (jsxRuntime.jsx("button", { onClick: scrollToTop, className: `fixed bottom-6 right-6 p-3 ${lib.themeButtonGradientClass} ${lib.themeButtonGradientHoverClass} text-white rounded-full shadow-lg hover:shadow-xl transition-all duration-300 z-50`, "aria-label": "Go to top", children: jsxRuntime.jsx(server.globalLucideIcons.ArrowUp, { size: 20, className: "text-white" }) })) }));
}

exports.GoToTop = GoToTop;
