"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.EditBioModal = void 0;
var _react = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _vectorIcons = require("@expo/vector-icons");
var _useThemeStyles = require("../../hooks/useThemeStyles");
var _useColorScheme = require("../../hooks/use-color-scheme");
var _useI18n = require("../../hooks/useI18n");
var _fonts = require("../../styles/fonts");
var _useProfileEditing = require("../../hooks/useProfileEditing");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
const EditBioModal = ({
  visible,
  onClose,
  initialValue = '',
  theme = 'light',
  onSave
}) => {
  const {
    t
  } = (0, _useI18n.useI18n)();
  const colorScheme = (0, _useColorScheme.useColorScheme)();
  const themeStyles = (0, _useThemeStyles.useThemeStyles)(theme || 'light', colorScheme);
  const colors = themeStyles.colors;
  const {
    updateField,
    isSaving
  } = (0, _useProfileEditing.useProfileEditing)();
  const [bio, setBio] = (0, _react.useState)(initialValue);
  (0, _react.useEffect)(() => {
    if (visible) {
      setBio(initialValue);
    }
  }, [visible, initialValue]);
  const handleSave = async () => {
    const success = await updateField('bio', bio);
    if (success) {
      onSave?.();
      onClose();
    }
  };
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Modal, {
    visible: visible,
    animationType: "slide",
    transparent: true,
    onRequestClose: onClose,
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
      style: styles.modalOverlay,
      children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
        style: [styles.modalContent, {
          backgroundColor: colors.background
        }],
        children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
          style: styles.modalHeader,
          children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
            onPress: onClose,
            style: styles.closeButton,
            children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_vectorIcons.Ionicons, {
              name: "close",
              size: 24,
              color: colors.text
            })
          }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
            style: [styles.modalTitle, {
              color: colors.text
            }],
            children: t('editProfile.items.bio.title') || 'Bio'
          }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
            onPress: handleSave,
            disabled: isSaving,
            style: [styles.saveButton, {
              opacity: isSaving ? 0.5 : 1
            }],
            children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
              style: [styles.saveButtonText, {
                color: colors.tint
              }],
              children: isSaving ? 'Saving...' : 'Save'
            })
          })]
        }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
          style: styles.modalBody,
          children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
            style: styles.inputGroup,
            children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
              style: [styles.label, {
                color: colors.text
              }],
              children: t('editProfile.items.bio.label') || 'Bio'
            }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TextInput, {
              style: [styles.textArea, {
                backgroundColor: colors.card,
                color: colors.text,
                borderColor: colors.border
              }],
              value: bio,
              onChangeText: setBio,
              placeholder: t('editProfile.items.bio.placeholder') || 'Tell people about yourself...',
              placeholderTextColor: colors.secondaryText,
              autoFocus: true,
              multiline: true,
              numberOfLines: 6,
              textAlignVertical: "top",
              selectionColor: colors.tint
            })]
          })
        })]
      })
    })
  });
};
exports.EditBioModal = EditBioModal;
const styles = _reactNative.StyleSheet.create({
  modalOverlay: {
    flex: 1,
    backgroundColor: 'rgba(0, 0, 0, 0.5)',
    justifyContent: 'flex-end'
  },
  modalContent: {
    borderTopLeftRadius: 20,
    borderTopRightRadius: 20,
    paddingTop: _reactNative.Platform.OS === 'ios' ? 20 : 16,
    maxHeight: '80%'
  },
  modalHeader: {
    flexDirection: 'row',
    alignItems: 'center',
    justifyContent: 'space-between',
    paddingHorizontal: 16,
    paddingBottom: 16,
    borderBottomWidth: _reactNative.StyleSheet.hairlineWidth,
    borderBottomColor: '#E5E5EA'
  },
  closeButton: {
    width: 40,
    height: 40,
    alignItems: 'center',
    justifyContent: 'center'
  },
  modalTitle: {
    fontSize: 18,
    fontWeight: '600',
    fontFamily: _fonts.fontFamilies.phuduSemiBold,
    flex: 1,
    textAlign: 'center'
  },
  saveButton: {
    paddingHorizontal: 16,
    paddingVertical: 8
  },
  saveButtonText: {
    fontSize: 16,
    fontWeight: '600',
    fontFamily: _fonts.fontFamilies.phuduSemiBold
  },
  modalBody: {
    padding: 16,
    gap: 16
  },
  inputGroup: {
    gap: 8
  },
  label: {
    fontSize: 14,
    fontWeight: '600',
    fontFamily: _fonts.fontFamilies.phuduSemiBold
  },
  textArea: {
    borderWidth: _reactNative.StyleSheet.hairlineWidth,
    borderRadius: 12,
    padding: 16,
    fontSize: 16,
    minHeight: 120
  }
});
//# sourceMappingURL=EditBioModal.js.map