import '../../../preact/compat/dist/compat.module.mjs';
import { clsx } from '../../../clsx/dist/clsx.mjs';
import { jsx as u } from '../../../preact/jsx-runtime/dist/jsxRuntime.module.mjs';
import { useState as h, useEffect as p } from '../../../preact/hooks/dist/hooks.module.mjs';

function Ripple(props) {
  const {
    className,
    classes,
    pulsate = false,
    rippleX,
    rippleY,
    rippleSize,
    in: inProp,
    onExited,
    timeout
  } = props;
  const [leaving, setLeaving] = h(false);
  const rippleClassName = clsx(className, classes.ripple, classes.rippleVisible, pulsate && classes.ripplePulsate);
  const rippleStyles = {
    width: rippleSize,
    height: rippleSize,
    top: -(rippleSize / 2) + rippleY,
    left: -(rippleSize / 2) + rippleX
  };
  const childClassName = clsx(classes.child, leaving && classes.childLeaving, pulsate && classes.childPulsate);
  if (!inProp && !leaving) {
    setLeaving(true);
  }
  p(() => {
    if (!inProp && onExited != null) {
      // react-transition-group#onExited
      const timeoutId = setTimeout(onExited, timeout);
      return () => {
        clearTimeout(timeoutId);
      };
    }
    return undefined;
  }, [onExited, inProp, timeout]);
  return /*#__PURE__*/u("span", {
    className: rippleClassName,
    style: rippleStyles,
    children: /*#__PURE__*/u("span", {
      className: childClassName
    })
  });
}

export { Ripple as default };
//# sourceMappingURL=Ripple.mjs.map
