 ]
 
 
+chatInputChannelsQuery = (stateId) -> [
+  ChatInputChannelsQueryStore
+  (queries) -> queries.get stateId
+]
+# Returns a list of channels depending on the current query
+# If query if empty, returns popular channels
+# Otherwise, returns channels filtered by query
+chatInputChannels = (stateId) -> [
+  ChannelsStore
+  popularChannels
+  chatInputChannelsQuery stateId
+  (channels, popularChannels, query) ->
+    return popularChannels.toList()  unless query
+
+    query = query.toLowerCase()
+    channels.toList().filter (channel) ->
+      channelName = channel.get('name').toLowerCase()
+      return channelName.indexOf(query) is 0
+]
+chatInputChannelsRawIndex = (stateId) -> [
+  ChatInputChannelsSelectedIndexStore
+  (indexes) -> indexes.get stateId
+]
+chatInputChannelsSelectedIndex = (stateId) -> [
+  chatInputChannels stateId
+  chatInputChannelsRawIndex stateId
+  calculateListSelectedIndex
+]
+chatInputChannelsSelectedItem = (stateId) -> [
+  chatInputChannels stateId
+  chatInputChannelsSelectedIndex stateId
+  getListSelectedItem
+]
+chatInputChannelsVisibility = (stateId) -> [
+  ChatInputChannelsVisibilityStore
+  (visibilities) -> visibilities.get stateId
+]
+
+chatInputUsersQuery = (stateId) -> [
+  ChatInputUsersQueryStore
+  (queries) -> queries.get stateId
+]
+# Returns a list of users depending on the current query
+# If query is empty, returns selected channel participants
+# Otherwise, returns users filtered by query
+chatInputUsers = (stateId) -> [
+  UsersStore
+  selectedChannelParticipants
+  chatInputUsersQuery stateId
+  (users, participants, query) ->
+    return participants?.toList() ? immutable.List()  unless query
+
+    query = query.toLowerCase()
+    users.toList().filter (user) ->
+      userName = user.getIn(['profile', 'nickname']).toLowerCase()
+      return userName.indexOf(query) is 0
+]
+chatInputUsersRawIndex = (stateId) -> [
+  ChatInputUsersSelectedIndexStore
+  (indexes) -> indexes.get stateId
+]
+chatInputUsersSelectedIndex = (stateId) -> [
+  chatInputUsers stateId
+  chatInputUsersRawIndex stateId
+  calculateListSelectedIndex
+]
+chatInputUsersSelectedItem = (stateId) -> [
+  chatInputUsers stateId
+  chatInputUsersSelectedIndex stateId
+  getListSelectedItem
+]
+chatInputUsersVisibility = (stateId) -> [
+  ChatInputUsersVisibilityStore
+  (visibilities) -> visibilities.get stateId
+]
+
+chatInputSearchItems = (stateId) -> [
+  ChatInputSearchStore
+  (searchStore) -> searchStore.get stateId
+]
+chatInputSearchQuery = (stateId) -> [
+  ChatInputSearchQueryStore
+  (queries) -> queries.get stateId
+]
+chatInputSearchRawIndex = (stateId) -> [
+  ChatInputSearchSelectedIndexStore
+  (indexes) -> indexes.get stateId
+]
+chatInputSearchSelectedIndex = (stateId) -> [
+  chatInputSearchItems stateId
+  chatInputSearchRawIndex stateId
+  calculateListSelectedIndex
+]
+chatInputSearchSelectedItem = (stateId) -> [
+  chatInputSearchItems stateId
+  chatInputSearchSelectedIndex stateId
+  getListSelectedItem
+]
+chatInputSearchVisibility = (stateId) -> [
+  ChatInputSearchVisibilityStore
+  (visibilities) -> visibilities.get stateId
+]
+
+
+channelParticipantsSearchQuery  = ChannelParticipantsSearchQueryStore
+
+# Returns a list of users depending on the current query
+# If query is empty, returns selected channel participants
+# Otherwise, returns users filtered by query
+channelParticipantsInputUsers = [
+  UsersStore
+  selectedChannelParticipants
+  channelParticipantsSearchQuery
+  (users, participants, query) ->
+    return participants?.toList() ? immutable.List()  unless query
+
+    query = query.toLowerCase()
+    users.toList().filter (user) ->
+      userName = user.getIn(['profile', 'nickname']).toLowerCase()
+      return userName.indexOf(query) is 0
+]
+
 module.exports = {
   allChannels
   followedPublicChannelThreads

  currentSuggestionsSelectedIndex
  currentSuggestionsSelectedItem

  allUsers
}


allChannels = ChannelsStore
allUsers    = UsersStore

ChannelParticipantsSearchQueryStore        = ['ChannelParticipantsSearchQueryStore']

# Computed Data getters.
# Following will be transformations of the store datas for other parts (mainly
# visual components) to use.
