import React from 'react';

import {
  FILE_SELECTION_BITRATE,
  FILE_SELECTION_NONE,
  FILE_SELECTION_RESOLUTION,
} from '@/modules/feeds/Editor/constants';

import { fileSelectionSelector, skipTaggingForLongClipsSelector } from '@/modules/feeds/Editor/redux/selectors';

import { FormRow } from '@/modules/@common/Form';
import { useAppSelector } from '@/modules/@common/store/hooks';
import Bitrate from '@/modules/feeds/Editor/components/FormElements/Bitrate/Bitrate';
import CreateClipSelector from '@/modules/feeds/Editor/components/FormElements/CreateClipSelector/CreateClipSelector';
import Evergreen from '@/modules/feeds/Editor/components/FormElements/Evergreen/Evergreen';
import FeedPriority from '@/modules/feeds/Editor/components/FormElements/FeedPriority/FeedPriority';
import FileSelection from '@/modules/feeds/Editor/components/FormElements/FileSelection/FileSelection';
import ImmediateAvailability from '@/modules/feeds/Editor/components/FormElements/ImmediateAvailability/ImmediateAvailability';
import ImportPlot from '@/modules/feeds/Editor/components/FormElements/ImportPlot/ImportPlot';
import Keywords from '@/modules/feeds/Editor/components/FormElements/Keywords/Keywords';
import MaxDuration from '@/modules/feeds/Editor/components/FormElements/MaxDuration/MaxDuration';
import MaxDurationForTagging from '@/modules/feeds/Editor/components/FormElements/MaxDurationForTagging/MaxDurationForTagging';
import MinBitrate from '@/modules/feeds/Editor/components/FormElements/MinBitrate/MinBitrate';
import MinResolutionValue from '@/modules/feeds/Editor/components/FormElements/MinResolutionValue/MinResolutionValue';
import PriorityVerification from '@/modules/feeds/Editor/components/FormElements/PriorityVerification/PriorityVerification';
import Resolution from '@/modules/feeds/Editor/components/FormElements/Resolution/Resolution';
import ResolutionValue from '@/modules/feeds/Editor/components/FormElements/ResolutionValue/ResolutionValue';
import Restricted from '@/modules/feeds/Editor/components/FormElements/Restricted/Restricted';
import SkipTaggingForLongClips from '@/modules/feeds/Editor/components/FormElements/SkipTaggingForLongClips/SkipTaggingForLongClips';
import VideoFileType from '@/modules/feeds/Editor/components/FormElements/VideoFileType/VideoFileType';

function AdvancedTab() {
  const fileSelection = useAppSelector(fileSelectionSelector);
  const skipTaggingForLongClips = useAppSelector(skipTaggingForLongClipsSelector);

  return (
    <>
      <FormRow
        label="Max Duration (sec)"
        tooltip="Maximum value should not exceed 7200 seconds (2 hours). Longer videos may encounter tagging issues and/or lead to delays in the video uploader."
      >
        <MaxDuration />
      </FormRow>
      <FormRow label="Skip Tagging for Long Clips">
        <SkipTaggingForLongClips />
      </FormRow>
      <FormRow label="Max Duration for Tagging (sec)">
        <MaxDurationForTagging disabled={!skipTaggingForLongClips} />
      </FormRow>
      <FormRow label="Video File Types">
        <VideoFileType />
      </FormRow>
      <FormRow label="File Selection">
        <FileSelection />
      </FormRow>
      {fileSelection !== FILE_SELECTION_NONE && (
        <>
          {fileSelection === FILE_SELECTION_RESOLUTION && (
            <>
              <FormRow label="Resolution">
                <Resolution />
              </FormRow>
              <FormRow label="Preferred Resolution">
                <ResolutionValue />
              </FormRow>
              <FormRow label="Minimum Resolution">
                <MinResolutionValue />
              </FormRow>
            </>
          )}

          {fileSelection === FILE_SELECTION_BITRATE && (
            <>
              <FormRow label="Preferred bps">
                <Bitrate />
              </FormRow>
              <FormRow label="Minimum bps">
                <MinBitrate />
              </FormRow>
            </>
          )}
        </>
      )}
      <FormRow label="Keywords (comma delimited)">
        <Keywords />
      </FormRow>
      <FormRow label="Import Plot/Description">
        <ImportPlot />
      </FormRow>
      <FormRow label="Create Clip">
        <CreateClipSelector />
      </FormRow>
      <FormRow label="Immediate Availability (video+thumbnail available)">
        <ImmediateAvailability />
      </FormRow>
      <FormRow label="Evergreen">
        <Evergreen />
      </FormRow>
      <FormRow label="Restricted">
        <Restricted />
      </FormRow>
      <FormRow label="Source Priority">
        <FeedPriority />
      </FormRow>
      <FormRow label="Priority Verification">
        <PriorityVerification />
      </FormRow>
    </>
  );
}

export default AdvancedTab;
