"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
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); }
/** A component used to provide a visual cue that an action is either processing, awaiting a course of change or a result. */
const Indicator = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.default.forwardRef(({
  animationEasing = _reactNative.Easing.linear,
  animationDuration = 1200,
  renderComponent = () => {
    return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null);
  },
  count = 1,
  ...rest
}, ref) => {
  const progress = (0, _react.useRef)(new _reactNative.Animated.Value(0)).current;
  const startAnimation = (0, _react.useCallback)(() => {
    let animation = _reactNative.Animated.timing(progress, {
      duration: animationDuration,
      easing: animationEasing,
      useNativeDriver: _reactNative.Platform.OS !== "web",
      // Web doesn't support loops if using Native Driver,
      isInteraction: true,
      toValue: 1
    });
    _reactNative.Animated.loop(animation).start();
  }, [animationDuration, animationEasing, progress]);
  const _renderComponent = (0, _react.useCallback)((item, index) => {
    if ("function" === typeof renderComponent) {
      return renderComponent({
        index,
        count,
        progress
      });
    }
    return null;
  }, [renderComponent, count, progress]);
  (0, _react.useEffect)(() => {
    startAnimation();
  }, []);
  return /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, _extends({}, rest, {
    ref: ref
  }), /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, Array.from(new Array(count), _renderComponent, void 0)));
}));
var _default = exports.default = Indicator;
//# sourceMappingURL=indicator.js.map