Created
November 16, 2012 22:33
-
-
Save CoderPuppy/4091538 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){var require = function (file, cwd) { | |
var resolved = require.resolve(file, cwd || '/'); | |
var mod = require.modules[resolved]; | |
if (!mod) throw new Error( | |
'Failed to resolve module ' + file + ', tried ' + resolved | |
); | |
var cached = require.cache[resolved]; | |
var res = cached? cached.exports : mod(); | |
return res; | |
}; | |
require.paths = []; | |
require.modules = {}; | |
require.cache = {}; | |
require.extensions = [".js",".coffee",".json",".html",".svg"]; | |
require._core = { | |
'assert': true, | |
'events': true, | |
'fs': true, | |
'path': true, | |
'vm': true | |
}; | |
require.resolve = (function () { | |
return function (x, cwd) { | |
if (!cwd) cwd = '/'; | |
if (require._core[x]) return x; | |
var path = require.modules.path(); | |
cwd = path.resolve('/', cwd); | |
var y = cwd || '/'; | |
if (x.match(/^(?:\.\.?\/|\/)/)) { | |
var m = loadAsFileSync(path.resolve(y, x)) | |
|| loadAsDirectorySync(path.resolve(y, x)); | |
if (m) return m; | |
} | |
var n = loadNodeModulesSync(x, y); | |
if (n) return n; | |
throw new Error("Cannot find module '" + x + "'"); | |
function loadAsFileSync (x) { | |
x = path.normalize(x); | |
if (require.modules[x]) { | |
return x; | |
} | |
for (var i = 0; i < require.extensions.length; i++) { | |
var ext = require.extensions[i]; | |
if (require.modules[x + ext]) return x + ext; | |
} | |
} | |
function loadAsDirectorySync (x) { | |
x = x.replace(/\/+$/, ''); | |
var pkgfile = path.normalize(x + '/package.json'); | |
if (require.modules[pkgfile]) { | |
var pkg = require.modules[pkgfile](); | |
var b = pkg.browserify; | |
if (typeof b === 'object' && b.main) { | |
var m = loadAsFileSync(path.resolve(x, b.main)); | |
if (m) return m; | |
} | |
else if (typeof b === 'string') { | |
var m = loadAsFileSync(path.resolve(x, b)); | |
if (m) return m; | |
} | |
else if (pkg.main) { | |
var m = loadAsFileSync(path.resolve(x, pkg.main)); | |
if (m) return m; | |
} | |
} | |
return loadAsFileSync(x + '/index'); | |
} | |
function loadNodeModulesSync (x, start) { | |
var dirs = nodeModulesPathsSync(start); | |
for (var i = 0; i < dirs.length; i++) { | |
var dir = dirs[i]; | |
var m = loadAsFileSync(dir + '/' + x); | |
if (m) return m; | |
var n = loadAsDirectorySync(dir + '/' + x); | |
if (n) return n; | |
} | |
var m = loadAsFileSync(x); | |
if (m) return m; | |
} | |
function nodeModulesPathsSync (start) { | |
var parts; | |
if (start === '/') parts = [ '' ]; | |
else parts = path.normalize(start).split('/'); | |
var dirs = []; | |
for (var i = parts.length - 1; i >= 0; i--) { | |
if (parts[i] === 'node_modules') continue; | |
var dir = parts.slice(0, i + 1).join('/') + '/node_modules'; | |
dirs.push(dir); | |
} | |
return dirs; | |
} | |
}; | |
})(); | |
require.alias = function (from, to) { | |
var path = require.modules.path(); | |
var res = null; | |
try { | |
res = require.resolve(from + '/package.json', '/'); | |
} | |
catch (err) { | |
res = require.resolve(from, '/'); | |
} | |
var basedir = path.dirname(res); | |
var keys = (Object.keys || function (obj) { | |
var res = []; | |
for (var key in obj) res.push(key); | |
return res; | |
})(require.modules); | |
for (var i = 0; i < keys.length; i++) { | |
var key = keys[i]; | |
if (key.slice(0, basedir.length + 1) === basedir + '/') { | |
var f = key.slice(basedir.length); | |
require.modules[to + f] = require.modules[basedir + f]; | |
} | |
else if (key === basedir) { | |
require.modules[to] = require.modules[basedir]; | |
} | |
} | |
}; | |
(function () { | |
var process = {}; | |
var global = typeof window !== 'undefined' ? window : {}; | |
var definedProcess = false; | |
require.define = function (filename, fn) { | |
if (!definedProcess && require.modules.__browserify_process) { | |
process = require.modules.__browserify_process(); | |
definedProcess = true; | |
} | |
var dirname = require._core[filename] | |
? '' | |
: require.modules.path().dirname(filename) | |
; | |
var require_ = function (file) { | |
var requiredModule = require(file, dirname); | |
var cached = require.cache[require.resolve(file, dirname)]; | |
if (cached && cached.parent === null) { | |
cached.parent = module_; | |
} | |
return requiredModule; | |
}; | |
require_.resolve = function (name) { | |
return require.resolve(name, dirname); | |
}; | |
require_.modules = require.modules; | |
require_.define = require.define; | |
require_.cache = require.cache; | |
var module_ = { | |
id : filename, | |
filename: filename, | |
exports : {}, | |
loaded : false, | |
parent: null | |
}; | |
require.modules[filename] = function () { | |
require.cache[filename] = module_; | |
fn.call( | |
module_.exports, | |
require_, | |
module_, | |
module_.exports, | |
dirname, | |
filename, | |
process, | |
global | |
); | |
module_.loaded = true; | |
return module_.exports; | |
}; | |
}; | |
})(); | |
require.define("path",Function(['require','module','exports','__dirname','__filename','process','global'],"function filter (xs, fn) {\n var res = [];\n for (var i = 0; i < xs.length; i++) {\n if (fn(xs[i], i, xs)) res.push(xs[i]);\n }\n return res;\n}\n\n// resolves . and .. elements in a path array with directory names there\n// must be no slashes, empty elements, or device names (c:\\) in the array\n// (so also no leading and trailing slashes - it does not distinguish\n// relative and absolute paths)\nfunction normalizeArray(parts, allowAboveRoot) {\n // if the path tries to go above the root, `up` ends up > 0\n var up = 0;\n for (var i = parts.length; i >= 0; i--) {\n var last = parts[i];\n if (last == '.') {\n parts.splice(i, 1);\n } else if (last === '..') {\n parts.splice(i, 1);\n up++;\n } else if (up) {\n parts.splice(i, 1);\n up--;\n }\n }\n\n // if the path is allowed to go above the root, restore leading ..s\n if (allowAboveRoot) {\n for (; up--; up) {\n parts.unshift('..');\n }\n }\n\n return parts;\n}\n\n// Regex to split a filename into [*, dir, basename, ext]\n// posix version\nvar splitPathRe = /^(.+\\/(?!$)|\\/)?((?:.+?)?(\\.[^.]*)?)$/;\n\n// path.resolve([from ...], to)\n// posix version\nexports.resolve = function() {\nvar resolvedPath = '',\n resolvedAbsolute = false;\n\nfor (var i = arguments.length; i >= -1 && !resolvedAbsolute; i--) {\n var path = (i >= 0)\n ? arguments[i]\n : process.cwd();\n\n // Skip empty and invalid entries\n if (typeof path !== 'string' || !path) {\n continue;\n }\n\n resolvedPath = path + '/' + resolvedPath;\n resolvedAbsolute = path.charAt(0) === '/';\n}\n\n// At this point the path should be resolved to a full absolute path, but\n// handle relative paths to be safe (might happen when process.cwd() fails)\n\n// Normalize the path\nresolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {\n return !!p;\n }), !resolvedAbsolute).join('/');\n\n return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';\n};\n\n// path.normalize(path)\n// posix version\nexports.normalize = function(path) {\nvar isAbsolute = path.charAt(0) === '/',\n trailingSlash = path.slice(-1) === '/';\n\n// Normalize the path\npath = normalizeArray(filter(path.split('/'), function(p) {\n return !!p;\n }), !isAbsolute).join('/');\n\n if (!path && !isAbsolute) {\n path = '.';\n }\n if (path && trailingSlash) {\n path += '/';\n }\n \n return (isAbsolute ? '/' : '') + path;\n};\n\n\n// posix version\nexports.join = function() {\n var paths = Array.prototype.slice.call(arguments, 0);\n return exports.normalize(filter(paths, function(p, index) {\n return p && typeof p === 'string';\n }).join('/'));\n};\n\n\nexports.dirname = function(path) {\n var dir = splitPathRe.exec(path)[1] || '';\n var isWindows = false;\n if (!dir) {\n // No dirname\n return '.';\n } else if (dir.length === 1 ||\n (isWindows && dir.length <= 3 && dir.charAt(1) === ':')) {\n // It is just a slash or a drive letter with a slash\n return dir;\n } else {\n // It is a full dirname, strip trailing slash\n return dir.substring(0, dir.length - 1);\n }\n};\n\n\nexports.basename = function(path, ext) {\n var f = splitPathRe.exec(path)[2] || '';\n // TODO: make this comparison case-insensitive on windows?\n if (ext && f.substr(-1 * ext.length) === ext) {\n f = f.substr(0, f.length - ext.length);\n }\n return f;\n};\n\n\nexports.extname = function(path) {\n return splitPathRe.exec(path)[3] || '';\n};\n\n//@ sourceURL=path" | |
)); | |
require.define("__browserify_process",Function(['require','module','exports','__dirname','__filename','process','global'],"var process = module.exports = {};\n\nprocess.nextTick = (function () {\n var canSetImmediate = typeof window !== 'undefined'\n && window.setImmediate;\n var canPost = typeof window !== 'undefined'\n && window.postMessage && window.addEventListener\n ;\n\n if (canSetImmediate) {\n return function (f) { return window.setImmediate(f) };\n }\n\n if (canPost) {\n var queue = [];\n window.addEventListener('message', function (ev) {\n if (ev.source === window && ev.data === 'browserify-tick') {\n ev.stopPropagation();\n if (queue.length > 0) {\n var fn = queue.shift();\n fn();\n }\n }\n }, true);\n\n return function nextTick(fn) {\n queue.push(fn);\n window.postMessage('browserify-tick', '*');\n };\n }\n\n return function nextTick(fn) {\n setTimeout(fn, 0);\n };\n})();\n\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\n\nprocess.binding = function (name) {\n if (name === 'evals') return (require)('vm')\n else throw new Error('No such module. (Possibly not yet loaded)')\n};\n\n(function () {\n var cwd = '/';\n var path;\n process.cwd = function () { return cwd };\n process.chdir = function (dir) {\n if (!path) path = require('path');\n cwd = path.resolve(dir, cwd);\n };\n})();\n\n//@ sourceURL=__browserify_process" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {\"main\":\"server.js\"}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/package.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/model.js",Function(['require','module','exports','__dirname','__filename','process','global'],"var crdt = require('crdt')\nvar model = module.exports = new (crdt.Doc)\n\nvar ids = 1\nfunction id (type) {\n return type+'_'+ids++\n}\n\nmodel.create = function (type) {\n console.log('create', type)\n var row = model.add({\n id: id(type)\n , x: Math.round(Math.random() * 600)\n , y: Math.round(Math.random() * 480)\n , type: type\n })\n\n console.log(row.toJSON())\n return row\n}\n\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/model.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/crdt/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/crdt/package.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/crdt/index.js",Function(['require','module','exports','__dirname','__filename','process','global'],"//index\n'use strict';\n\nvar inherits = require('util').inherits\nvar EventEmitter = require('events').EventEmitter\nvar u = require('./utils')\n\nexports = module.exports = require('./doc')\nexports.Row = require('./row')\n\nexports.sync = sync\nexports.Set = require('./set')\nexports.Seq = require('./seq')\n\nexports.Doc = exports\n\nfunction sync(a, b) {\n var as = a.createStream()\n var bs = b.createStream()\n return as.pipe(bs).pipe(as)\n}\n\n\nexports.createStream = function (doc, opts) {\n return doc.createStream(opts)\n}\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/crdt/index.js" | |
)); | |
require.define("util",Function(['require','module','exports','__dirname','__filename','process','global'],"var events = require('events');\n\nexports.print = function () {};\nexports.puts = function () {};\nexports.debug = function() {};\n\nexports.inspect = function(obj, showHidden, depth, colors) {\n var seen = [];\n\n var stylize = function(str, styleType) {\n // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics\n var styles =\n { 'bold' : [1, 22],\n 'italic' : [3, 23],\n 'underline' : [4, 24],\n 'inverse' : [7, 27],\n 'white' : [37, 39],\n 'grey' : [90, 39],\n 'black' : [30, 39],\n 'blue' : [34, 39],\n 'cyan' : [36, 39],\n 'green' : [32, 39],\n 'magenta' : [35, 39],\n 'red' : [31, 39],\n 'yellow' : [33, 39] };\n\n var style =\n { 'special': 'cyan',\n 'number': 'blue',\n 'boolean': 'yellow',\n 'undefined': 'grey',\n 'null': 'bold',\n 'string': 'green',\n 'date': 'magenta',\n // \"name\": intentionally not styling\n 'regexp': 'red' }[styleType];\n\n if (style) {\n return '\\033[' + styles[style][0] + 'm' + str +\n '\\033[' + styles[style][1] + 'm';\n } else {\n return str;\n }\n };\n if (! colors) {\n stylize = function(str, styleType) { return str; };\n }\n\n function format(value, recurseTimes) {\n // Provide a hook for user-specified inspect functions.\n // Check that value is an object with an inspect function on it\n if (value && typeof value.inspect === 'function' &&\n // Filter out the util module, it's inspect function is special\n value !== exports &&\n // Also filter out any prototype objects using the circular check.\n !(value.constructor && value.constructor.prototype === value)) {\n return value.inspect(recurseTimes);\n }\n\n // Primitive types cannot have properties\n switch (typeof value) {\n case 'undefined':\n return stylize('undefined', 'undefined');\n\n case 'string':\n var simple = '\\'' + JSON.stringify(value).replace(/^\"|\"$/g, '')\n .replace(/'/g, \"\\\\'\")\n .replace(/\\\\\"/g, '\"') + '\\'';\n return stylize(simple, 'string');\n\n case 'number':\n return stylize('' + value, 'number');\n\n case 'boolean':\n return stylize('' + value, 'boolean');\n }\n // For some reason typeof null is \"object\", so special case here.\n if (value === null) {\n return stylize('null', 'null');\n }\n\n // Look up the keys of the object.\n var visible_keys = Object_keys(value);\n var keys = showHidden ? Object_getOwnPropertyNames(value) : visible_keys;\n\n // Functions without properties can be shortcutted.\n if (typeof value === 'function' && keys.length === 0) {\n if (isRegExp(value)) {\n return stylize('' + value, 'regexp');\n } else {\n var name = value.name ? ': ' + value.name : '';\n return stylize('[Function' + name + ']', 'special');\n }\n }\n\n // Dates without properties can be shortcutted\n if (isDate(value) && keys.length === 0) {\n return stylize(value.toUTCString(), 'date');\n }\n\n var base, type, braces;\n // Determine the object type\n if (isArray(value)) {\n type = 'Array';\n braces = ['[', ']'];\n } else {\n type = 'Object';\n braces = ['{', '}'];\n }\n\n // Make functions say that they are functions\n if (typeof value === 'function') {\n var n = value.name ? ': ' + value.name : '';\n base = (isRegExp(value)) ? ' ' + value : ' [Function' + n + ']';\n } else {\n base = '';\n }\n\n // Make dates with properties first say the date\n if (isDate(value)) {\n base = ' ' + value.toUTCString();\n }\n\n if (keys.length === 0) {\n return braces[0] + base + braces[1];\n }\n\n if (recurseTimes < 0) {\n if (isRegExp(value)) {\n return stylize('' + value, 'regexp');\n } else {\n return stylize('[Object]', 'special');\n }\n }\n\n seen.push(value);\n\n var output = keys.map(function(key) {\n var name, str;\n if (value.__lookupGetter__) {\n if (value.__lookupGetter__(key)) {\n if (value.__lookupSetter__(key)) {\n str = stylize('[Getter/Setter]', 'special');\n } else {\n str = stylize('[Getter]', 'special');\n }\n } else {\n if (value.__lookupSetter__(key)) {\n str = stylize('[Setter]', 'special');\n }\n }\n }\n if (visible_keys.indexOf(key) < 0) {\n name = '[' + key + ']';\n }\n if (!str) {\n if (seen.indexOf(value[key]) < 0) {\n if (recurseTimes === null) {\n str = format(value[key]);\n } else {\n str = format(value[key], recurseTimes - 1);\n }\n if (str.indexOf('\\n') > -1) {\n if (isArray(value)) {\n str = str.split('\\n').map(function(line) {\n return ' ' + line;\n }).join('\\n').substr(2);\n } else {\n str = '\\n' + str.split('\\n').map(function(line) {\n return ' ' + line;\n }).join('\\n');\n }\n }\n } else {\n str = stylize('[Circular]', 'special');\n }\n }\n if (typeof name === 'undefined') {\n if (type === 'Array' && key.match(/^\\d+$/)) {\n return str;\n }\n name = JSON.stringify('' + key);\n if (name.match(/^\"([a-zA-Z_][a-zA-Z_0-9]*)\"$/)) {\n name = name.substr(1, name.length - 2);\n name = stylize(name, 'name');\n } else {\n name = name.replace(/'/g, \"\\\\'\")\n .replace(/\\\\\"/g, '\"')\n .replace(/(^\"|\"$)/g, \"'\");\n name = stylize(name, 'string');\n }\n }\n\n return name + ': ' + str;\n });\n\n seen.pop();\n\n var numLinesEst = 0;\n var length = output.reduce(function(prev, cur) {\n numLinesEst++;\n if (cur.indexOf('\\n') >= 0) numLinesEst++;\n return prev + cur.length + 1;\n }, 0);\n\n if (length > 50) {\n output = braces[0] +\n (base === '' ? '' : base + '\\n ') +\n ' ' +\n output.join(',\\n ') +\n ' ' +\n braces[1];\n\n } else {\n output = braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];\n }\n\n return output;\n }\n return format(obj, (typeof depth === 'undefined' ? 2 : depth));\n};\n\n\nfunction isArray(ar) {\n return ar instanceof Array ||\n Array.isArray(ar) ||\n (ar && ar !== Object.prototype && isArray(ar.__proto__));\n}\n\n\nfunction isRegExp(re) {\n return re instanceof RegExp ||\n (typeof re === 'object' && Object.prototype.toString.call(re) === '[object RegExp]');\n}\n\n\nfunction isDate(d) {\n if (d instanceof Date) return true;\n if (typeof d !== 'object') return false;\n var properties = Date.prototype && Object_getOwnPropertyNames(Date.prototype);\n var proto = d.__proto__ && Object_getOwnPropertyNames(d.__proto__);\n return JSON.stringify(proto) === JSON.stringify(properties);\n}\n\nfunction pad(n) {\n return n < 10 ? '0' + n.toString(10) : n.toString(10);\n}\n\nvar months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',\n 'Oct', 'Nov', 'Dec'];\n\n// 26 Feb 16:19:34\nfunction timestamp() {\n var d = new Date();\n var time = [pad(d.getHours()),\n pad(d.getMinutes()),\n pad(d.getSeconds())].join(':');\n return [d.getDate(), months[d.getMonth()], time].join(' ');\n}\n\nexports.log = function (msg) {};\n\nexports.pump = null;\n\nvar Object_keys = Object.keys || function (obj) {\n var res = [];\n for (var key in obj) res.push(key);\n return res;\n};\n\nvar Object_getOwnPropertyNames = Object.getOwnPropertyNames || function (obj) {\n var res = [];\n for (var key in obj) {\n if (Object.hasOwnProperty.call(obj, key)) res.push(key);\n }\n return res;\n};\n\nvar Object_create = Object.create || function (prototype, properties) {\n // from es5-shim\n var object;\n if (prototype === null) {\n object = { '__proto__' : null };\n }\n else {\n if (typeof prototype !== 'object') {\n throw new TypeError(\n 'typeof prototype[' + (typeof prototype) + '] != \\'object\\''\n );\n }\n var Type = function () {};\n Type.prototype = prototype;\n object = new Type();\n object.__proto__ = prototype;\n }\n if (typeof properties !== 'undefined' && Object.defineProperties) {\n Object.defineProperties(object, properties);\n }\n return object;\n};\n\nexports.inherits = function(ctor, superCtor) {\n ctor.super_ = superCtor;\n ctor.prototype = Object_create(superCtor.prototype, {\n constructor: {\n value: ctor,\n enumerable: false,\n writable: true,\n configurable: true\n }\n });\n};\n\nvar formatRegExp = /%[sdj%]/g;\nexports.format = function(f) {\n if (typeof f !== 'string') {\n var objects = [];\n for (var i = 0; i < arguments.length; i++) {\n objects.push(exports.inspect(arguments[i]));\n }\n return objects.join(' ');\n }\n\n var i = 1;\n var args = arguments;\n var len = args.length;\n var str = String(f).replace(formatRegExp, function(x) {\n if (x === '%%') return '%';\n if (i >= len) return x;\n switch (x) {\n case '%s': return String(args[i++]);\n case '%d': return Number(args[i++]);\n case '%j': return JSON.stringify(args[i++]);\n default:\n return x;\n }\n });\n for(var x = args[i]; i < len; x = args[++i]){\n if (x === null || typeof x !== 'object') {\n str += ' ' + x;\n } else {\n str += ' ' + exports.inspect(x);\n }\n }\n return str;\n};\n\n//@ sourceURL=util" | |
)); | |
require.define("events",Function(['require','module','exports','__dirname','__filename','process','global'],"if (!process.EventEmitter) process.EventEmitter = function () {};\n\nvar EventEmitter = exports.EventEmitter = process.EventEmitter;\nvar isArray = typeof Array.isArray === 'function'\n ? Array.isArray\n : function (xs) {\n return Object.prototype.toString.call(xs) === '[object Array]'\n }\n;\n\n// By default EventEmitters will print a warning if more than\n// 10 listeners are added to it. This is a useful default which\n// helps finding memory leaks.\n//\n// Obviously not all Emitters should be limited to 10. This function allows\n// that to be increased. Set to zero for unlimited.\nvar defaultMaxListeners = 10;\nEventEmitter.prototype.setMaxListeners = function(n) {\n if (!this._events) this._events = {};\n this._events.maxListeners = n;\n};\n\n\nEventEmitter.prototype.emit = function(type) {\n // If there is no 'error' event listener then throw.\n if (type === 'error') {\n if (!this._events || !this._events.error ||\n (isArray(this._events.error) && !this._events.error.length))\n {\n if (arguments[1] instanceof Error) {\n throw arguments[1]; // Unhandled 'error' event\n } else {\n throw new Error(\"Uncaught, unspecified 'error' event.\");\n }\n return false;\n }\n }\n\n if (!this._events) return false;\n var handler = this._events[type];\n if (!handler) return false;\n\n if (typeof handler == 'function') {\n switch (arguments.length) {\n // fast cases\n case 1:\n handler.call(this);\n break;\n case 2:\n handler.call(this, arguments[1]);\n break;\n case 3:\n handler.call(this, arguments[1], arguments[2]);\n break;\n // slower\n default:\n var args = Array.prototype.slice.call(arguments, 1);\n handler.apply(this, args);\n }\n return true;\n\n } else if (isArray(handler)) {\n var args = Array.prototype.slice.call(arguments, 1);\n\n var listeners = handler.slice();\n for (var i = 0, l = listeners.length; i < l; i++) {\n listeners[i].apply(this, args);\n }\n return true;\n\n } else {\n return false;\n }\n};\n\n// EventEmitter is defined in src/node_events.cc\n// EventEmitter.prototype.emit() is also defined there.\nEventEmitter.prototype.addListener = function(type, listener) {\n if ('function' !== typeof listener) {\n throw new Error('addListener only takes instances of Function');\n }\n\n if (!this._events) this._events = {};\n\n // To avoid recursion in the case that type == \"newListeners\"! Before\n // adding it to the listeners, first emit \"newListeners\".\n this.emit('newListener', type, listener);\n\n if (!this._events[type]) {\n // Optimize the case of one listener. Don't need the extra array object.\n this._events[type] = listener;\n } else if (isArray(this._events[type])) {\n\n // Check for listener leak\n if (!this._events[type].warned) {\n var m;\n if (this._events.maxListeners !== undefined) {\n m = this._events.maxListeners;\n } else {\n m = defaultMaxListeners;\n }\n\n if (m && m > 0 && this._events[type].length > m) {\n this._events[type].warned = true;\n console.error('(node) warning: possible EventEmitter memory ' +\n 'leak detected. %d listeners added. ' +\n 'Use emitter.setMaxListeners() to increase limit.',\n this._events[type].length);\n console.trace();\n }\n }\n\n // If we've already got an array, just append.\n this._events[type].push(listener);\n } else {\n // Adding the second element, need to change to array.\n this._events[type] = [this._events[type], listener];\n }\n\n return this;\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\nEventEmitter.prototype.once = function(type, listener) {\n var self = this;\n self.on(type, function g() {\n self.removeListener(type, g);\n listener.apply(this, arguments);\n });\n\n return this;\n};\n\nEventEmitter.prototype.removeListener = function(type, listener) {\n if ('function' !== typeof listener) {\n throw new Error('removeListener only takes instances of Function');\n }\n\n // does not use listeners(), so no side effect of creating _events[type]\n if (!this._events || !this._events[type]) return this;\n\n var list = this._events[type];\n\n if (isArray(list)) {\n var i = list.indexOf(listener);\n if (i < 0) return this;\n list.splice(i, 1);\n if (list.length == 0)\n delete this._events[type];\n } else if (this._events[type] === listener) {\n delete this._events[type];\n }\n\n return this;\n};\n\nEventEmitter.prototype.removeAllListeners = function(type) {\n // does not use listeners(), so no side effect of creating _events[type]\n if (type && this._events && this._events[type]) this._events[type] = null;\n return this;\n};\n\nEventEmitter.prototype.listeners = function(type) {\n if (!this._events) this._events = {};\n if (!this._events[type]) this._events[type] = [];\n if (!isArray(this._events[type])) {\n this._events[type] = [this._events[type]];\n }\n return this._events[type];\n};\n\n//@ sourceURL=events" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/crdt/utils.js",Function(['require','module','exports','__dirname','__filename','process','global'],"'use strict';\nvar b = require('between')\n\nexports.clone = \nfunction (ary) {\n return ary.map(function (e) {\n return Array.isArray(e) ? exports.clone(e) : e\n })\n}\n\nexports.randstr = b.randstr\nexports.between = b.between\nexports.strord = b.strord\nexports.merge = merge\nexports.concat = concat\nexports.timestamp = timestamp\n\n\nfunction merge(to, from) {\n for(var k in from)\n to[k] = from[k]\n return to\n}\n\nvar _last = 0\nvar _count = 1\nvar LAST\nfunction timestamp () {\n var t = Date.now()\n var _t = t\n if(_last == t) {\n// while(_last == _t)\n _t += ((_count++)/1000) \n } \n else _count = 1 \n\n _last = t\n\n if(_t === LAST)\n throw new Error('LAST:' + LAST + ',' + _t)\n LAST = _t\n return _t\n}\n\nfunction concat(to, from) {\n while(from.length)\n to.push(from.shift())\n return to\n}\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/crdt/utils.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/crdt/node_modules/between/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/crdt/node_modules/between/package.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/crdt/node_modules/between/index.js",Function(['require','module','exports','__dirname','__filename','process','global'],"\nexports = module.exports = function (chars, exports) {\n\n chars = chars ||\n '!0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~'\n\n chars = chars.split('').sort().join('')\n\n exports = exports || {} \n\n exports.randstr = randstr\n exports.between = between\n exports.strord = strord\n\n exports.lo = chars[0]\n exports.hi = chars[chars.length - 1]\n\n function randstr(l) {\n var str = ''\n while(l--) \n str += chars[\n Math.floor(\n Math.random() * chars.length \n )\n ]\n return str\n }\n\n /*\n SOME EXAMPLE STRINGS, IN ORDER\n \n 0\n 00001\n 0001\n 001\n 001001\n 00101\n 0011\n 0011001\n 001100101\n 00110011\n 001101\n 00111\n 01 \n\n if you never make a string that ends in the lowest char,\n then it is always possible to make a string between two strings.\n this is like how decimals never end in 0. \n\n example:\n\n between('A', 'AB') \n\n ... 'AA' will sort between 'A' and 'AB' but then it is impossible\n to make a string inbetween 'A' and 'AA'.\n instead, return 'AAB', then there will be space.\n\n */\n\n function between (a, b) {\n\n var s = '', i = 0\n\n while (true) {\n\n var _a = chars.indexOf(a[i])\n var _b = chars.indexOf(b[i])\n \n if(_a == -1) _a = 0\n if(_b == -1) _b = chars.length - 1\n\n i++\n\n var c = chars[\n _a + 1 < _b \n ? Math.round((_a+_b)/2) \n : _a\n ]\n\n s += c\n\n if(a < s && s < b && c != exports.lo)\n return s;\n }\n }\n\n function strord (a, b) {\n return (\n a == b ? 0\n : a < b ? -1\n : 1\n )\n }\n\n return exports\n}\n\nexports(null, module.exports)\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/crdt/node_modules/between/index.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/crdt/doc.js",Function(['require','module','exports','__dirname','__filename','process','global'],"var inherits = require('util').inherits\nvar Row = require('./row')\nvar u = require('./utils')\nvar Set = require('./set')\nvar Seq = require('./seq')\nvar Scuttlebutt = require('scuttlebutt')\nvar EventEmitter = require('events').EventEmitter\n\ninherits(Doc, Scuttlebutt)\n\nmodule.exports = Doc\n//doc\n//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n/*\n idea: instead of using a tombstone for deletes,\n use a anti-tombstone to show something is alive.\n breathing: count. -- updated by an authority.\n set breathing to 0 to kill something.\n \n if a node has rows that have been garbage collected on the server,\n it will be obvious from the value of breathing.\n\n node disconnects... makes changes...\n other nodes delete some things, which get garbage collected.\n\n node reconnects.\n server updates the node, but only increments _breathing for some rows.\n \n clearly, the nodes that do not have an upto date _breathing are either\n dead, or where created by the node while it was offline.\n\n would breathing need to be a vector clock?\n \n if the disconneded node is still updating the rows,\n maybe it shouldn't be deleted, that is, undeleted.\n\n may be on to something here... but this needs more thinking.\n\n will depend on how much churn something has...\n*/\n\nfunction order (a, b) {\n return u.strord(a[2], b[2]) || u.strord(a[3], b[3])\n}\n\nfunction Doc (id) {\n //the id of the doc refers to the instance.\n //that is, to the node.\n //it's used to identify a node \n// this.id = id || '#' + Math.round(Math.random()*1000)\n this.rows = {}\n this.hist = {}\n this.recieved = {}\n this.sets = new EventEmitter() //for tracking membership of sets.\n this.setMaxListeners(Infinity)\n this.sets.setMaxListeners(Infinity)\n Scuttlebutt.call(this, id)\n\n}\n\nDoc.prototype.add = function (initial) {\n\n if(!initial.id)\n throw new Error('id is required')\n var r = this._add(initial.id, 'local')\n r._set(initial, 'local')\n return r\n}\n\nDoc.prototype._add = function (id, source) {\n\n var doc = this\n\n if(this.rows[id])\n return this.rows[id]\n\n var r = id instanceof Row ? id : new Row(id)\n this.rows[r.id] = r\n\n function track (changes, source) {\n// var update = [r.id, changes, u.timestamp(), doc.id]\n doc.localUpdate(r.id, changes)\n }\n\n r.on('preupdate', track)\n\n this.emit('add', r)\n this.emit('create', r) //alias\n return r\n}\n\nDoc.prototype.timeUpdated = function (row, key) {\n var h = this.hist[row.id] \n if(!h) return\n return h[key][3]\n}\n\nDoc.prototype.set = function (id, change) {\n var r = this._add(id, 'local')\n return r.set(change)\n}\n\n/*\n histroy for each row is indexed by key.\n key -> update that set that key.\n\n so applying a change is as simple\n as iterating over the keys in the rows hist\n checking if the new update is more recent\n than the hist update\n if so, replace that keys hist.\n*/\n\nDoc.prototype.applyUpdate = function (update, source) {\n\n //apply an update to a row.\n //take into account histroy.\n //and insert the change into the correct place.\n var id = update[0]\n var changes = update[1]\n var timestamp = update[2]\n var from = update[3]\n\n var changed = {}\n\n var row = this._add(id, source)\n var hist = this.hist[id] = this.hist[id] || {}\n var emit = false, oldnews = false\n\n\n //remember the most recent update from each node.\n //now handled my scuttlebutt.\n// if(!this.recieved[from] || this.recieved[from] < timestamp)\n// this.recieved[from] = timestamp\n\n// if(!row.validate(changes)) return\n \n for(var key in changes) {\n var value = changes[key]\n if(!hist[key] || order(hist[key], update) < 0) {\n hist[key] = update\n changed[key] = changes[key]\n emit = true \n }\n }\n\n// probably, there may be mulitple sets that listen to the same key, \n// but activate on different values...\n//\n// hang on, in the mean time, I will probably only be managing n < 10 sets. \n// at once, \n\n u.merge(row.state, changed)\n for(var k in changed)\n this.sets.emit(k, row, changed) \n \n if(!emit) return\n \n this.emit('_update', update)\n row.emit('update', update, changed)\n row.emit('changes', changes, changed)\n row.emit('change', changed) //installing this in paralel, so tests still pass.\n //will depreciate the old way later.\n this.emit('update', update, source) //rename this event to 'data' or 'diff'?\n this.emit('row_update', row) //rename this event to 'update'\n}\n\nDoc.prototype.history = function (sources) {\n var h = []\n for (var id in this.hist) {\n var hist = this.hist[id]\n for (var k in hist) {\n if(!~h.indexOf(hist[k]) && Scuttlebutt.filter(hist[k], sources))\n h.push(hist[k])\n }\n }\n return h.sort(order)\n}\n\nfunction _set(self, key, val, type) {\n var id = key + ':' + val\n if(self.sets[id]) return self.sets[id] \n return self.sets[key + ':' + val] = new type(self, key, val) \n}\n\nDoc.prototype.createSet = function (key, val) {\n return _set(this, key, val, Set)\n}\n\nDoc.prototype.createSeq = function (key, val) {\n return _set(this, key, val, Seq)\n}\n\nDoc.prototype.toJSON = function () {\n var j = {}\n for (var k in this.rows)\n j[k] = this.rows[k].state\n return j\n}\n//retrive a reference to a row.\n//if the row is not created yet, create \nDoc.prototype.get = function (id) {\n return this.rows[id] = this.rows[id] || this._add(new Row(id), 'local')\n}\n\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/crdt/doc.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/crdt/row.js",Function(['require','module','exports','__dirname','__filename','process','global'],"//row\n//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n'use strict';\n\nvar inherits = require('util').inherits\nvar EventEmitter = require('events').EventEmitter\n\nmodule.exports = Row\n\ninherits(Row, EventEmitter)\n\nfunction Row (id) {\n this.id = id\n this.state = {id: id}\n this.setMaxListeners(Infinity)\n}\n\nRow.prototype.set = function (changes, v) {\n if(arguments.length == 2) {\n var k = changes \n changes = {}\n changes[k] = v\n }\n\n if(changes.id && changes.id !== this.state.id)\n throw new Error('id cannot be changed')\n\n this._set(changes, 'local') \n return this\n}\n\nRow.prototype.validate = function (changes) {\n try {\n this.emit('validate', changes)\n return true\n } catch (e) {\n console.error('validation', e.message)\n return false\n } \n}\n\nRow.prototype._set = function (changes, source) {\n\n //the change is applied by the Doc!\n this.emit('preupdate', changes, source)\n return this\n}\n\nRow.prototype.get = function (key) {\n if(key)\n return this.state[key]\n return this.state\n}\n\nRow.prototype.toJSON = function () {\n return this.state\n}\n\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/crdt/row.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/crdt/set.js",Function(['require','module','exports','__dirname','__filename','process','global'],"'use strict';\nvar inherits = require('util').inherits\nvar EventEmitter = require('events').EventEmitter\nvar u = require('./utils')\nvar Row = require('./row')\n\ninherits(Set, EventEmitter)\n\nmodule.exports = Set\n\n//set\n//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n/*\n a set is just a query.\n could expand this to enable replicating a subset of a document.\n that could enable massive documents that are too large to fit in memory.\n as long as they could be partitioned.\n\n heh, join queries? or rather, recursive queries,\n for when rows have sets.\n\n that is my vibe. don't make a database you have to \n _map_ to your application. pre-map the database.\n\n could also specify sets like\n\n //set of all things\n {type: 'thing'}\n\n //set of things with thier parts\n { type: 'thing',\n parts: {\n parent_id: function (val) {return val == this.id}\n }\n }\n\n or use map-reduces. remember, if the the reduce is \n monotonic you don't have to remember each input.\n*/\n\n//TODO check if any currently existing items should be in the set. currently, one must create the set before recieving anything.\n\nfunction Set(doc, key, value) {\n var array = this._array = []\n var rows = this.rows = {}\n var set = this\n\n //DO NOT CHANGE once you have created the set.\n this.key = key\n this.value = value\n\n function add(row) {\n array.push(row)\n rows[row.id] = row\n set.emit('add', row)\n\n function remove (_, changed) {\n if(row.state[key] === value) {\n set.emit('changes', row, changed)\n return\n }\n delete rows[row.id]\n var i = array.indexOf(row)\n if(~i) array.splice(i, 1)\n set.emit('changes', row, changed)\n set.emit('remove', row)\n row.removeListener('changes', remove)\n }\n\n row.on('changes', remove)\n \n }\n\n doc.sets.on(key, function (row, changed) {\n if(changed[key] !== value) return \n add(row)\n })\n\n this.rm = this.remove = function (row) {\n row = this.get(row) \n if(!row) return\n return row.set(key, null)\n }\n\n for(var id in doc.rows) {\n var row = doc.get(id)\n if(row.get(key) === value) add(row) \n }\n\n this.setMaxListeners(Infinity)\n\n}\n\nSet.prototype.asArray = function () {\n return this._array\n}\n\nSet.prototype.toJSON = function () {\n return this._array.map(function (e) {\n return e.state\n }).sort(function (a, b) {\n return u.strord(a._sort || a.id, b._sort || b.id)\n })\n}\n\nSet.prototype.each = \nSet.prototype.forEach = function (iter) {\n return this._array.forEach(iter)\n}\n\nSet.prototype.get = function (id) {\n if(!arguments.length)\n return this.array\n return (\n 'string' === typeof id ? this.rows[id] \n : 'number' === typeof id ? this.rows[id] \n : id && id.id ? this.rows[id.id]\n : null\n )\n}\n\nSet.prototype.has = function (row) {\n return this.get(row)\n}\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/crdt/set.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/crdt/seq.js",Function(['require','module','exports','__dirname','__filename','process','global'],"'use strict';\n\nvar Set = require('./set')\nvar Row = require('./row')\nvar inherits = require('util').inherits\nvar u = require('./utils')\n\nmodule.exports = Seq\n\nfunction sort (array) {\n return array.sort(function (a, b) {\n return u.strord(a.get('_sort'), b.get('_sort'))\n })\n}\n\ninherits(Seq, Set)\n\nfunction find (obj, iter) {\n \n for(var k in obj) {\n var v = obj[k]\n if(iter(v, k, obj)) return v\n }\n return null\n}\n\nfunction Seq (doc, key, val) {\n\n Set.call(this, doc, key, val)\n var seq = this\n this.on('changes', function (row, changes) {\n if(!changes._sort) return\n sort(seq._array)\n //check if there is already an item with this sort key.\n var prev = \n find(seq._array, function (other) {\n return other != row && other.get('_sort') == row.get('_sort')\n })\n\n //nudge it forward if it has the same key. \n if(prev)\n seq.insert(row, prev, seq.next(row)) \n else\n seq.emit('move', row)\n })\n this.insert = function (obj, before, after) {\n\n before = toKey(this.get(before) || '!')\n after = toKey(this.get(after) || '~')\n\n //must get id from the doc,\n //because may be moving this item into this set.\n if('string' === typeof obj)\n obj = doc.rows[obj]\n\n var _sort = \n u.between(before, after ) \n + u.randstr(3) //add a random tail so it's hard\n //to concurrently add two items with the\n //same sort.\n \n var r, changes\n if(obj instanceof Row) {\n r = obj\n changes = {_sort: _sort}\n if(r.get(key) != val)\n changes[key] = val\n r.set(changes)\n } else {\n obj._sort = _sort\n obj[key] = val\n r = doc.set(id(obj), obj)\n } \n sort(this._array)\n return r\n }\n}\n\nfunction toKey (key) {\n\n return (\n 'string' === typeof key ? key \n : key instanceof Row ? key.get()._sort\n : key ? key._sort\n : null\n )\n\n}\n\n/*\n items are relative to each other,\n more like a linked list.\n although it is possible to make an\n index based interface, before after,\n etc is more natural\n*/\n\nfunction max (ary, test, wantIndex) {\n var max = null, _max = -1\n if(!ary.length) return\n\n for (var i = 0; i < ary.length; i++)\n if(test(max, ary[i])) max = ary[_max = i]\n return wantIndex ? _max : max\n}\n\nSeq.prototype.prev = function (key) {\n key = toKey(this.get(key) || '~')\n //find the greatest item that is less than `key`.\n //since the list is kept in order,\n //a binary search is used.\n //think about that later\n return max(this._array, function (M, m) {\n if(toKey(m) < key)\n return M ? toKey(m) > toKey(M) : true\n })\n}\n\nSeq.prototype.next = function (key) {\n key = toKey(this.get(key) || '!')\n return max(this._array, function (M, m) {\n if(toKey(m) > key)\n return M ? toKey(m) < toKey(M) : true\n })\n}\n\nfunction id(obj) {\n return (obj.id \n || obj._id \n || '_' + Date.now() \n + '_' + Math.round(Math.random()*1000)\n )\n}\n\nSeq.prototype.before = function (obj, before) {\n return this.insert(obj, this.prev(before), before)\n}\n\nSeq.prototype.after = function (obj, after) {\n return this.insert(obj, after, this.next(after))\n}\n\nSeq.prototype.first = function () {\n return this._array[0]\n}\n\nSeq.prototype.last = function () {\n return this._array[this._array.length - 1]\n}\n\nSeq.prototype.indexOf = function (obj) {\n return this._array.indexOf('string' == typeof obj ? this.rows[obj] : obj)\n}\n\nSeq.prototype.at = function (i) {\n return this._array[i]\n}\n\nSeq.prototype.unshift = function (obj) {\n return this.insert(obj, '!', this.first())\n}\n\nSeq.prototype.push = function (obj) {\n return this.insert(obj, this.last(), '~') \n}\n\nSeq.prototype.length = function () {\n return this._array.length\n}\n\nSeq.prototype.pop = function () {\n return this.remove(this.last())\n}\n\nSeq.prototype.shift = function () {\n return this.remove(this.first())\n}\n\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/crdt/seq.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/scuttlebutt/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/scuttlebutt/package.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/scuttlebutt/index.js",Function(['require','module','exports','__dirname','__filename','process','global'],"\n//really simple data replication.\n\nvar EventEmitter = require('events').EventEmitter\nvar i = require('iterate')\nvar duplex = require('duplex')\nvar inherits = require('util').inherits\nvar serializer = require('stream-serializer')\nvar u = require('./util')\nvar ReadableStream = require('readable-stream')\nvar timestamp = require('monotonic-timestamp')\n\nexports = \nmodule.exports = Scuttlebutt\n\nexports.createID = u.createID\nexports.updateIsRecent = u.filter\nexports.filter = u.filter\nexports.timestamp = timestamp\n\nfunction dutyOfSubclass() {\n throw new Error('method must be implemented by subclass')\n}\n\nfunction validate (data) {\n var key = data[0], ts = data[2], source = data[3]\n\n if( !Array.isArray(data) \n || data.length < 4 \n || 'string' !== typeof key\n || 'string' !== typeof source\n || 'number' !== typeof ts\n ) \n return false\n\n return true\n}\n\nvar emit = EventEmitter.prototype.emit\n\ninherits (Scuttlebutt, EventEmitter)\n\nfunction Scuttlebutt (opts) {\n\n if(!(this instanceof Scuttlebutt)) return new Scuttlebutt(opts)\n var id = 'string' === typeof opts ? opts : opts && opts.id\n this.sources = {}\n\n if(opts && opts.sign && opts.verify) {\n // id should be camelcased \"Id\" not \"ID\".\n // as it's a abbreviation, not an acronym.\n this.id = opts.id || opts.createId()\n this._sign = opts.sign\n this._verify = opts.verify\n } else {\n this.id = id || u.createId()\n }\n}\n\nvar sb = Scuttlebutt.prototype\n\nvar emit = EventEmitter.prototype.emit\n\nsb.applyUpdate = dutyOfSubclass\nsb.history = dutyOfSubclass\n\nsb.localUpdate = function (key, value) {\n this._update([key, value, timestamp(), this.id])\n return this\n}\n\n//checks whether this update is valid.\n\nsb._update = function (update) {\n var ts = update[2]\n var source = update[3]\n //if this message is old for it's source,\n //ignore it. it's out of order.\n //each node must emit it's changes in order!\n \n var latest = this.sources[source]\n if(latest && latest >= ts)\n return emit.call(this, 'old_data', update), false\n\n this.sources[source] = ts\n\n var self = this\n function didVerification (err, verified) {\n\n // I'm not sure how what should happen if a async verification\n // errors. if it's an key not found - that is a verification fail,\n // not a error. if it's genunie error, really you should queue and \n // try again? or replay the message later\n // -- this should be done my the security plugin though, not scuttlebutt.\n\n if(err)\n return emit.call(self, 'error', err)\n\n if(!verified)\n return emit.call(self, 'unverified_data', update)\n\n // check if this message is older than\n // the value we already have.\n // do nothing if so\n // emit an 'old-data' event because i'll want to track how many\n // unnecessary messages are sent.\n\n if(self.applyUpdate(update))\n emit.call(self, '_update', update)\n\n }\n\n if(source !== this.id) {\n if(this._verify)\n this._verify(update, didVerification)\n else\n didVerification(null, true)\n } else {\n if(this._sign) {\n //could make this async easily enough.\n update[4] = this._sign(update)\n }\n didVerification(null, true)\n }\n\n return true\n}\n\n\n//TODO remove legacy duplex usage\n// emitData() -> _data()\n\nsb.createStream = function (opts) {\n var self = this\n //the sources for the remote end.\n var sources = {}, other\n\n var syncSent = false, syncRecv = false\n\n var d = duplex()\n d.name = opts && opts.name\n var outer = serializer(opts && opts.wrapper)(d)\n outer.inner = d\n d\n .on('write', function (data) {\n //if it's an array, it's an update.\n //if it's an object, it's a scuttlebut digest.\n if(Array.isArray(data)) {\n if(validate(data))\n return self._update(data)\n }\n //suppose we want to disconnect after we have synced?\n else if('object' === typeof data && data) {\n //when the digest is recieved from the other end,\n //send the history.\n //merge with the current list of sources.\n sources = data.clock\n i.each(self.history(sources), d.emitData.bind(d))\n\n outer.emit('header', data)\n d.emitData('SYNC')\n //when we have sent all history\n outer.emit('sync')\n syncSent = true\n //when we have recieved all histoyr\n //emit 'synced' when this stream has synced.\n if(syncRecv) outer.emit('synced')\n }\n else if('string' === typeof data && data == 'SYNC') {\n syncRecv = true\n if(syncSent) outer.emit('synced')\n }\n }).on('ended', function () {\n d.emitEnd()\n })\n .on('close', function () {\n self.removeListener('_update', onUpdate)\n })\n\n if(opts && opts.tail === false) {\n outer.on('sync', function () {\n process.nextTick(function () {\n d.emitEnd()\n })\n })\n }\n function onUpdate (update) { //key, value, source, ts\n if(!u.filter(update, sources))\n return\n\n //if I put this after source[source]= ... it breaks tests\n d.emitData(update)\n\n //really, this should happen before emitting.\n var ts = update[2]\n var source = update[3]\n sources[source] = ts\n }\n\n var outgoing = { id : self.id, clock : self.sources }\n if (opts && opts.meta) outgoing.meta = opts.meta\n d.emitData(outgoing)\n \n self.on('_update', onUpdate)\n return outer\n}\n\n//createReadStream -- for persisting.\n\nsb.createReadStream = function (opts) {\n opts = opts || {}\n\n //write this.id\n //then write the histroy.\n //then, if opts.tail\n //listen for updates, else emit 'end'\n\n var out = this.history()\n out.unshift(this.id)\n\n var tail = opts.tail !== false //default to tailing\n\n var wrapper = ({\n json: function (e) { return JSON.stringify(e) + '\\n' },\n raw: function (e) { return e }\n }) [opts.wrapper || 'json']\n\n var rs = new ReadableStream()\n rs.read = function () {\n var data = out.shift()\n\n if(!data && !tail) {\n return this.emit('end'), null\n }\n if(!data)\n return null\n \n return wrapper(data)\n }\n\n rs.end = function () {\n tail = false\n rs.emit('readable') \n process.nextTick(rs.destroy)\n }\n\n function onUpdate (update) {\n out.push(update)\n rs.emit('readable')\n }\n\n if(tail) {\n this.on('_update', onUpdate)\n }\n var self = this\n rs.destroy = function () {\n rs.removeListener('_update', onUpdate)\n rs.emit('close')\n //should this emit end?\n //this is basically close,\n //does readable-stream actually support this?\n return rs\n }\n\n this.once('dispose', function () {\n tail = false //close the stream soon.\n rs.end()\n })\n\n return rs\n}\n\nsb.createWriteStream = function (opts) {\n opts = opts || {}\n var Stream = require('stream')\n var ws = new Stream()\n var self = this, first = true\n ws.writable = true\n ws.write = function (data) {\n if(!this.writable) return\n if('string' === typeof data)\n return self.id = data, true\n first = false\n self._update(data)\n return true\n }\n ws.end = function () {\n this.writable = false\n self.sync = true\n //there are probably bugs in persisting when there are lots of streams.\n //TODO: figure out what they are! then fix them!\n emit.call(self, 'sync')\n process.nextTick(ws.destroy.bind(ws))\n }\n ws.destroy = function () {\n this.writable = false\n this.emit('close')\n }\n return serializer(opts.wrapper)(ws)\n}\n\nsb.dispose = function () {\n emit.call(this, 'dispose')\n}\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/scuttlebutt/index.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/scuttlebutt/node_modules/iterate/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {\"main\":\"index.js\"}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/scuttlebutt/node_modules/iterate/package.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/scuttlebutt/node_modules/iterate/index.js",Function(['require','module','exports','__dirname','__filename','process','global'],"\n//\n// adds all the fields from obj2 onto obj1\n//\n\nvar each = exports.each = function (obj,iterator){\n var keys = Object.keys(obj)\n keys.forEach(function (key){\n iterator(obj[key],key,obj) \n })\n}\n\nvar RX = /sadf/.constructor\nfunction rx (iterator ){\n return iterator instanceof RX ? function (str) { \n var m = iterator.exec(str)\n return m && (m[1] ? m[1] : m[0]) \n } : iterator\n}\n\nvar times = exports.times = function () {\n var args = [].slice.call(arguments)\n , iterator = rx(args.pop())\n , m = args.pop()\n , i = args.shift()\n , j = args.shift()\n , diff, dir\n , a = []\n \n i = 'number' === typeof i ? i : 1\n diff = j ? j - i : 1\n dir = i < m\n if(m == i)\n throw new Error('steps cannot be the same: '+m+', '+i)\n for (; dir ? i <= m : m <= i; i += diff)\n a.push(iterator(i))\n return a\n}\n\nvar map = exports.map = function (obj, iterator){\n iterator = rx(iterator)\n if(Array.isArray(obj))\n return obj.map(iterator)\n if('number' === typeof obj)\n return times.apply(null, [].slice.call(arguments)) \n //return if null ? \n var keys = Object.keys(obj)\n , r = {}\n keys.forEach(function (key){\n r[key] = iterator(obj[key],key,obj) \n })\n return r\n}\n\nvar findReturn = exports.findReturn = function (obj, iterator) {\n iterator = rx(iterator)\n if(obj == null)\n return\n var keys = Object.keys(obj)\n , l = keys.length\n for (var i = 0; i < l; i ++) {\n var key = keys[i]\n , value = obj[key]\n var r = iterator(value, key)\n if(r) return r\n }\n}\n\nvar find = exports.find = function (obj, iterator) { \n iterator = rx(iterator)\n return findReturn (obj, function (v, k) {\n var r = iterator(v, k)\n if(r) return v\n })\n}\n\nvar findKey = exports.findKey = function (obj, iterator) { \n iterator = rx(iterator)\n return findReturn (obj, function (v, k) {\n var r = iterator(v, k)\n if(r) return k\n })\n}\n\nvar filter = exports.filter = function (obj, iterator){\n iterator = rx (iterator)\n\n if(Array.isArray(obj))\n return obj.filter(iterator)\n \n var keys = Object.keys(obj)\n , r = {}\n keys.forEach(function (key){\n var v\n if(iterator(v = obj[key],key,obj))\n r[key] = v\n })\n return r \n}\n\nvar mapKeys = exports.mapKeys = function (ary, iterator){\n var r = {}\n iterator = rx(iterator)\n each(ary, function (v,k){\n r[v] = iterator(v,k)\n })\n return r\n}\n\n\nvar mapToArray = exports.mapToArray = function (ary, iterator){\n var r = []\n iterator = rx(iterator)\n each(ary, function (v,k){\n r.push(iterator(v,k))\n })\n return r\n}\n\nvar path = exports.path = function (object, path) {\n\n for (var i in path) {\n if(object == null) return undefined\n var key = path[i]\n object = object[key]\n }\n return object\n}\n\n/*\nNOTE: naive implementation. \n`match` must not contain circular references.\n*/\n\nvar setPath = exports.setPath = function (object, path, value) {\n\n for (var i in path) {\n var key = path[i]\n if(object[key] == null) object[key] = ( \n i + 1 == path.length ? value : {}\n )\n object = object[key]\n }\n}\n\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/scuttlebutt/node_modules/iterate/index.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/scuttlebutt/node_modules/duplex/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/scuttlebutt/node_modules/duplex/package.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/scuttlebutt/node_modules/duplex/index.js",Function(['require','module','exports','__dirname','__filename','process','global'],"var Stream = require('stream')\n\n/*\n lemmy think...\n\n pause() and resume() must prevent data from being emitted.\n\n write controls 'drain', and the return value.\n\n idea:\n\n write -> emit('write')\n\n on('pause') --> writePause = true\n if(writePause) --> wirte() == false\n on('drain') --> writePause = false\n\n pause() -> paused = true\n resume() -> paused = false, drain()\n sendData(data) -> push onto buffer or emit.\n sendEnd() -> queue end after buffer clears. \n*/\n\nmodule.exports = function (write, end) {\n var stream = new Stream() \n var buffer = [], ended = false, destroyed = false, emitEnd\n stream.writable = stream.readable = true\n stream.paused = false\n stream.buffer = buffer\n \n stream.writePause = false\n stream\n .on('pause', function () {\n stream.writePause = true\n })\n .on('drain', function () {\n stream.writePause = false\n })\n \n function destroySoon () {\n process.nextTick(stream.destroy.bind(stream))\n }\n\n if(write)\n stream.on('write', write)\n if(end)\n stream.on('ended', end)\n\n //destroy the stream once both ends are over\n //but do it in nextTick, so that other listeners\n //on end have time to respond\n stream.once('end', function () { \n stream.readable = false\n if(!stream.writable) {\n process.nextTick(function () {\n stream.destroy()\n })\n }\n })\n\n stream.once('ended', function () { \n stream.writable = false\n if(!stream.readable)\n stream.destroy()\n })\n\n // this is the default write method,\n // if you overide it, you are resposible\n // for pause state.\n\n stream.emitData =\n stream.sendData = function (data) {\n if(!stream.paused && !buffer.length)\n stream.emit('data', data)\n else \n buffer.push(data) \n return !(stream.paused || buffer.length)\n }\n\n stream.emitEnd =\n stream.sendEnd = function (data) {\n if(data) stream.emitData(data)\n if(emitEnd) return\n emitEnd = true\n //destroy is handled above.\n stream.drain()\n }\n\n stream.write = function (data) {\n stream.emit('write', data)\n return !stream.writePaused\n }\n stream.end = function () {\n stream.writable = false\n if(stream.ended) return\n stream.ended = true\n stream.emit('ended')\n }\n stream.drain = function () {\n if(!buffer.length && !emitEnd) return\n //if the stream is paused after just before emitEnd()\n //end should be buffered.\n while(!stream.paused) {\n if(buffer.length) {\n stream.emit('data', buffer.shift())\n if(buffer.length == 0)\n stream.emit('read-drain')\n }\n else if(emitEnd && stream.readable) {\n stream.readable = false\n stream.emit('end')\n return\n } else {\n //if the buffer has emptied. emit drain.\n return true\n }\n }\n }\n var started = false\n stream.resume = function () {\n //this is where I need pauseRead, and pauseWrite.\n //here the reading side is unpaused,\n //but the writing side may still be paused.\n //the whole buffer might not empity at once.\n //it might pause again.\n //the stream should never emit data inbetween pause()...resume()\n //and write should return !buffer.length\n started = true\n stream.paused = false\n stream.drain() //will emit drain if buffer empties.\n return stream\n }\n\n stream.destroy = function () {\n if(destroyed) return\n destroyed = ended = true \n buffer.length = 0\n stream.emit('close')\n }\n var pauseCalled = false\n stream.pause = function () {\n started = true\n stream.paused = true\n return stream\n }\n stream.paused = true\n process.nextTick(function () {\n //unless the user manually\n if(started) return\n stream.resume()\n })\n \n return stream\n}\n\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/scuttlebutt/node_modules/duplex/index.js" | |
)); | |
require.define("stream",Function(['require','module','exports','__dirname','__filename','process','global'],"var events = require('events');\nvar util = require('util');\n\nfunction Stream() {\n events.EventEmitter.call(this);\n}\nutil.inherits(Stream, events.EventEmitter);\nmodule.exports = Stream;\n// Backwards-compat with node 0.4.x\nStream.Stream = Stream;\n\nStream.prototype.pipe = function(dest, options) {\n var source = this;\n\n function ondata(chunk) {\n if (dest.writable) {\n if (false === dest.write(chunk) && source.pause) {\n source.pause();\n }\n }\n }\n\n source.on('data', ondata);\n\n function ondrain() {\n if (source.readable && source.resume) {\n source.resume();\n }\n }\n\n dest.on('drain', ondrain);\n\n // If the 'end' option is not supplied, dest.end() will be called when\n // source gets the 'end' or 'close' events. Only dest.end() once, and\n // only when all sources have ended.\n if (!dest._isStdio && (!options || options.end !== false)) {\n dest._pipeCount = dest._pipeCount || 0;\n dest._pipeCount++;\n\n source.on('end', onend);\n source.on('close', onclose);\n }\n\n var didOnEnd = false;\n function onend() {\n if (didOnEnd) return;\n didOnEnd = true;\n\n dest._pipeCount--;\n\n // remove the listeners\n cleanup();\n\n if (dest._pipeCount > 0) {\n // waiting for other incoming streams to end.\n return;\n }\n\n dest.end();\n }\n\n\n function onclose() {\n if (didOnEnd) return;\n didOnEnd = true;\n\n dest._pipeCount--;\n\n // remove the listeners\n cleanup();\n\n if (dest._pipeCount > 0) {\n // waiting for other incoming streams to end.\n return;\n }\n\n dest.destroy();\n }\n\n // don't leave dangling pipes when there are errors.\n function onerror(er) {\n cleanup();\n if (this.listeners('error').length === 0) {\n throw er; // Unhandled stream error in pipe.\n }\n }\n\n source.on('error', onerror);\n dest.on('error', onerror);\n\n // remove all the event listeners that were added.\n function cleanup() {\n source.removeListener('data', ondata);\n dest.removeListener('drain', ondrain);\n\n source.removeListener('end', onend);\n source.removeListener('close', onclose);\n\n source.removeListener('error', onerror);\n dest.removeListener('error', onerror);\n\n source.removeListener('end', cleanup);\n source.removeListener('close', cleanup);\n\n dest.removeListener('end', cleanup);\n dest.removeListener('close', cleanup);\n }\n\n source.on('end', cleanup);\n source.on('close', cleanup);\n\n dest.on('end', cleanup);\n dest.on('close', cleanup);\n\n dest.emit('pipe', source);\n\n // Allow for unix-like usage: A.pipe(B).pipe(C)\n return dest;\n};\n\n//@ sourceURL=stream" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/scuttlebutt/node_modules/stream-serializer/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/scuttlebutt/node_modules/stream-serializer/package.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/scuttlebutt/node_modules/stream-serializer/index.js",Function(['require','module','exports','__dirname','__filename','process','global'],"\nvar EventEmitter = require('events').EventEmitter\n\nexports = module.exports = function (wrapper) {\n\n if('function' == typeof wrapper)\n return wrapper\n \n return exports[wrapper] || exports.json\n}\n\nexports.json = function (stream) {\n\n var write = stream.write\n var soFar = ''\n\n function parse (line) {\n var js\n try {\n js = JSON.parse(line)\n //ignore lines of whitespace...\n } catch (err) { \n return console.error('invalid JSON', line)\n }\n if(js !== undefined)\n write.call(stream, js)\n }\n\n function onData (data) {\n var lines = (soFar + data).split('\\n')\n soFar = lines.pop()\n while(lines.length) {\n parse(lines.shift())\n }\n }\n\n stream.write = onData\n \n var end = stream.end\n\n stream.end = function (data) {\n if(data)\n stream.write(data)\n //if there is any left over...\n if(soFar) {\n parse(soFar)\n }\n return end.call(stream)\n }\n\n stream.emit = function (event, data) {\n\n if(event == 'data') {\n data = JSON.stringify(data) + '\\n'\n }\n //since all stream events only use one argument, this is okay...\n EventEmitter.prototype.emit.call(stream, event, data)\n }\n\n return stream\n// return es.pipeline(es.split(), es.parse(), stream, es.stringify())\n}\n\nexports.raw = function (stream) {\n return stream\n}\n\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/scuttlebutt/node_modules/stream-serializer/index.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/scuttlebutt/util.js",Function(['require','module','exports','__dirname','__filename','process','global'],"exports.createId = \nfunction () {\n return [1,1,1].map(function () {\n return Math.random().toString(16).substring(2).toUpperCase()\n }).join('')\n}\n\nexports.filter = function (update, sources) {\n var ts = update[2]\n var source = update[3]\n return (!sources || !sources[source] || sources[source] < ts)\n}\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/scuttlebutt/util.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/scuttlebutt/node_modules/readable-stream/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {\"main\":\"readable.js\"}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/scuttlebutt/node_modules/readable-stream/package.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/scuttlebutt/node_modules/readable-stream/readable.js",Function(['require','module','exports','__dirname','__filename','process','global'],"// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nmodule.exports = Readable;\n\nvar Stream = require('stream');\nvar util = require('util');\nvar assert = require('assert');\nvar StringDecoder;\n\nutil.inherits(Readable, Stream);\n\nfunction ReadableState(options) {\n options = options || {};\n\n this.bufferSize = options.bufferSize || 16 * 1024;\n assert(typeof this.bufferSize === 'number');\n // cast to an int\n this.bufferSize = ~~this.bufferSize;\n\n this.lowWaterMark = options.hasOwnProperty('lowWaterMark') ?\n options.lowWaterMark : 1024;\n this.buffer = [];\n this.length = 0;\n this.pipes = [];\n this.flowing = false;\n this.ended = false;\n this.endEmitted = false;\n this.reading = false;\n\n // whenever we return null, then we set a flag to say\n // that we're awaiting a 'readable' event emission.\n this.needReadable = false;\n\n this.decoder = null;\n if (options.encoding) {\n if (!StringDecoder)\n StringDecoder = require('string_decoder').StringDecoder;\n this.decoder = new StringDecoder(options.encoding);\n }\n}\n\nfunction Readable(options) {\n if (!(this instanceof Readable))\n return new Readable(options);\n\n this._readableState = new ReadableState(options, this);\n Stream.apply(this);\n}\n\n// backwards compatibility.\nReadable.prototype.setEncoding = function(enc) {\n if (!StringDecoder)\n StringDecoder = require('string_decoder').StringDecoder;\n this._readableState.decoder = new StringDecoder(enc);\n};\n\n\nfunction howMuchToRead(n, state) {\n if (state.length === 0 && state.ended)\n return 0;\n\n if (isNaN(n))\n return state.length;\n\n if (n <= 0)\n return 0;\n\n // don't have that much. return null, unless we've ended.\n if (n > state.length) {\n if (!state.ended) {\n state.needReadable = true;\n return 0;\n } else\n return state.length;\n }\n\n return n;\n}\n\n// you can override either this method, or _read(n, cb) below.\nReadable.prototype.read = function(n) {\n var state = this._readableState;\n var nOrig = n;\n\n n = howMuchToRead(n, state);\n\n // if we've ended, and we're now clear, then finish it up.\n if (n === 0 && state.ended) {\n endReadable(this);\n return null;\n }\n\n // All the actual chunk generation logic needs to be\n // *below* the call to _read. The reason is that in certain\n // synthetic stream cases, such as passthrough streams, _read\n // may be a completely synchronous operation which may change\n // the state of the read buffer, providing enough data when\n // before there was *not* enough.\n //\n // So, the steps are:\n // 1. Figure out what the state of things will be after we do\n // a read from the buffer.\n //\n // 2. If that resulting state will trigger a _read, then call _read.\n // Note that this may be asynchronous, or synchronous. Yes, it is\n // deeply ugly to write APIs this way, but that still doesn't mean\n // that the Readable class should behave improperly, as streams are\n // designed to be sync/async agnostic.\n // Take note if the _read call is sync or async (ie, if the read call\n // has returned yet), so that we know whether or not it's safe to emit\n // 'readable' etc.\n //\n // 3. Actually pull the requested chunks out of the buffer and return.\n\n // if we need a readable event, then we need to do some reading.\n var doRead = state.needReadable;\n // if we currently have less than the lowWaterMark, then also read some\n if (state.length - n <= state.lowWaterMark)\n doRead = true;\n // however, if we've ended, then there's no point, and if we're already\n // reading, then it's unnecessary.\n if (state.ended || state.reading)\n doRead = false;\n\n if (doRead) {\n var sync = true;\n state.reading = true;\n // call internal read method\n this._read(state.bufferSize, function onread(er, chunk) {\n state.reading = false;\n if (er)\n return this.emit('error', er);\n\n if (!chunk || !chunk.length) {\n // eof\n state.ended = true;\n // if we've ended and we have some data left, then emit\n // 'readable' now to make sure it gets picked up.\n if (!sync) {\n if (state.length > 0)\n this.emit('readable');\n else\n endReadable(this);\n }\n return;\n }\n\n if (state.decoder)\n chunk = state.decoder.write(chunk);\n\n // update the buffer info.\n if (chunk) {\n state.length += chunk.length;\n state.buffer.push(chunk);\n }\n\n // if we haven't gotten enough to pass the lowWaterMark,\n // and we haven't ended, then don't bother telling the user\n // that it's time to read more data. Otherwise, that'll\n // probably kick off another stream.read(), which can trigger\n // another _read(n,cb) before this one returns!\n if (state.length <= state.lowWaterMark) {\n state.reading = true;\n this._read(state.bufferSize, onread.bind(this));\n return;\n }\n\n if (state.needReadable && !sync) {\n state.needReadable = false;\n this.emit('readable');\n }\n }.bind(this));\n sync = false;\n }\n\n // If _read called its callback synchronously, then `reading`\n // will be false, and we need to re-evaluate how much data we\n // can return to the user.\n if (doRead && !state.reading)\n n = howMuchToRead(nOrig, state);\n\n var ret;\n if (n > 0)\n ret = fromList(n, state.buffer, state.length, !!state.decoder);\n else\n ret = null;\n\n if (ret === null || ret.length === 0) {\n state.needReadable = true;\n n = 0;\n }\n\n state.length -= n;\n\n return ret;\n};\n\n// abstract method. to be overridden in specific implementation classes.\n// call cb(er, data) where data is <= n in length.\n// for virtual (non-string, non-buffer) streams, \"length\" is somewhat\n// arbitrary, and perhaps not very meaningful.\nReadable.prototype._read = function(n, cb) {\n process.nextTick(cb.bind(this, new Error('not implemented')));\n};\n\nReadable.prototype.pipe = function(dest, pipeOpts) {\n var src = this;\n var state = this._readableState;\n if (!pipeOpts)\n pipeOpts = {};\n state.pipes.push(dest);\n\n if ((!pipeOpts || pipeOpts.end !== false) &&\n dest !== process.stdout &&\n dest !== process.stderr) {\n src.once('end', onend);\n dest.on('unpipe', function(readable) {\n if (readable === src)\n src.removeListener('end', onend);\n });\n }\n\n function onend() {\n dest.end();\n }\n\n dest.emit('pipe', src);\n\n // start the flow.\n if (!state.flowing) {\n state.flowing = true;\n process.nextTick(flow.bind(null, src, pipeOpts));\n }\n\n return dest;\n};\n\nfunction flow(src, pipeOpts) {\n var state = src._readableState;\n var chunk;\n var needDrain = 0;\n\n function ondrain() {\n needDrain--;\n if (needDrain === 0)\n flow(src, pipeOpts);\n }\n\n while (state.pipes.length &&\n null !== (chunk = src.read(pipeOpts.chunkSize))) {\n state.pipes.forEach(function(dest, i, list) {\n var written = dest.write(chunk);\n if (false === written) {\n needDrain++;\n dest.once('drain', ondrain);\n }\n });\n src.emit('data', chunk);\n\n // if anyone needs a drain, then we have to wait for that.\n if (needDrain > 0)\n return;\n }\n\n // if every destination was unpiped, either before entering this\n // function, or in the while loop, then stop flowing.\n //\n // NB: This is a pretty rare edge case.\n if (state.pipes.length === 0) {\n state.flowing = false;\n\n // if there were data event listeners added, then switch to old mode.\n if (this.listeners('data').length)\n emitDataEvents(this);\n return;\n }\n\n // at this point, no one needed a drain, so we just ran out of data\n // on the next readable event, start it over again.\n src.once('readable', flow.bind(null, src, pipeOpts));\n}\n\nReadable.prototype.unpipe = function(dest) {\n var state = this._readableState;\n if (!dest) {\n // remove all of them.\n state.pipes.forEach(function(dest, i, list) {\n dest.emit('unpipe', this);\n }, this);\n state.pipes.length = 0;\n } else {\n var i = state.pipes.indexOf(dest);\n if (i !== -1) {\n dest.emit('unpipe', this);\n state.pipes.splice(i, 1);\n }\n }\n return this;\n};\n\n// kludge for on('data', fn) consumers. Sad.\n// This is *not* part of the new readable stream interface.\n// It is an ugly unfortunate mess of history.\nReadable.prototype.on = function(ev, fn) {\n // https://github.com/isaacs/readable-stream/issues/16\n // if we're already flowing, then no need to set up data events.\n if (ev === 'data' && !this._readableState.flowing)\n emitDataEvents(this);\n\n return Stream.prototype.on.call(this, ev, fn);\n};\nReadable.prototype.addListener = Readable.prototype.on;\n\n// pause() and resume() are remnants of the legacy readable stream API\n// If the user uses them, then switch into old mode.\nReadable.prototype.resume = function() {\n emitDataEvents(this);\n return this.resume();\n};\n\nReadable.prototype.pause = function() {\n emitDataEvents(this);\n return this.pause();\n};\n\nfunction emitDataEvents(stream) {\n var state = stream._readableState;\n\n if (state.flowing) {\n // https://github.com/isaacs/readable-stream/issues/16\n throw new Error('Cannot switch to old mode now.');\n }\n\n var paused = false;\n var readable = false;\n\n // convert to an old-style stream.\n stream.readable = true;\n stream.pipe = Stream.prototype.pipe;\n stream.on = stream.addEventListener = Stream.prototype.on;\n\n stream.on('readable', function() {\n readable = true;\n var c;\n while (!paused && (null !== (c = stream.read())))\n stream.emit('data', c);\n\n if (c === null) {\n readable = false;\n stream._readableState.needReadable = true;\n }\n });\n\n stream.pause = function() {\n paused = true;\n };\n\n stream.resume = function() {\n paused = false;\n if (readable)\n stream.emit('readable');\n };\n\n // now make it start, just in case it hadn't already.\n process.nextTick(function() {\n stream.emit('readable');\n });\n}\n\n// wrap an old-style stream as the async data source.\n// This is *not* part of the readable stream interface.\n// It is an ugly unfortunate mess of history.\nReadable.prototype.wrap = function(stream) {\n var state = this._readableState;\n var paused = false;\n\n stream.on('end', function() {\n state.ended = true;\n if (state.length === 0)\n endReadable(this);\n }.bind(this));\n\n stream.on('data', function(chunk) {\n state.buffer.push(chunk);\n state.length += chunk.length;\n this.emit('readable');\n\n // if not consumed, then pause the stream.\n if (state.length > state.lowWaterMark && !paused) {\n paused = true;\n stream.pause();\n }\n }.bind(this));\n\n // proxy all the other methods.\n // important when wrapping filters and duplexes.\n for (var i in stream) {\n if (typeof stream[i] === 'function' &&\n typeof this[i] === 'undefined') {\n this[i] = function(method) { return function() {\n return stream[method].apply(stream, arguments);\n }}(i);\n }\n }\n\n // proxy certain important events.\n var events = ['error', 'close', 'destroy', 'pause', 'resume'];\n events.forEach(function(ev) {\n stream.on(ev, this.emit.bind(this, ev));\n }.bind(this));\n\n // consume some bytes. if not all is consumed, then\n // pause the underlying stream.\n this.read = function(n) {\n if (state.length === 0) {\n state.needReadable = true;\n return null;\n }\n\n if (isNaN(n) || n <= 0)\n n = state.length;\n\n if (n > state.length) {\n if (!state.ended) {\n state.needReadable = true;\n return null;\n } else\n n = state.length;\n }\n\n var ret = fromList(n, state.buffer, state.length, !!state.decoder);\n state.length -= n;\n\n if (state.length <= state.lowWaterMark && paused) {\n stream.resume();\n paused = false;\n }\n\n if (state.length === 0 && state.ended)\n endReadable(this);\n\n return ret;\n };\n};\n\n\n\n// exposed for testing purposes only.\nReadable._fromList = fromList;\n\n// Pluck off n bytes from an array of buffers.\n// Length is the combined lengths of all the buffers in the list.\nfunction fromList(n, list, length, stringMode) {\n var ret;\n\n // nothing in the list, definitely empty.\n if (list.length === 0) {\n return null;\n }\n\n if (length === 0)\n ret = null;\n else if (!n || n >= length) {\n // read it all, truncate the array.\n if (stringMode)\n ret = list.join('');\n else\n ret = Buffer.concat(list, length);\n list.length = 0;\n } else {\n // read just some of it.\n if (n < list[0].length) {\n // just take a part of the first list item.\n // slice is the same for buffers and strings.\n var buf = list[0];\n ret = buf.slice(0, n);\n list[0] = buf.slice(n);\n } else if (n === list[0].length) {\n // first list is a perfect match\n ret = list.shift();\n } else {\n // complex case.\n // we have enough to cover it, but it spans past the first buffer.\n if (stringMode)\n ret = '';\n else\n ret = new Buffer(n);\n\n var c = 0;\n for (var i = 0, l = list.length; i < l && c < n; i++) {\n var buf = list[0];\n var cpy = Math.min(n - c, buf.length);\n\n if (stringMode)\n ret += buf.slice(0, cpy);\n else\n buf.copy(ret, c, 0, cpy);\n\n if (cpy < buf.length)\n list[0] = buf.slice(cpy);\n else\n list.shift();\n\n c += cpy;\n }\n }\n }\n\n return ret;\n}\n\nfunction endReadable(stream) {\n var state = stream._readableState;\n if (state.endEmitted)\n return;\n state.ended = true;\n state.endEmitted = true;\n process.nextTick(stream.emit.bind(stream, 'end'));\n}\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/scuttlebutt/node_modules/readable-stream/readable.js" | |
)); | |
require.define("assert",Function(['require','module','exports','__dirname','__filename','process','global'],"// UTILITY\nvar util = require('util');\nvar Buffer = require(\"buffer\").Buffer;\nvar pSlice = Array.prototype.slice;\n\n// 1. The assert module provides functions that throw\n// AssertionError's when particular conditions are not met. The\n// assert module must conform to the following interface.\n\nvar assert = module.exports = ok;\n\n// 2. The AssertionError is defined in assert.\n// new assert.AssertionError({ message: message,\n// actual: actual,\n// expected: expected })\n\nassert.AssertionError = function AssertionError(options) {\n this.name = 'AssertionError';\n this.message = options.message;\n this.actual = options.actual;\n this.expected = options.expected;\n this.operator = options.operator;\n var stackStartFunction = options.stackStartFunction || fail;\n\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, stackStartFunction);\n }\n};\nutil.inherits(assert.AssertionError, Error);\n\nfunction replacer(key, value) {\n if (value === undefined) {\n return '' + value;\n }\n if (typeof value === 'number' && (isNaN(value) || !isFinite(value))) {\n return value.toString();\n }\n if (typeof value === 'function' || value instanceof RegExp) {\n return value.toString();\n }\n return value;\n}\n\nfunction truncate(s, n) {\n if (typeof s == 'string') {\n return s.length < n ? s : s.slice(0, n);\n } else {\n return s;\n }\n}\n\nassert.AssertionError.prototype.toString = function() {\n if (this.message) {\n return [this.name + ':', this.message].join(' ');\n } else {\n return [\n this.name + ':',\n truncate(JSON.stringify(this.actual, replacer), 128),\n this.operator,\n truncate(JSON.stringify(this.expected, replacer), 128)\n ].join(' ');\n }\n};\n\n// assert.AssertionError instanceof Error\n\nassert.AssertionError.__proto__ = Error.prototype;\n\n// At present only the three keys mentioned above are used and\n// understood by the spec. Implementations or sub modules can pass\n// other keys to the AssertionError's constructor - they will be\n// ignored.\n\n// 3. All of the following functions must throw an AssertionError\n// when a corresponding condition is not met, with a message that\n// may be undefined if not provided. All assertion methods provide\n// both the actual and expected values to the assertion error for\n// display purposes.\n\nfunction fail(actual, expected, message, operator, stackStartFunction) {\n throw new assert.AssertionError({\n message: message,\n actual: actual,\n expected: expected,\n operator: operator,\n stackStartFunction: stackStartFunction\n });\n}\n\n// EXTENSION! allows for well behaved errors defined elsewhere.\nassert.fail = fail;\n\n// 4. Pure assertion tests whether a value is truthy, as determined\n// by !!guard.\n// assert.ok(guard, message_opt);\n// This statement is equivalent to assert.equal(true, guard,\n// message_opt);. To test strictly for the value true, use\n// assert.strictEqual(true, guard, message_opt);.\n\nfunction ok(value, message) {\n if (!!!value) fail(value, true, message, '==', assert.ok);\n}\nassert.ok = ok;\n\n// 5. The equality assertion tests shallow, coercive equality with\n// ==.\n// assert.equal(actual, expected, message_opt);\n\nassert.equal = function equal(actual, expected, message) {\n if (actual != expected) fail(actual, expected, message, '==', assert.equal);\n};\n\n// 6. The non-equality assertion tests for whether two objects are not equal\n// with != assert.notEqual(actual, expected, message_opt);\n\nassert.notEqual = function notEqual(actual, expected, message) {\n if (actual == expected) {\n fail(actual, expected, message, '!=', assert.notEqual);\n }\n};\n\n// 7. The equivalence assertion tests a deep equality relation.\n// assert.deepEqual(actual, expected, message_opt);\n\nassert.deepEqual = function deepEqual(actual, expected, message) {\n if (!_deepEqual(actual, expected)) {\n fail(actual, expected, message, 'deepEqual', assert.deepEqual);\n }\n};\n\nfunction _deepEqual(actual, expected) {\n // 7.1. All identical values are equivalent, as determined by ===.\n if (actual === expected) {\n return true;\n\n } else if (Buffer.isBuffer(actual) && Buffer.isBuffer(expected)) {\n if (actual.length != expected.length) return false;\n\n for (var i = 0; i < actual.length; i++) {\n if (actual[i] !== expected[i]) return false;\n }\n\n return true;\n\n // 7.2. If the expected value is a Date object, the actual value is\n // equivalent if it is also a Date object that refers to the same time.\n } else if (actual instanceof Date && expected instanceof Date) {\n return actual.getTime() === expected.getTime();\n\n // 7.3. Other pairs that do not both pass typeof value == 'object',\n // equivalence is determined by ==.\n } else if (typeof actual != 'object' && typeof expected != 'object') {\n return actual == expected;\n\n // 7.4. For all other Object pairs, including Array objects, equivalence is\n // determined by having the same number of owned properties (as verified\n // with Object.prototype.hasOwnProperty.call), the same set of keys\n // (although not necessarily the same order), equivalent values for every\n // corresponding key, and an identical 'prototype' property. Note: this\n // accounts for both named and indexed properties on Arrays.\n } else {\n return objEquiv(actual, expected);\n }\n}\n\nfunction isUndefinedOrNull(value) {\n return value === null || value === undefined;\n}\n\nfunction isArguments(object) {\n return Object.prototype.toString.call(object) == '[object Arguments]';\n}\n\nfunction objEquiv(a, b) {\n if (isUndefinedOrNull(a) || isUndefinedOrNull(b))\n return false;\n // an identical 'prototype' property.\n if (a.prototype !== b.prototype) return false;\n //~~~I've managed to break Object.keys through screwy arguments passing.\n // Converting to array solves the problem.\n if (isArguments(a)) {\n if (!isArguments(b)) {\n return false;\n }\n a = pSlice.call(a);\n b = pSlice.call(b);\n return _deepEqual(a, b);\n }\n try {\n var ka = Object.keys(a),\n kb = Object.keys(b),\n key, i;\n } catch (e) {//happens when one is a string literal and the other isn't\n return false;\n }\n // having the same number of owned properties (keys incorporates\n // hasOwnProperty)\n if (ka.length != kb.length)\n return false;\n //the same set of keys (although not necessarily the same order),\n ka.sort();\n kb.sort();\n //~~~cheap key test\n for (i = ka.length - 1; i >= 0; i--) {\n if (ka[i] != kb[i])\n return false;\n }\n //equivalent values for every corresponding key, and\n //~~~possibly expensive deep test\n for (i = ka.length - 1; i >= 0; i--) {\n key = ka[i];\n if (!_deepEqual(a[key], b[key])) return false;\n }\n return true;\n}\n\n// 8. The non-equivalence assertion tests for any deep inequality.\n// assert.notDeepEqual(actual, expected, message_opt);\n\nassert.notDeepEqual = function notDeepEqual(actual, expected, message) {\n if (_deepEqual(actual, expected)) {\n fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);\n }\n};\n\n// 9. The strict equality assertion tests strict equality, as determined by ===.\n// assert.strictEqual(actual, expected, message_opt);\n\nassert.strictEqual = function strictEqual(actual, expected, message) {\n if (actual !== expected) {\n fail(actual, expected, message, '===', assert.strictEqual);\n }\n};\n\n// 10. The strict non-equality assertion tests for strict inequality, as\n// determined by !==. assert.notStrictEqual(actual, expected, message_opt);\n\nassert.notStrictEqual = function notStrictEqual(actual, expected, message) {\n if (actual === expected) {\n fail(actual, expected, message, '!==', assert.notStrictEqual);\n }\n};\n\nfunction expectedException(actual, expected) {\n if (!actual || !expected) {\n return false;\n }\n\n if (expected instanceof RegExp) {\n return expected.test(actual);\n } else if (actual instanceof expected) {\n return true;\n } else if (expected.call({}, actual) === true) {\n return true;\n }\n\n return false;\n}\n\nfunction _throws(shouldThrow, block, expected, message) {\n var actual;\n\n if (typeof expected === 'string') {\n message = expected;\n expected = null;\n }\n\n try {\n block();\n } catch (e) {\n actual = e;\n }\n\n message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +\n (message ? ' ' + message : '.');\n\n if (shouldThrow && !actual) {\n fail('Missing expected exception' + message);\n }\n\n if (!shouldThrow && expectedException(actual, expected)) {\n fail('Got unwanted exception' + message);\n }\n\n if ((shouldThrow && actual && expected &&\n !expectedException(actual, expected)) || (!shouldThrow && actual)) {\n throw actual;\n }\n}\n\n// 11. Expected to throw an error:\n// assert.throws(block, Error_opt, message_opt);\n\nassert.throws = function(block, /*optional*/error, /*optional*/message) {\n _throws.apply(this, [true].concat(pSlice.call(arguments)));\n};\n\n// EXTENSION! This is annoying to write outside this module.\nassert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) {\n _throws.apply(this, [false].concat(pSlice.call(arguments)));\n};\n\nassert.ifError = function(err) { if (err) {throw err;}};\n\n//@ sourceURL=assert" | |
)); | |
require.define("buffer",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = require(\"buffer-browserify\")\n//@ sourceURL=buffer" | |
)); | |
require.define("/AppData/Roaming/npm/node_modules/browserify-server/node_modules/browserify/node_modules/buffer-browserify/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {\"main\":\"index.js\",\"browserify\":\"index.js\"}\n//@ sourceURL=/AppData/Roaming/npm/node_modules/browserify-server/node_modules/browserify/node_modules/buffer-browserify/package.json" | |
)); | |
require.define("/AppData/Roaming/npm/node_modules/browserify-server/node_modules/browserify/node_modules/buffer-browserify/index.js",Function(['require','module','exports','__dirname','__filename','process','global'],"function SlowBuffer (size) {\n this.length = size;\n};\n\nvar assert = require('assert');\n\nexports.INSPECT_MAX_BYTES = 50;\n\n\nfunction toHex(n) {\n if (n < 16) return '0' + n.toString(16);\n return n.toString(16);\n}\n\nfunction utf8ToBytes(str) {\n var byteArray = [];\n for (var i = 0; i < str.length; i++)\n if (str.charCodeAt(i) <= 0x7F)\n byteArray.push(str.charCodeAt(i));\n else {\n var h = encodeURIComponent(str.charAt(i)).substr(1).split('%');\n for (var j = 0; j < h.length; j++)\n byteArray.push(parseInt(h[j], 16));\n }\n\n return byteArray;\n}\n\nfunction asciiToBytes(str) {\n var byteArray = []\n for (var i = 0; i < str.length; i++ )\n // Node's code seems to be doing this and not & 0x7F..\n byteArray.push( str.charCodeAt(i) & 0xFF );\n\n return byteArray;\n}\n\nfunction base64ToBytes(str) {\n return require(\"base64-js\").toByteArray(str);\n}\n\nSlowBuffer.byteLength = function (str, encoding) {\n switch (encoding || \"utf8\") {\n case 'hex':\n return str.length / 2;\n\n case 'utf8':\n case 'utf-8':\n return utf8ToBytes(str).length;\n\n case 'ascii':\n return str.length;\n\n case 'base64':\n return base64ToBytes(str).length;\n\n default:\n throw new Error('Unknown encoding');\n }\n};\n\nfunction blitBuffer(src, dst, offset, length) {\n var pos, i = 0;\n while (i < length) {\n if ((i+offset >= dst.length) || (i >= src.length))\n break;\n\n dst[i + offset] = src[i];\n i++;\n }\n return i;\n}\n\nSlowBuffer.prototype.utf8Write = function (string, offset, length) {\n var bytes, pos;\n return SlowBuffer._charsWritten = blitBuffer(utf8ToBytes(string), this, offset, length);\n};\n\nSlowBuffer.prototype.asciiWrite = function (string, offset, length) {\n var bytes, pos;\n return SlowBuffer._charsWritten = blitBuffer(asciiToBytes(string), this, offset, length);\n};\n\nSlowBuffer.prototype.base64Write = function (string, offset, length) {\n var bytes, pos;\n return SlowBuffer._charsWritten = blitBuffer(base64ToBytes(string), this, offset, length);\n};\n\nSlowBuffer.prototype.base64Slice = function (start, end) {\n var bytes = Array.prototype.slice.apply(this, arguments)\n return require(\"base64-js\").fromByteArray(bytes);\n}\n\nfunction decodeUtf8Char(str) {\n try {\n return decodeURIComponent(str);\n } catch (err) {\n return String.fromCharCode(0xFFFD); // UTF 8 invalid char\n }\n}\n\nSlowBuffer.prototype.utf8Slice = function () {\n var bytes = Array.prototype.slice.apply(this, arguments);\n var res = \"\";\n var tmp = \"\";\n var i = 0;\n while (i < bytes.length) {\n if (bytes[i] <= 0x7F) {\n res += decodeUtf8Char(tmp) + String.fromCharCode(bytes[i]);\n tmp = \"\";\n } else\n tmp += \"%\" + bytes[i].toString(16);\n\n i++;\n }\n\n return res + decodeUtf8Char(tmp);\n}\n\nSlowBuffer.prototype.asciiSlice = function () {\n var bytes = Array.prototype.slice.apply(this, arguments);\n var ret = \"\";\n for (var i = 0; i < bytes.length; i++)\n ret += String.fromCharCode(bytes[i]);\n return ret;\n}\n\nSlowBuffer.prototype.inspect = function() {\n var out = [],\n len = this.length;\n for (var i = 0; i < len; i++) {\n out[i] = toHex(this[i]);\n if (i == exports.INSPECT_MAX_BYTES) {\n out[i + 1] = '...';\n break;\n }\n }\n return '<SlowBuffer ' + out.join(' ') + '>';\n};\n\n\nSlowBuffer.prototype.hexSlice = function(start, end) {\n var len = this.length;\n\n if (!start || start < 0) start = 0;\n if (!end || end < 0 || end > len) end = len;\n\n var out = '';\n for (var i = start; i < end; i++) {\n out += toHex(this[i]);\n }\n return out;\n};\n\n\nSlowBuffer.prototype.toString = function(encoding, start, end) {\n encoding = String(encoding || 'utf8').toLowerCase();\n start = +start || 0;\n if (typeof end == 'undefined') end = this.length;\n\n // Fastpath empty strings\n if (+end == start) {\n return '';\n }\n\n switch (encoding) {\n case 'hex':\n return this.hexSlice(start, end);\n\n case 'utf8':\n case 'utf-8':\n return this.utf8Slice(start, end);\n\n case 'ascii':\n return this.asciiSlice(start, end);\n\n case 'binary':\n return this.binarySlice(start, end);\n\n case 'base64':\n return this.base64Slice(start, end);\n\n case 'ucs2':\n case 'ucs-2':\n return this.ucs2Slice(start, end);\n\n default:\n throw new Error('Unknown encoding');\n }\n};\n\n\nSlowBuffer.prototype.hexWrite = function(string, offset, length) {\n offset = +offset || 0;\n var remaining = this.length - offset;\n if (!length) {\n length = remaining;\n } else {\n length = +length;\n if (length > remaining) {\n length = remaining;\n }\n }\n\n // must be an even number of digits\n var strLen = string.length;\n if (strLen % 2) {\n throw new Error('Invalid hex string');\n }\n if (length > strLen / 2) {\n length = strLen / 2;\n }\n for (var i = 0; i < length; i++) {\n var byte = parseInt(string.substr(i * 2, 2), 16);\n if (isNaN(byte)) throw new Error('Invalid hex string');\n this[offset + i] = byte;\n }\n SlowBuffer._charsWritten = i * 2;\n return i;\n};\n\n\nSlowBuffer.prototype.write = function(string, offset, length, encoding) {\n // Support both (string, offset, length, encoding)\n // and the legacy (string, encoding, offset, length)\n if (isFinite(offset)) {\n if (!isFinite(length)) {\n encoding = length;\n length = undefined;\n }\n } else { // legacy\n var swap = encoding;\n encoding = offset;\n offset = length;\n length = swap;\n }\n\n offset = +offset || 0;\n var remaining = this.length - offset;\n if (!length) {\n length = remaining;\n } else {\n length = +length;\n if (length > remaining) {\n length = remaining;\n }\n }\n encoding = String(encoding || 'utf8').toLowerCase();\n\n switch (encoding) {\n case 'hex':\n return this.hexWrite(string, offset, length);\n\n case 'utf8':\n case 'utf-8':\n return this.utf8Write(string, offset, length);\n\n case 'ascii':\n return this.asciiWrite(string, offset, length);\n\n case 'binary':\n return this.binaryWrite(string, offset, length);\n\n case 'base64':\n return this.base64Write(string, offset, length);\n\n case 'ucs2':\n case 'ucs-2':\n return this.ucs2Write(string, offset, length);\n\n default:\n throw new Error('Unknown encoding');\n }\n};\n\n\n// slice(start, end)\nSlowBuffer.prototype.slice = function(start, end) {\n if (end === undefined) end = this.length;\n\n if (end > this.length) {\n throw new Error('oob');\n }\n if (start > end) {\n throw new Error('oob');\n }\n\n return new Buffer(this, end - start, +start);\n};\n\nSlowBuffer.prototype.copy = function(target, targetstart, sourcestart, sourceend) {\n var temp = [];\n for (var i=sourcestart; i<sourceend; i++) {\n assert.ok(typeof this[i] !== 'undefined', \"copying undefined buffer bytes!\");\n temp.push(this[i]);\n }\n\n for (var i=targetstart; i<targetstart+temp.length; i++) {\n target[i] = temp[i-targetstart];\n }\n};\n\nfunction coerce(length) {\n // Coerce length to a number (possibly NaN), round up\n // in case it's fractional (e.g. 123.456) then do a\n // double negate to coerce a NaN to 0. Easy, right?\n length = ~~Math.ceil(+length);\n return length < 0 ? 0 : length;\n}\n\n\n// Buffer\n\nfunction Buffer(subject, encoding, offset) {\n if (!(this instanceof Buffer)) {\n return new Buffer(subject, encoding, offset);\n }\n\n var type;\n\n // Are we slicing?\n if (typeof offset === 'number') {\n this.length = coerce(encoding);\n this.parent = subject;\n this.offset = offset;\n } else {\n // Find the length\n switch (type = typeof subject) {\n case 'number':\n this.length = coerce(subject);\n break;\n\n case 'string':\n this.length = Buffer.byteLength(subject, encoding);\n break;\n\n case 'object': // Assume object is an array\n this.length = coerce(subject.length);\n break;\n\n default:\n throw new Error('First argument needs to be a number, ' +\n 'array or string.');\n }\n\n if (this.length > Buffer.poolSize) {\n // Big buffer, just alloc one.\n this.parent = new SlowBuffer(this.length);\n this.offset = 0;\n\n } else {\n // Small buffer.\n if (!pool || pool.length - pool.used < this.length) allocPool();\n this.parent = pool;\n this.offset = pool.used;\n pool.used += this.length;\n }\n\n // Treat array-ish objects as a byte array.\n if (isArrayIsh(subject)) {\n for (var i = 0; i < this.length; i++) {\n this.parent[i + this.offset] = subject[i];\n }\n } else if (type == 'string') {\n // We are a string\n this.length = this.write(subject, 0, encoding);\n }\n }\n\n}\n\nfunction isArrayIsh(subject) {\n return Array.isArray(subject) || Buffer.isBuffer(subject) ||\n subject && typeof subject === 'object' &&\n typeof subject.length === 'number';\n}\n\nexports.SlowBuffer = SlowBuffer;\nexports.Buffer = Buffer;\n\nBuffer.poolSize = 8 * 1024;\nvar pool;\n\nfunction allocPool() {\n pool = new SlowBuffer(Buffer.poolSize);\n pool.used = 0;\n}\n\n\n// Static methods\nBuffer.isBuffer = function isBuffer(b) {\n return b instanceof Buffer || b instanceof SlowBuffer;\n};\n\nBuffer.concat = function (list, totalLength) {\n if (!Array.isArray(list)) {\n throw new Error(\"Usage: Buffer.concat(list, [totalLength])\\n \\\n list should be an Array.\");\n }\n\n if (list.length === 0) {\n return new Buffer(0);\n } else if (list.length === 1) {\n return list[0];\n }\n\n if (typeof totalLength !== 'number') {\n totalLength = 0;\n for (var i = 0; i < list.length; i++) {\n var buf = list[i];\n totalLength += buf.length;\n }\n }\n\n var buffer = new Buffer(totalLength);\n var pos = 0;\n for (var i = 0; i < list.length; i++) {\n var buf = list[i];\n buf.copy(buffer, pos);\n pos += buf.length;\n }\n return buffer;\n};\n\n// Inspect\nBuffer.prototype.inspect = function inspect() {\n var out = [],\n len = this.length;\n\n for (var i = 0; i < len; i++) {\n out[i] = toHex(this.parent[i + this.offset]);\n if (i == exports.INSPECT_MAX_BYTES) {\n out[i + 1] = '...';\n break;\n }\n }\n\n return '<Buffer ' + out.join(' ') + '>';\n};\n\n\nBuffer.prototype.get = function get(i) {\n if (i < 0 || i >= this.length) throw new Error('oob');\n return this.parent[this.offset + i];\n};\n\n\nBuffer.prototype.set = function set(i, v) {\n if (i < 0 || i >= this.length) throw new Error('oob');\n return this.parent[this.offset + i] = v;\n};\n\n\n// write(string, offset = 0, length = buffer.length-offset, encoding = 'utf8')\nBuffer.prototype.write = function(string, offset, length, encoding) {\n // Support both (string, offset, length, encoding)\n // and the legacy (string, encoding, offset, length)\n if (isFinite(offset)) {\n if (!isFinite(length)) {\n encoding = length;\n length = undefined;\n }\n } else { // legacy\n var swap = encoding;\n encoding = offset;\n offset = length;\n length = swap;\n }\n\n offset = +offset || 0;\n var remaining = this.length - offset;\n if (!length) {\n length = remaining;\n } else {\n length = +length;\n if (length > remaining) {\n length = remaining;\n }\n }\n encoding = String(encoding || 'utf8').toLowerCase();\n\n var ret;\n switch (encoding) {\n case 'hex':\n ret = this.parent.hexWrite(string, this.offset + offset, length);\n break;\n\n case 'utf8':\n case 'utf-8':\n ret = this.parent.utf8Write(string, this.offset + offset, length);\n break;\n\n case 'ascii':\n ret = this.parent.asciiWrite(string, this.offset + offset, length);\n break;\n\n case 'binary':\n ret = this.parent.binaryWrite(string, this.offset + offset, length);\n break;\n\n case 'base64':\n // Warning: maxLength not taken into account in base64Write\n ret = this.parent.base64Write(string, this.offset + offset, length);\n break;\n\n case 'ucs2':\n case 'ucs-2':\n ret = this.parent.ucs2Write(string, this.offset + offset, length);\n break;\n\n default:\n throw new Error('Unknown encoding');\n }\n\n Buffer._charsWritten = SlowBuffer._charsWritten;\n\n return ret;\n};\n\n\n// toString(encoding, start=0, end=buffer.length)\nBuffer.prototype.toString = function(encoding, start, end) {\n encoding = String(encoding || 'utf8').toLowerCase();\n\n if (typeof start == 'undefined' || start < 0) {\n start = 0;\n } else if (start > this.length) {\n start = this.length;\n }\n\n if (typeof end == 'undefined' || end > this.length) {\n end = this.length;\n } else if (end < 0) {\n end = 0;\n }\n\n start = start + this.offset;\n end = end + this.offset;\n\n switch (encoding) {\n case 'hex':\n return this.parent.hexSlice(start, end);\n\n case 'utf8':\n case 'utf-8':\n return this.parent.utf8Slice(start, end);\n\n case 'ascii':\n return this.parent.asciiSlice(start, end);\n\n case 'binary':\n return this.parent.binarySlice(start, end);\n\n case 'base64':\n return this.parent.base64Slice(start, end);\n\n case 'ucs2':\n case 'ucs-2':\n return this.parent.ucs2Slice(start, end);\n\n default:\n throw new Error('Unknown encoding');\n }\n};\n\n\n// byteLength\nBuffer.byteLength = SlowBuffer.byteLength;\n\n\n// fill(value, start=0, end=buffer.length)\nBuffer.prototype.fill = function fill(value, start, end) {\n value || (value = 0);\n start || (start = 0);\n end || (end = this.length);\n\n if (typeof value === 'string') {\n value = value.charCodeAt(0);\n }\n if (!(typeof value === 'number') || isNaN(value)) {\n throw new Error('value is not a number');\n }\n\n if (end < start) throw new Error('end < start');\n\n // Fill 0 bytes; we're done\n if (end === start) return 0;\n if (this.length == 0) return 0;\n\n if (start < 0 || start >= this.length) {\n throw new Error('start out of bounds');\n }\n\n if (end < 0 || end > this.length) {\n throw new Error('end out of bounds');\n }\n\n return this.parent.fill(value,\n start + this.offset,\n end + this.offset);\n};\n\n\n// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)\nBuffer.prototype.copy = function(target, target_start, start, end) {\n var source = this;\n start || (start = 0);\n end || (end = this.length);\n target_start || (target_start = 0);\n\n if (end < start) throw new Error('sourceEnd < sourceStart');\n\n // Copy 0 bytes; we're done\n if (end === start) return 0;\n if (target.length == 0 || source.length == 0) return 0;\n\n if (target_start < 0 || target_start >= target.length) {\n throw new Error('targetStart out of bounds');\n }\n\n if (start < 0 || start >= source.length) {\n throw new Error('sourceStart out of bounds');\n }\n\n if (end < 0 || end > source.length) {\n throw new Error('sourceEnd out of bounds');\n }\n\n // Are we oob?\n if (end > this.length) {\n end = this.length;\n }\n\n if (target.length - target_start < end - start) {\n end = target.length - target_start + start;\n }\n\n return this.parent.copy(target.parent,\n target_start + target.offset,\n start + this.offset,\n end + this.offset);\n};\n\n\n// slice(start, end)\nBuffer.prototype.slice = function(start, end) {\n if (end === undefined) end = this.length;\n if (end > this.length) throw new Error('oob');\n if (start > end) throw new Error('oob');\n\n return new Buffer(this.parent, end - start, +start + this.offset);\n};\n\n\n// Legacy methods for backwards compatibility.\n\nBuffer.prototype.utf8Slice = function(start, end) {\n return this.toString('utf8', start, end);\n};\n\nBuffer.prototype.binarySlice = function(start, end) {\n return this.toString('binary', start, end);\n};\n\nBuffer.prototype.asciiSlice = function(start, end) {\n return this.toString('ascii', start, end);\n};\n\nBuffer.prototype.utf8Write = function(string, offset) {\n return this.write(string, offset, 'utf8');\n};\n\nBuffer.prototype.binaryWrite = function(string, offset) {\n return this.write(string, offset, 'binary');\n};\n\nBuffer.prototype.asciiWrite = function(string, offset) {\n return this.write(string, offset, 'ascii');\n};\n\nBuffer.prototype.readUInt8 = function(offset, noAssert) {\n var buffer = this;\n\n if (!noAssert) {\n assert.ok(offset !== undefined && offset !== null,\n 'missing offset');\n\n assert.ok(offset < buffer.length,\n 'Trying to read beyond buffer length');\n }\n\n return buffer.parent[buffer.offset + offset];\n};\n\nfunction readUInt16(buffer, offset, isBigEndian, noAssert) {\n var val = 0;\n\n\n if (!noAssert) {\n assert.ok(typeof (isBigEndian) === 'boolean',\n 'missing or invalid endian');\n\n assert.ok(offset !== undefined && offset !== null,\n 'missing offset');\n\n assert.ok(offset + 1 < buffer.length,\n 'Trying to read beyond buffer length');\n }\n\n if (isBigEndian) {\n val = buffer.parent[buffer.offset + offset] << 8;\n val |= buffer.parent[buffer.offset + offset + 1];\n } else {\n val = buffer.parent[buffer.offset + offset];\n val |= buffer.parent[buffer.offset + offset + 1] << 8;\n }\n\n return val;\n}\n\nBuffer.prototype.readUInt16LE = function(offset, noAssert) {\n return readUInt16(this, offset, false, noAssert);\n};\n\nBuffer.prototype.readUInt16BE = function(offset, noAssert) {\n return readUInt16(this, offset, true, noAssert);\n};\n\nfunction readUInt32(buffer, offset, isBigEndian, noAssert) {\n var val = 0;\n\n if (!noAssert) {\n assert.ok(typeof (isBigEndian) === 'boolean',\n 'missing or invalid endian');\n\n assert.ok(offset !== undefined && offset !== null,\n 'missing offset');\n\n assert.ok(offset + 3 < buffer.length,\n 'Trying to read beyond buffer length');\n }\n\n if (isBigEndian) {\n val = buffer.parent[buffer.offset + offset + 1] << 16;\n val |= buffer.parent[buffer.offset + offset + 2] << 8;\n val |= buffer.parent[buffer.offset + offset + 3];\n val = val + (buffer.parent[buffer.offset + offset] << 24 >>> 0);\n } else {\n val = buffer.parent[buffer.offset + offset + 2] << 16;\n val |= buffer.parent[buffer.offset + offset + 1] << 8;\n val |= buffer.parent[buffer.offset + offset];\n val = val + (buffer.parent[buffer.offset + offset + 3] << 24 >>> 0);\n }\n\n return val;\n}\n\nBuffer.prototype.readUInt32LE = function(offset, noAssert) {\n return readUInt32(this, offset, false, noAssert);\n};\n\nBuffer.prototype.readUInt32BE = function(offset, noAssert) {\n return readUInt32(this, offset, true, noAssert);\n};\n\n\n/*\n * Signed integer types, yay team! A reminder on how two's complement actually\n * works. The first bit is the signed bit, i.e. tells us whether or not the\n * number should be positive or negative. If the two's complement value is\n * positive, then we're done, as it's equivalent to the unsigned representation.\n *\n * Now if the number is positive, you're pretty much done, you can just leverage\n * the unsigned translations and return those. Unfortunately, negative numbers\n * aren't quite that straightforward.\n *\n * At first glance, one might be inclined to use the traditional formula to\n * translate binary numbers between the positive and negative values in two's\n * complement. (Though it doesn't quite work for the most negative value)\n * Mainly:\n * - invert all the bits\n * - add one to the result\n *\n * Of course, this doesn't quite work in Javascript. Take for example the value\n * of -128. This could be represented in 16 bits (big-endian) as 0xff80. But of\n * course, Javascript will do the following:\n *\n * > ~0xff80\n * -65409\n *\n * Whoh there, Javascript, that's not quite right. But wait, according to\n * Javascript that's perfectly correct. When Javascript ends up seeing the\n * constant 0xff80, it has no notion that it is actually a signed number. It\n * assumes that we've input the unsigned value 0xff80. Thus, when it does the\n * binary negation, it casts it into a signed value, (positive 0xff80). Then\n * when you perform binary negation on that, it turns it into a negative number.\n *\n * Instead, we're going to have to use the following general formula, that works\n * in a rather Javascript friendly way. I'm glad we don't support this kind of\n * weird numbering scheme in the kernel.\n *\n * (BIT-MAX - (unsigned)val + 1) * -1\n *\n * The astute observer, may think that this doesn't make sense for 8-bit numbers\n * (really it isn't necessary for them). However, when you get 16-bit numbers,\n * you do. Let's go back to our prior example and see how this will look:\n *\n * (0xffff - 0xff80 + 1) * -1\n * (0x007f + 1) * -1\n * (0x0080) * -1\n */\nBuffer.prototype.readInt8 = function(offset, noAssert) {\n var buffer = this;\n var neg;\n\n if (!noAssert) {\n assert.ok(offset !== undefined && offset !== null,\n 'missing offset');\n\n assert.ok(offset < buffer.length,\n 'Trying to read beyond buffer length');\n }\n\n neg = buffer.parent[buffer.offset + offset] & 0x80;\n if (!neg) {\n return (buffer.parent[buffer.offset + offset]);\n }\n\n return ((0xff - buffer.parent[buffer.offset + offset] + 1) * -1);\n};\n\nfunction readInt16(buffer, offset, isBigEndian, noAssert) {\n var neg, val;\n\n if (!noAssert) {\n assert.ok(typeof (isBigEndian) === 'boolean',\n 'missing or invalid endian');\n\n assert.ok(offset !== undefined && offset !== null,\n 'missing offset');\n\n assert.ok(offset + 1 < buffer.length,\n 'Trying to read beyond buffer length');\n }\n\n val = readUInt16(buffer, offset, isBigEndian, noAssert);\n neg = val & 0x8000;\n if (!neg) {\n return val;\n }\n\n return (0xffff - val + 1) * -1;\n}\n\nBuffer.prototype.readInt16LE = function(offset, noAssert) {\n return readInt16(this, offset, false, noAssert);\n};\n\nBuffer.prototype.readInt16BE = function(offset, noAssert) {\n return readInt16(this, offset, true, noAssert);\n};\n\nfunction readInt32(buffer, offset, isBigEndian, noAssert) {\n var neg, val;\n\n if (!noAssert) {\n assert.ok(typeof (isBigEndian) === 'boolean',\n 'missing or invalid endian');\n\n assert.ok(offset !== undefined && offset !== null,\n 'missing offset');\n\n assert.ok(offset + 3 < buffer.length,\n 'Trying to read beyond buffer length');\n }\n\n val = readUInt32(buffer, offset, isBigEndian, noAssert);\n neg = val & 0x80000000;\n if (!neg) {\n return (val);\n }\n\n return (0xffffffff - val + 1) * -1;\n}\n\nBuffer.prototype.readInt32LE = function(offset, noAssert) {\n return readInt32(this, offset, false, noAssert);\n};\n\nBuffer.prototype.readInt32BE = function(offset, noAssert) {\n return readInt32(this, offset, true, noAssert);\n};\n\nfunction readFloat(buffer, offset, isBigEndian, noAssert) {\n if (!noAssert) {\n assert.ok(typeof (isBigEndian) === 'boolean',\n 'missing or invalid endian');\n\n assert.ok(offset + 3 < buffer.length,\n 'Trying to read beyond buffer length');\n }\n\n return require('./buffer_ieee754').readIEEE754(buffer, offset, isBigEndian,\n 23, 4);\n}\n\nBuffer.prototype.readFloatLE = function(offset, noAssert) {\n return readFloat(this, offset, false, noAssert);\n};\n\nBuffer.prototype.readFloatBE = function(offset, noAssert) {\n return readFloat(this, offset, true, noAssert);\n};\n\nfunction readDouble(buffer, offset, isBigEndian, noAssert) {\n if (!noAssert) {\n assert.ok(typeof (isBigEndian) === 'boolean',\n 'missing or invalid endian');\n\n assert.ok(offset + 7 < buffer.length,\n 'Trying to read beyond buffer length');\n }\n\n return require('./buffer_ieee754').readIEEE754(buffer, offset, isBigEndian,\n 52, 8);\n}\n\nBuffer.prototype.readDoubleLE = function(offset, noAssert) {\n return readDouble(this, offset, false, noAssert);\n};\n\nBuffer.prototype.readDoubleBE = function(offset, noAssert) {\n return readDouble(this, offset, true, noAssert);\n};\n\n\n/*\n * We have to make sure that the value is a valid integer. This means that it is\n * non-negative. It has no fractional component and that it does not exceed the\n * maximum allowed value.\n *\n * value The number to check for validity\n *\n * max The maximum value\n */\nfunction verifuint(value, max) {\n assert.ok(typeof (value) == 'number',\n 'cannot write a non-number as a number');\n\n assert.ok(value >= 0,\n 'specified a negative value for writing an unsigned value');\n\n assert.ok(value <= max, 'value is larger than maximum value for type');\n\n assert.ok(Math.floor(value) === value, 'value has a fractional component');\n}\n\nBuffer.prototype.writeUInt8 = function(value, offset, noAssert) {\n var buffer = this;\n\n if (!noAssert) {\n assert.ok(value !== undefined && value !== null,\n 'missing value');\n\n assert.ok(offset !== undefined && offset !== null,\n 'missing offset');\n\n assert.ok(offset < buffer.length,\n 'trying to write beyond buffer length');\n\n verifuint(value, 0xff);\n }\n\n buffer.parent[buffer.offset + offset] = value;\n};\n\nfunction writeUInt16(buffer, value, offset, isBigEndian, noAssert) {\n if (!noAssert) {\n assert.ok(value !== undefined && value !== null,\n 'missing value');\n\n assert.ok(typeof (isBigEndian) === 'boolean',\n 'missing or invalid endian');\n\n assert.ok(offset !== undefined && offset !== null,\n 'missing offset');\n\n assert.ok(offset + 1 < buffer.length,\n 'trying to write beyond buffer length');\n\n verifuint(value, 0xffff);\n }\n\n if (isBigEndian) {\n buffer.parent[buffer.offset + offset] = (value & 0xff00) >>> 8;\n buffer.parent[buffer.offset + offset + 1] = value & 0x00ff;\n } else {\n buffer.parent[buffer.offset + offset + 1] = (value & 0xff00) >>> 8;\n buffer.parent[buffer.offset + offset] = value & 0x00ff;\n }\n}\n\nBuffer.prototype.writeUInt16LE = function(value, offset, noAssert) {\n writeUInt16(this, value, offset, false, noAssert);\n};\n\nBuffer.prototype.writeUInt16BE = function(value, offset, noAssert) {\n writeUInt16(this, value, offset, true, noAssert);\n};\n\nfunction writeUInt32(buffer, value, offset, isBigEndian, noAssert) {\n if (!noAssert) {\n assert.ok(value !== undefined && value !== null,\n 'missing value');\n\n assert.ok(typeof (isBigEndian) === 'boolean',\n 'missing or invalid endian');\n\n assert.ok(offset !== undefined && offset !== null,\n 'missing offset');\n\n assert.ok(offset + 3 < buffer.length,\n 'trying to write beyond buffer length');\n\n verifuint(value, 0xffffffff);\n }\n\n if (isBigEndian) {\n buffer.parent[buffer.offset + offset] = (value >>> 24) & 0xff;\n buffer.parent[buffer.offset + offset + 1] = (value >>> 16) & 0xff;\n buffer.parent[buffer.offset + offset + 2] = (value >>> 8) & 0xff;\n buffer.parent[buffer.offset + offset + 3] = value & 0xff;\n } else {\n buffer.parent[buffer.offset + offset + 3] = (value >>> 24) & 0xff;\n buffer.parent[buffer.offset + offset + 2] = (value >>> 16) & 0xff;\n buffer.parent[buffer.offset + offset + 1] = (value >>> 8) & 0xff;\n buffer.parent[buffer.offset + offset] = value & 0xff;\n }\n}\n\nBuffer.prototype.writeUInt32LE = function(value, offset, noAssert) {\n writeUInt32(this, value, offset, false, noAssert);\n};\n\nBuffer.prototype.writeUInt32BE = function(value, offset, noAssert) {\n writeUInt32(this, value, offset, true, noAssert);\n};\n\n\n/*\n * We now move onto our friends in the signed number category. Unlike unsigned\n * numbers, we're going to have to worry a bit more about how we put values into\n * arrays. Since we are only worrying about signed 32-bit values, we're in\n * slightly better shape. Unfortunately, we really can't do our favorite binary\n * & in this system. It really seems to do the wrong thing. For example:\n *\n * > -32 & 0xff\n * 224\n *\n * What's happening above is really: 0xe0 & 0xff = 0xe0. However, the results of\n * this aren't treated as a signed number. Ultimately a bad thing.\n *\n * What we're going to want to do is basically create the unsigned equivalent of\n * our representation and pass that off to the wuint* functions. To do that\n * we're going to do the following:\n *\n * - if the value is positive\n * we can pass it directly off to the equivalent wuint\n * - if the value is negative\n * we do the following computation:\n * mb + val + 1, where\n * mb is the maximum unsigned value in that byte size\n * val is the Javascript negative integer\n *\n *\n * As a concrete value, take -128. In signed 16 bits this would be 0xff80. If\n * you do out the computations:\n *\n * 0xffff - 128 + 1\n * 0xffff - 127\n * 0xff80\n *\n * You can then encode this value as the signed version. This is really rather\n * hacky, but it should work and get the job done which is our goal here.\n */\n\n/*\n * A series of checks to make sure we actually have a signed 32-bit number\n */\nfunction verifsint(value, max, min) {\n assert.ok(typeof (value) == 'number',\n 'cannot write a non-number as a number');\n\n assert.ok(value <= max, 'value larger than maximum allowed value');\n\n assert.ok(value >= min, 'value smaller than minimum allowed value');\n\n assert.ok(Math.floor(value) === value, 'value has a fractional component');\n}\n\nfunction verifIEEE754(value, max, min) {\n assert.ok(typeof (value) == 'number',\n 'cannot write a non-number as a number');\n\n assert.ok(value <= max, 'value larger than maximum allowed value');\n\n assert.ok(value >= min, 'value smaller than minimum allowed value');\n}\n\nBuffer.prototype.writeInt8 = function(value, offset, noAssert) {\n var buffer = this;\n\n if (!noAssert) {\n assert.ok(value !== undefined && value !== null,\n 'missing value');\n\n assert.ok(offset !== undefined && offset !== null,\n 'missing offset');\n\n assert.ok(offset < buffer.length,\n 'Trying to write beyond buffer length');\n\n verifsint(value, 0x7f, -0x80);\n }\n\n if (value >= 0) {\n buffer.writeUInt8(value, offset, noAssert);\n } else {\n buffer.writeUInt8(0xff + value + 1, offset, noAssert);\n }\n};\n\nfunction writeInt16(buffer, value, offset, isBigEndian, noAssert) {\n if (!noAssert) {\n assert.ok(value !== undefined && value !== null,\n 'missing value');\n\n assert.ok(typeof (isBigEndian) === 'boolean',\n 'missing or invalid endian');\n\n assert.ok(offset !== undefined && offset !== null,\n 'missing offset');\n\n assert.ok(offset + 1 < buffer.length,\n 'Trying to write beyond buffer length');\n\n verifsint(value, 0x7fff, -0x8000);\n }\n\n if (value >= 0) {\n writeUInt16(buffer, value, offset, isBigEndian, noAssert);\n } else {\n writeUInt16(buffer, 0xffff + value + 1, offset, isBigEndian, noAssert);\n }\n}\n\nBuffer.prototype.writeInt16LE = function(value, offset, noAssert) {\n writeInt16(this, value, offset, false, noAssert);\n};\n\nBuffer.prototype.writeInt16BE = function(value, offset, noAssert) {\n writeInt16(this, value, offset, true, noAssert);\n};\n\nfunction writeInt32(buffer, value, offset, isBigEndian, noAssert) {\n if (!noAssert) {\n assert.ok(value !== undefined && value !== null,\n 'missing value');\n\n assert.ok(typeof (isBigEndian) === 'boolean',\n 'missing or invalid endian');\n\n assert.ok(offset !== undefined && offset !== null,\n 'missing offset');\n\n assert.ok(offset + 3 < buffer.length,\n 'Trying to write beyond buffer length');\n\n verifsint(value, 0x7fffffff, -0x80000000);\n }\n\n if (value >= 0) {\n writeUInt32(buffer, value, offset, isBigEndian, noAssert);\n } else {\n writeUInt32(buffer, 0xffffffff + value + 1, offset, isBigEndian, noAssert);\n }\n}\n\nBuffer.prototype.writeInt32LE = function(value, offset, noAssert) {\n writeInt32(this, value, offset, false, noAssert);\n};\n\nBuffer.prototype.writeInt32BE = function(value, offset, noAssert) {\n writeInt32(this, value, offset, true, noAssert);\n};\n\nfunction writeFloat(buffer, value, offset, isBigEndian, noAssert) {\n if (!noAssert) {\n assert.ok(value !== undefined && value !== null,\n 'missing value');\n\n assert.ok(typeof (isBigEndian) === 'boolean',\n 'missing or invalid endian');\n\n assert.ok(offset !== undefined && offset !== null,\n 'missing offset');\n\n assert.ok(offset + 3 < buffer.length,\n 'Trying to write beyond buffer length');\n\n verifIEEE754(value, 3.4028234663852886e+38, -3.4028234663852886e+38);\n }\n\n require('./buffer_ieee754').writeIEEE754(buffer, value, offset, isBigEndian,\n 23, 4);\n}\n\nBuffer.prototype.writeFloatLE = function(value, offset, noAssert) {\n writeFloat(this, value, offset, false, noAssert);\n};\n\nBuffer.prototype.writeFloatBE = function(value, offset, noAssert) {\n writeFloat(this, value, offset, true, noAssert);\n};\n\nfunction writeDouble(buffer, value, offset, isBigEndian, noAssert) {\n if (!noAssert) {\n assert.ok(value !== undefined && value !== null,\n 'missing value');\n\n assert.ok(typeof (isBigEndian) === 'boolean',\n 'missing or invalid endian');\n\n assert.ok(offset !== undefined && offset !== null,\n 'missing offset');\n\n assert.ok(offset + 7 < buffer.length,\n 'Trying to write beyond buffer length');\n\n verifIEEE754(value, 1.7976931348623157E+308, -1.7976931348623157E+308);\n }\n\n require('./buffer_ieee754').writeIEEE754(buffer, value, offset, isBigEndian,\n 52, 8);\n}\n\nBuffer.prototype.writeDoubleLE = function(value, offset, noAssert) {\n writeDouble(this, value, offset, false, noAssert);\n};\n\nBuffer.prototype.writeDoubleBE = function(value, offset, noAssert) {\n writeDouble(this, value, offset, true, noAssert);\n};\n\nSlowBuffer.prototype.readUInt8 = Buffer.prototype.readUInt8;\nSlowBuffer.prototype.readUInt16LE = Buffer.prototype.readUInt16LE;\nSlowBuffer.prototype.readUInt16BE = Buffer.prototype.readUInt16BE;\nSlowBuffer.prototype.readUInt32LE = Buffer.prototype.readUInt32LE;\nSlowBuffer.prototype.readUInt32BE = Buffer.prototype.readUInt32BE;\nSlowBuffer.prototype.readInt8 = Buffer.prototype.readInt8;\nSlowBuffer.prototype.readInt16LE = Buffer.prototype.readInt16LE;\nSlowBuffer.prototype.readInt16BE = Buffer.prototype.readInt16BE;\nSlowBuffer.prototype.readInt32LE = Buffer.prototype.readInt32LE;\nSlowBuffer.prototype.readInt32BE = Buffer.prototype.readInt32BE;\nSlowBuffer.prototype.readFloatLE = Buffer.prototype.readFloatLE;\nSlowBuffer.prototype.readFloatBE = Buffer.prototype.readFloatBE;\nSlowBuffer.prototype.readDoubleLE = Buffer.prototype.readDoubleLE;\nSlowBuffer.prototype.readDoubleBE = Buffer.prototype.readDoubleBE;\nSlowBuffer.prototype.writeUInt8 = Buffer.prototype.writeUInt8;\nSlowBuffer.prototype.writeUInt16LE = Buffer.prototype.writeUInt16LE;\nSlowBuffer.prototype.writeUInt16BE = Buffer.prototype.writeUInt16BE;\nSlowBuffer.prototype.writeUInt32LE = Buffer.prototype.writeUInt32LE;\nSlowBuffer.prototype.writeUInt32BE = Buffer.prototype.writeUInt32BE;\nSlowBuffer.prototype.writeInt8 = Buffer.prototype.writeInt8;\nSlowBuffer.prototype.writeInt16LE = Buffer.prototype.writeInt16LE;\nSlowBuffer.prototype.writeInt16BE = Buffer.prototype.writeInt16BE;\nSlowBuffer.prototype.writeInt32LE = Buffer.prototype.writeInt32LE;\nSlowBuffer.prototype.writeInt32BE = Buffer.prototype.writeInt32BE;\nSlowBuffer.prototype.writeFloatLE = Buffer.prototype.writeFloatLE;\nSlowBuffer.prototype.writeFloatBE = Buffer.prototype.writeFloatBE;\nSlowBuffer.prototype.writeDoubleLE = Buffer.prototype.writeDoubleLE;\nSlowBuffer.prototype.writeDoubleBE = Buffer.prototype.writeDoubleBE;\n\n//@ sourceURL=/AppData/Roaming/npm/node_modules/browserify-server/node_modules/browserify/node_modules/buffer-browserify/index.js" | |
)); | |
require.define("/AppData/Roaming/npm/node_modules/browserify-server/node_modules/browserify/node_modules/buffer-browserify/node_modules/base64-js/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {\"main\":\"lib/b64.js\"}\n//@ sourceURL=/AppData/Roaming/npm/node_modules/browserify-server/node_modules/browserify/node_modules/buffer-browserify/node_modules/base64-js/package.json" | |
)); | |
require.define("/AppData/Roaming/npm/node_modules/browserify-server/node_modules/browserify/node_modules/buffer-browserify/node_modules/base64-js/lib/b64.js",Function(['require','module','exports','__dirname','__filename','process','global'],"(function (exports) {\n\t'use strict';\n\n\tvar lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\n\n\tfunction b64ToByteArray(b64) {\n\t\tvar i, j, l, tmp, placeHolders, arr;\n\t\n\t\tif (b64.length % 4 > 0) {\n\t\t\tthrow 'Invalid string. Length must be a multiple of 4';\n\t\t}\n\n\t\t// the number of equal signs (place holders)\n\t\t// if there are two placeholders, than the two characters before it\n\t\t// represent one byte\n\t\t// if there is only one, then the three characters before it represent 2 bytes\n\t\t// this is just a cheap hack to not do indexOf twice\n\t\tplaceHolders = b64.indexOf('=');\n\t\tplaceHolders = placeHolders > 0 ? b64.length - placeHolders : 0;\n\n\t\t// base64 is 4/3 + up to two characters of the original data\n\t\tarr = [];//new Uint8Array(b64.length * 3 / 4 - placeHolders);\n\n\t\t// if there are placeholders, only get up to the last complete 4 chars\n\t\tl = placeHolders > 0 ? b64.length - 4 : b64.length;\n\n\t\tfor (i = 0, j = 0; i < l; i += 4, j += 3) {\n\t\t\ttmp = (lookup.indexOf(b64[i]) << 18) | (lookup.indexOf(b64[i + 1]) << 12) | (lookup.indexOf(b64[i + 2]) << 6) | lookup.indexOf(b64[i + 3]);\n\t\t\tarr.push((tmp & 0xFF0000) >> 16);\n\t\t\tarr.push((tmp & 0xFF00) >> 8);\n\t\t\tarr.push(tmp & 0xFF);\n\t\t}\n\n\t\tif (placeHolders === 2) {\n\t\t\ttmp = (lookup.indexOf(b64[i]) << 2) | (lookup.indexOf(b64[i + 1]) >> 4);\n\t\t\tarr.push(tmp & 0xFF);\n\t\t} else if (placeHolders === 1) {\n\t\t\ttmp = (lookup.indexOf(b64[i]) << 10) | (lookup.indexOf(b64[i + 1]) << 4) | (lookup.indexOf(b64[i + 2]) >> 2);\n\t\t\tarr.push((tmp >> 8) & 0xFF);\n\t\t\tarr.push(tmp & 0xFF);\n\t\t}\n\n\t\treturn arr;\n\t}\n\n\tfunction uint8ToBase64(uint8) {\n\t\tvar i,\n\t\t\textraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes\n\t\t\toutput = \"\",\n\t\t\ttemp, length;\n\n\t\tfunction tripletToBase64 (num) {\n\t\t\treturn lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F];\n\t\t};\n\n\t\t// go through the array every three bytes, we'll deal with trailing stuff later\n\t\tfor (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {\n\t\t\ttemp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]);\n\t\t\toutput += tripletToBase64(temp);\n\t\t}\n\n\t\t// pad the end with zeros, but make sure to not forget the extra bytes\n\t\tswitch (extraBytes) {\n\t\t\tcase 1:\n\t\t\t\ttemp = uint8[uint8.length - 1];\n\t\t\t\toutput += lookup[temp >> 2];\n\t\t\t\toutput += lookup[(temp << 4) & 0x3F];\n\t\t\t\toutput += '==';\n\t\t\t\tbreak;\n\t\t\tcase 2:\n\t\t\t\ttemp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1]);\n\t\t\t\toutput += lookup[temp >> 10];\n\t\t\t\toutput += lookup[(temp >> 4) & 0x3F];\n\t\t\t\toutput += lookup[(temp << 2) & 0x3F];\n\t\t\t\toutput += '=';\n\t\t\t\tbreak;\n\t\t}\n\n\t\treturn output;\n\t}\n\n\tmodule.exports.toByteArray = b64ToByteArray;\n\tmodule.exports.fromByteArray = uint8ToBase64;\n}());\n\n//@ sourceURL=/AppData/Roaming/npm/node_modules/browserify-server/node_modules/browserify/node_modules/buffer-browserify/node_modules/base64-js/lib/b64.js" | |
)); | |
require.define("/AppData/Roaming/npm/node_modules/browserify-server/node_modules/browserify/node_modules/buffer-browserify/buffer_ieee754.js",Function(['require','module','exports','__dirname','__filename','process','global'],"exports.readIEEE754 = function(buffer, offset, isBE, mLen, nBytes) {\n var e, m,\n eLen = nBytes * 8 - mLen - 1,\n eMax = (1 << eLen) - 1,\n eBias = eMax >> 1,\n nBits = -7,\n i = isBE ? 0 : (nBytes - 1),\n d = isBE ? 1 : -1,\n s = buffer[offset + i];\n\n i += d;\n\n e = s & ((1 << (-nBits)) - 1);\n s >>= (-nBits);\n nBits += eLen;\n for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8);\n\n m = e & ((1 << (-nBits)) - 1);\n e >>= (-nBits);\n nBits += mLen;\n for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8);\n\n if (e === 0) {\n e = 1 - eBias;\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity);\n } else {\n m = m + Math.pow(2, mLen);\n e = e - eBias;\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen);\n};\n\nexports.writeIEEE754 = function(buffer, value, offset, isBE, mLen, nBytes) {\n var e, m, c,\n eLen = nBytes * 8 - mLen - 1,\n eMax = (1 << eLen) - 1,\n eBias = eMax >> 1,\n rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0),\n i = isBE ? (nBytes - 1) : 0,\n d = isBE ? -1 : 1,\n s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;\n\n value = Math.abs(value);\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0;\n e = eMax;\n } else {\n e = Math.floor(Math.log(value) / Math.LN2);\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--;\n c *= 2;\n }\n if (e + eBias >= 1) {\n value += rt / c;\n } else {\n value += rt * Math.pow(2, 1 - eBias);\n }\n if (value * c >= 2) {\n e++;\n c /= 2;\n }\n\n if (e + eBias >= eMax) {\n m = 0;\n e = eMax;\n } else if (e + eBias >= 1) {\n m = (value * c - 1) * Math.pow(2, mLen);\n e = e + eBias;\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);\n e = 0;\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8);\n\n e = (e << mLen) | m;\n eLen += mLen;\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8);\n\n buffer[offset + i - d] |= s * 128;\n};\n\n//@ sourceURL=/AppData/Roaming/npm/node_modules/browserify-server/node_modules/browserify/node_modules/buffer-browserify/buffer_ieee754.js" | |
)); | |
require.define("string_decoder",Function(['require','module','exports','__dirname','__filename','process','global'],"var StringDecoder = exports.StringDecoder = function(encoding) {\n this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, '');\n switch (this.encoding) {\n case 'utf8':\n // CESU-8 represents each of Surrogate Pair by 3-bytes\n this.surrogateSize = 3;\n break;\n case 'ucs2':\n case 'utf16le':\n // UTF-16 represents each of Surrogate Pair by 2-bytes\n this.surrogateSize = 2;\n this.detectIncompleteChar = utf16DetectIncompleteChar;\n break;\n case 'base64':\n // Base-64 stores 3 bytes in 4 chars, and pads the remainder.\n this.surrogateSize = 3;\n this.detectIncompleteChar = base64DetectIncompleteChar;\n break;\n default:\n this.write = passThroughWrite;\n return;\n }\n\n this.charBuffer = new Buffer(6);\n this.charReceived = 0;\n this.charLength = 0;\n};\n\n\nStringDecoder.prototype.write = function(buffer) {\n var charStr = '';\n var offset = 0;\n\n // if our last write ended with an incomplete multibyte character\n while (this.charLength) {\n // determine how many remaining bytes this buffer has to offer for this char\n var i = (buffer.length >= this.charLength - this.charReceived) ?\n this.charLength - this.charReceived :\n buffer.length;\n\n // add the new bytes to the char buffer\n buffer.copy(this.charBuffer, this.charReceived, offset, i);\n this.charReceived += (i - offset);\n offset = i;\n\n if (this.charReceived < this.charLength) {\n // still not enough chars in this buffer? wait for more ...\n return '';\n }\n\n // get the character that was split\n charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding);\n\n // lead surrogate (D800-DBFF) is also the incomplete character\n var charCode = charStr.charCodeAt(charStr.length - 1);\n if (charCode >= 0xD800 && charCode <= 0xDBFF) {\n this.charLength += this.surrogateSize;\n charStr = '';\n continue;\n }\n this.charReceived = this.charLength = 0;\n\n // if there are no more bytes in this buffer, just emit our char\n if (i == buffer.length) return charStr;\n\n // otherwise cut off the characters end from the beginning of this buffer\n buffer = buffer.slice(i, buffer.length);\n break;\n }\n\n var lenIncomplete = this.detectIncompleteChar(buffer);\n\n var end = buffer.length;\n if (this.charLength) {\n // buffer the incomplete character bytes we got\n buffer.copy(this.charBuffer, 0, buffer.length - lenIncomplete, end);\n this.charReceived = lenIncomplete;\n end -= lenIncomplete;\n }\n\n charStr += buffer.toString(this.encoding, 0, end);\n\n var end = charStr.length - 1;\n var charCode = charStr.charCodeAt(end);\n // lead surrogate (D800-DBFF) is also the incomplete character\n if (charCode >= 0xD800 && charCode <= 0xDBFF) {\n var size = this.surrogateSize;\n this.charLength += size;\n this.charReceived += size;\n this.charBuffer.copy(this.charBuffer, size, 0, size);\n this.charBuffer.write(charStr.charAt(charStr.length - 1), this.encoding);\n return charStr.substring(0, end);\n }\n\n // or just emit the charStr\n return charStr;\n};\n\nStringDecoder.prototype.detectIncompleteChar = function(buffer) {\n // determine how many bytes we have to check at the end of this buffer\n var i = (buffer.length >= 3) ? 3 : buffer.length;\n\n // Figure out if one of the last i bytes of our buffer announces an\n // incomplete char.\n for (; i > 0; i--) {\n var c = buffer[buffer.length - i];\n\n // See http://en.wikipedia.org/wiki/UTF-8#Description\n\n // 110XXXXX\n if (i == 1 && c >> 5 == 0x06) {\n this.charLength = 2;\n break;\n }\n\n // 1110XXXX\n if (i <= 2 && c >> 4 == 0x0E) {\n this.charLength = 3;\n break;\n }\n\n // 11110XXX\n if (i <= 3 && c >> 3 == 0x1E) {\n this.charLength = 4;\n break;\n }\n }\n\n return i;\n};\n\nStringDecoder.prototype.end = function(buffer) {\n var res = '';\n if (buffer && buffer.length)\n res = this.write(buffer);\n\n if (this.charReceived) {\n var cr = this.charReceived;\n var buf = this.charBuffer;\n var enc = this.encoding;\n res += buf.slice(0, cr).toString(enc);\n }\n\n return res;\n};\n\nfunction passThroughWrite(buffer) {\n return buffer.toString(this.encoding);\n}\n\nfunction utf16DetectIncompleteChar(buffer) {\n var incomplete = this.charReceived = buffer.length % 2;\n this.charLength = incomplete ? 2 : 0;\n return incomplete;\n}\n\nfunction base64DetectIncompleteChar(buffer) {\n var incomplete = this.charReceived = buffer.length % 3;\n this.charLength = incomplete ? 3 : 0;\n return incomplete;\n}\n\n//@ sourceURL=string_decoder" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/scuttlebutt/node_modules/monotonic-timestamp/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/scuttlebutt/node_modules/monotonic-timestamp/package.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/scuttlebutt/node_modules/monotonic-timestamp/index.js",Function(['require','module','exports','__dirname','__filename','process','global'],"var _last = 0\nvar _count = 1\nvar LAST\n\nmodule.exports = \nfunction () {\n var t = Date.now()\n var _t = t\n if(_last == t) {\n _t += ((_count++)/1000) \n } \n else _count = 1 \n\n _last = t\n\n if(_t === LAST)\n throw new Error('LAST:' + LAST + ',' + _t)\n LAST = _t\n return _t\n}\n\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/scuttlebutt/node_modules/monotonic-timestamp/index.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/reconnect/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {\"browserify\":\"./shoe\"}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/reconnect/package.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/reconnect/shoe.js",Function(['require','module','exports','__dirname','__filename','process','global'],"\nvar shoe = require('shoe')\n\nmodule.exports = require('./inject')(function (){ \n var args = [].slice.call(arguments)\n return shoe.apply(null, args)\n})\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/reconnect/shoe.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/shoe/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {\"main\":\"index.js\",\"browserify\":\"browser.js\"}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/shoe/package.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/shoe/browser.js",Function(['require','module','exports','__dirname','__filename','process','global'],"var Stream = require('stream');\nvar sockjs = require('sockjs-client');\n\nmodule.exports = function (uri, cb) {\n if (/^\\/\\/[^\\/]+\\//.test(uri)) {\n uri = window.location.protocol + uri;\n }\n else if (!/^https?:\\/\\//.test(uri)) {\n uri = window.location.protocol + '//'\n + window.location.host\n + (/^\\//.test(uri) ? uri : '/' + uri)\n ;\n }\n \n var stream = new Stream;\n stream.readable = true;\n stream.writable = true;\n \n var ready = false;\n var buffer = [];\n \n var sock = sockjs(uri);\n stream.sock = sock;\n \n stream.write = function (msg) {\n if (!ready || buffer.length) buffer.push(msg)\n else sock.send(msg)\n };\n stream.end = function (msg) {\n if (msg !== undefined) stream.write(msg);\n if (!ready) {\n stream._ended = true;\n return;\n }\n stream.writable = false;\n sock.close();\n };\n\n stream.destroy = function () {\n stream._ended = true;\n stream.writable = stream.readable = false;\n buffer.length = 0\n sock.close();\n }\n \n sock.onopen = function () {\n if (typeof cb === 'function') cb();\n ready = true;\n buffer.forEach(function (msg) {\n sock.send(msg);\n });\n buffer = [];\n stream.emit('connect')\n if (stream._ended) stream.end();\n };\n sock.onmessage = function (e) {\n stream.emit('data', e.data);\n };\n sock.onclose = function () {\n stream.emit('end');\n stream.writable = false;\n stream.readable = false;\n };\n \n return stream;\n};\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/shoe/browser.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/shoe/node_modules/sockjs-client/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {\"main\":\"sockjs.js\"}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/shoe/node_modules/sockjs-client/package.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/shoe/node_modules/sockjs-client/sockjs.js",Function(['require','module','exports','__dirname','__filename','process','global'],"/* SockJS client, version 0.3.1.7.ga67f.dirty, http://sockjs.org, MIT License\n\nCopyright (c) 2011-2012 VMware, Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n*/\n\n// JSON2 by Douglas Crockford (minified).\nvar JSON;JSON||(JSON={}),function(){function str(a,b){var c,d,e,f,g=gap,h,i=b[a];i&&typeof i==\"object\"&&typeof i.toJSON==\"function\"&&(i=i.toJSON(a)),typeof rep==\"function\"&&(i=rep.call(b,a,i));switch(typeof i){case\"string\":return quote(i);case\"number\":return isFinite(i)?String(i):\"null\";case\"boolean\":case\"null\":return String(i);case\"object\":if(!i)return\"null\";gap+=indent,h=[];if(Object.prototype.toString.apply(i)===\"[object Array]\"){f=i.length;for(c=0;c<f;c+=1)h[c]=str(c,i)||\"null\";e=h.length===0?\"[]\":gap?\"[\\n\"+gap+h.join(\",\\n\"+gap)+\"\\n\"+g+\"]\":\"[\"+h.join(\",\")+\"]\",gap=g;return e}if(rep&&typeof rep==\"object\"){f=rep.length;for(c=0;c<f;c+=1)typeof rep[c]==\"string\"&&(d=rep[c],e=str(d,i),e&&h.push(quote(d)+(gap?\": \":\":\")+e))}else for(d in i)Object.prototype.hasOwnProperty.call(i,d)&&(e=str(d,i),e&&h.push(quote(d)+(gap?\": \":\":\")+e));e=h.length===0?\"{}\":gap?\"{\\n\"+gap+h.join(\",\\n\"+gap)+\"\\n\"+g+\"}\":\"{\"+h.join(\",\")+\"}\",gap=g;return e}}function quote(a){escapable.lastIndex=0;return escapable.test(a)?'\"'+a.replace(escapable,function(a){var b=meta[a];return typeof b==\"string\"?b:\"\\\\u\"+(\"0000\"+a.charCodeAt(0).toString(16)).slice(-4)})+'\"':'\"'+a+'\"'}function f(a){return a<10?\"0\"+a:a}\"use strict\",typeof Date.prototype.toJSON!=\"function\"&&(Date.prototype.toJSON=function(a){return isFinite(this.valueOf())?this.getUTCFullYear()+\"-\"+f(this.getUTCMonth()+1)+\"-\"+f(this.getUTCDate())+\"T\"+f(this.getUTCHours())+\":\"+f(this.getUTCMinutes())+\":\"+f(this.getUTCSeconds())+\"Z\":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(a){return this.valueOf()});var cx=/[\\u0000\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,escapable=/[\\\\\\\"\\x00-\\x1f\\x7f-\\x9f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,gap,indent,meta={\"\\b\":\"\\\\b\",\"\\t\":\"\\\\t\",\"\\n\":\"\\\\n\",\"\\f\":\"\\\\f\",\"\\r\":\"\\\\r\",'\"':'\\\\\"',\"\\\\\":\"\\\\\\\\\"},rep;typeof JSON.stringify!=\"function\"&&(JSON.stringify=function(a,b,c){var d;gap=\"\",indent=\"\";if(typeof c==\"number\")for(d=0;d<c;d+=1)indent+=\" \";else typeof c==\"string\"&&(indent=c);rep=b;if(!b||typeof b==\"function\"||typeof b==\"object\"&&typeof b.length==\"number\")return str(\"\",{\"\":a});throw new Error(\"JSON.stringify\")}),typeof JSON.parse!=\"function\"&&(JSON.parse=function(text,reviver){function walk(a,b){var c,d,e=a[b];if(e&&typeof e==\"object\")for(c in e)Object.prototype.hasOwnProperty.call(e,c)&&(d=walk(e,c),d!==undefined?e[c]=d:delete e[c]);return reviver.call(a,b,e)}var j;text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(a){return\"\\\\u\"+(\"0000\"+a.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\\],:{}\\s]*$/.test(text.replace(/\\\\(?:[\"\\\\\\/bfnrt]|u[0-9a-fA-F]{4})/g,\"@\").replace(/\"[^\"\\\\\\n\\r]*\"|true|false|null|-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?/g,\"]\").replace(/(?:^|:|,)(?:\\s*\\[)+/g,\"\"))){j=eval(\"(\"+text+\")\");return typeof reviver==\"function\"?walk({\"\":j},\"\"):j}throw new SyntaxError(\"JSON.parse\")})}()\n\n\n// [*] Including lib/index.js\n// Public object\nvar SockJS = (function(){\n var _document = document;\n var _window = window;\n var utils = {};\n\n\n// [*] Including lib/reventtarget.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\n/* Simplified implementation of DOM2 EventTarget.\n * http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-EventTarget\n */\nvar REventTarget = function() {};\nREventTarget.prototype.addEventListener = function (eventType, listener) {\n if(!this._listeners) {\n this._listeners = {};\n }\n if(!(eventType in this._listeners)) {\n this._listeners[eventType] = [];\n }\n var arr = this._listeners[eventType];\n if(utils.arrIndexOf(arr, listener) === -1) {\n arr.push(listener);\n }\n return;\n};\n\nREventTarget.prototype.removeEventListener = function (eventType, listener) {\n if(!(this._listeners && (eventType in this._listeners))) {\n return;\n }\n var arr = this._listeners[eventType];\n var idx = utils.arrIndexOf(arr, listener);\n if (idx !== -1) {\n if(arr.length > 1) {\n this._listeners[eventType] = arr.slice(0, idx).concat( arr.slice(idx+1) );\n } else {\n delete this._listeners[eventType];\n }\n return;\n }\n return;\n};\n\nREventTarget.prototype.dispatchEvent = function (event) {\n var t = event.type;\n var args = Array.prototype.slice.call(arguments, 0);\n if (this['on'+t]) {\n this['on'+t].apply(this, args);\n }\n if (this._listeners && t in this._listeners) {\n for(var i=0; i < this._listeners[t].length; i++) {\n this._listeners[t][i].apply(this, args);\n }\n }\n};\n// [*] End of lib/reventtarget.js\n\n\n// [*] Including lib/simpleevent.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\nvar SimpleEvent = function(type, obj) {\n this.type = type;\n if (typeof obj !== 'undefined') {\n for(var k in obj) {\n if (!obj.hasOwnProperty(k)) continue;\n this[k] = obj[k];\n }\n }\n};\n\nSimpleEvent.prototype.toString = function() {\n var r = [];\n for(var k in this) {\n if (!this.hasOwnProperty(k)) continue;\n var v = this[k];\n if (typeof v === 'function') v = '[function]';\n r.push(k + '=' + v);\n }\n return 'SimpleEvent(' + r.join(', ') + ')';\n};\n// [*] End of lib/simpleevent.js\n\n\n// [*] Including lib/eventemitter.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\nvar EventEmitter = function(events) {\n this.events = events || [];\n};\nEventEmitter.prototype.emit = function(type) {\n var that = this;\n var args = Array.prototype.slice.call(arguments, 1);\n if (!that.nuked && that['on'+type]) {\n that['on'+type].apply(that, args);\n }\n if (utils.arrIndexOf(that.events, type) === -1) {\n utils.log('Event ' + JSON.stringify(type) +\n ' not listed ' + JSON.stringify(that.events) +\n ' in ' + that);\n }\n};\n\nEventEmitter.prototype.nuke = function(type) {\n var that = this;\n that.nuked = true;\n for(var i=0; i<that.events.length; i++) {\n delete that[that.events[i]];\n }\n};\n// [*] End of lib/eventemitter.js\n\n\n// [*] Including lib/utils.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\nvar random_string_chars = 'abcdefghijklmnopqrstuvwxyz0123456789_';\nutils.random_string = function(length, max) {\n max = max || random_string_chars.length;\n var i, ret = [];\n for(i=0; i < length; i++) {\n ret.push( random_string_chars.substr(Math.floor(Math.random() * max),1) );\n }\n return ret.join('');\n};\nutils.random_number = function(max) {\n return Math.floor(Math.random() * max);\n};\nutils.random_number_string = function(max) {\n var t = (''+(max - 1)).length;\n var p = Array(t+1).join('0');\n return (p + utils.random_number(max)).slice(-t);\n};\n\n// Assuming that url looks like: http://asdasd:111/asd\nutils.getOrigin = function(url) {\n url += '/';\n var parts = url.split('/').slice(0, 3);\n return parts.join('/');\n};\n\nutils.isSameOriginUrl = function(url_a, url_b) {\n // location.origin would do, but it's not always available.\n if (!url_b) url_b = _window.location.href;\n\n return (url_a.split('/').slice(0,3).join('/')\n ===\n url_b.split('/').slice(0,3).join('/'));\n};\n\nutils.getParentDomain = function(url) {\n // ipv4 ip address\n if (/^[0-9.]*$/.test(url)) return url;\n // ipv6 ip address\n if (/^\\[/.test(url)) return url;\n // no dots\n if (!(/[.]/.test(url))) return url;\n\n var parts = url.split('.').slice(1);\n return parts.join('.');\n};\n\nutils.objectExtend = function(dst, src) {\n for(var k in src) {\n if (src.hasOwnProperty(k)) {\n dst[k] = src[k];\n }\n }\n return dst;\n};\n\nvar WPrefix = '_jp';\n\nutils.polluteGlobalNamespace = function() {\n if (!(WPrefix in _window)) {\n _window[WPrefix] = {};\n }\n};\n\nutils.closeFrame = function (code, reason) {\n return 'c'+JSON.stringify([code, reason]);\n};\n\nutils.userSetCode = function (code) {\n return code === 1000 || (code >= 3000 && code <= 4999);\n};\n\n// See: http://www.erg.abdn.ac.uk/~gerrit/dccp/notes/ccid2/rto_estimator/\n// and RFC 2988.\nutils.countRTO = function (rtt) {\n var rto;\n if (rtt > 100) {\n rto = 3 * rtt; // rto > 300msec\n } else {\n rto = rtt + 200; // 200msec < rto <= 300msec\n }\n return rto;\n}\n\nutils.log = function() {\n if (_window.console && console.log && console.log.apply) {\n console.log.apply(console, arguments);\n }\n};\n\nutils.bind = function(fun, that) {\n if (fun.bind) {\n return fun.bind(that);\n } else {\n return function() {\n return fun.apply(that, arguments);\n };\n }\n};\n\nutils.flatUrl = function(url) {\n return url.indexOf('?') === -1 && url.indexOf('#') === -1;\n};\n\nutils.amendUrl = function(url) {\n var dl = _document.location;\n if (!url) {\n throw new Error('Wrong url for SockJS');\n }\n if (!utils.flatUrl(url)) {\n throw new Error('Only basic urls are supported in SockJS');\n }\n\n // '//abc' --> 'http://abc'\n if (url.indexOf('//') === 0) {\n url = dl.protocol + url;\n }\n // '/abc' --> 'http://localhost:80/abc'\n if (url.indexOf('/') === 0) {\n url = dl.protocol + '//' + dl.host + url;\n }\n // strip trailing slashes\n url = url.replace(/[/]+$/,'');\n return url;\n};\n\n// IE doesn't support [].indexOf.\nutils.arrIndexOf = function(arr, obj){\n for(var i=0; i < arr.length; i++){\n if(arr[i] === obj){\n return i;\n }\n }\n return -1;\n};\n\nutils.arrSkip = function(arr, obj) {\n var idx = utils.arrIndexOf(arr, obj);\n if (idx === -1) {\n return arr.slice();\n } else {\n var dst = arr.slice(0, idx);\n return dst.concat(arr.slice(idx+1));\n }\n};\n\n// Via: https://gist.github.com/1133122/2121c601c5549155483f50be3da5305e83b8c5df\nutils.isArray = Array.isArray || function(value) {\n return {}.toString.call(value).indexOf('Array') >= 0\n};\n\nutils.delay = function(t, fun) {\n if(typeof t === 'function') {\n fun = t;\n t = 0;\n }\n return setTimeout(fun, t);\n};\n\n\n// Chars worth escaping, as defined by Douglas Crockford:\n// https://github.com/douglascrockford/JSON-js/blob/47a9882cddeb1e8529e07af9736218075372b8ac/json2.js#L196\nvar json_escapable = /[\\\\\\\"\\x00-\\x1f\\x7f-\\x9f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,\n json_lookup = {\n\"\\u0000\":\"\\\\u0000\",\"\\u0001\":\"\\\\u0001\",\"\\u0002\":\"\\\\u0002\",\"\\u0003\":\"\\\\u0003\",\n\"\\u0004\":\"\\\\u0004\",\"\\u0005\":\"\\\\u0005\",\"\\u0006\":\"\\\\u0006\",\"\\u0007\":\"\\\\u0007\",\n\"\\b\":\"\\\\b\",\"\\t\":\"\\\\t\",\"\\n\":\"\\\\n\",\"\\u000b\":\"\\\\u000b\",\"\\f\":\"\\\\f\",\"\\r\":\"\\\\r\",\n\"\\u000e\":\"\\\\u000e\",\"\\u000f\":\"\\\\u000f\",\"\\u0010\":\"\\\\u0010\",\"\\u0011\":\"\\\\u0011\",\n\"\\u0012\":\"\\\\u0012\",\"\\u0013\":\"\\\\u0013\",\"\\u0014\":\"\\\\u0014\",\"\\u0015\":\"\\\\u0015\",\n\"\\u0016\":\"\\\\u0016\",\"\\u0017\":\"\\\\u0017\",\"\\u0018\":\"\\\\u0018\",\"\\u0019\":\"\\\\u0019\",\n\"\\u001a\":\"\\\\u001a\",\"\\u001b\":\"\\\\u001b\",\"\\u001c\":\"\\\\u001c\",\"\\u001d\":\"\\\\u001d\",\n\"\\u001e\":\"\\\\u001e\",\"\\u001f\":\"\\\\u001f\",\"\\\"\":\"\\\\\\\"\",\"\\\\\":\"\\\\\\\\\",\n\"\\u007f\":\"\\\\u007f\",\"\\u0080\":\"\\\\u0080\",\"\\u0081\":\"\\\\u0081\",\"\\u0082\":\"\\\\u0082\",\n\"\\u0083\":\"\\\\u0083\",\"\\u0084\":\"\\\\u0084\",\"\\u0085\":\"\\\\u0085\",\"\\u0086\":\"\\\\u0086\",\n\"\\u0087\":\"\\\\u0087\",\"\\u0088\":\"\\\\u0088\",\"\\u0089\":\"\\\\u0089\",\"\\u008a\":\"\\\\u008a\",\n\"\\u008b\":\"\\\\u008b\",\"\\u008c\":\"\\\\u008c\",\"\\u008d\":\"\\\\u008d\",\"\\u008e\":\"\\\\u008e\",\n\"\\u008f\":\"\\\\u008f\",\"\\u0090\":\"\\\\u0090\",\"\\u0091\":\"\\\\u0091\",\"\\u0092\":\"\\\\u0092\",\n\"\\u0093\":\"\\\\u0093\",\"\\u0094\":\"\\\\u0094\",\"\\u0095\":\"\\\\u0095\",\"\\u0096\":\"\\\\u0096\",\n\"\\u0097\":\"\\\\u0097\",\"\\u0098\":\"\\\\u0098\",\"\\u0099\":\"\\\\u0099\",\"\\u009a\":\"\\\\u009a\",\n\"\\u009b\":\"\\\\u009b\",\"\\u009c\":\"\\\\u009c\",\"\\u009d\":\"\\\\u009d\",\"\\u009e\":\"\\\\u009e\",\n\"\\u009f\":\"\\\\u009f\",\"\\u00ad\":\"\\\\u00ad\",\"\\u0600\":\"\\\\u0600\",\"\\u0601\":\"\\\\u0601\",\n\"\\u0602\":\"\\\\u0602\",\"\\u0603\":\"\\\\u0603\",\"\\u0604\":\"\\\\u0604\",\"\\u070f\":\"\\\\u070f\",\n\"\\u17b4\":\"\\\\u17b4\",\"\\u17b5\":\"\\\\u17b5\",\"\\u200c\":\"\\\\u200c\",\"\\u200d\":\"\\\\u200d\",\n\"\\u200e\":\"\\\\u200e\",\"\\u200f\":\"\\\\u200f\",\"\\u2028\":\"\\\\u2028\",\"\\u2029\":\"\\\\u2029\",\n\"\\u202a\":\"\\\\u202a\",\"\\u202b\":\"\\\\u202b\",\"\\u202c\":\"\\\\u202c\",\"\\u202d\":\"\\\\u202d\",\n\"\\u202e\":\"\\\\u202e\",\"\\u202f\":\"\\\\u202f\",\"\\u2060\":\"\\\\u2060\",\"\\u2061\":\"\\\\u2061\",\n\"\\u2062\":\"\\\\u2062\",\"\\u2063\":\"\\\\u2063\",\"\\u2064\":\"\\\\u2064\",\"\\u2065\":\"\\\\u2065\",\n\"\\u2066\":\"\\\\u2066\",\"\\u2067\":\"\\\\u2067\",\"\\u2068\":\"\\\\u2068\",\"\\u2069\":\"\\\\u2069\",\n\"\\u206a\":\"\\\\u206a\",\"\\u206b\":\"\\\\u206b\",\"\\u206c\":\"\\\\u206c\",\"\\u206d\":\"\\\\u206d\",\n\"\\u206e\":\"\\\\u206e\",\"\\u206f\":\"\\\\u206f\",\"\\ufeff\":\"\\\\ufeff\",\"\\ufff0\":\"\\\\ufff0\",\n\"\\ufff1\":\"\\\\ufff1\",\"\\ufff2\":\"\\\\ufff2\",\"\\ufff3\":\"\\\\ufff3\",\"\\ufff4\":\"\\\\ufff4\",\n\"\\ufff5\":\"\\\\ufff5\",\"\\ufff6\":\"\\\\ufff6\",\"\\ufff7\":\"\\\\ufff7\",\"\\ufff8\":\"\\\\ufff8\",\n\"\\ufff9\":\"\\\\ufff9\",\"\\ufffa\":\"\\\\ufffa\",\"\\ufffb\":\"\\\\ufffb\",\"\\ufffc\":\"\\\\ufffc\",\n\"\\ufffd\":\"\\\\ufffd\",\"\\ufffe\":\"\\\\ufffe\",\"\\uffff\":\"\\\\uffff\"};\n\n// Some extra characters that Chrome gets wrong, and substitutes with\n// something else on the wire.\nvar extra_escapable = /[\\x00-\\x1f\\ud800-\\udfff\\ufffe\\uffff\\u0300-\\u0333\\u033d-\\u0346\\u034a-\\u034c\\u0350-\\u0352\\u0357-\\u0358\\u035c-\\u0362\\u0374\\u037e\\u0387\\u0591-\\u05af\\u05c4\\u0610-\\u0617\\u0653-\\u0654\\u0657-\\u065b\\u065d-\\u065e\\u06df-\\u06e2\\u06eb-\\u06ec\\u0730\\u0732-\\u0733\\u0735-\\u0736\\u073a\\u073d\\u073f-\\u0741\\u0743\\u0745\\u0747\\u07eb-\\u07f1\\u0951\\u0958-\\u095f\\u09dc-\\u09dd\\u09df\\u0a33\\u0a36\\u0a59-\\u0a5b\\u0a5e\\u0b5c-\\u0b5d\\u0e38-\\u0e39\\u0f43\\u0f4d\\u0f52\\u0f57\\u0f5c\\u0f69\\u0f72-\\u0f76\\u0f78\\u0f80-\\u0f83\\u0f93\\u0f9d\\u0fa2\\u0fa7\\u0fac\\u0fb9\\u1939-\\u193a\\u1a17\\u1b6b\\u1cda-\\u1cdb\\u1dc0-\\u1dcf\\u1dfc\\u1dfe\\u1f71\\u1f73\\u1f75\\u1f77\\u1f79\\u1f7b\\u1f7d\\u1fbb\\u1fbe\\u1fc9\\u1fcb\\u1fd3\\u1fdb\\u1fe3\\u1feb\\u1fee-\\u1fef\\u1ff9\\u1ffb\\u1ffd\\u2000-\\u2001\\u20d0-\\u20d1\\u20d4-\\u20d7\\u20e7-\\u20e9\\u2126\\u212a-\\u212b\\u2329-\\u232a\\u2adc\\u302b-\\u302c\\uaab2-\\uaab3\\uf900-\\ufa0d\\ufa10\\ufa12\\ufa15-\\ufa1e\\ufa20\\ufa22\\ufa25-\\ufa26\\ufa2a-\\ufa2d\\ufa30-\\ufa6d\\ufa70-\\ufad9\\ufb1d\\ufb1f\\ufb2a-\\ufb36\\ufb38-\\ufb3c\\ufb3e\\ufb40-\\ufb41\\ufb43-\\ufb44\\ufb46-\\ufb4e\\ufff0-\\uffff]/g,\n extra_lookup;\n\n// JSON Quote string. Use native implementation when possible.\nvar JSONQuote = (JSON && JSON.stringify) || function(string) {\n json_escapable.lastIndex = 0;\n if (json_escapable.test(string)) {\n string = string.replace(json_escapable, function(a) {\n return json_lookup[a];\n });\n }\n return '\"' + string + '\"';\n};\n\n// This may be quite slow, so let's delay until user actually uses bad\n// characters.\nvar unroll_lookup = function(escapable) {\n var i;\n var unrolled = {}\n var c = []\n for(i=0; i<65536; i++) {\n c.push( String.fromCharCode(i) );\n }\n escapable.lastIndex = 0;\n c.join('').replace(escapable, function (a) {\n unrolled[ a ] = '\\\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);\n return '';\n });\n escapable.lastIndex = 0;\n return unrolled;\n};\n\n// Quote string, also taking care of unicode characters that browsers\n// often break. Especially, take care of unicode surrogates:\n// http://en.wikipedia.org/wiki/Mapping_of_Unicode_characters#Surrogates\nutils.quote = function(string) {\n var quoted = JSONQuote(string);\n\n // In most cases this should be very fast and good enough.\n extra_escapable.lastIndex = 0;\n if(!extra_escapable.test(quoted)) {\n return quoted;\n }\n\n if(!extra_lookup) extra_lookup = unroll_lookup(extra_escapable);\n\n return quoted.replace(extra_escapable, function(a) {\n return extra_lookup[a];\n });\n}\n\nvar _all_protocols = ['websocket',\n 'xdr-streaming',\n 'xhr-streaming',\n 'iframe-eventsource',\n 'iframe-htmlfile',\n 'xdr-polling',\n 'xhr-polling',\n 'iframe-xhr-polling',\n 'jsonp-polling'];\n\nutils.probeProtocols = function() {\n var probed = {};\n for(var i=0; i<_all_protocols.length; i++) {\n var protocol = _all_protocols[i];\n // User can have a typo in protocol name.\n probed[protocol] = SockJS[protocol] &&\n SockJS[protocol].enabled();\n }\n return probed;\n};\n\nutils.detectProtocols = function(probed, protocols_whitelist, info) {\n var pe = {},\n protocols = [];\n if (!protocols_whitelist) protocols_whitelist = _all_protocols;\n for(var i=0; i<protocols_whitelist.length; i++) {\n var protocol = protocols_whitelist[i];\n pe[protocol] = probed[protocol];\n }\n var maybe_push = function(protos) {\n var proto = protos.shift();\n if (pe[proto]) {\n protocols.push(proto);\n } else {\n if (protos.length > 0) {\n maybe_push(protos);\n }\n }\n }\n\n // 1. Websocket\n if (info.websocket !== false) {\n maybe_push(['websocket']);\n }\n\n // 2. Streaming\n if (pe['xhr-streaming'] && !info.null_origin) {\n protocols.push('xhr-streaming');\n } else {\n if (pe['xdr-streaming'] && !info.cookie_needed && !info.null_origin) {\n protocols.push('xdr-streaming');\n } else {\n maybe_push(['iframe-eventsource',\n 'iframe-htmlfile']);\n }\n }\n\n // 3. Polling\n if (pe['xhr-polling'] && !info.null_origin) {\n protocols.push('xhr-polling');\n } else {\n if (pe['xdr-polling'] && !info.cookie_needed && !info.null_origin) {\n protocols.push('xdr-polling');\n } else {\n maybe_push(['iframe-xhr-polling',\n 'jsonp-polling']);\n }\n }\n return protocols;\n}\n// [*] End of lib/utils.js\n\n\n// [*] Including lib/dom.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\n// May be used by htmlfile jsonp and transports.\nvar MPrefix = '_sockjs_global';\nutils.createHook = function() {\n var window_id = 'a' + utils.random_string(8);\n if (!(MPrefix in _window)) {\n var map = {};\n _window[MPrefix] = function(window_id) {\n if (!(window_id in map)) {\n map[window_id] = {\n id: window_id,\n del: function() {delete map[window_id];}\n };\n }\n return map[window_id];\n }\n }\n return _window[MPrefix](window_id);\n};\n\n\n\nutils.attachMessage = function(listener) {\n utils.attachEvent('message', listener);\n};\nutils.attachEvent = function(event, listener) {\n if (typeof _window.addEventListener !== 'undefined') {\n _window.addEventListener(event, listener, false);\n } else {\n // IE quirks.\n // According to: http://stevesouders.com/misc/test-postmessage.php\n // the message gets delivered only to 'document', not 'window'.\n _document.attachEvent(\"on\" + event, listener);\n // I get 'window' for ie8.\n _window.attachEvent(\"on\" + event, listener);\n }\n};\n\nutils.detachMessage = function(listener) {\n utils.detachEvent('message', listener);\n};\nutils.detachEvent = function(event, listener) {\n if (typeof _window.addEventListener !== 'undefined') {\n _window.removeEventListener(event, listener, false);\n } else {\n _document.detachEvent(\"on\" + event, listener);\n _window.detachEvent(\"on\" + event, listener);\n }\n};\n\n\nvar on_unload = {};\n// Things registered after beforeunload are to be called immediately.\nvar after_unload = false;\n\nvar trigger_unload_callbacks = function() {\n for(var ref in on_unload) {\n on_unload[ref]();\n delete on_unload[ref];\n };\n};\n\nvar unload_triggered = function() {\n if(after_unload) return;\n after_unload = true;\n trigger_unload_callbacks();\n};\n\n// Onbeforeunload alone is not reliable. We could use only 'unload'\n// but it's not working in opera within an iframe. Let's use both.\nutils.attachEvent('beforeunload', unload_triggered);\nutils.attachEvent('unload', unload_triggered);\n\nutils.unload_add = function(listener) {\n var ref = utils.random_string(8);\n on_unload[ref] = listener;\n if (after_unload) {\n utils.delay(trigger_unload_callbacks);\n }\n return ref;\n};\nutils.unload_del = function(ref) {\n if (ref in on_unload)\n delete on_unload[ref];\n};\n\n\nutils.createIframe = function (iframe_url, error_callback) {\n var iframe = _document.createElement('iframe');\n var tref, unload_ref;\n var unattach = function() {\n clearTimeout(tref);\n // Explorer had problems with that.\n try {iframe.onload = null;} catch (x) {}\n iframe.onerror = null;\n };\n var cleanup = function() {\n if (iframe) {\n unattach();\n // This timeout makes chrome fire onbeforeunload event\n // within iframe. Without the timeout it goes straight to\n // onunload.\n setTimeout(function() {\n if(iframe) {\n iframe.parentNode.removeChild(iframe);\n }\n iframe = null;\n }, 0);\n utils.unload_del(unload_ref);\n }\n };\n var onerror = function(r) {\n if (iframe) {\n cleanup();\n error_callback(r);\n }\n };\n var post = function(msg, origin) {\n try {\n // When the iframe is not loaded, IE raises an exception\n // on 'contentWindow'.\n if (iframe && iframe.contentWindow) {\n iframe.contentWindow.postMessage(msg, origin);\n }\n } catch (x) {};\n };\n\n iframe.src = iframe_url;\n iframe.style.display = 'none';\n iframe.style.position = 'absolute';\n iframe.onerror = function(){onerror('onerror');};\n iframe.onload = function() {\n // `onload` is triggered before scripts on the iframe are\n // executed. Give it few seconds to actually load stuff.\n clearTimeout(tref);\n tref = setTimeout(function(){onerror('onload timeout');}, 2000);\n };\n _document.body.appendChild(iframe);\n tref = setTimeout(function(){onerror('timeout');}, 15000);\n unload_ref = utils.unload_add(cleanup);\n return {\n post: post,\n cleanup: cleanup,\n loaded: unattach\n };\n};\n\nutils.createHtmlfile = function (iframe_url, error_callback) {\n var doc = new ActiveXObject('htmlfile');\n var tref, unload_ref;\n var iframe;\n var unattach = function() {\n clearTimeout(tref);\n };\n var cleanup = function() {\n if (doc) {\n unattach();\n utils.unload_del(unload_ref);\n iframe.parentNode.removeChild(iframe);\n iframe = doc = null;\n CollectGarbage();\n }\n };\n var onerror = function(r) {\n if (doc) {\n cleanup();\n error_callback(r);\n }\n };\n var post = function(msg, origin) {\n try {\n // When the iframe is not loaded, IE raises an exception\n // on 'contentWindow'.\n if (iframe && iframe.contentWindow) {\n iframe.contentWindow.postMessage(msg, origin);\n }\n } catch (x) {};\n };\n\n doc.open();\n doc.write('<html><s' + 'cript>' +\n 'document.domain=\"' + document.domain + '\";' +\n '</s' + 'cript></html>');\n doc.close();\n doc.parentWindow[WPrefix] = _window[WPrefix];\n var c = doc.createElement('div');\n doc.body.appendChild(c);\n iframe = doc.createElement('iframe');\n c.appendChild(iframe);\n iframe.src = iframe_url;\n tref = setTimeout(function(){onerror('timeout');}, 15000);\n unload_ref = utils.unload_add(cleanup);\n return {\n post: post,\n cleanup: cleanup,\n loaded: unattach\n };\n};\n// [*] End of lib/dom.js\n\n\n// [*] Including lib/dom2.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\nvar AbstractXHRObject = function(){};\nAbstractXHRObject.prototype = new EventEmitter(['chunk', 'finish']);\n\nAbstractXHRObject.prototype._start = function(method, url, payload, opts) {\n var that = this;\n\n try {\n that.xhr = new XMLHttpRequest();\n } catch(x) {};\n\n if (!that.xhr) {\n try {\n that.xhr = new _window.ActiveXObject('Microsoft.XMLHTTP');\n } catch(x) {};\n }\n if (_window.ActiveXObject || _window.XDomainRequest) {\n // IE8 caches even POSTs\n url += ((url.indexOf('?') === -1) ? '?' : '&') + 't='+(+new Date);\n }\n\n // Explorer tends to keep connection open, even after the\n // tab gets closed: http://bugs.jquery.com/ticket/5280\n that.unload_ref = utils.unload_add(function(){that._cleanup(true);});\n try {\n that.xhr.open(method, url, true);\n } catch(e) {\n // IE raises an exception on wrong port.\n that.emit('finish', 0, '');\n that._cleanup();\n return;\n };\n\n if (!opts || !opts.no_credentials) {\n // Mozilla docs says https://developer.mozilla.org/en/XMLHttpRequest :\n // \"This never affects same-site requests.\"\n that.xhr.withCredentials = 'true';\n }\n if (opts && opts.headers) {\n for(var key in opts.headers) {\n that.xhr.setRequestHeader(key, opts.headers[key]);\n }\n }\n\n that.xhr.onreadystatechange = function() {\n if (that.xhr) {\n var x = that.xhr;\n switch (x.readyState) {\n case 3:\n // IE doesn't like peeking into responseText or status\n // on Microsoft.XMLHTTP and readystate=3\n try {\n var status = x.status;\n var text = x.responseText;\n } catch (x) {};\n // IE does return readystate == 3 for 404 answers.\n if (text && text.length > 0) {\n that.emit('chunk', status, text);\n }\n break;\n case 4:\n that.emit('finish', x.status, x.responseText);\n that._cleanup(false);\n break;\n }\n }\n };\n that.xhr.send(payload);\n};\n\nAbstractXHRObject.prototype._cleanup = function(abort) {\n var that = this;\n if (!that.xhr) return;\n utils.unload_del(that.unload_ref);\n\n // IE needs this field to be a function\n that.xhr.onreadystatechange = function(){};\n\n if (abort) {\n try {\n that.xhr.abort();\n } catch(x) {};\n }\n that.unload_ref = that.xhr = null;\n};\n\nAbstractXHRObject.prototype.close = function() {\n var that = this;\n that.nuke();\n that._cleanup(true);\n};\n\nvar XHRCorsObject = utils.XHRCorsObject = function() {\n var that = this, args = arguments;\n utils.delay(function(){that._start.apply(that, args);});\n};\nXHRCorsObject.prototype = new AbstractXHRObject();\n\nvar XHRLocalObject = utils.XHRLocalObject = function(method, url, payload) {\n var that = this;\n utils.delay(function(){\n that._start(method, url, payload, {\n no_credentials: true\n });\n });\n};\nXHRLocalObject.prototype = new AbstractXHRObject();\n\n\n\n// References:\n// http://ajaxian.com/archives/100-line-ajax-wrapper\n// http://msdn.microsoft.com/en-us/library/cc288060(v=VS.85).aspx\nvar XDRObject = utils.XDRObject = function(method, url, payload) {\n var that = this;\n utils.delay(function(){that._start(method, url, payload);});\n};\nXDRObject.prototype = new EventEmitter(['chunk', 'finish']);\nXDRObject.prototype._start = function(method, url, payload) {\n var that = this;\n var xdr = new XDomainRequest();\n // IE caches even POSTs\n url += ((url.indexOf('?') === -1) ? '?' : '&') + 't='+(+new Date);\n\n var onerror = xdr.ontimeout = xdr.onerror = function() {\n that.emit('finish', 0, '');\n that._cleanup(false);\n };\n xdr.onprogress = function() {\n that.emit('chunk', 200, xdr.responseText);\n };\n xdr.onload = function() {\n that.emit('finish', 200, xdr.responseText);\n that._cleanup(false);\n };\n that.xdr = xdr;\n that.unload_ref = utils.unload_add(function(){that._cleanup(true);});\n try {\n // Fails with AccessDenied if port number is bogus\n that.xdr.open(method, url);\n that.xdr.send(payload);\n } catch(x) {\n onerror();\n }\n};\n\nXDRObject.prototype._cleanup = function(abort) {\n var that = this;\n if (!that.xdr) return;\n utils.unload_del(that.unload_ref);\n\n that.xdr.ontimeout = that.xdr.onerror = that.xdr.onprogress =\n that.xdr.onload = null;\n if (abort) {\n try {\n that.xdr.abort();\n } catch(x) {};\n }\n that.unload_ref = that.xdr = null;\n};\n\nXDRObject.prototype.close = function() {\n var that = this;\n that.nuke();\n that._cleanup(true);\n};\n\n// 1. Is natively via XHR\n// 2. Is natively via XDR\n// 3. Nope, but postMessage is there so it should work via the Iframe.\n// 4. Nope, sorry.\nutils.isXHRCorsCapable = function() {\n if (_window.XMLHttpRequest && 'withCredentials' in new XMLHttpRequest()) {\n return 1;\n }\n // XDomainRequest doesn't work if page is served from file://\n if (_window.XDomainRequest && _document.domain) {\n return 2;\n }\n if (IframeTransport.enabled()) {\n return 3;\n }\n return 4;\n};\n// [*] End of lib/dom2.js\n\n\n// [*] Including lib/sockjs.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\nvar SockJS = function(url, dep_protocols_whitelist, options) {\n if (this === window) {\n // makes `new` optional\n return new SockJS(url, dep_protocols_whitelist, options);\n }\n \n var that = this, protocols_whitelist;\n that._options = {devel: false, debug: false, protocols_whitelist: [],\n info: undefined, rtt: undefined};\n if (options) {\n utils.objectExtend(that._options, options);\n }\n that._base_url = utils.amendUrl(url);\n that._server = that._options.server || utils.random_number_string(1000);\n if (that._options.protocols_whitelist &&\n that._options.protocols_whitelist.length) {\n protocols_whitelist = that._options.protocols_whitelist;\n } else {\n // Deprecated API\n if (typeof dep_protocols_whitelist === 'string' &&\n dep_protocols_whitelist.length > 0) {\n protocols_whitelist = [dep_protocols_whitelist];\n } else if (utils.isArray(dep_protocols_whitelist)) {\n protocols_whitelist = dep_protocols_whitelist\n } else {\n protocols_whitelist = null;\n }\n if (protocols_whitelist) {\n that._debug('Deprecated API: Use \"protocols_whitelist\" option ' +\n 'instead of supplying protocol list as a second ' +\n 'parameter to SockJS constructor.');\n }\n }\n that._protocols = [];\n that.protocol = null;\n that.readyState = SockJS.CONNECTING;\n that._ir = createInfoReceiver(that._base_url);\n that._ir.onfinish = function(info, rtt) {\n that._ir = null;\n if (info) {\n if (that._options.info) {\n // Override if user supplies the option\n info = utils.objectExtend(info, that._options.info);\n }\n if (that._options.rtt) {\n rtt = that._options.rtt;\n }\n that._applyInfo(info, rtt, protocols_whitelist);\n that._didClose();\n } else {\n that._didClose(1002, 'Can\\'t connect to server', true);\n }\n };\n};\n// Inheritance\nSockJS.prototype = new REventTarget();\n\nSockJS.version = \"0.3.1.7.ga67f.dirty\";\n\nSockJS.CONNECTING = 0;\nSockJS.OPEN = 1;\nSockJS.CLOSING = 2;\nSockJS.CLOSED = 3;\n\nSockJS.prototype._debug = function() {\n if (this._options.debug)\n utils.log.apply(utils, arguments);\n};\n\nSockJS.prototype._dispatchOpen = function() {\n var that = this;\n if (that.readyState === SockJS.CONNECTING) {\n if (that._transport_tref) {\n clearTimeout(that._transport_tref);\n that._transport_tref = null;\n }\n that.readyState = SockJS.OPEN;\n that.dispatchEvent(new SimpleEvent(\"open\"));\n } else {\n // The server might have been restarted, and lost track of our\n // connection.\n that._didClose(1006, \"Server lost session\");\n }\n};\n\nSockJS.prototype._dispatchMessage = function(data) {\n var that = this;\n if (that.readyState !== SockJS.OPEN)\n return;\n that.dispatchEvent(new SimpleEvent(\"message\", {data: data}));\n};\n\nSockJS.prototype._dispatchHeartbeat = function(data) {\n var that = this;\n if (that.readyState !== SockJS.OPEN)\n return;\n that.dispatchEvent(new SimpleEvent('heartbeat', {}));\n};\n\nSockJS.prototype._didClose = function(code, reason, force) {\n var that = this;\n if (that.readyState !== SockJS.CONNECTING &&\n that.readyState !== SockJS.OPEN &&\n that.readyState !== SockJS.CLOSING)\n throw new Error('INVALID_STATE_ERR');\n if (that._ir) {\n that._ir.nuke();\n that._ir = null;\n }\n\n if (that._transport) {\n that._transport.doCleanup();\n that._transport = null;\n }\n\n var close_event = new SimpleEvent(\"close\", {\n code: code,\n reason: reason,\n wasClean: utils.userSetCode(code)});\n\n if (!utils.userSetCode(code) &&\n that.readyState === SockJS.CONNECTING && !force) {\n if (that._try_next_protocol(close_event)) {\n return;\n }\n close_event = new SimpleEvent(\"close\", {code: 2000,\n reason: \"All transports failed\",\n wasClean: false,\n last_event: close_event});\n }\n that.readyState = SockJS.CLOSED;\n\n utils.delay(function() {\n that.dispatchEvent(close_event);\n });\n};\n\nSockJS.prototype._didMessage = function(data) {\n var that = this;\n var type = data.slice(0, 1);\n switch(type) {\n case 'o':\n that._dispatchOpen();\n break;\n case 'a':\n var payload = JSON.parse(data.slice(1) || '[]');\n for(var i=0; i < payload.length; i++){\n that._dispatchMessage(payload[i]);\n }\n break;\n case 'm':\n var payload = JSON.parse(data.slice(1) || 'null');\n that._dispatchMessage(payload);\n break;\n case 'c':\n var payload = JSON.parse(data.slice(1) || '[]');\n that._didClose(payload[0], payload[1]);\n break;\n case 'h':\n that._dispatchHeartbeat();\n break;\n }\n};\n\nSockJS.prototype._try_next_protocol = function(close_event) {\n var that = this;\n if (that.protocol) {\n that._debug('Closed transport:', that.protocol, ''+close_event);\n that.protocol = null;\n }\n if (that._transport_tref) {\n clearTimeout(that._transport_tref);\n that._transport_tref = null;\n }\n\n while(1) {\n var protocol = that.protocol = that._protocols.shift();\n if (!protocol) {\n return false;\n }\n // Some protocols require access to `body`, what if were in\n // the `head`?\n if (SockJS[protocol] &&\n SockJS[protocol].need_body === true &&\n (!_document.body ||\n (typeof _document.readyState !== 'undefined'\n && _document.readyState !== 'complete'))) {\n that._protocols.unshift(protocol);\n that.protocol = 'waiting-for-load';\n utils.attachEvent('load', function(){\n that._try_next_protocol();\n });\n return true;\n }\n\n if (!SockJS[protocol] ||\n !SockJS[protocol].enabled(that._options)) {\n that._debug('Skipping transport:', protocol);\n } else {\n var roundTrips = SockJS[protocol].roundTrips || 1;\n var to = ((that._options.rto || 0) * roundTrips) || 5000;\n that._transport_tref = utils.delay(to, function() {\n if (that.readyState === SockJS.CONNECTING) {\n // I can't understand how it is possible to run\n // this timer, when the state is CLOSED, but\n // apparently in IE everythin is possible.\n that._didClose(2007, \"Transport timeouted\");\n }\n });\n\n var connid = utils.random_string(8);\n var trans_url = that._base_url + '/' + that._server + '/' + connid;\n that._debug('Opening transport:', protocol, ' url:'+trans_url,\n ' RTO:'+that._options.rto);\n that._transport = new SockJS[protocol](that, trans_url,\n that._base_url);\n return true;\n }\n }\n};\n\nSockJS.prototype.close = function(code, reason) {\n var that = this;\n if (code && !utils.userSetCode(code))\n throw new Error(\"INVALID_ACCESS_ERR\");\n if(that.readyState !== SockJS.CONNECTING &&\n that.readyState !== SockJS.OPEN) {\n return false;\n }\n that.readyState = SockJS.CLOSING;\n that._didClose(code || 1000, reason || \"Normal closure\");\n return true;\n};\n\nSockJS.prototype.send = function(data) {\n var that = this;\n if (that.readyState === SockJS.CONNECTING)\n throw new Error('INVALID_STATE_ERR');\n if (that.readyState === SockJS.OPEN) {\n that._transport.doSend(utils.quote('' + data));\n }\n return true;\n};\n\nSockJS.prototype._applyInfo = function(info, rtt, protocols_whitelist) {\n var that = this;\n that._options.info = info;\n that._options.rtt = rtt;\n that._options.rto = utils.countRTO(rtt);\n that._options.info.null_origin = !_document.domain;\n var probed = utils.probeProtocols();\n that._protocols = utils.detectProtocols(probed, protocols_whitelist, info);\n};\n// [*] End of lib/sockjs.js\n\n\n// [*] Including lib/trans-websocket.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\nvar WebSocketTransport = SockJS.websocket = function(ri, trans_url) {\n var that = this;\n var url = trans_url + '/websocket';\n if (url.slice(0, 5) === 'https') {\n url = 'wss' + url.slice(5);\n } else {\n url = 'ws' + url.slice(4);\n }\n that.ri = ri;\n that.url = url;\n var Constructor = _window.WebSocket || _window.MozWebSocket;\n\n that.ws = new Constructor(that.url);\n that.ws.onmessage = function(e) {\n that.ri._didMessage(e.data);\n };\n // Firefox has an interesting bug. If a websocket connection is\n // created after onbeforeunload, it stays alive even when user\n // navigates away from the page. In such situation let's lie -\n // let's not open the ws connection at all. See:\n // https://github.com/sockjs/sockjs-client/issues/28\n // https://bugzilla.mozilla.org/show_bug.cgi?id=696085\n that.unload_ref = utils.unload_add(function(){that.ws.close()});\n that.ws.onclose = function() {\n that.ri._didMessage(utils.closeFrame(1006, \"WebSocket connection broken\"));\n };\n};\n\nWebSocketTransport.prototype.doSend = function(data) {\n this.ws.send('[' + data + ']');\n};\n\nWebSocketTransport.prototype.doCleanup = function() {\n var that = this;\n var ws = that.ws;\n if (ws) {\n ws.onmessage = ws.onclose = null;\n ws.close();\n utils.unload_del(that.unload_ref);\n that.unload_ref = that.ri = that.ws = null;\n }\n};\n\nWebSocketTransport.enabled = function() {\n return !!(_window.WebSocket || _window.MozWebSocket);\n};\n\n// In theory, ws should require 1 round trip. But in chrome, this is\n// not very stable over SSL. Most likely a ws connection requires a\n// separate SSL connection, in which case 2 round trips are an\n// absolute minumum.\nWebSocketTransport.roundTrips = 2;\n// [*] End of lib/trans-websocket.js\n\n\n// [*] Including lib/trans-sender.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\nvar BufferedSender = function() {};\nBufferedSender.prototype.send_constructor = function(sender) {\n var that = this;\n that.send_buffer = [];\n that.sender = sender;\n};\nBufferedSender.prototype.doSend = function(message) {\n var that = this;\n that.send_buffer.push(message);\n if (!that.send_stop) {\n that.send_schedule();\n }\n};\n\n// For polling transports in a situation when in the message callback,\n// new message is being send. If the sending connection was started\n// before receiving one, it is possible to saturate the network and\n// timeout due to the lack of receiving socket. To avoid that we delay\n// sending messages by some small time, in order to let receiving\n// connection be started beforehand. This is only a halfmeasure and\n// does not fix the big problem, but it does make the tests go more\n// stable on slow networks.\nBufferedSender.prototype.send_schedule_wait = function() {\n var that = this;\n var tref;\n that.send_stop = function() {\n that.send_stop = null;\n clearTimeout(tref);\n };\n tref = utils.delay(25, function() {\n that.send_stop = null;\n that.send_schedule();\n });\n};\n\nBufferedSender.prototype.send_schedule = function() {\n var that = this;\n if (that.send_buffer.length > 0) {\n var payload = '[' + that.send_buffer.join(',') + ']';\n that.send_stop = that.sender(that.trans_url,\n payload,\n function() {\n that.send_stop = null;\n that.send_schedule_wait();\n });\n that.send_buffer = [];\n }\n};\n\nBufferedSender.prototype.send_destructor = function() {\n var that = this;\n if (that._send_stop) {\n that._send_stop();\n }\n that._send_stop = null;\n};\n\nvar jsonPGenericSender = function(url, payload, callback) {\n var that = this;\n\n if (!('_send_form' in that)) {\n var form = that._send_form = _document.createElement('form');\n var area = that._send_area = _document.createElement('textarea');\n area.name = 'd';\n form.style.display = 'none';\n form.style.position = 'absolute';\n form.method = 'POST';\n form.enctype = 'application/x-www-form-urlencoded';\n form.acceptCharset = \"UTF-8\";\n form.appendChild(area);\n _document.body.appendChild(form);\n }\n var form = that._send_form;\n var area = that._send_area;\n var id = 'a' + utils.random_string(8);\n form.target = id;\n form.action = url + '/jsonp_send?i=' + id;\n\n var iframe;\n try {\n // ie6 dynamic iframes with target=\"\" support (thanks Chris Lambacher)\n iframe = _document.createElement('<iframe name=\"'+ id +'\">');\n } catch(x) {\n iframe = _document.createElement('iframe');\n iframe.name = id;\n }\n iframe.id = id;\n form.appendChild(iframe);\n iframe.style.display = 'none';\n\n try {\n area.value = payload;\n } catch(e) {\n utils.log('Your browser is seriously broken. Go home! ' + e.message);\n }\n form.submit();\n\n var completed = function(e) {\n if (!iframe.onerror) return;\n iframe.onreadystatechange = iframe.onerror = iframe.onload = null;\n // Opera mini doesn't like if we GC iframe\n // immediately, thus this timeout.\n utils.delay(500, function() {\n iframe.parentNode.removeChild(iframe);\n iframe = null;\n });\n area.value = '';\n callback();\n };\n iframe.onerror = iframe.onload = completed;\n iframe.onreadystatechange = function(e) {\n if (iframe.readyState == 'complete') completed();\n };\n return completed;\n};\n\nvar createAjaxSender = function(AjaxObject) {\n return function(url, payload, callback) {\n var xo = new AjaxObject('POST', url + '/xhr_send', payload);\n xo.onfinish = function(status, text) {\n callback(status);\n };\n return function(abort_reason) {\n callback(0, abort_reason);\n };\n };\n};\n// [*] End of lib/trans-sender.js\n\n\n// [*] Including lib/trans-jsonp-receiver.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\n// Parts derived from Socket.io:\n// https://github.com/LearnBoost/socket.io/blob/0.6.17/lib/socket.io/transports/jsonp-polling.js\n// and jQuery-JSONP:\n// https://code.google.com/p/jquery-jsonp/source/browse/trunk/core/jquery.jsonp.js\nvar jsonPGenericReceiver = function(url, callback) {\n var tref;\n var script = _document.createElement('script');\n var script2; // Opera synchronous load trick.\n var close_script = function(frame) {\n if (script2) {\n script2.parentNode.removeChild(script2);\n script2 = null;\n }\n if (script) {\n clearTimeout(tref);\n script.parentNode.removeChild(script);\n script.onreadystatechange = script.onerror =\n script.onload = script.onclick = null;\n script = null;\n callback(frame);\n callback = null;\n }\n };\n\n // IE9 fires 'error' event after orsc or before, in random order.\n var loaded_okay = false;\n var error_timer = null;\n\n script.id = 'a' + utils.random_string(8);\n script.src = url;\n script.type = 'text/javascript';\n script.charset = 'UTF-8';\n script.onerror = function(e) {\n if (!error_timer) {\n // Delay firing close_script.\n error_timer = setTimeout(function() {\n if (!loaded_okay) {\n close_script(utils.closeFrame(\n 1006,\n \"JSONP script loaded abnormally (onerror)\"));\n }\n }, 1000);\n }\n };\n script.onload = function(e) {\n close_script(utils.closeFrame(1006, \"JSONP script loaded abnormally (onload)\"));\n };\n\n script.onreadystatechange = function(e) {\n if (/loaded|closed/.test(script.readyState)) {\n if (script && script.htmlFor && script.onclick) {\n loaded_okay = true;\n try {\n // In IE, actually execute the script.\n script.onclick();\n } catch (x) {}\n }\n if (script) {\n close_script(utils.closeFrame(1006, \"JSONP script loaded abnormally (onreadystatechange)\"));\n }\n }\n };\n // IE: event/htmlFor/onclick trick.\n // One can't rely on proper order for onreadystatechange. In order to\n // make sure, set a 'htmlFor' and 'event' properties, so that\n // script code will be installed as 'onclick' handler for the\n // script object. Later, onreadystatechange, manually execute this\n // code. FF and Chrome doesn't work with 'event' and 'htmlFor'\n // set. For reference see:\n // http://jaubourg.net/2010/07/loading-script-as-onclick-handler-of.html\n // Also, read on that about script ordering:\n // http://wiki.whatwg.org/wiki/Dynamic_Script_Execution_Order\n if (typeof script.async === 'undefined' && _document.attachEvent) {\n // According to mozilla docs, in recent browsers script.async defaults\n // to 'true', so we may use it to detect a good browser:\n // https://developer.mozilla.org/en/HTML/Element/script\n if (!/opera/i.test(navigator.userAgent)) {\n // Naively assume we're in IE\n try {\n script.htmlFor = script.id;\n script.event = \"onclick\";\n } catch (x) {}\n script.async = true;\n } else {\n // Opera, second sync script hack\n script2 = _document.createElement('script');\n script2.text = \"try{var a = document.getElementById('\"+script.id+\"'); if(a)a.onerror();}catch(x){};\";\n script.async = script2.async = false;\n }\n }\n if (typeof script.async !== 'undefined') {\n script.async = true;\n }\n\n // Fallback mostly for Konqueror - stupid timer, 35 seconds shall be plenty.\n tref = setTimeout(function() {\n close_script(utils.closeFrame(1006, \"JSONP script loaded abnormally (timeout)\"));\n }, 35000);\n\n var head = _document.getElementsByTagName('head')[0];\n head.insertBefore(script, head.firstChild);\n if (script2) {\n head.insertBefore(script2, head.firstChild);\n }\n return close_script;\n};\n// [*] End of lib/trans-jsonp-receiver.js\n\n\n// [*] Including lib/trans-jsonp-polling.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\n// The simplest and most robust transport, using the well-know cross\n// domain hack - JSONP. This transport is quite inefficient - one\n// mssage could use up to one http request. But at least it works almost\n// everywhere.\n// Known limitations:\n// o you will get a spinning cursor\n// o for Konqueror a dumb timer is needed to detect errors\n\n\nvar JsonPTransport = SockJS['jsonp-polling'] = function(ri, trans_url) {\n utils.polluteGlobalNamespace();\n var that = this;\n that.ri = ri;\n that.trans_url = trans_url;\n that.send_constructor(jsonPGenericSender);\n that._schedule_recv();\n};\n\n// Inheritnace\nJsonPTransport.prototype = new BufferedSender();\n\nJsonPTransport.prototype._schedule_recv = function() {\n var that = this;\n var callback = function(data) {\n that._recv_stop = null;\n if (data) {\n // no data - heartbeat;\n if (!that._is_closing) {\n that.ri._didMessage(data);\n }\n }\n // The message can be a close message, and change is_closing state.\n if (!that._is_closing) {\n that._schedule_recv();\n }\n };\n that._recv_stop = jsonPReceiverWrapper(that.trans_url + '/jsonp',\n jsonPGenericReceiver, callback);\n};\n\nJsonPTransport.enabled = function() {\n return true;\n};\n\nJsonPTransport.need_body = true;\n\n\nJsonPTransport.prototype.doCleanup = function() {\n var that = this;\n that._is_closing = true;\n if (that._recv_stop) {\n that._recv_stop();\n }\n that.ri = that._recv_stop = null;\n that.send_destructor();\n};\n\n\n// Abstract away code that handles global namespace pollution.\nvar jsonPReceiverWrapper = function(url, constructReceiver, user_callback) {\n var id = 'a' + utils.random_string(6);\n var url_id = url + '?c=' + escape(WPrefix + '.' + id);\n // Callback will be called exactly once.\n var callback = function(frame) {\n delete _window[WPrefix][id];\n user_callback(frame);\n };\n\n var close_script = constructReceiver(url_id, callback);\n _window[WPrefix][id] = close_script;\n var stop = function() {\n if (_window[WPrefix][id]) {\n _window[WPrefix][id](utils.closeFrame(1000, \"JSONP user aborted read\"));\n }\n };\n return stop;\n};\n// [*] End of lib/trans-jsonp-polling.js\n\n\n// [*] Including lib/trans-xhr.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\nvar AjaxBasedTransport = function() {};\nAjaxBasedTransport.prototype = new BufferedSender();\n\nAjaxBasedTransport.prototype.run = function(ri, trans_url,\n url_suffix, Receiver, AjaxObject) {\n var that = this;\n that.ri = ri;\n that.trans_url = trans_url;\n that.send_constructor(createAjaxSender(AjaxObject));\n that.poll = new Polling(ri, Receiver,\n trans_url + url_suffix, AjaxObject);\n};\n\nAjaxBasedTransport.prototype.doCleanup = function() {\n var that = this;\n if (that.poll) {\n that.poll.abort();\n that.poll = null;\n }\n};\n\n// xhr-streaming\nvar XhrStreamingTransport = SockJS['xhr-streaming'] = function(ri, trans_url) {\n this.run(ri, trans_url, '/xhr_streaming', XhrReceiver, utils.XHRCorsObject);\n};\n\nXhrStreamingTransport.prototype = new AjaxBasedTransport();\n\nXhrStreamingTransport.enabled = function() {\n // Support for CORS Ajax aka Ajax2? Opera 12 claims CORS but\n // doesn't do streaming.\n return (_window.XMLHttpRequest &&\n 'withCredentials' in new XMLHttpRequest() &&\n (!/opera/i.test(navigator.userAgent)));\n};\nXhrStreamingTransport.roundTrips = 2; // preflight, ajax\n\n// Safari gets confused when a streaming ajax request is started\n// before onload. This causes the load indicator to spin indefinetely.\nXhrStreamingTransport.need_body = true;\n\n\n// According to:\n// http://stackoverflow.com/questions/1641507/detect-browser-support-for-cross-domain-xmlhttprequests\n// http://hacks.mozilla.org/2009/07/cross-site-xmlhttprequest-with-cors/\n\n\n// xdr-streaming\nvar XdrStreamingTransport = SockJS['xdr-streaming'] = function(ri, trans_url) {\n this.run(ri, trans_url, '/xhr_streaming', XhrReceiver, utils.XDRObject);\n};\n\nXdrStreamingTransport.prototype = new AjaxBasedTransport();\n\nXdrStreamingTransport.enabled = function() {\n return !!_window.XDomainRequest;\n};\nXdrStreamingTransport.roundTrips = 2; // preflight, ajax\n\n\n\n// xhr-polling\nvar XhrPollingTransport = SockJS['xhr-polling'] = function(ri, trans_url) {\n this.run(ri, trans_url, '/xhr', XhrReceiver, utils.XHRCorsObject);\n};\n\nXhrPollingTransport.prototype = new AjaxBasedTransport();\n\nXhrPollingTransport.enabled = XhrStreamingTransport.enabled;\nXhrPollingTransport.roundTrips = 2; // preflight, ajax\n\n\n// xdr-polling\nvar XdrPollingTransport = SockJS['xdr-polling'] = function(ri, trans_url) {\n this.run(ri, trans_url, '/xhr', XhrReceiver, utils.XDRObject);\n};\n\nXdrPollingTransport.prototype = new AjaxBasedTransport();\n\nXdrPollingTransport.enabled = XdrStreamingTransport.enabled;\nXdrPollingTransport.roundTrips = 2; // preflight, ajax\n// [*] End of lib/trans-xhr.js\n\n\n// [*] Including lib/trans-iframe.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\n// Few cool transports do work only for same-origin. In order to make\n// them working cross-domain we shall use iframe, served form the\n// remote domain. New browsers, have capabilities to communicate with\n// cross domain iframe, using postMessage(). In IE it was implemented\n// from IE 8+, but of course, IE got some details wrong:\n// http://msdn.microsoft.com/en-us/library/cc197015(v=VS.85).aspx\n// http://stevesouders.com/misc/test-postmessage.php\n\nvar IframeTransport = function() {};\n\nIframeTransport.prototype.i_constructor = function(ri, trans_url, base_url) {\n var that = this;\n that.ri = ri;\n that.origin = utils.getOrigin(base_url);\n that.base_url = base_url;\n that.trans_url = trans_url;\n\n var iframe_url = base_url + '/iframe.html';\n if (that.ri._options.devel) {\n iframe_url += '?t=' + (+new Date);\n }\n that.window_id = utils.random_string(8);\n iframe_url += '#' + that.window_id;\n\n that.iframeObj = utils.createIframe(iframe_url, function(r) {\n that.ri._didClose(1006, \"Unable to load an iframe (\" + r + \")\");\n });\n\n that.onmessage_cb = utils.bind(that.onmessage, that);\n utils.attachMessage(that.onmessage_cb);\n};\n\nIframeTransport.prototype.doCleanup = function() {\n var that = this;\n if (that.iframeObj) {\n utils.detachMessage(that.onmessage_cb);\n try {\n // When the iframe is not loaded, IE raises an exception\n // on 'contentWindow'.\n if (that.iframeObj.iframe.contentWindow) {\n that.postMessage('c');\n }\n } catch (x) {}\n that.iframeObj.cleanup();\n that.iframeObj = null;\n that.onmessage_cb = that.iframeObj = null;\n }\n};\n\nIframeTransport.prototype.onmessage = function(e) {\n var that = this;\n if (e.origin !== that.origin) return;\n var window_id = e.data.slice(0, 8);\n var type = e.data.slice(8, 9);\n var data = e.data.slice(9);\n\n if (window_id !== that.window_id) return;\n\n switch(type) {\n case 's':\n that.iframeObj.loaded();\n that.postMessage('s', JSON.stringify([SockJS.version, that.protocol, that.trans_url, that.base_url]));\n break;\n case 't':\n that.ri._didMessage(data);\n break;\n }\n};\n\nIframeTransport.prototype.postMessage = function(type, data) {\n var that = this;\n that.iframeObj.post(that.window_id + type + (data || ''), that.origin);\n};\n\nIframeTransport.prototype.doSend = function (message) {\n this.postMessage('m', message);\n};\n\nIframeTransport.enabled = function() {\n // postMessage misbehaves in konqueror 4.6.5 - the messages are delivered with\n // huge delay, or not at all.\n var konqueror = navigator && navigator.userAgent && navigator.userAgent.indexOf('Konqueror') !== -1;\n return ((typeof _window.postMessage === 'function' ||\n typeof _window.postMessage === 'object') && (!konqueror));\n};\n// [*] End of lib/trans-iframe.js\n\n\n// [*] Including lib/trans-iframe-within.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\nvar curr_window_id;\n\nvar postMessage = function (type, data) {\n if(parent !== _window) {\n parent.postMessage(curr_window_id + type + (data || ''), '*');\n } else {\n utils.log(\"Can't postMessage, no parent window.\", type, data);\n }\n};\n\nvar FacadeJS = function() {};\nFacadeJS.prototype._didClose = function (code, reason) {\n postMessage('t', utils.closeFrame(code, reason));\n};\nFacadeJS.prototype._didMessage = function (frame) {\n postMessage('t', frame);\n};\nFacadeJS.prototype._doSend = function (data) {\n this._transport.doSend(data);\n};\nFacadeJS.prototype._doCleanup = function () {\n this._transport.doCleanup();\n};\n\nutils.parent_origin = undefined;\n\nSockJS.bootstrap_iframe = function() {\n var facade;\n curr_window_id = _document.location.hash.slice(1);\n var onMessage = function(e) {\n if(e.source !== parent) return;\n if(typeof utils.parent_origin === 'undefined')\n utils.parent_origin = e.origin;\n if (e.origin !== utils.parent_origin) return;\n\n var window_id = e.data.slice(0, 8);\n var type = e.data.slice(8, 9);\n var data = e.data.slice(9);\n if (window_id !== curr_window_id) return;\n switch(type) {\n case 's':\n var p = JSON.parse(data);\n var version = p[0];\n var protocol = p[1];\n var trans_url = p[2];\n var base_url = p[3];\n if (version !== SockJS.version) {\n utils.log(\"Incompatibile SockJS! Main site uses:\" +\n \" \\\"\" + version + \"\\\", the iframe:\" +\n \" \\\"\" + SockJS.version + \"\\\".\");\n }\n if (!utils.flatUrl(trans_url) || !utils.flatUrl(base_url)) {\n utils.log(\"Only basic urls are supported in SockJS\");\n return;\n }\n\n if (!utils.isSameOriginUrl(trans_url) ||\n !utils.isSameOriginUrl(base_url)) {\n utils.log(\"Can't connect to different domain from within an \" +\n \"iframe. (\" + JSON.stringify([_window.location.href, trans_url, base_url]) +\n \")\");\n return;\n }\n facade = new FacadeJS();\n facade._transport = new FacadeJS[protocol](facade, trans_url, base_url);\n break;\n case 'm':\n facade._doSend(data);\n break;\n case 'c':\n if (facade)\n facade._doCleanup();\n facade = null;\n break;\n }\n };\n\n // alert('test ticker');\n // facade = new FacadeJS();\n // facade._transport = new FacadeJS['w-iframe-xhr-polling'](facade, 'http://host.com:9999/ticker/12/basd');\n\n utils.attachMessage(onMessage);\n\n // Start\n postMessage('s');\n};\n// [*] End of lib/trans-iframe-within.js\n\n\n// [*] Including lib/info.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\nvar InfoReceiver = function(base_url, AjaxObject) {\n var that = this;\n utils.delay(function(){that.doXhr(base_url, AjaxObject);});\n};\n\nInfoReceiver.prototype = new EventEmitter(['finish']);\n\nInfoReceiver.prototype.doXhr = function(base_url, AjaxObject) {\n var that = this;\n var t0 = (new Date()).getTime();\n var xo = new AjaxObject('GET', base_url + '/info');\n\n var tref = utils.delay(8000,\n function(){xo.ontimeout();});\n\n xo.onfinish = function(status, text) {\n clearTimeout(tref);\n tref = null;\n if (status === 200) {\n var rtt = (new Date()).getTime() - t0;\n var info = JSON.parse(text);\n if (typeof info !== 'object') info = {};\n that.emit('finish', info, rtt);\n } else {\n that.emit('finish');\n }\n };\n xo.ontimeout = function() {\n xo.close();\n that.emit('finish');\n };\n};\n\nvar InfoReceiverIframe = function(base_url) {\n var that = this;\n var go = function() {\n var ifr = new IframeTransport();\n ifr.protocol = 'w-iframe-info-receiver';\n var fun = function(r) {\n if (typeof r === 'string' && r.substr(0,1) === 'm') {\n var d = JSON.parse(r.substr(1));\n var info = d[0], rtt = d[1];\n that.emit('finish', info, rtt);\n } else {\n that.emit('finish');\n }\n ifr.doCleanup();\n ifr = null;\n };\n var mock_ri = {\n _options: {},\n _didClose: fun,\n _didMessage: fun\n };\n ifr.i_constructor(mock_ri, base_url, base_url);\n }\n if(!_document.body) {\n utils.attachEvent('load', go);\n } else {\n go();\n }\n};\nInfoReceiverIframe.prototype = new EventEmitter(['finish']);\n\n\nvar InfoReceiverFake = function() {\n // It may not be possible to do cross domain AJAX to get the info\n // data, for example for IE7. But we want to run JSONP, so let's\n // fake the response, with rtt=2s (rto=6s).\n var that = this;\n utils.delay(function() {\n that.emit('finish', {}, 2000);\n });\n};\nInfoReceiverFake.prototype = new EventEmitter(['finish']);\n\nvar createInfoReceiver = function(base_url) {\n if (utils.isSameOriginUrl(base_url)) {\n // If, for some reason, we have SockJS locally - there's no\n // need to start up the complex machinery. Just use ajax.\n return new InfoReceiver(base_url, utils.XHRLocalObject);\n }\n switch (utils.isXHRCorsCapable()) {\n case 1:\n return new InfoReceiver(base_url, utils.XHRCorsObject);\n case 2:\n return new InfoReceiver(base_url, utils.XDRObject);\n case 3:\n // Opera\n return new InfoReceiverIframe(base_url);\n default:\n // IE 7\n return new InfoReceiverFake();\n };\n};\n\n\nvar WInfoReceiverIframe = FacadeJS['w-iframe-info-receiver'] = function(ri, _trans_url, base_url) {\n var ir = new InfoReceiver(base_url, utils.XHRLocalObject);\n ir.onfinish = function(info, rtt) {\n ri._didMessage('m'+JSON.stringify([info, rtt]));\n ri._didClose();\n }\n};\nWInfoReceiverIframe.prototype.doCleanup = function() {};\n// [*] End of lib/info.js\n\n\n// [*] Including lib/trans-iframe-eventsource.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\nvar EventSourceIframeTransport = SockJS['iframe-eventsource'] = function () {\n var that = this;\n that.protocol = 'w-iframe-eventsource';\n that.i_constructor.apply(that, arguments);\n};\n\nEventSourceIframeTransport.prototype = new IframeTransport();\n\nEventSourceIframeTransport.enabled = function () {\n return ('EventSource' in _window) && IframeTransport.enabled();\n};\n\nEventSourceIframeTransport.need_body = true;\nEventSourceIframeTransport.roundTrips = 3; // html, javascript, eventsource\n\n\n// w-iframe-eventsource\nvar EventSourceTransport = FacadeJS['w-iframe-eventsource'] = function(ri, trans_url) {\n this.run(ri, trans_url, '/eventsource', EventSourceReceiver, utils.XHRLocalObject);\n}\nEventSourceTransport.prototype = new AjaxBasedTransport();\n// [*] End of lib/trans-iframe-eventsource.js\n\n\n// [*] Including lib/trans-iframe-xhr-polling.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\nvar XhrPollingIframeTransport = SockJS['iframe-xhr-polling'] = function () {\n var that = this;\n that.protocol = 'w-iframe-xhr-polling';\n that.i_constructor.apply(that, arguments);\n};\n\nXhrPollingIframeTransport.prototype = new IframeTransport();\n\nXhrPollingIframeTransport.enabled = function () {\n return _window.XMLHttpRequest && IframeTransport.enabled();\n};\n\nXhrPollingIframeTransport.need_body = true;\nXhrPollingIframeTransport.roundTrips = 3; // html, javascript, xhr\n\n\n// w-iframe-xhr-polling\nvar XhrPollingITransport = FacadeJS['w-iframe-xhr-polling'] = function(ri, trans_url) {\n this.run(ri, trans_url, '/xhr', XhrReceiver, utils.XHRLocalObject);\n};\n\nXhrPollingITransport.prototype = new AjaxBasedTransport();\n// [*] End of lib/trans-iframe-xhr-polling.js\n\n\n// [*] Including lib/trans-iframe-htmlfile.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\n// This transport generally works in any browser, but will cause a\n// spinning cursor to appear in any browser other than IE.\n// We may test this transport in all browsers - why not, but in\n// production it should be only run in IE.\n\nvar HtmlFileIframeTransport = SockJS['iframe-htmlfile'] = function () {\n var that = this;\n that.protocol = 'w-iframe-htmlfile';\n that.i_constructor.apply(that, arguments);\n};\n\n// Inheritance.\nHtmlFileIframeTransport.prototype = new IframeTransport();\n\nHtmlFileIframeTransport.enabled = function() {\n return IframeTransport.enabled();\n};\n\nHtmlFileIframeTransport.need_body = true;\nHtmlFileIframeTransport.roundTrips = 3; // html, javascript, htmlfile\n\n\n// w-iframe-htmlfile\nvar HtmlFileTransport = FacadeJS['w-iframe-htmlfile'] = function(ri, trans_url) {\n this.run(ri, trans_url, '/htmlfile', HtmlfileReceiver, utils.XHRLocalObject);\n};\nHtmlFileTransport.prototype = new AjaxBasedTransport();\n// [*] End of lib/trans-iframe-htmlfile.js\n\n\n// [*] Including lib/trans-polling.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\nvar Polling = function(ri, Receiver, recv_url, AjaxObject) {\n var that = this;\n that.ri = ri;\n that.Receiver = Receiver;\n that.recv_url = recv_url;\n that.AjaxObject = AjaxObject;\n that._scheduleRecv();\n};\n\nPolling.prototype._scheduleRecv = function() {\n var that = this;\n var poll = that.poll = new that.Receiver(that.recv_url, that.AjaxObject);\n var msg_counter = 0;\n poll.onmessage = function(e) {\n msg_counter += 1;\n that.ri._didMessage(e.data);\n };\n poll.onclose = function(e) {\n that.poll = poll = poll.onmessage = poll.onclose = null;\n if (!that.poll_is_closing) {\n if (e.reason === 'permanent') {\n that.ri._didClose(1006, 'Polling error (' + e.reason + ')');\n } else {\n that._scheduleRecv();\n }\n }\n };\n};\n\nPolling.prototype.abort = function() {\n var that = this;\n that.poll_is_closing = true;\n if (that.poll) {\n that.poll.abort();\n }\n};\n// [*] End of lib/trans-polling.js\n\n\n// [*] Including lib/trans-receiver-eventsource.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\nvar EventSourceReceiver = function(url) {\n var that = this;\n var es = new EventSource(url);\n es.onmessage = function(e) {\n that.dispatchEvent(new SimpleEvent('message',\n {'data': unescape(e.data)}));\n };\n that.es_close = es.onerror = function(e, abort_reason) {\n // ES on reconnection has readyState = 0 or 1.\n // on network error it's CLOSED = 2\n var reason = abort_reason ? 'user' :\n (es.readyState !== 2 ? 'network' : 'permanent');\n that.es_close = es.onmessage = es.onerror = null;\n // EventSource reconnects automatically.\n es.close();\n es = null;\n // Safari and chrome < 15 crash if we close window before\n // waiting for ES cleanup. See:\n // https://code.google.com/p/chromium/issues/detail?id=89155\n utils.delay(200, function() {\n that.dispatchEvent(new SimpleEvent('close', {reason: reason}));\n });\n };\n};\n\nEventSourceReceiver.prototype = new REventTarget();\n\nEventSourceReceiver.prototype.abort = function() {\n var that = this;\n if (that.es_close) {\n that.es_close({}, true);\n }\n};\n// [*] End of lib/trans-receiver-eventsource.js\n\n\n// [*] Including lib/trans-receiver-htmlfile.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\nvar _is_ie_htmlfile_capable;\nvar isIeHtmlfileCapable = function() {\n if (_is_ie_htmlfile_capable === undefined) {\n if ('ActiveXObject' in _window) {\n try {\n _is_ie_htmlfile_capable = !!new ActiveXObject('htmlfile');\n } catch (x) {}\n } else {\n _is_ie_htmlfile_capable = false;\n }\n }\n return _is_ie_htmlfile_capable;\n};\n\n\nvar HtmlfileReceiver = function(url) {\n var that = this;\n utils.polluteGlobalNamespace();\n\n that.id = 'a' + utils.random_string(6, 26);\n url += ((url.indexOf('?') === -1) ? '?' : '&') +\n 'c=' + escape(WPrefix + '.' + that.id);\n\n var constructor = isIeHtmlfileCapable() ?\n utils.createHtmlfile : utils.createIframe;\n\n var iframeObj;\n _window[WPrefix][that.id] = {\n start: function () {\n iframeObj.loaded();\n },\n message: function (data) {\n that.dispatchEvent(new SimpleEvent('message', {'data': data}));\n },\n stop: function () {\n that.iframe_close({}, 'network');\n }\n };\n that.iframe_close = function(e, abort_reason) {\n iframeObj.cleanup();\n that.iframe_close = iframeObj = null;\n delete _window[WPrefix][that.id];\n that.dispatchEvent(new SimpleEvent('close', {reason: abort_reason}));\n };\n iframeObj = constructor(url, function(e) {\n that.iframe_close({}, 'permanent');\n });\n};\n\nHtmlfileReceiver.prototype = new REventTarget();\n\nHtmlfileReceiver.prototype.abort = function() {\n var that = this;\n if (that.iframe_close) {\n that.iframe_close({}, 'user');\n }\n};\n// [*] End of lib/trans-receiver-htmlfile.js\n\n\n// [*] Including lib/trans-receiver-xhr.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\nvar XhrReceiver = function(url, AjaxObject) {\n var that = this;\n var buf_pos = 0;\n\n that.xo = new AjaxObject('POST', url, null);\n that.xo.onchunk = function(status, text) {\n if (status !== 200) return;\n while (1) {\n var buf = text.slice(buf_pos);\n var p = buf.indexOf('\\n');\n if (p === -1) break;\n buf_pos += p+1;\n var msg = buf.slice(0, p);\n that.dispatchEvent(new SimpleEvent('message', {data: msg}));\n }\n };\n that.xo.onfinish = function(status, text) {\n that.xo.onchunk(status, text);\n that.xo = null;\n var reason = status === 200 ? 'network' : 'permanent';\n that.dispatchEvent(new SimpleEvent('close', {reason: reason}));\n }\n};\n\nXhrReceiver.prototype = new REventTarget();\n\nXhrReceiver.prototype.abort = function() {\n var that = this;\n if (that.xo) {\n that.xo.close();\n that.dispatchEvent(new SimpleEvent('close', {reason: 'user'}));\n that.xo = null;\n }\n};\n// [*] End of lib/trans-receiver-xhr.js\n\n\n// [*] Including lib/test-hooks.js\n/*\n * ***** BEGIN LICENSE BLOCK *****\n * Copyright (c) 2011-2012 VMware, Inc.\n *\n * For the license see COPYING.\n * ***** END LICENSE BLOCK *****\n */\n\n// For testing\nSockJS.getUtils = function(){\n return utils;\n};\n\nSockJS.getIframeTransport = function(){\n return IframeTransport;\n};\n// [*] End of lib/test-hooks.js\n\n return SockJS;\n })();\nif ('_sockjs_onload' in window) setTimeout(_sockjs_onload, 1);\n\n// AMD compliance\nif (typeof define === 'function' && define.amd) {\n define('sockjs', [], function(){return SockJS;});\n}\n\nif (typeof module === 'object' && module && module.exports) {\n module.exports = SockJS;\n}\n// [*] End of lib/index.js\n\n// [*] End of lib/all.js\n\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/shoe/node_modules/sockjs-client/sockjs.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/reconnect/inject.js",Function(['require','module','exports','__dirname','__filename','process','global'],"var EventEmitter = require('events').EventEmitter\nvar backoff = require('backoff')\n\nmodule.exports =\nfunction (createConnection) {\n return function (opts, onConnect) {\n onConnect = 'function' == typeof opts ? opts : onConnect\n opts = opts || {initialDelay: 1e3, maxDelay: 30e3}\n if(!onConnect)\n onConnect = opts.onConnect\n\n var emitter = new EventEmitter()\n emitter.connected = false\n emitter.reconnect = true\n\n if(onConnect)\n emitter.on('connect', onConnect)\n\n var backoffMethod = (backoff[opts.type] || backoff.fibonacci) (opts)\n\n backoffMethod.on('backoff', function (n, d) {\n emitter.emit('backoff', n, d)\n })\n\n var args\n function attempt (n, delay) {\n if(!emitter.reconnect) return\n\n emitter.emit('reconnect', n, delay)\n var con = createConnection.apply(null, args)\n emitter._connection = con\n function onDisconnect () {\n\n emitter.connected = false\n con.removeListener('error', onDisconnect)\n con.removeListener('close', onDisconnect)\n con.removeListener('end' , onDisconnect)\n\n //emit disconnect before checking reconnect, so user has a chance to decide not to.\n emitter.emit('disconnect', con)\n\n if(!emitter.reconnect) return\n backoffMethod.backoff()\n }\n\n con.on('connect', function () {\n backoffMethod.reset()\n emitter.connected = true\n emitter.emit('connect', con)\n }).on('error', onDisconnect)\n .on('close', onDisconnect)\n .on('end' , onDisconnect)\n }\n\n emitter.connect =\n emitter.listen = function () {\n this.reconnect = true\n if(emitter.connected) return\n backoffMethod.reset()\n backoffMethod.on('ready', attempt)\n args = [].slice.call(arguments)\n attempt(0, 0)\n return emitter\n }\n\n //force reconnection\n emitter.reconnect = function () {\n if(this.connected)\n return emitter.disconnect()\n \n backoffMethod.reset()\n attempt(0, 0)\n return emitter\n }\n\n emitter.disconnect = function () {\n this.reconnect = false\n if(!emitter.connected) return emitter\n \n else if(emitter._connection)\n emitter._connection.destroy()\n\n emitter.emit('disconnect')\n return emitter\n }\n\n var widget\n emitter.widget = function () {\n if(!widget)\n widget = require('./widget')(emitter)\n return widget\n }\n\n return emitter\n }\n\n}\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/reconnect/inject.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/reconnect/node_modules/backoff/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/reconnect/node_modules/backoff/package.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/reconnect/node_modules/backoff/index.js",Function(['require','module','exports','__dirname','__filename','process','global'],"/*\n * Copyright (c) 2012 Mathieu Turcotte\n * Licensed under the MIT license.\n */\n\nvar Backoff = require('./lib/backoff'),\n FibonacciBackoffStrategy = require('./lib/strategy/fibonacci'),\n ExponentialBackoffStrategy = require('./lib/strategy/exponential');\n\nmodule.exports.Backoff = Backoff;\nmodule.exports.FibonacciStrategy = FibonacciBackoffStrategy;\nmodule.exports.ExponentialStrategy = ExponentialBackoffStrategy;\n\n/**\n * Constructs a Fibonacci backoff.\n * @param options Fibonacci backoff strategy arguments.\n * @see FibonacciBackoffStrategy\n */\nmodule.exports.fibonacci = function(options) {\n return new Backoff(new FibonacciBackoffStrategy(options));\n};\n\n/**\n * Constructs an exponential backoff.\n * @param options Exponential strategy arguments.\n * @see ExponentialBackoffStrategy\n */\nmodule.exports.exponential = function(options) {\n return new Backoff(new ExponentialBackoffStrategy(options));\n};\n\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/reconnect/node_modules/backoff/index.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/reconnect/node_modules/backoff/lib/backoff.js",Function(['require','module','exports','__dirname','__filename','process','global'],"/*\n * Copyright (c) 2012 Mathieu Turcotte\n * Licensed under the MIT license.\n */\n\nvar events = require('events'),\n util = require('util');\n\n/**\n * Backoff driver.\n * @param backoffStrategy Backoff delay generator/strategy.\n * @constructor\n */\nfunction Backoff(backoffStrategy) {\n events.EventEmitter.call(this);\n\n this.backoffStrategy_ = backoffStrategy;\n this.backoffNumber_ = 0;\n this.backoffDelay_ = 0;\n this.timeoutID_ = -1;\n\n this.handlers = {\n backoff: this.onBackoff_.bind(this)\n };\n}\nutil.inherits(Backoff, events.EventEmitter);\n\n/**\n * Starts a backoff operation.\n */\nBackoff.prototype.backoff = function() {\n if (this.timeoutID_ !== -1) {\n throw new Error('Backoff in progress.');\n }\n\n this.backoffDelay_ = this.backoffStrategy_.next();\n this.timeoutID_ = setTimeout(this.handlers.backoff, this.backoffDelay_);\n this.emit('backoff', this.backoffNumber_, this.backoffDelay_);\n};\n\n/**\n * Backoff completion handler.\n * @private\n */\nBackoff.prototype.onBackoff_ = function() {\n this.timeoutID_ = -1;\n this.emit('ready', this.backoffNumber_++, this.backoffDelay_);\n};\n\n/**\n * Stops any backoff operation and resets the backoff\n * delay to its inital value.\n */\nBackoff.prototype.reset = function() {\n this.backoffNumber_ = 0;\n this.backoffStrategy_.reset();\n clearTimeout(this.timeoutID_);\n this.timeoutID_ = -1;\n};\n\nmodule.exports = Backoff;\n\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/reconnect/node_modules/backoff/lib/backoff.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/reconnect/node_modules/backoff/lib/strategy/fibonacci.js",Function(['require','module','exports','__dirname','__filename','process','global'],"/*\n * Copyright (c) 2012 Mathieu Turcotte\n * Licensed under the MIT license.\n */\n\nvar util = require('util');\n\nvar BackoffStrategy = require('./strategy');\n\n/**\n * Fibonacci backoff strategy.\n * @extends BackoffStrategy\n */\nfunction FibonacciBackoffStrategy(options) {\n BackoffStrategy.call(this, options);\n this.backoffDelay_ = 0;\n this.nextBackoffDelay_ = this.getInitialDelay();\n}\nutil.inherits(FibonacciBackoffStrategy, BackoffStrategy);\n\n/** @inheritDoc */\nFibonacciBackoffStrategy.prototype.next_ = function() {\n var backoffDelay = Math.min(this.nextBackoffDelay_, this.getMaxDelay());\n this.nextBackoffDelay_ += this.backoffDelay_;\n this.backoffDelay_ = backoffDelay;\n return backoffDelay;\n};\n\n/** @inheritDoc */\nFibonacciBackoffStrategy.prototype.reset_ = function() {\n this.nextBackoffDelay_ = this.getInitialDelay();\n this.backoffDelay_ = 0;\n};\n\nmodule.exports = FibonacciBackoffStrategy;\n\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/reconnect/node_modules/backoff/lib/strategy/fibonacci.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/reconnect/node_modules/backoff/lib/strategy/strategy.js",Function(['require','module','exports','__dirname','__filename','process','global'],"/*\n * Copyright (c) 2012 Mathieu Turcotte\n * Licensed under the MIT license.\n */\n\nvar events = require('events'),\n util = require('util');\n\nfunction isDef(value) {\n return value !== undefined && value !== null;\n}\n\n/**\n * Abstract class defining the skeleton for all backoff strategies.\n * @param options Backoff strategy options.\n * @param options.randomisationFactor The randomisation factor, must be between\n * 0 and 1.\n * @param options.initialDelay The backoff initial delay, in milliseconds.\n * @param options.maxDelay The backoff maximal delay, in milliseconds.\n * @constructor\n */\nfunction BackoffStrategy(options) {\n options = options || {};\n\n if (isDef(options.initialDelay) && options.initialDelay < 1) {\n throw new Error('The initial timeout must be greater than 0.');\n } else if (isDef(options.maxDelay) && options.maxDelay < 1) {\n throw new Error('The maximal timeout must be greater than 0.');\n }\n\n this.initialDelay_ = options.initialDelay || 100;\n this.maxDelay_ = options.maxDelay || 10000;\n\n if (this.maxDelay_ <= this.initialDelay_) {\n throw new Error('The maximal backoff delay must be ' +\n 'greater than the initial backoff delay.');\n }\n\n if (isDef(options.randomisationFactor) &&\n (options.randomisationFactor < 0 || options.randomisationFactor > 1)) {\n throw new Error('The randomisation factor must be between 0 and 1.');\n }\n\n this.randomisationFactor_ = options.randomisationFactor || 0;\n}\n\n/**\n * Retrieves the maximal backoff delay.\n * @return The maximal backoff delay.\n */\nBackoffStrategy.prototype.getMaxDelay = function() {\n return this.maxDelay_;\n};\n\n/**\n * Retrieves the initial backoff delay.\n * @return The initial backoff delay.\n */\nBackoffStrategy.prototype.getInitialDelay = function() {\n return this.initialDelay_;\n};\n\n/**\n * Template method that computes the next backoff delay.\n * @return The backoff delay, in milliseconds.\n */\nBackoffStrategy.prototype.next = function() {\n var backoffDelay = this.next_();\n var randomisationMultiple = 1 + Math.random() * this.randomisationFactor_;\n var randomizedDelay = Math.round(backoffDelay * randomisationMultiple);\n return randomizedDelay;\n};\n\n/**\n * Computes the next backoff delay.\n * @return The backoff delay, in milliseconds.\n */\nBackoffStrategy.prototype.next_ = function() {\n throw new Error('BackoffStrategy.next_() unimplemented.');\n};\n\n/**\n * Template method that resets the backoff delay to its initial value.\n */\nBackoffStrategy.prototype.reset = function() {\n this.reset_();\n};\n\n/**\n * Resets the backoff delay to its initial value.\n */\nBackoffStrategy.prototype.reset_ = function() {\n throw new Error('BackoffStrategy.reset_() unimplemented.');\n};\n\nmodule.exports = BackoffStrategy;\n\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/reconnect/node_modules/backoff/lib/strategy/strategy.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/reconnect/node_modules/backoff/lib/strategy/exponential.js",Function(['require','module','exports','__dirname','__filename','process','global'],"/*\n * Copyright (c) 2012 Mathieu Turcotte\n * Licensed under the MIT license.\n */\n\nvar util = require('util');\n\nvar BackoffStrategy = require('./strategy');\n\n/**\n * Exponential backoff strategy.\n * @extends BackoffStrategy\n */\nfunction ExponentialBackoffStrategy(options) {\n BackoffStrategy.call(this, options);\n this.backoffDelay_ = 0;\n this.nextBackoffDelay_ = this.getInitialDelay();\n}\nutil.inherits(ExponentialBackoffStrategy, BackoffStrategy);\n\n/** @inheritDoc */\nExponentialBackoffStrategy.prototype.next_ = function() {\n this.backoffDelay_ = Math.min(this.nextBackoffDelay_, this.getMaxDelay());\n this.nextBackoffDelay_ = this.backoffDelay_ * 2;\n return this.backoffDelay_;\n};\n\n/** @inheritDoc */\nExponentialBackoffStrategy.prototype.reset_ = function() {\n this.backoffDelay_ = 0;\n this.nextBackoffDelay_ = this.getInitialDelay();\n};\n\nmodule.exports = ExponentialBackoffStrategy;\n\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/reconnect/node_modules/backoff/lib/strategy/exponential.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/reconnect/widget.js",Function(['require','module','exports','__dirname','__filename','process','global'],"\nvar h = require('h')\n\nmodule.exports = function (emitter) {\n var style = {}\n var el = h('a', {\n href: '#', \n style: style, \n click: function () {\n emitter.connected \n ? emitter.disconnect()\n : emitter.reconnect()\n }\n })\n var int\n emitter.on('reconnect', function (n, d) {\n var delay = Math.round(d / 1000) + 1\n console.log(n, d)\n el.innerText = 'reconnect in ' + delay\n clearInterval(int)\n int = setInterval(function () {\n el.innerText = delay ? 'reconnect in ' + --delay : 'reconnecting...'\n }, 1e3)\n })\n emitter.on('connect', function () {\n el.innerText = 'connected'\n clearInterval(int)\n })\n return el\n}\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/reconnect/widget.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/reconnect/node_modules/h/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/reconnect/node_modules/h/package.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/reconnect/node_modules/h/index.js",Function(['require','module','exports','__dirname','__filename','process','global'],";(function () {\n\nfunction h() {\n var args = [].slice.call(arguments), e = null\n function item (l) {\n \n function parseClass (string) {\n var m = string.split(/([\\.#]?[a-zA-Z0-9_-]+)/)\n m.forEach(function (v) {\n var s = v.substring(1,v.length)\n if(!v) return \n if(!e)\n e = document.createElement(v)\n else if (v[0] === '.')\n e.classList.add(s)\n else if (v[0] === '#')\n e.setAttribute('id', s)\n \n })\n }\n\n if(l == null)\n ;\n else if('string' === typeof l) {\n if(!e)\n parseClass(l)\n else\n e.appendChild(document.createTextNode(l))\n }\n else if('number' === typeof l \n || 'boolean' === typeof l\n || l instanceof Date \n || l instanceof RegExp ) {\n e.appendChild(document.createTextNode(l.toString()))\n }\n else if (Array.isArray(l))\n l.forEach(item)\n else if(l instanceof HTMLElement)\n e.appendChild(l)\n else if ('object' === typeof l) {\n for (var k in l) {\n if('function' === typeof l[k])\n e.addEventListener(k, l[k])\n else if(k === 'style') {\n for (var s in l[k])\n e.style.setProperty(s, l[k][s])\n }\n else\n e.setAttribute(k, l[k])\n }\n }\n }\n while(args.length) {\n item(args.shift())\n }\n return e\n}\n\nif(typeof module === 'object')\n module.exports = h\nelse\n this.h = h\n})()\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/reconnect/node_modules/h/index.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/client-reloader/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {\"browserify\":\"./browser.js\"}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/client-reloader/package.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/client-reloader/browser.js",Function(['require','module','exports','__dirname','__filename','process','global'],"\nvar header = require('header-stream')\n\nvar version\n/**\nTODO\nmore sophisticated reloading, \npass in a package and a semver range...\n**/\nmodule.exports = function (handler) {\n return function (stream) {\n var args = [].slice.call(arguments)\n header(stream).writeHead()\n stream.on('header', function (meta) {\n\n if(!version)\n version = meta.version\n if(meta.version !== version) {\n stream.emit('reload', meta.version, version)\n stream.end()\n\n return window.location.reload(true)\n }\n\n handler.apply(this, args)\n })\n }\n\n}\n\nvar wrap = function (stream, _version) {\n version = _version || version\n stream = header(stream)\n stream.on('header', function (meta) {\n //is it same version as last time?\n if(!version)\n version = meta.version\n if(meta.version !== version) {\n stream.emit('reload', meta.version, version)\n stream.end()\n\n window.location.reload(true)\n }\n })\n return stream\n}\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/client-reloader/browser.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/client-reloader/node_modules/header-stream/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/client-reloader/node_modules/header-stream/package.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/client-reloader/node_modules/header-stream/index.js",Function(['require','module','exports','__dirname','__filename','process','global'],"\n//the first line is header, in JSON format, with no whitespace.\n\nfunction merge (a, b) {\n for (var k in b)\n a[k] = a[k] || b[k]\n}\n\nmodule.exports = \nfunction header (stream) {\n\n var emit = stream.emit\n var write = stream.write\n var soFar = ''\n\n stream.emit = function (event, data) {\n if(event !== 'data')\n return emit.apply(stream, arguments)\n\n soFar += data\n var m\n if(!(m = /\\n/.exec(soFar))) return\n var meta = JSON.parse(soFar.substring(0, m.index))\n //+ 1 to get past the newline\n soFar = soFar.substring(m.index + 1)\n stream.emit = emit\n stream.meta = meta\n stream.emit('header', meta)\n //check that the stream is still readable,\n //it may have been ended during the 'header'\n //event.\n if('' !== soFar && stream.readable)\n stream.emit('data', soFar)\n }\n\n var meta = {}\n\n stream.setHeader = function (key, val) {\n if('string' === typeof key)\n meta[key] = val\n else\n merge(meta, key)\n return stream\n }\n\n stream.writeHead = function (_meta) {\n if(_meta) merge(meta, _meta)\n stream.write = write\n stream.write(JSON.stringify(meta)+'\\n') \n }\n\n stream.write = function (data) {\n stream.writeHead()\n return stream.write(data)\n }\n\n return stream\n}\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/client-reloader/node_modules/header-stream/index.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/mux-demux/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/mux-demux/package.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/mux-demux/index.js",Function(['require','module','exports','__dirname','__filename','process','global'],"'use strict';\n\nvar through = require('through')\n , extend = require('xtend')\n , serializer = require('stream-serializer')\n\nfunction MuxDemux (opts, onConnection) {\n if('function' === typeof opts)\n onConnection = opts, opts = null\n opts = opts || {}\n\n function createID() {\n return (\n Math.random().toString(16).slice(2) +\n Math.random().toString(16).slice(2)\n )\n }\n\n var streams = {}, streamCount = 0\n var md = through(function (data) {\n var id = data.shift()\n var event = data[0]\n var s = streams[id]\n if(!s) {\n if(event == 'close')\n return\n if(event != 'new') \n return outer.emit('unknown', id)\n md.emit('connection', createStream(id, data[1].meta, data[1].opts))\n } \n else if (event === 'pause')\n s.paused = true\n else if (event === 'resume') {\n var p = s.paused\n s.paused = false\n if(p) s.emit('drain')\n }\n else if (event === 'error') {\n var error = data[1]\n if (typeof error === 'string') {\n s.emit('error', new Error(error))\n } else if (typeof error.message === 'string') {\n var e = new Error(error.message)\n extend(e, error)\n s.emit('error', e)\n } else {\n s.emit('error', error)\n }\n }\n else {\n s.emit.apply(s, data)\n }\n })\n\n function destroyAll (_err) {\n md.removeListener('end', destroyAll)\n md.removeListener('error', destroyAll)\n md.removeListener('close', destroyAll)\n var err = _err || new Error ('unexpected disconnection')\n for (var i in streams) {\n var s = streams[i]\n s.destroyed = true\n if (opts.error !== true) {\n s.end()\n } else {\n s.emit('error', err)\n s.destroy()\n }\n }\n }\n\n //end the stream once sub-streams have ended.\n //(waits for them to close, like on a tcp server)\n\n md.pause = function () {}\n md.resume = function () {}\n\n function createStream(id, meta, opts) {\n streamCount ++\n var s = through(function (data) {\n if(!this.writable)\n return outer.emit(\"error\", Error('stream is not writable: ' + id))\n md.emit('data', [s.id, 'data', data])\n }, function () {\n md.emit('data', [s.id, 'end'])\n if (this.readable && !opts.allowHalfOpen && !this.ended) {\n this.emit(\"end\")\n }\n })\n s.pause = function () {\n md.emit('data', [s.id, 'pause'])\n }\n s.resume = function () {\n md.emit('data', [s.id, 'resume'])\n }\n s.error = function (message) {\n md.emit('data', [s.id, 'error', message])\n }\n s.once('close', function () {\n delete streams[id]\n streamCount --\n md.emit('data', [s.id, 'close'])\n if(streamCount === 0)\n md.emit('zero')\n })\n s.writable = opts.writable\n s.readable = opts.readable\n streams[s.id = id] = s\n s.meta = meta\n return s\n }\n\n var outer = serializer(opts.wrapper)(md)\n\n if(md !== outer)\n md.on('connection', function (stream) {\n outer.emit('connection', stream)\n })\n\n outer.close = function (cb) {\n md.once('zero', function () {\n md.emit('end')\n if(cb) cb()\n })\n return this\n }\n\n if(onConnection)\n outer.on('connection', onConnection)\n\n outer.on('connection', function (stream) {\n //if mux-demux recieves a stream but there is nothing to handle it,\n //then return an error to the other side.\n //still trying to think of the best error message.\n if(outer.listeners('connection').length === 1)\n stream.error('remote end lacks connection listener')\n })\n\n var pipe = outer.pipe\n outer.pipe = function (dest, opts) {\n pipe.call(outer, dest, opts)\n md.on('end', destroyAll)\n md.on('close', destroyAll)\n md.on('error', destroyAll)\n return dest\n }\n\n outer.createStream = function (meta, opts) {\n opts = opts || {}\n if (!opts.writable && !opts.readable)\n opts.readable = opts.writable = true\n var s = createStream(createID(), meta, opts)\n var _opts = {writable: opts.readable, readable: opts.writable}\n md.emit('data', [s.id, 'new', {meta: meta, opts: _opts}])\n return s\n }\n outer.createWriteStream = function (meta) {\n return outer.createStream(meta, {writable: true, readable: false})\n }\n outer.createReadStream = function (meta) {\n return outer.createStream(meta, {writable: false, readable: true})\n }\n\n return outer\n}\n\nmodule.exports = MuxDemux\n\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/mux-demux/index.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/through/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {\"main\":\"index.js\"}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/through/package.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/through/index.js",Function(['require','module','exports','__dirname','__filename','process','global'],"var Stream = require('stream')\n\n// through\n//\n// a stream that does nothing but re-emit the input.\n// useful for aggregating a series of changing but not ending streams into one stream)\n\n\n\nexports = module.exports = through\nthrough.through = through\n\n//create a readable writable stream.\n\nfunction through (write, end) {\n write = write || function (data) { this.emit('data', data) }\n end = end || function () { this.emit('end') }\n\n var ended = false, destroyed = false\n var stream = new Stream(), buffer = []\n stream.buffer = buffer\n stream.readable = stream.writable = true\n stream.paused = false \n stream.write = function (data) {\n write.call(this, data)\n return !stream.paused\n }\n\n function drain() {\n while(buffer.length && !stream.paused) {\n var data = buffer.shift()\n if(null === data)\n return stream.emit('end')\n else\n stream.emit('data', data)\n }\n }\n\n stream.queue = function (data) {\n buffer.push(data)\n drain()\n }\n\n //this will be registered as the first 'end' listener\n //must call destroy next tick, to make sure we're after any\n //stream piped from here. \n //this is only a problem if end is not emitted synchronously.\n //a nicer way to do this is to make sure this is the last listener for 'end'\n\n stream.on('end', function () {\n stream.readable = false\n if(!stream.writable)\n process.nextTick(function () {\n stream.destroy()\n })\n })\n\n function _end () {\n stream.writable = false\n end.call(stream)\n if(!stream.readable)\n stream.destroy()\n }\n\n stream.end = function (data) {\n if(ended) return \n ended = true\n if(arguments.length) stream.write(data)\n if(!buffer.length) _end()\n }\n\n stream.destroy = function () {\n if(destroyed) return\n destroyed = true\n ended = true\n buffer.length = 0\n stream.writable = stream.readable = false\n stream.emit('close')\n }\n\n stream.pause = function () {\n if(stream.paused) return\n stream.paused = true\n stream.emit('pause')\n }\n stream.resume = function () {\n if(stream.paused) {\n stream.paused = false\n }\n drain()\n //may have become paused again,\n //as drain emits 'data'.\n if(!stream.paused)\n stream.emit('drain')\n }\n return stream\n}\n\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/through/index.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/mux-demux/node_modules/xtend/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {\"main\":\"index\"}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/mux-demux/node_modules/xtend/package.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/mux-demux/node_modules/xtend/index.js",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = extend\n\nfunction extend(target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i],\n keys = Object.keys(source)\n\n for (var j = 0; j < keys.length; j++) {\n var name = keys[j]\n target[name] = source[name]\n }\n }\n\n return target\n}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/mux-demux/node_modules/xtend/index.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/mux-demux/node_modules/stream-serializer/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/mux-demux/node_modules/stream-serializer/package.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/mux-demux/node_modules/stream-serializer/index.js",Function(['require','module','exports','__dirname','__filename','process','global'],"\nvar EventEmitter = require('events').EventEmitter\n\nexports = module.exports = function (wrapper) {\n\n if('function' == typeof wrapper)\n return wrapper\n \n return exports[wrapper] || exports.json\n}\n\nexports.json = function (stream) {\n\n var write = stream.write\n var soFar = ''\n\n function parse (line) {\n var js\n try {\n js = JSON.parse(line)\n //ignore lines of whitespace...\n } catch (err) { \n return console.error('invalid JSON', line)\n }\n if(js !== undefined)\n write.call(stream, js)\n }\n\n function onData (data) {\n var lines = (soFar + data).split('\\n')\n soFar = lines.pop()\n while(lines.length) {\n parse(lines.shift())\n }\n }\n\n stream.write = onData\n \n var end = stream.end\n\n stream.end = function (data) {\n if(data)\n stream.write(data)\n //if there is any left over...\n if(soFar) {\n parse(soFar)\n }\n return end.call(stream)\n }\n\n stream.emit = function (event, data) {\n\n if(event == 'data') {\n data = JSON.stringify(data) + '\\n'\n }\n //since all stream events only use one argument, this is okay...\n EventEmitter.prototype.emit.call(stream, event, data)\n }\n\n return stream\n// return es.pipeline(es.split(), es.parse(), stream, es.stringify())\n}\n\nexports.raw = function (stream) {\n return stream\n}\n\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/mux-demux/node_modules/stream-serializer/index.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/browser/ui/index.js",Function(['require','module','exports','__dirname','__filename','process','global'],"/*global screen:true*/\nvar uuid = require(\"node-uuid\")\n\nvar World = require(\"./world\")\nvar topBarUI = require(\"./top_bar\")\nvar Editor = require(\"./editor\")\n\n// Hackish name\nvar NAME = require(\"../name\")\n\nmodule.exports = UI\n\nfunction UI(doc) {\n var world = World(doc)\n var source = \"// I am a wizard \\n// self.say(self.id())\" +\n \"\\n// self.say(Object.keys(self))\" +\n \"\\n// self.hear(function (message) {\" +\n \"\\n// self.say(message)\" +\n \"\\n// })\"\n\n var player = {\n id: \"wizard:\" + NAME.name\n , name: NAME.name\n , color: NAME.color\n , type: \"wizard\"\n , dead: false\n }\n\n if (NAME.newPlayer) {\n player.x = 300\n player.y = 240\n player.source = source\n }\n\n var playerRow = doc.add(player)\n var topBar = topBarUI(playerRow)\n\n NAME.on('color', function (c) {\n player.color = c\n doc.set(player.id, player)\n })\n\n setTimeout(function () {\n if (!playerRow.state.source) {\n playerRow.set(\"source\", source)\n }\n }, 3000)\n\n Editor(world)\n\n document.querySelector('#controls').appendChild(topBar.root)\n\n topBar.on(\"name\", function (name) {\n // console.log(\"name\", name)\n playerRow.set(\"displayName\", name)\n })\n}\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/browser/ui/index.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/node-uuid/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {\"main\":\"./uuid.js\"}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/node-uuid/package.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/node-uuid/uuid.js",Function(['require','module','exports','__dirname','__filename','process','global'],"// uuid.js\n//\n// (c) 2010-2012 Robert Kieffer\n// MIT License\n// https://github.com/broofa/node-uuid\n(function() {\n var _global = this;\n\n // Unique ID creation requires a high quality random # generator. We feature\n // detect to determine the best RNG source, normalizing to a function that\n // returns 128-bits of randomness, since that's what's usually required\n var _rng;\n\n // Node.js crypto-based RNG - http://nodejs.org/docs/v0.6.2/api/crypto.html\n //\n // Moderately fast, high quality\n if (typeof(require) == 'function') {\n try {\n var _rb = require('crypto').randomBytes;\n _rng = _rb && function() {return _rb(16);};\n } catch(e) {}\n }\n\n if (!_rng && _global.crypto && crypto.getRandomValues) {\n // WHATWG crypto-based RNG - http://wiki.whatwg.org/wiki/Crypto\n //\n // Moderately fast, high quality\n var _rnds8 = new Uint8Array(16);\n _rng = function whatwgRNG() {\n crypto.getRandomValues(_rnds8);\n return _rnds8;\n };\n }\n\n if (!_rng) {\n // Math.random()-based (RNG)\n //\n // If all else fails, use Math.random(). It's fast, but is of unspecified\n // quality.\n var _rnds = new Array(16);\n _rng = function() {\n for (var i = 0, r; i < 16; i++) {\n if ((i & 0x03) === 0) r = Math.random() * 0x100000000;\n _rnds[i] = r >>> ((i & 0x03) << 3) & 0xff;\n }\n\n return _rnds;\n };\n }\n\n // Buffer class to use\n var BufferClass = typeof(Buffer) == 'function' ? Buffer : Array;\n\n // Maps for number <-> hex string conversion\n var _byteToHex = [];\n var _hexToByte = {};\n for (var i = 0; i < 256; i++) {\n _byteToHex[i] = (i + 0x100).toString(16).substr(1);\n _hexToByte[_byteToHex[i]] = i;\n }\n\n // **`parse()` - Parse a UUID into it's component bytes**\n function parse(s, buf, offset) {\n var i = (buf && offset) || 0, ii = 0;\n\n buf = buf || [];\n s.toLowerCase().replace(/[0-9a-f]{2}/g, function(oct) {\n if (ii < 16) { // Don't overflow!\n buf[i + ii++] = _hexToByte[oct];\n }\n });\n\n // Zero out remaining bytes if string was short\n while (ii < 16) {\n buf[i + ii++] = 0;\n }\n\n return buf;\n }\n\n // **`unparse()` - Convert UUID byte array (ala parse()) into a string**\n function unparse(buf, offset) {\n var i = offset || 0, bth = _byteToHex;\n return bth[buf[i++]] + bth[buf[i++]] +\n bth[buf[i++]] + bth[buf[i++]] + '-' +\n bth[buf[i++]] + bth[buf[i++]] + '-' +\n bth[buf[i++]] + bth[buf[i++]] + '-' +\n bth[buf[i++]] + bth[buf[i++]] + '-' +\n bth[buf[i++]] + bth[buf[i++]] +\n bth[buf[i++]] + bth[buf[i++]] +\n bth[buf[i++]] + bth[buf[i++]];\n }\n\n // **`v1()` - Generate time-based UUID**\n //\n // Inspired by https://github.com/LiosK/UUID.js\n // and http://docs.python.org/library/uuid.html\n\n // random #'s we need to init node and clockseq\n var _seedBytes = _rng();\n\n // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)\n var _nodeId = [\n _seedBytes[0] | 0x01,\n _seedBytes[1], _seedBytes[2], _seedBytes[3], _seedBytes[4], _seedBytes[5]\n ];\n\n // Per 4.2.2, randomize (14 bit) clockseq\n var _clockseq = (_seedBytes[6] << 8 | _seedBytes[7]) & 0x3fff;\n\n // Previous uuid creation time\n var _lastMSecs = 0, _lastNSecs = 0;\n\n // See https://github.com/broofa/node-uuid for API details\n function v1(options, buf, offset) {\n var i = buf && offset || 0;\n var b = buf || [];\n\n options = options || {};\n\n var clockseq = options.clockseq != null ? options.clockseq : _clockseq;\n\n // UUID timestamps are 100 nano-second units since the Gregorian epoch,\n // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so\n // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'\n // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.\n var msecs = options.msecs != null ? options.msecs : new Date().getTime();\n\n // Per 4.2.1.2, use count of uuid's generated during the current clock\n // cycle to simulate higher resolution clock\n var nsecs = options.nsecs != null ? options.nsecs : _lastNSecs + 1;\n\n // Time since last uuid creation (in msecs)\n var dt = (msecs - _lastMSecs) + (nsecs - _lastNSecs)/10000;\n\n // Per 4.2.1.2, Bump clockseq on clock regression\n if (dt < 0 && options.clockseq == null) {\n clockseq = clockseq + 1 & 0x3fff;\n }\n\n // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new\n // time interval\n if ((dt < 0 || msecs > _lastMSecs) && options.nsecs == null) {\n nsecs = 0;\n }\n\n // Per 4.2.1.2 Throw error if too many uuids are requested\n if (nsecs >= 10000) {\n throw new Error('uuid.v1(): Can\\'t create more than 10M uuids/sec');\n }\n\n _lastMSecs = msecs;\n _lastNSecs = nsecs;\n _clockseq = clockseq;\n\n // Per 4.1.4 - Convert from unix epoch to Gregorian epoch\n msecs += 12219292800000;\n\n // `time_low`\n var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;\n b[i++] = tl >>> 24 & 0xff;\n b[i++] = tl >>> 16 & 0xff;\n b[i++] = tl >>> 8 & 0xff;\n b[i++] = tl & 0xff;\n\n // `time_mid`\n var tmh = (msecs / 0x100000000 * 10000) & 0xfffffff;\n b[i++] = tmh >>> 8 & 0xff;\n b[i++] = tmh & 0xff;\n\n // `time_high_and_version`\n b[i++] = tmh >>> 24 & 0xf | 0x10; // include version\n b[i++] = tmh >>> 16 & 0xff;\n\n // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)\n b[i++] = clockseq >>> 8 | 0x80;\n\n // `clock_seq_low`\n b[i++] = clockseq & 0xff;\n\n // `node`\n var node = options.node || _nodeId;\n for (var n = 0; n < 6; n++) {\n b[i + n] = node[n];\n }\n\n return buf ? buf : unparse(b);\n }\n\n // **`v4()` - Generate random UUID**\n\n // See https://github.com/broofa/node-uuid for API details\n function v4(options, buf, offset) {\n // Deprecated - 'format' argument, as supported in v1.2\n var i = buf && offset || 0;\n\n if (typeof(options) == 'string') {\n buf = options == 'binary' ? new BufferClass(16) : null;\n options = null;\n }\n options = options || {};\n\n var rnds = options.random || (options.rng || _rng)();\n\n // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`\n rnds[6] = (rnds[6] & 0x0f) | 0x40;\n rnds[8] = (rnds[8] & 0x3f) | 0x80;\n\n // Copy bytes to buffer, if provided\n if (buf) {\n for (var ii = 0; ii < 16; ii++) {\n buf[i + ii] = rnds[ii];\n }\n }\n\n return buf || unparse(rnds);\n }\n\n // Export public API\n var uuid = v4;\n uuid.v1 = v1;\n uuid.v4 = v4;\n uuid.parse = parse;\n uuid.unparse = unparse;\n uuid.BufferClass = BufferClass;\n\n if (_global.define && define.amd) {\n // Publish as AMD module\n define(function() {return uuid;});\n } else if (typeof(module) != 'undefined' && module.exports) {\n // Publish as node.js module\n module.exports = uuid;\n } else {\n // Publish as global (in browsers)\n var _previousRoot = _global.uuid;\n\n // **`noConflict()` - (browser only) to reset global 'uuid' var**\n uuid.noConflict = function() {\n _global.uuid = _previousRoot;\n return uuid;\n };\n\n _global.uuid = uuid;\n }\n}());\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/node-uuid/uuid.js" | |
)); | |
require.define("crypto",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = require(\"crypto-browserify\")\n//@ sourceURL=crypto" | |
)); | |
require.define("/AppData/Roaming/npm/node_modules/browserify-server/node_modules/browserify/node_modules/crypto-browserify/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {}\n//@ sourceURL=/AppData/Roaming/npm/node_modules/browserify-server/node_modules/browserify/node_modules/crypto-browserify/package.json" | |
)); | |
require.define("/AppData/Roaming/npm/node_modules/browserify-server/node_modules/browserify/node_modules/crypto-browserify/index.js",Function(['require','module','exports','__dirname','__filename','process','global'],"var sha = require('./sha')\nvar rng = require('./rng')\n\nvar algorithms = {\n sha1: {\n hex: sha.hex_sha1,\n binary: sha.b64_sha1,\n ascii: sha.str_sha1\n }\n}\n\nfunction error () {\n var m = [].slice.call(arguments).join(' ')\n throw new Error([\n m,\n 'we accept pull requests',\n 'http://github.com/dominictarr/crypto-browserify'\n ].join('\\n'))\n}\n\nexports.createHash = function (alg) {\n alg = alg || 'sha1'\n if(!algorithms[alg])\n error('algorithm:', alg, 'is not yet supported')\n var s = ''\n var _alg = algorithms[alg]\n return {\n update: function (data) {\n s += data\n return this\n },\n digest: function (enc) {\n enc = enc || 'binary'\n var fn\n if(!(fn = _alg[enc]))\n error('encoding:', enc , 'is not yet supported for algorithm', alg)\n var r = fn(s)\n s = null //not meant to use the hash after you've called digest.\n return r\n }\n }\n}\n\nexports.randomBytes = function(size, callback) {\n if (callback && callback.call) {\n try {\n callback.call(this, undefined, rng(size));\n } catch (err) { callback(err); }\n } else {\n return rng(size);\n }\n}\n\n// the least I can do is make error messages for the rest of the node.js/crypto api.\n;['createCredentials'\n, 'createHmac'\n, 'createCypher'\n, 'createCypheriv'\n, 'createDecipher'\n, 'createDecipheriv'\n, 'createSign'\n, 'createVerify'\n, 'createDeffieHellman'\n, 'pbkdf2'].forEach(function (name) {\n exports[name] = function () {\n error('sorry,', name, 'is not implemented yet')\n }\n})\n\n//@ sourceURL=/AppData/Roaming/npm/node_modules/browserify-server/node_modules/browserify/node_modules/crypto-browserify/index.js" | |
)); | |
require.define("/AppData/Roaming/npm/node_modules/browserify-server/node_modules/browserify/node_modules/crypto-browserify/sha.js",Function(['require','module','exports','__dirname','__filename','process','global'],"/*\n * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined\n * in FIPS PUB 180-1\n * Version 2.1a Copyright Paul Johnston 2000 - 2002.\n * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet\n * Distributed under the BSD License\n * See http://pajhome.org.uk/crypt/md5 for details.\n */\n\nexports.hex_sha1 = hex_sha1;\nexports.b64_sha1 = b64_sha1;\nexports.str_sha1 = str_sha1;\nexports.hex_hmac_sha1 = hex_hmac_sha1;\nexports.b64_hmac_sha1 = b64_hmac_sha1;\nexports.str_hmac_sha1 = str_hmac_sha1;\n\n/*\n * Configurable variables. You may need to tweak these to be compatible with\n * the server-side, but the defaults work in most cases.\n */\nvar hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */\nvar b64pad = \"\"; /* base-64 pad character. \"=\" for strict RFC compliance */\nvar chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */\n\n/*\n * These are the functions you'll usually want to call\n * They take string arguments and return either hex or base-64 encoded strings\n */\nfunction hex_sha1(s){return binb2hex(core_sha1(str2binb(s),s.length * chrsz));}\nfunction b64_sha1(s){return binb2b64(core_sha1(str2binb(s),s.length * chrsz));}\nfunction str_sha1(s){return binb2str(core_sha1(str2binb(s),s.length * chrsz));}\nfunction hex_hmac_sha1(key, data){ return binb2hex(core_hmac_sha1(key, data));}\nfunction b64_hmac_sha1(key, data){ return binb2b64(core_hmac_sha1(key, data));}\nfunction str_hmac_sha1(key, data){ return binb2str(core_hmac_sha1(key, data));}\n\n/*\n * Perform a simple self-test to see if the VM is working\n */\nfunction sha1_vm_test()\n{\n return hex_sha1(\"abc\") == \"a9993e364706816aba3e25717850c26c9cd0d89d\";\n}\n\n/*\n * Calculate the SHA-1 of an array of big-endian words, and a bit length\n */\nfunction core_sha1(x, len)\n{\n /* append padding */\n x[len >> 5] |= 0x80 << (24 - len % 32);\n x[((len + 64 >> 9) << 4) + 15] = len;\n\n var w = Array(80);\n var a = 1732584193;\n var b = -271733879;\n var c = -1732584194;\n var d = 271733878;\n var e = -1009589776;\n\n for(var i = 0; i < x.length; i += 16)\n {\n var olda = a;\n var oldb = b;\n var oldc = c;\n var oldd = d;\n var olde = e;\n\n for(var j = 0; j < 80; j++)\n {\n if(j < 16) w[j] = x[i + j];\n else w[j] = rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1);\n var t = safe_add(safe_add(rol(a, 5), sha1_ft(j, b, c, d)),\n safe_add(safe_add(e, w[j]), sha1_kt(j)));\n e = d;\n d = c;\n c = rol(b, 30);\n b = a;\n a = t;\n }\n\n a = safe_add(a, olda);\n b = safe_add(b, oldb);\n c = safe_add(c, oldc);\n d = safe_add(d, oldd);\n e = safe_add(e, olde);\n }\n return Array(a, b, c, d, e);\n\n}\n\n/*\n * Perform the appropriate triplet combination function for the current\n * iteration\n */\nfunction sha1_ft(t, b, c, d)\n{\n if(t < 20) return (b & c) | ((~b) & d);\n if(t < 40) return b ^ c ^ d;\n if(t < 60) return (b & c) | (b & d) | (c & d);\n return b ^ c ^ d;\n}\n\n/*\n * Determine the appropriate additive constant for the current iteration\n */\nfunction sha1_kt(t)\n{\n return (t < 20) ? 1518500249 : (t < 40) ? 1859775393 :\n (t < 60) ? -1894007588 : -899497514;\n}\n\n/*\n * Calculate the HMAC-SHA1 of a key and some data\n */\nfunction core_hmac_sha1(key, data)\n{\n var bkey = str2binb(key);\n if(bkey.length > 16) bkey = core_sha1(bkey, key.length * chrsz);\n\n var ipad = Array(16), opad = Array(16);\n for(var i = 0; i < 16; i++)\n {\n ipad[i] = bkey[i] ^ 0x36363636;\n opad[i] = bkey[i] ^ 0x5C5C5C5C;\n }\n\n var hash = core_sha1(ipad.concat(str2binb(data)), 512 + data.length * chrsz);\n return core_sha1(opad.concat(hash), 512 + 160);\n}\n\n/*\n * Add integers, wrapping at 2^32. This uses 16-bit operations internally\n * to work around bugs in some JS interpreters.\n */\nfunction safe_add(x, y)\n{\n var lsw = (x & 0xFFFF) + (y & 0xFFFF);\n var msw = (x >> 16) + (y >> 16) + (lsw >> 16);\n return (msw << 16) | (lsw & 0xFFFF);\n}\n\n/*\n * Bitwise rotate a 32-bit number to the left.\n */\nfunction rol(num, cnt)\n{\n return (num << cnt) | (num >>> (32 - cnt));\n}\n\n/*\n * Convert an 8-bit or 16-bit string to an array of big-endian words\n * In 8-bit function, characters >255 have their hi-byte silently ignored.\n */\nfunction str2binb(str)\n{\n var bin = Array();\n var mask = (1 << chrsz) - 1;\n for(var i = 0; i < str.length * chrsz; i += chrsz)\n bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (32 - chrsz - i%32);\n return bin;\n}\n\n/*\n * Convert an array of big-endian words to a string\n */\nfunction binb2str(bin)\n{\n var str = \"\";\n var mask = (1 << chrsz) - 1;\n for(var i = 0; i < bin.length * 32; i += chrsz)\n str += String.fromCharCode((bin[i>>5] >>> (32 - chrsz - i%32)) & mask);\n return str;\n}\n\n/*\n * Convert an array of big-endian words to a hex string.\n */\nfunction binb2hex(binarray)\n{\n var hex_tab = hexcase ? \"0123456789ABCDEF\" : \"0123456789abcdef\";\n var str = \"\";\n for(var i = 0; i < binarray.length * 4; i++)\n {\n str += hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8+4)) & 0xF) +\n hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8 )) & 0xF);\n }\n return str;\n}\n\n/*\n * Convert an array of big-endian words to a base-64 string\n */\nfunction binb2b64(binarray)\n{\n var tab = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n var str = \"\";\n for(var i = 0; i < binarray.length * 4; i += 3)\n {\n var triplet = (((binarray[i >> 2] >> 8 * (3 - i %4)) & 0xFF) << 16)\n | (((binarray[i+1 >> 2] >> 8 * (3 - (i+1)%4)) & 0xFF) << 8 )\n | ((binarray[i+2 >> 2] >> 8 * (3 - (i+2)%4)) & 0xFF);\n for(var j = 0; j < 4; j++)\n {\n if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;\n else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);\n }\n }\n return str;\n}\n\n\n//@ sourceURL=/AppData/Roaming/npm/node_modules/browserify-server/node_modules/browserify/node_modules/crypto-browserify/sha.js" | |
)); | |
require.define("/AppData/Roaming/npm/node_modules/browserify-server/node_modules/browserify/node_modules/crypto-browserify/rng.js",Function(['require','module','exports','__dirname','__filename','process','global'],"// Original code adapted from Robert Kieffer.\n// details at https://github.com/broofa/node-uuid\n(function() {\n var _global = this;\n\n var mathRNG, whatwgRNG;\n\n // NOTE: Math.random() does not guarantee \"cryptographic quality\"\n mathRNG = function(size) {\n var bytes = new Array(size);\n var r;\n\n for (var i = 0, r; i < size; i++) {\n if ((i & 0x03) == 0) r = Math.random() * 0x100000000;\n bytes[i] = r >>> ((i & 0x03) << 3) & 0xff;\n }\n\n return bytes;\n }\n\n // currently only available in webkit-based browsers.\n if (_global.crypto && crypto.getRandomValues) {\n var _rnds = new Uint32Array(4);\n whatwgRNG = function(size) {\n var bytes = new Array(size);\n crypto.getRandomValues(_rnds);\n\n for (var c = 0 ; c < size; c++) {\n bytes[c] = _rnds[c >> 2] >>> ((c & 0x03) * 8) & 0xff;\n }\n return bytes;\n }\n }\n\n module.exports = whatwgRNG || mathRNG;\n\n}())\n//@ sourceURL=/AppData/Roaming/npm/node_modules/browserify-server/node_modules/browserify/node_modules/crypto-browserify/rng.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/browser/ui/world.js",Function(['require','module','exports','__dirname','__filename','process','global'],"/*global screen:true, name:true*/\nvar screen = require(\"screen\")\nvar Raphael = require(\"raphael-browserify\")\nvar point = require(\"screen/point\")\nvar generator = require(\"point-generator\")\nvar pick = require(\"deck\").pick\nvar uuid = require(\"node-uuid\")\n\nvar entities = require(\"../entities\")\nvar PlayerRepl = require(\"./playerRepl\")\n\n// mother of all hacks\nvar NAME = require(\"../name\")\nvar renderPlayer = require(\"./renderPlayer\")\n\nvar types = [\"tree\", \"rock\", \"monster\"]\n\nmodule.exports = World\n\nfunction World(model) {\n var width = window.innerWidth - 400 - 4\n var height = window.innerHeight - 80 - 4\n var container = document.querySelector('#container')\n container.style.width = width\n container.style.height = height\n\n var paper = Raphael(\n document.querySelector('#container'),\n width, height\n )\n var center = point({ x: width / 2, y: height / 2 })\n var world = screen(center, width, height)\n var gen = generator(world, {\n tick: 10000\n , density: 1\n })\n\n gen.on(\"item\", function (pos) {\n var type = pick(types)\n\n model.add({\n id: type + \"_\" + uuid()\n , x: pos.x\n , y: pos.y\n , type: type\n })\n })\n\n model.on(\"create\", renderEntity)\n for (var id in model.rows)\n renderEntity(model.rows[id])\n\n world.center = center\n return world\n\n function renderEntity(row) {\n\n var state = row.state\n\n if(state.type) ready()\n else row.once(\"change\", ready)\n\n function ready () {\n if (row.state.name === NAME.name) {\n var repl = PlayerRepl(row)\n\n var entity = renderPlayer(paper, center, row)\n row.on('change', function (ch) {\n if (ch.error) world.emit('log', 'error: ' + ch.error)\n if (ch.result) world.emit('log', 'result: ' + ch.result)\n })\n\n entity.on(\"click\", function () {\n world.emit(\"examine\", row)\n })\n setTimeout(function () {\n world.emit(\"examine\", row)\n }, 1000)\n return\n }\n\n if (row.state.dead) {\n return\n }\n\n if (!entities[state.type]) {\n return\n }\n\n create(row.state, state.type, row)\n }\n }\n\n function create(pos, type, row) {\n var absolute = point(pos)\n var relative = world.add(absolute)\n var alive = true\n\n var entity = entities[type](paper, relative, row)\n\n if (entity.node && entity.node.addEventListener) {\n entity.node.addEventListener('click', onclick)\n }\n else entity.on('click', onclick)\n\n function onclick (e) {\n world.emit('examine', row)\n }\n\n row.on(\"change\", function (changes) {\n absolute(changes)\n\n if (changes.dead) {\n alive = false\n entity.cleanup()\n } else if (\n changes.dead === false &&\n alive === false\n ) {\n create(pos, type, row)\n }\n })\n }\n}\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/browser/ui/world.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/screen/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {\"main\":\"index\"}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/screen/package.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/screen/index.js",Function(['require','module','exports','__dirname','__filename','process','global'],"var EventEmitter = require(\"events\").EventEmitter\n , extend = require(\"xtend\")\n\n , point = require(\"./point\")\n\n/*global screen:true*/\nmodule.exports = screen\n\nfunction screen(center, width, height) {\n var list = []\n\n center.on(\"change\", function () {\n list.forEach(function (tuple) {\n calculate.apply(null, tuple)\n })\n })\n\n var s = new EventEmitter()\n s.list = list\n s.center = center\n s.width = width\n s.height = height\n s.add = add\n return s\n\n function add(absolute) {\n var relative = point()\n\n list.push([relative, absolute])\n\n absolute.on(\"change\", function () {\n calculate(relative, absolute)\n })\n\n calculate(relative, absolute)\n\n return relative\n }\n\n function calculate(relative, absolute) {\n relative.x = absolute.x - center.x + (width / 2)\n relative.y = absolute.y - center.y + (height / 2)\n relative.emit(\"change\")\n\n if (0 < relative.x &&\n relative.x < width &&\n 0 < relative.y &&\n relative.y < height\n ) {\n relative.emit(\"visible\")\n relative.state = \"visible\"\n } else {\n relative.emit(\"offscreen\")\n relative.state = \"offscreen\"\n }\n }\n}\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/screen/index.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/screen/node_modules/xtend/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {\"main\":\"index\"}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/screen/node_modules/xtend/package.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/screen/node_modules/xtend/index.js",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = extend\n\nfunction extend(target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i],\n keys = Object.keys(source)\n\n for (var j = 0; j < keys.length; j++) {\n var name = keys[j]\n target[name] = source[name]\n }\n }\n\n return target\n}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/screen/node_modules/xtend/index.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/screen/point.js",Function(['require','module','exports','__dirname','__filename','process','global'],"var EventEmitter = require(\"events\").EventEmitter\n , extend = require(\"xtend\")\n\nmodule.exports = point\n\nfunction point(position) {\n if (position) {\n if (typeof position.x === \"number\") {\n self.x = position.x\n }\n\n if (typeof position.y === \"number\") {\n self.y = position.y\n }\n }\n\n extend(self, EventEmitter.prototype)\n\n return self\n\n function self(update) {\n if (typeof update === \"function\") {\n self.on(\"change\", listener)\n\n if (self.state) {\n self.emit(self.state)\n }\n\n valid(self) && update(self)\n return cleanup\n }\n\n if (typeof update.x === \"number\") {\n self.x = update.x\n }\n\n if (typeof update.y === \"number\") {\n self.y = update.y\n }\n\n self.emit(\"change\")\n\n function listener() {\n valid(self) && update(self)\n }\n\n function cleanup() {\n self.removeListener(\"change\", listener)\n }\n }\n}\n\nfunction valid(point) {\n if (typeof point.x === \"number\" &&\n typeof point.y === \"number\" &&\n !isNaN(point.x) && !isNaN(point.y)\n ) {\n return true\n }\n}\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/screen/point.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/raphael-browserify/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {\"main\":\"raphael-browserify.js\"}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/raphael-browserify/package.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/raphael-browserify/raphael-browserify.js",Function(['require','module','exports','__dirname','__filename','process','global'],"// Browserify modifications by Brenton Partridge, released into the public domain\n\n// BEGIN BROWSERIFY MOD\nvar eve, Raphael = 'foo';\n// END BROWSERIFY MOD\n\n// ┌────────────────────────────────────────────────────────────────────┐ \\\\\n// │ Raphaël 2.1.0 - JavaScript Vector Library │ \\\\\n// ├────────────────────────────────────────────────────────────────────┤ \\\\\n// │ Copyright © 2008-2012 Dmitry Baranovskiy (http://raphaeljs.com) │ \\\\\n// │ Copyright © 2008-2012 Sencha Labs (http://sencha.com) │ \\\\\n// ├────────────────────────────────────────────────────────────────────┤ \\\\\n// │ Licensed under the MIT (http://raphaeljs.com/license.html) license.│ \\\\\n// └────────────────────────────────────────────────────────────────────┘ \\\\\n\n// ┌──────────────────────────────────────────────────────────────────────────────────────┐ \\\\\n// │ Eve 0.3.4 - JavaScript Events Library │ \\\\\n// ├──────────────────────────────────────────────────────────────────────────────────────┤ \\\\\n// │ Copyright (c) 2008-2011 Dmitry Baranovskiy (http://dmitry.baranovskiy.com/) │ \\\\\n// │ Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license. │ \\\\\n// └──────────────────────────────────────────────────────────────────────────────────────┘ \\\\\n\n(function (glob) {\n var version = \"0.3.4\",\n has = \"hasOwnProperty\",\n separator = /[\\.\\/]/,\n wildcard = \"*\",\n fun = function () {},\n numsort = function (a, b) {\n return a - b;\n },\n current_event,\n stop,\n events = {n: {}};\n \n // BROWSERIFY MOD: make eve a top-level-scope variable instead of function-scope.\n eve = function (name, scope) {\n var e = events,\n oldstop = stop,\n args = Array.prototype.slice.call(arguments, 2),\n listeners = eve.listeners(name),\n z = 0,\n f = false,\n l,\n indexed = [],\n queue = {},\n out = [],\n ce = current_event,\n errors = [];\n current_event = name;\n stop = 0;\n for (var i = 0, ii = listeners.length; i < ii; i++) if (\"zIndex\" in listeners[i]) {\n indexed.push(listeners[i].zIndex);\n if (listeners[i].zIndex < 0) {\n queue[listeners[i].zIndex] = listeners[i];\n }\n }\n indexed.sort(numsort);\n while (indexed[z] < 0) {\n l = queue[indexed[z++]];\n out.push(l.apply(scope, args));\n if (stop) {\n stop = oldstop;\n return out;\n }\n }\n for (i = 0; i < ii; i++) {\n l = listeners[i];\n if (\"zIndex\" in l) {\n if (l.zIndex == indexed[z]) {\n out.push(l.apply(scope, args));\n if (stop) {\n break;\n }\n do {\n z++;\n l = queue[indexed[z]];\n l && out.push(l.apply(scope, args));\n if (stop) {\n break;\n }\n } while (l)\n } else {\n queue[l.zIndex] = l;\n }\n } else {\n out.push(l.apply(scope, args));\n if (stop) {\n break;\n }\n }\n }\n stop = oldstop;\n current_event = ce;\n return out.length ? out : null;\n };\n \n eve.listeners = function (name) {\n var names = name.split(separator),\n e = events,\n item,\n items,\n k,\n i,\n ii,\n j,\n jj,\n nes,\n es = [e],\n out = [];\n for (i = 0, ii = names.length; i < ii; i++) {\n nes = [];\n for (j = 0, jj = es.length; j < jj; j++) {\n e = es[j].n;\n items = [e[names[i]], e[wildcard]];\n k = 2;\n while (k--) {\n item = items[k];\n if (item) {\n nes.push(item);\n out = out.concat(item.f || []);\n }\n }\n }\n es = nes;\n }\n return out;\n };\n \n \n eve.on = function (name, f) {\n var names = name.split(separator),\n e = events;\n for (var i = 0, ii = names.length; i < ii; i++) {\n e = e.n;\n !e[names[i]] && (e[names[i]] = {n: {}});\n e = e[names[i]];\n }\n e.f = e.f || [];\n for (i = 0, ii = e.f.length; i < ii; i++) if (e.f[i] == f) {\n return fun;\n }\n e.f.push(f);\n return function (zIndex) {\n if (+zIndex == +zIndex) {\n f.zIndex = +zIndex;\n }\n };\n };\n \n eve.stop = function () {\n stop = 1;\n };\n \n eve.nt = function (subname) {\n if (subname) {\n return new RegExp(\"(?:\\\\.|\\\\/|^)\" + subname + \"(?:\\\\.|\\\\/|$)\").test(current_event);\n }\n return current_event;\n };\n \n \n eve.off = eve.unbind = function (name, f) {\n var names = name.split(separator),\n e,\n key,\n splice,\n i, ii, j, jj,\n cur = [events];\n for (i = 0, ii = names.length; i < ii; i++) {\n for (j = 0; j < cur.length; j += splice.length - 2) {\n splice = [j, 1];\n e = cur[j].n;\n if (names[i] != wildcard) {\n if (e[names[i]]) {\n splice.push(e[names[i]]);\n }\n } else {\n for (key in e) if (e[has](key)) {\n splice.push(e[key]);\n }\n }\n cur.splice.apply(cur, splice);\n }\n }\n for (i = 0, ii = cur.length; i < ii; i++) {\n e = cur[i];\n while (e.n) {\n if (f) {\n if (e.f) {\n for (j = 0, jj = e.f.length; j < jj; j++) if (e.f[j] == f) {\n e.f.splice(j, 1);\n break;\n }\n !e.f.length && delete e.f;\n }\n for (key in e.n) if (e.n[has](key) && e.n[key].f) {\n var funcs = e.n[key].f;\n for (j = 0, jj = funcs.length; j < jj; j++) if (funcs[j] == f) {\n funcs.splice(j, 1);\n break;\n }\n !funcs.length && delete e.n[key].f;\n }\n } else {\n delete e.f;\n for (key in e.n) if (e.n[has](key) && e.n[key].f) {\n delete e.n[key].f;\n }\n }\n e = e.n;\n }\n }\n };\n \n eve.once = function (name, f) {\n var f2 = function () {\n var res = f.apply(this, arguments);\n eve.unbind(name, f2);\n return res;\n };\n return eve.on(name, f2);\n };\n \n eve.version = version;\n eve.toString = function () {\n return \"You are running Eve \" + version;\n };\n // BROWSERIFY MOD: do not set module.exports = eve\n})(this);\n\n\n// ┌─────────────────────────────────────────────────────────────────────┐ \\\\\n// │ \"Raphaël 2.1.0\" - JavaScript Vector Library │ \\\\\n// ├─────────────────────────────────────────────────────────────────────┤ \\\\\n// │ Copyright (c) 2008-2011 Dmitry Baranovskiy (http://raphaeljs.com) │ \\\\\n// │ Copyright (c) 2008-2011 Sencha Labs (http://sencha.com) │ \\\\\n// │ Licensed under the MIT (http://raphaeljs.com/license.html) license. │ \\\\\n// └─────────────────────────────────────────────────────────────────────┘ \\\\\n(function () {\n \n function R(first) {\n if (R.is(first, \"function\")) {\n return loaded ? first() : eve.on(\"raphael.DOMload\", first);\n } else if (R.is(first, array)) {\n return R._engine.create[apply](R, first.splice(0, 3 + R.is(first[0], nu))).add(first);\n } else {\n var args = Array.prototype.slice.call(arguments, 0);\n if (R.is(args[args.length - 1], \"function\")) {\n var f = args.pop();\n return loaded ? f.call(R._engine.create[apply](R, args)) : eve.on(\"raphael.DOMload\", function () {\n f.call(R._engine.create[apply](R, args));\n });\n } else {\n return R._engine.create[apply](R, arguments);\n }\n }\n }\n R.version = \"2.1.0\";\n R.eve = eve;\n var loaded,\n separator = /[, ]+/,\n elements = {circle: 1, rect: 1, path: 1, ellipse: 1, text: 1, image: 1},\n formatrg = /\\{(\\d+)\\}/g,\n proto = \"prototype\",\n has = \"hasOwnProperty\",\n g = (function() {\n var _g = {};\n if (typeof window !== 'undefined') {\n _g.win = window;\n _g.doc = document;\n }\n else if (typeof require !== 'undefined') {\n // Keep browserify from including jsdom.\n eval(\"_g.doc = require('jsdom').jsdom()\");\n _g.win = _g.doc.createWindow();\n _g.win.document = _g.doc;\n _g.doc.implementation.addFeature(\n \"http://www.w3.org/TR/SVG11/feature#BasicStructure\", \"1.1\")\n }\n return _g;\n })(),\n oldRaphael = {\n was: Object.prototype[has].call(g.win, \"Raphael\"),\n is: g.win.Raphael\n },\n Paper = function () {\n \n \n this.ca = this.customAttributes = {};\n },\n paperproto,\n appendChild = \"appendChild\",\n apply = \"apply\",\n concat = \"concat\",\n supportsTouch = \"createTouch\" in g.doc,\n E = \"\",\n S = \" \",\n Str = String,\n split = \"split\",\n events = \"click dblclick mousedown mousemove mouseout mouseover mouseup touchstart touchmove touchend touchcancel\"[split](S),\n touchMap = {\n mousedown: \"touchstart\",\n mousemove: \"touchmove\",\n mouseup: \"touchend\"\n },\n lowerCase = Str.prototype.toLowerCase,\n math = Math,\n mmax = math.max,\n mmin = math.min,\n abs = math.abs,\n pow = math.pow,\n PI = math.PI,\n nu = \"number\",\n string = \"string\",\n array = \"array\",\n toString = \"toString\",\n fillString = \"fill\",\n objectToString = Object.prototype.toString,\n paper = {},\n push = \"push\",\n ISURL = R._ISURL = /^url\\(['\"]?([^\\)]+?)['\"]?\\)$/i,\n colourRegExp = /^\\s*((#[a-f\\d]{6})|(#[a-f\\d]{3})|rgba?\\(\\s*([\\d\\.]+%?\\s*,\\s*[\\d\\.]+%?\\s*,\\s*[\\d\\.]+%?(?:\\s*,\\s*[\\d\\.]+%?)?)\\s*\\)|hsba?\\(\\s*([\\d\\.]+(?:deg|\\xb0|%)?\\s*,\\s*[\\d\\.]+%?\\s*,\\s*[\\d\\.]+(?:%?\\s*,\\s*[\\d\\.]+)?)%?\\s*\\)|hsla?\\(\\s*([\\d\\.]+(?:deg|\\xb0|%)?\\s*,\\s*[\\d\\.]+%?\\s*,\\s*[\\d\\.]+(?:%?\\s*,\\s*[\\d\\.]+)?)%?\\s*\\))\\s*$/i,\n isnan = {\"NaN\": 1, \"Infinity\": 1, \"-Infinity\": 1},\n bezierrg = /^(?:cubic-)?bezier\\(([^,]+),([^,]+),([^,]+),([^\\)]+)\\)/,\n round = math.round,\n setAttribute = \"setAttribute\",\n toFloat = parseFloat,\n toInt = parseInt,\n upperCase = Str.prototype.toUpperCase,\n availableAttrs = R._availableAttrs = {\n \"arrow-end\": \"none\",\n \"arrow-start\": \"none\",\n blur: 0,\n \"clip-rect\": \"0 0 1e9 1e9\",\n cursor: \"default\",\n cx: 0,\n cy: 0,\n fill: \"#fff\",\n \"fill-opacity\": 1,\n font: '10px \"Arial\"',\n \"font-family\": '\"Arial\"',\n \"font-size\": \"10\",\n \"font-style\": \"normal\",\n \"font-weight\": 400,\n gradient: 0,\n height: 0,\n href: \"http://raphaeljs.com/\",\n \"letter-spacing\": 0,\n opacity: 1,\n path: \"M0,0\",\n r: 0,\n rx: 0,\n ry: 0,\n src: \"\",\n stroke: \"#000\",\n \"stroke-dasharray\": \"\",\n \"stroke-linecap\": \"butt\",\n \"stroke-linejoin\": \"butt\",\n \"stroke-miterlimit\": 0,\n \"stroke-opacity\": 1,\n \"stroke-width\": 1,\n target: \"_blank\",\n \"text-anchor\": \"middle\",\n title: \"Raphael\",\n transform: \"\",\n width: 0,\n x: 0,\n y: 0\n },\n availableAnimAttrs = R._availableAnimAttrs = {\n blur: nu,\n \"clip-rect\": \"csv\",\n cx: nu,\n cy: nu,\n fill: \"colour\",\n \"fill-opacity\": nu,\n \"font-size\": nu,\n height: nu,\n opacity: nu,\n path: \"path\",\n r: nu,\n rx: nu,\n ry: nu,\n stroke: \"colour\",\n \"stroke-opacity\": nu,\n \"stroke-width\": nu,\n transform: \"transform\",\n width: nu,\n x: nu,\n y: nu\n },\n whitespace = /[\\x09\\x0a\\x0b\\x0c\\x0d\\x20\\xa0\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000\\u2028\\u2029]/g,\n commaSpaces = /[\\x09\\x0a\\x0b\\x0c\\x0d\\x20\\xa0\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000\\u2028\\u2029]*,[\\x09\\x0a\\x0b\\x0c\\x0d\\x20\\xa0\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000\\u2028\\u2029]*/,\n hsrg = {hs: 1, rg: 1},\n p2s = /,?([achlmqrstvxz]),?/gi,\n pathCommand = /([achlmrqstvz])[\\x09\\x0a\\x0b\\x0c\\x0d\\x20\\xa0\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000\\u2028\\u2029,]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?[\\x09\\x0a\\x0b\\x0c\\x0d\\x20\\xa0\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000\\u2028\\u2029]*,?[\\x09\\x0a\\x0b\\x0c\\x0d\\x20\\xa0\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000\\u2028\\u2029]*)+)/ig,\n tCommand = /([rstm])[\\x09\\x0a\\x0b\\x0c\\x0d\\x20\\xa0\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000\\u2028\\u2029,]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?[\\x09\\x0a\\x0b\\x0c\\x0d\\x20\\xa0\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000\\u2028\\u2029]*,?[\\x09\\x0a\\x0b\\x0c\\x0d\\x20\\xa0\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000\\u2028\\u2029]*)+)/ig,\n pathValues = /(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)[\\x09\\x0a\\x0b\\x0c\\x0d\\x20\\xa0\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000\\u2028\\u2029]*,?[\\x09\\x0a\\x0b\\x0c\\x0d\\x20\\xa0\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000\\u2028\\u2029]*/ig,\n radial_gradient = R._radial_gradient = /^r(?:\\(([^,]+?)[\\x09\\x0a\\x0b\\x0c\\x0d\\x20\\xa0\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000\\u2028\\u2029]*,[\\x09\\x0a\\x0b\\x0c\\x0d\\x20\\xa0\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000\\u2028\\u2029]*([^\\)]+?)\\))?/,\n eldata = {},\n sortByKey = function (a, b) {\n return a.key - b.key;\n },\n sortByNumber = function (a, b) {\n return toFloat(a) - toFloat(b);\n },\n fun = function () {},\n pipe = function (x) {\n return x;\n },\n rectPath = R._rectPath = function (x, y, w, h, r) {\n if (r) {\n return [[\"M\", x + r, y], [\"l\", w - r * 2, 0], [\"a\", r, r, 0, 0, 1, r, r], [\"l\", 0, h - r * 2], [\"a\", r, r, 0, 0, 1, -r, r], [\"l\", r * 2 - w, 0], [\"a\", r, r, 0, 0, 1, -r, -r], [\"l\", 0, r * 2 - h], [\"a\", r, r, 0, 0, 1, r, -r], [\"z\"]];\n }\n return [[\"M\", x, y], [\"l\", w, 0], [\"l\", 0, h], [\"l\", -w, 0], [\"z\"]];\n },\n ellipsePath = function (x, y, rx, ry) {\n if (ry == null) {\n ry = rx;\n }\n return [[\"M\", x, y], [\"m\", 0, -ry], [\"a\", rx, ry, 0, 1, 1, 0, 2 * ry], [\"a\", rx, ry, 0, 1, 1, 0, -2 * ry], [\"z\"]];\n },\n getPath = R._getPath = {\n path: function (el) {\n return el.attr(\"path\");\n },\n circle: function (el) {\n var a = el.attrs;\n return ellipsePath(a.cx, a.cy, a.r);\n },\n ellipse: function (el) {\n var a = el.attrs;\n return ellipsePath(a.cx, a.cy, a.rx, a.ry);\n },\n rect: function (el) {\n var a = el.attrs;\n return rectPath(a.x, a.y, a.width, a.height, a.r);\n },\n image: function (el) {\n var a = el.attrs;\n return rectPath(a.x, a.y, a.width, a.height);\n },\n text: function (el) {\n var bbox = el._getBBox();\n return rectPath(bbox.x, bbox.y, bbox.width, bbox.height);\n }\n },\n \n mapPath = R.mapPath = function (path, matrix) {\n if (!matrix) {\n return path;\n }\n var x, y, i, j, ii, jj, pathi;\n path = path2curve(path);\n for (i = 0, ii = path.length; i < ii; i++) {\n pathi = path[i];\n for (j = 1, jj = pathi.length; j < jj; j += 2) {\n x = matrix.x(pathi[j], pathi[j + 1]);\n y = matrix.y(pathi[j], pathi[j + 1]);\n pathi[j] = x;\n pathi[j + 1] = y;\n }\n }\n return path;\n };\n\n R._g = g;\n \n \n R.type = (g.win.SVGAngle || g.doc.implementation.hasFeature(\"http://www.w3.org/TR/SVG11/feature#BasicStructure\", \"1.1\") ? \"SVG\" : \"VML\");\n if (R.type == \"VML\") {\n var d = g.doc.createElement(\"div\"),\n b;\n d.innerHTML = '<v:shape adj=\"1\"/>';\n b = d.firstChild;\n b.style.behavior = \"url(#default#VML)\";\n if (!(b && typeof b.adj == \"object\")) {\n return (R.type = E);\n }\n d = null;\n }\n\n \n R.svg = !(R.vml = R.type == \"VML\");\n R._Paper = Paper;\n \n R.fn = paperproto = Paper.prototype = R.prototype;\n R._id = 0;\n R._oid = 0;\n \n R.is = function (o, type) {\n type = lowerCase.call(type);\n if (type == \"finite\") {\n return !isnan[has](+o);\n }\n if (type == \"array\") {\n return o instanceof Array;\n }\n return (type == \"null\" && o === null) ||\n (type == typeof o && o !== null) ||\n (type == \"object\" && o === Object(o)) ||\n (type == \"array\" && Array.isArray && Array.isArray(o)) ||\n objectToString.call(o).slice(8, -1).toLowerCase() == type;\n };\n\n function clone(obj) {\n if (Object(obj) !== obj) {\n return obj;\n }\n var res = new obj.constructor;\n for (var key in obj) if (obj[has](key)) {\n res[key] = clone(obj[key]);\n }\n return res;\n }\n\n \n R.angle = function (x1, y1, x2, y2, x3, y3) {\n if (x3 == null) {\n var x = x1 - x2,\n y = y1 - y2;\n if (!x && !y) {\n return 0;\n }\n return (180 + math.atan2(-y, -x) * 180 / PI + 360) % 360;\n } else {\n return R.angle(x1, y1, x3, y3) - R.angle(x2, y2, x3, y3);\n }\n };\n \n R.rad = function (deg) {\n return deg % 360 * PI / 180;\n };\n \n R.deg = function (rad) {\n return rad * 180 / PI % 360;\n };\n \n R.snapTo = function (values, value, tolerance) {\n tolerance = R.is(tolerance, \"finite\") ? tolerance : 10;\n if (R.is(values, array)) {\n var i = values.length;\n while (i--) if (abs(values[i] - value) <= tolerance) {\n return values[i];\n }\n } else {\n values = +values;\n var rem = value % values;\n if (rem < tolerance) {\n return value - rem;\n }\n if (rem > values - tolerance) {\n return value - rem + values;\n }\n }\n return value;\n };\n \n \n var createUUID = R.createUUID = (function (uuidRegEx, uuidReplacer) {\n return function () {\n return \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\".replace(uuidRegEx, uuidReplacer).toUpperCase();\n };\n })(/[xy]/g, function (c) {\n var r = math.random() * 16 | 0,\n v = c == \"x\" ? r : (r & 3 | 8);\n return v.toString(16);\n });\n\n \n R.setWindow = function (newwin) {\n eve(\"raphael.setWindow\", R, g.win, newwin);\n g.win = newwin;\n g.doc = g.win.document;\n if (R._engine.initWin) {\n R._engine.initWin(g.win);\n }\n };\n var toHex = function (color) {\n if (R.vml) {\n // http://dean.edwards.name/weblog/2009/10/convert-any-colour-value-to-hex-in-msie/\n var trim = /^\\s+|\\s+$/g;\n var bod;\n try {\n var docum = new ActiveXObject(\"htmlfile\");\n docum.write(\"<body>\");\n docum.close();\n bod = docum.body;\n } catch(e) {\n bod = createPopup().document.body;\n }\n var range = bod.createTextRange();\n toHex = cacher(function (color) {\n try {\n bod.style.color = Str(color).replace(trim, E);\n var value = range.queryCommandValue(\"ForeColor\");\n value = ((value & 255) << 16) | (value & 65280) | ((value & 16711680) >>> 16);\n return \"#\" + (\"000000\" + value.toString(16)).slice(-6);\n } catch(e) {\n return \"none\";\n }\n });\n } else {\n var i = g.doc.createElement(\"i\");\n i.title = \"Rapha\\xebl Colour Picker\";\n i.style.display = \"none\";\n g.doc.body.appendChild(i);\n toHex = cacher(function (color) {\n i.style.color = color;\n return g.doc.defaultView.getComputedStyle(i, E).getPropertyValue(\"color\");\n });\n }\n return toHex(color);\n },\n hsbtoString = function () {\n return \"hsb(\" + [this.h, this.s, this.b] + \")\";\n },\n hsltoString = function () {\n return \"hsl(\" + [this.h, this.s, this.l] + \")\";\n },\n rgbtoString = function () {\n return this.hex;\n },\n prepareRGB = function (r, g, b) {\n if (g == null && R.is(r, \"object\") && \"r\" in r && \"g\" in r && \"b\" in r) {\n b = r.b;\n g = r.g;\n r = r.r;\n }\n if (g == null && R.is(r, string)) {\n var clr = R.getRGB(r);\n r = clr.r;\n g = clr.g;\n b = clr.b;\n }\n if (r > 1 || g > 1 || b > 1) {\n r /= 255;\n g /= 255;\n b /= 255;\n }\n \n return [r, g, b];\n },\n packageRGB = function (r, g, b, o) {\n r *= 255;\n g *= 255;\n b *= 255;\n var rgb = {\n r: r,\n g: g,\n b: b,\n hex: R.rgb(r, g, b),\n toString: rgbtoString\n };\n R.is(o, \"finite\") && (rgb.opacity = o);\n return rgb;\n };\n \n \n R.color = function (clr) {\n var rgb;\n if (R.is(clr, \"object\") && \"h\" in clr && \"s\" in clr && \"b\" in clr) {\n rgb = R.hsb2rgb(clr);\n clr.r = rgb.r;\n clr.g = rgb.g;\n clr.b = rgb.b;\n clr.hex = rgb.hex;\n } else if (R.is(clr, \"object\") && \"h\" in clr && \"s\" in clr && \"l\" in clr) {\n rgb = R.hsl2rgb(clr);\n clr.r = rgb.r;\n clr.g = rgb.g;\n clr.b = rgb.b;\n clr.hex = rgb.hex;\n } else {\n if (R.is(clr, \"string\")) {\n clr = R.getRGB(clr);\n }\n if (R.is(clr, \"object\") && \"r\" in clr && \"g\" in clr && \"b\" in clr) {\n rgb = R.rgb2hsl(clr);\n clr.h = rgb.h;\n clr.s = rgb.s;\n clr.l = rgb.l;\n rgb = R.rgb2hsb(clr);\n clr.v = rgb.b;\n } else {\n clr = {hex: \"none\"};\n clr.r = clr.g = clr.b = clr.h = clr.s = clr.v = clr.l = -1;\n }\n }\n clr.toString = rgbtoString;\n return clr;\n };\n \n R.hsb2rgb = function (h, s, v, o) {\n if (this.is(h, \"object\") && \"h\" in h && \"s\" in h && \"b\" in h) {\n v = h.b;\n s = h.s;\n h = h.h;\n o = h.o;\n }\n h *= 360;\n var R, G, B, X, C;\n h = (h % 360) / 60;\n C = v * s;\n X = C * (1 - abs(h % 2 - 1));\n R = G = B = v - C;\n\n h = ~~h;\n R += [C, X, 0, 0, X, C][h];\n G += [X, C, C, X, 0, 0][h];\n B += [0, 0, X, C, C, X][h];\n return packageRGB(R, G, B, o);\n };\n \n R.hsl2rgb = function (h, s, l, o) {\n if (this.is(h, \"object\") && \"h\" in h && \"s\" in h && \"l\" in h) {\n l = h.l;\n s = h.s;\n h = h.h;\n }\n if (h > 1 || s > 1 || l > 1) {\n h /= 360;\n s /= 100;\n l /= 100;\n }\n h *= 360;\n var R, G, B, X, C;\n h = (h % 360) / 60;\n C = 2 * s * (l < .5 ? l : 1 - l);\n X = C * (1 - abs(h % 2 - 1));\n R = G = B = l - C / 2;\n\n h = ~~h;\n R += [C, X, 0, 0, X, C][h];\n G += [X, C, C, X, 0, 0][h];\n B += [0, 0, X, C, C, X][h];\n return packageRGB(R, G, B, o);\n };\n \n R.rgb2hsb = function (r, g, b) {\n b = prepareRGB(r, g, b);\n r = b[0];\n g = b[1];\n b = b[2];\n\n var H, S, V, C;\n V = mmax(r, g, b);\n C = V - mmin(r, g, b);\n H = (C == 0 ? null :\n V == r ? (g - b) / C :\n V == g ? (b - r) / C + 2 :\n (r - g) / C + 4\n );\n H = ((H + 360) % 6) * 60 / 360;\n S = C == 0 ? 0 : C / V;\n return {h: H, s: S, b: V, toString: hsbtoString};\n };\n \n R.rgb2hsl = function (r, g, b) {\n b = prepareRGB(r, g, b);\n r = b[0];\n g = b[1];\n b = b[2];\n\n var H, S, L, M, m, C;\n M = mmax(r, g, b);\n m = mmin(r, g, b);\n C = M - m;\n H = (C == 0 ? null :\n M == r ? (g - b) / C :\n M == g ? (b - r) / C + 2 :\n (r - g) / C + 4);\n H = ((H + 360) % 6) * 60 / 360;\n L = (M + m) / 2;\n S = (C == 0 ? 0 :\n L < .5 ? C / (2 * L) :\n C / (2 - 2 * L));\n return {h: H, s: S, l: L, toString: hsltoString};\n };\n R._path2string = function () {\n return this.join(\",\").replace(p2s, \"$1\");\n };\n function repush(array, item) {\n for (var i = 0, ii = array.length; i < ii; i++) if (array[i] === item) {\n return array.push(array.splice(i, 1)[0]);\n }\n }\n function cacher(f, scope, postprocessor) {\n function newf() {\n var arg = Array.prototype.slice.call(arguments, 0),\n args = arg.join(\"\\u2400\"),\n cache = newf.cache = newf.cache || {},\n count = newf.count = newf.count || [];\n if (cache[has](args)) {\n repush(count, args);\n return postprocessor ? postprocessor(cache[args]) : cache[args];\n }\n count.length >= 1e3 && delete cache[count.shift()];\n count.push(args);\n cache[args] = f[apply](scope, arg);\n return postprocessor ? postprocessor(cache[args]) : cache[args];\n }\n return newf;\n }\n\n var preload = R._preload = function (src, f) {\n var img = g.doc.createElement(\"img\");\n img.style.cssText = \"position:absolute;left:-9999em;top:-9999em\";\n img.onload = function () {\n f.call(this);\n this.onload = null;\n g.doc.body.removeChild(this);\n };\n img.onerror = function () {\n g.doc.body.removeChild(this);\n };\n g.doc.body.appendChild(img);\n img.src = src;\n };\n \n function clrToString() {\n return this.hex;\n }\n\n \n R.getRGB = cacher(function (colour) {\n if (!colour || !!((colour = Str(colour)).indexOf(\"-\") + 1)) {\n return {r: -1, g: -1, b: -1, hex: \"none\", error: 1, toString: clrToString};\n }\n if (colour == \"none\") {\n return {r: -1, g: -1, b: -1, hex: \"none\", toString: clrToString};\n }\n !(hsrg[has](colour.toLowerCase().substring(0, 2)) || colour.charAt() == \"#\") && (colour = toHex(colour));\n var res,\n red,\n green,\n blue,\n opacity,\n t,\n values,\n rgb = colour.match(colourRegExp);\n if (rgb) {\n if (rgb[2]) {\n blue = toInt(rgb[2].substring(5), 16);\n green = toInt(rgb[2].substring(3, 5), 16);\n red = toInt(rgb[2].substring(1, 3), 16);\n }\n if (rgb[3]) {\n blue = toInt((t = rgb[3].charAt(3)) + t, 16);\n green = toInt((t = rgb[3].charAt(2)) + t, 16);\n red = toInt((t = rgb[3].charAt(1)) + t, 16);\n }\n if (rgb[4]) {\n values = rgb[4][split](commaSpaces);\n red = toFloat(values[0]);\n values[0].slice(-1) == \"%\" && (red *= 2.55);\n green = toFloat(values[1]);\n values[1].slice(-1) == \"%\" && (green *= 2.55);\n blue = toFloat(values[2]);\n values[2].slice(-1) == \"%\" && (blue *= 2.55);\n rgb[1].toLowerCase().slice(0, 4) == \"rgba\" && (opacity = toFloat(values[3]));\n values[3] && values[3].slice(-1) == \"%\" && (opacity /= 100);\n }\n if (rgb[5]) {\n values = rgb[5][split](commaSpaces);\n red = toFloat(values[0]);\n values[0].slice(-1) == \"%\" && (red *= 2.55);\n green = toFloat(values[1]);\n values[1].slice(-1) == \"%\" && (green *= 2.55);\n blue = toFloat(values[2]);\n values[2].slice(-1) == \"%\" && (blue *= 2.55);\n (values[0].slice(-3) == \"deg\" || values[0].slice(-1) == \"\\xb0\") && (red /= 360);\n rgb[1].toLowerCase().slice(0, 4) == \"hsba\" && (opacity = toFloat(values[3]));\n values[3] && values[3].slice(-1) == \"%\" && (opacity /= 100);\n return R.hsb2rgb(red, green, blue, opacity);\n }\n if (rgb[6]) {\n values = rgb[6][split](commaSpaces);\n red = toFloat(values[0]);\n values[0].slice(-1) == \"%\" && (red *= 2.55);\n green = toFloat(values[1]);\n values[1].slice(-1) == \"%\" && (green *= 2.55);\n blue = toFloat(values[2]);\n values[2].slice(-1) == \"%\" && (blue *= 2.55);\n (values[0].slice(-3) == \"deg\" || values[0].slice(-1) == \"\\xb0\") && (red /= 360);\n rgb[1].toLowerCase().slice(0, 4) == \"hsla\" && (opacity = toFloat(values[3]));\n values[3] && values[3].slice(-1) == \"%\" && (opacity /= 100);\n return R.hsl2rgb(red, green, blue, opacity);\n }\n rgb = {r: red, g: green, b: blue, toString: clrToString};\n rgb.hex = \"#\" + (16777216 | blue | (green << 8) | (red << 16)).toString(16).slice(1);\n R.is(opacity, \"finite\") && (rgb.opacity = opacity);\n return rgb;\n }\n return {r: -1, g: -1, b: -1, hex: \"none\", error: 1, toString: clrToString};\n }, R);\n \n R.hsb = cacher(function (h, s, b) {\n return R.hsb2rgb(h, s, b).hex;\n });\n \n R.hsl = cacher(function (h, s, l) {\n return R.hsl2rgb(h, s, l).hex;\n });\n \n R.rgb = cacher(function (r, g, b) {\n return \"#\" + (16777216 | b | (g << 8) | (r << 16)).toString(16).slice(1);\n });\n \n R.getColor = function (value) {\n var start = this.getColor.start = this.getColor.start || {h: 0, s: 1, b: value || .75},\n rgb = this.hsb2rgb(start.h, start.s, start.b);\n start.h += .075;\n if (start.h > 1) {\n start.h = 0;\n start.s -= .2;\n start.s <= 0 && (this.getColor.start = {h: 0, s: 1, b: start.b});\n }\n return rgb.hex;\n };\n \n R.getColor.reset = function () {\n delete this.start;\n };\n\n // http://schepers.cc/getting-to-the-point\n function catmullRom2bezier(crp, z) {\n var d = [];\n for (var i = 0, iLen = crp.length; iLen - 2 * !z > i; i += 2) {\n var p = [\n {x: +crp[i - 2], y: +crp[i - 1]},\n {x: +crp[i], y: +crp[i + 1]},\n {x: +crp[i + 2], y: +crp[i + 3]},\n {x: +crp[i + 4], y: +crp[i + 5]}\n ];\n if (z) {\n if (!i) {\n p[0] = {x: +crp[iLen - 2], y: +crp[iLen - 1]};\n } else if (iLen - 4 == i) {\n p[3] = {x: +crp[0], y: +crp[1]};\n } else if (iLen - 2 == i) {\n p[2] = {x: +crp[0], y: +crp[1]};\n p[3] = {x: +crp[2], y: +crp[3]};\n }\n } else {\n if (iLen - 4 == i) {\n p[3] = p[2];\n } else if (!i) {\n p[0] = {x: +crp[i], y: +crp[i + 1]};\n }\n }\n d.push([\"C\",\n (-p[0].x + 6 * p[1].x + p[2].x) / 6,\n (-p[0].y + 6 * p[1].y + p[2].y) / 6,\n (p[1].x + 6 * p[2].x - p[3].x) / 6,\n (p[1].y + 6*p[2].y - p[3].y) / 6,\n p[2].x,\n p[2].y\n ]);\n }\n\n return d;\n }\n \n R.parsePathString = function (pathString) {\n if (!pathString) {\n return null;\n }\n var pth = paths(pathString);\n if (pth.arr) {\n return pathClone(pth.arr);\n }\n \n var paramCounts = {a: 7, c: 6, h: 1, l: 2, m: 2, r: 4, q: 4, s: 4, t: 2, v: 1, z: 0},\n data = [];\n if (R.is(pathString, array) && R.is(pathString[0], array)) { // rough assumption\n data = pathClone(pathString);\n }\n if (!data.length) {\n Str(pathString).replace(pathCommand, function (a, b, c) {\n var params = [],\n name = b.toLowerCase();\n c.replace(pathValues, function (a, b) {\n b && params.push(+b);\n });\n if (name == \"m\" && params.length > 2) {\n data.push([b][concat](params.splice(0, 2)));\n name = \"l\";\n b = b == \"m\" ? \"l\" : \"L\";\n }\n if (name == \"r\") {\n data.push([b][concat](params));\n } else while (params.length >= paramCounts[name]) {\n data.push([b][concat](params.splice(0, paramCounts[name])));\n if (!paramCounts[name]) {\n break;\n }\n }\n });\n }\n data.toString = R._path2string;\n pth.arr = pathClone(data);\n return data;\n };\n \n R.parseTransformString = cacher(function (TString) {\n if (!TString) {\n return null;\n }\n var paramCounts = {r: 3, s: 4, t: 2, m: 6},\n data = [];\n if (R.is(TString, array) && R.is(TString[0], array)) { // rough assumption\n data = pathClone(TString);\n }\n if (!data.length) {\n Str(TString).replace(tCommand, function (a, b, c) {\n var params = [],\n name = lowerCase.call(b);\n c.replace(pathValues, function (a, b) {\n b && params.push(+b);\n });\n data.push([b][concat](params));\n });\n }\n data.toString = R._path2string;\n return data;\n });\n // PATHS\n var paths = function (ps) {\n var p = paths.ps = paths.ps || {};\n if (p[ps]) {\n p[ps].sleep = 100;\n } else {\n p[ps] = {\n sleep: 100\n };\n }\n setTimeout(function () {\n for (var key in p) if (p[has](key) && key != ps) {\n p[key].sleep--;\n !p[key].sleep && delete p[key];\n }\n });\n return p[ps];\n };\n \n R.findDotsAtSegment = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) {\n var t1 = 1 - t,\n t13 = pow(t1, 3),\n t12 = pow(t1, 2),\n t2 = t * t,\n t3 = t2 * t,\n x = t13 * p1x + t12 * 3 * t * c1x + t1 * 3 * t * t * c2x + t3 * p2x,\n y = t13 * p1y + t12 * 3 * t * c1y + t1 * 3 * t * t * c2y + t3 * p2y,\n mx = p1x + 2 * t * (c1x - p1x) + t2 * (c2x - 2 * c1x + p1x),\n my = p1y + 2 * t * (c1y - p1y) + t2 * (c2y - 2 * c1y + p1y),\n nx = c1x + 2 * t * (c2x - c1x) + t2 * (p2x - 2 * c2x + c1x),\n ny = c1y + 2 * t * (c2y - c1y) + t2 * (p2y - 2 * c2y + c1y),\n ax = t1 * p1x + t * c1x,\n ay = t1 * p1y + t * c1y,\n cx = t1 * c2x + t * p2x,\n cy = t1 * c2y + t * p2y,\n alpha = (90 - math.atan2(mx - nx, my - ny) * 180 / PI);\n (mx > nx || my < ny) && (alpha += 180);\n return {\n x: x,\n y: y,\n m: {x: mx, y: my},\n n: {x: nx, y: ny},\n start: {x: ax, y: ay},\n end: {x: cx, y: cy},\n alpha: alpha\n };\n };\n \n R.bezierBBox = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) {\n if (!R.is(p1x, \"array\")) {\n p1x = [p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y];\n }\n var bbox = curveDim.apply(null, p1x);\n return {\n x: bbox.min.x,\n y: bbox.min.y,\n x2: bbox.max.x,\n y2: bbox.max.y,\n width: bbox.max.x - bbox.min.x,\n height: bbox.max.y - bbox.min.y\n };\n };\n \n R.isPointInsideBBox = function (bbox, x, y) {\n return x >= bbox.x && x <= bbox.x2 && y >= bbox.y && y <= bbox.y2;\n };\n \n R.isBBoxIntersect = function (bbox1, bbox2) {\n var i = R.isPointInsideBBox;\n return i(bbox2, bbox1.x, bbox1.y)\n || i(bbox2, bbox1.x2, bbox1.y)\n || i(bbox2, bbox1.x, bbox1.y2)\n || i(bbox2, bbox1.x2, bbox1.y2)\n || i(bbox1, bbox2.x, bbox2.y)\n || i(bbox1, bbox2.x2, bbox2.y)\n || i(bbox1, bbox2.x, bbox2.y2)\n || i(bbox1, bbox2.x2, bbox2.y2)\n || (bbox1.x < bbox2.x2 && bbox1.x > bbox2.x || bbox2.x < bbox1.x2 && bbox2.x > bbox1.x)\n && (bbox1.y < bbox2.y2 && bbox1.y > bbox2.y || bbox2.y < bbox1.y2 && bbox2.y > bbox1.y);\n };\n function base3(t, p1, p2, p3, p4) {\n var t1 = -3 * p1 + 9 * p2 - 9 * p3 + 3 * p4,\n t2 = t * t1 + 6 * p1 - 12 * p2 + 6 * p3;\n return t * t2 - 3 * p1 + 3 * p2;\n }\n function bezlen(x1, y1, x2, y2, x3, y3, x4, y4, z) {\n if (z == null) {\n z = 1;\n }\n z = z > 1 ? 1 : z < 0 ? 0 : z;\n var z2 = z / 2,\n n = 12,\n Tvalues = [-0.1252,0.1252,-0.3678,0.3678,-0.5873,0.5873,-0.7699,0.7699,-0.9041,0.9041,-0.9816,0.9816],\n Cvalues = [0.2491,0.2491,0.2335,0.2335,0.2032,0.2032,0.1601,0.1601,0.1069,0.1069,0.0472,0.0472],\n sum = 0;\n for (var i = 0; i < n; i++) {\n var ct = z2 * Tvalues[i] + z2,\n xbase = base3(ct, x1, x2, x3, x4),\n ybase = base3(ct, y1, y2, y3, y4),\n comb = xbase * xbase + ybase * ybase;\n sum += Cvalues[i] * math.sqrt(comb);\n }\n return z2 * sum;\n }\n function getTatLen(x1, y1, x2, y2, x3, y3, x4, y4, ll) {\n if (ll < 0 || bezlen(x1, y1, x2, y2, x3, y3, x4, y4) < ll) {\n return;\n }\n var t = 1,\n step = t / 2,\n t2 = t - step,\n l,\n e = .01;\n l = bezlen(x1, y1, x2, y2, x3, y3, x4, y4, t2);\n while (abs(l - ll) > e) {\n step /= 2;\n t2 += (l < ll ? 1 : -1) * step;\n l = bezlen(x1, y1, x2, y2, x3, y3, x4, y4, t2);\n }\n return t2;\n }\n function intersect(x1, y1, x2, y2, x3, y3, x4, y4) {\n if (\n mmax(x1, x2) < mmin(x3, x4) ||\n mmin(x1, x2) > mmax(x3, x4) ||\n mmax(y1, y2) < mmin(y3, y4) ||\n mmin(y1, y2) > mmax(y3, y4)\n ) {\n return;\n }\n var nx = (x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4),\n ny = (x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4),\n denominator = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);\n\n if (!denominator) {\n return;\n }\n var px = nx / denominator,\n py = ny / denominator,\n px2 = +px.toFixed(2),\n py2 = +py.toFixed(2);\n if (\n px2 < +mmin(x1, x2).toFixed(2) ||\n px2 > +mmax(x1, x2).toFixed(2) ||\n px2 < +mmin(x3, x4).toFixed(2) ||\n px2 > +mmax(x3, x4).toFixed(2) ||\n py2 < +mmin(y1, y2).toFixed(2) ||\n py2 > +mmax(y1, y2).toFixed(2) ||\n py2 < +mmin(y3, y4).toFixed(2) ||\n py2 > +mmax(y3, y4).toFixed(2)\n ) {\n return;\n }\n return {x: px, y: py};\n }\n function inter(bez1, bez2) {\n return interHelper(bez1, bez2);\n }\n function interCount(bez1, bez2) {\n return interHelper(bez1, bez2, 1);\n }\n function interHelper(bez1, bez2, justCount) {\n var bbox1 = R.bezierBBox(bez1),\n bbox2 = R.bezierBBox(bez2);\n if (!R.isBBoxIntersect(bbox1, bbox2)) {\n return justCount ? 0 : [];\n }\n var l1 = bezlen.apply(0, bez1),\n l2 = bezlen.apply(0, bez2),\n n1 = ~~(l1 / 5),\n n2 = ~~(l2 / 5),\n dots1 = [],\n dots2 = [],\n xy = {},\n res = justCount ? 0 : [];\n for (var i = 0; i < n1 + 1; i++) {\n var p = R.findDotsAtSegment.apply(R, bez1.concat(i / n1));\n dots1.push({x: p.x, y: p.y, t: i / n1});\n }\n for (i = 0; i < n2 + 1; i++) {\n p = R.findDotsAtSegment.apply(R, bez2.concat(i / n2));\n dots2.push({x: p.x, y: p.y, t: i / n2});\n }\n for (i = 0; i < n1; i++) {\n for (var j = 0; j < n2; j++) {\n var di = dots1[i],\n di1 = dots1[i + 1],\n dj = dots2[j],\n dj1 = dots2[j + 1],\n ci = abs(di1.x - di.x) < .001 ? \"y\" : \"x\",\n cj = abs(dj1.x - dj.x) < .001 ? \"y\" : \"x\",\n is = intersect(di.x, di.y, di1.x, di1.y, dj.x, dj.y, dj1.x, dj1.y);\n if (is) {\n if (xy[is.x.toFixed(4)] == is.y.toFixed(4)) {\n continue;\n }\n xy[is.x.toFixed(4)] = is.y.toFixed(4);\n var t1 = di.t + abs((is[ci] - di[ci]) / (di1[ci] - di[ci])) * (di1.t - di.t),\n t2 = dj.t + abs((is[cj] - dj[cj]) / (dj1[cj] - dj[cj])) * (dj1.t - dj.t);\n if (t1 >= 0 && t1 <= 1 && t2 >= 0 && t2 <= 1) {\n if (justCount) {\n res++;\n } else {\n res.push({\n x: is.x,\n y: is.y,\n t1: t1,\n t2: t2\n });\n }\n }\n }\n }\n }\n return res;\n }\n \n R.pathIntersection = function (path1, path2) {\n return interPathHelper(path1, path2);\n };\n R.pathIntersectionNumber = function (path1, path2) {\n return interPathHelper(path1, path2, 1);\n };\n function interPathHelper(path1, path2, justCount) {\n path1 = R._path2curve(path1);\n path2 = R._path2curve(path2);\n var x1, y1, x2, y2, x1m, y1m, x2m, y2m, bez1, bez2,\n res = justCount ? 0 : [];\n for (var i = 0, ii = path1.length; i < ii; i++) {\n var pi = path1[i];\n if (pi[0] == \"M\") {\n x1 = x1m = pi[1];\n y1 = y1m = pi[2];\n } else {\n if (pi[0] == \"C\") {\n bez1 = [x1, y1].concat(pi.slice(1));\n x1 = bez1[6];\n y1 = bez1[7];\n } else {\n bez1 = [x1, y1, x1, y1, x1m, y1m, x1m, y1m];\n x1 = x1m;\n y1 = y1m;\n }\n for (var j = 0, jj = path2.length; j < jj; j++) {\n var pj = path2[j];\n if (pj[0] == \"M\") {\n x2 = x2m = pj[1];\n y2 = y2m = pj[2];\n } else {\n if (pj[0] == \"C\") {\n bez2 = [x2, y2].concat(pj.slice(1));\n x2 = bez2[6];\n y2 = bez2[7];\n } else {\n bez2 = [x2, y2, x2, y2, x2m, y2m, x2m, y2m];\n x2 = x2m;\n y2 = y2m;\n }\n var intr = interHelper(bez1, bez2, justCount);\n if (justCount) {\n res += intr;\n } else {\n for (var k = 0, kk = intr.length; k < kk; k++) {\n intr[k].segment1 = i;\n intr[k].segment2 = j;\n intr[k].bez1 = bez1;\n intr[k].bez2 = bez2;\n }\n res = res.concat(intr);\n }\n }\n }\n }\n }\n return res;\n }\n \n R.isPointInsidePath = function (path, x, y) {\n var bbox = R.pathBBox(path);\n return R.isPointInsideBBox(bbox, x, y) &&\n interPathHelper(path, [[\"M\", x, y], [\"H\", bbox.x2 + 10]], 1) % 2 == 1;\n };\n R._removedFactory = function (methodname) {\n return function () {\n eve(\"raphael.log\", null, \"Rapha\\xebl: you are calling to method \\u201c\" + methodname + \"\\u201d of removed object\", methodname);\n };\n };\n \n var pathDimensions = R.pathBBox = function (path) {\n var pth = paths(path);\n if (pth.bbox) {\n return pth.bbox;\n }\n if (!path) {\n return {x: 0, y: 0, width: 0, height: 0, x2: 0, y2: 0};\n }\n path = path2curve(path);\n var x = 0, \n y = 0,\n X = [],\n Y = [],\n p;\n for (var i = 0, ii = path.length; i < ii; i++) {\n p = path[i];\n if (p[0] == \"M\") {\n x = p[1];\n y = p[2];\n X.push(x);\n Y.push(y);\n } else {\n var dim = curveDim(x, y, p[1], p[2], p[3], p[4], p[5], p[6]);\n X = X[concat](dim.min.x, dim.max.x);\n Y = Y[concat](dim.min.y, dim.max.y);\n x = p[5];\n y = p[6];\n }\n }\n var xmin = mmin[apply](0, X),\n ymin = mmin[apply](0, Y),\n xmax = mmax[apply](0, X),\n ymax = mmax[apply](0, Y),\n bb = {\n x: xmin,\n y: ymin,\n x2: xmax,\n y2: ymax,\n width: xmax - xmin,\n height: ymax - ymin\n };\n pth.bbox = clone(bb);\n return bb;\n },\n pathClone = function (pathArray) {\n var res = clone(pathArray);\n res.toString = R._path2string;\n return res;\n },\n pathToRelative = R._pathToRelative = function (pathArray) {\n var pth = paths(pathArray);\n if (pth.rel) {\n return pathClone(pth.rel);\n }\n if (!R.is(pathArray, array) || !R.is(pathArray && pathArray[0], array)) { // rough assumption\n pathArray = R.parsePathString(pathArray);\n }\n var res = [],\n x = 0,\n y = 0,\n mx = 0,\n my = 0,\n start = 0;\n if (pathArray[0][0] == \"M\") {\n x = pathArray[0][1];\n y = pathArray[0][2];\n mx = x;\n my = y;\n start++;\n res.push([\"M\", x, y]);\n }\n for (var i = start, ii = pathArray.length; i < ii; i++) {\n var r = res[i] = [],\n pa = pathArray[i];\n if (pa[0] != lowerCase.call(pa[0])) {\n r[0] = lowerCase.call(pa[0]);\n switch (r[0]) {\n case \"a\":\n r[1] = pa[1];\n r[2] = pa[2];\n r[3] = pa[3];\n r[4] = pa[4];\n r[5] = pa[5];\n r[6] = +(pa[6] - x).toFixed(3);\n r[7] = +(pa[7] - y).toFixed(3);\n break;\n case \"v\":\n r[1] = +(pa[1] - y).toFixed(3);\n break;\n case \"m\":\n mx = pa[1];\n my = pa[2];\n default:\n for (var j = 1, jj = pa.length; j < jj; j++) {\n r[j] = +(pa[j] - ((j % 2) ? x : y)).toFixed(3);\n }\n }\n } else {\n r = res[i] = [];\n if (pa[0] == \"m\") {\n mx = pa[1] + x;\n my = pa[2] + y;\n }\n for (var k = 0, kk = pa.length; k < kk; k++) {\n res[i][k] = pa[k];\n }\n }\n var len = res[i].length;\n switch (res[i][0]) {\n case \"z\":\n x = mx;\n y = my;\n break;\n case \"h\":\n x += +res[i][len - 1];\n break;\n case \"v\":\n y += +res[i][len - 1];\n break;\n default:\n x += +res[i][len - 2];\n y += +res[i][len - 1];\n }\n }\n res.toString = R._path2string;\n pth.rel = pathClone(res);\n return res;\n },\n pathToAbsolute = R._pathToAbsolute = function (pathArray) {\n var pth = paths(pathArray);\n if (pth.abs) {\n return pathClone(pth.abs);\n }\n if (!R.is(pathArray, array) || !R.is(pathArray && pathArray[0], array)) { // rough assumption\n pathArray = R.parsePathString(pathArray);\n }\n if (!pathArray || !pathArray.length) {\n return [[\"M\", 0, 0]];\n }\n var res = [],\n x = 0,\n y = 0,\n mx = 0,\n my = 0,\n start = 0;\n if (pathArray[0][0] == \"M\") {\n x = +pathArray[0][1];\n y = +pathArray[0][2];\n mx = x;\n my = y;\n start++;\n res[0] = [\"M\", x, y];\n }\n var crz = pathArray.length == 3 && pathArray[0][0] == \"M\" && pathArray[1][0].toUpperCase() == \"R\" && pathArray[2][0].toUpperCase() == \"Z\";\n for (var r, pa, i = start, ii = pathArray.length; i < ii; i++) {\n res.push(r = []);\n pa = pathArray[i];\n if (pa[0] != upperCase.call(pa[0])) {\n r[0] = upperCase.call(pa[0]);\n switch (r[0]) {\n case \"A\":\n r[1] = pa[1];\n r[2] = pa[2];\n r[3] = pa[3];\n r[4] = pa[4];\n r[5] = pa[5];\n r[6] = +(pa[6] + x);\n r[7] = +(pa[7] + y);\n break;\n case \"V\":\n r[1] = +pa[1] + y;\n break;\n case \"H\":\n r[1] = +pa[1] + x;\n break;\n case \"R\":\n var dots = [x, y][concat](pa.slice(1));\n for (var j = 2, jj = dots.length; j < jj; j++) {\n dots[j] = +dots[j] + x;\n dots[++j] = +dots[j] + y;\n }\n res.pop();\n res = res[concat](catmullRom2bezier(dots, crz));\n break;\n case \"M\":\n mx = +pa[1] + x;\n my = +pa[2] + y;\n default:\n for (j = 1, jj = pa.length; j < jj; j++) {\n r[j] = +pa[j] + ((j % 2) ? x : y);\n }\n }\n } else if (pa[0] == \"R\") {\n dots = [x, y][concat](pa.slice(1));\n res.pop();\n res = res[concat](catmullRom2bezier(dots, crz));\n r = [\"R\"][concat](pa.slice(-2));\n } else {\n for (var k = 0, kk = pa.length; k < kk; k++) {\n r[k] = pa[k];\n }\n }\n switch (r[0]) {\n case \"Z\":\n x = mx;\n y = my;\n break;\n case \"H\":\n x = r[1];\n break;\n case \"V\":\n y = r[1];\n break;\n case \"M\":\n mx = r[r.length - 2];\n my = r[r.length - 1];\n default:\n x = r[r.length - 2];\n y = r[r.length - 1];\n }\n }\n res.toString = R._path2string;\n pth.abs = pathClone(res);\n return res;\n },\n l2c = function (x1, y1, x2, y2) {\n return [x1, y1, x2, y2, x2, y2];\n },\n q2c = function (x1, y1, ax, ay, x2, y2) {\n var _13 = 1 / 3,\n _23 = 2 / 3;\n return [\n _13 * x1 + _23 * ax,\n _13 * y1 + _23 * ay,\n _13 * x2 + _23 * ax,\n _13 * y2 + _23 * ay,\n x2,\n y2\n ];\n },\n a2c = function (x1, y1, rx, ry, angle, large_arc_flag, sweep_flag, x2, y2, recursive) {\n // for more information of where this math came from visit:\n // http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes\n var _120 = PI * 120 / 180,\n rad = PI / 180 * (+angle || 0),\n res = [],\n xy,\n rotate = cacher(function (x, y, rad) {\n var X = x * math.cos(rad) - y * math.sin(rad),\n Y = x * math.sin(rad) + y * math.cos(rad);\n return {x: X, y: Y};\n });\n if (!recursive) {\n xy = rotate(x1, y1, -rad);\n x1 = xy.x;\n y1 = xy.y;\n xy = rotate(x2, y2, -rad);\n x2 = xy.x;\n y2 = xy.y;\n var cos = math.cos(PI / 180 * angle),\n sin = math.sin(PI / 180 * angle),\n x = (x1 - x2) / 2,\n y = (y1 - y2) / 2;\n var h = (x * x) / (rx * rx) + (y * y) / (ry * ry);\n if (h > 1) {\n h = math.sqrt(h);\n rx = h * rx;\n ry = h * ry;\n }\n var rx2 = rx * rx,\n ry2 = ry * ry,\n k = (large_arc_flag == sweep_flag ? -1 : 1) *\n math.sqrt(abs((rx2 * ry2 - rx2 * y * y - ry2 * x * x) / (rx2 * y * y + ry2 * x * x))),\n cx = k * rx * y / ry + (x1 + x2) / 2,\n cy = k * -ry * x / rx + (y1 + y2) / 2,\n f1 = math.asin(((y1 - cy) / ry).toFixed(9)),\n f2 = math.asin(((y2 - cy) / ry).toFixed(9));\n\n f1 = x1 < cx ? PI - f1 : f1;\n f2 = x2 < cx ? PI - f2 : f2;\n f1 < 0 && (f1 = PI * 2 + f1);\n f2 < 0 && (f2 = PI * 2 + f2);\n if (sweep_flag && f1 > f2) {\n f1 = f1 - PI * 2;\n }\n if (!sweep_flag && f2 > f1) {\n f2 = f2 - PI * 2;\n }\n } else {\n f1 = recursive[0];\n f2 = recursive[1];\n cx = recursive[2];\n cy = recursive[3];\n }\n var df = f2 - f1;\n if (abs(df) > _120) {\n var f2old = f2,\n x2old = x2,\n y2old = y2;\n f2 = f1 + _120 * (sweep_flag && f2 > f1 ? 1 : -1);\n x2 = cx + rx * math.cos(f2);\n y2 = cy + ry * math.sin(f2);\n res = a2c(x2, y2, rx, ry, angle, 0, sweep_flag, x2old, y2old, [f2, f2old, cx, cy]);\n }\n df = f2 - f1;\n var c1 = math.cos(f1),\n s1 = math.sin(f1),\n c2 = math.cos(f2),\n s2 = math.sin(f2),\n t = math.tan(df / 4),\n hx = 4 / 3 * rx * t,\n hy = 4 / 3 * ry * t,\n m1 = [x1, y1],\n m2 = [x1 + hx * s1, y1 - hy * c1],\n m3 = [x2 + hx * s2, y2 - hy * c2],\n m4 = [x2, y2];\n m2[0] = 2 * m1[0] - m2[0];\n m2[1] = 2 * m1[1] - m2[1];\n if (recursive) {\n return [m2, m3, m4][concat](res);\n } else {\n res = [m2, m3, m4][concat](res).join()[split](\",\");\n var newres = [];\n for (var i = 0, ii = res.length; i < ii; i++) {\n newres[i] = i % 2 ? rotate(res[i - 1], res[i], rad).y : rotate(res[i], res[i + 1], rad).x;\n }\n return newres;\n }\n },\n findDotAtSegment = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) {\n var t1 = 1 - t;\n return {\n x: pow(t1, 3) * p1x + pow(t1, 2) * 3 * t * c1x + t1 * 3 * t * t * c2x + pow(t, 3) * p2x,\n y: pow(t1, 3) * p1y + pow(t1, 2) * 3 * t * c1y + t1 * 3 * t * t * c2y + pow(t, 3) * p2y\n };\n },\n curveDim = cacher(function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) {\n var a = (c2x - 2 * c1x + p1x) - (p2x - 2 * c2x + c1x),\n b = 2 * (c1x - p1x) - 2 * (c2x - c1x),\n c = p1x - c1x,\n t1 = (-b + math.sqrt(b * b - 4 * a * c)) / 2 / a,\n t2 = (-b - math.sqrt(b * b - 4 * a * c)) / 2 / a,\n y = [p1y, p2y],\n x = [p1x, p2x],\n dot;\n abs(t1) > \"1e12\" && (t1 = .5);\n abs(t2) > \"1e12\" && (t2 = .5);\n if (t1 > 0 && t1 < 1) {\n dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t1);\n x.push(dot.x);\n y.push(dot.y);\n }\n if (t2 > 0 && t2 < 1) {\n dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t2);\n x.push(dot.x);\n y.push(dot.y);\n }\n a = (c2y - 2 * c1y + p1y) - (p2y - 2 * c2y + c1y);\n b = 2 * (c1y - p1y) - 2 * (c2y - c1y);\n c = p1y - c1y;\n t1 = (-b + math.sqrt(b * b - 4 * a * c)) / 2 / a;\n t2 = (-b - math.sqrt(b * b - 4 * a * c)) / 2 / a;\n abs(t1) > \"1e12\" && (t1 = .5);\n abs(t2) > \"1e12\" && (t2 = .5);\n if (t1 > 0 && t1 < 1) {\n dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t1);\n x.push(dot.x);\n y.push(dot.y);\n }\n if (t2 > 0 && t2 < 1) {\n dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t2);\n x.push(dot.x);\n y.push(dot.y);\n }\n return {\n min: {x: mmin[apply](0, x), y: mmin[apply](0, y)},\n max: {x: mmax[apply](0, x), y: mmax[apply](0, y)}\n };\n }),\n path2curve = R._path2curve = cacher(function (path, path2) {\n var pth = !path2 && paths(path);\n if (!path2 && pth.curve) {\n return pathClone(pth.curve);\n }\n var p = pathToAbsolute(path),\n p2 = path2 && pathToAbsolute(path2),\n attrs = {x: 0, y: 0, bx: 0, by: 0, X: 0, Y: 0, qx: null, qy: null},\n attrs2 = {x: 0, y: 0, bx: 0, by: 0, X: 0, Y: 0, qx: null, qy: null},\n processPath = function (path, d) {\n var nx, ny;\n if (!path) {\n return [\"C\", d.x, d.y, d.x, d.y, d.x, d.y];\n }\n !(path[0] in {T:1, Q:1}) && (d.qx = d.qy = null);\n switch (path[0]) {\n case \"M\":\n d.X = path[1];\n d.Y = path[2];\n break;\n case \"A\":\n path = [\"C\"][concat](a2c[apply](0, [d.x, d.y][concat](path.slice(1))));\n break;\n case \"S\":\n nx = d.x + (d.x - (d.bx || d.x));\n ny = d.y + (d.y - (d.by || d.y));\n path = [\"C\", nx, ny][concat](path.slice(1));\n break;\n case \"T\":\n d.qx = d.x + (d.x - (d.qx || d.x));\n d.qy = d.y + (d.y - (d.qy || d.y));\n path = [\"C\"][concat](q2c(d.x, d.y, d.qx, d.qy, path[1], path[2]));\n break;\n case \"Q\":\n d.qx = path[1];\n d.qy = path[2];\n path = [\"C\"][concat](q2c(d.x, d.y, path[1], path[2], path[3], path[4]));\n break;\n case \"L\":\n path = [\"C\"][concat](l2c(d.x, d.y, path[1], path[2]));\n break;\n case \"H\":\n path = [\"C\"][concat](l2c(d.x, d.y, path[1], d.y));\n break;\n case \"V\":\n path = [\"C\"][concat](l2c(d.x, d.y, d.x, path[1]));\n break;\n case \"Z\":\n path = [\"C\"][concat](l2c(d.x, d.y, d.X, d.Y));\n break;\n }\n return path;\n },\n fixArc = function (pp, i) {\n if (pp[i].length > 7) {\n pp[i].shift();\n var pi = pp[i];\n while (pi.length) {\n pp.splice(i++, 0, [\"C\"][concat](pi.splice(0, 6)));\n }\n pp.splice(i, 1);\n ii = mmax(p.length, p2 && p2.length || 0);\n }\n },\n fixM = function (path1, path2, a1, a2, i) {\n if (path1 && path2 && path1[i][0] == \"M\" && path2[i][0] != \"M\") {\n path2.splice(i, 0, [\"M\", a2.x, a2.y]);\n a1.bx = 0;\n a1.by = 0;\n a1.x = path1[i][1];\n a1.y = path1[i][2];\n ii = mmax(p.length, p2 && p2.length || 0);\n }\n };\n for (var i = 0, ii = mmax(p.length, p2 && p2.length || 0); i < ii; i++) {\n p[i] = processPath(p[i], attrs);\n fixArc(p, i);\n p2 && (p2[i] = processPath(p2[i], attrs2));\n p2 && fixArc(p2, i);\n fixM(p, p2, attrs, attrs2, i);\n fixM(p2, p, attrs2, attrs, i);\n var seg = p[i],\n seg2 = p2 && p2[i],\n seglen = seg.length,\n seg2len = p2 && seg2.length;\n attrs.x = seg[seglen - 2];\n attrs.y = seg[seglen - 1];\n attrs.bx = toFloat(seg[seglen - 4]) || attrs.x;\n attrs.by = toFloat(seg[seglen - 3]) || attrs.y;\n attrs2.bx = p2 && (toFloat(seg2[seg2len - 4]) || attrs2.x);\n attrs2.by = p2 && (toFloat(seg2[seg2len - 3]) || attrs2.y);\n attrs2.x = p2 && seg2[seg2len - 2];\n attrs2.y = p2 && seg2[seg2len - 1];\n }\n if (!p2) {\n pth.curve = pathClone(p);\n }\n return p2 ? [p, p2] : p;\n }, null, pathClone),\n parseDots = R._parseDots = cacher(function (gradient) {\n var dots = [];\n for (var i = 0, ii = gradient.length; i < ii; i++) {\n var dot = {},\n par = gradient[i].match(/^([^:]*):?([\\d\\.]*)/);\n dot.color = R.getRGB(par[1]);\n if (dot.color.error) {\n return null;\n }\n dot.color = dot.color.hex;\n par[2] && (dot.offset = par[2] + \"%\");\n dots.push(dot);\n }\n for (i = 1, ii = dots.length - 1; i < ii; i++) {\n if (!dots[i].offset) {\n var start = toFloat(dots[i - 1].offset || 0),\n end = 0;\n for (var j = i + 1; j < ii; j++) {\n if (dots[j].offset) {\n end = dots[j].offset;\n break;\n }\n }\n if (!end) {\n end = 100;\n j = ii;\n }\n end = toFloat(end);\n var d = (end - start) / (j - i + 1);\n for (; i < j; i++) {\n start += d;\n dots[i].offset = start + \"%\";\n }\n }\n }\n return dots;\n }),\n tear = R._tear = function (el, paper) {\n el == paper.top && (paper.top = el.prev);\n el == paper.bottom && (paper.bottom = el.next);\n el.next && (el.next.prev = el.prev);\n el.prev && (el.prev.next = el.next);\n },\n tofront = R._tofront = function (el, paper) {\n if (paper.top === el) {\n return;\n }\n tear(el, paper);\n el.next = null;\n el.prev = paper.top;\n paper.top.next = el;\n paper.top = el;\n },\n toback = R._toback = function (el, paper) {\n if (paper.bottom === el) {\n return;\n }\n tear(el, paper);\n el.next = paper.bottom;\n el.prev = null;\n paper.bottom.prev = el;\n paper.bottom = el;\n },\n insertafter = R._insertafter = function (el, el2, paper) {\n tear(el, paper);\n el2 == paper.top && (paper.top = el);\n el2.next && (el2.next.prev = el);\n el.next = el2.next;\n el.prev = el2;\n el2.next = el;\n },\n insertbefore = R._insertbefore = function (el, el2, paper) {\n tear(el, paper);\n el2 == paper.bottom && (paper.bottom = el);\n el2.prev && (el2.prev.next = el);\n el.prev = el2.prev;\n el2.prev = el;\n el.next = el2;\n },\n \n toMatrix = R.toMatrix = function (path, transform) {\n var bb = pathDimensions(path),\n el = {\n _: {\n transform: E\n },\n getBBox: function () {\n return bb;\n }\n };\n extractTransform(el, transform);\n return el.matrix;\n },\n \n transformPath = R.transformPath = function (path, transform) {\n return mapPath(path, toMatrix(path, transform));\n },\n extractTransform = R._extractTransform = function (el, tstr) {\n if (tstr == null) {\n return el._.transform;\n }\n tstr = Str(tstr).replace(/\\.{3}|\\u2026/g, el._.transform || E);\n var tdata = R.parseTransformString(tstr),\n deg = 0,\n dx = 0,\n dy = 0,\n sx = 1,\n sy = 1,\n _ = el._,\n m = new Matrix;\n _.transform = tdata || [];\n if (tdata) {\n for (var i = 0, ii = tdata.length; i < ii; i++) {\n var t = tdata[i],\n tlen = t.length,\n command = Str(t[0]).toLowerCase(),\n absolute = t[0] != command,\n inver = absolute ? m.invert() : 0,\n x1,\n y1,\n x2,\n y2,\n bb;\n if (command == \"t\" && tlen == 3) {\n if (absolute) {\n x1 = inver.x(0, 0);\n y1 = inver.y(0, 0);\n x2 = inver.x(t[1], t[2]);\n y2 = inver.y(t[1], t[2]);\n m.translate(x2 - x1, y2 - y1);\n } else {\n m.translate(t[1], t[2]);\n }\n } else if (command == \"r\") {\n if (tlen == 2) {\n bb = bb || el.getBBox(1);\n m.rotate(t[1], bb.x + bb.width / 2, bb.y + bb.height / 2);\n deg += t[1];\n } else if (tlen == 4) {\n if (absolute) {\n x2 = inver.x(t[2], t[3]);\n y2 = inver.y(t[2], t[3]);\n m.rotate(t[1], x2, y2);\n } else {\n m.rotate(t[1], t[2], t[3]);\n }\n deg += t[1];\n }\n } else if (command == \"s\") {\n if (tlen == 2 || tlen == 3) {\n bb = bb || el.getBBox(1);\n m.scale(t[1], t[tlen - 1], bb.x + bb.width / 2, bb.y + bb.height / 2);\n sx *= t[1];\n sy *= t[tlen - 1];\n } else if (tlen == 5) {\n if (absolute) {\n x2 = inver.x(t[3], t[4]);\n y2 = inver.y(t[3], t[4]);\n m.scale(t[1], t[2], x2, y2);\n } else {\n m.scale(t[1], t[2], t[3], t[4]);\n }\n sx *= t[1];\n sy *= t[2];\n }\n } else if (command == \"m\" && tlen == 7) {\n m.add(t[1], t[2], t[3], t[4], t[5], t[6]);\n }\n _.dirtyT = 1;\n el.matrix = m;\n }\n }\n\n \n el.matrix = m;\n\n _.sx = sx;\n _.sy = sy;\n _.deg = deg;\n _.dx = dx = m.e;\n _.dy = dy = m.f;\n\n if (sx == 1 && sy == 1 && !deg && _.bbox) {\n _.bbox.x += +dx;\n _.bbox.y += +dy;\n } else {\n _.dirtyT = 1;\n }\n },\n getEmpty = function (item) {\n var l = item[0];\n switch (l.toLowerCase()) {\n case \"t\": return [l, 0, 0];\n case \"m\": return [l, 1, 0, 0, 1, 0, 0];\n case \"r\": if (item.length == 4) {\n return [l, 0, item[2], item[3]];\n } else {\n return [l, 0];\n }\n case \"s\": if (item.length == 5) {\n return [l, 1, 1, item[3], item[4]];\n } else if (item.length == 3) {\n return [l, 1, 1];\n } else {\n return [l, 1];\n }\n }\n },\n equaliseTransform = R._equaliseTransform = function (t1, t2) {\n t2 = Str(t2).replace(/\\.{3}|\\u2026/g, t1);\n t1 = R.parseTransformString(t1) || [];\n t2 = R.parseTransformString(t2) || [];\n var maxlength = mmax(t1.length, t2.length),\n from = [],\n to = [],\n i = 0, j, jj,\n tt1, tt2;\n for (; i < maxlength; i++) {\n tt1 = t1[i] || getEmpty(t2[i]);\n tt2 = t2[i] || getEmpty(tt1);\n if ((tt1[0] != tt2[0]) ||\n (tt1[0].toLowerCase() == \"r\" && (tt1[2] != tt2[2] || tt1[3] != tt2[3])) ||\n (tt1[0].toLowerCase() == \"s\" && (tt1[3] != tt2[3] || tt1[4] != tt2[4]))\n ) {\n return;\n }\n from[i] = [];\n to[i] = [];\n for (j = 0, jj = mmax(tt1.length, tt2.length); j < jj; j++) {\n j in tt1 && (from[i][j] = tt1[j]);\n j in tt2 && (to[i][j] = tt2[j]);\n }\n }\n return {\n from: from,\n to: to\n };\n };\n R._getContainer = function (x, y, w, h) {\n var container;\n container = h == null && !R.is(x, \"object\") ? g.doc.getElementById(x) : x;\n if (container == null) {\n return;\n }\n if (container.tagName) {\n if (y == null) {\n return {\n container: container,\n width: container.style.pixelWidth || container.offsetWidth,\n height: container.style.pixelHeight || container.offsetHeight\n };\n } else {\n return {\n container: container,\n width: y,\n height: w\n };\n }\n }\n return {\n container: 1,\n x: x,\n y: y,\n width: w,\n height: h\n };\n };\n \n R.pathToRelative = pathToRelative;\n R._engine = {};\n \n R.path2curve = path2curve;\n \n R.matrix = function (a, b, c, d, e, f) {\n return new Matrix(a, b, c, d, e, f);\n };\n function Matrix(a, b, c, d, e, f) {\n if (a != null) {\n this.a = +a;\n this.b = +b;\n this.c = +c;\n this.d = +d;\n this.e = +e;\n this.f = +f;\n } else {\n this.a = 1;\n this.b = 0;\n this.c = 0;\n this.d = 1;\n this.e = 0;\n this.f = 0;\n }\n }\n (function (matrixproto) {\n \n matrixproto.add = function (a, b, c, d, e, f) {\n var out = [[], [], []],\n m = [[this.a, this.c, this.e], [this.b, this.d, this.f], [0, 0, 1]],\n matrix = [[a, c, e], [b, d, f], [0, 0, 1]],\n x, y, z, res;\n\n if (a && a instanceof Matrix) {\n matrix = [[a.a, a.c, a.e], [a.b, a.d, a.f], [0, 0, 1]];\n }\n\n for (x = 0; x < 3; x++) {\n for (y = 0; y < 3; y++) {\n res = 0;\n for (z = 0; z < 3; z++) {\n res += m[x][z] * matrix[z][y];\n }\n out[x][y] = res;\n }\n }\n this.a = out[0][0];\n this.b = out[1][0];\n this.c = out[0][1];\n this.d = out[1][1];\n this.e = out[0][2];\n this.f = out[1][2];\n };\n \n matrixproto.invert = function () {\n var me = this,\n x = me.a * me.d - me.b * me.c;\n return new Matrix(me.d / x, -me.b / x, -me.c / x, me.a / x, (me.c * me.f - me.d * me.e) / x, (me.b * me.e - me.a * me.f) / x);\n };\n \n matrixproto.clone = function () {\n return new Matrix(this.a, this.b, this.c, this.d, this.e, this.f);\n };\n \n matrixproto.translate = function (x, y) {\n this.add(1, 0, 0, 1, x, y);\n };\n \n matrixproto.scale = function (x, y, cx, cy) {\n y == null && (y = x);\n (cx || cy) && this.add(1, 0, 0, 1, cx, cy);\n this.add(x, 0, 0, y, 0, 0);\n (cx || cy) && this.add(1, 0, 0, 1, -cx, -cy);\n };\n \n matrixproto.rotate = function (a, x, y) {\n a = R.rad(a);\n x = x || 0;\n y = y || 0;\n var cos = +math.cos(a).toFixed(9),\n sin = +math.sin(a).toFixed(9);\n this.add(cos, sin, -sin, cos, x, y);\n this.add(1, 0, 0, 1, -x, -y);\n };\n \n matrixproto.x = function (x, y) {\n return x * this.a + y * this.c + this.e;\n };\n \n matrixproto.y = function (x, y) {\n return x * this.b + y * this.d + this.f;\n };\n matrixproto.get = function (i) {\n return +this[Str.fromCharCode(97 + i)].toFixed(4);\n };\n matrixproto.toString = function () {\n return R.svg ?\n \"matrix(\" + [this.get(0), this.get(1), this.get(2), this.get(3), this.get(4), this.get(5)].join() + \")\" :\n [this.get(0), this.get(2), this.get(1), this.get(3), 0, 0].join();\n };\n matrixproto.toFilter = function () {\n return \"progid:DXImageTransform.Microsoft.Matrix(M11=\" + this.get(0) +\n \", M12=\" + this.get(2) + \", M21=\" + this.get(1) + \", M22=\" + this.get(3) +\n \", Dx=\" + this.get(4) + \", Dy=\" + this.get(5) + \", sizingmethod='auto expand')\";\n };\n matrixproto.offset = function () {\n return [this.e.toFixed(4), this.f.toFixed(4)];\n };\n function norm(a) {\n return a[0] * a[0] + a[1] * a[1];\n }\n function normalize(a) {\n var mag = math.sqrt(norm(a));\n a[0] && (a[0] /= mag);\n a[1] && (a[1] /= mag);\n }\n \n matrixproto.split = function () {\n var out = {};\n // translation\n out.dx = this.e;\n out.dy = this.f;\n\n // scale and shear\n var row = [[this.a, this.c], [this.b, this.d]];\n out.scalex = math.sqrt(norm(row[0]));\n normalize(row[0]);\n\n out.shear = row[0][0] * row[1][0] + row[0][1] * row[1][1];\n row[1] = [row[1][0] - row[0][0] * out.shear, row[1][1] - row[0][1] * out.shear];\n\n out.scaley = math.sqrt(norm(row[1]));\n normalize(row[1]);\n out.shear /= out.scaley;\n\n // rotation\n var sin = -row[0][1],\n cos = row[1][1];\n if (cos < 0) {\n out.rotate = R.deg(math.acos(cos));\n if (sin < 0) {\n out.rotate = 360 - out.rotate;\n }\n } else {\n out.rotate = R.deg(math.asin(sin));\n }\n\n out.isSimple = !+out.shear.toFixed(9) && (out.scalex.toFixed(9) == out.scaley.toFixed(9) || !out.rotate);\n out.isSuperSimple = !+out.shear.toFixed(9) && out.scalex.toFixed(9) == out.scaley.toFixed(9) && !out.rotate;\n out.noRotation = !+out.shear.toFixed(9) && !out.rotate;\n return out;\n };\n \n matrixproto.toTransformString = function (shorter) {\n var s = shorter || this[split]();\n if (s.isSimple) {\n s.scalex = +s.scalex.toFixed(4);\n s.scaley = +s.scaley.toFixed(4);\n s.rotate = +s.rotate.toFixed(4);\n return (s.dx || s.dy ? \"t\" + [s.dx, s.dy] : E) + \n (s.scalex != 1 || s.scaley != 1 ? \"s\" + [s.scalex, s.scaley, 0, 0] : E) +\n (s.rotate ? \"r\" + [s.rotate, 0, 0] : E);\n } else {\n return \"m\" + [this.get(0), this.get(1), this.get(2), this.get(3), this.get(4), this.get(5)];\n }\n };\n })(Matrix.prototype);\n\n // WebKit rendering bug workaround method\n // BROWSERIFY MOD: don't assume navigator exists\n if (typeof navigator !== 'undefined') {\n var version = navigator.userAgent.match(/Version\\/(.*?)\\s/) || navigator.userAgent.match(/Chrome\\/(\\d+)/);\n if ((navigator.vendor == \"Apple Computer, Inc.\") && (version && version[1] < 4 || navigator.platform.slice(0, 2) == \"iP\") ||\n (navigator.vendor == \"Google Inc.\" && version && version[1] < 8)) {\n \n paperproto.safari = function () {\n var rect = this.rect(-99, -99, this.width + 99, this.height + 99).attr({stroke: \"none\"});\n setTimeout(function () {rect.remove();});\n };\n } else {\n paperproto.safari = fun;\n }\n } else {\n paperproto.safari = fun;\n }\n \n var preventDefault = function () {\n this.returnValue = false;\n },\n preventTouch = function () {\n return this.originalEvent.preventDefault();\n },\n stopPropagation = function () {\n this.cancelBubble = true;\n },\n stopTouch = function () {\n return this.originalEvent.stopPropagation();\n },\n addEvent = (function () {\n if (g.doc.addEventListener) {\n return function (obj, type, fn, element) {\n var realName = supportsTouch && touchMap[type] ? touchMap[type] : type,\n f = function (e) {\n var scrollY = g.doc.documentElement.scrollTop || g.doc.body.scrollTop,\n scrollX = g.doc.documentElement.scrollLeft || g.doc.body.scrollLeft,\n x = e.clientX + scrollX,\n y = e.clientY + scrollY;\n if (supportsTouch && touchMap[has](type)) {\n for (var i = 0, ii = e.targetTouches && e.targetTouches.length; i < ii; i++) {\n if (e.targetTouches[i].target == obj) {\n var olde = e;\n e = e.targetTouches[i];\n e.originalEvent = olde;\n e.preventDefault = preventTouch;\n e.stopPropagation = stopTouch;\n break;\n }\n }\n }\n return fn.call(element, e, x, y);\n };\n obj.addEventListener(realName, f, false);\n return function () {\n obj.removeEventListener(realName, f, false);\n return true;\n };\n };\n } else if (g.doc.attachEvent) {\n return function (obj, type, fn, element) {\n var f = function (e) {\n e = e || g.win.event;\n var scrollY = g.doc.documentElement.scrollTop || g.doc.body.scrollTop,\n scrollX = g.doc.documentElement.scrollLeft || g.doc.body.scrollLeft,\n x = e.clientX + scrollX,\n y = e.clientY + scrollY;\n e.preventDefault = e.preventDefault || preventDefault;\n e.stopPropagation = e.stopPropagation || stopPropagation;\n return fn.call(element, e, x, y);\n };\n obj.attachEvent(\"on\" + type, f);\n var detacher = function () {\n obj.detachEvent(\"on\" + type, f);\n return true;\n };\n return detacher;\n };\n }\n })(),\n drag = [],\n dragMove = function (e) {\n var x = e.clientX,\n y = e.clientY,\n scrollY = g.doc.documentElement.scrollTop || g.doc.body.scrollTop,\n scrollX = g.doc.documentElement.scrollLeft || g.doc.body.scrollLeft,\n dragi,\n j = drag.length;\n while (j--) {\n dragi = drag[j];\n if (supportsTouch) {\n var i = e.touches.length,\n touch;\n while (i--) {\n touch = e.touches[i];\n if (touch.identifier == dragi.el._drag.id) {\n x = touch.clientX;\n y = touch.clientY;\n (e.originalEvent ? e.originalEvent : e).preventDefault();\n break;\n }\n }\n } else {\n e.preventDefault();\n }\n var node = dragi.el.node,\n o,\n next = node.nextSibling,\n parent = node.parentNode,\n display = node.style.display;\n g.win.opera && parent.removeChild(node);\n node.style.display = \"none\";\n o = dragi.el.paper.getElementByPoint(x, y);\n node.style.display = display;\n g.win.opera && (next ? parent.insertBefore(node, next) : parent.appendChild(node));\n o && eve(\"raphael.drag.over.\" + dragi.el.id, dragi.el, o);\n x += scrollX;\n y += scrollY;\n eve(\"raphael.drag.move.\" + dragi.el.id, dragi.move_scope || dragi.el, x - dragi.el._drag.x, y - dragi.el._drag.y, x, y, e);\n }\n },\n dragUp = function (e) {\n R.unmousemove(dragMove).unmouseup(dragUp);\n var i = drag.length,\n dragi;\n while (i--) {\n dragi = drag[i];\n dragi.el._drag = {};\n eve(\"raphael.drag.end.\" + dragi.el.id, dragi.end_scope || dragi.start_scope || dragi.move_scope || dragi.el, e);\n }\n drag = [];\n },\n \n elproto = R.el = {};\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n for (var i = events.length; i--;) {\n (function (eventName) {\n R[eventName] = elproto[eventName] = function (fn, scope) {\n if (R.is(fn, \"function\")) {\n this.events = this.events || [];\n this.events.push({name: eventName, f: fn, unbind: addEvent(this.shape || this.node || g.doc, eventName, fn, scope || this)});\n }\n return this;\n };\n R[\"un\" + eventName] = elproto[\"un\" + eventName] = function (fn) {\n var events = this.events || [],\n l = events.length;\n while (l--) if (events[l].name == eventName && events[l].f == fn) {\n events[l].unbind();\n events.splice(l, 1);\n !events.length && delete this.events;\n return this;\n }\n return this;\n };\n })(events[i]);\n }\n \n \n elproto.data = function (key, value) {\n var data = eldata[this.id] = eldata[this.id] || {};\n if (arguments.length == 1) {\n if (R.is(key, \"object\")) {\n for (var i in key) if (key[has](i)) {\n this.data(i, key[i]);\n }\n return this;\n }\n eve(\"raphael.data.get.\" + this.id, this, data[key], key);\n return data[key];\n }\n data[key] = value;\n eve(\"raphael.data.set.\" + this.id, this, value, key);\n return this;\n };\n \n elproto.removeData = function (key) {\n if (key == null) {\n eldata[this.id] = {};\n } else {\n eldata[this.id] && delete eldata[this.id][key];\n }\n return this;\n };\n \n elproto.hover = function (f_in, f_out, scope_in, scope_out) {\n return this.mouseover(f_in, scope_in).mouseout(f_out, scope_out || scope_in);\n };\n \n elproto.unhover = function (f_in, f_out) {\n return this.unmouseover(f_in).unmouseout(f_out);\n };\n var draggable = [];\n \n elproto.drag = function (onmove, onstart, onend, move_scope, start_scope, end_scope) {\n function start(e) {\n (e.originalEvent || e).preventDefault();\n var scrollY = g.doc.documentElement.scrollTop || g.doc.body.scrollTop,\n scrollX = g.doc.documentElement.scrollLeft || g.doc.body.scrollLeft;\n this._drag.x = e.clientX + scrollX;\n this._drag.y = e.clientY + scrollY;\n this._drag.id = e.identifier;\n !drag.length && R.mousemove(dragMove).mouseup(dragUp);\n drag.push({el: this, move_scope: move_scope, start_scope: start_scope, end_scope: end_scope});\n onstart && eve.on(\"raphael.drag.start.\" + this.id, onstart);\n onmove && eve.on(\"raphael.drag.move.\" + this.id, onmove);\n onend && eve.on(\"raphael.drag.end.\" + this.id, onend);\n eve(\"raphael.drag.start.\" + this.id, start_scope || move_scope || this, e.clientX + scrollX, e.clientY + scrollY, e);\n }\n this._drag = {};\n draggable.push({el: this, start: start});\n this.mousedown(start);\n return this;\n };\n \n elproto.onDragOver = function (f) {\n f ? eve.on(\"raphael.drag.over.\" + this.id, f) : eve.unbind(\"raphael.drag.over.\" + this.id);\n };\n \n elproto.undrag = function () {\n var i = draggable.length;\n while (i--) if (draggable[i].el == this) {\n this.unmousedown(draggable[i].start);\n draggable.splice(i, 1);\n eve.unbind(\"raphael.drag.*.\" + this.id);\n }\n !draggable.length && R.unmousemove(dragMove).unmouseup(dragUp);\n };\n \n paperproto.circle = function (x, y, r) {\n var out = R._engine.circle(this, x || 0, y || 0, r || 0);\n this.__set__ && this.__set__.push(out);\n return out;\n };\n \n paperproto.rect = function (x, y, w, h, r) {\n var out = R._engine.rect(this, x || 0, y || 0, w || 0, h || 0, r || 0);\n this.__set__ && this.__set__.push(out);\n return out;\n };\n \n paperproto.ellipse = function (x, y, rx, ry) {\n var out = R._engine.ellipse(this, x || 0, y || 0, rx || 0, ry || 0);\n this.__set__ && this.__set__.push(out);\n return out;\n };\n \n paperproto.path = function (pathString) {\n pathString && !R.is(pathString, string) && !R.is(pathString[0], array) && (pathString += E);\n var out = R._engine.path(R.format[apply](R, arguments), this);\n this.__set__ && this.__set__.push(out);\n return out;\n };\n \n paperproto.image = function (src, x, y, w, h) {\n var out = R._engine.image(this, src || \"about:blank\", x || 0, y || 0, w || 0, h || 0);\n this.__set__ && this.__set__.push(out);\n return out;\n };\n \n paperproto.text = function (x, y, text) {\n var out = R._engine.text(this, x || 0, y || 0, Str(text));\n this.__set__ && this.__set__.push(out);\n return out;\n };\n \n paperproto.set = function (itemsArray) {\n !R.is(itemsArray, \"array\") && (itemsArray = Array.prototype.splice.call(arguments, 0, arguments.length));\n var out = new Set(itemsArray);\n this.__set__ && this.__set__.push(out);\n return out;\n };\n \n paperproto.setStart = function (set) {\n this.__set__ = set || this.set();\n };\n \n paperproto.setFinish = function (set) {\n var out = this.__set__;\n delete this.__set__;\n return out;\n };\n \n paperproto.setSize = function (width, height) {\n return R._engine.setSize.call(this, width, height);\n };\n \n paperproto.setViewBox = function (x, y, w, h, fit) {\n return R._engine.setViewBox.call(this, x, y, w, h, fit);\n };\n \n \n paperproto.top = paperproto.bottom = null;\n \n paperproto.raphael = R;\n var getOffset = function (elem) {\n var box = elem.getBoundingClientRect(),\n doc = elem.ownerDocument,\n body = doc.body,\n docElem = doc.documentElement,\n clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0,\n top = box.top + (g.win.pageYOffset || docElem.scrollTop || body.scrollTop ) - clientTop,\n left = box.left + (g.win.pageXOffset || docElem.scrollLeft || body.scrollLeft) - clientLeft;\n return {\n y: top,\n x: left\n };\n };\n \n paperproto.getElementByPoint = function (x, y) {\n var paper = this,\n svg = paper.canvas,\n target = g.doc.elementFromPoint(x, y);\n if (g.win.opera && target.tagName == \"svg\") {\n var so = getOffset(svg),\n sr = svg.createSVGRect();\n sr.x = x - so.x;\n sr.y = y - so.y;\n sr.width = sr.height = 1;\n var hits = svg.getIntersectionList(sr, null);\n if (hits.length) {\n target = hits[hits.length - 1];\n }\n }\n if (!target) {\n return null;\n }\n while (target.parentNode && target != svg.parentNode && !target.raphael) {\n target = target.parentNode;\n }\n target == paper.canvas.parentNode && (target = svg);\n target = target && target.raphael ? paper.getById(target.raphaelid) : null;\n return target;\n };\n \n paperproto.getById = function (id) {\n var bot = this.bottom;\n while (bot) {\n if (bot.id == id) {\n return bot;\n }\n bot = bot.next;\n }\n return null;\n };\n \n paperproto.forEach = function (callback, thisArg) {\n var bot = this.bottom;\n while (bot) {\n if (callback.call(thisArg, bot) === false) {\n return this;\n }\n bot = bot.next;\n }\n return this;\n };\n \n paperproto.getElementsByPoint = function (x, y) {\n var set = this.set();\n this.forEach(function (el) {\n if (el.isPointInside(x, y)) {\n set.push(el);\n }\n });\n return set;\n };\n function x_y() {\n return this.x + S + this.y;\n }\n function x_y_w_h() {\n return this.x + S + this.y + S + this.width + \" \\xd7 \" + this.height;\n }\n \n elproto.isPointInside = function (x, y) {\n var rp = this.realPath = this.realPath || getPath[this.type](this);\n return R.isPointInsidePath(rp, x, y);\n };\n \n elproto.getBBox = function (isWithoutTransform) {\n if (this.removed) {\n return {};\n }\n var _ = this._;\n if (isWithoutTransform) {\n if (_.dirty || !_.bboxwt) {\n this.realPath = getPath[this.type](this);\n _.bboxwt = pathDimensions(this.realPath);\n _.bboxwt.toString = x_y_w_h;\n _.dirty = 0;\n }\n return _.bboxwt;\n }\n if (_.dirty || _.dirtyT || !_.bbox) {\n if (_.dirty || !this.realPath) {\n _.bboxwt = 0;\n this.realPath = getPath[this.type](this);\n }\n _.bbox = pathDimensions(mapPath(this.realPath, this.matrix));\n _.bbox.toString = x_y_w_h;\n _.dirty = _.dirtyT = 0;\n }\n return _.bbox;\n };\n \n elproto.clone = function () {\n if (this.removed) {\n return null;\n }\n var out = this.paper[this.type]().attr(this.attr());\n this.__set__ && this.__set__.push(out);\n return out;\n };\n \n elproto.glow = function (glow) {\n if (this.type == \"text\") {\n return null;\n }\n glow = glow || {};\n var s = {\n width: (glow.width || 10) + (+this.attr(\"stroke-width\") || 1),\n fill: glow.fill || false,\n opacity: glow.opacity || .5,\n offsetx: glow.offsetx || 0,\n offsety: glow.offsety || 0,\n color: glow.color || \"#000\"\n },\n c = s.width / 2,\n r = this.paper,\n out = r.set(),\n path = this.realPath || getPath[this.type](this);\n path = this.matrix ? mapPath(path, this.matrix) : path;\n for (var i = 1; i < c + 1; i++) {\n out.push(r.path(path).attr({\n stroke: s.color,\n fill: s.fill ? s.color : \"none\",\n \"stroke-linejoin\": \"round\",\n \"stroke-linecap\": \"round\",\n \"stroke-width\": +(s.width / c * i).toFixed(3),\n opacity: +(s.opacity / c).toFixed(3)\n }));\n }\n return out.insertBefore(this).translate(s.offsetx, s.offsety);\n };\n var curveslengths = {},\n getPointAtSegmentLength = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, length) {\n if (length == null) {\n return bezlen(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y);\n } else {\n return R.findDotsAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, getTatLen(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, length));\n }\n },\n getLengthFactory = function (istotal, subpath) {\n return function (path, length, onlystart) {\n path = path2curve(path);\n var x, y, p, l, sp = \"\", subpaths = {}, point,\n len = 0;\n for (var i = 0, ii = path.length; i < ii; i++) {\n p = path[i];\n if (p[0] == \"M\") {\n x = +p[1];\n y = +p[2];\n } else {\n l = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6]);\n if (len + l > length) {\n if (subpath && !subpaths.start) {\n point = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6], length - len);\n sp += [\"C\" + point.start.x, point.start.y, point.m.x, point.m.y, point.x, point.y];\n if (onlystart) {return sp;}\n subpaths.start = sp;\n sp = [\"M\" + point.x, point.y + \"C\" + point.n.x, point.n.y, point.end.x, point.end.y, p[5], p[6]].join();\n len += l;\n x = +p[5];\n y = +p[6];\n continue;\n }\n if (!istotal && !subpath) {\n point = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6], length - len);\n return {x: point.x, y: point.y, alpha: point.alpha};\n }\n }\n len += l;\n x = +p[5];\n y = +p[6];\n }\n sp += p.shift() + p;\n }\n subpaths.end = sp;\n point = istotal ? len : subpath ? subpaths : R.findDotsAtSegment(x, y, p[0], p[1], p[2], p[3], p[4], p[5], 1);\n point.alpha && (point = {x: point.x, y: point.y, alpha: point.alpha});\n return point;\n };\n };\n var getTotalLength = getLengthFactory(1),\n getPointAtLength = getLengthFactory(),\n getSubpathsAtLength = getLengthFactory(0, 1);\n \n R.getTotalLength = getTotalLength;\n \n R.getPointAtLength = getPointAtLength;\n \n R.getSubpath = function (path, from, to) {\n if (this.getTotalLength(path) - to < 1e-6) {\n return getSubpathsAtLength(path, from).end;\n }\n var a = getSubpathsAtLength(path, to, 1);\n return from ? getSubpathsAtLength(a, from).end : a;\n };\n \n elproto.getTotalLength = function () {\n if (this.type != \"path\") {return;}\n if (this.node.getTotalLength) {\n return this.node.getTotalLength();\n }\n return getTotalLength(this.attrs.path);\n };\n \n elproto.getPointAtLength = function (length) {\n if (this.type != \"path\") {return;}\n return getPointAtLength(this.attrs.path, length);\n };\n \n elproto.getSubpath = function (from, to) {\n if (this.type != \"path\") {return;}\n return R.getSubpath(this.attrs.path, from, to);\n };\n \n var ef = R.easing_formulas = {\n linear: function (n) {\n return n;\n },\n \"<\": function (n) {\n return pow(n, 1.7);\n },\n \">\": function (n) {\n return pow(n, .48);\n },\n \"<>\": function (n) {\n var q = .48 - n / 1.04,\n Q = math.sqrt(.1734 + q * q),\n x = Q - q,\n X = pow(abs(x), 1 / 3) * (x < 0 ? -1 : 1),\n y = -Q - q,\n Y = pow(abs(y), 1 / 3) * (y < 0 ? -1 : 1),\n t = X + Y + .5;\n return (1 - t) * 3 * t * t + t * t * t;\n },\n backIn: function (n) {\n var s = 1.70158;\n return n * n * ((s + 1) * n - s);\n },\n backOut: function (n) {\n n = n - 1;\n var s = 1.70158;\n return n * n * ((s + 1) * n + s) + 1;\n },\n elastic: function (n) {\n if (n == !!n) {\n return n;\n }\n return pow(2, -10 * n) * math.sin((n - .075) * (2 * PI) / .3) + 1;\n },\n bounce: function (n) {\n var s = 7.5625,\n p = 2.75,\n l;\n if (n < (1 / p)) {\n l = s * n * n;\n } else {\n if (n < (2 / p)) {\n n -= (1.5 / p);\n l = s * n * n + .75;\n } else {\n if (n < (2.5 / p)) {\n n -= (2.25 / p);\n l = s * n * n + .9375;\n } else {\n n -= (2.625 / p);\n l = s * n * n + .984375;\n }\n }\n }\n return l;\n }\n };\n ef.easeIn = ef[\"ease-in\"] = ef[\"<\"];\n ef.easeOut = ef[\"ease-out\"] = ef[\">\"];\n ef.easeInOut = ef[\"ease-in-out\"] = ef[\"<>\"];\n ef[\"back-in\"] = ef.backIn;\n ef[\"back-out\"] = ef.backOut;\n\n // BROWSERIFY MOD: use R._g.win here instead of window\n var animationElements = [],\n requestAnimFrame = R._g.win.requestAnimationFrame ||\n R._g.win.webkitRequestAnimationFrame ||\n R._g.win.mozRequestAnimationFrame ||\n R._g.win.oRequestAnimationFrame ||\n R._g.win.msRequestAnimationFrame ||\n function (callback) {\n setTimeout(callback, 16);\n },\n animation = function () {\n var Now = +new Date,\n l = 0;\n for (; l < animationElements.length; l++) {\n var e = animationElements[l];\n if (e.el.removed || e.paused) {\n continue;\n }\n var time = Now - e.start,\n ms = e.ms,\n easing = e.easing,\n from = e.from,\n diff = e.diff,\n to = e.to,\n t = e.t,\n that = e.el,\n set = {},\n now,\n init = {},\n key;\n if (e.initstatus) {\n time = (e.initstatus * e.anim.top - e.prev) / (e.percent - e.prev) * ms;\n e.status = e.initstatus;\n delete e.initstatus;\n e.stop && animationElements.splice(l--, 1);\n } else {\n e.status = (e.prev + (e.percent - e.prev) * (time / ms)) / e.anim.top;\n }\n if (time < 0) {\n continue;\n }\n if (time < ms) {\n var pos = easing(time / ms);\n for (var attr in from) if (from[has](attr)) {\n switch (availableAnimAttrs[attr]) {\n case nu:\n now = +from[attr] + pos * ms * diff[attr];\n break;\n case \"colour\":\n now = \"rgb(\" + [\n upto255(round(from[attr].r + pos * ms * diff[attr].r)),\n upto255(round(from[attr].g + pos * ms * diff[attr].g)),\n upto255(round(from[attr].b + pos * ms * diff[attr].b))\n ].join(\",\") + \")\";\n break;\n case \"path\":\n now = [];\n for (var i = 0, ii = from[attr].length; i < ii; i++) {\n now[i] = [from[attr][i][0]];\n for (var j = 1, jj = from[attr][i].length; j < jj; j++) {\n now[i][j] = +from[attr][i][j] + pos * ms * diff[attr][i][j];\n }\n now[i] = now[i].join(S);\n }\n now = now.join(S);\n break;\n case \"transform\":\n if (diff[attr].real) {\n now = [];\n for (i = 0, ii = from[attr].length; i < ii; i++) {\n now[i] = [from[attr][i][0]];\n for (j = 1, jj = from[attr][i].length; j < jj; j++) {\n now[i][j] = from[attr][i][j] + pos * ms * diff[attr][i][j];\n }\n }\n } else {\n var get = function (i) {\n return +from[attr][i] + pos * ms * diff[attr][i];\n };\n // now = [[\"r\", get(2), 0, 0], [\"t\", get(3), get(4)], [\"s\", get(0), get(1), 0, 0]];\n now = [[\"m\", get(0), get(1), get(2), get(3), get(4), get(5)]];\n }\n break;\n case \"csv\":\n if (attr == \"clip-rect\") {\n now = [];\n i = 4;\n while (i--) {\n now[i] = +from[attr][i] + pos * ms * diff[attr][i];\n }\n }\n break;\n default:\n var from2 = [][concat](from[attr]);\n now = [];\n i = that.paper.customAttributes[attr].length;\n while (i--) {\n now[i] = +from2[i] + pos * ms * diff[attr][i];\n }\n break;\n }\n set[attr] = now;\n }\n that.attr(set);\n (function (id, that, anim) {\n setTimeout(function () {\n eve(\"raphael.anim.frame.\" + id, that, anim);\n });\n })(that.id, that, e.anim);\n } else {\n (function(f, el, a) {\n setTimeout(function() {\n eve(\"raphael.anim.frame.\" + el.id, el, a);\n eve(\"raphael.anim.finish.\" + el.id, el, a);\n R.is(f, \"function\") && f.call(el);\n });\n })(e.callback, that, e.anim);\n that.attr(to);\n animationElements.splice(l--, 1);\n if (e.repeat > 1 && !e.next) {\n for (key in to) if (to[has](key)) {\n init[key] = e.totalOrigin[key];\n }\n e.el.attr(init);\n runAnimation(e.anim, e.el, e.anim.percents[0], null, e.totalOrigin, e.repeat - 1);\n }\n if (e.next && !e.stop) {\n runAnimation(e.anim, e.el, e.next, null, e.totalOrigin, e.repeat);\n }\n }\n }\n R.svg && that && that.paper && that.paper.safari();\n animationElements.length && requestAnimFrame(animation);\n },\n upto255 = function (color) {\n return color > 255 ? 255 : color < 0 ? 0 : color;\n };\n \n elproto.animateWith = function (el, anim, params, ms, easing, callback) {\n var element = this;\n if (element.removed) {\n callback && callback.call(element);\n return element;\n }\n var a = params instanceof Animation ? params : R.animation(params, ms, easing, callback),\n x, y;\n runAnimation(a, element, a.percents[0], null, element.attr());\n for (var i = 0, ii = animationElements.length; i < ii; i++) {\n if (animationElements[i].anim == anim && animationElements[i].el == el) {\n animationElements[ii - 1].start = animationElements[i].start;\n break;\n }\n }\n return element;\n // \n // \n // var a = params ? R.animation(params, ms, easing, callback) : anim,\n // status = element.status(anim);\n // return this.animate(a).status(a, status * anim.ms / a.ms);\n };\n function CubicBezierAtTime(t, p1x, p1y, p2x, p2y, duration) {\n var cx = 3 * p1x,\n bx = 3 * (p2x - p1x) - cx,\n ax = 1 - cx - bx,\n cy = 3 * p1y,\n by = 3 * (p2y - p1y) - cy,\n ay = 1 - cy - by;\n function sampleCurveX(t) {\n return ((ax * t + bx) * t + cx) * t;\n }\n function solve(x, epsilon) {\n var t = solveCurveX(x, epsilon);\n return ((ay * t + by) * t + cy) * t;\n }\n function solveCurveX(x, epsilon) {\n var t0, t1, t2, x2, d2, i;\n for(t2 = x, i = 0; i < 8; i++) {\n x2 = sampleCurveX(t2) - x;\n if (abs(x2) < epsilon) {\n return t2;\n }\n d2 = (3 * ax * t2 + 2 * bx) * t2 + cx;\n if (abs(d2) < 1e-6) {\n break;\n }\n t2 = t2 - x2 / d2;\n }\n t0 = 0;\n t1 = 1;\n t2 = x;\n if (t2 < t0) {\n return t0;\n }\n if (t2 > t1) {\n return t1;\n }\n while (t0 < t1) {\n x2 = sampleCurveX(t2);\n if (abs(x2 - x) < epsilon) {\n return t2;\n }\n if (x > x2) {\n t0 = t2;\n } else {\n t1 = t2;\n }\n t2 = (t1 - t0) / 2 + t0;\n }\n return t2;\n }\n return solve(t, 1 / (200 * duration));\n }\n elproto.onAnimation = function (f) {\n f ? eve.on(\"raphael.anim.frame.\" + this.id, f) : eve.unbind(\"raphael.anim.frame.\" + this.id);\n return this;\n };\n function Animation(anim, ms) {\n var percents = [],\n newAnim = {};\n this.ms = ms;\n this.times = 1;\n if (anim) {\n for (var attr in anim) if (anim[has](attr)) {\n newAnim[toFloat(attr)] = anim[attr];\n percents.push(toFloat(attr));\n }\n percents.sort(sortByNumber);\n }\n this.anim = newAnim;\n this.top = percents[percents.length - 1];\n this.percents = percents;\n }\n \n Animation.prototype.delay = function (delay) {\n var a = new Animation(this.anim, this.ms);\n a.times = this.times;\n a.del = +delay || 0;\n return a;\n };\n \n Animation.prototype.repeat = function (times) { \n var a = new Animation(this.anim, this.ms);\n a.del = this.del;\n a.times = math.floor(mmax(times, 0)) || 1;\n return a;\n };\n function runAnimation(anim, element, percent, status, totalOrigin, times) {\n percent = toFloat(percent);\n var params,\n isInAnim,\n isInAnimSet,\n percents = [],\n next,\n prev,\n timestamp,\n ms = anim.ms,\n from = {},\n to = {},\n diff = {};\n if (status) {\n for (i = 0, ii = animationElements.length; i < ii; i++) {\n var e = animationElements[i];\n if (e.el.id == element.id && e.anim == anim) {\n if (e.percent != percent) {\n animationElements.splice(i, 1);\n isInAnimSet = 1;\n } else {\n isInAnim = e;\n }\n element.attr(e.totalOrigin);\n break;\n }\n }\n } else {\n status = +to; // NaN\n }\n for (var i = 0, ii = anim.percents.length; i < ii; i++) {\n if (anim.percents[i] == percent || anim.percents[i] > status * anim.top) {\n percent = anim.percents[i];\n prev = anim.percents[i - 1] || 0;\n ms = ms / anim.top * (percent - prev);\n next = anim.percents[i + 1];\n params = anim.anim[percent];\n break;\n } else if (status) {\n element.attr(anim.anim[anim.percents[i]]);\n }\n }\n if (!params) {\n return;\n }\n if (!isInAnim) {\n for (var attr in params) if (params[has](attr)) {\n if (availableAnimAttrs[has](attr) || element.paper.customAttributes[has](attr)) {\n from[attr] = element.attr(attr);\n (from[attr] == null) && (from[attr] = availableAttrs[attr]);\n to[attr] = params[attr];\n switch (availableAnimAttrs[attr]) {\n case nu:\n diff[attr] = (to[attr] - from[attr]) / ms;\n break;\n case \"colour\":\n from[attr] = R.getRGB(from[attr]);\n var toColour = R.getRGB(to[attr]);\n diff[attr] = {\n r: (toColour.r - from[attr].r) / ms,\n g: (toColour.g - from[attr].g) / ms,\n b: (toColour.b - from[attr].b) / ms\n };\n break;\n case \"path\":\n var pathes = path2curve(from[attr], to[attr]),\n toPath = pathes[1];\n from[attr] = pathes[0];\n diff[attr] = [];\n for (i = 0, ii = from[attr].length; i < ii; i++) {\n diff[attr][i] = [0];\n for (var j = 1, jj = from[attr][i].length; j < jj; j++) {\n diff[attr][i][j] = (toPath[i][j] - from[attr][i][j]) / ms;\n }\n }\n break;\n case \"transform\":\n var _ = element._,\n eq = equaliseTransform(_[attr], to[attr]);\n if (eq) {\n from[attr] = eq.from;\n to[attr] = eq.to;\n diff[attr] = [];\n diff[attr].real = true;\n for (i = 0, ii = from[attr].length; i < ii; i++) {\n diff[attr][i] = [from[attr][i][0]];\n for (j = 1, jj = from[attr][i].length; j < jj; j++) {\n diff[attr][i][j] = (to[attr][i][j] - from[attr][i][j]) / ms;\n }\n }\n } else {\n var m = (element.matrix || new Matrix),\n to2 = {\n _: {transform: _.transform},\n getBBox: function () {\n return element.getBBox(1);\n }\n };\n from[attr] = [\n m.a,\n m.b,\n m.c,\n m.d,\n m.e,\n m.f\n ];\n extractTransform(to2, to[attr]);\n to[attr] = to2._.transform;\n diff[attr] = [\n (to2.matrix.a - m.a) / ms,\n (to2.matrix.b - m.b) / ms,\n (to2.matrix.c - m.c) / ms,\n (to2.matrix.d - m.d) / ms,\n (to2.matrix.e - m.e) / ms,\n (to2.matrix.f - m.f) / ms\n ];\n // from[attr] = [_.sx, _.sy, _.deg, _.dx, _.dy];\n // var to2 = {_:{}, getBBox: function () { return element.getBBox(); }};\n // extractTransform(to2, to[attr]);\n // diff[attr] = [\n // (to2._.sx - _.sx) / ms,\n // (to2._.sy - _.sy) / ms,\n // (to2._.deg - _.deg) / ms,\n // (to2._.dx - _.dx) / ms,\n // (to2._.dy - _.dy) / ms\n // ];\n }\n break;\n case \"csv\":\n var values = Str(params[attr])[split](separator),\n from2 = Str(from[attr])[split](separator);\n if (attr == \"clip-rect\") {\n from[attr] = from2;\n diff[attr] = [];\n i = from2.length;\n while (i--) {\n diff[attr][i] = (values[i] - from[attr][i]) / ms;\n }\n }\n to[attr] = values;\n break;\n default:\n values = [][concat](params[attr]);\n from2 = [][concat](from[attr]);\n diff[attr] = [];\n i = element.paper.customAttributes[attr].length;\n while (i--) {\n diff[attr][i] = ((values[i] || 0) - (from2[i] || 0)) / ms;\n }\n break;\n }\n }\n }\n var easing = params.easing,\n easyeasy = R.easing_formulas[easing];\n if (!easyeasy) {\n easyeasy = Str(easing).match(bezierrg);\n if (easyeasy && easyeasy.length == 5) {\n var curve = easyeasy;\n easyeasy = function (t) {\n return CubicBezierAtTime(t, +curve[1], +curve[2], +curve[3], +curve[4], ms);\n };\n } else {\n easyeasy = pipe;\n }\n }\n timestamp = params.start || anim.start || +new Date;\n e = {\n anim: anim,\n percent: percent,\n timestamp: timestamp,\n start: timestamp + (anim.del || 0),\n status: 0,\n initstatus: status || 0,\n stop: false,\n ms: ms,\n easing: easyeasy,\n from: from,\n diff: diff,\n to: to,\n el: element,\n callback: params.callback,\n prev: prev,\n next: next,\n repeat: times || anim.times,\n origin: element.attr(),\n totalOrigin: totalOrigin\n };\n animationElements.push(e);\n if (status && !isInAnim && !isInAnimSet) {\n e.stop = true;\n e.start = new Date - ms * status;\n if (animationElements.length == 1) {\n return animation();\n }\n }\n if (isInAnimSet) {\n e.start = new Date - e.ms * status;\n }\n animationElements.length == 1 && requestAnimFrame(animation);\n } else {\n isInAnim.initstatus = status;\n isInAnim.start = new Date - isInAnim.ms * status;\n }\n eve(\"raphael.anim.start.\" + element.id, element, anim);\n }\n \n R.animation = function (params, ms, easing, callback) {\n if (params instanceof Animation) {\n return params;\n }\n if (R.is(easing, \"function\") || !easing) {\n callback = callback || easing || null;\n easing = null;\n }\n params = Object(params);\n ms = +ms || 0;\n var p = {},\n json,\n attr;\n for (attr in params) if (params[has](attr) && toFloat(attr) != attr && toFloat(attr) + \"%\" != attr) {\n json = true;\n p[attr] = params[attr];\n }\n if (!json) {\n return new Animation(params, ms);\n } else {\n easing && (p.easing = easing);\n callback && (p.callback = callback);\n return new Animation({100: p}, ms);\n }\n };\n \n elproto.animate = function (params, ms, easing, callback) {\n var element = this;\n if (element.removed) {\n callback && callback.call(element);\n return element;\n }\n var anim = params instanceof Animation ? params : R.animation(params, ms, easing, callback);\n runAnimation(anim, element, anim.percents[0], null, element.attr());\n return element;\n };\n \n elproto.setTime = function (anim, value) {\n if (anim && value != null) {\n this.status(anim, mmin(value, anim.ms) / anim.ms);\n }\n return this;\n };\n \n elproto.status = function (anim, value) {\n var out = [],\n i = 0,\n len,\n e;\n if (value != null) {\n runAnimation(anim, this, -1, mmin(value, 1));\n return this;\n } else {\n len = animationElements.length;\n for (; i < len; i++) {\n e = animationElements[i];\n if (e.el.id == this.id && (!anim || e.anim == anim)) {\n if (anim) {\n return e.status;\n }\n out.push({\n anim: e.anim,\n status: e.status\n });\n }\n }\n if (anim) {\n return 0;\n }\n return out;\n }\n };\n \n elproto.pause = function (anim) {\n for (var i = 0; i < animationElements.length; i++) if (animationElements[i].el.id == this.id && (!anim || animationElements[i].anim == anim)) {\n if (eve(\"raphael.anim.pause.\" + this.id, this, animationElements[i].anim) !== false) {\n animationElements[i].paused = true;\n }\n }\n return this;\n };\n \n elproto.resume = function (anim) {\n for (var i = 0; i < animationElements.length; i++) if (animationElements[i].el.id == this.id && (!anim || animationElements[i].anim == anim)) {\n var e = animationElements[i];\n if (eve(\"raphael.anim.resume.\" + this.id, this, e.anim) !== false) {\n delete e.paused;\n this.status(e.anim, e.status);\n }\n }\n return this;\n };\n \n elproto.stop = function (anim) {\n for (var i = 0; i < animationElements.length; i++) if (animationElements[i].el.id == this.id && (!anim || animationElements[i].anim == anim)) {\n if (eve(\"raphael.anim.stop.\" + this.id, this, animationElements[i].anim) !== false) {\n animationElements.splice(i--, 1);\n }\n }\n return this;\n };\n function stopAnimation(paper) {\n for (var i = 0; i < animationElements.length; i++) if (animationElements[i].el.paper == paper) {\n animationElements.splice(i--, 1);\n }\n }\n eve.on(\"raphael.remove\", stopAnimation);\n eve.on(\"raphael.clear\", stopAnimation);\n elproto.toString = function () {\n return \"Rapha\\xebl\\u2019s object\";\n };\n\n // Set\n var Set = function (items) {\n this.items = [];\n this.length = 0;\n this.type = \"set\";\n if (items) {\n for (var i = 0, ii = items.length; i < ii; i++) {\n if (items[i] && (items[i].constructor == elproto.constructor || items[i].constructor == Set)) {\n this[this.items.length] = this.items[this.items.length] = items[i];\n this.length++;\n }\n }\n }\n },\n setproto = Set.prototype;\n \n setproto.push = function () {\n var item,\n len;\n for (var i = 0, ii = arguments.length; i < ii; i++) {\n item = arguments[i];\n if (item && (item.constructor == elproto.constructor || item.constructor == Set)) {\n len = this.items.length;\n this[len] = this.items[len] = item;\n this.length++;\n }\n }\n return this;\n };\n \n setproto.pop = function () {\n this.length && delete this[this.length--];\n return this.items.pop();\n };\n \n setproto.forEach = function (callback, thisArg) {\n for (var i = 0, ii = this.items.length; i < ii; i++) {\n if (callback.call(thisArg, this.items[i], i) === false) {\n return this;\n }\n }\n return this;\n };\n for (var method in elproto) if (elproto[has](method)) {\n setproto[method] = (function (methodname) {\n return function () {\n var arg = arguments;\n return this.forEach(function (el) {\n el[methodname][apply](el, arg);\n });\n };\n })(method);\n }\n setproto.attr = function (name, value) {\n if (name && R.is(name, array) && R.is(name[0], \"object\")) {\n for (var j = 0, jj = name.length; j < jj; j++) {\n this.items[j].attr(name[j]);\n }\n } else {\n for (var i = 0, ii = this.items.length; i < ii; i++) {\n this.items[i].attr(name, value);\n }\n }\n return this;\n };\n \n setproto.clear = function () {\n while (this.length) {\n this.pop();\n }\n };\n \n setproto.splice = function (index, count, insertion) {\n index = index < 0 ? mmax(this.length + index, 0) : index;\n count = mmax(0, mmin(this.length - index, count));\n var tail = [],\n todel = [],\n args = [],\n i;\n for (i = 2; i < arguments.length; i++) {\n args.push(arguments[i]);\n }\n for (i = 0; i < count; i++) {\n todel.push(this[index + i]);\n }\n for (; i < this.length - index; i++) {\n tail.push(this[index + i]);\n }\n var arglen = args.length;\n for (i = 0; i < arglen + tail.length; i++) {\n this.items[index + i] = this[index + i] = i < arglen ? args[i] : tail[i - arglen];\n }\n i = this.items.length = this.length -= count - arglen;\n while (this[i]) {\n delete this[i++];\n }\n return new Set(todel);\n };\n \n setproto.exclude = function (el) {\n for (var i = 0, ii = this.length; i < ii; i++) if (this[i] == el) {\n this.splice(i, 1);\n return true;\n }\n };\n setproto.animate = function (params, ms, easing, callback) {\n (R.is(easing, \"function\") || !easing) && (callback = easing || null);\n var len = this.items.length,\n i = len,\n item,\n set = this,\n collector;\n if (!len) {\n return this;\n }\n callback && (collector = function () {\n !--len && callback.call(set);\n });\n easing = R.is(easing, string) ? easing : collector;\n var anim = R.animation(params, ms, easing, collector);\n item = this.items[--i].animate(anim);\n while (i--) {\n this.items[i] && !this.items[i].removed && this.items[i].animateWith(item, anim, anim);\n }\n return this;\n };\n setproto.insertAfter = function (el) {\n var i = this.items.length;\n while (i--) {\n this.items[i].insertAfter(el);\n }\n return this;\n };\n setproto.getBBox = function () {\n var x = [],\n y = [],\n x2 = [],\n y2 = [];\n for (var i = this.items.length; i--;) if (!this.items[i].removed) {\n var box = this.items[i].getBBox();\n x.push(box.x);\n y.push(box.y);\n x2.push(box.x + box.width);\n y2.push(box.y + box.height);\n }\n x = mmin[apply](0, x);\n y = mmin[apply](0, y);\n x2 = mmax[apply](0, x2);\n y2 = mmax[apply](0, y2);\n return {\n x: x,\n y: y,\n x2: x2,\n y2: y2,\n width: x2 - x,\n height: y2 - y\n };\n };\n setproto.clone = function (s) {\n s = new Set;\n for (var i = 0, ii = this.items.length; i < ii; i++) {\n s.push(this.items[i].clone());\n }\n return s;\n };\n setproto.toString = function () {\n return \"Rapha\\xebl\\u2018s set\";\n };\n\n \n R.registerFont = function (font) {\n if (!font.face) {\n return font;\n }\n this.fonts = this.fonts || {};\n var fontcopy = {\n w: font.w,\n face: {},\n glyphs: {}\n },\n family = font.face[\"font-family\"];\n for (var prop in font.face) if (font.face[has](prop)) {\n fontcopy.face[prop] = font.face[prop];\n }\n if (this.fonts[family]) {\n this.fonts[family].push(fontcopy);\n } else {\n this.fonts[family] = [fontcopy];\n }\n if (!font.svg) {\n fontcopy.face[\"units-per-em\"] = toInt(font.face[\"units-per-em\"], 10);\n for (var glyph in font.glyphs) if (font.glyphs[has](glyph)) {\n var path = font.glyphs[glyph];\n fontcopy.glyphs[glyph] = {\n w: path.w,\n k: {},\n d: path.d && \"M\" + path.d.replace(/[mlcxtrv]/g, function (command) {\n return {l: \"L\", c: \"C\", x: \"z\", t: \"m\", r: \"l\", v: \"c\"}[command] || \"M\";\n }) + \"z\"\n };\n if (path.k) {\n for (var k in path.k) if (path[has](k)) {\n fontcopy.glyphs[glyph].k[k] = path.k[k];\n }\n }\n }\n }\n return font;\n };\n \n paperproto.getFont = function (family, weight, style, stretch) {\n stretch = stretch || \"normal\";\n style = style || \"normal\";\n weight = +weight || {normal: 400, bold: 700, lighter: 300, bolder: 800}[weight] || 400;\n if (!R.fonts) {\n return;\n }\n var font = R.fonts[family];\n if (!font) {\n var name = new RegExp(\"(^|\\\\s)\" + family.replace(/[^\\w\\d\\s+!~.:_-]/g, E) + \"(\\\\s|$)\", \"i\");\n for (var fontName in R.fonts) if (R.fonts[has](fontName)) {\n if (name.test(fontName)) {\n font = R.fonts[fontName];\n break;\n }\n }\n }\n var thefont;\n if (font) {\n for (var i = 0, ii = font.length; i < ii; i++) {\n thefont = font[i];\n if (thefont.face[\"font-weight\"] == weight && (thefont.face[\"font-style\"] == style || !thefont.face[\"font-style\"]) && thefont.face[\"font-stretch\"] == stretch) {\n break;\n }\n }\n }\n return thefont;\n };\n \n paperproto.print = function (x, y, string, font, size, origin, letter_spacing) {\n origin = origin || \"middle\"; // baseline|middle\n letter_spacing = mmax(mmin(letter_spacing || 0, 1), -1);\n var letters = Str(string)[split](E),\n shift = 0,\n notfirst = 0,\n path = E,\n scale;\n R.is(font, string) && (font = this.getFont(font));\n if (font) {\n scale = (size || 16) / font.face[\"units-per-em\"];\n var bb = font.face.bbox[split](separator),\n top = +bb[0],\n lineHeight = bb[3] - bb[1],\n shifty = 0,\n height = +bb[1] + (origin == \"baseline\" ? lineHeight + (+font.face.descent) : lineHeight / 2);\n for (var i = 0, ii = letters.length; i < ii; i++) {\n if (letters[i] == \"\\n\") {\n shift = 0;\n curr = 0;\n notfirst = 0;\n shifty += lineHeight;\n } else {\n var prev = notfirst && font.glyphs[letters[i - 1]] || {},\n curr = font.glyphs[letters[i]];\n shift += notfirst ? (prev.w || font.w) + (prev.k && prev.k[letters[i]] || 0) + (font.w * letter_spacing) : 0;\n notfirst = 1;\n }\n if (curr && curr.d) {\n path += R.transformPath(curr.d, [\"t\", shift * scale, shifty * scale, \"s\", scale, scale, top, height, \"t\", (x - top) / scale, (y - height) / scale]);\n }\n }\n }\n return this.path(path).attr({\n fill: \"#000\",\n stroke: \"none\"\n });\n };\n\n \n paperproto.add = function (json) {\n if (R.is(json, \"array\")) {\n var res = this.set(),\n i = 0,\n ii = json.length,\n j;\n for (; i < ii; i++) {\n j = json[i] || {};\n elements[has](j.type) && res.push(this[j.type]().attr(j));\n }\n }\n return res;\n };\n\n \n R.format = function (token, params) {\n var args = R.is(params, array) ? [0][concat](params) : arguments;\n token && R.is(token, string) && args.length - 1 && (token = token.replace(formatrg, function (str, i) {\n return args[++i] == null ? E : args[i];\n }));\n return token || E;\n };\n \n R.fullfill = (function () {\n var tokenRegex = /\\{([^\\}]+)\\}/g,\n objNotationRegex = /(?:(?:^|\\.)(.+?)(?=\\[|\\.|$|\\()|\\[('|\")(.+?)\\2\\])(\\(\\))?/g, // matches .xxxxx or [\"xxxxx\"] to run over object properties\n replacer = function (all, key, obj) {\n var res = obj;\n key.replace(objNotationRegex, function (all, name, quote, quotedName, isFunc) {\n name = name || quotedName;\n if (res) {\n if (name in res) {\n res = res[name];\n }\n typeof res == \"function\" && isFunc && (res = res());\n }\n });\n res = (res == null || res == obj ? all : res) + \"\";\n return res;\n };\n return function (str, obj) {\n return String(str).replace(tokenRegex, function (all, key) {\n return replacer(all, key, obj);\n });\n };\n })();\n \n R.ninja = function () {\n oldRaphael.was ? (g.win.Raphael = oldRaphael.is) : delete Raphael;\n return R;\n };\n \n R.st = setproto;\n // BROWSERIFY MOD: use R._g.doc instead of document\n // Firefox <3.6 fix: http://webreflection.blogspot.com/2009/11/195-chars-to-help-lazy-loading.html\n (function (doc, loaded, f) {\n if (doc.readyState == null && doc.addEventListener){\n doc.addEventListener(loaded, f = function () {\n doc.removeEventListener(loaded, f, false);\n doc.readyState = \"complete\";\n }, false);\n doc.readyState = \"loading\";\n }\n function isLoaded() {\n (/in/).test(doc.readyState) ? setTimeout(isLoaded, 9) : R.eve(\"raphael.DOMload\");\n }\n isLoaded();\n })(R._g.doc, \"DOMContentLoaded\");\n\n // BROWSERIFY MOD: always set file-scope Raphael = R\n // oldRaphael.was ? (g.win.Raphael = R) : (Raphael = R);\n // if (oldRaphael.was) g.win.Raphael = R;\n Raphael = R;\n \n eve.on(\"raphael.DOMload\", function () {\n loaded = true;\n });\n})();\n\n// console.log(Raphael);\n\n// ┌─────────────────────────────────────────────────────────────────────┐ \\\\\n// │ Raphaël - JavaScript Vector Library │ \\\\\n// ├─────────────────────────────────────────────────────────────────────┤ \\\\\n// │ SVG Module │ \\\\\n// ├─────────────────────────────────────────────────────────────────────┤ \\\\\n// │ Copyright (c) 2008-2011 Dmitry Baranovskiy (http://raphaeljs.com) │ \\\\\n// │ Copyright (c) 2008-2011 Sencha Labs (http://sencha.com) │ \\\\\n// │ Licensed under the MIT (http://raphaeljs.com/license.html) license. │ \\\\\n// └─────────────────────────────────────────────────────────────────────┘ \\\\\n// BROWSERIFY MOD: use Raphael instead of window.raphael\nRaphael.svg && function (R) {\n var has = \"hasOwnProperty\",\n Str = String,\n toFloat = parseFloat,\n toInt = parseInt,\n math = Math,\n mmax = math.max,\n abs = math.abs,\n pow = math.pow,\n separator = /[, ]+/,\n eve = R.eve,\n E = \"\",\n S = \" \";\n var xlink = \"http://www.w3.org/1999/xlink\",\n markers = {\n block: \"M5,0 0,2.5 5,5z\",\n classic: \"M5,0 0,2.5 5,5 3.5,3 3.5,2z\",\n diamond: \"M2.5,0 5,2.5 2.5,5 0,2.5z\",\n open: \"M6,1 1,3.5 6,6\",\n oval: \"M2.5,0A2.5,2.5,0,0,1,2.5,5 2.5,2.5,0,0,1,2.5,0z\"\n },\n markerCounter = {};\n R.toString = function () {\n return \"Your browser supports SVG.\\nYou are running Rapha\\xebl \" + this.version;\n };\n var $ = function (el, attr) {\n if (attr) {\n if (typeof el == \"string\") {\n el = $(el);\n }\n for (var key in attr) if (attr[has](key)) {\n if (key.substring(0, 6) == \"xlink:\") {\n el.setAttributeNS(xlink, key.substring(6), Str(attr[key]));\n } else {\n el.setAttribute(key, Str(attr[key]));\n }\n }\n } else {\n el = R._g.doc.createElementNS(\"http://www.w3.org/2000/svg\", el);\n el.style && (el.style.webkitTapHighlightColor = \"rgba(0,0,0,0)\");\n }\n return el;\n },\n addGradientFill = function (element, gradient) {\n var type = \"linear\",\n id = element.id + gradient,\n fx = .5, fy = .5,\n o = element.node,\n SVG = element.paper,\n s = o.style,\n el = R._g.doc.getElementById(id);\n if (!el) {\n gradient = Str(gradient).replace(R._radial_gradient, function (all, _fx, _fy) {\n type = \"radial\";\n if (_fx && _fy) {\n fx = toFloat(_fx);\n fy = toFloat(_fy);\n var dir = ((fy > .5) * 2 - 1);\n pow(fx - .5, 2) + pow(fy - .5, 2) > .25 &&\n (fy = math.sqrt(.25 - pow(fx - .5, 2)) * dir + .5) &&\n fy != .5 &&\n (fy = fy.toFixed(5) - 1e-5 * dir);\n }\n return E;\n });\n gradient = gradient.split(/\\s*\\-\\s*/);\n if (type == \"linear\") {\n var angle = gradient.shift();\n angle = -toFloat(angle);\n if (isNaN(angle)) {\n return null;\n }\n var vector = [0, 0, math.cos(R.rad(angle)), math.sin(R.rad(angle))],\n max = 1 / (mmax(abs(vector[2]), abs(vector[3])) || 1);\n vector[2] *= max;\n vector[3] *= max;\n if (vector[2] < 0) {\n vector[0] = -vector[2];\n vector[2] = 0;\n }\n if (vector[3] < 0) {\n vector[1] = -vector[3];\n vector[3] = 0;\n }\n }\n var dots = R._parseDots(gradient);\n if (!dots) {\n return null;\n }\n id = id.replace(/[\\(\\)\\s,\\xb0#]/g, \"_\");\n \n if (element.gradient && id != element.gradient.id) {\n SVG.defs.removeChild(element.gradient);\n delete element.gradient;\n }\n\n if (!element.gradient) {\n el = $(type + \"Gradient\", {id: id});\n element.gradient = el;\n $(el, type == \"radial\" ? {\n fx: fx,\n fy: fy\n } : {\n x1: vector[0],\n y1: vector[1],\n x2: vector[2],\n y2: vector[3],\n gradientTransform: element.matrix.invert()\n });\n SVG.defs.appendChild(el);\n for (var i = 0, ii = dots.length; i < ii; i++) {\n el.appendChild($(\"stop\", {\n offset: dots[i].offset ? dots[i].offset : i ? \"100%\" : \"0%\",\n \"stop-color\": dots[i].color || \"#fff\"\n }));\n }\n }\n }\n $(o, {\n fill: \"url(#\" + id + \")\",\n opacity: 1,\n \"fill-opacity\": 1\n });\n s.fill = E;\n s.opacity = 1;\n s.fillOpacity = 1;\n return 1;\n },\n updatePosition = function (o) {\n var bbox = o.getBBox(1);\n $(o.pattern, {patternTransform: o.matrix.invert() + \" translate(\" + bbox.x + \",\" + bbox.y + \")\"});\n },\n addArrow = function (o, value, isEnd) {\n if (o.type == \"path\") {\n var values = Str(value).toLowerCase().split(\"-\"),\n p = o.paper,\n se = isEnd ? \"end\" : \"start\",\n node = o.node,\n attrs = o.attrs,\n stroke = attrs[\"stroke-width\"],\n i = values.length,\n type = \"classic\",\n from,\n to,\n dx,\n refX,\n attr,\n w = 3,\n h = 3,\n t = 5;\n while (i--) {\n switch (values[i]) {\n case \"block\":\n case \"classic\":\n case \"oval\":\n case \"diamond\":\n case \"open\":\n case \"none\":\n type = values[i];\n break;\n case \"wide\": h = 5; break;\n case \"narrow\": h = 2; break;\n case \"long\": w = 5; break;\n case \"short\": w = 2; break;\n }\n }\n if (type == \"open\") {\n w += 2;\n h += 2;\n t += 2;\n dx = 1;\n refX = isEnd ? 4 : 1;\n attr = {\n fill: \"none\",\n stroke: attrs.stroke\n };\n } else {\n refX = dx = w / 2;\n attr = {\n fill: attrs.stroke,\n stroke: \"none\"\n };\n }\n if (o._.arrows) {\n if (isEnd) {\n o._.arrows.endPath && markerCounter[o._.arrows.endPath]--;\n o._.arrows.endMarker && markerCounter[o._.arrows.endMarker]--;\n } else {\n o._.arrows.startPath && markerCounter[o._.arrows.startPath]--;\n o._.arrows.startMarker && markerCounter[o._.arrows.startMarker]--;\n }\n } else {\n o._.arrows = {};\n }\n if (type != \"none\") {\n var pathId = \"raphael-marker-\" + type,\n markerId = \"raphael-marker-\" + se + type + w + h;\n if (!R._g.doc.getElementById(pathId)) {\n p.defs.appendChild($($(\"path\"), {\n \"stroke-linecap\": \"round\",\n d: markers[type],\n id: pathId\n }));\n markerCounter[pathId] = 1;\n } else {\n markerCounter[pathId]++;\n }\n var marker = R._g.doc.getElementById(markerId),\n use;\n if (!marker) {\n marker = $($(\"marker\"), {\n id: markerId,\n markerHeight: h,\n markerWidth: w,\n orient: \"auto\",\n refX: refX,\n refY: h / 2\n });\n use = $($(\"use\"), {\n \"xlink:href\": \"#\" + pathId,\n transform: (isEnd ? \"rotate(180 \" + w / 2 + \" \" + h / 2 + \") \" : E) + \"scale(\" + w / t + \",\" + h / t + \")\",\n \"stroke-width\": (1 / ((w / t + h / t) / 2)).toFixed(4)\n });\n marker.appendChild(use);\n p.defs.appendChild(marker);\n markerCounter[markerId] = 1;\n } else {\n markerCounter[markerId]++;\n use = marker.getElementsByTagName(\"use\")[0];\n }\n $(use, attr);\n var delta = dx * (type != \"diamond\" && type != \"oval\");\n if (isEnd) {\n from = o._.arrows.startdx * stroke || 0;\n to = R.getTotalLength(attrs.path) - delta * stroke;\n } else {\n from = delta * stroke;\n to = R.getTotalLength(attrs.path) - (o._.arrows.enddx * stroke || 0);\n }\n attr = {};\n attr[\"marker-\" + se] = \"url(#\" + markerId + \")\";\n if (to || from) {\n attr.d = Raphael.getSubpath(attrs.path, from, to);\n }\n $(node, attr);\n o._.arrows[se + \"Path\"] = pathId;\n o._.arrows[se + \"Marker\"] = markerId;\n o._.arrows[se + \"dx\"] = delta;\n o._.arrows[se + \"Type\"] = type;\n o._.arrows[se + \"String\"] = value;\n } else {\n if (isEnd) {\n from = o._.arrows.startdx * stroke || 0;\n to = R.getTotalLength(attrs.path) - from;\n } else {\n from = 0;\n to = R.getTotalLength(attrs.path) - (o._.arrows.enddx * stroke || 0);\n }\n o._.arrows[se + \"Path\"] && $(node, {d: Raphael.getSubpath(attrs.path, from, to)});\n delete o._.arrows[se + \"Path\"];\n delete o._.arrows[se + \"Marker\"];\n delete o._.arrows[se + \"dx\"];\n delete o._.arrows[se + \"Type\"];\n delete o._.arrows[se + \"String\"];\n }\n for (attr in markerCounter) if (markerCounter[has](attr) && !markerCounter[attr]) {\n var item = R._g.doc.getElementById(attr);\n item && item.parentNode.removeChild(item);\n }\n }\n },\n dasharray = {\n \"\": [0],\n \"none\": [0],\n \"-\": [3, 1],\n \".\": [1, 1],\n \"-.\": [3, 1, 1, 1],\n \"-..\": [3, 1, 1, 1, 1, 1],\n \". \": [1, 3],\n \"- \": [4, 3],\n \"--\": [8, 3],\n \"- .\": [4, 3, 1, 3],\n \"--.\": [8, 3, 1, 3],\n \"--..\": [8, 3, 1, 3, 1, 3]\n },\n addDashes = function (o, value, params) {\n value = dasharray[Str(value).toLowerCase()];\n if (value) {\n var width = o.attrs[\"stroke-width\"] || \"1\",\n butt = {round: width, square: width, butt: 0}[o.attrs[\"stroke-linecap\"] || params[\"stroke-linecap\"]] || 0,\n dashes = [],\n i = value.length;\n while (i--) {\n dashes[i] = value[i] * width + ((i % 2) ? 1 : -1) * butt;\n }\n $(o.node, {\"stroke-dasharray\": dashes.join(\",\")});\n }\n },\n setFillAndStroke = function (o, params) {\n var node = o.node,\n attrs = o.attrs,\n vis = node.style.visibility;\n node.style.visibility = \"hidden\";\n for (var att in params) {\n if (params[has](att)) {\n if (!R._availableAttrs[has](att)) {\n continue;\n }\n var value = params[att];\n attrs[att] = value;\n switch (att) {\n case \"blur\":\n o.blur(value);\n break;\n case \"href\":\n case \"title\":\n case \"target\":\n var pn = node.parentNode;\n if (pn.tagName.toLowerCase() != \"a\") {\n var hl = $(\"a\");\n pn.insertBefore(hl, node);\n hl.appendChild(node);\n pn = hl;\n }\n if (att == \"target\") {\n pn.setAttributeNS(xlink, \"show\", value == \"blank\" ? \"new\" : value);\n } else {\n pn.setAttributeNS(xlink, att, value);\n }\n break;\n case \"cursor\":\n node.style.cursor = value;\n break;\n case \"transform\":\n o.transform(value);\n break;\n case \"arrow-start\":\n addArrow(o, value);\n break;\n case \"arrow-end\":\n addArrow(o, value, 1);\n break;\n case \"clip-rect\":\n var rect = Str(value).split(separator);\n if (rect.length == 4) {\n o.clip && o.clip.parentNode.parentNode.removeChild(o.clip.parentNode);\n var el = $(\"clipPath\"),\n rc = $(\"rect\");\n el.id = R.createUUID();\n $(rc, {\n x: rect[0],\n y: rect[1],\n width: rect[2],\n height: rect[3]\n });\n el.appendChild(rc);\n o.paper.defs.appendChild(el);\n $(node, {\"clip-path\": \"url(#\" + el.id + \")\"});\n o.clip = rc;\n }\n if (!value) {\n var path = node.getAttribute(\"clip-path\");\n if (path) {\n var clip = R._g.doc.getElementById(path.replace(/(^url\\(#|\\)$)/g, E));\n clip && clip.parentNode.removeChild(clip);\n $(node, {\"clip-path\": E});\n delete o.clip;\n }\n }\n break;\n case \"path\":\n if (o.type == \"path\") {\n $(node, {d: value ? attrs.path = R._pathToAbsolute(value) : \"M0,0\"});\n o._.dirty = 1;\n if (o._.arrows) {\n \"startString\" in o._.arrows && addArrow(o, o._.arrows.startString);\n \"endString\" in o._.arrows && addArrow(o, o._.arrows.endString, 1);\n }\n }\n break;\n case \"width\":\n node.setAttribute(att, value);\n o._.dirty = 1;\n if (attrs.fx) {\n att = \"x\";\n value = attrs.x;\n } else {\n break;\n }\n case \"x\":\n if (attrs.fx) {\n value = -attrs.x - (attrs.width || 0);\n }\n case \"rx\":\n if (att == \"rx\" && o.type == \"rect\") {\n break;\n }\n case \"cx\":\n node.setAttribute(att, value);\n o.pattern && updatePosition(o);\n o._.dirty = 1;\n break;\n case \"height\":\n node.setAttribute(att, value);\n o._.dirty = 1;\n if (attrs.fy) {\n att = \"y\";\n value = attrs.y;\n } else {\n break;\n }\n case \"y\":\n if (attrs.fy) {\n value = -attrs.y - (attrs.height || 0);\n }\n case \"ry\":\n if (att == \"ry\" && o.type == \"rect\") {\n break;\n }\n case \"cy\":\n node.setAttribute(att, value);\n o.pattern && updatePosition(o);\n o._.dirty = 1;\n break;\n case \"r\":\n if (o.type == \"rect\") {\n $(node, {rx: value, ry: value});\n } else {\n node.setAttribute(att, value);\n }\n o._.dirty = 1;\n break;\n case \"src\":\n if (o.type == \"image\") {\n node.setAttributeNS(xlink, \"href\", value);\n }\n break;\n case \"stroke-width\":\n if (o._.sx != 1 || o._.sy != 1) {\n value /= mmax(abs(o._.sx), abs(o._.sy)) || 1;\n }\n if (o.paper._vbSize) {\n value *= o.paper._vbSize;\n }\n node.setAttribute(att, value);\n if (attrs[\"stroke-dasharray\"]) {\n addDashes(o, attrs[\"stroke-dasharray\"], params);\n }\n if (o._.arrows) {\n \"startString\" in o._.arrows && addArrow(o, o._.arrows.startString);\n \"endString\" in o._.arrows && addArrow(o, o._.arrows.endString, 1);\n }\n break;\n case \"stroke-dasharray\":\n addDashes(o, value, params);\n break;\n case \"fill\":\n var isURL = Str(value).match(R._ISURL);\n if (isURL) {\n el = $(\"pattern\");\n var ig = $(\"image\");\n el.id = R.createUUID();\n $(el, {x: 0, y: 0, patternUnits: \"userSpaceOnUse\", height: 1, width: 1});\n $(ig, {x: 0, y: 0, \"xlink:href\": isURL[1]});\n el.appendChild(ig);\n\n (function (el) {\n R._preload(isURL[1], function () {\n var w = this.offsetWidth,\n h = this.offsetHeight;\n $(el, {width: w, height: h});\n $(ig, {width: w, height: h});\n o.paper.safari();\n });\n })(el);\n o.paper.defs.appendChild(el);\n $(node, {fill: \"url(#\" + el.id + \")\"});\n o.pattern = el;\n o.pattern && updatePosition(o);\n break;\n }\n var clr = R.getRGB(value);\n if (!clr.error) {\n delete params.gradient;\n delete attrs.gradient;\n !R.is(attrs.opacity, \"undefined\") &&\n R.is(params.opacity, \"undefined\") &&\n $(node, {opacity: attrs.opacity});\n !R.is(attrs[\"fill-opacity\"], \"undefined\") &&\n R.is(params[\"fill-opacity\"], \"undefined\") &&\n $(node, {\"fill-opacity\": attrs[\"fill-opacity\"]});\n } else if ((o.type == \"circle\" || o.type == \"ellipse\" || Str(value).charAt() != \"r\") && addGradientFill(o, value)) {\n if (\"opacity\" in attrs || \"fill-opacity\" in attrs) {\n var gradient = R._g.doc.getElementById(node.getAttribute(\"fill\").replace(/^url\\(#|\\)$/g, E));\n if (gradient) {\n var stops = gradient.getElementsByTagName(\"stop\");\n $(stops[stops.length - 1], {\"stop-opacity\": (\"opacity\" in attrs ? attrs.opacity : 1) * (\"fill-opacity\" in attrs ? attrs[\"fill-opacity\"] : 1)});\n }\n }\n attrs.gradient = value;\n attrs.fill = \"none\";\n break;\n }\n clr[has](\"opacity\") && $(node, {\"fill-opacity\": clr.opacity > 1 ? clr.opacity / 100 : clr.opacity});\n case \"stroke\":\n clr = R.getRGB(value);\n node.setAttribute(att, clr.hex);\n att == \"stroke\" && clr[has](\"opacity\") && $(node, {\"stroke-opacity\": clr.opacity > 1 ? clr.opacity / 100 : clr.opacity});\n if (att == \"stroke\" && o._.arrows) {\n \"startString\" in o._.arrows && addArrow(o, o._.arrows.startString);\n \"endString\" in o._.arrows && addArrow(o, o._.arrows.endString, 1);\n }\n break;\n case \"gradient\":\n (o.type == \"circle\" || o.type == \"ellipse\" || Str(value).charAt() != \"r\") && addGradientFill(o, value);\n break;\n case \"opacity\":\n if (attrs.gradient && !attrs[has](\"stroke-opacity\")) {\n $(node, {\"stroke-opacity\": value > 1 ? value / 100 : value});\n }\n // fall\n case \"fill-opacity\":\n if (attrs.gradient) {\n gradient = R._g.doc.getElementById(node.getAttribute(\"fill\").replace(/^url\\(#|\\)$/g, E));\n if (gradient) {\n stops = gradient.getElementsByTagName(\"stop\");\n $(stops[stops.length - 1], {\"stop-opacity\": value});\n }\n break;\n }\n default:\n att == \"font-size\" && (value = toInt(value, 10) + \"px\");\n var cssrule = att.replace(/(\\-.)/g, function (w) {\n return w.substring(1).toUpperCase();\n });\n node.style[cssrule] = value;\n o._.dirty = 1;\n node.setAttribute(att, value);\n break;\n }\n }\n }\n\n tuneText(o, params);\n node.style.visibility = vis;\n },\n leading = 1.2,\n tuneText = function (el, params) {\n if (el.type != \"text\" || !(params[has](\"text\") || params[has](\"font\") || params[has](\"font-size\") || params[has](\"x\") || params[has](\"y\"))) {\n return;\n }\n var a = el.attrs,\n node = el.node,\n fontSize = node.firstChild ? toInt(R._g.doc.defaultView.getComputedStyle(node.firstChild, E).getPropertyValue(\"font-size\"), 10) : 10;\n\n if (params[has](\"text\")) {\n a.text = params.text;\n while (node.firstChild) {\n node.removeChild(node.firstChild);\n }\n var texts = Str(params.text).split(\"\\n\"),\n tspans = [],\n tspan;\n for (var i = 0, ii = texts.length; i < ii; i++) {\n tspan = $(\"tspan\");\n i && $(tspan, {dy: fontSize * leading, x: a.x});\n tspan.appendChild(R._g.doc.createTextNode(texts[i]));\n node.appendChild(tspan);\n tspans[i] = tspan;\n }\n } else {\n tspans = node.getElementsByTagName(\"tspan\");\n for (i = 0, ii = tspans.length; i < ii; i++) if (i) {\n $(tspans[i], {dy: fontSize * leading, x: a.x});\n } else {\n $(tspans[0], {dy: 0});\n }\n }\n $(node, {x: a.x, y: a.y});\n el._.dirty = 1;\n var bb = el._getBBox(),\n dif = a.y - (bb.y + bb.height / 2);\n dif && R.is(dif, \"finite\") && $(tspans[0], {dy: dif});\n },\n Element = function (node, svg) {\n var X = 0,\n Y = 0;\n \n this[0] = this.node = node;\n \n node.raphael = true;\n \n this.id = R._oid++;\n node.raphaelid = this.id;\n this.matrix = R.matrix();\n this.realPath = null;\n \n this.paper = svg;\n this.attrs = this.attrs || {};\n this._ = {\n transform: [],\n sx: 1,\n sy: 1,\n deg: 0,\n dx: 0,\n dy: 0,\n dirty: 1\n };\n !svg.bottom && (svg.bottom = this);\n \n this.prev = svg.top;\n svg.top && (svg.top.next = this);\n svg.top = this;\n \n this.next = null;\n },\n elproto = R.el;\n\n Element.prototype = elproto;\n elproto.constructor = Element;\n\n R._engine.path = function (pathString, SVG) {\n var el = $(\"path\");\n SVG.canvas && SVG.canvas.appendChild(el);\n var p = new Element(el, SVG);\n p.type = \"path\";\n setFillAndStroke(p, {\n fill: \"none\",\n stroke: \"#000\",\n path: pathString\n });\n return p;\n };\n \n elproto.rotate = function (deg, cx, cy) {\n if (this.removed) {\n return this;\n }\n deg = Str(deg).split(separator);\n if (deg.length - 1) {\n cx = toFloat(deg[1]);\n cy = toFloat(deg[2]);\n }\n deg = toFloat(deg[0]);\n (cy == null) && (cx = cy);\n if (cx == null || cy == null) {\n var bbox = this.getBBox(1);\n cx = bbox.x + bbox.width / 2;\n cy = bbox.y + bbox.height / 2;\n }\n this.transform(this._.transform.concat([[\"r\", deg, cx, cy]]));\n return this;\n };\n \n elproto.scale = function (sx, sy, cx, cy) {\n if (this.removed) {\n return this;\n }\n sx = Str(sx).split(separator);\n if (sx.length - 1) {\n sy = toFloat(sx[1]);\n cx = toFloat(sx[2]);\n cy = toFloat(sx[3]);\n }\n sx = toFloat(sx[0]);\n (sy == null) && (sy = sx);\n (cy == null) && (cx = cy);\n if (cx == null || cy == null) {\n var bbox = this.getBBox(1);\n }\n cx = cx == null ? bbox.x + bbox.width / 2 : cx;\n cy = cy == null ? bbox.y + bbox.height / 2 : cy;\n this.transform(this._.transform.concat([[\"s\", sx, sy, cx, cy]]));\n return this;\n };\n \n elproto.translate = function (dx, dy) {\n if (this.removed) {\n return this;\n }\n dx = Str(dx).split(separator);\n if (dx.length - 1) {\n dy = toFloat(dx[1]);\n }\n dx = toFloat(dx[0]) || 0;\n dy = +dy || 0;\n this.transform(this._.transform.concat([[\"t\", dx, dy]]));\n return this;\n };\n \n elproto.transform = function (tstr) {\n var _ = this._;\n if (tstr == null) {\n return _.transform;\n }\n R._extractTransform(this, tstr);\n\n this.clip && $(this.clip, {transform: this.matrix.invert()});\n this.pattern && updatePosition(this);\n this.node && $(this.node, {transform: this.matrix});\n \n if (_.sx != 1 || _.sy != 1) {\n var sw = this.attrs[has](\"stroke-width\") ? this.attrs[\"stroke-width\"] : 1;\n this.attr({\"stroke-width\": sw});\n }\n\n return this;\n };\n \n elproto.hide = function () {\n !this.removed && this.paper.safari(this.node.style.display = \"none\");\n return this;\n };\n \n elproto.show = function () {\n !this.removed && this.paper.safari(this.node.style.display = \"\");\n return this;\n };\n \n elproto.remove = function () {\n if (this.removed || !this.node.parentNode) {\n return;\n }\n var paper = this.paper;\n paper.__set__ && paper.__set__.exclude(this);\n eve.unbind(\"raphael.*.*.\" + this.id);\n if (this.gradient) {\n paper.defs.removeChild(this.gradient);\n }\n R._tear(this, paper);\n if (this.node.parentNode.tagName.toLowerCase() == \"a\") {\n this.node.parentNode.parentNode.removeChild(this.node.parentNode);\n } else {\n this.node.parentNode.removeChild(this.node);\n }\n for (var i in this) {\n this[i] = typeof this[i] == \"function\" ? R._removedFactory(i) : null;\n }\n this.removed = true;\n };\n elproto._getBBox = function () {\n if (this.node.style.display == \"none\") {\n this.show();\n var hide = true;\n }\n var bbox = {};\n try {\n bbox = this.node.getBBox();\n } catch(e) {\n // Firefox 3.0.x plays badly here\n } finally {\n bbox = bbox || {};\n }\n hide && this.hide();\n return bbox;\n };\n \n elproto.attr = function (name, value) {\n if (this.removed) {\n return this;\n }\n if (name == null) {\n var res = {};\n for (var a in this.attrs) if (this.attrs[has](a)) {\n res[a] = this.attrs[a];\n }\n res.gradient && res.fill == \"none\" && (res.fill = res.gradient) && delete res.gradient;\n res.transform = this._.transform;\n return res;\n }\n if (value == null && R.is(name, \"string\")) {\n if (name == \"fill\" && this.attrs.fill == \"none\" && this.attrs.gradient) {\n return this.attrs.gradient;\n }\n if (name == \"transform\") {\n return this._.transform;\n }\n var names = name.split(separator),\n out = {};\n for (var i = 0, ii = names.length; i < ii; i++) {\n name = names[i];\n if (name in this.attrs) {\n out[name] = this.attrs[name];\n } else if (R.is(this.paper.customAttributes[name], \"function\")) {\n out[name] = this.paper.customAttributes[name].def;\n } else {\n out[name] = R._availableAttrs[name];\n }\n }\n return ii - 1 ? out : out[names[0]];\n }\n if (value == null && R.is(name, \"array\")) {\n out = {};\n for (i = 0, ii = name.length; i < ii; i++) {\n out[name[i]] = this.attr(name[i]);\n }\n return out;\n }\n if (value != null) {\n var params = {};\n params[name] = value;\n } else if (name != null && R.is(name, \"object\")) {\n params = name;\n }\n for (var key in params) {\n eve(\"raphael.attr.\" + key + \".\" + this.id, this, params[key]);\n }\n for (key in this.paper.customAttributes) if (this.paper.customAttributes[has](key) && params[has](key) && R.is(this.paper.customAttributes[key], \"function\")) {\n var par = this.paper.customAttributes[key].apply(this, [].concat(params[key]));\n this.attrs[key] = params[key];\n for (var subkey in par) if (par[has](subkey)) {\n params[subkey] = par[subkey];\n }\n }\n setFillAndStroke(this, params);\n return this;\n };\n \n elproto.toFront = function () {\n if (this.removed) {\n return this;\n }\n if (this.node.parentNode.tagName.toLowerCase() == \"a\") {\n this.node.parentNode.parentNode.appendChild(this.node.parentNode);\n } else {\n this.node.parentNode.appendChild(this.node);\n }\n var svg = this.paper;\n svg.top != this && R._tofront(this, svg);\n return this;\n };\n \n elproto.toBack = function () {\n if (this.removed) {\n return this;\n }\n var parent = this.node.parentNode;\n if (parent.tagName.toLowerCase() == \"a\") {\n parent.parentNode.insertBefore(this.node.parentNode, this.node.parentNode.parentNode.firstChild); \n } else if (parent.firstChild != this.node) {\n parent.insertBefore(this.node, this.node.parentNode.firstChild);\n }\n R._toback(this, this.paper);\n var svg = this.paper;\n return this;\n };\n \n elproto.insertAfter = function (element) {\n if (this.removed) {\n return this;\n }\n var node = element.node || element[element.length - 1].node;\n if (node.nextSibling) {\n node.parentNode.insertBefore(this.node, node.nextSibling);\n } else {\n node.parentNode.appendChild(this.node);\n }\n R._insertafter(this, element, this.paper);\n return this;\n };\n \n elproto.insertBefore = function (element) {\n if (this.removed) {\n return this;\n }\n var node = element.node || element[0].node;\n node.parentNode.insertBefore(this.node, node);\n R._insertbefore(this, element, this.paper);\n return this;\n };\n elproto.blur = function (size) {\n // Experimental. No Safari support. Use it on your own risk.\n var t = this;\n if (+size !== 0) {\n var fltr = $(\"filter\"),\n blur = $(\"feGaussianBlur\");\n t.attrs.blur = size;\n fltr.id = R.createUUID();\n $(blur, {stdDeviation: +size || 1.5});\n fltr.appendChild(blur);\n t.paper.defs.appendChild(fltr);\n t._blur = fltr;\n $(t.node, {filter: \"url(#\" + fltr.id + \")\"});\n } else {\n if (t._blur) {\n t._blur.parentNode.removeChild(t._blur);\n delete t._blur;\n delete t.attrs.blur;\n }\n t.node.removeAttribute(\"filter\");\n }\n };\n R._engine.circle = function (svg, x, y, r) {\n var el = $(\"circle\");\n svg.canvas && svg.canvas.appendChild(el);\n var res = new Element(el, svg);\n res.attrs = {cx: x, cy: y, r: r, fill: \"none\", stroke: \"#000\"};\n res.type = \"circle\";\n $(el, res.attrs);\n return res;\n };\n R._engine.rect = function (svg, x, y, w, h, r) {\n var el = $(\"rect\");\n svg.canvas && svg.canvas.appendChild(el);\n var res = new Element(el, svg);\n res.attrs = {x: x, y: y, width: w, height: h, r: r || 0, rx: r || 0, ry: r || 0, fill: \"none\", stroke: \"#000\"};\n res.type = \"rect\";\n $(el, res.attrs);\n return res;\n };\n R._engine.ellipse = function (svg, x, y, rx, ry) {\n var el = $(\"ellipse\");\n svg.canvas && svg.canvas.appendChild(el);\n var res = new Element(el, svg);\n res.attrs = {cx: x, cy: y, rx: rx, ry: ry, fill: \"none\", stroke: \"#000\"};\n res.type = \"ellipse\";\n $(el, res.attrs);\n return res;\n };\n R._engine.image = function (svg, src, x, y, w, h) {\n var el = $(\"image\");\n $(el, {x: x, y: y, width: w, height: h, preserveAspectRatio: \"none\"});\n el.setAttributeNS(xlink, \"href\", src);\n svg.canvas && svg.canvas.appendChild(el);\n var res = new Element(el, svg);\n res.attrs = {x: x, y: y, width: w, height: h, src: src};\n res.type = \"image\";\n return res;\n };\n R._engine.text = function (svg, x, y, text) {\n var el = $(\"text\");\n svg.canvas && svg.canvas.appendChild(el);\n var res = new Element(el, svg);\n res.attrs = {\n x: x,\n y: y,\n \"text-anchor\": \"middle\",\n text: text,\n font: R._availableAttrs.font,\n stroke: \"none\",\n fill: \"#000\"\n };\n res.type = \"text\";\n setFillAndStroke(res, res.attrs);\n return res;\n };\n R._engine.setSize = function (width, height) {\n this.width = width || this.width;\n this.height = height || this.height;\n this.canvas.setAttribute(\"width\", this.width);\n this.canvas.setAttribute(\"height\", this.height);\n if (this._viewBox) {\n this.setViewBox.apply(this, this._viewBox);\n }\n return this;\n };\n R._engine.create = function () {\n var con = R._getContainer.apply(0, arguments),\n container = con && con.container,\n x = con.x,\n y = con.y,\n width = con.width,\n height = con.height;\n if (!container) {\n throw new Error(\"SVG container not found.\");\n }\n var cnvs = $(\"svg\"),\n css = \"overflow:hidden;\",\n isFloating;\n x = x || 0;\n y = y || 0;\n width = width || 512;\n height = height || 342;\n $(cnvs, {\n height: height,\n version: 1.1,\n width: width,\n xmlns: \"http://www.w3.org/2000/svg\"\n });\n if (container == 1) {\n cnvs.style.cssText = css + \"position:absolute;left:\" + x + \"px;top:\" + y + \"px\";\n R._g.doc.body.appendChild(cnvs);\n isFloating = 1;\n } else {\n cnvs.style.cssText = css + \"position:relative\";\n if (container.firstChild) {\n container.insertBefore(cnvs, container.firstChild);\n } else {\n container.appendChild(cnvs);\n }\n }\n container = new R._Paper;\n container.width = width;\n container.height = height;\n container.canvas = cnvs;\n container.clear();\n container._left = container._top = 0;\n isFloating && (container.renderfix = function () {});\n container.renderfix();\n return container;\n };\n R._engine.setViewBox = function (x, y, w, h, fit) {\n eve(\"raphael.setViewBox\", this, this._viewBox, [x, y, w, h, fit]);\n var size = mmax(w / this.width, h / this.height),\n top = this.top,\n aspectRatio = fit ? \"meet\" : \"xMinYMin\",\n vb,\n sw;\n if (x == null) {\n if (this._vbSize) {\n size = 1;\n }\n delete this._vbSize;\n vb = \"0 0 \" + this.width + S + this.height;\n } else {\n this._vbSize = size;\n vb = x + S + y + S + w + S + h;\n }\n $(this.canvas, {\n viewBox: vb,\n preserveAspectRatio: aspectRatio\n });\n while (size && top) {\n sw = \"stroke-width\" in top.attrs ? top.attrs[\"stroke-width\"] : 1;\n top.attr({\"stroke-width\": sw});\n top._.dirty = 1;\n top._.dirtyT = 1;\n top = top.prev;\n }\n this._viewBox = [x, y, w, h, !!fit];\n return this;\n };\n \n R.prototype.renderfix = function () {\n var cnvs = this.canvas,\n s = cnvs.style,\n pos;\n try {\n pos = cnvs.getScreenCTM() || cnvs.createSVGMatrix();\n } catch (e) {\n // BROWSERIFY MOD: this will fail with jsdom since it's SVG 1.0,\n // but in jsdom this whole function isn't needed anyways\n try {\n pos = cnvs.createSVGMatrix();\n } catch (e) {\n return;\n }\n }\n var left = -pos.e % 1,\n top = -pos.f % 1;\n if (left || top) {\n if (left) {\n this._left = (this._left + left) % 1;\n s.left = this._left + \"px\";\n }\n if (top) {\n this._top = (this._top + top) % 1;\n s.top = this._top + \"px\";\n }\n }\n };\n \n R.prototype.clear = function () {\n R.eve(\"raphael.clear\", this);\n var c = this.canvas;\n while (c.firstChild) {\n c.removeChild(c.firstChild);\n }\n this.bottom = this.top = null;\n (this.desc = $(\"desc\")).appendChild(R._g.doc.createTextNode(\"Created with Rapha\\xebl \" + R.version));\n c.appendChild(this.desc);\n c.appendChild(this.defs = $(\"defs\"));\n };\n \n R.prototype.remove = function () {\n eve(\"raphael.remove\", this);\n this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas);\n for (var i in this) {\n this[i] = typeof this[i] == \"function\" ? R._removedFactory(i) : null;\n }\n };\n var setproto = R.st;\n for (var method in elproto) if (elproto[has](method) && !setproto[has](method)) {\n setproto[method] = (function (methodname) {\n return function () {\n var arg = arguments;\n return this.forEach(function (el) {\n el[methodname].apply(el, arg);\n });\n };\n })(method);\n }\n}(Raphael);\n\n// ┌─────────────────────────────────────────────────────────────────────┐ \\\\\n// │ Raphaël - JavaScript Vector Library │ \\\\\n// ├─────────────────────────────────────────────────────────────────────┤ \\\\\n// │ VML Module │ \\\\\n// ├─────────────────────────────────────────────────────────────────────┤ \\\\\n// │ Copyright (c) 2008-2011 Dmitry Baranovskiy (http://raphaeljs.com) │ \\\\\n// │ Copyright (c) 2008-2011 Sencha Labs (http://sencha.com) │ \\\\\n// │ Licensed under the MIT (http://raphaeljs.com/license.html) license. │ \\\\\n// └─────────────────────────────────────────────────────────────────────┘ \\\\\nRaphael.vml && function (R) {\n var has = \"hasOwnProperty\",\n Str = String,\n toFloat = parseFloat,\n math = Math,\n round = math.round,\n mmax = math.max,\n mmin = math.min,\n abs = math.abs,\n fillString = \"fill\",\n separator = /[, ]+/,\n eve = R.eve,\n ms = \" progid:DXImageTransform.Microsoft\",\n S = \" \",\n E = \"\",\n map = {M: \"m\", L: \"l\", C: \"c\", Z: \"x\", m: \"t\", l: \"r\", c: \"v\", z: \"x\"},\n bites = /([clmz]),?([^clmz]*)/gi,\n blurregexp = / progid:\\S+Blur\\([^\\)]+\\)/g,\n val = /-?[^,\\s-]+/g,\n cssDot = \"position:absolute;left:0;top:0;width:1px;height:1px\",\n zoom = 21600,\n pathTypes = {path: 1, rect: 1, image: 1},\n ovalTypes = {circle: 1, ellipse: 1},\n path2vml = function (path) {\n var total = /[ahqstv]/ig,\n command = R._pathToAbsolute;\n Str(path).match(total) && (command = R._path2curve);\n total = /[clmz]/g;\n if (command == R._pathToAbsolute && !Str(path).match(total)) {\n var res = Str(path).replace(bites, function (all, command, args) {\n var vals = [],\n isMove = command.toLowerCase() == \"m\",\n res = map[command];\n args.replace(val, function (value) {\n if (isMove && vals.length == 2) {\n res += vals + map[command == \"m\" ? \"l\" : \"L\"];\n vals = [];\n }\n vals.push(round(value * zoom));\n });\n return res + vals;\n });\n return res;\n }\n var pa = command(path), p, r;\n res = [];\n for (var i = 0, ii = pa.length; i < ii; i++) {\n p = pa[i];\n r = pa[i][0].toLowerCase();\n r == \"z\" && (r = \"x\");\n for (var j = 1, jj = p.length; j < jj; j++) {\n r += round(p[j] * zoom) + (j != jj - 1 ? \",\" : E);\n }\n res.push(r);\n }\n return res.join(S);\n },\n compensation = function (deg, dx, dy) {\n var m = R.matrix();\n m.rotate(-deg, .5, .5);\n return {\n dx: m.x(dx, dy),\n dy: m.y(dx, dy)\n };\n },\n setCoords = function (p, sx, sy, dx, dy, deg) {\n var _ = p._,\n m = p.matrix,\n fillpos = _.fillpos,\n o = p.node,\n s = o.style,\n y = 1,\n flip = \"\",\n dxdy,\n kx = zoom / sx,\n ky = zoom / sy;\n s.visibility = \"hidden\";\n if (!sx || !sy) {\n return;\n }\n o.coordsize = abs(kx) + S + abs(ky);\n s.rotation = deg * (sx * sy < 0 ? -1 : 1);\n if (deg) {\n var c = compensation(deg, dx, dy);\n dx = c.dx;\n dy = c.dy;\n }\n sx < 0 && (flip += \"x\");\n sy < 0 && (flip += \" y\") && (y = -1);\n s.flip = flip;\n o.coordorigin = (dx * -kx) + S + (dy * -ky);\n if (fillpos || _.fillsize) {\n var fill = o.getElementsByTagName(fillString);\n fill = fill && fill[0];\n o.removeChild(fill);\n if (fillpos) {\n c = compensation(deg, m.x(fillpos[0], fillpos[1]), m.y(fillpos[0], fillpos[1]));\n fill.position = c.dx * y + S + c.dy * y;\n }\n if (_.fillsize) {\n fill.size = _.fillsize[0] * abs(sx) + S + _.fillsize[1] * abs(sy);\n }\n o.appendChild(fill);\n }\n s.visibility = \"visible\";\n };\n R.toString = function () {\n return \"Your browser doesn\\u2019t support SVG. Falling down to VML.\\nYou are running Rapha\\xebl \" + this.version;\n };\n var addArrow = function (o, value, isEnd) {\n var values = Str(value).toLowerCase().split(\"-\"),\n se = isEnd ? \"end\" : \"start\",\n i = values.length,\n type = \"classic\",\n w = \"medium\",\n h = \"medium\";\n while (i--) {\n switch (values[i]) {\n case \"block\":\n case \"classic\":\n case \"oval\":\n case \"diamond\":\n case \"open\":\n case \"none\":\n type = values[i];\n break;\n case \"wide\":\n case \"narrow\": h = values[i]; break;\n case \"long\":\n case \"short\": w = values[i]; break;\n }\n }\n var stroke = o.node.getElementsByTagName(\"stroke\")[0];\n stroke[se + \"arrow\"] = type;\n stroke[se + \"arrowlength\"] = w;\n stroke[se + \"arrowwidth\"] = h;\n },\n setFillAndStroke = function (o, params) {\n // o.paper.canvas.style.display = \"none\";\n o.attrs = o.attrs || {};\n var node = o.node,\n a = o.attrs,\n s = node.style,\n xy,\n newpath = pathTypes[o.type] && (params.x != a.x || params.y != a.y || params.width != a.width || params.height != a.height || params.cx != a.cx || params.cy != a.cy || params.rx != a.rx || params.ry != a.ry || params.r != a.r),\n isOval = ovalTypes[o.type] && (a.cx != params.cx || a.cy != params.cy || a.r != params.r || a.rx != params.rx || a.ry != params.ry),\n res = o;\n\n\n for (var par in params) if (params[has](par)) {\n a[par] = params[par];\n }\n if (newpath) {\n a.path = R._getPath[o.type](o);\n o._.dirty = 1;\n }\n params.href && (node.href = params.href);\n params.title && (node.title = params.title);\n params.target && (node.target = params.target);\n params.cursor && (s.cursor = params.cursor);\n \"blur\" in params && o.blur(params.blur);\n if (params.path && o.type == \"path\" || newpath) {\n node.path = path2vml(~Str(a.path).toLowerCase().indexOf(\"r\") ? R._pathToAbsolute(a.path) : a.path);\n if (o.type == \"image\") {\n o._.fillpos = [a.x, a.y];\n o._.fillsize = [a.width, a.height];\n setCoords(o, 1, 1, 0, 0, 0);\n }\n }\n \"transform\" in params && o.transform(params.transform);\n if (isOval) {\n var cx = +a.cx,\n cy = +a.cy,\n rx = +a.rx || +a.r || 0,\n ry = +a.ry || +a.r || 0;\n node.path = R.format(\"ar{0},{1},{2},{3},{4},{1},{4},{1}x\", round((cx - rx) * zoom), round((cy - ry) * zoom), round((cx + rx) * zoom), round((cy + ry) * zoom), round(cx * zoom));\n }\n if (\"clip-rect\" in params) {\n var rect = Str(params[\"clip-rect\"]).split(separator);\n if (rect.length == 4) {\n rect[2] = +rect[2] + (+rect[0]);\n rect[3] = +rect[3] + (+rect[1]);\n var div = node.clipRect || R._g.doc.createElement(\"div\"),\n dstyle = div.style;\n dstyle.clip = R.format(\"rect({1}px {2}px {3}px {0}px)\", rect);\n if (!node.clipRect) {\n dstyle.position = \"absolute\";\n dstyle.top = 0;\n dstyle.left = 0;\n dstyle.width = o.paper.width + \"px\";\n dstyle.height = o.paper.height + \"px\";\n node.parentNode.insertBefore(div, node);\n div.appendChild(node);\n node.clipRect = div;\n }\n }\n if (!params[\"clip-rect\"]) {\n node.clipRect && (node.clipRect.style.clip = \"auto\");\n }\n }\n if (o.textpath) {\n var textpathStyle = o.textpath.style;\n params.font && (textpathStyle.font = params.font);\n params[\"font-family\"] && (textpathStyle.fontFamily = '\"' + params[\"font-family\"].split(\",\")[0].replace(/^['\"]+|['\"]+$/g, E) + '\"');\n params[\"font-size\"] && (textpathStyle.fontSize = params[\"font-size\"]);\n params[\"font-weight\"] && (textpathStyle.fontWeight = params[\"font-weight\"]);\n params[\"font-style\"] && (textpathStyle.fontStyle = params[\"font-style\"]);\n }\n if (\"arrow-start\" in params) {\n addArrow(res, params[\"arrow-start\"]);\n }\n if (\"arrow-end\" in params) {\n addArrow(res, params[\"arrow-end\"], 1);\n }\n if (params.opacity != null || \n params[\"stroke-width\"] != null ||\n params.fill != null ||\n params.src != null ||\n params.stroke != null ||\n params[\"stroke-width\"] != null ||\n params[\"stroke-opacity\"] != null ||\n params[\"fill-opacity\"] != null ||\n params[\"stroke-dasharray\"] != null ||\n params[\"stroke-miterlimit\"] != null ||\n params[\"stroke-linejoin\"] != null ||\n params[\"stroke-linecap\"] != null) {\n var fill = node.getElementsByTagName(fillString),\n newfill = false;\n fill = fill && fill[0];\n !fill && (newfill = fill = createNode(fillString));\n if (o.type == \"image\" && params.src) {\n fill.src = params.src;\n }\n params.fill && (fill.on = true);\n if (fill.on == null || params.fill == \"none\" || params.fill === null) {\n fill.on = false;\n }\n if (fill.on && params.fill) {\n var isURL = Str(params.fill).match(R._ISURL);\n if (isURL) {\n fill.parentNode == node && node.removeChild(fill);\n fill.rotate = true;\n fill.src = isURL[1];\n fill.type = \"tile\";\n var bbox = o.getBBox(1);\n fill.position = bbox.x + S + bbox.y;\n o._.fillpos = [bbox.x, bbox.y];\n\n R._preload(isURL[1], function () {\n o._.fillsize = [this.offsetWidth, this.offsetHeight];\n });\n } else {\n fill.color = R.getRGB(params.fill).hex;\n fill.src = E;\n fill.type = \"solid\";\n if (R.getRGB(params.fill).error && (res.type in {circle: 1, ellipse: 1} || Str(params.fill).charAt() != \"r\") && addGradientFill(res, params.fill, fill)) {\n a.fill = \"none\";\n a.gradient = params.fill;\n fill.rotate = false;\n }\n }\n }\n if (\"fill-opacity\" in params || \"opacity\" in params) {\n var opacity = ((+a[\"fill-opacity\"] + 1 || 2) - 1) * ((+a.opacity + 1 || 2) - 1) * ((+R.getRGB(params.fill).o + 1 || 2) - 1);\n opacity = mmin(mmax(opacity, 0), 1);\n fill.opacity = opacity;\n if (fill.src) {\n fill.color = \"none\";\n }\n }\n node.appendChild(fill);\n var stroke = (node.getElementsByTagName(\"stroke\") && node.getElementsByTagName(\"stroke\")[0]),\n newstroke = false;\n !stroke && (newstroke = stroke = createNode(\"stroke\"));\n if ((params.stroke && params.stroke != \"none\") ||\n params[\"stroke-width\"] ||\n params[\"stroke-opacity\"] != null ||\n params[\"stroke-dasharray\"] ||\n params[\"stroke-miterlimit\"] ||\n params[\"stroke-linejoin\"] ||\n params[\"stroke-linecap\"]) {\n stroke.on = true;\n }\n (params.stroke == \"none\" || params.stroke === null || stroke.on == null || params.stroke == 0 || params[\"stroke-width\"] == 0) && (stroke.on = false);\n var strokeColor = R.getRGB(params.stroke);\n stroke.on && params.stroke && (stroke.color = strokeColor.hex);\n opacity = ((+a[\"stroke-opacity\"] + 1 || 2) - 1) * ((+a.opacity + 1 || 2) - 1) * ((+strokeColor.o + 1 || 2) - 1);\n var width = (toFloat(params[\"stroke-width\"]) || 1) * .75;\n opacity = mmin(mmax(opacity, 0), 1);\n params[\"stroke-width\"] == null && (width = a[\"stroke-width\"]);\n params[\"stroke-width\"] && (stroke.weight = width);\n width && width < 1 && (opacity *= width) && (stroke.weight = 1);\n stroke.opacity = opacity;\n \n params[\"stroke-linejoin\"] && (stroke.joinstyle = params[\"stroke-linejoin\"] || \"miter\");\n stroke.miterlimit = params[\"stroke-miterlimit\"] || 8;\n params[\"stroke-linecap\"] && (stroke.endcap = params[\"stroke-linecap\"] == \"butt\" ? \"flat\" : params[\"stroke-linecap\"] == \"square\" ? \"square\" : \"round\");\n if (params[\"stroke-dasharray\"]) {\n var dasharray = {\n \"-\": \"shortdash\",\n \".\": \"shortdot\",\n \"-.\": \"shortdashdot\",\n \"-..\": \"shortdashdotdot\",\n \". \": \"dot\",\n \"- \": \"dash\",\n \"--\": \"longdash\",\n \"- .\": \"dashdot\",\n \"--.\": \"longdashdot\",\n \"--..\": \"longdashdotdot\"\n };\n stroke.dashstyle = dasharray[has](params[\"stroke-dasharray\"]) ? dasharray[params[\"stroke-dasharray\"]] : E;\n }\n newstroke && node.appendChild(stroke);\n }\n if (res.type == \"text\") {\n res.paper.canvas.style.display = E;\n var span = res.paper.span,\n m = 100,\n fontSize = a.font && a.font.match(/\\d+(?:\\.\\d*)?(?=px)/);\n s = span.style;\n a.font && (s.font = a.font);\n a[\"font-family\"] && (s.fontFamily = a[\"font-family\"]);\n a[\"font-weight\"] && (s.fontWeight = a[\"font-weight\"]);\n a[\"font-style\"] && (s.fontStyle = a[\"font-style\"]);\n fontSize = toFloat(a[\"font-size\"] || fontSize && fontSize[0]) || 10;\n s.fontSize = fontSize * m + \"px\";\n res.textpath.string && (span.innerHTML = Str(res.textpath.string).replace(/</g, \"<\").replace(/&/g, \"&\").replace(/\\n/g, \"<br>\"));\n var brect = span.getBoundingClientRect();\n res.W = a.w = (brect.right - brect.left) / m;\n res.H = a.h = (brect.bottom - brect.top) / m;\n // res.paper.canvas.style.display = \"none\";\n res.X = a.x;\n res.Y = a.y + res.H / 2;\n\n (\"x\" in params || \"y\" in params) && (res.path.v = R.format(\"m{0},{1}l{2},{1}\", round(a.x * zoom), round(a.y * zoom), round(a.x * zoom) + 1));\n var dirtyattrs = [\"x\", \"y\", \"text\", \"font\", \"font-family\", \"font-weight\", \"font-style\", \"font-size\"];\n for (var d = 0, dd = dirtyattrs.length; d < dd; d++) if (dirtyattrs[d] in params) {\n res._.dirty = 1;\n break;\n }\n \n // text-anchor emulation\n switch (a[\"text-anchor\"]) {\n case \"start\":\n res.textpath.style[\"v-text-align\"] = \"left\";\n res.bbx = res.W / 2;\n break;\n case \"end\":\n res.textpath.style[\"v-text-align\"] = \"right\";\n res.bbx = -res.W / 2;\n break;\n default:\n res.textpath.style[\"v-text-align\"] = \"center\";\n res.bbx = 0;\n break;\n }\n res.textpath.style[\"v-text-kern\"] = true;\n }\n // res.paper.canvas.style.display = E;\n },\n addGradientFill = function (o, gradient, fill) {\n o.attrs = o.attrs || {};\n var attrs = o.attrs,\n pow = Math.pow,\n opacity,\n oindex,\n type = \"linear\",\n fxfy = \".5 .5\";\n o.attrs.gradient = gradient;\n gradient = Str(gradient).replace(R._radial_gradient, function (all, fx, fy) {\n type = \"radial\";\n if (fx && fy) {\n fx = toFloat(fx);\n fy = toFloat(fy);\n pow(fx - .5, 2) + pow(fy - .5, 2) > .25 && (fy = math.sqrt(.25 - pow(fx - .5, 2)) * ((fy > .5) * 2 - 1) + .5);\n fxfy = fx + S + fy;\n }\n return E;\n });\n gradient = gradient.split(/\\s*\\-\\s*/);\n if (type == \"linear\") {\n var angle = gradient.shift();\n angle = -toFloat(angle);\n if (isNaN(angle)) {\n return null;\n }\n }\n var dots = R._parseDots(gradient);\n if (!dots) {\n return null;\n }\n o = o.shape || o.node;\n if (dots.length) {\n o.removeChild(fill);\n fill.on = true;\n fill.method = \"none\";\n fill.color = dots[0].color;\n fill.color2 = dots[dots.length - 1].color;\n var clrs = [];\n for (var i = 0, ii = dots.length; i < ii; i++) {\n dots[i].offset && clrs.push(dots[i].offset + S + dots[i].color);\n }\n fill.colors = clrs.length ? clrs.join() : \"0% \" + fill.color;\n if (type == \"radial\") {\n fill.type = \"gradientTitle\";\n fill.focus = \"100%\";\n fill.focussize = \"0 0\";\n fill.focusposition = fxfy;\n fill.angle = 0;\n } else {\n // fill.rotate= true;\n fill.type = \"gradient\";\n fill.angle = (270 - angle) % 360;\n }\n o.appendChild(fill);\n }\n return 1;\n },\n Element = function (node, vml) {\n this[0] = this.node = node;\n node.raphael = true;\n this.id = R._oid++;\n node.raphaelid = this.id;\n this.X = 0;\n this.Y = 0;\n this.attrs = {};\n this.paper = vml;\n this.matrix = R.matrix();\n this._ = {\n transform: [],\n sx: 1,\n sy: 1,\n dx: 0,\n dy: 0,\n deg: 0,\n dirty: 1,\n dirtyT: 1\n };\n !vml.bottom && (vml.bottom = this);\n this.prev = vml.top;\n vml.top && (vml.top.next = this);\n vml.top = this;\n this.next = null;\n };\n var elproto = R.el;\n\n Element.prototype = elproto;\n elproto.constructor = Element;\n elproto.transform = function (tstr) {\n if (tstr == null) {\n return this._.transform;\n }\n var vbs = this.paper._viewBoxShift,\n vbt = vbs ? \"s\" + [vbs.scale, vbs.scale] + \"-1-1t\" + [vbs.dx, vbs.dy] : E,\n oldt;\n if (vbs) {\n oldt = tstr = Str(tstr).replace(/\\.{3}|\\u2026/g, this._.transform || E);\n }\n R._extractTransform(this, vbt + tstr);\n var matrix = this.matrix.clone(),\n skew = this.skew,\n o = this.node,\n split,\n isGrad = ~Str(this.attrs.fill).indexOf(\"-\"),\n isPatt = !Str(this.attrs.fill).indexOf(\"url(\");\n matrix.translate(-.5, -.5);\n if (isPatt || isGrad || this.type == \"image\") {\n skew.matrix = \"1 0 0 1\";\n skew.offset = \"0 0\";\n split = matrix.split();\n if ((isGrad && split.noRotation) || !split.isSimple) {\n o.style.filter = matrix.toFilter();\n var bb = this.getBBox(),\n bbt = this.getBBox(1),\n dx = bb.x - bbt.x,\n dy = bb.y - bbt.y;\n o.coordorigin = (dx * -zoom) + S + (dy * -zoom);\n setCoords(this, 1, 1, dx, dy, 0);\n } else {\n o.style.filter = E;\n setCoords(this, split.scalex, split.scaley, split.dx, split.dy, split.rotate);\n }\n } else {\n o.style.filter = E;\n skew.matrix = Str(matrix);\n skew.offset = matrix.offset();\n }\n oldt && (this._.transform = oldt);\n return this;\n };\n elproto.rotate = function (deg, cx, cy) {\n if (this.removed) {\n return this;\n }\n if (deg == null) {\n return;\n }\n deg = Str(deg).split(separator);\n if (deg.length - 1) {\n cx = toFloat(deg[1]);\n cy = toFloat(deg[2]);\n }\n deg = toFloat(deg[0]);\n (cy == null) && (cx = cy);\n if (cx == null || cy == null) {\n var bbox = this.getBBox(1);\n cx = bbox.x + bbox.width / 2;\n cy = bbox.y + bbox.height / 2;\n }\n this._.dirtyT = 1;\n this.transform(this._.transform.concat([[\"r\", deg, cx, cy]]));\n return this;\n };\n elproto.translate = function (dx, dy) {\n if (this.removed) {\n return this;\n }\n dx = Str(dx).split(separator);\n if (dx.length - 1) {\n dy = toFloat(dx[1]);\n }\n dx = toFloat(dx[0]) || 0;\n dy = +dy || 0;\n if (this._.bbox) {\n this._.bbox.x += dx;\n this._.bbox.y += dy;\n }\n this.transform(this._.transform.concat([[\"t\", dx, dy]]));\n return this;\n };\n elproto.scale = function (sx, sy, cx, cy) {\n if (this.removed) {\n return this;\n }\n sx = Str(sx).split(separator);\n if (sx.length - 1) {\n sy = toFloat(sx[1]);\n cx = toFloat(sx[2]);\n cy = toFloat(sx[3]);\n isNaN(cx) && (cx = null);\n isNaN(cy) && (cy = null);\n }\n sx = toFloat(sx[0]);\n (sy == null) && (sy = sx);\n (cy == null) && (cx = cy);\n if (cx == null || cy == null) {\n var bbox = this.getBBox(1);\n }\n cx = cx == null ? bbox.x + bbox.width / 2 : cx;\n cy = cy == null ? bbox.y + bbox.height / 2 : cy;\n \n this.transform(this._.transform.concat([[\"s\", sx, sy, cx, cy]]));\n this._.dirtyT = 1;\n return this;\n };\n elproto.hide = function () {\n !this.removed && (this.node.style.display = \"none\");\n return this;\n };\n elproto.show = function () {\n !this.removed && (this.node.style.display = E);\n return this;\n };\n elproto._getBBox = function () {\n if (this.removed) {\n return {};\n }\n return {\n x: this.X + (this.bbx || 0) - this.W / 2,\n y: this.Y - this.H,\n width: this.W,\n height: this.H\n };\n };\n elproto.remove = function () {\n if (this.removed || !this.node.parentNode) {\n return;\n }\n this.paper.__set__ && this.paper.__set__.exclude(this);\n R.eve.unbind(\"raphael.*.*.\" + this.id);\n R._tear(this, this.paper);\n this.node.parentNode.removeChild(this.node);\n this.shape && this.shape.parentNode.removeChild(this.shape);\n for (var i in this) {\n this[i] = typeof this[i] == \"function\" ? R._removedFactory(i) : null;\n }\n this.removed = true;\n };\n elproto.attr = function (name, value) {\n if (this.removed) {\n return this;\n }\n if (name == null) {\n var res = {};\n for (var a in this.attrs) if (this.attrs[has](a)) {\n res[a] = this.attrs[a];\n }\n res.gradient && res.fill == \"none\" && (res.fill = res.gradient) && delete res.gradient;\n res.transform = this._.transform;\n return res;\n }\n if (value == null && R.is(name, \"string\")) {\n if (name == fillString && this.attrs.fill == \"none\" && this.attrs.gradient) {\n return this.attrs.gradient;\n }\n var names = name.split(separator),\n out = {};\n for (var i = 0, ii = names.length; i < ii; i++) {\n name = names[i];\n if (name in this.attrs) {\n out[name] = this.attrs[name];\n } else if (R.is(this.paper.customAttributes[name], \"function\")) {\n out[name] = this.paper.customAttributes[name].def;\n } else {\n out[name] = R._availableAttrs[name];\n }\n }\n return ii - 1 ? out : out[names[0]];\n }\n if (this.attrs && value == null && R.is(name, \"array\")) {\n out = {};\n for (i = 0, ii = name.length; i < ii; i++) {\n out[name[i]] = this.attr(name[i]);\n }\n return out;\n }\n var params;\n if (value != null) {\n params = {};\n params[name] = value;\n }\n value == null && R.is(name, \"object\") && (params = name);\n for (var key in params) {\n eve(\"raphael.attr.\" + key + \".\" + this.id, this, params[key]);\n }\n if (params) {\n for (key in this.paper.customAttributes) if (this.paper.customAttributes[has](key) && params[has](key) && R.is(this.paper.customAttributes[key], \"function\")) {\n var par = this.paper.customAttributes[key].apply(this, [].concat(params[key]));\n this.attrs[key] = params[key];\n for (var subkey in par) if (par[has](subkey)) {\n params[subkey] = par[subkey];\n }\n }\n // this.paper.canvas.style.display = \"none\";\n if (params.text && this.type == \"text\") {\n this.textpath.string = params.text;\n }\n setFillAndStroke(this, params);\n // this.paper.canvas.style.display = E;\n }\n return this;\n };\n elproto.toFront = function () {\n !this.removed && this.node.parentNode.appendChild(this.node);\n this.paper && this.paper.top != this && R._tofront(this, this.paper);\n return this;\n };\n elproto.toBack = function () {\n if (this.removed) {\n return this;\n }\n if (this.node.parentNode.firstChild != this.node) {\n this.node.parentNode.insertBefore(this.node, this.node.parentNode.firstChild);\n R._toback(this, this.paper);\n }\n return this;\n };\n elproto.insertAfter = function (element) {\n if (this.removed) {\n return this;\n }\n if (element.constructor == R.st.constructor) {\n element = element[element.length - 1];\n }\n if (element.node.nextSibling) {\n element.node.parentNode.insertBefore(this.node, element.node.nextSibling);\n } else {\n element.node.parentNode.appendChild(this.node);\n }\n R._insertafter(this, element, this.paper);\n return this;\n };\n elproto.insertBefore = function (element) {\n if (this.removed) {\n return this;\n }\n if (element.constructor == R.st.constructor) {\n element = element[0];\n }\n element.node.parentNode.insertBefore(this.node, element.node);\n R._insertbefore(this, element, this.paper);\n return this;\n };\n elproto.blur = function (size) {\n var s = this.node.runtimeStyle,\n f = s.filter;\n f = f.replace(blurregexp, E);\n if (+size !== 0) {\n this.attrs.blur = size;\n s.filter = f + S + ms + \".Blur(pixelradius=\" + (+size || 1.5) + \")\";\n s.margin = R.format(\"-{0}px 0 0 -{0}px\", round(+size || 1.5));\n } else {\n s.filter = f;\n s.margin = 0;\n delete this.attrs.blur;\n }\n };\n\n R._engine.path = function (pathString, vml) {\n var el = createNode(\"shape\");\n el.style.cssText = cssDot;\n el.coordsize = zoom + S + zoom;\n el.coordorigin = vml.coordorigin;\n var p = new Element(el, vml),\n attr = {fill: \"none\", stroke: \"#000\"};\n pathString && (attr.path = pathString);\n p.type = \"path\";\n p.path = [];\n p.Path = E;\n setFillAndStroke(p, attr);\n vml.canvas.appendChild(el);\n var skew = createNode(\"skew\");\n skew.on = true;\n el.appendChild(skew);\n p.skew = skew;\n p.transform(E);\n return p;\n };\n R._engine.rect = function (vml, x, y, w, h, r) {\n var path = R._rectPath(x, y, w, h, r),\n res = vml.path(path),\n a = res.attrs;\n res.X = a.x = x;\n res.Y = a.y = y;\n res.W = a.width = w;\n res.H = a.height = h;\n a.r = r;\n a.path = path;\n res.type = \"rect\";\n return res;\n };\n R._engine.ellipse = function (vml, x, y, rx, ry) {\n var res = vml.path(),\n a = res.attrs;\n res.X = x - rx;\n res.Y = y - ry;\n res.W = rx * 2;\n res.H = ry * 2;\n res.type = \"ellipse\";\n setFillAndStroke(res, {\n cx: x,\n cy: y,\n rx: rx,\n ry: ry\n });\n return res;\n };\n R._engine.circle = function (vml, x, y, r) {\n var res = vml.path(),\n a = res.attrs;\n res.X = x - r;\n res.Y = y - r;\n res.W = res.H = r * 2;\n res.type = \"circle\";\n setFillAndStroke(res, {\n cx: x,\n cy: y,\n r: r\n });\n return res;\n };\n R._engine.image = function (vml, src, x, y, w, h) {\n var path = R._rectPath(x, y, w, h),\n res = vml.path(path).attr({stroke: \"none\"}),\n a = res.attrs,\n node = res.node,\n fill = node.getElementsByTagName(fillString)[0];\n a.src = src;\n res.X = a.x = x;\n res.Y = a.y = y;\n res.W = a.width = w;\n res.H = a.height = h;\n a.path = path;\n res.type = \"image\";\n fill.parentNode == node && node.removeChild(fill);\n fill.rotate = true;\n fill.src = src;\n fill.type = \"tile\";\n res._.fillpos = [x, y];\n res._.fillsize = [w, h];\n node.appendChild(fill);\n setCoords(res, 1, 1, 0, 0, 0);\n return res;\n };\n R._engine.text = function (vml, x, y, text) {\n var el = createNode(\"shape\"),\n path = createNode(\"path\"),\n o = createNode(\"textpath\");\n x = x || 0;\n y = y || 0;\n text = text || \"\";\n path.v = R.format(\"m{0},{1}l{2},{1}\", round(x * zoom), round(y * zoom), round(x * zoom) + 1);\n path.textpathok = true;\n o.string = Str(text);\n o.on = true;\n el.style.cssText = cssDot;\n el.coordsize = zoom + S + zoom;\n el.coordorigin = \"0 0\";\n var p = new Element(el, vml),\n attr = {\n fill: \"#000\",\n stroke: \"none\",\n font: R._availableAttrs.font,\n text: text\n };\n p.shape = el;\n p.path = path;\n p.textpath = o;\n p.type = \"text\";\n p.attrs.text = Str(text);\n p.attrs.x = x;\n p.attrs.y = y;\n p.attrs.w = 1;\n p.attrs.h = 1;\n setFillAndStroke(p, attr);\n el.appendChild(o);\n el.appendChild(path);\n vml.canvas.appendChild(el);\n var skew = createNode(\"skew\");\n skew.on = true;\n el.appendChild(skew);\n p.skew = skew;\n p.transform(E);\n return p;\n };\n R._engine.setSize = function (width, height) {\n var cs = this.canvas.style;\n this.width = width;\n this.height = height;\n width == +width && (width += \"px\");\n height == +height && (height += \"px\");\n cs.width = width;\n cs.height = height;\n cs.clip = \"rect(0 \" + width + \" \" + height + \" 0)\";\n if (this._viewBox) {\n R._engine.setViewBox.apply(this, this._viewBox);\n }\n return this;\n };\n R._engine.setViewBox = function (x, y, w, h, fit) {\n R.eve(\"raphael.setViewBox\", this, this._viewBox, [x, y, w, h, fit]);\n var width = this.width,\n height = this.height,\n size = 1 / mmax(w / width, h / height),\n H, W;\n if (fit) {\n H = height / h;\n W = width / w;\n if (w * H < width) {\n x -= (width - w * H) / 2 / H;\n }\n if (h * W < height) {\n y -= (height - h * W) / 2 / W;\n }\n }\n this._viewBox = [x, y, w, h, !!fit];\n this._viewBoxShift = {\n dx: -x,\n dy: -y,\n scale: size\n };\n this.forEach(function (el) {\n el.transform(\"...\");\n });\n return this;\n };\n var createNode;\n R._engine.initWin = function (win) {\n var doc = win.document;\n doc.createStyleSheet().addRule(\".rvml\", \"behavior:url(#default#VML)\");\n try {\n !doc.namespaces.rvml && doc.namespaces.add(\"rvml\", \"urn:schemas-microsoft-com:vml\");\n createNode = function (tagName) {\n return doc.createElement('<rvml:' + tagName + ' class=\"rvml\">');\n };\n } catch (e) {\n createNode = function (tagName) {\n return doc.createElement('<' + tagName + ' xmlns=\"urn:schemas-microsoft.com:vml\" class=\"rvml\">');\n };\n }\n };\n R._engine.initWin(R._g.win);\n R._engine.create = function () {\n var con = R._getContainer.apply(0, arguments),\n container = con.container,\n height = con.height,\n s,\n width = con.width,\n x = con.x,\n y = con.y;\n if (!container) {\n throw new Error(\"VML container not found.\");\n }\n var res = new R._Paper,\n c = res.canvas = R._g.doc.createElement(\"div\"),\n cs = c.style;\n x = x || 0;\n y = y || 0;\n width = width || 512;\n height = height || 342;\n res.width = width;\n res.height = height;\n width == +width && (width += \"px\");\n height == +height && (height += \"px\");\n res.coordsize = zoom * 1e3 + S + zoom * 1e3;\n res.coordorigin = \"0 0\";\n res.span = R._g.doc.createElement(\"span\");\n res.span.style.cssText = \"position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;\";\n c.appendChild(res.span);\n cs.cssText = R.format(\"top:0;left:0;width:{0};height:{1};display:inline-block;position:relative;clip:rect(0 {0} {1} 0);overflow:hidden\", width, height);\n if (container == 1) {\n R._g.doc.body.appendChild(c);\n cs.left = x + \"px\";\n cs.top = y + \"px\";\n cs.position = \"absolute\";\n } else {\n if (container.firstChild) {\n container.insertBefore(c, container.firstChild);\n } else {\n container.appendChild(c);\n }\n }\n res.renderfix = function () {};\n return res;\n };\n R.prototype.clear = function () {\n R.eve(\"raphael.clear\", this);\n this.canvas.innerHTML = E;\n this.span = R._g.doc.createElement(\"span\");\n this.span.style.cssText = \"position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;\";\n this.canvas.appendChild(this.span);\n this.bottom = this.top = null;\n };\n R.prototype.remove = function () {\n R.eve(\"raphael.remove\", this);\n this.canvas.parentNode.removeChild(this.canvas);\n for (var i in this) {\n this[i] = typeof this[i] == \"function\" ? R._removedFactory(i) : null;\n }\n return true;\n };\n\n var setproto = R.st;\n for (var method in elproto) if (elproto[has](method) && !setproto[has](method)) {\n setproto[method] = (function (methodname) {\n return function () {\n var arg = arguments;\n return this.forEach(function (el) {\n el[methodname].apply(el, arg);\n });\n };\n })(method);\n }\n}(Raphael);\n\n// BROWSERIFY MOD: export Raphael\nif (typeof module !== 'undefined') {\n module.exports = Raphael;\n}\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/raphael-browserify/raphael-browserify.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/point-generator/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {\"main\":\"index\"}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/point-generator/package.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/point-generator/index.js",Function(['require','module','exports','__dirname','__filename','process','global'],"var extend = require(\"xtend\")\n , EventEmitter = require(\"events\").EventEmitter\n\n , defaults = {\n tick: 1000\n , density: 3\n }\n\nmodule.exports = generator\n\nfunction generator(world, options) {\n var center = world.center\n , list = world.list\n , width = world.width\n , height = world.height\n , gen = new EventEmitter()\n\n options = extend(defaults, options || {})\n\n setInterval(function () {\n var count = 0\n\n list.forEach(function (tuple) {\n var relative = tuple[0]\n , x = relative.x\n , y = relative.y\n\n if (0 < x && x < width && 0 < y && y < height) {\n count++\n }\n })\n\n if (count < options.density) {\n var x = Math.floor(Math.random() * width)\n , y = Math.floor(Math.random() * height)\n\n x = center.x + x - (width / 2)\n y = center.y + y - (height / 2)\n\n gen.emit(\"item\", {\n x: x\n , y: y\n })\n }\n }, options.tick)\n\n return gen\n}\n\nfunction size(p) { return { x: p.x, y: p.y } }\n\nfunction mapsize(list) {\n return list.map(function (tuple) {\n return size(tuple[1])\n })\n}\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/point-generator/index.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/point-generator/node_modules/xtend/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {\"main\":\"index\"}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/point-generator/node_modules/xtend/package.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/point-generator/node_modules/xtend/index.js",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = extend\n\nfunction extend(target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i],\n keys = Object.keys(source)\n\n for (var j = 0; j < keys.length; j++) {\n var name = keys[j]\n target[name] = source[name]\n }\n }\n\n return target\n}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/point-generator/node_modules/xtend/index.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/deck/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {\"main\":\"./index.js\"}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/deck/package.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/deck/index.js",Function(['require','module','exports','__dirname','__filename','process','global'],"var exports = module.exports = function (xs) {\n if (typeof xs !== 'object') { // of which Arrays are\n throw new TypeError('Must be an Array or an object');\n }\n \n return Object.keys(exports).reduce(function (acc, name) {\n acc[name] = exports[name].bind(null, xs);\n return acc;\n }, {});\n};\n\nexports.shuffle = function (xs) {\n if (Array.isArray(xs)) {\n // uniform shuffle\n var res = xs.slice();\n for (var i = res.length - 1; i >= 0; i--) {\n var n = Math.floor(Math.random() * i);\n var t = res[i];\n res[i] = res[n];\n res[n] = t;\n }\n return res;\n }\n else if (typeof xs === 'object') {\n // weighted shuffle\n var weights = Object.keys(xs).reduce(function (acc, key) {\n acc[key] = xs[key];\n return acc;\n }, {});\n \n var ret = [];\n \n while (Object.keys(weights).length > 0) {\n var key = exports.pick(weights);\n delete weights[key];\n ret.push(key);\n }\n \n return ret;\n }\n else {\n throw new TypeError('Must be an Array or an object');\n }\n};\n\nexports.pick = function (xs) {\n if (Array.isArray(xs)) {\n // uniform sample\n return xs[Math.floor(Math.random() * xs.length)];\n }\n else if (typeof xs === 'object') {\n // weighted sample\n var weights = exports.normalize(xs);\n if (!weights) return undefined;\n \n var n = Math.random();\n var threshold = 0;\n var keys = Object.keys(weights);\n \n for (var i = 0; i < keys.length; i++) {\n threshold += weights[keys[i]];\n if (n < threshold) return keys[i];\n }\n throw new Error('Exceeded threshold. Something is very wrong.');\n }\n else {\n throw new TypeError('Must be an Array or an object');\n }\n};\n\nexports.normalize = function (weights) {\n if (typeof weights !== 'object' || Array.isArray(weights)) {\n throw 'Not an object'\n }\n \n var keys = Object.keys(weights);\n if (keys.length === 0) return undefined;\n \n var total = keys.reduce(function (sum, key) {\n var x = weights[key];\n if (x < 0) {\n throw new Error('Negative weight encountered at key ' + key);\n }\n else if (typeof x !== 'number') {\n throw new TypeError('Number expected, got ' + typeof x);\n }\n else {\n return sum + x;\n }\n }, 0);\n \n return total === 1\n ? weights\n : keys.reduce(function (acc, key) {\n acc[key] = weights[key] / total;\n return acc;\n }, {})\n ;\n};\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/deck/index.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/browser/entities/index.js",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {\n tree: require(\"./tree\")\n , rock: require(\"./rock\")\n , wizard: require(\"./wizard\")\n , monster: require(\"./monster\")\n}\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/browser/entities/index.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/browser/entities/tree.js",Function(['require','module','exports','__dirname','__filename','process','global'],"var Sprite = require(\"./sprite\")\n\nmodule.exports = tree\n\nfunction tree(paper, relative, row) {\n \n var entity = Sprite(paper, relative, {\n files : { tree : [\n { file : '/tree.png', width: 121, height : 281 }\n ] }\n , computeKey : function () { return 'tree' }\n , row : row\n })\n\n return entity\n}\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/browser/entities/tree.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/browser/entities/sprite.js",Function(['require','module','exports','__dirname','__filename','process','global'],"var EventEmitter = require('events').EventEmitter;\n\nmodule.exports = createSprite\n\nfunction createSprite (paper, relative, opts) {\n var hidden = true\n var row = opts.row\n var files = opts.files\n var computeKey = opts.computeKey || String;\n\n var entity = new EventEmitter\n entity.cleanup = cleanup\n entity.color = opts.color || 'purple'\n entity.direction = 'front'\n entity.last = Date.now\n\n console.log(\"paper\", paper)\n\n var messageBack = paper.rect(relative.x, relative.y - 10, 200, 20)\n messageBack.attr('fill', 'transparent')\n messageBack.attr('stroke', 'transparent')\n\n var messageText = paper.text(\n relative.x + files[Object.keys(opts.files)[0]][0].width / 2,\n relative.y - 10,\n row.state.message && row.state.message.text\n ? row.state.message.text : ''\n )\n\n function resizeMessage () {\n var s = messageText.attr('text')\n\n var cols = Math.max.apply(null, s.split('\\n')\n .map(function (line) { return line.length })\n )\n var rows = s.split('\\n').length\n var w = cols * 8, h = rows * 12\n\n messageBack.attr('width', w)\n messageBack.attr('height', h)\n messageBack.attr('x', messageText.attr('x') - w / 2)\n messageBack.attr('y', messageText.attr('y') - h / 2)\n }\n\n var lastPos = { x : row.state.x, y : row.state.y }\n\n row.on('change', onchange)\n\n if (relative.on) {\n relative.on('visible', onvisible)\n relative.on('invisible', onhide)\n }\n else hidden = false\n\n var sprites = Object.keys(files).reduce(function (acc, key) {\n acc[key] = files[key].map(function (r) {\n var im = paper.image(\n r.file, relative.x, relative.y,\n r.width, r.height\n ).hide()\n\n im.click(function (ev) {\n entity.emit('click', ev)\n })\n return im\n })\n return acc\n }, {})\n\n var prev = sprites[computeKey(entity.direction)][0].show()\n var animate = (function () {\n var ix = 0\n return function (override) {\n if (hidden) return\n if (override || Date.now() - entity.last < 100) {\n var xs = sprites[computeKey(entity.direction)]\n if (xs) {\n if (prev) prev.hide()\n prev = xs[++ix % xs.length].show()\n }\n }\n }\n })()\n var iv = setInterval(animate, 100)\n entity.animate = animate\n\n if (typeof relative === 'function') relative(onrelative)\n\n return entity\n\n function onrelative (pos) {\n Object.keys(sprites).forEach(function (key) {\n sprites[key].forEach(function (sprite, ix) {\n sprite.attr('x', pos.x - files[key][ix].width / 2)\n sprite.attr('y', pos.y - files[key][ix].height / 2)\n })\n })\n\n messageText.attr('x', pos.x)\n messageText.attr('y', pos.y - 80)\n resizeMessage()\n }\n\n function cleanup() {\n clearInterval(iv)\n\n messageText.remove()\n messageBack.remove()\n\n row.removeListener('change', onchange)\n relative.removeListener('visible', onvisible)\n relative.removeListener('invisible', onhide)\n\n Object.keys(sprites).forEach(function (key) {\n sprites[key].forEach(function (sprite) {\n sprite.remove()\n })\n })\n }\n\n function onvisible() {\n hidden = false\n var xs = sprites[computeKey(entity.direction)]\n if (xs) {\n if (prev) prev.hide()\n prev = xs[0].show()\n }\n\n messageText.show()\n messageBack.show()\n }\n\n function onhide() {\n hidden = true\n Object.keys(sprites).forEach(function (key) {\n sprites[key].forEach(function (sprite) {\n sprite.hide()\n })\n })\n\n messageText.hide()\n messageBack.hide()\n }\n\n function onchange (ch) {\n if (ch.color) {\n if (prev) prev.hide()\n prev = sprites[computeKey(entity.direction)][0].show()\n }\n\n if (ch.message && typeof ch.message === 'object') {\n messageBack.toFront()\n messageText.toFront()\n\n messageText.attr('text', String(ch.message.text || ''))\n messageText.attr('stroke', ch.message.stroke || 'red')\n foreground(messageBack)\n foreground(messageText)\n\n if (ch.message.fill) {\n messageBack.attr('fill', 'rgba(0,0,0,1)') // reset opacity\n messageBack.attr('fill', ch.message.fill)\n resizeMessage()\n }\n else messageBack.attr('fill', 'transparent')\n }\n\n if (ch.x === undefined || ch.y === undefined) return\n\n var delta = {\n x: lastPos.x - row.state.x\n , y: lastPos.y - row.state.y\n }\n if (delta.x === 0 && delta.y === 0) return\n\n lastPos = ch\n\n var key = ''\n if (delta.x) key = 'x' + (delta.x > 0 ? 1 : -1)\n else if (delta.y) key = 'y' + (delta.y > 0 ? 1 : -1)\n\n var d = {\n 'x1': 'left'\n , 'x-1': 'right'\n , 'y-1': 'front'\n , 'y1' : 'back'\n }[key]\n\n entity.last = Date.now()\n if (entity.direction !== d) animate()\n entity.direction = d\n }\n}\n\nfunction foreground(item) {\n item.node.parentNode.appendChild(item.node)\n}\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/browser/entities/sprite.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/browser/entities/rock.js",Function(['require','module','exports','__dirname','__filename','process','global'],"var Sprite = require(\"./sprite\")\n\nmodule.exports = rock\n\nfunction rock(paper, relative, row) {\n var r = [\n { file : '/rock_0.png', width: 100, height : 74 }\n , { file : '/rock_1.png', width: 122, height : 50 }\n ][Math.floor(Math.random() * 2)]\n\n var entity = Sprite(paper, relative, {\n files : { rock : [ r ] }\n , computeKey : function () { return 'rock' }\n , row : row\n })\n\n return entity\n}\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/browser/entities/rock.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/browser/entities/wizard.js",Function(['require','module','exports','__dirname','__filename','process','global'],"var Sprite = require('./sprite')\n\nmodule.exports = wizard\n\nfunction wizard(paper, relative, row) {\n var colors = [ 'purple', 'green', 'orange' ]\n var directions = [ 'front', 'back', 'left', 'right' ]\n \n var files = colors.reduce(function (acc, color) {\n directions.forEach(function (dir) {\n var key = color + '_' + dir\n acc[key] = []\n \n for (var i = 0; i < 2; i++) {\n acc[key].push({\n file : '/wizard_' + key + '_' + i + '.png'\n , width : 86\n , height : 135\n })\n }\n })\n return acc\n }, {})\n \n var opts = {\n files: files\n , computeKey: function (direction) {\n return row.state.color + '_' + direction\n }\n , row : row\n }\n \n var entity = Sprite(paper, relative, opts)\n return entity\n}\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/browser/entities/wizard.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/browser/entities/monster.js",Function(['require','module','exports','__dirname','__filename','process','global'],"var Sprite = require(\"./sprite\")\n\nmodule.exports = monster\n\nfunction monster(paper, relative, row) {\n var rs = [\n { file : '/monster_0.png', width: 150, height : 115 }\n ]\n var r = rs[Math.floor(Math.random() * rs.length)]\n\n var entity = Sprite(paper, relative, {\n files : { monster : [ r ] }\n , computeKey : function () { return 'monster' }\n , row : row\n })\n\n return entity\n}\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/browser/entities/monster.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/browser/ui/playerRepl.js",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = PlayerRepl\n\nfunction PlayerRepl(row) {\n var div = document.createElement(\"input\")\n div.className = \"repl\"\n div.value = 'self.say(\"oh hello\")'\n document.querySelector('#controls').appendChild(div)\n \n div.addEventListener(function (ev) {\n ev.stopPropagation()\n console.log('stop!')\n })\n\n div.onkeyup = function (e) {\n if(e.keyCode == 13) { //enter\n row.set({cast: e.target.value, run: true})\n }\n }\n\n}\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/browser/ui/playerRepl.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/browser/name.js",Function(['require','module','exports','__dirname','__filename','process','global'],"/*global name:true*/\n\nvar EventEmitter = require('events').EventEmitter\n\nvar uuid = require(\"node-uuid\")\nvar store = require(\"local-store\")(\"player-name\")\n\nvar newPlayer = false\n\nvar name = store.get(\"name\")\n\nif (!name) {\n name = uuid().substring(0,4)\n store.set(\"name\", name)\n newPlayer = true\n}\n\nvar colors = [ 'purple', 'green', 'orange' ]\n\nexports = module.exports = new EventEmitter\nexports.name = name\nexports.newPlayer = newPlayer\nexports.displayName = null\nexports.color = colors[Math.floor(Math.random() * colors.length)]\n\nexports.setColor = function (c) {\n exports.color = c\n this.emit('color', c)\n}\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/browser/name.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/local-store/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {\"main\":\"index\"}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/local-store/package.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/local-store/index.js",Function(['require','module','exports','__dirname','__filename','process','global'],"var LocalStorage = typeof window !== \"undefined\" && window.localStorage\n , prefixes = {}\n , store\n\nif (LocalStorage) {\n store = createLocalStore\n} else {\n store = createMemoryStore\n}\n\nstore.createMemoryStore = createMemoryStore\nstore.createLocalStore = createLocalStore\n\nmodule.exports = store\n\nfunction createLocalStore(prefix) {\n prefix = prefix || \"\"\n\n return {\n set: storeSet\n , get: storeGet\n , delete: storeDelete\n }\n\n function storeSet(key, value) {\n LocalStorage.setItem(prefix + \".\" + key, JSON.stringify(value))\n }\n\n function storeGet(key) {\n var str = LocalStorage.getItem(prefix + \".\" + key)\n if (str === null) {\n return null\n }\n return JSON.parse(str)\n }\n\n function storeDelete(key) {\n return LocalStorage.removeItem(prefix + \".\" + key)\n }\n}\n\nfunction createMemoryStore(prefix) {\n var store = {}\n if (prefix) {\n store = prefixes[prefix]\n\n if (!store) {\n store = prefixes[prefix] = {}\n }\n }\n\n return {\n set: storeSet\n , get: storeGet\n , delete: storeDelete\n }\n\n function storeSet(key, value) {\n store[key] = value\n }\n\n function storeGet(key) {\n if (!(key in store)) {\n return null\n }\n\n return store[key]\n }\n\n function storeDelete(key) {\n return delete store[key]\n }\n}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/local-store/index.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/browser/ui/renderPlayer.js",Function(['require','module','exports','__dirname','__filename','process','global'],"var once = require(\"once\")\n\nvar Player = require(\"../entities/player\")\n\nmodule.exports = renderPlayer\n\nfunction renderPlayer(paper, absolute, row) {\n row.on(\"change\", function (changes) {\n if (changes.displayName) {\n entity.setName(changes.displayName)\n }\n\n absolute(changes)\n })\n\n var entity = Player(paper, {\n x: row.state.x || (paper.width - 80) / 2\n , y: row.state.y || (paper.height - 130) / 2\n }, row)\n\n var speed = 5\n entity.on(\"change\", function (changes) {\n var pos = {\n x: absolute.x\n , y: absolute.y\n }\n\n if (changes.x) {\n pos.x += changes.x * speed\n }\n\n if (changes.y) {\n pos.y += changes.y * speed\n }\n\n row.set(pos)\n })\n\n return entity\n}\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/browser/ui/renderPlayer.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/once/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {\"main\":\"once.js\"}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/once/package.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/once/once.js",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = once\n\nonce.proto = once(function () {\n Object.defineProperty(Function.prototype, 'once', {\n value: function () {\n return once(this)\n },\n configurable: true\n })\n})\n\nfunction once (fn) {\n var called = false\n return function () {\n if (called) return\n called = true\n return fn.apply(this, arguments)\n }\n}\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/once/once.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/browser/entities/player.js",Function(['require','module','exports','__dirname','__filename','process','global'],"var EventEmitter = require(\"events\").EventEmitter\nvar ArrowKeys = require(\"../../../vendor/arrow-keys\")\nvar NAME = require('../name')\n\nvar Sprite = require('./sprite')\n\nmodule.exports = player\n\nfunction player(paper, relative, row) {\n var directions = [ 'front', 'back', 'left', 'right' ]\n var colors = [ 'purple', 'green', 'orange' ]\n\n var files = colors.reduce(function (acc, color) {\n directions.forEach(function (dir) {\n var key = color + '_' + dir\n acc[key] = []\n\n for (var i = 0; i < 2; i++) {\n acc[key].push({\n file : '/wizard_' + key + '_' + i + '.svg'\n , width : 86\n , height : 133\n })\n }\n })\n return acc\n }, {})\n\n var opts = {\n files: files\n , computeKey: function (direction) {\n return row.state.color + '_' + direction\n }\n , row : row\n }\n\n var entity = Sprite(paper, relative, opts)\n var keys = ArrowKeys(60)\n\n keys.on('change', function (coords, ev) {\n var key = \"\"\n if (coords.x) {\n key = \"x\" + (coords.x > 0 ? 1 : -1)\n } else if (coords.y) {\n key = \"y\" + (coords.y > 0 ? 1 : -1)\n }\n else return\n\n var d = {\n 'x1' : 'right',\n 'x-1' : 'left',\n 'y-1' : 'back',\n 'y1' : 'front',\n }[key]\n\n entity.last = Date.now()\n if (entity.direction !== d) {\n entity.direction = d\n entity.animate()\n }\n\n entity.emit('change', coords)\n })\n\n row.set({ message : {\n text : 'YOU ARE A WIZARD',\n fill : 'blue',\n stroke : 'yellow'\n }})\n\n setTimeout(function () {\n row.set({ message : {} })\n }, 3000)\n\n entity.setName = function (name) {\n NAME.emit('name', name)\n }\n\n return entity\n}\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/browser/entities/player.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/vendor/arrow-keys/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {\"main\":\"index\"}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/vendor/arrow-keys/package.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/vendor/arrow-keys/index.js",Function(['require','module','exports','__dirname','__filename','process','global'],"var EventEmitter = require(\"events\").EventEmitter\n , uuid = require(\"node-uuid\")\n\n , KEYS = {\n \"37\": \"left\"\n , \"38\": \"up\"\n , \"39\": \"right\"\n , \"40\": \"down\"\n }\n\nmodule.exports = ArrowKeys\n\nfunction ArrowKeys(fps, source) {\n if (!source) source = window\n\n var id = uuid()\n , emitter = new EventEmitter()\n , down = {}\n\n source.addEventListener(\"keyup\", onup)\n source.addEventListener(\"keydown\", ondown)\n\n fps = fps || 60\n\n var timeOffset = 1000.0 / fps\n\n setTimeout(move, timeOffset)\n\n return emitter\n\n function move() {\n var changes = getChanges()\n\n if (changes !== null) {\n emitter.emit(\"change\", changes)\n }\n\n setTimeout(move, timeOffset)\n }\n\n function ondown(event) {\n if (ignore(event)) return\n var key = KEYS[event.which]\n down[key] = true\n }\n\n function onup(event) {\n var key = KEYS[event.which]\n down[key] = false\n }\n\n function getChanges() {\n var x, y\n if (down.up) {\n y = -1\n } else if (down.down) {\n y = 1\n }\n\n if (down.left) {\n x = -1\n } else if (down.right) {\n x = 1\n }\n\n if (!x && !y) {\n return null\n }\n\n return {\n x: x\n , y: y\n }\n }\n\n function ignore (ev) {\n var t = ev.target\n return t.tagName === 'INPUT' || t.tagName === 'TEXTAREA'\n }\n}\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/vendor/arrow-keys/index.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/browser/ui/top_bar.js",Function(['require','module','exports','__dirname','__filename','process','global'],"var unpack = require(\"unpack-element\")\nvar Element = require(\"fragment\").Element\nvar EventEmitter = require(\"events\").EventEmitter\nvar ever = require(\"ever\")\n\n// Dirty hack\nvar NAME = require(\"../name\")\nvar loginHtml = require(\"./html/login\")\n\nmodule.exports = TopBar\n\nfunction TopBar(row) {\n var elements = html(loginHtml)\n , component = new EventEmitter()\n\n elements.id.textContent = JSON.stringify(row.state.id)\n\n var colors = [ \"purple\", \"green\", \"orange\" ]\n colors.forEach(function (color) {\n var div = document.createElement(\"div\")\n elements.colors.appendChild(div)\n div.className = 'color ' + color\n\n function setActive() {\n var prev = elements.colors.querySelector('.color.active')\n if (prev) prev.className = prev.className\n .split(' ')\n .filter(function (x) { return x !== 'active' })\n .join(' ')\n ;\n div.className += ' active'\n }\n\n NAME.on(\"color\", function (c) {\n if (color === c) setActive()\n })\n \n ever(div).on(\"click\", function (ev) {\n NAME.setColor(color)\n })\n if (color === NAME.color) setActive()\n })\n\n row.on('change', function (ch) {\n if (ch.magic) elements.magic.textContent = JSON.stringify(ch)\n })\n \n submit(elements.field, elements.button, function (value) {\n NAME.displayName = value\n component.emit(\"name\", value)\n NAME.emit('name', value)\n })\n\n NAME.on('name', function (name) {\n elements.login.style.display = 'none'\n NAME.displayName = name\n elements.name.textContent = JSON.stringify(name)\n elements.name.style.display = 'inline'\n })\n\n component.root = elements.root\n\n return component\n}\n\nfunction submit(field, button, callback) {\n var ENTER = 13\n\n ever(field).on(\"keyup\", function (ev) {\n if (ev.which === ENTER) {\n callback(field.value)\n }\n })\n\n ever(button).on(\"click\", function (ev) {\n callback(field.value)\n })\n}\n\nfunction html(source) {\n return unpack(Element(source))\n}\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/browser/ui/top_bar.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/unpack-element/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {\"main\":\"index\"}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/unpack-element/package.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/unpack-element/index.js",Function(['require','module','exports','__dirname','__filename','process','global'],"var walk = require(\"dom-walk\")\n , forEach = require(\"for-each\")\n\nmodule.exports = unpack\n\nfunction unpack(elem, mapping) {\n var struct = {}\n\n walk([elem], findChildren)\n\n if (!struct.root) {\n struct.root = elem\n }\n\n if (mapping) {\n forEach(mapping, findElement)\n }\n\n return struct\n\n function findChildren(node) {\n if (node.id) {\n var id = node.id\n node.removeAttribute(\"id\")\n struct[id] = node\n }\n }\n\n function findElement(className, key) {\n var children = elem.getElementsByClassName(className)\n struct[key] = children[0]\n }\n}\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/unpack-element/index.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/unpack-element/node_modules/dom-walk/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {\"main\":\"index\"}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/unpack-element/node_modules/dom-walk/package.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/unpack-element/node_modules/dom-walk/index.js",Function(['require','module','exports','__dirname','__filename','process','global'],"var slice = Array.prototype.slice\n\nmodule.exports = iterativelyWalk\n\nfunction iterativelyWalk(nodes, cb) {\n nodes = slice.call(nodes)\n\n while(nodes.length) {\n var node = nodes.shift(),\n ret = cb(node)\n\n if (ret) {\n return ret\n }\n\n if (node.childNodes.length) {\n nodes = slice.call(node.childNodes).concat(nodes)\n }\n }\n}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/unpack-element/node_modules/dom-walk/index.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/unpack-element/node_modules/for-each/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {\"main\":\"index\"}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/unpack-element/node_modules/for-each/package.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/unpack-element/node_modules/for-each/index.js",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = forEach\n\nfunction forEach(list, iterator, context) {\n var keys = Object.keys(list)\n\n if (arguments.length < 3) {\n context = this\n }\n\n for (var i = 0, len = keys.length; i < len; i++) {\n var key = keys[i]\n , value = list[key]\n\n iterator.call(context, value, key, list)\n }\n}\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/unpack-element/node_modules/for-each/index.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/fragment/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/fragment/package.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/fragment/index.js",Function(['require','module','exports','__dirname','__filename','process','global'],"Fragment.Element = Element\n\nmodule.exports = Fragment\n\nfunction Fragment(html, elementName) {\n var el = document.createElement(elementName || \"div\")\n , fragment = document.createDocumentFragment()\n\n el.innerHTML = html\n\n while (el.hasChildNodes()) {\n fragment.appendChild(el.firstChild)\n }\n\n return fragment\n}\n\nfunction Element(html, elementName) {\n var el = document.createElement(elementName || \"div\")\n\n el.innerHTML = html\n\n var child = el.firstChild\n el.removeChild(child)\n\n return child\n}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/fragment/index.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/ever/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {\"main\":\"index.js\"}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/ever/package.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/ever/index.js",Function(['require','module','exports','__dirname','__filename','process','global'],"var EventEmitter = require('events').EventEmitter;\n\nmodule.exports = function (elem) {\n return new Ever(elem);\n};\n\nfunction Ever (elem) {\n this.element = elem;\n}\n\nEver.prototype = new EventEmitter;\n\nEver.prototype.on = function (name, cb) {\n if (!this._events) this._events = {};\n if (!this._events[name]) this._events[name] = [];\n this._events[name].push(cb);\n this.element.addEventListener(name, cb);\n};\nEver.prototype.addListener = Ever.prototype.on;\n\nEver.prototype.removeListener = function (type, listener, useCapture) {\n if (!this._events) this._events = {};\n this.element.removeEventListener(type, listener, useCapture);\n \n var xs = this.listeners(type);\n var ix = xs.indexOf(listener);\n if (ix >= 0) xs.splice(ix, 1);\n};\n\nEver.prototype.removeAllListeners = function (type) {\n var self = this;\n function removeAll (t) {\n var xs = self.listeners(t);\n for (var i = 0; i < xs.length; i++) {\n self.removeListener(t, xs[i]);\n }\n }\n \n if (type) {\n removeAll(type)\n }\n else if (self._events) {\n for (var key in self._events) {\n if (key) removeAll(key);\n }\n }\n EventEmitter.prototype.removeAllListeners.apply(self, arguments);\n}\n\nvar initSignatures = require('./init.json');\n\nEver.prototype.emit = function (name, ev) {\n if (typeof name === 'object') {\n ev = name;\n name = ev.type;\n }\n \n if (!isEvent(ev)) {\n var type = Ever.typeOf(name);\n \n var opts = ev || {};\n if (opts.type === undefined) opts.type = name;\n \n ev = document.createEvent(type + 's');\n var init = typeof ev['init' + type] === 'function'\n ? 'init' + type : 'initEvent'\n ;\n \n var sig = initSignatures[init];\n var used = {};\n var args = [];\n \n for (var i = 0; i < sig.length; i++) {\n var key = sig[i];\n args.push(opts[key]);\n used[key] = true;\n }\n ev[init].apply(ev, args);\n \n // attach remaining unused options to the object\n for (var key in opts) {\n if (!used[key]) ev[key] = opts[key];\n }\n }\n return this.element.dispatchEvent(ev);\n};\n\nfunction isEvent (ev) {\n var s = Object.prototype.toString.call(ev);\n return /\\[object \\S+Event\\]/.test(s);\n}\n\nEver.types = require('./types.json');\nEver.typeOf = (function () {\n var types = {};\n for (var key in Ever.types) {\n var ts = Ever.types[key];\n for (var i = 0; i < ts.length; i++) {\n types[ts[i]] = key;\n }\n }\n \n return function (name) {\n return types[name] || 'Event';\n };\n})();;\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/ever/index.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/ever/init.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {\n \"initEvent\" : [\n \"type\",\n \"canBubble\", \n \"cancelable\"\n ],\n \"initUIEvent\" : [\n \"type\",\n \"canBubble\", \n \"cancelable\", \n \"view\", \n \"detail\"\n ],\n \"initMouseEvent\" : [\n \"type\",\n \"canBubble\", \n \"cancelable\", \n \"view\", \n \"detail\", \n \"screenX\", \n \"screenY\", \n \"clientX\", \n \"clientY\", \n \"ctrlKey\", \n \"altKey\", \n \"shiftKey\", \n \"metaKey\", \n \"button\",\n \"relatedTarget\"\n ],\n \"initMutationEvent\" : [\n \"type\",\n \"canBubble\", \n \"cancelable\", \n \"relatedNode\", \n \"prevValue\", \n \"newValue\", \n \"attrName\", \n \"attrChange\"\n ]\n}\n;\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/ever/init.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/ever/types.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {\n \"MouseEvent\" : [\n \"click\",\n \"mousedown\",\n \"mouseup\",\n \"mouseover\",\n \"mousemove\",\n \"mouseout\"\n ],\n \"KeyEvent\" : [\n \"keydown\",\n \"keyup\",\n \"keypress\"\n ],\n \"MutationEvent\" : [\n \"DOMSubtreeModified\",\n \"DOMNodeInserted\",\n \"DOMNodeRemoved\",\n \"DOMNodeRemovedFromDocument\",\n \"DOMNodeInsertedIntoDocument\",\n \"DOMAttrModified\",\n \"DOMCharacterDataModified\"\n ],\n \"HTMLEvent\" : [\n \"load\",\n \"unload\",\n \"abort\",\n \"error\",\n \"select\",\n \"change\",\n \"submit\",\n \"reset\",\n \"focus\",\n \"blur\",\n \"resize\",\n \"scroll\"\n ],\n \"UIEvent\" : [\n \"DOMFocusIn\",\n \"DOMFocusOut\",\n \"DOMActivate\"\n ]\n}\n;\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/ever/types.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/browser/ui/html/login.js",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = '<div class=\"top\">'\n + '{'\n + '\"<span class=\"key\">name</span>\" : '\n + '<div id=\"login\" class=\"login\">'\n + '<input id=\"field\"/>'\n + '<button id=\"button\">set name</button>'\n + '</div>'\n + '<span id=\"name\" class=\"value\"></span>'\n + ', \"<span class=\"key\">color</span>\" : '\n + '<div id=\"colors\" class=\"color-picker value\"></div>'\n + ', \"<span class=\"key\">id</span>\" : '\n + '<span id=\"id\" class=\"value\"></span>'\n //+ ', \"<span class=\"key\">magic</span>\" : '\n //+ '<span id=\"magic\" class=\"value\">undefined</span>'\n+ ' }</div>'\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/browser/ui/html/login.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/browser/ui/editor.js",Function(['require','module','exports','__dirname','__filename','process','global'],"var ever = require('ever')\nvar deepEqual = require('deep-equal')\n\nmodule.exports = Editor\n\nfunction Editor(world) {\n var display = Display(world)\n var code = Code(world)\n}\n\nvar helpText = require('../../help.json').join('\\n')\n\nconsole.log(\"helpText\", helpText)\n\nfunction Code(world) {\n var ta = document.createElement('textarea')\n ta.className = 'code'\n document.querySelector('#controls').appendChild(ta)\n\n var tj = document.createElement('textarea')\n tj.className = 'json'\n document.querySelector('#controls').appendChild(tj)\n\n var spellbook = document.createElement('div')\n spellbook.className = 'spellbook'\n spellbook.textContent = helpText\n document.querySelector('#controls').appendChild(spellbook)\n\n var tabs = document.createElement('div')\n tabs.className = 'tabs'\n tabs.appendChild(createTab('codex', function () {\n tj.style.display = 'none'\n ta.style.display = 'block'\n spellbook.style.display = 'none'\n }))\n tabs.appendChild(createTab('tome', function () {\n ta.style.display = 'none'\n tj.style.display = 'block'\n spellbook.style.display = 'none'\n }))\n tabs.querySelector('.tab').className = 'tab active'\n tabs.appendChild(createTab('spellbook', function () {\n ta.style.display = 'none'\n tj.style.display = 'none'\n spellbook.style.display = 'block'\n }))\n\n function createTab (txt, cb) {\n var div = document.createElement('div')\n div.className = 'tab'\n div.textContent = txt\n\n div.addEventListener('click', function (ev) {\n var o = tabs.querySelector('.active')\n if (o) o.className = 'tab'\n div.className = 'tab active'\n cb.call(div, ev)\n ever({ codex : ta, tome : tj }[txt]).emit('change')\n })\n\n return div\n }\n\n tabs.appendChild((function () {\n var div = document.createElement('div')\n div.className = 'cast tab'\n div.textContent = 'cast'\n\n div.addEventListener('click', function () {\n var name = document.querySelector('.tab.active').textContent\n console.log('cast ' + name)\n\n if (name === 'codex') {\n current.set({ source : ta.value, run : true })\n }\n else if (name === 'tome') {\n try { next = JSON.parse(tj.value) }\n catch (err) { tj.className = 'json error'; return }\n\n tj.className = 'json'\n\n var ch = Object.keys(current.state).concat(Object.keys(next))\n .reduce(function (acc, key) {\n if (!deepEqual(current.state[key], next[key])) {\n acc[key] = next[key]\n }\n return acc\n }, {})\n ;\n current.set(ch)\n }\n })\n\n var current\n world.on('examine', function (row) { current = row })\n\n function onchange () {\n if (!current) return\n\n var name = document.querySelector('.tab.active').textContent\n if (name === 'codex') {\n try {\n Function(ta.value)\n }\n catch (err) {\n ta.className = 'code error'\n div.className = 'cast tab disable'\n\n return\n }\n ta.className = 'code'\n div.className = 'cast tab'\n }\n else if (name === 'tome') {\n try {\n JSON.parse(tj.value)\n }\n catch (err) {\n tj.className = 'json error'\n div.className = 'cast tab disable'\n return\n }\n tj.className = 'json'\n div.className = 'cast tab'\n }\n }\n\n tj.addEventListener('change', onchange)\n tj.addEventListener('keydown', onchange)\n\n ta.addEventListener('change', onchange)\n ta.addEventListener('keydown', onchange)\n\n return div\n })())\n\n document.querySelector('#controls').appendChild(tabs)\n\n world.on(\"examine\", function (row) {\n world.emit('log', 'examine: '+ (row.id || row))\n if(!row.get || !row.get('source')) return\n\n _row = row\n ta.value = row.get(\"source\")\n tj.value = JSON.stringify(row.state, null, 2)\n\n })\n}\n\nfunction Display(world) {\n var log = document.createElement('pre')\n log.className = 'display'\n document.querySelector('#controls').appendChild(log)\n\n world.on('log', function (s) {\n\n log.appendChild(document.createTextNode(s+'\\n'))\n if(log.childNodes.length > 5)\n log.removeChild(log.firstChild)\n })\n}\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/browser/ui/editor.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/deep-equal/package.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = {\"main\":\"index.js\"}\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/deep-equal/package.json" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/node_modules/deep-equal/index.js",Function(['require','module','exports','__dirname','__filename','process','global'],"var pSlice = Array.prototype.slice;\nvar Object_keys = typeof Object.keys === 'function'\n ? Object.keys\n : function (obj) {\n var keys = [];\n for (var key in obj) keys.push(key);\n return keys;\n }\n;\n\nvar deepEqual = module.exports = function (actual, expected) {\n // 7.1. All identical values are equivalent, as determined by ===.\n if (actual === expected) {\n return true;\n\n } else if (actual instanceof Date && expected instanceof Date) {\n return actual.getTime() === expected.getTime();\n\n // 7.3. Other pairs that do not both pass typeof value == 'object',\n // equivalence is determined by ==.\n } else if (typeof actual != 'object' && typeof expected != 'object') {\n return actual == expected;\n\n // 7.4. For all other Object pairs, including Array objects, equivalence is\n // determined by having the same number of owned properties (as verified\n // with Object.prototype.hasOwnProperty.call), the same set of keys\n // (although not necessarily the same order), equivalent values for every\n // corresponding key, and an identical 'prototype' property. Note: this\n // accounts for both named and indexed properties on Arrays.\n } else {\n return objEquiv(actual, expected);\n }\n}\n\nfunction isUndefinedOrNull(value) {\n return value === null || value === undefined;\n}\n\nfunction isArguments(object) {\n return Object.prototype.toString.call(object) == '[object Arguments]';\n}\n\nfunction objEquiv(a, b) {\n if (isUndefinedOrNull(a) || isUndefinedOrNull(b))\n return false;\n // an identical 'prototype' property.\n if (a.prototype !== b.prototype) return false;\n //~~~I've managed to break Object.keys through screwy arguments passing.\n // Converting to array solves the problem.\n if (isArguments(a)) {\n if (!isArguments(b)) {\n return false;\n }\n a = pSlice.call(a);\n b = pSlice.call(b);\n return deepEqual(a, b);\n }\n try {\n var ka = Object_keys(a),\n kb = Object_keys(b),\n key, i;\n } catch (e) {//happens when one is a string literal and the other isn't\n return false;\n }\n // having the same number of owned properties (keys incorporates\n // hasOwnProperty)\n if (ka.length != kb.length)\n return false;\n //the same set of keys (although not necessarily the same order),\n ka.sort();\n kb.sort();\n //~~~cheap key test\n for (i = ka.length - 1; i >= 0; i--) {\n if (ka[i] != kb[i])\n return false;\n }\n //equivalent values for every corresponding key, and\n //~~~possibly expensive deep test\n for (i = ka.length - 1; i >= 0; i--) {\n key = ka[i];\n if (!deepEqual(a[key], b[key])) return false;\n }\n return true;\n}\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/node_modules/deep-equal/index.js" | |
)); | |
require.define("/Development/Code/Github/Raynos/wizard-game/help.json",Function(['require','module','exports','__dirname','__filename','process','global'],"module.exports = [\n \"// click an item to see\"\n , \"// its source codex\"\n , \"\"\n , \"# spells\"\n , \"\"\n , \"## self.say(msg)\"\n , \"\"\n , \"self.say(String) allows you to print a\"\n , \"message above yourself. Use this to\"\n , \"either talk with other players or\"\n , \"inspect values.\"\n , \"\"\n , \"For example try `self.say(self.id())`\"\n , \"or try `self.say(Object.keys(self))`\"\n , \"\"\n , \"## self.id()\"\n , \"\"\n , \"Prints your id. An entities id is \"\n , \"used to uniquely identify them.\"\n , \"you will need the id to be able\"\n , \"to target other things. Just click\"\n , \"on a thing and look at the tome\"\n , \"to see their id\"\n , \"\"\n , \"## self.whatDist(id)\"\n , \"\"\n , \"Pass in the id of another thing and\"\n , \"get the x,y distance of it. Useful\"\n , \"to move to them\"\n , \"\"\n , \"Try `self.move(self.whatDist(id))`\"\n , \"\"\n , \"## self.move(x,y)\"\n , \"\"\n , \"used to move around relative. Pass it\"\n , \"an x and y that are relative to move\"\n , \"or pass it an `{ x: x, y: y }` to move\"\n , \"\"\n , \"Try `self.move(self.whatDist(id))`\"\n , \"\"\n , \"## self.think(cb)\"\n , \"\"\n , \"You can't have timers or anything fancy\"\n , \"But you can think. this will call your\"\n , \"callback every half second\"\n , \"\"\n , \"## self.hear(cb)\"\n , \"\"\n , \"Listen on anyone saying messages. You\"\n , \"will need to be near them and your\"\n , \"callback gets called with message and\"\n , \"id\"\n , \"\"\n , \"If you want to be an echo player try\"\n , \"self.hear(function (message) {\"\n , \" self.say(message)\"\n , \"})\"\n]\n;\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/help.json" | |
)); | |
require.define("/AppData/Roaming/npm/node_modules/browserify-server/other.js",Function(['require','module','exports','__dirname','__filename','process','global'],"process.env.NODE_ENV = 'undefined'\n\n//@ sourceURL=/AppData/Roaming/npm/node_modules/browserify-server/other.js" | |
)); | |
require("/AppData/Roaming/npm/node_modules/browserify-server/other.js"); | |
require.define("/Development/Code/Github/Raynos/wizard-game/browser/client.js",Function(['require','module','exports','__dirname','__filename','process','global'],"var model = require('../model')\n\nvar reconnect = require('reconnect')\nvar reloader = require('client-reloader')\nvar MuxDemux = require('mux-demux')\nvar ui = require('./ui')\n\n// GLOBAL IDENTITY HACK\nvar NAME = require(\"./name\")\n\nui(model)\n\nreconnect({maxDelay: 3e3}, reloader(function (stream) {\n // console.log(\"mdm\")\n var mdm = MuxDemux()\n\n stream.pipe(mdm).pipe(stream)\n\n var modelStream = mdm.createStream(\"model\")\n modelStream.pipe(model.createStream()).pipe(modelStream)\n\n // console.log(\"name\", NAME)\n\n var idStream = mdm.createStream(\"identity\")\n idStream.write(NAME.name)\n})).connect('/shoe')\n\n//@ sourceURL=/Development/Code/Github/Raynos/wizard-game/browser/client.js" | |
)); | |
require("/Development/Code/Github/Raynos/wizard-game/browser/client.js"); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment