UNPKG

chess-ai-random

Version:
1,618 lines (1,469 loc) 108 kB
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.chessAiRandom = f()}})(function(){var define,module,exports;return (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);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.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){ /* The MIT License (MIT) Original Library - Copyright (c) Marak Squires Additional functionality - Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) 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 colors = {}; module['exports'] = colors; colors.themes = {}; var ansiStyles = colors.styles = require('./styles'); var defineProps = Object.defineProperties; colors.supportsColor = require('./system/supports-colors'); if (typeof colors.enabled === "undefined") { colors.enabled = colors.supportsColor; } colors.stripColors = colors.strip = function(str){ return ("" + str).replace(/\x1B\[\d+m/g, ''); }; var stylize = colors.stylize = function stylize (str, style) { if (!colors.enabled) { return str+''; } return ansiStyles[style].open + str + ansiStyles[style].close; } var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g; var escapeStringRegexp = function (str) { if (typeof str !== 'string') { throw new TypeError('Expected a string'); } return str.replace(matchOperatorsRe, '\\$&'); } function build(_styles) { var builder = function builder() { return applyStyle.apply(builder, arguments); }; builder._styles = _styles; // __proto__ is used because we must return a function, but there is // no way to create a function with a different prototype. builder.__proto__ = proto; return builder; } var styles = (function () { var ret = {}; ansiStyles.grey = ansiStyles.gray; Object.keys(ansiStyles).forEach(function (key) { ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g'); ret[key] = { get: function () { return build(this._styles.concat(key)); } }; }); return ret; })(); var proto = defineProps(function colors() {}, styles); function applyStyle() { var args = arguments; var argsLen = args.length; var str = argsLen !== 0 && String(arguments[0]); if (argsLen > 1) { for (var a = 1; a < argsLen; a++) { str += ' ' + args[a]; } } if (!colors.enabled || !str) { return str; } var nestedStyles = this._styles; var i = nestedStyles.length; while (i--) { var code = ansiStyles[nestedStyles[i]]; str = code.open + str.replace(code.closeRe, code.open) + code.close; } return str; } function applyTheme (theme) { for (var style in theme) { (function(style){ colors[style] = function(str){ if (typeof theme[style] === 'object'){ var out = str; for (var i in theme[style]){ out = colors[theme[style][i]](out); } return out; } return colors[theme[style]](str); }; })(style) } } colors.setTheme = function (theme) { if (typeof theme === 'string') { try { colors.themes[theme] = require(theme); applyTheme(colors.themes[theme]); return colors.themes[theme]; } catch (err) { console.log(err); return err; } } else { applyTheme(theme); } }; function init() { var ret = {}; Object.keys(styles).forEach(function (name) { ret[name] = { get: function () { return build([name]); } }; }); return ret; } var sequencer = function sequencer (map, str) { var exploded = str.split(""), i = 0; exploded = exploded.map(map); return exploded.join(""); }; // custom formatter methods colors.trap = require('./custom/trap'); colors.zalgo = require('./custom/zalgo'); // maps colors.maps = {}; colors.maps.america = require('./maps/america'); colors.maps.zebra = require('./maps/zebra'); colors.maps.rainbow = require('./maps/rainbow'); colors.maps.random = require('./maps/random') for (var map in colors.maps) { (function(map){ colors[map] = function (str) { return sequencer(colors.maps[map], str); } })(map) } defineProps(colors, init()); },{"./custom/trap":2,"./custom/zalgo":3,"./maps/america":6,"./maps/rainbow":7,"./maps/random":8,"./maps/zebra":9,"./styles":10,"./system/supports-colors":11}],2:[function(require,module,exports){ module['exports'] = function runTheTrap (text, options) { var result = ""; text = text || "Run the trap, drop the bass"; text = text.split(''); var trap = { a: ["\u0040", "\u0104", "\u023a", "\u0245", "\u0394", "\u039b", "\u0414"], b: ["\u00df", "\u0181", "\u0243", "\u026e", "\u03b2", "\u0e3f"], c: ["\u00a9", "\u023b", "\u03fe"], d: ["\u00d0", "\u018a", "\u0500" , "\u0501" ,"\u0502", "\u0503"], e: ["\u00cb", "\u0115", "\u018e", "\u0258", "\u03a3", "\u03be", "\u04bc", "\u0a6c"], f: ["\u04fa"], g: ["\u0262"], h: ["\u0126", "\u0195", "\u04a2", "\u04ba", "\u04c7", "\u050a"], i: ["\u0f0f"], j: ["\u0134"], k: ["\u0138", "\u04a0", "\u04c3", "\u051e"], l: ["\u0139"], m: ["\u028d", "\u04cd", "\u04ce", "\u0520", "\u0521", "\u0d69"], n: ["\u00d1", "\u014b", "\u019d", "\u0376", "\u03a0", "\u048a"], o: ["\u00d8", "\u00f5", "\u00f8", "\u01fe", "\u0298", "\u047a", "\u05dd", "\u06dd", "\u0e4f"], p: ["\u01f7", "\u048e"], q: ["\u09cd"], r: ["\u00ae", "\u01a6", "\u0210", "\u024c", "\u0280", "\u042f"], s: ["\u00a7", "\u03de", "\u03df", "\u03e8"], t: ["\u0141", "\u0166", "\u0373"], u: ["\u01b1", "\u054d"], v: ["\u05d8"], w: ["\u0428", "\u0460", "\u047c", "\u0d70"], x: ["\u04b2", "\u04fe", "\u04fc", "\u04fd"], y: ["\u00a5", "\u04b0", "\u04cb"], z: ["\u01b5", "\u0240"] } text.forEach(function(c){ c = c.toLowerCase(); var chars = trap[c] || [" "]; var rand = Math.floor(Math.random() * chars.length); if (typeof trap[c] !== "undefined") { result += trap[c][rand]; } else { result += c; } }); return result; } },{}],3:[function(require,module,exports){ // please no module['exports'] = function zalgo(text, options) { text = text || " he is here "; var soul = { "up" : [ '̍', '̎', '̄', '̅', '̿', '̑', '̆', '̐', '͒', '͗', '͑', '̇', '̈', '̊', '͂', '̓', '̈', '͊', '͋', '͌', '̃', '̂', '̌', '͐', '̀', '́', '̋', '̏', '̒', '̓', '̔', '̽', '̉', 'ͣ', 'ͤ', 'ͥ', 'ͦ', 'ͧ', 'ͨ', 'ͩ', 'ͪ', 'ͫ', 'ͬ', 'ͭ', 'ͮ', 'ͯ', '̾', '͛', '͆', '̚' ], "down" : [ '̖', '̗', '̘', '̙', '̜', '̝', '̞', '̟', '̠', '̤', '̥', '̦', '̩', '̪', '̫', '̬', '̭', '̮', '̯', '̰', '̱', '̲', '̳', '̹', '̺', '̻', '̼', 'ͅ', '͇', '͈', '͉', '͍', '͎', '͓', '͔', '͕', '͖', '͙', '͚', '̣' ], "mid" : [ '̕', '̛', '̀', '́', '͘', '̡', '̢', '̧', '̨', '̴', '̵', '̶', '͜', '͝', '͞', '͟', '͠', '͢', '̸', '̷', '͡', ' ҉' ] }, all = [].concat(soul.up, soul.down, soul.mid), zalgo = {}; function randomNumber(range) { var r = Math.floor(Math.random() * range); return r; } function is_char(character) { var bool = false; all.filter(function (i) { bool = (i === character); }); return bool; } function heComes(text, options) { var result = '', counts, l; options = options || {}; options["up"] = typeof options["up"] !== 'undefined' ? options["up"] : true; options["mid"] = typeof options["mid"] !== 'undefined' ? options["mid"] : true; options["down"] = typeof options["down"] !== 'undefined' ? options["down"] : true; options["size"] = typeof options["size"] !== 'undefined' ? options["size"] : "maxi"; text = text.split(''); for (l in text) { if (is_char(l)) { continue; } result = result + text[l]; counts = {"up" : 0, "down" : 0, "mid" : 0}; switch (options.size) { case 'mini': counts.up = randomNumber(8); counts.mid = randomNumber(2); counts.down = randomNumber(8); break; case 'maxi': counts.up = randomNumber(16) + 3; counts.mid = randomNumber(4) + 1; counts.down = randomNumber(64) + 3; break; default: counts.up = randomNumber(8) + 1; counts.mid = randomNumber(6) / 2; counts.down = randomNumber(8) + 1; break; } var arr = ["up", "mid", "down"]; for (var d in arr) { var index = arr[d]; for (var i = 0 ; i <= counts[index]; i++) { if (options[index]) { result = result + soul[index][randomNumber(soul[index].length)]; } } } } return result; } // don't summon him return heComes(text, options); } },{}],4:[function(require,module,exports){ var colors = require('./colors'); module['exports'] = function () { // // Extends prototype of native string object to allow for "foo".red syntax // var addProperty = function (color, func) { String.prototype.__defineGetter__(color, func); }; var sequencer = function sequencer (map, str) { return function () { var exploded = this.split(""), i = 0; exploded = exploded.map(map); return exploded.join(""); } }; addProperty('strip', function () { return colors.strip(this); }); addProperty('stripColors', function () { return colors.strip(this); }); addProperty("trap", function(){ return colors.trap(this); }); addProperty("zalgo", function(){ return colors.zalgo(this); }); addProperty("zebra", function(){ return colors.zebra(this); }); addProperty("rainbow", function(){ return colors.rainbow(this); }); addProperty("random", function(){ return colors.random(this); }); addProperty("america", function(){ return colors.america(this); }); // // Iterate through all default styles and colors // var x = Object.keys(colors.styles); x.forEach(function (style) { addProperty(style, function () { return colors.stylize(this, style); }); }); function applyTheme(theme) { // // Remark: This is a list of methods that exist // on String that you should not overwrite. // var stringPrototypeBlacklist = [ '__defineGetter__', '__defineSetter__', '__lookupGetter__', '__lookupSetter__', 'charAt', 'constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf', 'charCodeAt', 'indexOf', 'lastIndexof', 'length', 'localeCompare', 'match', 'replace', 'search', 'slice', 'split', 'substring', 'toLocaleLowerCase', 'toLocaleUpperCase', 'toLowerCase', 'toUpperCase', 'trim', 'trimLeft', 'trimRight' ]; Object.keys(theme).forEach(function (prop) { if (stringPrototypeBlacklist.indexOf(prop) !== -1) { console.log('warn: '.red + ('String.prototype' + prop).magenta + ' is probably something you don\'t want to override. Ignoring style name'); } else { if (typeof(theme[prop]) === 'string') { colors[prop] = colors[theme[prop]]; addProperty(prop, function () { return colors[theme[prop]](this); }); } else { addProperty(prop, function () { var ret = this; for (var t = 0; t < theme[prop].length; t++) { ret = colors[theme[prop][t]](ret); } return ret; }); } } }); } colors.setTheme = function (theme) { if (typeof theme === 'string') { try { colors.themes[theme] = require(theme); applyTheme(colors.themes[theme]); return colors.themes[theme]; } catch (err) { console.log(err); return err; } } else { applyTheme(theme); } }; }; },{"./colors":1}],5:[function(require,module,exports){ var colors = require('./colors'); module['exports'] = colors; // Remark: By default, colors will add style properties to String.prototype // // If you don't wish to extend String.prototype you can do this instead and native String will not be touched // // var colors = require('colors/safe); // colors.red("foo") // // require('./extendStringPrototype')(); },{"./colors":1,"./extendStringPrototype":4}],6:[function(require,module,exports){ var colors = require('../colors'); module['exports'] = (function() { return function (letter, i, exploded) { if(letter === " ") return letter; switch(i%3) { case 0: return colors.red(letter); case 1: return colors.white(letter) case 2: return colors.blue(letter) } } })(); },{"../colors":1}],7:[function(require,module,exports){ var colors = require('../colors'); module['exports'] = (function () { var rainbowColors = ['red', 'yellow', 'green', 'blue', 'magenta']; //RoY G BiV return function (letter, i, exploded) { if (letter === " ") { return letter; } else { return colors[rainbowColors[i++ % rainbowColors.length]](letter); } }; })(); },{"../colors":1}],8:[function(require,module,exports){ var colors = require('../colors'); module['exports'] = (function () { var available = ['underline', 'inverse', 'grey', 'yellow', 'red', 'green', 'blue', 'white', 'cyan', 'magenta']; return function(letter, i, exploded) { return letter === " " ? letter : colors[available[Math.round(Math.random() * (available.length - 1))]](letter); }; })(); },{"../colors":1}],9:[function(require,module,exports){ var colors = require('../colors'); module['exports'] = function (letter, i, exploded) { return i % 2 === 0 ? letter : colors.inverse(letter); }; },{"../colors":1}],10:[function(require,module,exports){ /* The MIT License (MIT) Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) 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 styles = {}; module['exports'] = styles; var codes = { reset: [0, 0], bold: [1, 22], dim: [2, 22], italic: [3, 23], underline: [4, 24], inverse: [7, 27], hidden: [8, 28], strikethrough: [9, 29], black: [30, 39], red: [31, 39], green: [32, 39], yellow: [33, 39], blue: [34, 39], magenta: [35, 39], cyan: [36, 39], white: [37, 39], gray: [90, 39], grey: [90, 39], bgBlack: [40, 49], bgRed: [41, 49], bgGreen: [42, 49], bgYellow: [43, 49], bgBlue: [44, 49], bgMagenta: [45, 49], bgCyan: [46, 49], bgWhite: [47, 49], // legacy styles for colors pre v1.0.0 blackBG: [40, 49], redBG: [41, 49], greenBG: [42, 49], yellowBG: [43, 49], blueBG: [44, 49], magentaBG: [45, 49], cyanBG: [46, 49], whiteBG: [47, 49] }; Object.keys(codes).forEach(function (key) { var val = codes[key]; var style = styles[key] = []; style.open = '\u001b[' + val[0] + 'm'; style.close = '\u001b[' + val[1] + 'm'; }); },{}],11:[function(require,module,exports){ (function (process){ /* The MIT License (MIT) Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) 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 argv = process.argv; module.exports = (function () { if (argv.indexOf('--no-color') !== -1 || argv.indexOf('--color=false') !== -1) { return false; } if (argv.indexOf('--color') !== -1 || argv.indexOf('--color=true') !== -1 || argv.indexOf('--color=always') !== -1) { return true; } if (process.stdout && !process.stdout.isTTY) { return false; } if (process.platform === 'win32') { return true; } if ('COLORTERM' in process.env) { return true; } if (process.env.TERM === 'dumb') { return false; } if (/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)) { return true; } return false; })(); }).call(this,require('_process')) },{"_process":24}],12:[function(require,module,exports){ (function (process){ (function() { var isEqual, isPlainObject, macModifierKeyMap, nonMacModifierKeyMap, plus, shiftKeyMap, splitKeyPath, _, __slice = [].slice; _ = require('underscore'); macModifierKeyMap = { cmd: '\u2318', ctrl: '\u2303', alt: '\u2325', option: '\u2325', shift: '\u21e7', enter: '\u23ce', left: '\u2190', right: '\u2192', up: '\u2191', down: '\u2193' }; nonMacModifierKeyMap = { cmd: 'Cmd', ctrl: 'Ctrl', alt: 'Alt', option: 'Alt', shift: 'Shift', enter: 'Enter', left: 'Left', right: 'Right', up: 'Up', down: 'Down' }; shiftKeyMap = { '~': '`', '_': '-', '+': '=', '|': '\\', '{': '[', '}': ']', ':': ';', '"': '\'', '<': ',', '>': '.', '?': '/' }; splitKeyPath = function(keyPath) { var char, i, keyPathArray, startIndex, _i, _len; startIndex = 0; keyPathArray = []; if (keyPath == null) { return keyPathArray; } for (i = _i = 0, _len = keyPath.length; _i < _len; i = ++_i) { char = keyPath[i]; if (char === '.' && (i === 0 || keyPath[i - 1] !== '\\')) { keyPathArray.push(keyPath.substring(startIndex, i)); startIndex = i + 1; } } keyPathArray.push(keyPath.substr(startIndex, keyPath.length)); return keyPathArray; }; isPlainObject = function(value) { return _.isObject(value) && !_.isArray(value); }; plus = { adviseBefore: function(object, methodName, advice) { var original; original = object[methodName]; return object[methodName] = function() { var args; args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; if (advice.apply(this, args) !== false) { return original.apply(this, args); } }; }, camelize: function(string) { if (string) { return string.replace(/[_-]+(\w)/g, function(m) { return m[1].toUpperCase(); }); } else { return ''; } }, capitalize: function(word) { if (!word) { return ''; } if (word.toLowerCase() === 'github') { return 'GitHub'; } else { return word[0].toUpperCase() + word.slice(1); } }, compactObject: function(object) { var key, newObject, value; newObject = {}; for (key in object) { value = object[key]; if (value != null) { newObject[key] = value; } } return newObject; }, dasherize: function(string) { if (!string) { return ''; } string = string[0].toLowerCase() + string.slice(1); return string.replace(/([A-Z])|(_)/g, function(m, letter) { if (letter) { return "-" + letter.toLowerCase(); } else { return "-"; } }); }, deepClone: function(object) { if (_.isArray(object)) { return object.map(function(value) { return plus.deepClone(value); }); } else if (_.isObject(object) && !_.isFunction(object)) { return plus.mapObject(object, (function(_this) { return function(key, value) { return [key, plus.deepClone(value)]; }; })(this)); } else { return object; } }, deepExtend: function(target) { var i, key, object, result, _i, _len, _ref; result = target; i = 0; while (++i < arguments.length) { object = arguments[i]; if (isPlainObject(result) && isPlainObject(object)) { _ref = Object.keys(object); for (_i = 0, _len = _ref.length; _i < _len; _i++) { key = _ref[_i]; result[key] = plus.deepExtend(result[key], object[key]); } } else { result = plus.deepClone(object); } } return result; }, deepContains: function(array, target) { var object, _i, _len; if (array == null) { return false; } for (_i = 0, _len = array.length; _i < _len; _i++) { object = array[_i]; if (_.isEqual(object, target)) { return true; } } return false; }, endsWith: function(string, suffix) { if (suffix == null) { suffix = ''; } if (string) { return string.indexOf(suffix, string.length - suffix.length) !== -1; } else { return false; } }, escapeAttribute: function(string) { if (string) { return string.replace(/"/g, '&quot;').replace(/\n/g, '').replace(/\\/g, '-'); } else { return ''; } }, escapeRegExp: function(string) { if (string) { return string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); } else { return ''; } }, humanizeEventName: function(eventName, eventDoc) { var event, namespace, namespaceDoc, _ref; _ref = eventName.split(':'), namespace = _ref[0], event = _ref[1]; if (event == null) { return plus.undasherize(namespace); } namespaceDoc = plus.undasherize(namespace); if (eventDoc == null) { eventDoc = plus.undasherize(event); } return "" + namespaceDoc + ": " + eventDoc; }, humanizeKey: function(key, platform) { var modifierKeyMap; if (platform == null) { platform = process.platform; } if (!key) { return key; } modifierKeyMap = platform === 'darwin' ? macModifierKeyMap : nonMacModifierKeyMap; if (modifierKeyMap[key]) { return modifierKeyMap[key]; } else if (key.length === 1 && (shiftKeyMap[key] != null)) { return [modifierKeyMap.shift, shiftKeyMap[key]]; } else if (key.length === 1 && key === key.toUpperCase() && key.toUpperCase() !== key.toLowerCase()) { return [modifierKeyMap.shift, key.toUpperCase()]; } else if (key.length === 1 || /f[0-9]{1,2}/.test(key)) { return key.toUpperCase(); } else { if (platform === 'darwin') { return key; } else { return plus.capitalize(key); } } }, humanizeKeystroke: function(keystroke, platform) { var humanizedKeystrokes, index, key, keys, keystrokes, splitKeystroke, _i, _j, _len, _len1; if (platform == null) { platform = process.platform; } if (!keystroke) { return keystroke; } keystrokes = keystroke.split(' '); humanizedKeystrokes = []; for (_i = 0, _len = keystrokes.length; _i < _len; _i++) { keystroke = keystrokes[_i]; keys = []; splitKeystroke = keystroke.split('-'); for (index = _j = 0, _len1 = splitKeystroke.length; _j < _len1; index = ++_j) { key = splitKeystroke[index]; if (key === '' && splitKeystroke[index - 1] === '') { key = '-'; } if (key) { keys.push(plus.humanizeKey(key, platform)); } } keys = _.uniq(_.flatten(keys)); if (platform === 'darwin') { keys = keys.join(''); } else { keys = keys.join('+'); } humanizedKeystrokes.push(keys); } return humanizedKeystrokes.join(' '); }, isSubset: function(potentialSubset, potentialSuperset) { return _.every(potentialSubset, function(element) { return _.include(potentialSuperset, element); }); }, losslessInvert: function(hash) { var inverted, key, value; inverted = {}; for (key in hash) { value = hash[key]; if (inverted[value] == null) { inverted[value] = []; } inverted[value].push(key); } return inverted; }, mapObject: function(object, iterator) { var key, newObject, value, _i, _len, _ref, _ref1; newObject = {}; _ref = Object.keys(object); for (_i = 0, _len = _ref.length; _i < _len; _i++) { key = _ref[_i]; _ref1 = iterator(key, object[key]), key = _ref1[0], value = _ref1[1]; newObject[key] = value; } return newObject; }, multiplyString: function(string, n) { var finalString, i; finalString = ""; i = 0; while (i < n) { finalString += string; i++; } return finalString; }, pluralize: function(count, singular, plural) { if (count == null) { count = 0; } if (plural == null) { plural = singular + 's'; } if (count === 1) { return "" + count + " " + singular; } else { return "" + count + " " + plural; } }, remove: function(array, element) { var index; index = array.indexOf(element); if (index >= 0) { array.splice(index, 1); } return array; }, setValueForKeyPath: function(object, keyPath, value) { var key, keys; keys = splitKeyPath(keyPath); while (keys.length > 1) { key = keys.shift(); if (object[key] == null) { object[key] = {}; } object = object[key]; } if (value != null) { return object[keys.shift()] = value; } else { return delete object[keys.shift()]; } }, hasKeyPath: function(object, keyPath) { var key, keys, _i, _len; keys = splitKeyPath(keyPath); for (_i = 0, _len = keys.length; _i < _len; _i++) { key = keys[_i]; if (!object.hasOwnProperty(key)) { return false; } object = object[key]; } return true; }, spliceWithArray: function(originalArray, start, length, insertedArray, chunkSize) { var chunkStart, _i, _ref, _results; if (chunkSize == null) { chunkSize = 100000; } if (insertedArray.length < chunkSize) { return originalArray.splice.apply(originalArray, [start, length].concat(__slice.call(insertedArray))); } else { originalArray.splice(start, length); _results = []; for (chunkStart = _i = 0, _ref = insertedArray.length; chunkSize > 0 ? _i <= _ref : _i >= _ref; chunkStart = _i += chunkSize) { _results.push(originalArray.splice.apply(originalArray, [start + chunkStart, 0].concat(__slice.call(insertedArray.slice(chunkStart, chunkStart + chunkSize))))); } return _results; } }, sum: function(array) { var elt, sum, _i, _len; sum = 0; for (_i = 0, _len = array.length; _i < _len; _i++) { elt = array[_i]; sum += elt; } return sum; }, uncamelcase: function(string) { var result; if (!string) { return ''; } result = string.replace(/([A-Z])|_+/g, function(match, letter) { if (letter == null) { letter = ''; } return " " + letter; }); return plus.capitalize(result.trim()); }, undasherize: function(string) { if (string) { return string.split('-').map(plus.capitalize).join(' '); } else { return ''; } }, underscore: function(string) { if (!string) { return ''; } string = string[0].toLowerCase() + string.slice(1); return string.replace(/([A-Z])|-+/g, function(match, letter) { if (letter == null) { letter = ''; } return "_" + (letter.toLowerCase()); }); }, valueForKeyPath: function(object, keyPath) { var key, keys, _i, _len; keys = splitKeyPath(keyPath); for (_i = 0, _len = keys.length; _i < _len; _i++) { key = keys[_i]; object = object[key]; if (object == null) { return; } } return object; }, isEqual: function(a, b, aStack, bStack) { if (_.isArray(aStack) && _.isArray(bStack)) { return isEqual(a, b, aStack, bStack); } else { return isEqual(a, b); } }, isEqualForProperties: function() { var a, b, properties, property, _i, _len; a = arguments[0], b = arguments[1], properties = 3 <= arguments.length ? __slice.call(arguments, 2) : []; for (_i = 0, _len = properties.length; _i < _len; _i++) { property = properties[_i]; if (!_.isEqual(a[property], b[property])) { return false; } } return true; } }; isEqual = function(a, b, aStack, bStack) { var aCtor, aCtorValid, aElement, aKeyCount, aValue, bCtor, bCtorValid, bKeyCount, bValue, equal, i, key, stackIndex, _i, _len; if (aStack == null) { aStack = []; } if (bStack == null) { bStack = []; } if (a === b) { return _.isEqual(a, b); } if (_.isFunction(a) || _.isFunction(b)) { return _.isEqual(a, b); } stackIndex = aStack.length; while (stackIndex--) { if (aStack[stackIndex] === a) { return bStack[stackIndex] === b; } } aStack.push(a); bStack.push(b); equal = false; if (_.isFunction(a != null ? a.isEqual : void 0)) { equal = a.isEqual(b, aStack, bStack); } else if (_.isFunction(b != null ? b.isEqual : void 0)) { equal = b.isEqual(a, bStack, aStack); } else if (_.isArray(a) && _.isArray(b) && a.length === b.length) { equal = true; for (i = _i = 0, _len = a.length; _i < _len; i = ++_i) { aElement = a[i]; if (!isEqual(aElement, b[i], aStack, bStack)) { equal = false; break; } } } else if (_.isRegExp(a) && _.isRegExp(b)) { equal = _.isEqual(a, b); } else if (_.isElement(a) && _.isElement(b)) { equal = a === b; } else if (_.isObject(a) && _.isObject(b)) { aCtor = a.constructor; bCtor = b.constructor; aCtorValid = _.isFunction(aCtor) && aCtor instanceof aCtor; bCtorValid = _.isFunction(bCtor) && bCtor instanceof bCtor; if (aCtor !== bCtor && !(aCtorValid && bCtorValid)) { equal = false; } else { aKeyCount = 0; equal = true; for (key in a) { aValue = a[key]; if (!_.has(a, key)) { continue; } aKeyCount++; if (!(_.has(b, key) && isEqual(aValue, b[key], aStack, bStack))) { equal = false; break; } } if (equal) { bKeyCount = 0; for (key in b) { bValue = b[key]; if (_.has(b, key)) { bKeyCount++; } } equal = aKeyCount === bKeyCount; } } } else { equal = _.isEqual(a, b); } aStack.pop(); bStack.pop(); return equal; }; module.exports = _.extend({}, _, plus); }).call(this); }).call(this,require('_process')) },{"_process":24,"underscore":13}],13:[function(require,module,exports){ // Underscore.js 1.6.0 // http://underscorejs.org // (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors // Underscore may be freely distributed under the MIT license. (function() { // Baseline setup // -------------- // Establish the root object, `window` in the browser, or `exports` on the server. var root = this; // Save the previous value of the `_` variable. var previousUnderscore = root._; // Establish the object that gets returned to break out of a loop iteration. var breaker = {}; // Save bytes in the minified (but not gzipped) version: var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype; // Create quick reference variables for speed access to core prototypes. var push = ArrayProto.push, slice = ArrayProto.slice, concat = ArrayProto.concat, toString = ObjProto.toString, hasOwnProperty = ObjProto.hasOwnProperty; // All **ECMAScript 5** native function implementations that we hope to use // are declared here. var nativeForEach = ArrayProto.forEach, nativeMap = ArrayProto.map, nativeReduce = ArrayProto.reduce, nativeReduceRight = ArrayProto.reduceRight, nativeFilter = ArrayProto.filter, nativeEvery = ArrayProto.every, nativeSome = ArrayProto.some, nativeIndexOf = ArrayProto.indexOf, nativeLastIndexOf = ArrayProto.lastIndexOf, nativeIsArray = Array.isArray, nativeKeys = Object.keys, nativeBind = FuncProto.bind; // Create a safe reference to the Underscore object for use below. var _ = function(obj) { if (obj instanceof _) return obj; if (!(this instanceof _)) return new _(obj); this._wrapped = obj; }; // Export the Underscore object for **Node.js**, with // backwards-compatibility for the old `require()` API. If we're in // the browser, add `_` as a global object via a string identifier, // for Closure Compiler "advanced" mode. if (typeof exports !== 'undefined') { if (typeof module !== 'undefined' && module.exports) { exports = module.exports = _; } exports._ = _; } else { root._ = _; } // Current version. _.VERSION = '1.6.0'; // Collection Functions // -------------------- // The cornerstone, an `each` implementation, aka `forEach`. // Handles objects with the built-in `forEach`, arrays, and raw objects. // Delegates to **ECMAScript 5**'s native `forEach` if available. var each = _.each = _.forEach = function(obj, iterator, context) { if (obj == null) return obj; if (nativeForEach && obj.forEach === nativeForEach) { obj.forEach(iterator, context); } else if (obj.length === +obj.length) { for (var i = 0, length = obj.length; i < length; i++) { if (iterator.call(context, obj[i], i, obj) === breaker) return; } } else { var keys = _.keys(obj); for (var i = 0, length = keys.length; i < length; i++) { if (iterator.call(context, obj[keys[i]], keys[i], obj) === breaker) return; } } return obj; }; // Return the results of applying the iterator to each element. // Delegates to **ECMAScript 5**'s native `map` if available. _.map = _.collect = function(obj, iterator, context) { var results = []; if (obj == null) return results; if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context); each(obj, function(value, index, list) { results.push(iterator.call(context, value, index, list)); }); return results; }; var reduceError = 'Reduce of empty array with no initial value'; // **Reduce** builds up a single result from a list of values, aka `inject`, // or `foldl`. Delegates to **ECMAScript 5**'s native `reduce` if available. _.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) { var initial = arguments.length > 2; if (obj == null) obj = []; if (nativeReduce && obj.reduce === nativeReduce) { if (context) iterator = _.bind(iterator, context); return initial ? obj.reduce(iterator, memo) : obj.reduce(iterator); } each(obj, function(value, index, list) { if (!initial) { memo = value; initial = true; } else { memo = iterator.call(context, memo, value, index, list); } }); if (!initial) throw new TypeError(reduceError); return memo; }; // The right-associative version of reduce, also known as `foldr`. // Delegates to **ECMAScript 5**'s native `reduceRight` if available. _.reduceRight = _.foldr = function(obj, iterator, memo, context) { var initial = arguments.length > 2; if (obj == null) obj = []; if (nativeReduceRight && obj.reduceRight === nativeReduceRight) { if (context) iterator = _.bind(iterator, context); return initial ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator); } var length = obj.length; if (length !== +length) { var keys = _.keys(obj); length = keys.length; } each(obj, function(value, index, list) { index = keys ? keys[--length] : --length; if (!initial) { memo = obj[index]; initial = true; } else { memo = iterator.call(context, memo, obj[index], index, list); } }); if (!initial) throw new TypeError(reduceError); return memo; }; // Return the first value which passes a truth test. Aliased as `detect`. _.find = _.detect = function(obj, predicate, context) { var result; any(obj, function(value, index, list) { if (predicate.call(context, value, index, list)) { result = value; return true; } }); return result; }; // Return all the elements that pass a truth test. // Delegates to **ECMAScript 5**'s native `filter` if available. // Aliased as `select`. _.filter = _.select = function(obj, predicate, context) { var results = []; if (obj == null) return results; if (nativeFilter && obj.filter === nativeFilter) return obj.filter(predicate, context); each(obj, function(value, index, list) { if (predicate.call(context, value, index, list)) results.push(value); }); return results; }; // Return all the elements for which a truth test fails. _.reject = function(obj, predicate, context) { return _.filter(obj, function(value, index, list) { return !predicate.call(context, value, index, list); }, context); }; // Determine whether all of the elements match a truth test. // Delegates to **ECMAScript 5**'s native `every` if available. // Aliased as `all`. _.every = _.all = function(obj, predicate, context) { predicate || (predicate = _.identity); var result = true; if (obj == null) return result; if (nativeEvery && obj.every === nativeEvery) return obj.every(predicate, context); each(obj, function(value, index, list) { if (!(result = result && predicate.call(context, value, index, list))) return breaker; }); return !!result; }; // Determine if at least one element in the object matches a truth test. // Delegates to **ECMAScript 5**'s native `some` if available. // Aliased as `any`. var any = _.some = _.any = function(obj, predicate, context) { predicate || (predicate = _.identity); var result = false; if (obj == null) return result; if (nativeSome && obj.some === nativeSome) return obj.some(predicate, context); each(obj, function(value, index, list) { if (result || (result = predicate.call(context, value, index, list))) return breaker; }); return !!result; }; // Determine if the array or object contains a given value (using `===`). // Aliased as `include`. _.contains = _.include = function(obj, target) { if (obj == null) return false; if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1; return any(obj, function(value) { return value === target; }); }; // Invoke a method (with arguments) on every item in a collection. _.invoke = function(obj, method) { var args = slice.call(arguments, 2); var isFunc = _.isFunction(method); return _.map(obj, function(value) { return (isFunc ? method : value[method]).apply(value, args); }); }; // Convenience version of a common use case of `map`: fetching a property. _.pluck = function(obj, key) { return _.map(obj, _.property(key)); }; // Convenience version of a common use case of `filter`: selecting only objects // containing specific `key:value` pairs. _.where = function(obj, attrs) { return _.filter(obj, _.matches(attrs)); }; // Convenience version of a common use case of `find`: getting the first object // containing specific `key:value` pairs. _.findWhere = function(obj, attrs) { return _.find(obj, _.matches(attrs)); }; // Return the maximum element or (element-based computation). // Can't optimize arrays of integers longer than 65,535 elements. // See [WebKit Bug 80797](https://bugs.webkit.org/show_bug.cgi?id=80797) _.max = function(obj, iterator, context) { if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) { return Math.max.apply(Math, obj); } var result = -Infinity, lastComputed = -Infinity; each(obj, function(value, index, list) { var computed = iterator ? iterator.call(context, value, index, list) : value; if (computed > lastComputed) { result = value; lastComputed = computed; } }); return result; }; // Return the minimum element (or element-based computation). _.min = function(obj, iterator, context) { if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) { return Math.min.apply(Math, obj); } var result = Infinity, lastComputed = Infinity; each(obj, function(value, index, list) { var computed = iterator ? iterator.call(context, value, index, list) : value; if (computed < lastComputed) { result = value; lastComputed = computed; } }); return result; }; // Shuffle an array, using the modern version of the // [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher–Yates_shuffle). _.shuffle = function(obj) { var rand; var index = 0; var shuffled = []; each(obj, function(value) { rand = _.random(index++); shuffled[index - 1] = shuffled[rand]; shuffled[rand] = value; }); return shuffled; }; // Sample **n** random values from a collection. // If **n** is not specified, returns a single random element. // The internal `guard` argument allows it to work with `map`. _.sample = function(obj, n, guard) { if (n == null || guard) { if (obj.length !== +obj.length) obj = _.values(obj); return obj[_.random(obj.length - 1)]; } return _.shuffle(obj).slice(0, Math.max(0, n)); }; // An internal function to generate lookup iterators. var lookupIterator = function(value) { if (value == null) return _.identity; if (_.isFunction(value)) return value; return _.property(value); }; // Sort the object's values by a criterion produced by an iterator. _.sortBy = function(obj, iterator, context) { iterator = lookupIterator(iterator); return _.pluck(_.map(obj, function(value, index, list) { return { value: value, index: index, criteria: iterator.call(context, value, index, list) }; }).sort(function(left, right) { var a = left.criteria; var b = right.criteria; if (a !== b) { if (a > b || a === void 0) return 1; if (a < b || b === void 0) return -1; } return left.index - right.index; }), 'value'); }; // An internal function used for aggregate "group by" operations. var group = function(behavior) { return function(obj, iterator, context) { var result = {}; iterator = lookupIterator(iterator); each(obj, function(value, index) { var key = iterator.call(context, value, index, obj); behavior(result, key, value); }); return result; }; }; // Groups the object's values by a criterion. Pass either a string attribute // to group by, or a function that returns the criterion. _.groupBy = group(function(result, key, value) { _.has(result, key) ? result[key].push(value) : result[key] = [value]; }); // Indexes the object's values by a criterion, similar to `groupBy`, but for // when you know that your index values will be unique. _.indexBy = group(function(result, key, value) { result[key] = value; }); // Counts instances of an object that group by a certain criterion. Pass // either a string attribute to count by, or a function that returns the // criterion. _.countBy = group(function(result, key) { _.has(result, key) ? result[key]++ : result[key] = 1; }); // Use a comparator function to figure out the smallest index at which // an object should be inserted so as to maintain order. Uses binary search. _.sortedIndex = function(array, obj, iterator, context) { iterator = lookupIterator(iterator); var value = iterator.call(context, obj); var low = 0, high = array.length; while (low < high) { var mid = (low + high) >>> 1; iterator.call(context, array[mid]) < value ? low = mid + 1 : high = mid; } return low; }; // Safely create a real, live array from anything iterable. _.toArray = function(obj) { if (!obj) return []; if (_.isArray(obj)) return slice.call(obj); if (obj.length === +obj.length) return _.map(obj, _.identity); return _.values(obj); }; // Return the number of elements in an object. _.size = function(obj) { if (obj == null) return 0; return (obj.length === +obj.length) ? obj.length : _.keys(obj).length; }; // Array Functions // --------------- // Get the first element of an array. Passing **n** will return the first N // values in the array. Aliased as `head` and `take`. The **guard** check // allows it to work with `_.map`. _.first = _.head = _.take = function(array, n, guard) { if (array == null) return void 0; if ((n == null) || guard) return array[0]; if (n < 0) return []; return slice.call(array, 0, n); }; // Returns everything but the last entry of the array. Especially useful on // the arguments object. Passing **n** will return all the values in // the array, excluding the last N. The **guard** check allows it to work with // `_.map`. _.initial = function(array, n, guard) { return slice.call(array, 0, array.length - ((n == null) || guard ? 1 : n)); }; // Get the last element of an array. Passing **n** will return the last N // values in the array. The **guard** check allows it to work with `_.map`. _.last = function(array, n, guard) { if (array == null) return void 0; if ((n == null) || guard) return array[array.length - 1]; return slice.call(array, Math.max(array.length - n, 0)); }; // Returns everything but the first entry of the array. Aliased as `tail` and `drop`. // Especially useful on the arguments object. Passing an **n** will return // the rest N values in the array. The **guard** // check allows it to work with `_.map`. _.rest = _.tail = _.drop = function(array, n, guard) { return slice.call(array, (n == null) || guard ? 1 : n); }; // Trim out all falsy values from an array. _.compact = function(array) { return _.filter(array, _.identity); }; // Internal impl