"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _box = _interopRequireDefault(require("../box/box"));
var _pearl = require("../../../pearl");
var _reactNative = require("react-native");
var _hooks = require("../../../hooks");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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); }
const BaseSkeleton = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.default.forwardRef(({
  startColor,
  endColor,
  isLoaded = false,
  speed = 800,
  fadeDuration = 200,
  ...rest
}, ref) => {
  const {
    colorMode
  } = (0, _hooks.useTheme)();
  const key = _react.default.useMemo(() => `${colorMode}-${Math.random()}`, [isLoaded, colorMode, startColor, endColor, speed, fadeDuration, rest]);
  if (isLoaded) {
    return /*#__PURE__*/_react.default.createElement(_box.default, {
      key: key,
      ref: ref,
      from: {
        opacity: 0
      },
      animate: {
        opacity: 1
      },
      transition: {
        duration: fadeDuration
      }
    }, rest.children);
  }
  rest.children = /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: {
      opacity: 0
    }
  }, rest.children);
  return /*#__PURE__*/_react.default.createElement(_box.default, _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 = (0, _pearl.pearl)(BaseSkeleton, {
  componentName: "Skeleton",
  type: "atom"
});
Skeleton.displayName = "Skeleton";
var _default = exports.default = Skeleton;
//# sourceMappingURL=skeleton.js.map