"use strict";

exports.__esModule = true;
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _reactNativeSlider = _interopRequireDefault(require("@coorpacademy/react-native-slider"));
var _index = _interopRequireDefault(require("../../../../atom/text/index.native"));
var _templateContext = require("../../../../template/app-review/template-context");
var _shadow = require("../../../../variables/shadow");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
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 && {}.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; }
const createStyleSheet = (brandTheme, theme) => _reactNative.StyleSheet.create({
  container: {
    flex: 1,
    paddingHorizontal: 20,
    flexDirection: 'column',
    justifyContent: 'center'
  },
  header: {
    fontSize: 25,
    fontWeight: theme.fontWeight.bold,
    textAlign: 'center'
  },
  textValue: {
    fontSize: 15,
    color: theme.colors.black,
    fontWeight: theme.fontWeight.bold,
    textAlign: 'center'
  },
  valuesContainer: {
    flexDirection: 'row',
    justifyContent: 'space-around'
  },
  leftValue: {
    flex: 1,
    alignItems: 'flex-start'
  },
  rightValue: {
    flex: 1,
    alignItems: 'flex-end'
  },
  track: {
    height: 10,
    borderRadius: theme.radius.button
  },
  thumb: {
    ..._shadow.BOX_STYLE,
    width: 30,
    height: 30,
    borderRadius: 30 / 2,
    borderWidth: 5,
    backgroundColor: brandTheme?.colors?.primary,
    borderColor: 'white'
  }
});
const QuestionSlider = props => {
  const {
    step,
    style,
    min,
    max,
    unit = '',
    value: storeValue = 0,
    onSlidingComplete,
    testID
  } = props;
  const templateContext = (0, _templateContext.useTemplateContext)();
  const {
    brandTheme,
    theme
  } = templateContext;
  const [styleSheet, setStylesheet] = (0, _react.useState)(null);
  const [value, setValue] = (0, _react.useState)(storeValue);
  const handleSlidingComplete = (0, _react.useCallback)(() => {
    onSlidingComplete(value);
  }, [onSlidingComplete, value]);
  (0, _react.useEffect)(() => {
    const _stylesheet = createStyleSheet(brandTheme, theme);
    setStylesheet(_stylesheet);
  }, [brandTheme, theme]);
  if (!styleSheet) {
    return null;
  }
  const textStyle = {
    ...styleSheet.header,
    color: brandTheme?.colors?.primary
  };
  return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: [styleSheet.container, style],
    testID: testID
  }, /*#__PURE__*/_react.default.createElement(_index.default, {
    style: textStyle,
    testID: "slider-value"
  }, value), /*#__PURE__*/_react.default.createElement(_reactNativeSlider.default, {
    step: step || 1,
    value: value,
    onValueChange: setValue,
    maximumValue: max,
    minimumValue: min,
    onSlidingComplete: handleSlidingComplete,
    minimumTrackTintColor: brandTheme?.colors?.primary,
    trackStyle: styleSheet.track,
    thumbStyle: [styleSheet.thumb],
    testID: "slider"
  }), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: styleSheet.valuesContainer,
    testID: "slider-values-container"
  }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: styleSheet.leftValue
  }, /*#__PURE__*/_react.default.createElement(_index.default, {
    style: styleSheet.textValue,
    testID: "slider-min-value"
  }, `${min} ${unit}`)), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: styleSheet.rightValue
  }, /*#__PURE__*/_react.default.createElement(_index.default, {
    style: styleSheet.textValue,
    testID: "slider-max-value"
  }, `${max} ${unit}`))));
};
var _default = exports.default = QuestionSlider;
//# sourceMappingURL=index.native.js.map