import { select } from 'd3-selection';
import Set from 'es6-set';

let namespaces = new Set();

const makeEnum = (ns, keys) => {
  // Construct an object containing keys matching those passed in `keys`, whose
  // values are the keys themselves, prefixed by the specified namespace.
  //
  // Dots are not allowed in the namespace name.
  if (ns.indexOf('.') > -1) {
    throw new Error('dots not allowed in namespace');
  }

  // Namespaces are not allowed to repeat.
  if (namespaces.has(ns)) {
    throw new Error(`duplicate namespace "${ns}"`);
  }
  namespaces.add(ns);

  let obj = {};

  let used = new Set();
  keys.forEach((key) => {
    if (key.indexOf('.') > -1) {
      throw new Error('dots not allowed in key');
    }

    if (used.has(key)) {
      throw new Error(`duplicate key "${key}"`);
    }
    used.add(key);

    obj[key] = `${ns}.${key}`;
  });

  // Freeze the resulting object so no one else can alter the values or keys.
  return Object.freeze(obj);
};

const enumName = (enumVal) => enumVal.split('.')[0];
const enumValue = (enumVal) => enumVal.split('.')[1];

const switchOverlay = (which) => {
  select('#overlay')
    .style('display', which === null ? 'none' : null)
    .selectAll('.overlay')
    .style('display', function () {
      return select(this).classed(which) ? null : 'none';
    });
};

const initializeNewProject = () => {
  return Promise.resolve({
    name: 'Foobarius'
  });
};

export {
  makeEnum,
  enumName,
  enumValue,
  switchOverlay,
  initializeNewProject
};

@@ -1363,16 +1363,70 @@
 () =%3E %7B%0A
+  console.log('stub function: initializeNewProject');%0A
   return

Include a console message to mark the stub function