"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.IOSkeleton = void 0;
var _react = require("react");
var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
var _context = require("../../context");
var _core = require("../../core");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
const ANIMATION_DURATION = 1250;
const [OPACITY_MIN, OPACITY_MAX] = [0.35, 0.75];
const OPACITY_REDUCED_MOTION = (OPACITY_MAX + OPACITY_MIN) / 2;
const pulseKeyframes = {
  "0%, 100%": {
    opacity: OPACITY_MAX
  },
  "50%": {
    opacity: OPACITY_MIN
  }
};
const IOSkeleton = ({
  shape,
  size,
  width,
  height,
  radius: borderRadius,
  color,
  testID
}) => {
  const reduceMotion = (0, _reactNativeReanimated.useReducedMotion)();
  const theme = (0, _context.useIOTheme)();
  const backgroundColor = color ?? _core.IOColors[theme["skeleton-background"]];
  const baseStyle = (0, _react.useMemo)(() => ({
    backgroundColor,
    width: shape === "square" ? size : width,
    height: shape === "square" ? size : height,
    borderRadius,
    borderCurve: "continuous"
  }), [backgroundColor, shape, size, width, height, borderRadius]);
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
    testID: testID,
    style: [baseStyle, reduceMotion ? {
      opacity: OPACITY_REDUCED_MOTION
    } : {
      animationName: pulseKeyframes,
      animationDuration: `${ANIMATION_DURATION}ms`,
      animationIterationCount: "infinite",
      animationTimingFunction: _core.IOEasingCurves.easeInOutSine
    }]
  });
};
exports.IOSkeleton = IOSkeleton;
//# sourceMappingURL=IOSkeleton.js.map