/* ordinal 1.0.2: https://github.com/dcousens/ordinal/ Copyright (c) 2016, Daniel Cousens Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ require.preload("ordinal", String.raw` function indicator (i) { var cent = i % 100 if (cent >= 10 && cent <= 20) return 'th' var dec = i % 10 if (dec === 1) return 'st' if (dec === 2) return 'nd' if (dec === 3) return 'rd' return 'th' } function ordinal (i) { if (typeof i !== 'number') throw new TypeError('Expected Number, got ' + (typeof i) + ' ' + i) return i + indicator(i) } ordinal.indicator = indicator module.exports = ordinal`) /* date-names 0.1.11: https://github.com/martinandert/date-names The MIT License (MIT) Copyright (c) 2014 Martin Andert 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. */ require.preload("date-names", String.raw` module.exports = { __locale: "en", days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], abbreviated_days: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], abbreviated_months: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], am: 'AM', pm: 'PM' };`) /* ini 1.3.5: https://github.com/npm/ini The ISC License Copyright (c) Isaac Z. Schlueter and Contributors Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ require.preload("ini", String.raw`exports.parse = exports.decode = decode exports.stringify = exports.encode = encode exports.safe = safe exports.unsafe = unsafe var eol = typeof process !== 'undefined' && process.platform === 'win32' ? '\r\n' : '\n' function encode (obj, opt) { var children = [] var out = '' if (typeof opt === 'string') { opt = { section: opt, whitespace: false } } else { opt = opt || {} opt.whitespace = opt.whitespace === true } var separator = opt.whitespace ? ' = ' : '=' Object.keys(obj).forEach(function (k, _, __) { var val = obj[k] if (val && Array.isArray(val)) { val.forEach(function (item) { out += safe(k + '[]') + separator + safe(item) + '\n' }) } else if (val && typeof val === 'object') { children.push(k) } else { out += safe(k) + separator + safe(val) + eol } }) if (opt.section && out.length) { out = '[' + safe(opt.section) + ']' + eol + out } children.forEach(function (k, _, __) { var nk = dotSplit(k).join('\\.') var section = (opt.section ? opt.section + '.' : '') + nk var child = encode(obj[k], { section: section, whitespace: opt.whitespace }) if (out.length && child.length) { out += eol } out += child }) return out } function dotSplit (str) { return str.replace(/\1/g, '\u0002LITERAL\\1LITERAL\u0002') .replace(/\\\./g, '\u0001') .split(/\./).map(function (part) { return part.replace(/\1/g, '\\.') .replace(/\2LITERAL\\1LITERAL\2/g, '\u0001') }) } function decode (str) { var out = {} var p = out var section = null // section |key = value var re = /^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i var lines = str.split(/[\r\n]+/g) lines.forEach(function (line, _, __) { if (!line || line.match(/^\s*[;#]/)) return var match = line.match(re) if (!match) return if (match[1] !== undefined) { section = unsafe(match[1]) p = out[section] = out[section] || {} return } var key = unsafe(match[2]) var value = match[3] ? unsafe(match[4]) : true switch (value) { case 'true': case 'false': case 'null': value = JSON.parse(value) } // Convert keys with '[]' suffix to an array if (key.length > 2 && key.slice(-2) === '[]') { key = key.substring(0, key.length - 2) if (!p[key]) { p[key] = [] } else if (!Array.isArray(p[key])) { p[key] = [p[key]] } } // safeguard against resetting a previously defined // array by accidentally forgetting the brackets if (Array.isArray(p[key])) { p[key].push(value) } else { p[key] = value } }) // {a:{y:1},"a.b":{x:2}} --> {a:{y:1,b:{x:2}}} // use a filter to return the keys that have to be deleted. Object.keys(out).filter(function (k, _, __) { if (!out[k] || typeof out[k] !== 'object' || Array.isArray(out[k])) { return false } // see if the parent section is also an object. // if so, add it to that, and mark this one for deletion var parts = dotSplit(k) var p = out var l = parts.pop() var nl = l.replace(/\\\./g, '.') parts.forEach(function (part, _, __) { if (!p[part] || typeof p[part] !== 'object') p[part] = {} p = p[part] }) if (p === out && nl === l) { return false } p[nl] = out[k] return true }).forEach(function (del, _, __) { delete out[del] }) return out } function isQuoted (val) { return (val.charAt(0) === '"' && val.slice(-1) === '"') || (val.charAt(0) === "'" && val.slice(-1) === "'") } function safe (val) { return (typeof val !== 'string' || val.match(/[=\r\n]/) || val.match(/^\[/) || (val.length > 1 && isQuoted(val)) || val !== val.trim()) ? JSON.stringify(val) : val.replace(/;/g, '\\;').replace(/#/g, '\\#') } function unsafe (val, doUnesc) { val = (val || '').trim() if (isQuoted(val)) { // remove the single quotes before calling JSON.parse if (val.charAt(0) === "'") { val = val.substr(1, val.length - 2) } try { val = JSON.parse(val) } catch (_) {} } else { // walk the val to find the first not-escaped ; character var esc = false var unesc = '' for (var i = 0, l = val.length; i < l; i++) { var c = val.charAt(i) if (esc) { if ('\\;#'.indexOf(c) !== -1) { unesc += c } else { unesc += '\\' + c } esc = false } else if (';#'.indexOf(c) !== -1) { break } else if (c === '\\') { esc = true } else { unesc += c } } if (esc) { unesc += '\\' } return unesc.trim() } return val }`) /* dijkstrajs 1.0.1: https://github.com/tcort/dijkstrajs/ Dijkstra path-finding functions. Adapted from the Dijkstar Python project. Copyright (C) 2008 Wyatt Baldwin All rights reserved Licensed under the MIT license. http://www.opensource.org/licenses/mit-license.php 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. */ require.preload("dijkstrajs", String.raw`'use strict'; var dijkstra = { single_source_shortest_paths: function(graph, s, d) { // Predecessor map for each node that has been encountered. // node ID => predecessor node ID var predecessors = {}; // Costs of shortest paths from s to all nodes encountered. // node ID => cost var costs = {}; costs[s] = 0; // Costs of shortest paths from s to all nodes encountered; differs from // costs in that it provides easy access to the node that currently has // the known shortest path from s. // XXX: Do we actually need both costs and open? var open = dijkstra.PriorityQueue.make(); open.push(s, 0); var closest, u, v, cost_of_s_to_u, adjacent_nodes, cost_of_e, cost_of_s_to_u_plus_cost_of_e, cost_of_s_to_v, first_visit; while (!open.empty()) { // In the nodes remaining in graph that have a known cost from s, // find the node, u, that currently has the shortest path from s. closest = open.pop(); u = closest.value; cost_of_s_to_u = closest.cost; // Get nodes adjacent to u... adjacent_nodes = graph[u] || {}; // ...and explore the edges that connect u to those nodes, updating // the cost of the shortest paths to any or all of those nodes as // necessary. v is the node across the current edge from u. for (v in adjacent_nodes) { if (adjacent_nodes.hasOwnProperty(v)) { // Get the cost of the edge running from u to v. cost_of_e = adjacent_nodes[v]; // Cost of s to u plus the cost of u to v across e--this is *a* // cost from s to v that may or may not be less than the current // known cost to v. cost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e; // If we haven't visited v yet OR if the current known cost from s to // v is greater than the new cost we just found (cost of s to u plus // cost of u to v across e), update v's cost in the cost list and // update v's predecessor in the predecessor list (it's now u). cost_of_s_to_v = costs[v]; first_visit = (typeof costs[v] === 'undefined'); if (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) { costs[v] = cost_of_s_to_u_plus_cost_of_e; open.push(v, cost_of_s_to_u_plus_cost_of_e); predecessors[v] = u; } } } } if (typeof d !== 'undefined' && typeof costs[d] === 'undefined') { var msg = ['Could not find a path from ', s, ' to ', d, '.'].join(''); throw new Error(msg); } return predecessors; }, extract_shortest_path_from_predecessor_list: function(predecessors, d) { var nodes = []; var u = d; var predecessor; while (u) { nodes.push(u); predecessor = predecessors[u]; u = predecessors[u]; } nodes.reverse(); return nodes; }, find_path: function(graph, s, d) { var predecessors = dijkstra.single_source_shortest_paths(graph, s, d); return dijkstra.extract_shortest_path_from_predecessor_list( predecessors, d); }, /** * A very naive priority queue implementation. */ PriorityQueue: { make: function (opts) { var T = dijkstra.PriorityQueue, t = {}, key; opts = opts || {}; for (key in T) { if (T.hasOwnProperty(key)) { t[key] = T[key]; } } t.queue = []; t.sorter = opts.sorter || T.default_sorter; return t; }, default_sorter: function (a, b) { return a.cost - b.cost; }, /** * Add a new item to the queue and ensure the highest priority element * is at the front of the queue. */ push: function (value, cost) { var item = {value: value, cost: cost}; this.queue.push(item); this.queue.sort(this.sorter); }, /** * Return the highest priority element in the queue. */ pop: function () { return this.queue.shift(); }, empty: function () { return this.queue.length === 0; } } }; // node.js module exports if (typeof module !== 'undefined') { module.exports = dijkstra; }`) /* random-item 1.0.0: https://github.com/sindresorhus/random-item The MIT License (MIT) Copyright (c) Sindre Sorhus (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. */ require.preload("random-item", String.raw`'use strict'; module.exports = function (arr) { if (!Array.isArray(arr)) { throw new TypeError('Expected an array'); } return arr[Math.floor(Math.random() * arr.length)]; };`) require.preload("./format-date", String.raw`const ordinal = require("ordinal"); const {days, months} = require("date-names"); exports.formatDate = function(date, format) { return format.replace(/YYYY|M(MMM)?|Do?|dddd/g, tag => { if (tag == "YYYY") return date.getFullYear(); if (tag == "M") return date.getMonth(); if (tag == "MMMM") return months[date.getMonth()]; if (tag == "D") return date.getDate(); if (tag == "Do") return ordinal(date.getDate()); if (tag == "dddd") return days[date.getDay()]; }); };`) require.preload("./graph", String.raw`exports.buildGraph = function(edges) { let graph = Object.create(null); function addEdge(from, to) { if (!(from in graph)) graph[from] = Object.create(null); graph[from][to] = 1; } for (let [from, to] of edges) { addEdge(from, to); addEdge(to, from); } return graph; };`)