import { Container } from 'aurelia-framework';

import { EventAggregator } from 'aurelia-event-aggregator';

import States from 'services/states';

import { dispersePiles, trashPiles } from 'components/fragments/fragments-actions';

import {
  MODE_MEAN, MODE_TREND, MODE_VARIANCE, MODE_DIFFERENCE
} from 'components/fragments/fragments-defaults';

import COLORS from 'configs/colors';

const store = Container.instance.get(States).store;
const event = Container.instance.get(EventAggregator);

export const INSPECT = {
  name: 'Inspect',
  color: COLORS.WHITE,
  background: COLORS.BLACK,
  shortCut: 'I',
  trigger (pile) {
    event.publish('decompose.fgm.inspectPile', { pile });
  },
  single: false,
  stackedPileOnly: true
};

export const DISPERSE = {
  name: 'Disperse',
  color: COLORS.WHITE,
  background: COLORS.BLACK,
  shortCut: 'D',
  trigger (pile) {
    store.dispatch(dispersePiles([pile.id]));
  },
  single: false,
  stackedPileOnly: true
};

export const DIFFERENCE = {
  name: 'Difference',
  color: COLORS.WHITE,
  background: 0x666666,
  row: 0,
  shortCut: 'F',
  trigger (pile) {
    event.publish('decompose.fgm.coverDispMode', { mode: MODE_DIFFERENCE, pile });
  },
  triggerEvent: 'hover',
  single: false,
  stackedPileOnly: true
};

export const MEAN = {
  name: 'Mean',
  color: COLORS.WHITE,
  background: 0x666666,
  shortCut: 'M',
  trigger (pile) {
    event.publish('decompose.fgm.coverDispMode', { mode: MODE_MEAN, pile });
  },
  triggerEvent: 'hover',
  single: false,
  stackedPileOnly: true
};

export const TRASH = {
  name: 'Trash',
  color: COLORS.WHITE,
  background: COLORS.BLACK,
  shortCut: 'R',
  trigger (pile) {
    store.dispatch(trashPiles([pile.id]));
  },
  single: false
};

export const TREND = {
  name: 'Trend',
  color: COLORS.WHITE,
  background: 0x666666,
  shortCut: 'T',
  trigger (pile) {
    event.publish('decompose.fgm.coverDispMode', { mode: MODE_TREND, pile });
  },
  triggerEvent: 'hover',
  single: false,
  stackedPileOnly: true
};

export const VARIANCE = {
  name: 'Variance',
  color: COLORS.WHITE,
  background: 0x666666,
  shortCut: 'V',
  trigger (pile) {
    event.publish('decompose.fgm.coverDispMode', { mode: MODE_VARIANCE, pile });
  },
  triggerEvent: 'hover',
  single: false,
  stackedPileOnly: true
};

export default [
  INSPECT,
  DISPERSE,
  TRASH,
  MEAN,
  VARIANCE,
  TREND,
  DIFFERENCE
];

@@ -149,16 +149,18 @@
 import %7B
+%0A 
  dispers
@@ -166,16 +166,34 @@
 sePiles,
+%0A  recoverPiles,%0A 
  trashPi
@@ -195,17 +195,17 @@
 ashPiles
- 
+%0A
 %7D from '
@@ -702,33 +702,16 @@
 );%0A  %7D,%0A
-  single: false,%0A
   stacke
@@ -914,33 +914,16 @@
 );%0A  %7D,%0A
-  single: false,%0A
   stacke
@@ -1198,33 +1198,16 @@
 hover',%0A
-  single: false,%0A
   stacke
@@ -1454,33 +1454,16 @@
 hover',%0A
-  single: false,%0A
   stacke
@@ -1474,32 +1474,237 @@
 eOnly: true%0A%7D;%0A%0A
+export const RECOVER = %7B%0A  name: 'Recover',%0A  color: COLORS.WHITE,%0A  background: COLORS.BLACK,%0A  shortCut: 'R',%0A  trigger (pile) %7B%0A    store.dispatch(recoverPiles(%5Bpile.id%5D));%0A  %7D,%0A  trashedOnly: true%0A%7D;%0A%0A
 export const TRA
@@ -1860,33 +1860,16 @@
 %5D));%0A  %7D
-,%0A  single: false
 %0A%7D;%0A%0Aexp
@@ -2096,33 +2096,16 @@
 hover',%0A
-  single: false,%0A
   stacke
@@ -2368,25 +2368,8 @@
 r',%0A
-  single: false,%0A
   st
@@ -2432,16 +2432,16 @@
 SPERSE,%0A
-
   TRASH,
@@ -2441,16 +2441,27 @@
  TRASH,%0A
+  RECOVER,%0A
   MEAN,%0A

Add recover to the pile menu