import { View, ScrollView } from 'react-native';
import { Controller } from 'react-hook-form';
import CoverImage from '../shared/components/CoverImageUpload';
import { ElementID, PageID } from '../../../enums';
import FormInput from '../../../components/FormInput';
import Categories from '../shared/components/Categories';
import { AmityCommunityPrivacyEnum } from '../shared/types';
import Privacy from '../shared/components/Privacy';
import Members from './components/Members';
import { CHARACTER_LIMIT } from '../../../../core/constants';
import { SafeAreaView } from 'react-native-safe-area-context';
import Header from './components/Header';
import { useCreateCommunity } from './hooks/useCreateCommunity';
import ActionButton from '../../../elements/ActionButton';
import { plus } from '../../../../core/assets/icons';
function CreateCommunity() {
  const {
    control,
    isDirty,
    isSubmitting,
    isValid,
    handleSubmit,
    onSubmit,
    openCamera,
    openImageGallery,
    progress,
    styles,
    navigation,
    values
  } = useCreateCommunity();
  return /*#__PURE__*/React.createElement(SafeAreaView, {
    style: styles.container
  }, /*#__PURE__*/React.createElement(Header, {
    isFormDirty: isDirty
  }), /*#__PURE__*/React.createElement(ScrollView, {
    contentContainerStyle: styles.contentContainer
  }, /*#__PURE__*/React.createElement(Controller, {
    name: "image",
    control: control,
    render: ({
      field: {
        onChange,
        value
      }
    }) => /*#__PURE__*/React.createElement(CoverImage, {
      progress: progress,
      openCamera: openCamera,
      value: value,
      onChange: onChange,
      openImageGallery: openImageGallery
    })
  }), /*#__PURE__*/React.createElement(View, {
    style: styles.allInputContainer
  }, /*#__PURE__*/React.createElement(Controller, {
    name: "displayName",
    control: control,
    render: ({
      field: {
        onChange,
        onBlur,
        value
      }
    }) => /*#__PURE__*/React.createElement(FormInput, {
      value: value,
      onBlur: onBlur,
      multiline: false,
      onChangeText: onChange,
      placeholder: "Name your community",
      pageId: PageID.community_setup_page,
      maxLength: CHARACTER_LIMIT.COMMUNITY_NAME,
      elementId: ElementID.community_name_title
    })
  }), /*#__PURE__*/React.createElement(Controller, {
    name: "description",
    control: control,
    render: ({
      field: {
        onChange,
        onBlur,
        value
      }
    }) => /*#__PURE__*/React.createElement(FormInput, {
      optional: true,
      value: value,
      onBlur: onBlur,
      multiline: true,
      onChangeText: onChange,
      placeholder: "Enter description",
      pageId: PageID.community_setup_page,
      elementId: ElementID.community_about_title,
      maxLength: CHARACTER_LIMIT.COMMUNITY_DESCRIPTION
    })
  }), /*#__PURE__*/React.createElement(Controller, {
    name: "categories",
    control: control,
    render: ({
      field: {
        onChange,
        value
      }
    }) => /*#__PURE__*/React.createElement(Categories, {
      categories: value,
      onChange: onChange,
      goBack: navigation.goBack
    })
  }), /*#__PURE__*/React.createElement(Controller, {
    name: "privacy",
    control: control,
    render: ({
      field: {
        onChange,
        value
      }
    }) => /*#__PURE__*/React.createElement(Privacy, {
      value: value,
      onChange: onChange
    })
  }), values.privacy === AmityCommunityPrivacyEnum.PRIVATE && /*#__PURE__*/React.createElement(Controller, {
    name: "members",
    control: control,
    render: ({
      field: {
        onChange,
        value
      }
    }) => /*#__PURE__*/React.createElement(Members, {
      value: value,
      onChange: onChange,
      goBack: navigation.goBack
    })
  }))), /*#__PURE__*/React.createElement(View, {
    style: styles.submitButtonContainer
  }, /*#__PURE__*/React.createElement(ActionButton, {
    icon: plus(),
    onPress: handleSubmit(onSubmit),
    pageId: PageID.community_setup_page,
    elementId: ElementID.community_create_button,
    disabled: !isDirty || !isValid || isSubmitting || progress > 0
  })));
}
export default CreateCommunity;
//# sourceMappingURL=Create.js.map