import React from 'react'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faChevronRight, faEye, faEyeSlash, faUser, faUserGroup, faNetworkWired } from '@fortawesome/free-solid-svg-icons'
import { HighlightVisibility } from '../HighlightsPanel'
import IconButton from '../IconButton'

interface HighlightsPanelHeaderProps {
  hasHighlights: boolean
  showHighlights: boolean
  highlightVisibility: HighlightVisibility
  currentUserPubkey?: string
  onToggleHighlights: () => void
  onToggleCollapse: () => void
  onHighlightVisibilityChange?: (visibility: HighlightVisibility) => void
  isMobile?: boolean
}

const HighlightsPanelHeader: React.FC<HighlightsPanelHeaderProps> = ({
  hasHighlights,
  showHighlights,
  highlightVisibility,
  currentUserPubkey,
  onToggleHighlights,
  onToggleCollapse,
  onHighlightVisibilityChange,
  isMobile = false
}) => {
  return (
    <div className="highlights-header">
      <div className="highlights-actions">
        <div className="highlights-actions-left">
          {!isMobile && (
            <button 
              onClick={onToggleCollapse}
              className="toggle-highlights-btn"
              title="Collapse highlights panel"
              aria-label="Collapse highlights panel"
            >
              <FontAwesomeIcon icon={faChevronRight} style={{ transform: 'rotate(180deg)' }} />
            </button>
          )}
          {onHighlightVisibilityChange && (
            <div className="highlight-level-toggles">
              <IconButton
                icon={faNetworkWired}
                onClick={() => onHighlightVisibilityChange({ 
                  ...highlightVisibility, 
                  nostrverse: !highlightVisibility.nostrverse 
                })}
                title="Toggle nostrverse highlights"
                ariaLabel="Toggle nostrverse highlights"
                variant="ghost"
                style={{ 
                  color: highlightVisibility.nostrverse ? 'var(--highlight-color-nostrverse, #9333ea)' : undefined,
                  opacity: highlightVisibility.nostrverse ? 1 : 0.4 
                }}
              />
              {currentUserPubkey && (
                <>
                  <IconButton
                    icon={faUserGroup}
                    onClick={() => onHighlightVisibilityChange({ 
                      ...highlightVisibility, 
                      friends: !highlightVisibility.friends 
                    })}
                    title="Toggle friends highlights"
                    ariaLabel="Toggle friends highlights"
                    variant="ghost"
                    style={{ 
                      color: highlightVisibility.friends ? 'var(--highlight-color-friends, #f97316)' : undefined,
                      opacity: highlightVisibility.friends ? 1 : 0.4 
                    }}
                  />
                  <IconButton
                    icon={faUser}
                    onClick={() => onHighlightVisibilityChange({ 
                      ...highlightVisibility, 
                      mine: !highlightVisibility.mine 
                    })}
                    title="Toggle my highlights"
                    ariaLabel="Toggle my highlights"
                    variant="ghost"
                    style={{ 
                      color: highlightVisibility.mine ? 'var(--highlight-color-mine, #eab308)' : undefined,
                      opacity: highlightVisibility.mine ? 1 : 0.4 
                    }}
                  />
                </>
              )}
            </div>
          )}
        </div>
        <div className="highlights-actions-right">
          {hasHighlights && (
            <IconButton
              icon={showHighlights ? faEye : faEyeSlash}
              onClick={onToggleHighlights}
              title={showHighlights ? 'Hide highlights' : 'Show highlights'}
              ariaLabel={showHighlights ? 'Hide highlights' : 'Show highlights'}
              variant="ghost"
            />
          )}
        </div>
      </div>
    </div>
  )
}

export default HighlightsPanelHeader

