import debugModule from "debug";
const debug = debugModule("debugger");

import Session from "./session";

import { createNestedSelector } from "reselect-tree";

import dataSelector from "./data/selectors";
import astSelector from "./ast/selectors";
import traceSelector from "./trace/selectors";
import evmSelector from "./evm/selectors";
import soliditySelector from "./solidity/selectors";
import sessionSelector from "./session/selectors";
import stacktraceSelector from "./stacktrace/selectors";
import controllerSelector from "./controller/selectors";

import { Compilations } from "@truffle/codec";

const Debugger = {
  /**
   * Instantiates a Debugger for a given transaction hash.
   *
   * @param {String} txHash - transaction hash with leading "0x"
   * @param {{contracts: Array<Artifact>, files: Array<String>, provider: Web3Provider, compilations: Array<Compilation>}} options -
   * @return {Debugger} instance
   */
  forTx: async function(txHash, options = {}) {
    let { contracts, files, provider, compilations, lightMode } = options;
    if (!compilations) {
      compilations = Compilations.Utils.shimArtifacts(contracts, files);
    }
    let session = new Session(compilations, provider, { lightMode }, txHash);

    try {
      await session.ready();
      debug("session ready");
    } catch (e) {
      debug("error occurred, unloaded");
      session.unload();
    }

    return session;
  },

  /*
   * Instantiates a Debugger for a given project (with no transaction loaded)
   *
   * @param {{contracts: Array<Artifact>, files: Array<String>, provider: Web3Provider, compilations: Array<Compilation>}} options -
   * @return {Debugger} instance
   */
  forProject: async function(options = {}) {
    let { contracts, files, provider, compilations, lightMode } = options;
    if (!compilations) {
      compilations = Compilations.Utils.shimArtifacts(contracts, files);
    }
    let session = new Session(compilations, provider, { lightMode });

    await session.ready();

    return session;
  },

  /**
   * Exported selectors
   *
   * See individual selector docs for full listing
   *
   * @example
   * Debugger.selectors.ast.current.tree
   *
   * @example
   * Debugger.selectors.solidity.current.instruction
   *
   * @example
   * Debugger.selectors.trace.steps
   */
  selectors: createNestedSelector({
    ast: astSelector,
    data: dataSelector,
    trace: traceSelector,
    evm: evmSelector,
    solidity: soliditySelector,
    stacktrace: stacktraceSelector,
    session: sessionSelector,
    controller: controllerSelector
  })
};

export default Debugger;

@@ -2307,16 +2307,20 @@
    */%0A  
+get 
 selector
@@ -2320,17 +2320,31 @@
 electors
-:
+() %7B%0A    return
  createN
@@ -2359,16 +2359,18 @@
 ector(%7B%0A
+  
     ast:
@@ -2387,16 +2387,18 @@
 or,%0A    
+  
 data: da
@@ -2405,24 +2405,26 @@
 taSelector,%0A
+  
     trace: t
@@ -2433,24 +2433,26 @@
 ceSelector,%0A
+  
     evm: evm
@@ -2465,16 +2465,18 @@
 or,%0A    
+  
 solidity
@@ -2491,24 +2491,26 @@
 tySelector,%0A
+  
     stacktra
@@ -2533,24 +2533,26 @@
 lector,%0A    
+ 
+ 
 session: ses
@@ -2561,24 +2561,26 @@
 onSelector,%0A
+  
     controll
@@ -2606,12 +2606,19 @@
 tor%0A
+  
   %7D)
+;%0A  %7D
 %0A%7D;%0A

Change selectors field on Debugger back to a getter