"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _reactNative = require("react-native");
var _indicator = _interopRequireDefault(require("./indicator"));
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 ActivityIndicator = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.default.forwardRef(({
  size = 30,
  count = 12,
  color = "rgb(0, 0, 0)",
  ...rest
}, ref) => {
  const _renderComponent = _react.default.useCallback(({
    index,
    count,
    progress
  }) => {
    let angle = index * 360 / count;
    let layerStyle = {
      transform: [{
        rotate: angle + "deg"
      }]
    };
    let inputRange = Array.from(new Array(count + 1), (item, index) => index / count);
    let outputRange = Array.from(new Array(count), (item, index) => Math.max(1.0 - index * (1 / (count - 1)), 0));
    for (let j = 0; j < index; j++) {
      outputRange.unshift(outputRange.pop());
    }
    outputRange.unshift(...outputRange.slice(-1));
    let barStyle = {
      width: size / 10,
      height: size / 4,
      borderRadius: size / 20,
      backgroundColor: color,
      opacity: progress.interpolate({
        inputRange,
        outputRange
      })
    };
    return /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, {
      style: [{
        ..._reactNative.StyleSheet.absoluteFillObject,
        justifyContent: "flex-start",
        alignItems: "center"
      }, layerStyle],
      key: index
    }, /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, {
      style: barStyle
    }));
  }, [size, color]);
  const {
    style,
    ...props
  } = rest;
  return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: [{
      flex: 1,
      justifyContent: "center",
      alignItems: "center"
    }, style]
  }, /*#__PURE__*/_react.default.createElement(_indicator.default, _extends({}, props, {
    ref: ref,
    style: {
      width: size,
      height: size
    },
    renderComponent: _renderComponent,
    count: count
  })));
}));
var _default = exports.default = ActivityIndicator;
//# sourceMappingURL=activity.js.map