"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = require("react");
var _reactNative = require("react-native");
var _components = require("../../components");
var _useI18n = require("../../hooks/useI18n");
var _useThemeStyles = require("../../hooks/useThemeStyles");
var _themeUtils = require("../../utils/themeUtils");
var _useColorScheme = require("../../hooks/use-color-scheme");
var _OxyContext = require("../../context/OxyContext");
var _jsxRuntime = require("react/jsx-runtime");
const KarmaRulesScreen = ({
  goBack,
  theme
}) => {
  // Use useOxy() hook for OxyContext values
  const {
    oxyServices
  } = (0, _OxyContext.useOxy)();
  const {
    t
  } = (0, _useI18n.useI18n)();
  const [rules, setRules] = (0, _react.useState)([]);
  const [isLoading, setIsLoading] = (0, _react.useState)(true);
  const [error, setError] = (0, _react.useState)(null);
  const colorScheme = (0, _useColorScheme.useColorScheme)();
  const normalizedTheme = (0, _themeUtils.normalizeTheme)(theme);
  const themeStyles = (0, _useThemeStyles.useThemeStyles)(normalizedTheme, colorScheme);
  // Override primaryColor for Karma screens (purple instead of blue)
  const primaryColor = '#d169e5';
  (0, _react.useEffect)(() => {
    setIsLoading(true);
    setError(null);
    oxyServices.getKarmaRules().then(data => setRules(Array.isArray(data) ? data : [])).catch(err => setError(err.message || 'Failed to load rules')).finally(() => setIsLoading(false));
  }, [oxyServices]);
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
    style: [styles.container, {
      backgroundColor: themeStyles.backgroundColor
    }],
    children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Header, {
      title: t('karma.rules.title') || 'Karma Rules',
      subtitle: t('karma.rules.subtitle') || 'How to earn karma points',
      onBack: goBack,
      elevation: "subtle"
    }), isLoading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
      size: "large",
      color: primaryColor,
      style: {
        marginTop: 40
      }
    }) : error ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
      style: [styles.error, {
        color: '#D32F2F'
      }],
      children: error
    }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ScrollView, {
      contentContainerStyle: styles.listContainer,
      children: rules.length === 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
        style: [styles.placeholder, {
          color: themeStyles.textColor
        }],
        children: t('karma.rules.empty') || 'No rules found.'
      }) : rules.map((rule, idx) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
        style: styles.ruleRow,
        children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
          style: [styles.ruleDesc, {
            color: themeStyles.textColor
          }],
          children: rule.description
        })
      }, rule.id || idx))
    })]
  });
};
const styles = _reactNative.StyleSheet.create({
  container: {
    flex: 1
  },
  listContainer: {
    paddingBottom: 40,
    paddingTop: 20
  },
  ruleRow: {
    paddingVertical: 14,
    paddingHorizontal: 24,
    borderBottomWidth: 1,
    borderColor: '#eee'
  },
  ruleDesc: {
    fontSize: 16
  },
  placeholder: {
    fontSize: 16,
    color: '#888',
    textAlign: 'center',
    marginTop: 40
  },
  error: {
    fontSize: 16,
    textAlign: 'center',
    marginTop: 40
  }
});
var _default = exports.default = KarmaRulesScreen;
//# sourceMappingURL=KarmaRulesScreen.js.map