text: (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
  /*
   * manuscript
   * http://github.com/typesettin/manuscript
   *
   * Copyright (c) 2014 Yaw Joseph Etse. All rights reserved.
   */
  
  module.exports = require('./lib/ribbon');
  
  },{"./lib/ribbon":2}],2:[function(require,module,exports){
  /*
   * ribbon
   * http://github.com/typesettin/ribbon
   *
   * Copyright (c) 2014 Yaw Joseph Etse. All rights reserved.
   */
  
  'use strict';
  
  var classie = require('classie'),
  	extend = require('util-extend'),
  	events = require('events'),
  	util = require('util');
  
  /**
   * A module that represents a ribbon.
   * @{@link https://github.com/typesettin/ribbon}
   * @author Yaw Joseph Etse
   * @copyright Copyright (c) 2014 Typesettin. All rights reserved.
   * @license MIT
   * @module ribbon
   * @requires module:classie
   * @requires module:util-extent
   * @requires module:util
   * @requires module:events
   * @todo to do later
   */
  var ribbon = function(config_options,ribbon_message,show,timed,callback){
  	/** module default configuration */
  	var options,
  		defaults = {
  			idSelector : '#_mms_ribbon-element',
  			message : false,
  			element : null,
  			type : "default",
  			parentElement : null,
  			style : 'cards'
  		},
  		container;
  
  	defaults.message = (ribbon_message) ? ribbon_message : "empty ribbon";
  	//extend default options
  	options = extend( defaults,config_options );
  
  
  	/** Returns the configuration object 
  	 * @return {object} the module configuration
  	 */
  	this.config = function(){
  		return options;
  	};
  
  	/** 
  	 * The element to clone in child window
  	 * @param {object} element - html element to clone
  	 */
  	this.setRibbonContentElement = function(element){
  		options.element = element;
  	};
  
  	/**
  	 * intialize a new platter
  	 */
  	this.init = function(ribbon_message,show,timed,callback){
  		if(document.querySelector(options.idSelector)){
  			options.element = document.querySelector(options.idSelector);
  			if (options.parentElement){
  				options.parentElement = options.parentElement;
  			}
  			else if(document.querySelector('._ribbon_parent-element')){
  				options.parentElement = document.querySelector('._ribbon_parent-element');
  			}
  			else{
  				options.parentElement = options.element.parentNode;
  			}
  
  			classie.addClass(options.parentElement,'_ribbon_parent-element');
  			options.element.addEventListener('click',ribbonClickEventHandler,false);
  			this.createContainer();
  			this.createRibbon(options.idSelector);
  			this.emit("intializedRibbon",true);
  			if(show){
  				this.showRibbon(ribbon_message,timed,options.type,callback);
  			}
  		}
  		else{
  			throw new Error("invalid element selector");
  		}
  	}.bind(this);
  
  	this.setRibbonMessage = function(msg,hideDismiss){
  		var hideDismissText = (hideDismiss) ? '':' <span class="_rb_small _rb-hide-ribbon">(dismiss)</span>';
  		options.message = msg;
  		options.element.innerHTML = options.message + hideDismissText;
  	};
  
  	/**
  	 * create ribbon html container
  	 */
  	this.createContainer = function(){
  		if(document.getElementById("_mms_ribbon-element-wrapper")){
  			this.emit("ribbonContainerCreated",false);
  		}
  		else{
  			var ribbonContainer = document.createElement('div');
  			ribbonContainer.setAttribute("id","_mms_ribbon-element-wrapper");
  			classie.addClass(ribbonContainer,'_mms_ribbon-element-wrapper');
  			options.parentElement.appendChild(ribbonContainer);
  			this.emit("ribbonContainerCreated",ribbonContainer);
  		}
  	};
  
  	/**
  	 * create ribbon html
  	 * @param {string} id name for platter selector id
  	 */
  	this.createRibbon = function(id){
  		var ribbonHTML = (document.querySelector(id)) ? document.querySelector(id) : document.createElement('div');
  		/** create platter tab html */
  		classie.addClass(ribbonHTML,'_mms_ribbon-element');
  		classie.addClass(ribbonHTML,'future');
  		classie.addClass(ribbonHTML,options.style);
  		ribbonHTML.innerHTML =options.message;
  		/** add platter tab to tab bar */
  		document.querySelector('#_mms_ribbon-element-wrapper').appendChild(ribbonHTML);
  		this.emit("ribbonCreated",ribbonHTML);
  	};
  
  	/** hides platter in bar */
  	this.hideRibbon = function(){
  		classie.addClass(options.element,'past');
  
  		var t = setTimeout(function(){
  			classie.removeClass(options.element,'_mms_ribbon-type-'+options.type);
  			classie.removeClass(options.parentElement,'_mss-ribbon-active');
  			classie.removeClass(options.element,'past');
  			classie.addClass(options.element,'future');
  			clearTimeout(t);
  			this.emit("ribbonClosed",true);
  		}.bind(this),900);
  	};
  
  	/** show platter in bar */
  	this.showRibbon = function(msg,timed,type,hideDismiss,callback){
  		// console.log("msg",msg,"timed",timed,"type",type,"callback",callback);
  		if(hideDismiss === true && timed < 500 || timed > 20000){
  			timed = 5000;
  		}
  		if(msg){
  			options.type = (type) ? type : options.type;
  			classie.addClass(options.element,'_mms_ribbon-type-'+options.type);
  
  			this.setRibbonMessage(msg,hideDismiss);
  
  			classie.addClass(options.parentElement,'_mss-ribbon-active');
  			var y = setTimeout(function(){
  				classie.removeClass(options.element,'future');
  				if(timed){
  					var t = setTimeout(function(){
  						clearTimeout(t);
  						this.hideRibbon();
  						callCallBack(callback);
  						this.emit("ribbonOpened",true);
  					}.bind(this),timed);
  				}
  				else{
  					this.emit("ribbonOpened",true);
  					callCallBack(callback);
  				}
  			}.bind(this),100);
  		}
  	}.bind(this);
  
  	var ribbonClickEventHandler = function(e){
  		var etarget = e.target;
  		if(classie.hasClass(etarget,'_rb-hide-ribbon')){
  			this.hideRibbon();
  		}
  	}.bind(this);
  
  	this.init(ribbon_message,show,timed,callback);
  
  	function callCallBack(callback){
  		if(typeof callback ==='function'){
  			callback();
  		}
  	}
  };
  
  util.inherits(ribbon,events.EventEmitter);
  
  module.exports = ribbon;
  
  // If there is a window object, that at least has a document property,
  // define linotype
  if ( typeof window === "object" && typeof window.document === "object" ) {
  	window.ribbon = ribbon;
  }
  },{"classie":3,"events":16,"util":20,"util-extend":12}],3:[function(require,module,exports){
  /*
   * classie
   * http://github.amexpub.com/modules/classie
   *
   * Copyright (c) 2013 AmexPub. All rights reserved.
   */
  
  module.exports = require('./lib/classie');
  
  },{"./lib/classie":4}],4:[function(require,module,exports){
  /*!
   * classie - class helper functions
   * from bonzo https://github.com/ded/bonzo
   * 
   * classie.has( elem, 'my-class' ) -> true/false
   * classie.add( elem, 'my-new-class' )
   * classie.remove( elem, 'my-unwanted-class' )
   * classie.toggle( elem, 'my-class' )
   */
  
  /*jshint browser: true, strict: true, undef: true */
  /*global define: false */
  'use strict';
  
    // class helper functions from bonzo https://github.com/ded/bonzo
  
    function classReg( className ) {
      return new RegExp("(^|\\s+)" + className + "(\\s+|$)");
    }
  
    // classList support for class management
    // altho to be fair, the api sucks because it won't accept multiple classes at once
    var hasClass, addClass, removeClass;
  
    if (typeof document === "object" && 'classList' in document.documentElement ) {
      hasClass = function( elem, c ) {
        return elem.classList.contains( c );
      };
      addClass = function( elem, c ) {
        elem.classList.add( c );
      };
      removeClass = function( elem, c ) {
        elem.classList.remove( c );
      };
    }
    else {
      hasClass = function( elem, c ) {
        return classReg( c ).test( elem.className );
      };
      addClass = function( elem, c ) {
        if ( !hasClass( elem, c ) ) {
          elem.className = elem.className + ' ' + c;
        }
      };
      removeClass = function( elem, c ) {
        elem.className = elem.className.replace( classReg( c ), ' ' );
      };
    }
  
    function toggleClass( elem, c ) {
      var fn = hasClass( elem, c ) ? removeClass : addClass;
      fn( elem, c );
    }
  
    var classie = {
      // full names
      hasClass: hasClass,
      addClass: addClass,
      removeClass: removeClass,
      toggleClass: toggleClass,
      // short names
      has: hasClass,
      add: addClass,
      remove: removeClass,
      toggle: toggleClass
    };
  
    // transport
  
    if ( typeof module === "object" && module && typeof module.exports === "object" ) {
      // commonjs / browserify
      module.exports = classie;
    } else {
      // AMD
      define(classie);
    }
  
    // If there is a window object, that at least has a document property,
    // define classie
    if ( typeof window === "object" && typeof window.document === "object" ) {
      window.classie = classie;
    }
  },{}],5:[function(require,module,exports){
  /*
   * manuscript
   * http://github.com/typesettin/silkscreen
   *
   * Copyright (c) 2014 Yaw Joseph Etse. All rights reserved.
   */
  
  module.exports = require('./lib/silkscreen');
  
  },{"./lib/silkscreen":6}],6:[function(require,module,exports){
  /*
   * silkscreen
   * http://github.com/typesettin/silkscreen
   *
   * Copyright (c) 2014 Yaw Joseph Etse. All rights reserved.
   */
  
  'use strict';
  
  var classie = require('classie'),
  	extend = require('util-extend'),
  	events = require('events'),
  	util = require('util');
  
  /**
   * A module that represents a silkscreen.
   * @{@link https://github.com/typesettin/silkscreen}
   * @author Yaw Joseph Etse
   * @copyright Copyright (c) 2014 Typesettin. All rights reserved.
   * @license MIT
   * @module silkscreen
   * @requires module:classie
   * @requires module:util-extent
   * @requires module:util
   * @requires module:events
   * @todo to do later
   */
  var silkscreen = function(config_options,show,hideOverlay,callback){
  	/** module default configuration */
  	// console.log("silkscreen");
  	var options,
  		defaults = {
  			idSelector : '_slks_modal',
  			title : '',
  			message : 'silkscreen',
  			element : null,
  			type : "",
  			effect : 14
  		},
  		container;
  
  	//extend default options
  	options = extend( defaults,config_options );
  
  
  	/** Returns the configuration object 
  	 * @return {object} the module configuration
  	 */
  	this.config = function(){
  		return options;
  	};
  
  	/** 
  	 * The element to clone in child window
  	 * @param {object} element - html element to clone
  	 */
  	this.setSilkscreenContentElement = function(element){
  		options.element = element;
  	};
  
  	/**
  	 * intialize a new platter
  	 */
  	this.init = function(show,hideOverlay,callback){
  		console.log("show",show);
  		this.createOverlay();
  		this.createSilkscreen(options.idSelector);
  		options.element.addEventListener('click',silkscreenClickEventHandler,false);
  		if(show){
  			this.showSilkscreen(options.title,options.message,options.effect,options.type,hideOverlay,callback);
  		}
  	}.bind(this);
  
  	this.setSilkscreenMessage = function(msg){
  		if(typeof msg ==='object'){
  			options.element.querySelector('._slks-msg').innerHTML='';
  			options.element.querySelector('._slks-msg').appendChild(msg);
  		}
  		else{
  			options.element.querySelector('._slks-msg').innerHTML=msg;
  		}
  	};
  
  
  	this.setSilkscreenTitle = function(title){
  		options.element.querySelector('h3').innerHTML=title;
  	};
  
  	/**
  	 * create silkscreen html overlay
  	 */
  	this.createOverlay = function(){
  		if(document.getElementById("_slks-container")){
  			this.emit("silkscreenContainerCreated",false);
  		}
  		else{
  			var silkscreenModalContainer = document.createElement('div');
  			silkscreenModalContainer.setAttribute("id","_slks-container");
  			document.body.appendChild(silkscreenModalContainer);
  			this.emit("silkscreenModalContainerCreated",silkscreenModalContainer);
  		}
  
  		if(document.getElementById("_slks-overlay")){
  			this.emit("silkscreenOverlayCreated",false);
  		}
  		else{
  			var silkscreenContainer = document.createElement('div');
  			silkscreenContainer.setAttribute("id","_slks-overlay");
  			document.body.appendChild(silkscreenContainer);
  			this.emit("silkscreenOverlayCreated",silkscreenContainer);
  		}
  	};
  	/**
  	 * create silkscreen html
  	 * @param {string} id name for platter selector id
  	 */
  	this.createSilkscreen = function(id){
  		var silkscreenHTML = (document.getElementById(id)) ? document.getElementById(id) : document.createElement('div');
  		/** create platter tab html */
  		classie.addClass(silkscreenHTML,'_slks-modal');
  		classie.addClass(silkscreenHTML,'_slks');
  		classie.addClass(silkscreenHTML,'_slks-effect-'+options.effect);
  		silkscreenHTML.id = id;
  
  		var silkscreenContent = document.createElement('div');
  		classie.addClass( silkscreenContent , "_slks-content");
  
  		silkscreenContent.innerHTML ='<h3>'+options.title+"</h3>";
  
  		var silkscreenContentHTML = document.createElement('div');
  		if(options.message){
  			silkscreenContentHTML.innerHTML ='<div class="_slks-msg">'+options.message+'</div>';
  		}
  		else{
  			silkscreenContentHTML.innerHTML ='<div class="_slks-msg">'+silkscreenHTML.innerHTML+'</div>';
  		}
  		// empty div
  		silkscreenHTML.innerHTML='';
  
  		/** add close button to modal div html */
  		var silkscreenCloseBottom = document.createElement('button');
  		classie.addClass( silkscreenCloseBottom , "_slks-close");
  		silkscreenCloseBottom.innerHTML = 'Close';
  
  		silkscreenContentHTML.appendChild(silkscreenCloseBottom);
  		/** add conent to modal div */
  		silkscreenContent.appendChild(silkscreenContentHTML);
  		/** add modal to modal container */
  		silkscreenHTML.appendChild(silkscreenContent);
  		document.querySelector('#_slks-container').appendChild(silkscreenHTML);
  		options.element = document.getElementById(options.idSelector);
  		this.emit("silkscreenCreated",true);
  	};
  	/** hides platter in bar */
  	this.hideSilkscreen = function(){
  		classie.removeClass(options.element.querySelector('._slks-content'),'_slks-type-'+options.type);
  		classie.removeClass(options.element,'_slks-effect-'+options.effect);
  		classie.removeClass(options.element,'_slks-show');
  		classie.removeClass(document.getElementById("_slks-overlay"),'_slks-type-'+options.type);
  		classie.removeClass(document.getElementById("_slks-overlay"),'_slks-show-overlay');
  		this.emit("silkscreenClosed",true);
  	};
  
  	/** show platter in bar */
  	this.showSilkscreen = function(title,message,effect,type,hideOverlay,callback){
  		// console.log("msg",msg,"timed",timed,"type",type,"callback",callback);
  		if(title){
  			this.setSilkscreenTitle(title);
  		}
  		if(message){
  			this.setSilkscreenMessage(message);
  		}
  		options.effect = effect;
  		classie.addClass(options.element,'_slks-effect-'+effect);
  
  		options.type = type;
  		classie.addClass(options.element.querySelector('._slks-content'),'_slks-type-'+type);
  		classie.addClass(document.getElementById("_slks-overlay"),'_slks-type-'+type);
  		var t = setTimeout(function(){
  			classie.addClass(options.element,'_slks-show');
  			clearTimeout(t);
  		},100);
  		if(!hideOverlay){
  			classie.addClass(document.getElementById("_slks-overlay"),'_slks-show-overlay');
  		}
  		callCallBack(callback);
  		this.emit("silkscreenOpened",true);
  	}.bind(this);
  
  	var silkscreenClickEventHandler = function(e){
  		var etarget = e.target;
  		if(classie.hasClass(etarget,'_slks-close')){
  			this.hideSilkscreen();
  		}
  	}.bind(this);
  
  	this.init(show,hideOverlay,callback);
  	function callCallBack(callback){
  		if(typeof callback ==='function'){
  			callback();
  		}
  	}
  };
  
  util.inherits(silkscreen,events.EventEmitter);
  
  module.exports = silkscreen;
  
  // If there is a window object, that at least has a document property,
  // define linotype
  if ( typeof window === "object" && typeof window.document === "object" ) {
  	window.silkscreen = silkscreen;
  }
  },{"classie":7,"events":16,"util":20,"util-extend":12}],7:[function(require,module,exports){
  module.exports=require(3)
  },{"./lib/classie":8}],8:[function(require,module,exports){
  module.exports=require(4)
  },{}],9:[function(require,module,exports){
  /**
   * Module dependencies.
   */
  
  var Emitter = require('emitter');
  var reduce = require('reduce');
  
  /**
   * Root reference for iframes.
   */
  
  var root = 'undefined' == typeof window
    ? this
    : window;
  
  /**
   * Noop.
   */
  
  function noop(){};
  
  /**
   * Check if `obj` is a host object,
   * we don't want to serialize these :)
   *
   * TODO: future proof, move to compoent land
   *
   * @param {Object} obj
   * @return {Boolean}
   * @api private
   */
  
  function isHost(obj) {
    var str = {}.toString.call(obj);
  
    switch (str) {
      case '[object File]':
      case '[object Blob]':
      case '[object FormData]':
        return true;
      default:
        return false;
    }
  }
  
  /**
   * Determine XHR.
   */
  
  function getXHR() {
    if (root.XMLHttpRequest
      && ('file:' != root.location.protocol || !root.ActiveXObject)) {
      return new XMLHttpRequest;
    } else {
      try { return new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) {}
      try { return new ActiveXObject('Msxml2.XMLHTTP.6.0'); } catch(e) {}
      try { return new ActiveXObject('Msxml2.XMLHTTP.3.0'); } catch(e) {}
      try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) {}
    }
    return false;
  }
  
  /**
   * Removes leading and trailing whitespace, added to support IE.
   *
   * @param {String} s
   * @return {String}
   * @api private
   */
  
  var trim = ''.trim
    ? function(s) { return s.trim(); }
    : function(s) { return s.replace(/(^\s*|\s*$)/g, ''); };
  
  /**
   * Check if `obj` is an object.
   *
   * @param {Object} obj
   * @return {Boolean}
   * @api private
   */
  
  function isObject(obj) {
    return obj === Object(obj);
  }
  
  /**
   * Serialize the given `obj`.
   *
   * @param {Object} obj
   * @return {String}
   * @api private
   */
  
  function serialize(obj) {
    if (!isObject(obj)) return obj;
    var pairs = [];
    for (var key in obj) {
      if (null != obj[key]) {
        pairs.push(encodeURIComponent(key)
          + '=' + encodeURIComponent(obj[key]));
      }
    }
    return pairs.join('&');
  }
  
  /**
   * Expose serialization method.
   */
  
   request.serializeObject = serialize;
  
   /**
    * Parse the given x-www-form-urlencoded `str`.
    *
    * @param {String} str
    * @return {Object}
    * @api private
    */
  
  function parseString(str) {
    var obj = {};
    var pairs = str.split('&');
    var parts;
    var pair;
  
    for (var i = 0, len = pairs.length; i < len; ++i) {
      pair = pairs[i];
      parts = pair.split('=');
      obj[decodeURIComponent(parts[0])] = decodeURIComponent(parts[1]);
    }
  
    return obj;
  }
  
  /**
   * Expose parser.
   */
  
  request.parseString = parseString;
  
  /**
   * Default MIME type map.
   *
   *     superagent.types.xml = 'application/xml';
   *
   */
  
  request.types = {
    html: 'text/html',
    json: 'application/json',
    xml: 'application/xml',
    urlencoded: 'application/x-www-form-urlencoded',
    'form': 'application/x-www-form-urlencoded',
    'form-data': 'application/x-www-form-urlencoded'
  };
  
  /**
   * Default serialization map.
   *
   *     superagent.serialize['application/xml'] = function(obj){
   *       return 'generated xml here';
   *     };
   *
   */
  
   request.serialize = {
     'application/x-www-form-urlencoded': serialize,
     'application/json': JSON.stringify
   };
  
   /**
    * Default parsers.
    *
    *     superagent.parse['application/xml'] = function(str){
    *       return { object parsed from str };
    *     };
    *
    */
  
  request.parse = {
    'application/x-www-form-urlencoded': parseString,
    'application/json': JSON.parse
  };
  
  /**
   * Parse the given header `str` into
   * an object containing the mapped fields.
   *
   * @param {String} str
   * @return {Object}
   * @api private
   */
  
  function parseHeader(str) {
    var lines = str.split(/\r?\n/);
    var fields = {};
    var index;
    var line;
    var field;
    var val;
  
    lines.pop(); // trailing CRLF
  
    for (var i = 0, len = lines.length; i < len; ++i) {
      line = lines[i];
      index = line.indexOf(':');
      field = line.slice(0, index).toLowerCase();
      val = trim(line.slice(index + 1));
      fields[field] = val;
    }
  
    return fields;
  }
  
  /**
   * Return the mime type for the given `str`.
   *
   * @param {String} str
   * @return {String}
   * @api private
   */
  
  function type(str){
    return str.split(/ *; */).shift();
  };
  
  /**
   * Return header field parameters.
   *
   * @param {String} str
   * @return {Object}
   * @api private
   */
  
  function params(str){
    return reduce(str.split(/ *; */), function(obj, str){
      var parts = str.split(/ *= */)
        , key = parts.shift()
        , val = parts.shift();
  
      if (key && val) obj[key] = val;
      return obj;
    }, {});
  };
  
  /**
   * Initialize a new `Response` with the given `xhr`.
   *
   *  - set flags (.ok, .error, etc)
   *  - parse header
   *
   * Examples:
   *
   *  Aliasing `superagent` as `request` is nice:
   *
   *      request = superagent;
   *
   *  We can use the promise-like API, or pass callbacks:
   *
   *      request.get('/').end(function(res){});
   *      request.get('/', function(res){});
   *
   *  Sending data can be chained:
   *
   *      request
   *        .post('/user')
   *        .send({ name: 'tj' })
   *        .end(function(res){});
   *
   *  Or passed to `.send()`:
   *
   *      request
   *        .post('/user')
   *        .send({ name: 'tj' }, function(res){});
   *
   *  Or passed to `.post()`:
   *
   *      request
   *        .post('/user', { name: 'tj' })
   *        .end(function(res){});
   *
   * Or further reduced to a single call for simple cases:
   *
   *      request
   *        .post('/user', { name: 'tj' }, function(res){});
   *
   * @param {XMLHTTPRequest} xhr
   * @param {Object} options
   * @api private
   */
  
  function Response(req, options) {
    options = options || {};
    this.req = req;
    this.xhr = this.req.xhr;
    this.text = this.xhr.responseText;
    this.setStatusProperties(this.xhr.status);
    this.header = this.headers = parseHeader(this.xhr.getAllResponseHeaders());
    // getAllResponseHeaders sometimes falsely returns "" for CORS requests, but
    // getResponseHeader still works. so we get content-type even if getting
    // other headers fails.
    this.header['content-type'] = this.xhr.getResponseHeader('content-type');
    this.setHeaderProperties(this.header);
    this.body = this.req.method != 'HEAD'
      ? this.parseBody(this.text)
      : null;
  }
  
  /**
   * Get case-insensitive `field` value.
   *
   * @param {String} field
   * @return {String}
   * @api public
   */
  
  Response.prototype.get = function(field){
    return this.header[field.toLowerCase()];
  };
  
  /**
   * Set header related properties:
   *
   *   - `.type` the content type without params
   *
   * A response of "Content-Type: text/plain; charset=utf-8"
   * will provide you with a `.type` of "text/plain".
   *
   * @param {Object} header
   * @api private
   */
  
  Response.prototype.setHeaderProperties = function(header){
    // content-type
    var ct = this.header['content-type'] || '';
    this.type = type(ct);
  
    // params
    var obj = params(ct);
    for (var key in obj) this[key] = obj[key];
  };
  
  /**
   * Parse the given body `str`.
   *
   * Used for auto-parsing of bodies. Parsers
   * are defined on the `superagent.parse` object.
   *
   * @param {String} str
   * @return {Mixed}
   * @api private
   */
  
  Response.prototype.parseBody = function(str){
    var parse = request.parse[this.type];
    return parse
      ? parse(str)
      : null;
  };
  
  /**
   * Set flags such as `.ok` based on `status`.
   *
   * For example a 2xx response will give you a `.ok` of __true__
   * whereas 5xx will be __false__ and `.error` will be __true__. The
   * `.clientError` and `.serverError` are also available to be more
   * specific, and `.statusType` is the class of error ranging from 1..5
   * sometimes useful for mapping respond colors etc.
   *
   * "sugar" properties are also defined for common cases. Currently providing:
   *
   *   - .noContent
   *   - .badRequest
   *   - .unauthorized
   *   - .notAcceptable
   *   - .notFound
   *
   * @param {Number} status
   * @api private
   */
  
  Response.prototype.setStatusProperties = function(status){
    var type = status / 100 | 0;
  
    // status / class
    this.status = status;
    this.statusType = type;
  
    // basics
    this.info = 1 == type;
    this.ok = 2 == type;
    this.clientError = 4 == type;
    this.serverError = 5 == type;
    this.error = (4 == type || 5 == type)
      ? this.toError()
      : false;
  
    // sugar
    this.accepted = 202 == status;
    this.noContent = 204 == status || 1223 == status;
    this.badRequest = 400 == status;
    this.unauthorized = 401 == status;
    this.notAcceptable = 406 == status;
    this.notFound = 404 == status;
    this.forbidden = 403 == status;
  };
  
  /**
   * Return an `Error` representative of this response.
   *
   * @return {Error}
   * @api public
   */
  
  Response.prototype.toError = function(){
    var req = this.req;
    var method = req.method;
    var url = req.url;
  
    var msg = 'cannot ' + method + ' ' + url + ' (' + this.status + ')';
    var err = new Error(msg);
    err.status = this.status;
    err.method = method;
    err.url = url;
  
    return err;
  };
  
  /**
   * Expose `Response`.
   */
  
  request.Response = Response;
  
  /**
   * Initialize a new `Request` with the given `method` and `url`.
   *
   * @param {String} method
   * @param {String} url
   * @api public
   */
  
  function Request(method, url) {
    var self = this;
    Emitter.call(this);
    this._query = this._query || [];
    this.method = method;
    this.url = url;
    this.header = {};
    this._header = {};
    this.on('end', function(){
      var res = new Response(self);
      if ('HEAD' == method) res.text = null;
      self.callback(null, res);
    });
  }
  
  /**
   * Mixin `Emitter`.
   */
  
  Emitter(Request.prototype);
  
  /**
   * Allow for extension
   */
  
  Request.prototype.use = function(fn) {
    fn(this);
    return this;
  }
  
  /**
   * Set timeout to `ms`.
   *
   * @param {Number} ms
   * @return {Request} for chaining
   * @api public
   */
  
  Request.prototype.timeout = function(ms){
    this._timeout = ms;
    return this;
  };
  
  /**
   * Clear previous timeout.
   *
   * @return {Request} for chaining
   * @api public
   */
  
  Request.prototype.clearTimeout = function(){
    this._timeout = 0;
    clearTimeout(this._timer);
    return this;
  };
  
  /**
   * Abort the request, and clear potential timeout.
   *
   * @return {Request}
   * @api public
   */
  
  Request.prototype.abort = function(){
    if (this.aborted) return;
    this.aborted = true;
    this.xhr.abort();
    this.clearTimeout();
    this.emit('abort');
    return this;
  };
  
  /**
   * Set header `field` to `val`, or multiple fields with one object.
   *
   * Examples:
   *
   *      req.get('/')
   *        .set('Accept', 'application/json')
   *        .set('X-API-Key', 'foobar')
   *        .end(callback);
   *
   *      req.get('/')
   *        .set({ Accept: 'application/json', 'X-API-Key': 'foobar' })
   *        .end(callback);
   *
   * @param {String|Object} field
   * @param {String} val
   * @return {Request} for chaining
   * @api public
   */
  
  Request.prototype.set = function(field, val){
    if (isObject(field)) {
      for (var key in field) {
        this.set(key, field[key]);
      }
      return this;
    }
    this._header[field.toLowerCase()] = val;
    this.header[field] = val;
    return this;
  };
  
  /**
   * Get case-insensitive header `field` value.
   *
   * @param {String} field
   * @return {String}
   * @api private
   */
  
  Request.prototype.getHeader = function(field){
    return this._header[field.toLowerCase()];
  };
  
  /**
   * Set Content-Type to `type`, mapping values from `request.types`.
   *
   * Examples:
   *
   *      superagent.types.xml = 'application/xml';
   *
   *      request.post('/')
   *        .type('xml')
   *        .send(xmlstring)
   *        .end(callback);
   *
   *      request.post('/')
   *        .type('application/xml')
   *        .send(xmlstring)
   *        .end(callback);
   *
   * @param {String} type
   * @return {Request} for chaining
   * @api public
   */
  
  Request.prototype.type = function(type){
    this.set('Content-Type', request.types[type] || type);
    return this;
  };
  
  /**
   * Set Accept to `type`, mapping values from `request.types`.
   *
   * Examples:
   *
   *      superagent.types.json = 'application/json';
   *
   *      request.get('/agent')
   *        .accept('json')
   *        .end(callback);
   *
   *      request.get('/agent')
   *        .accept('application/json')
   *        .end(callback);
   *
   * @param {String} accept
   * @return {Request} for chaining
   * @api public
   */
  
  Request.prototype.accept = function(type){
    this.set('Accept', request.types[type] || type);
    return this;
  };
  
  /**
   * Set Authorization field value with `user` and `pass`.
   *
   * @param {String} user
   * @param {String} pass
   * @return {Request} for chaining
   * @api public
   */
  
  Request.prototype.auth = function(user, pass){
    var str = btoa(user + ':' + pass);
    this.set('Authorization', 'Basic ' + str);
    return this;
  };
  
  /**
  * Add query-string `val`.
  *
  * Examples:
  *
  *   request.get('/shoes')
  *     .query('size=10')
  *     .query({ color: 'blue' })
  *
  * @param {Object|String} val
  * @return {Request} for chaining
  * @api public
  */
  
  Request.prototype.query = function(val){
    if ('string' != typeof val) val = serialize(val);
    if (val) this._query.push(val);
    return this;
  };
  
  /**
   * Write the field `name` and `val` for "multipart/form-data"
   * request bodies.
   *
   * ``` js
   * request.post('/upload')
   *   .field('foo', 'bar')
   *   .end(callback);
   * ```
   *
   * @param {String} name
   * @param {String|Blob|File} val
   * @return {Request} for chaining
   * @api public
   */
  
  Request.prototype.field = function(name, val){
    if (!this._formData) this._formData = new FormData();
    this._formData.append(name, val);
    return this;
  };
  
  /**
   * Queue the given `file` as an attachment to the specified `field`,
   * with optional `filename`.
   *
   * ``` js
   * request.post('/upload')
   *   .attach(new Blob(['<a id="a"><b id="b">hey!</b></a>'], { type: "text/html"}))
   *   .end(callback);
   * ```
   *
   * @param {String} field
   * @param {Blob|File} file
   * @param {String} filename
   * @return {Request} for chaining
   * @api public
   */
  
  Request.prototype.attach = function(field, file, filename){
    if (!this._formData) this._formData = new FormData();
    this._formData.append(field, file, filename);
    return this;
  };
  
  /**
   * Send `data`, defaulting the `.type()` to "json" when
   * an object is given.
   *
   * Examples:
   *
   *       // querystring
   *       request.get('/search')
   *         .end(callback)
   *
   *       // multiple data "writes"
   *       request.get('/search')
   *         .send({ search: 'query' })
   *         .send({ range: '1..5' })
   *         .send({ order: 'desc' })
   *         .end(callback)
   *
   *       // manual json
   *       request.post('/user')
   *         .type('json')
   *         .send('{"name":"tj"})
   *         .end(callback)
   *
   *       // auto json
   *       request.post('/user')
   *         .send({ name: 'tj' })
   *         .end(callback)
   *
   *       // manual x-www-form-urlencoded
   *       request.post('/user')
   *         .type('form')
   *         .send('name=tj')
   *         .end(callback)
   *
   *       // auto x-www-form-urlencoded
   *       request.post('/user')
   *         .type('form')
   *         .send({ name: 'tj' })
   *         .end(callback)
   *
   *       // defaults to x-www-form-urlencoded
    *      request.post('/user')
    *        .send('name=tobi')
    *        .send('species=ferret')
    *        .end(callback)
   *
   * @param {String|Object} data
   * @return {Request} for chaining
   * @api public
   */
  
  Request.prototype.send = function(data){
    var obj = isObject(data);
    var type = this.getHeader('Content-Type');
  
    // merge
    if (obj && isObject(this._data)) {
      for (var key in data) {
        this._data[key] = data[key];
      }
    } else if ('string' == typeof data) {
      if (!type) this.type('form');
      type = this.getHeader('Content-Type');
      if ('application/x-www-form-urlencoded' == type) {
        this._data = this._data
          ? this._data + '&' + data
          : data;
      } else {
        this._data = (this._data || '') + data;
      }
    } else {
      this._data = data;
    }
  
    if (!obj) return this;
    if (!type) this.type('json');
    return this;
  };
  
  /**
   * Invoke the callback with `err` and `res`
   * and handle arity check.
   *
   * @param {Error} err
   * @param {Response} res
   * @api private
   */
  
  Request.prototype.callback = function(err, res){
    var fn = this._callback;
    if (2 == fn.length) return fn(err, res);
    if (err) return this.emit('error', err);
    fn(res);
  };
  
  /**
   * Invoke callback with x-domain error.
   *
   * @api private
   */
  
  Request.prototype.crossDomainError = function(){
    var err = new Error('Origin is not allowed by Access-Control-Allow-Origin');
    err.crossDomain = true;
    this.callback(err);
  };
  
  /**
   * Invoke callback with timeout error.
   *
   * @api private
   */
  
  Request.prototype.timeoutError = function(){
    var timeout = this._timeout;
    var err = new Error('timeout of ' + timeout + 'ms exceeded');
    err.timeout = timeout;
    this.callback(err);
  };
  
  /**
   * Enable transmission of cookies with x-domain requests.
   *
   * Note that for this to work the origin must not be
   * using "Access-Control-Allow-Origin" with a wildcard,
   * and also must set "Access-Control-Allow-Credentials"
   * to "true".
   *
   * @api public
   */
  
  Request.prototype.withCredentials = function(){
    this._withCredentials = true;
    return this;
  };
  
  /**
   * Initiate request, invoking callback `fn(res)`
   * with an instanceof `Response`.
   *
   * @param {Function} fn
   * @return {Request} for chaining
   * @api public
   */
  
  Request.prototype.end = function(fn){
    var self = this;
    var xhr = this.xhr = getXHR();
    var query = this._query.join('&');
    var timeout = this._timeout;
    var data = this._formData || this._data;
  
    // store callback
    this._callback = fn || noop;
  
    // state change
    xhr.onreadystatechange = function(){
      if (4 != xhr.readyState) return;
      if (0 == xhr.status) {
        if (self.aborted) return self.timeoutError();
        return self.crossDomainError();
      }
      self.emit('end');
    };
  
    // progress
    if (xhr.upload) {
      xhr.upload.onprogress = function(e){
        e.percent = e.loaded / e.total * 100;
        self.emit('progress', e);
      };
    }
  
    // timeout
    if (timeout && !this._timer) {
      this._timer = setTimeout(function(){
        self.abort();
      }, timeout);
    }
  
    // querystring
    if (query) {
      query = request.serializeObject(query);
      this.url += ~this.url.indexOf('?')
        ? '&' + query
        : '?' + query;
    }
  
    // initiate request
    xhr.open(this.method, this.url, true);
  
    // CORS
    if (this._withCredentials) xhr.withCredentials = true;
  
    // body
    if ('GET' != this.method && 'HEAD' != this.method && 'string' != typeof data && !isHost(data)) {
      // serialize stuff
      var serialize = request.serialize[this.getHeader('Content-Type')];
      if (serialize) data = serialize(data);
    }
  
    // set header fields
    for (var field in this.header) {
      if (null == this.header[field]) continue;
      xhr.setRequestHeader(field, this.header[field]);
    }
  
    // send stuff
    this.emit('request', this);
    xhr.send(data);
    return this;
  };
  
  /**
   * Expose `Request`.
   */
  
  request.Request = Request;
  
  /**
   * Issue a request:
   *
   * Examples:
   *
   *    request('GET', '/users').end(callback)
   *    request('/users').end(callback)
   *    request('/users', callback)
   *
   * @param {String} method
   * @param {String|Function} url or callback
   * @return {Request}
   * @api public
   */
  
  function request(method, url) {
    // callback
    if ('function' == typeof url) {
      return new Request('GET', method).end(url);
    }
  
    // url first
    if (1 == arguments.length) {
      return new Request('GET', method);
    }
  
    return new Request(method, url);
  }
  
  /**
   * GET `url` with optional callback `fn(res)`.
   *
   * @param {String} url
   * @param {Mixed|Function} data or fn
   * @param {Function} fn
   * @return {Request}
   * @api public
   */
  
  request.get = function(url, data, fn){
    var req = request('GET', url);
    if ('function' == typeof data) fn = data, data = null;
    if (data) req.query(data);
    if (fn) req.end(fn);
    return req;
  };
  
  /**
   * HEAD `url` with optional callback `fn(res)`.
   *
   * @param {String} url
   * @param {Mixed|Function} data or fn
   * @param {Function} fn
   * @return {Request}
   * @api public
   */
  
  request.head = function(url, data, fn){
    var req = request('HEAD', url);
    if ('function' == typeof data) fn = data, data = null;
    if (data) req.send(data);
    if (fn) req.end(fn);
    return req;
  };
  
  /**
   * DELETE `url` with optional callback `fn(res)`.
   *
   * @param {String} url
   * @param {Function} fn
   * @return {Request}
   * @api public
   */
  
  request.del = function(url, fn){
    var req = request('DELETE', url);
    if (fn) req.end(fn);
    return req;
  };
  
  /**
   * PATCH `url` with optional `data` and callback `fn(res)`.
   *
   * @param {String} url
   * @param {Mixed} data
   * @param {Function} fn
   * @return {Request}
   * @api public
   */
  
  request.patch = function(url, data, fn){
    var req = request('PATCH', url);
    if ('function' == typeof data) fn = data, data = null;
    if (data) req.send(data);
    if (fn) req.end(fn);
    return req;
  };
  
  /**
   * POST `url` with optional `data` and callback `fn(res)`.
   *
   * @param {String} url
   * @param {Mixed} data
   * @param {Function} fn
   * @return {Request}
   * @api public
   */
  
  request.post = function(url, data, fn){
    var req = request('POST', url);
    if ('function' == typeof data) fn = data, data = null;
    if (data) req.send(data);
    if (fn) req.end(fn);
    return req;
  };
  
  /**
   * PUT `url` with optional `data` and callback `fn(res)`.
   *
   * @param {String} url
   * @param {Mixed|Function} data or fn
   * @param {Function} fn
   * @return {Request}
   * @api public
   */
  
  request.put = function(url, data, fn){
    var req = request('PUT', url);
    if ('function' == typeof data) fn = data, data = null;
    if (data) req.send(data);
    if (fn) req.end(fn);
    return req;
  };
  
  /**
   * Expose `request`.
   */
  
  module.exports = request;
  
  },{"emitter":10,"reduce":11}],10:[function(require,module,exports){
  
  /**
   * Expose `Emitter`.
   */
  
  module.exports = Emitter;
  
  /**
   * Initialize a new `Emitter`.
   *
   * @api public
   */
  
  function Emitter(obj) {
    if (obj) return mixin(obj);
  };
  
  /**
   * Mixin the emitter properties.
   *
   * @param {Object} obj
   * @return {Object}
   * @api private
   */
  
  function mixin(obj) {
    for (var key in Emitter.prototype) {
      obj[key] = Emitter.prototype[key];
    }
    return obj;
  }
  
  /**
   * Listen on the given `event` with `fn`.
   *
   * @param {String} event
   * @param {Function} fn
   * @return {Emitter}
   * @api public
   */
  
  Emitter.prototype.on =
  Emitter.prototype.addEventListener = function(event, fn){
    this._callbacks = this._callbacks || {};
    (this._callbacks[event] = this._callbacks[event] || [])
      .push(fn);
    return this;
  };
  
  /**
   * Adds an `event` listener that will be invoked a single
   * time then automatically removed.
   *
   * @param {String} event
   * @param {Function} fn
   * @return {Emitter}
   * @api public
   */
  
  Emitter.prototype.once = function(event, fn){
    var self = this;
    this._callbacks = this._callbacks || {};
  
    function on() {
      self.off(event, on);
      fn.apply(this, arguments);
    }
  
    on.fn = fn;
    this.on(event, on);
    return this;
  };
  
  /**
   * Remove the given callback for `event` or all
   * registered callbacks.
   *
   * @param {String} event
   * @param {Function} fn
   * @return {Emitter}
   * @api public
   */
  
  Emitter.prototype.off =
  Emitter.prototype.removeListener =
  Emitter.prototype.removeAllListeners =
  Emitter.prototype.removeEventListener = function(event, fn){
    this._callbacks = this._callbacks || {};
  
    // all
    if (0 == arguments.length) {
      this._callbacks = {};
      return this;
    }
  
    // specific event
    var callbacks = this._callbacks[event];
    if (!callbacks) return this;
  
    // remove all handlers
    if (1 == arguments.length) {
      delete this._callbacks[event];
      return this;
    }
  
    // remove specific handler
    var cb;
    for (var i = 0; i < callbacks.length; i++) {
      cb = callbacks[i];
      if (cb === fn || cb.fn === fn) {
        callbacks.splice(i, 1);
        break;
      }
    }
    return this;
  };
  
  /**
   * Emit `event` with the given args.
   *
   * @param {String} event
   * @param {Mixed} ...
   * @return {Emitter}
   */
  
  Emitter.prototype.emit = function(event){
    this._callbacks = this._callbacks || {};
    var args = [].slice.call(arguments, 1)
      , callbacks = this._callbacks[event];
  
    if (callbacks) {
      callbacks = callbacks.slice(0);
      for (var i = 0, len = callbacks.length; i < len; ++i) {
        callbacks[i].apply(this, args);
      }
    }
  
    return this;
  };
  
  /**
   * Return array of callbacks for `event`.
   *
   * @param {String} event
   * @return {Array}
   * @api public
   */
  
  Emitter.prototype.listeners = function(event){
    this._callbacks = this._callbacks || {};
    return this._callbacks[event] || [];
  };
  
  /**
   * Check if this emitter has `event` handlers.
   *
   * @param {String} event
   * @return {Boolean}
   * @api public
   */
  
  Emitter.prototype.hasListeners = function(event){
    return !! this.listeners(event).length;
  };
  
  },{}],11:[function(require,module,exports){
  
  /**
   * Reduce `arr` with `fn`.
   *
   * @param {Array} arr
   * @param {Function} fn
   * @param {Mixed} initial
   *
   * TODO: combatible error handling?
   */
  
  module.exports = function(arr, fn, initial){  
    var idx = 0;
    var len = arr.length;
    var curr = arguments.length == 3
      ? initial
      : arr[idx++];
  
    while (idx < len) {
      curr = fn.call(null, curr, arr[idx], ++idx, arr);
    }
    
    return curr;
  };
  },{}],12:[function(require,module,exports){
  // Copyright Joyent, Inc. and other Node contributors.
  //
  // Permission is hereby granted, free of charge, to any person obtaining a
  // copy of this software and associated documentation files (the
  // "Software"), to deal in the Software without restriction, including
  // without limitation the rights to use, copy, modify, merge, publish,
  // distribute, sublicense, and/or sell copies of the Software, and to permit
  // persons to whom the Software is furnished to do so, subject to the
  // following conditions:
  //
  // The above copyright notice and this permission notice shall be included
  // in all copies or substantial portions of the Software.
  //
  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  // USE OR OTHER DEALINGS IN THE SOFTWARE.
  
  module.exports = extend;
  function extend(origin, add) {
    // Don't do anything if add isn't an object
    if (!add || typeof add !== 'object') return origin;
  
    var keys = Object.keys(add);
    var i = keys.length;
    while (i--) {
      origin[keys[i]] = add[keys[i]];
    }
    return origin;
  }
  
  },{}],13:[function(require,module,exports){
  'use strict';
  
  var preventSubmitOnEnter = function(e){
  			// console.log("key press");
  			if ( e.which === 13 || e.keyCode === 13  ) {
  				// console.log(e);
  				// console.log("prevent submit");
  				e.preventDefault();
  				return false;
  			}
  		},
  		request = require('superagent'),
  		formobj = require('./formtoobject');
  
  var ajaxform = function(options){
  };
  
  ajaxform.preventEnterSubmitListeners = function(){
  	var noSubmitElements = document.querySelectorAll('.noFormSubmit');
  	for(var x in noSubmitElements){
  		if(typeof noSubmitElements[x] ==='object'){
  			noSubmitElements[x].addEventListener("keypress",preventSubmitOnEnter,false);
  			noSubmitElements[x].addEventListener("keydown",preventSubmitOnEnter,false);
  		}
  	}
  	document.addEventListener("keypress",preventSubmitOnEnter,false);
  };
  
  ajaxform.makeNiceName = function(username) {
  	if (username) {
  		return username.replace(/[^a-z0-9]/gi, '-').toLowerCase();
  	}
  	else {
  		return false;
  	}
  };
  
  ajaxform.ajaxFormEventListers = function(selector,ribbonNotification){
  	var ajaxforms = document.querySelectorAll(selector);
  	// console.log("ajaxforms",ajaxforms);
  	for(var x in ajaxforms){
  		if(typeof ajaxforms[x] ==='object'){
  			// console.log(new FormData(ajaxforms[x]));
  			ajaxforms[x].addEventListener("submit",function(e){
  				e.preventDefault();
  				var f = e.target;
  				if(f.getAttribute("data-beforesubmitfunction")){
  					var beforesubmitFunctionString = f.getAttribute("data-beforesubmitfunction"),
  					beforefn = window[beforesubmitFunctionString];
  					// is object a function?
  					if (typeof beforefn === "function"){beforefn(e)};
  				}
  				var formData = new formobj(f);
  				
  				request
  					.post(f.action)
  					.set('x-csrf-token',document.querySelector('input[name=_csrf]').value)
  					.set('Accept', 'application/json')
  					.query({ format: 'json' })
  					.send(formData)
  					.end(function(error, res){
  						if(res && res.body && res.body.result==='error'){
  							ribbonNotification.showRibbon( res.body.data.error,4000,'error');
  						}
  						else if(res && res.clientError){
  							ribbonNotification.showRibbon( res.status+": "+res.text,4000,'error');
  						}
  						else if(error){
  							ribbonNotification.showRibbon( error.message ,4000,'error');
  						}
  						else{
  							if(!f.getAttribute("data-blockdefaultsuccess") && f.getAttribute("data-successfunction")){
  								ribbonNotification.showRibbon("saved",4000,'success');
  							}
  							if(f.getAttribute("data-successfunction")){
  								var successFunctionString = f.getAttribute("data-successfunction"),
  								successfn = window[successFunctionString];
  								// is object a function?
  								if (typeof successfn === "function"){successfn(res.body.data)};
  							}
  						}
  					});
  
  			},false);
  		}
  	}
  };
  
  module.exports = ajaxform;
  },{"./formtoobject":14,"superagent":9}],14:[function(require,module,exports){
  'use strict';
  
  var formToObject = function( formRef ){
  
  	if( !formRef ){ return false; }
  
  	this.formRef       = formRef;
  	this.keyRegex      = /[^\[\]]+/g;
  	this.$form         = null;
  	this.$formElements = [];
  	this.formObj       = {};
  
  	if( !this.setForm() ){ return false; }
  	if( !this.setFormElements() ){ return false; }
  
  	return this.setFormObj();
  
  };
  
  // Set the main form object we are working on.
  formToObject.prototype.setForm = function(){
  
  	switch( typeof this.formRef ){
  
  		case 'string':
  			this.$form = document.getElementById( this.formRef );
  		break;
  
  		case 'object':
  			if( this.isDomNode(this.formRef) ){
  				this.$form = this.formRef;
  			}
  		break;
  
  	}
  
  	return this.$form;
  
  };
  
  // Set the elements we need to parse.
  formToObject.prototype.setFormElements = function(){
  	this.$formElements = this.$form.querySelectorAll('input, button, textarea, select');
  	return this.$formElements.length;
  };
  
  // Check to see if the object is a HTML node.
  formToObject.prototype.isDomNode = function( node ){
  	return typeof node === "object" && "nodeType" in node && node.nodeType === 1;
  };
  
  // Iteration through arrays and objects. Compatible with IE.
  formToObject.prototype.forEach = function( arr, callback ){
  
  	if([].forEach){
  		return [].forEach.call(arr, callback);
  	}
  
  	var i;
  	for(i in arr){
  		// Object.prototype.hasOwnProperty instead of arr.hasOwnProperty for IE8 compatibility.
  		if( Object.prototype.hasOwnProperty.call(arr,i) ){
  			callback.call(arr, arr[i]);
  		}
  	}
  
  	return;
  
  }
  
  // Recursive method that adds keys and values of the corresponding fields.
  formToObject.prototype.addChild = function( result, domNode, keys, value ){
  
  	// #1 - Single dimensional array.
  	if(keys.length === 1){
  
  		// We're only interested in the radio that is checked.
  		if( domNode.nodeName === 'INPUT' && domNode.type === 'radio' ) {
  			if( domNode.checked ){
  				return result[keys] = value;
  			} else {
  				return;
  			}
  		}
  
  		// Checkboxes are a special case. We have to grab each checked values
  		// and put them into an array.
  		if( domNode.nodeName === 'INPUT' && domNode.type === 'checkbox' ) {
  
  			if( domNode.checked ){
  
  				if( !result[keys] ){
  					result[keys] = [];
  				}
  				return result[keys].push( value );
  
  			} else {
  				return;
  			}
  
  		}
  
  		// Multiple select is a special case.
  		// We have to grab each selected option and put them into an array.
  		if( domNode.nodeName === 'SELECT' && domNode.type === 'select-multiple' ) {
  
  			result[keys] = [];
  			var DOMchilds = domNode.querySelectorAll('option[selected]');
  			if( DOMchilds ){
  				this.forEach(DOMchilds, function(child){
  					result[keys].push( child.value );
  				});
  			}
  			return;
  
  		}
  
  		// Fallback. The default one to one assign.
  		result[keys] = value;
  
  	}
  
  	// #2 - Multi dimensional array.
  	if(keys.length > 1) {
  
  		if(!result[keys[0]]){
  			result[keys[0]] = {};
  		}
  
  		return this.addChild(result[keys[0]], domNode, keys.splice(1, keys.length), value);
  
  	}
  
  	return result;
  
  };
  
  formToObject.prototype.setFormObj = function(){
  
  	var test, i = 0;
  
  	for(i = 0; i < this.$formElements.length; i++){
  		// Ignore the element if the 'name' attribute is empty.
  		// Ignore the 'disabled' elements.
  		if( this.$formElements[i].name && !this.$formElements[i].disabled ) {
  			test = this.$formElements[i].name.match( this.keyRegex );
  			this.addChild( this.formObj, this.$formElements[i], test, this.$formElements[i].value );
  		}
  	}
  
  	return this.formObj;
  
  }
  
  module.exports =formToObject;
  },{}],15:[function(require,module,exports){
  'use strict';
  
  var ajaxform = require('./ajaxform'),
  		request = require('superagent'),
  		ribbon = require('ribbonjs'),
  		silkscreen = require('silkscreenjs'),
  		installadmin,
  		installform,
  		consoleOutput;
  
  window.addEventListener("load",function(){
  	window.silkscreenModal = new silkscreen(),
  	window.ribbonNotification = new ribbon({type:"info",idSelector:"#_pea_ribbon-element"});
  	installadmin = document.getElementById("install-admin-select");
  	installform = document.getElementById("install_form");
  	consoleOutput = document.getElementById("install-console-output");
  	ajaxform.preventEnterSubmitListeners();
  	ajaxform.ajaxFormEventListers('._pea-ajaxforms',window.ribbonNotification);
  	installadmin.addEventListener("change",showadminoptions,false);
  	installform.addEventListener("click",installformclick,false);
  });
  
  var showadminoptions = function(e){
  	var eTarget = e.target;
  	if(eTarget.value==="true"){
  		document.getElementById("admin-install-info").style.display="block";
  	}
  	else{
  		document.getElementById("admin-install-info").style.display="none";
  	}
  };
  
  var installformclick = function(e){
  	var eTarget = e.target;
  	if(eTarget.getAttribute("class") && eTarget.getAttribute("class").match("pop-tooltip")){
  		var modalelement = document.getElementById(eTarget.getAttribute("data-id"));
  		silkscreenModal.showSilkscreen(modalelement.getAttribute("data-title"),modalelement,14,"default");
  	}
  };
  
  var getConsoleOutput = function(){
  	var t = setInterval(function(){
  				getOutputFromFile();
  			},2000),
  			otf,
  			cnt=0,
  			lastres='outputlog',
  			MAXLOGREQUESTS = 100,
  			getRequest = '/install/getlog';
  	consoleOutput.innerHTML='';
  
  	var getOutputFromFile = function(){
  		request
  			.get(getRequest)
  			.set('Accept', ' text/plain')
  			.end(function(error, res){
  				// console.log("made request",cnt, error,res);
  
  				if(res && res.error){
  					ribbonNotification.showRibbon( res.error.message || res.text ,8000,'error');
  					// console.log("error in ajax for file log data");
  					try{
  						if((res && res.error) || cnt >MAXLOGREQUESTS){
  							clearTimeout(t);
  						}
  					}
  					catch(e){
  						console.warn("error",e);
  					}
  				}
  				if(error){
  					ribbonNotification.showRibbon( error.message || res.text ,8000,'error');
  					// console.log("error in ajax for file log data");
  					try{
  						if((res && res.error) || cnt >MAXLOGREQUESTS){
  							clearTimeout(t);
  						}
  					}
  					catch(e){
  						console.warn("error",e);
  					}
  				}
  				else{
  					if(cnt>MAXLOGREQUESTS){
  						console.warn("made "+MAXLOGREQUESTS+" req stop ajax");
  						clearTimeout(t);
  					}
  					// console.log(cnt);
  					// console.log(res.text);
  					if(res.text!==lastres){
  						otf = document.createElement("pre");
  						otf.innerHTML=res.text;
  						consoleOutput.appendChild(otf);
  						consoleOutput.scrollTop=consoleOutput.scrollHeight;
  					}
  					
  					if(res.text.match('====##CONFIGURED##====')){
  						ribbonNotification.showRibbon( 'installed, refresh window to get started' ,false,'success');
  						silkscreenModal.showSilkscreen('Install Complete',"Lets get <a href='"+window.location.href+"'>started</a>. ","default");
  						clearTimeout(t);
  					}
  					else if(res.text.match('====!!ERROR!!====') || res.text.match('====##REMOVED-END##====')){
  						// console.error("there was an error in installing periodic");
  						var errortext = res.error.message || '';
  						silkscreenModal.showSilkscreen('Install error',"there was an error in installing periodic. "+errortext,14,"error");
  						ribbonNotification.showRibbon(' there was an error in installing periodic' ,4000,'warn');
  						clearTimeout(t);
  					}
  					lastres=res.text;
  					cnt++;
  				}
  			});
  	}
  };
  
  
  window.successFormPost = function(resdata){
  	// console.log("resdata",resdata);
  	document.getElementById("install-console").style.display="block";
  	getConsoleOutput();
  	ribbonNotification.showRibbon( 'beginning installation' ,4000,'info');
  };
  },{"./ajaxform":13,"ribbonjs":1,"silkscreenjs":5,"superagent":9}],16:[function(require,module,exports){
  // Copyright Joyent, Inc. and other Node contributors.
  //
  // Permission is hereby granted, free of charge, to any person obtaining a
  // copy of this software and associated documentation files (the
  // "Software"), to deal in the Software without restriction, including
  // without limitation the rights to use, copy, modify, merge, publish,
  // distribute, sublicense, and/or sell copies of the Software, and to permit
  // persons to whom the Software is furnished to do so, subject to the
  // following conditions:
  //
  // The above copyright notice and this permission notice shall be included
  // in all copies or substantial portions of the Software.
  //
  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  // USE OR OTHER DEALINGS IN THE SOFTWARE.
  
  function EventEmitter() {
    this._events = this._events || {};
    this._maxListeners = this._maxListeners || undefined;
  }
  module.exports = EventEmitter;
  
  // Backwards-compat with node 0.10.x
  EventEmitter.EventEmitter = EventEmitter;
  
  EventEmitter.prototype._events = undefined;
  EventEmitter.prototype._maxListeners = undefined;
  
  // By default EventEmitters will print a warning if more than 10 listeners are
  // added to it. This is a useful default which helps finding memory leaks.
  EventEmitter.defaultMaxListeners = 10;
  
  // Obviously not all Emitters should be limited to 10. This function allows
  // that to be increased. Set to zero for unlimited.
  EventEmitter.prototype.setMaxListeners = function(n) {
    if (!isNumber(n) || n < 0 || isNaN(n))
      throw TypeError('n must be a positive number');
    this._maxListeners = n;
    return this;
  };
  
  EventEmitter.prototype.emit = function(type) {
    var er, handler, len, args, i, listeners;
  
    if (!this._events)
      this._events = {};
  
    // If there is no 'error' event listener then throw.
    if (type === 'error') {
      if (!this._events.error ||
          (isObject(this._events.error) && !this._events.error.length)) {
        er = arguments[1];
        if (er instanceof Error) {
          throw er; // Unhandled 'error' event
        } else {
          throw TypeError('Uncaught, unspecified "error" event.');
        }
        return false;
      }
    }
  
    handler = this._events[type];
  
    if (isUndefined(handler))
      return false;
  
    if (isFunction(handler)) {
      switch (arguments.length) {
        // fast cases
        case 1:
          handler.call(this);
          break;
        case 2:
          handler.call(this, arguments[1]);
          break;
        case 3:
          handler.call(this, arguments[1], arguments[2]);
          break;
        // slower
        default:
          len = arguments.length;
          args = new Array(len - 1);
          for (i = 1; i < len; i++)
            args[i - 1] = arguments[i];
          handler.apply(this, args);
      }
    } else if (isObject(handler)) {
      len = arguments.length;
      args = new Array(len - 1);
      for (i = 1; i < len; i++)
        args[i - 1] = arguments[i];
  
      listeners = handler.slice();
      len = listeners.length;
      for (i = 0; i < len; i++)
        listeners[i].apply(this, args);
    }
  
    return true;
  };
  
  EventEmitter.prototype.addListener = function(type, listener) {
    var m;
  
    if (!isFunction(listener))
      throw TypeError('listener must be a function');
  
    if (!this._events)
      this._events = {};
  
    // To avoid recursion in the case that type === "newListener"! Before
    // adding it to the listeners, first emit "newListener".
    if (this._events.newListener)
      this.emit('newListener', type,
                isFunction(listener.listener) ?
                listener.listener : listener);
  
    if (!this._events[type])
      // Optimize the case of one listener. Don't need the extra array object.
      this._events[type] = listener;
    else if (isObject(this._events[type]))
      // If we've already got an array, just append.
      this._events[type].push(listener);
    else
      // Adding the second element, need to change to array.
      this._events[type] = [this._events[type], listener];
  
    // Check for listener leak
    if (isObject(this._events[type]) && !this._events[type].warned) {
      var m;
      if (!isUndefined(this._maxListeners)) {
        m = this._maxListeners;
      } else {
        m = EventEmitter.defaultMaxListeners;
      }
  
      if (m && m > 0 && this._events[type].length > m) {
        this._events[type].warned = true;
        console.error('(node) warning: possible EventEmitter memory ' +
                      'leak detected. %d listeners added. ' +
                      'Use emitter.setMaxListeners() to increase limit.',
                      this._events[type].length);
        if (typeof console.trace === 'function') {
          // not supported in IE 10
          console.trace();
        }
      }
    }
  
    return this;
  };
  
  EventEmitter.prototype.on = EventEmitter.prototype.addListener;
  
  EventEmitter.prototype.once = function(type, listener) {
    if (!isFunction(listener))
      throw TypeError('listener must be a function');
  
    var fired = false;
  
    function g() {
      this.removeListener(type, g);
  
      if (!fired) {
        fired = true;
        listener.apply(this, arguments);
      }
    }
  
    g.listener = listener;
    this.on(type, g);
  
    return this;
  };
  
  // emits a 'removeListener' event iff the listener was removed
  EventEmitter.prototype.removeListener = function(type, listener) {
    var list, position, length, i;
  
    if (!isFunction(listener))
      throw TypeError('listener must be a function');
  
    if (!this._events || !this._events[type])
      return this;
  
    list = this._events[type];
    length = list.length;
    position = -1;
  
    if (list === listener ||
        (isFunction(list.listener) && list.listener === listener)) {
      delete this._events[type];
      if (this._events.removeListener)
        this.emit('removeListener', type, listener);
  
    } else if (isObject(list)) {
      for (i = length; i-- > 0;) {
        if (list[i] === listener ||
            (list[i].listener && list[i].listener === listener)) {
          position = i;
          break;
        }
      }
  
      if (position < 0)
        return this;
  
      if (list.length === 1) {
        list.length = 0;
        delete this._events[type];
      } else {
        list.splice(position, 1);
      }
  
      if (this._events.removeListener)
        this.emit('removeListener', type, listener);
    }
  
    return this;
  };
  
  EventEmitter.prototype.removeAllListeners = function(type) {
    var key, listeners;
  
    if (!this._events)
      return this;
  
    // not listening for removeListener, no need to emit
    if (!this._events.removeListener) {
      if (arguments.length === 0)
        this._events = {};
      else if (this._events[type])
        delete this._events[type];
      return this;
    }
  
    // emit removeListener for all listeners on all events
    if (arguments.length === 0) {
      for (key in this._events) {
        if (key === 'removeListener') continue;
        this.removeAllListeners(key);
      }
      this.removeAllListeners('removeListener');
      this._events = {};
      return this;
    }
  
    listeners = this._events[type];
  
    if (isFunction(listeners)) {
      this.removeListener(type, listeners);
    } else {
      // LIFO order
      while (listeners.length)
        this.removeListener(type, listeners[listeners.length - 1]);
    }
    delete this._events[type];
  
    return this;
  };
  
  EventEmitter.prototype.listeners = function(type) {
    var ret;
    if (!this._events || !this._events[type])
      ret = [];
    else if (isFunction(this._events[type]))
      ret = [this._events[type]];
    else
      ret = this._events[type].slice();
    return ret;
  };
  
  EventEmitter.listenerCount = function(emitter, type) {
    var ret;
    if (!emitter._events || !emitter._events[type])
      ret = 0;
    else if (isFunction(emitter._events[type]))
      ret = 1;
    else
      ret = emitter._events[type].length;
    return ret;
  };
  
  function isFunction(arg) {
    return typeof arg === 'function';
  }
  
  function isNumber(arg) {
    return typeof arg === 'number';
  }
  
  function isObject(arg) {
    return typeof arg === 'object' && arg !== null;
  }
  
  function isUndefined(arg) {
    return arg === void 0;
  }
  
  },{}],17:[function(require,module,exports){
  if (typeof Object.create === 'function') {
    // implementation from standard node.js 'util' module
    module.exports = function inherits(ctor, superCtor) {
      ctor.super_ = superCtor
      ctor.prototype = Object.create(superCtor.prototype, {
        constructor: {
          value: ctor,
          enumerable: false,
          writable: true,
          configurable: true
        }
      });
    };
  } else {
    // old school shim for old browsers
    module.exports = function inherits(ctor, superCtor) {
      ctor.super_ = superCtor
      var TempCtor = function () {}
      TempCtor.prototype = superCtor.prototype
      ctor.prototype = new TempCtor()
      ctor.prototype.constructor = ctor
    }
  }
  
  },{}],18:[function(require,module,exports){
  // shim for using process in browser
  
  var process = module.exports = {};
  
  process.nextTick = (function () {
      var canSetImmediate = typeof window !== 'undefined'
      && window.setImmediate;
      var canPost = typeof window !== 'undefined'
      && window.postMessage && window.addEventListener
      ;
  
      if (canSetImmediate) {
          return function (f) { return window.setImmediate(f) };
      }
  
      if (canPost) {
          var queue = [];
          window.addEventListener('message', function (ev) {
              var source = ev.source;
              if ((source === window || source === null) && ev.data === 'process-tick') {
                  ev.stopPropagation();
                  if (queue.length > 0) {
                      var fn = queue.shift();
                      fn();
                  }
              }
          }, true);
  
          return function nextTick(fn) {
              queue.push(fn);
              window.postMessage('process-tick', '*');
          };
      }
  
      return function nextTick(fn) {
          setTimeout(fn, 0);
      };
  })();
  
  process.title = 'browser';
  process.browser = true;
  process.env = {};
  process.argv = [];
  
  function noop() {}
  
  process.on = noop;
  process.addListener = noop;
  process.once = noop;
  process.off = noop;
  process.removeListener = noop;
  process.removeAllListeners = noop;
  process.emit = noop;
  
  process.binding = function (name) {
      throw new Error('process.binding is not supported');
  }
  
  // TODO(shtylman)
  process.cwd = function () { return '/' };
  process.chdir = function (dir) {
      throw new Error('process.chdir is not supported');
  };
  
  },{}],19:[function(require,module,exports){
  module.exports = function isBuffer(arg) {
    return arg && typeof arg === 'object'
      && typeof arg.copy === 'function'
      && typeof arg.fill === 'function'
      && typeof arg.readUInt8 === 'function';
  }
  },{}],20:[function(require,module,exports){
  (function (process,global){
  // Copyright Joyent, Inc. and other Node contributors.
  //
  // Permission is hereby granted, free of charge, to any person obtaining a
  // copy of this software and associated documentation files (the
  // "Software"), to deal in the Software without restriction, including
  // without limitation the rights to use, copy, modify, merge, publish,
  // distribute, sublicense, and/or sell copies of the Software, and to permit
  // persons to whom the Software is furnished to do so, subject to the
  // following conditions:
  //
  // The above copyright notice and this permission notice shall be included
  // in all copies or substantial portions of the Software.
  //
  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  // USE OR OTHER DEALINGS IN THE SOFTWARE.
  
  var formatRegExp = /%[sdj%]/g;
  exports.format = function(f) {
    if (!isString(f)) {
      var objects = [];
      for (var i = 0; i < arguments.length; i++) {
        objects.push(inspect(arguments[i]));
      }
      return objects.join(' ');
    }
  
    var i = 1;
    var args = arguments;
    var len = args.length;
    var str = String(f).replace(formatRegExp, function(x) {
      if (x === '%%') return '%';
      if (i >= len) return x;
      switch (x) {
        case '%s': return String(args[i++]);
        case '%d': return Number(args[i++]);
        case '%j':
          try {
            return JSON.stringify(args[i++]);
          } catch (_) {
            return '[Circular]';
          }
        default:
          return x;
      }
    });
    for (var x = args[i]; i < len; x = args[++i]) {
      if (isNull(x) || !isObject(x)) {
        str += ' ' + x;
      } else {
        str += ' ' + inspect(x);
      }
    }
    return str;
  };
  
  
  // Mark that a method should not be used.
  // Returns a modified function which warns once by default.
  // If --no-deprecation is set, then it is a no-op.
  exports.deprecate = function(fn, msg) {
    // Allow for deprecating things in the process of starting up.
    if (isUndefined(global.process)) {
      return function() {
        return exports.deprecate(fn, msg).apply(this, arguments);
      };
    }
  
    if (process.noDeprecation === true) {
      return fn;
    }
  
    var warned = false;
    function deprecated() {
      if (!warned) {
        if (process.throwDeprecation) {
          throw new Error(msg);
        } else if (process.traceDeprecation) {
          console.trace(msg);
        } else {
          console.error(msg);
        }
        warned = true;
      }
      return fn.apply(this, arguments);
    }
  
    return deprecated;
  };
  
  
  var debugs = {};
  var debugEnviron;
  exports.debuglog = function(set) {
    if (isUndefined(debugEnviron))
      debugEnviron = process.env.NODE_DEBUG || '';
    set = set.toUpperCase();
    if (!debugs[set]) {
      if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
        var pid = process.pid;
        debugs[set] = function() {
          var msg = exports.format.apply(exports, arguments);
          console.error('%s %d: %s', set, pid, msg);
        };
      } else {
        debugs[set] = function() {};
      }
    }
    return debugs[set];
  };
  
  
  /**
   * Echos the value of a value. Trys to print the value out
   * in the best way possible given the different types.
   *
   * @param {Object} obj The object to print out.
   * @param {Object} opts Optional options object that alters the output.
   */
  /* legacy: obj, showHidden, depth, colors*/
  function inspect(obj, opts) {
    // default options
    var ctx = {
      seen: [],
      stylize: stylizeNoColor
    };
    // legacy...
    if (arguments.length >= 3) ctx.depth = arguments[2];
    if (arguments.length >= 4) ctx.colors = arguments[3];
    if (isBoolean(opts)) {
      // legacy...
      ctx.showHidden = opts;
    } else if (opts) {
      // got an "options" object
      exports._extend(ctx, opts);
    }
    // set default options
    if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
    if (isUndefined(ctx.depth)) ctx.depth = 2;
    if (isUndefined(ctx.colors)) ctx.colors = false;
    if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
    if (ctx.colors) ctx.stylize = stylizeWithColor;
    return formatValue(ctx, obj, ctx.depth);
  }
  exports.inspect = inspect;
  
  
  // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
  inspect.colors = {
    'bold' : [1, 22],
    'italic' : [3, 23],
    'underline' : [4, 24],
    'inverse' : [7, 27],
    'white' : [37, 39],
    'grey' : [90, 39],
    'black' : [30, 39],
    'blue' : [34, 39],
    'cyan' : [36, 39],
    'green' : [32, 39],
    'magenta' : [35, 39],
    'red' : [31, 39],
    'yellow' : [33, 39]
  };
  
  // Don't use 'blue' not visible on cmd.exe
  inspect.styles = {
    'special': 'cyan',
    'number': 'yellow',
    'boolean': 'yellow',
    'undefined': 'grey',
    'null': 'bold',
    'string': 'green',
    'date': 'magenta',
    // "name": intentionally not styling
    'regexp': 'red'
  };
  
  
  function stylizeWithColor(str, styleType) {
    var style = inspect.styles[styleType];
  
    if (style) {
      return '\u001b[' + inspect.colors[style][0] + 'm' + str +
             '\u001b[' + inspect.colors[style][1] + 'm';
    } else {
      return str;
    }
  }
  
  
  function stylizeNoColor(str, styleType) {
    return str;
  }
  
  
  function arrayToHash(array) {
    var hash = {};
  
    array.forEach(function(val, idx) {
      hash[val] = true;
    });
  
    return hash;
  }
  
  
  function formatValue(ctx, value, recurseTimes) {
    // Provide a hook for user-specified inspect functions.
    // Check that value is an object with an inspect function on it
    if (ctx.customInspect &&
        value &&
        isFunction(value.inspect) &&
        // Filter out the util module, it's inspect function is special
        value.inspect !== exports.inspect &&
        // Also filter out any prototype objects using the circular check.
        !(value.constructor && value.constructor.prototype === value)) {
      var ret = value.inspect(recurseTimes, ctx);
      if (!isString(ret)) {
        ret = formatValue(ctx, ret, recurseTimes);
      }
      return ret;
    }
  
    // Primitive types cannot have properties
    var primitive = formatPrimitive(ctx, value);
    if (primitive) {
      return primitive;
    }
  
    // Look up the keys of the object.
    var keys = Object.keys(value);
    var visibleKeys = arrayToHash(keys);
  
    if (ctx.showHidden) {
      keys = Object.getOwnPropertyNames(value);
    }
  
    // IE doesn't make error fields non-enumerable
    // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
    if (isError(value)
        && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
      return formatError(value);
    }
  
    // Some type of object without properties can be shortcutted.
    if (keys.length === 0) {
      if (isFunction(value)) {
        var name = value.name ? ': ' + value.name : '';
        return ctx.stylize('[Function' + name + ']', 'special');
      }
      if (isRegExp(value)) {
        return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
      }
      if (isDate(value)) {
        return ctx.stylize(Date.prototype.toString.call(value), 'date');
      }
      if (isError(value)) {
        return formatError(value);
      }
    }
  
    var base = '', array = false, braces = ['{', '}'];
  
    // Make Array say that they are Array
    if (isArray(value)) {
      array = true;
      braces = ['[', ']'];
    }
  
    // Make functions say that they are functions
    if (isFunction(value)) {
      var n = value.name ? ': ' + value.name : '';
      base = ' [Function' + n + ']';
    }
  
    // Make RegExps say that they are RegExps
    if (isRegExp(value)) {
      base = ' ' + RegExp.prototype.toString.call(value);
    }
  
    // Make dates with properties first say the date
    if (isDate(value)) {
      base = ' ' + Date.prototype.toUTCString.call(value);
    }
  
    // Make error with message first say the error
    if (isError(value)) {
      base = ' ' + formatError(value);
    }
  
    if (keys.length === 0 && (!array || value.length == 0)) {
      return braces[0] + base + braces[1];
    }
  
    if (recurseTimes < 0) {
      if (isRegExp(value)) {
        return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
      } else {
        return ctx.stylize('[Object]', 'special');
      }
    }
  
    ctx.seen.push(value);
  
    var output;
    if (array) {
      output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
    } else {
      output = keys.map(function(key) {
        return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
      });
    }
  
    ctx.seen.pop();
  
    return reduceToSingleString(output, base, braces);
  }
  
  
  function formatPrimitive(ctx, value) {
    if (isUndefined(value))
      return ctx.stylize('undefined', 'undefined');
    if (isString(value)) {
      var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
                                               .replace(/'/g, "\\'")
                                               .replace(/\\"/g, '"') + '\'';
      return ctx.stylize(simple, 'string');
    }
    if (isNumber(value))
      return ctx.stylize('' + value, 'number');
    if (isBoolean(value))
      return ctx.stylize('' + value, 'boolean');
    // For some reason typeof null is "object", so special case here.
    if (isNull(value))
      return ctx.stylize('null', 'null');
  }
  
  
  function formatError(value) {
    return '[' + Error.prototype.toString.call(value) + ']';
  }
  
  
  function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
    var output = [];
    for (var i = 0, l = value.length; i < l; ++i) {
      if (hasOwnProperty(value, String(i))) {
        output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
            String(i), true));
      } else {
        output.push('');
      }
    }
    keys.forEach(function(key) {
      if (!key.match(/^\d+$/)) {
        output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
            key, true));
      }
    });
    return output;
  }
  
  
  function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
    var name, str, desc;
    desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
    if (desc.get) {
      if (desc.set) {
        str = ctx.stylize('[Getter/Setter]', 'special');
      } else {
        str = ctx.stylize('[Getter]', 'special');
      }
    } else {
      if (desc.set) {
        str = ctx.stylize('[Setter]', 'special');
      }
    }
    if (!hasOwnProperty(visibleKeys, key)) {
      name = '[' + key + ']';
    }
    if (!str) {
      if (ctx.seen.indexOf(desc.value) < 0) {
        if (isNull(recurseTimes)) {
          str = formatValue(ctx, desc.value, null);
        } else {
          str = formatValue(ctx, desc.value, recurseTimes - 1);
        }
        if (str.indexOf('\n') > -1) {
          if (array) {
            str = str.split('\n').map(function(line) {
              return '  ' + line;
            }).join('\n').substr(2);
          } else {
            str = '\n' + str.split('\n').map(function(line) {
              return '   ' + line;
            }).join('\n');
          }
        }
      } else {
        str = ctx.stylize('[Circular]', 'special');
      }
    }
    if (isUndefined(name)) {
      if (array && key.match(/^\d+$/)) {
        return str;
      }
      name = JSON.stringify('' + key);
      if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
        name = name.substr(1, name.length - 2);
        name = ctx.stylize(name, 'name');
      } else {
        name = name.replace(/'/g, "\\'")
                   .replace(/\\"/g, '"')
                   .replace(/(^"|"$)/g, "'");
        name = ctx.stylize(name, 'string');
      }
    }
  
    return name + ': ' + str;
  }
  
  
  function reduceToSingleString(output, base, braces) {
    var numLinesEst = 0;
    var length = output.reduce(function(prev, cur) {
      numLinesEst++;
      if (cur.indexOf('\n') >= 0) numLinesEst++;
      return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
    }, 0);
  
    if (length > 60) {
      return braces[0] +
             (base === '' ? '' : base + '\n ') +
             ' ' +
             output.join(',\n  ') +
             ' ' +
             braces[1];
    }
  
    return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
  }
  
  
  // NOTE: These type checking functions intentionally don't use `instanceof`
  // because it is fragile and can be easily faked with `Object.create()`.
  function isArray(ar) {
    return Array.isArray(ar);
  }
  exports.isArray = isArray;
  
  function isBoolean(arg) {
    return typeof arg === 'boolean';
  }
  exports.isBoolean = isBoolean;
  
  function isNull(arg) {
    return arg === null;
  }
  exports.isNull = isNull;
  
  function isNullOrUndefined(arg) {
    return arg == null;
  }
  exports.isNullOrUndefined = isNullOrUndefined;
  
  function isNumber(arg) {
    return typeof arg === 'number';
  }
  exports.isNumber = isNumber;
  
  function isString(arg) {
    return typeof arg === 'string';
  }
  exports.isString = isString;
  
  function isSymbol(arg) {
    return typeof arg === 'symbol';
  }
  exports.isSymbol = isSymbol;
  
  function isUndefined(arg) {
    return arg === void 0;
  }
  exports.isUndefined = isUndefined;
  
  function isRegExp(re) {
    return isObject(re) && objectToString(re) === '[object RegExp]';
  }
  exports.isRegExp = isRegExp;
  
  function isObject(arg) {
    return typeof arg === 'object' && arg !== null;
  }
  exports.isObject = isObject;
  
  function isDate(d) {
    return isObject(d) && objectToString(d) === '[object Date]';
  }
  exports.isDate = isDate;
  
  function isError(e) {
    return isObject(e) &&
        (objectToString(e) === '[object Error]' || e instanceof Error);
  }
  exports.isError = isError;
  
  function isFunction(arg) {
    return typeof arg === 'function';
  }
  exports.isFunction = isFunction;
  
  function isPrimitive(arg) {
    return arg === null ||
           typeof arg === 'boolean' ||
           typeof arg === 'number' ||
           typeof arg === 'string' ||
           typeof arg === 'symbol' ||  // ES6 symbol
           typeof arg === 'undefined';
  }
  exports.isPrimitive = isPrimitive;
  
  exports.isBuffer = require('./support/isBuffer');
  
  function objectToString(o) {
    return Object.prototype.toString.call(o);
  }
  
  
  function pad(n) {
    return n < 10 ? '0' + n.toString(10) : n.toString(10);
  }
  
  
  var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
                'Oct', 'Nov', 'Dec'];
  
  // 26 Feb 16:19:34
  function timestamp() {
    var d = new Date();
    var time = [pad(d.getHours()),
                pad(d.getMinutes()),
                pad(d.getSeconds())].join(':');
    return [d.getDate(), months[d.getMonth()], time].join(' ');
  }
  
  
  // log is just a thin wrapper to console.log that prepends a timestamp
  exports.log = function() {
    console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
  };
  
  
  /**
   * Inherit the prototype methods from one constructor into another.
   *
   * The Function.prototype.inherits from lang.js rewritten as a standalone
   * function (not on Function.prototype). NOTE: If this file is to be loaded
   * during bootstrapping this function needs to be rewritten using some native
   * functions as prototype setup using normal JavaScript does not work as
   * expected during bootstrapping (see mirror.js in r114903).
   *
   * @param {function} ctor Constructor function which needs to inherit the
   *     prototype.
   * @param {function} superCtor Constructor function to inherit prototype from.
   */
  exports.inherits = require('inherits');
  
  exports._extend = function(origin, add) {
    // Don't do anything if add isn't an object
    if (!add || !isObject(add)) return origin;
  
    var keys = Object.keys(add);
    var i = keys.length;
    while (i--) {
      origin[keys[i]] = add[keys[i]];
    }
    return origin;
  };
  
  function hasOwnProperty(obj, prop) {
    return Object.prototype.hasOwnProperty.call(obj, prop);
  }
  
  }).call(this,require("0NpzKc"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  },{"./support/isBuffer":19,"0NpzKc":18,"inherits":17}]},{},[15])