text: // @flow
  import * as React from 'react';
  
  import { bindActionCreators } from 'redux';
  import { connect } from 'react-redux';
  import ClipSelector from '../components/HLSIngester/ClipSelector';
  import * as clipSelectorActions from '../modules/clipSelector';
  import * as activeSourcesActions from '../modules/activeSources';
  import * as hlsPlayersActions from '../modules/hlsPlayers';
  
  import {orderClips} from '../lib/orderClips';
  
  function mapStateToProps(state, ownProps) {
    // console.log('mapStateToProps:',state) 
    const {channelNumber} = ownProps;
    const {currentClip, currentClipsOrdered, areas, clipsFrom} = state.clipSelector
    // const channelClips = currentClips.get(channelNumber) || [];
    const channelClipsOrdered = currentClipsOrdered.get(channelNumber) || [];
  
    // const channelOrderBy = orderBy.get(channelNumber);
    // const channelOrderDesc = orderDesc.get(channelNumber);
    // const clipsOrderBy = orderClips(channelClips);
    // const clips = channelOrderDesc ? clipsOrderBy(channelOrderBy).reverse() : clipsOrderBy(channelOrderBy)
  
    const channelClipsFrom = clipsFrom.get(channelNumber);
    const {channelActiveSource} = state.activeSources;
    const active = channelActiveSource.get(channelNumber) === 'clip';
    // const disabled = !active;
    const hlsRecorder = state.hlsRecorders.recorders.get(channelNumber);
    const disabled = hlsRecorder.recorderStatus === 'stopped' ? false : true;
  
    return {
      ...ownProps,
      clips:channelClipsOrdered,
      // clips: currentClips.get(channelNumber),
      currentClip: currentClip.get(channelNumber),
      active,
      disabled,
      areas,
      clipsFrom: channelClipsFrom
    }
  }
  
  function mapDispatchToProps(dispatch) {
    return {
      ClipSelectorActions: bindActionCreators(clipSelectorActions, dispatch),
      ActiveSourcesActions: bindActionCreators(activeSourcesActions, dispatch),
      HLSPlayersActions: bindActionCreators(hlsPlayersActions, dispatch)
    }
  }
  
  export default connect(mapStateToProps, mapDispatchToProps)(ClipSelector);
  