function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import React from "react";
import Box from "../box/box";
import { pearl } from "../../../pearl";
import { View } from "react-native";
import { useTheme } from "../../../hooks";
const BaseSkeleton = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(({
  startColor,
  endColor,
  isLoaded = false,
  speed = 800,
  fadeDuration = 200,
  ...rest
}, ref) => {
  const {
    colorMode
  } = useTheme();
  const key = React.useMemo(() => `${colorMode}-${Math.random()}`, [isLoaded, colorMode, startColor, endColor, speed, fadeDuration, rest]);
  if (isLoaded) {
    return /*#__PURE__*/React.createElement(Box, {
      key: key,
      ref: ref,
      from: {
        opacity: 0
      },
      animate: {
        opacity: 1
      },
      transition: {
        duration: fadeDuration
      }
    }, rest.children);
  }
  rest.children = /*#__PURE__*/React.createElement(View, {
    style: {
      opacity: 0
    }
  }, rest.children);
  return /*#__PURE__*/React.createElement(Box, _extends({
    key: key
  }, rest, {
    ref: ref,
    from: {
      bgColor: startColor
    },
    animate: {
      bgColor: endColor
    },
    transition: {
      loop: true,
      repeatReverse: true,
      duration: speed
    }
  }));
}));

/**
 * A Skeleton component that is used to show placeholders is a loading state
 */
const Skeleton = pearl(BaseSkeleton, {
  componentName: "Skeleton",
  type: "atom"
});
Skeleton.displayName = "Skeleton";
export default Skeleton;
//# sourceMappingURL=skeleton.js.map