function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import React, { Component } from "react";
import { StyleSheet, Animated, Dimensions } from "react-native";
import { connect } from "react-redux";
import { getMainBrandingColourFromState } from "../colours";
const DEFAULT_HEIGHT = 4;
const DEFAULT_WIDTH = Dimensions.get("window").width;
class LoadingIndicator extends Component {
  constructor(props) {
    super(props);
    _defineProperty(this, "animate", () => {
      Animated.sequence([Animated.timing(this.state.animatedLeft, {
        toValue: DEFAULT_WIDTH,
        duration: 1500,
        useNativeDriver: false
      }), Animated.delay(500), Animated.timing(this.state.animatedLeft, {
        toValue: -DEFAULT_WIDTH,
        duration: 1500,
        useNativeDriver: false
      }), Animated.delay(500)]).start(() => {
        this.animate();
      });
    });
    this.state = {
      animatedLeft: new Animated.Value(-DEFAULT_WIDTH),
      animatedOpacity: new Animated.Value(0)
    };
    this.height = 0;
  }
  componentDidMount() {
    this.animate();
  }
  getSnapshotBeforeUpdate(prevProps) {
    return null;
  }
  componentDidUpdate(prevProps) {
    if (prevProps.visible !== this.props.visible) {
      Animated.timing(this.state.animatedOpacity, {
        toValue: this.props.visible ? 0.8 : 0,
        duration: 300,
        useNativeDriver: false
      }).start();
    }
  }
  render() {
    return /*#__PURE__*/React.createElement(Animated.View, {
      style: [styles.container, this.props.style, {
        height: DEFAULT_HEIGHT,
        opacity: this.state.animatedOpacity
      }],
      onLayout: this.onLayout
    }, /*#__PURE__*/React.createElement(Animated.View, {
      style: [styles.line, {
        backgroundColor: this.props.colourBrandingMain,
        left: this.state.animatedLeft,
        height: DEFAULT_HEIGHT
      }]
    }));
  }
}
const styles = StyleSheet.create({
  container: {
    alignItems: "center",
    justifyContent: "center",
    overflow: "hidden",
    backgroundColor: "#fff",
    width: "100%",
    height: 38
  },
  innerContainer: {
    flexDirection: "row"
  },
  line: {
    width: DEFAULT_WIDTH
  }
});
const mapStateToProps = state => {
  return {
    colourBrandingMain: getMainBrandingColourFromState(state)
  };
};
export default connect(mapStateToProps, {})(LoadingIndicator);
// export { loadingIndicator as Default };
//# sourceMappingURL=LoadingIndicator.js.map