import { jsx } from "react/jsx-runtime";
import { styled } from "@mui/material";
import apollo_core from "@uipath/apollo-core";
import react, { useEffect } from "react";
import "./ApSkeleton.css";
const StyledSkeleton = styled('div')(({ variant, circleSize })=>({
        position: 'relative',
        display: 'inline-block',
        borderRadius: apollo_core.Border.BorderRadiusM,
        flexShrink: 0,
        flexGrow: 1,
        boxSizing: 'border-box',
        backgroundColor: 'var(--color-skeleton)',
        backgroundImage: `linear-gradient(
        to right,
        var(--color-skeleton) 0%,
        var(--color-skeleton-glow) 50%,
        var(--color-skeleton) 100%
    )`,
        backgroundRepeat: 'no-repeat',
        backgroundPosition: '0% 0%',
        backgroundSize: '200vmax 200vmax',
        backgroundAttachment: 'fixed',
        backgroundPositionX: 'var(--ap-skeleton_background-position-x, 0%)',
        '&:empty::before': {
            content: '"\\00a0"',
            userSelect: 'none'
        },
        ...'circle' === variant && {
            borderRadius: '10000px',
            width: `${circleSize}px !important`,
            height: `${circleSize}px !important`,
            flex: '0 0 auto'
        },
        ...'border' === variant && {
            opacity: 'unset',
            background: 'none',
            backgroundImage: 'none',
            border: '1px solid var(--color-skeleton)'
        },
        '@media (prefers-reduced-motion)': {
            backgroundImage: 'none',
            backgroundPosition: '0% 0%'
        }
    }));
const ApSkeleton = /*#__PURE__*/ react.forwardRef(({ variant = 'rectangle', circleSize = 24, children, className, style, 'data-testid': testId, ...rest }, ref)=>{
    useEffect(()=>{
        document.body.classList.add('has-skeletons');
        return ()=>{
            document.body.classList.remove('has-skeletons');
        };
    }, []);
    return /*#__PURE__*/ jsx(StyledSkeleton, {
        ref: ref,
        variant: variant,
        circleSize: circleSize,
        className: className,
        style: style,
        "data-testid": testId || 'ap-skeleton',
        ...rest,
        children: children
    });
});
ApSkeleton.displayName = 'ApSkeleton';
export { ApSkeleton };
